summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Tytgat <joty@netsurf-browser.org>2007-06-11 20:47:18 (GMT)
committer John Tytgat <joty@netsurf-browser.org>2007-06-11 20:47:18 (GMT)
commit957d6601bdd4b4b50f7a774f85676f3b7eb685ed (patch)
tree5cf798b85a30962f7027aaf775e38c5e0957a5cf
parentd6af9eba75d0d4b3ddcedbdca884d623545544fa (diff)
downloadlibrufl-957d6601bdd4b4b50f7a774f85676f3b7eb685ed.tar.gz
librufl-957d6601bdd4b4b50f7a774f85676f3b7eb685ed.tar.bz2
- Reduced compiler warnings:
- got rid of aliasing warnings by introducing an extra (void *) casting. - format specifier for 'size_t' type has now 'z' attribute - Injected const attributes (also changing public type rufl_family_list @ rufl.h) - makefile: - support for GCCSDK 3.4 (AOF) and GCCSDK 4 (ELF) based on AB_ELFBUILD (= a variable also used in GCCSDK Autobuilder). - changed the library name from rufl.o to librufl.a. Needed for GCCSDK 4 but if you're using -L<libdir> -lrufl in your link line, this rename make that this works for both GCCSDK 3.4 and GCCSDK 4. [ Also changes for the Norcroft case which haven't been verified and probably no longer working. ] svn path=/trunk/rufl/; revision=3343
-rw-r--r--makefile46
-rw-r--r--rufl.h2
-rw-r--r--rufl_chars.c6
-rw-r--r--rufl_decompose.c8
-rw-r--r--rufl_find.c2
-rw-r--r--rufl_init.c42
-rw-r--r--rufl_paint.c2
-rw-r--r--rufl_quit.c2
-rw-r--r--rufl_test.c4
9 files changed, 65 insertions, 49 deletions
diff --git a/makefile b/makefile
index 1d8e6da..8c86381 100644
--- a/makefile
+++ b/makefile
@@ -14,29 +14,44 @@ SOURCE = rufl_init.c rufl_quit.c rufl_dump_state.c \
rufl_character_set_test.c \
rufl_paint.c rufl_glyph_map.c rufl_invalidate_cache.c \
rufl_find.c rufl_decompose.c rufl_metrics.c
+HDRS = rufl.h rufl_internal.h
+ifeq (${AB_ELFBUILD},yes)
+EXEEXT=,e1f
+else
+EXEEXT=,ff8
+endif
+
+.PHONY: all install clean
ifeq ($(COMPILER), gcc)
# cross-compiling using GCCSDK
GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
GCCSDK_INSTALL_ENV ?= /home/riscos/env
-
+ifeq (${AB_ELFBUILD},yes)
+CC = $(GCCSDK_INSTALL_CROSSBIN)/arm-unknown-riscos-gcc
+AR = $(GCCSDK_INSTALL_CROSSBIN)/arm-unknown-riscos-ar
+else
CC = $(GCCSDK_INSTALL_CROSSBIN)/gcc
+AR = $(GCCSDK_INSTALL_CROSSBIN)/ar
+endif
CFLAGS = -std=c99 -O3 -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
-Wnested-externs -Winline -Wno-unused-parameter \
-mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
+ARFLAGS = cr
LIBS = -L$(GCCSDK_INSTALL_ENV)/lib -lOSLib32
INSTALL = $(GCCSDK_INSTALL_ENV)/ro-install
+OBJS = $(SOURCE:.c=.o)
-all: rufl.o rufl_test,ff8 rufl_chars,ff8
+all: librufl.a rufl_test$(EXEEXT) rufl_chars$(EXEEXT)
-rufl.o: $(SOURCE) rufl.h rufl_internal.h Glyphs
- $(CC) $(CFLAGS) -c -o $@ $(SOURCE)
+librufl.a: $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
-install: rufl.o
- $(INSTALL) rufl.o $(GCCSDK_INSTALL_ENV)/lib/librufl.o
+install: librufl.a
+ $(INSTALL) librufl.a $(GCCSDK_INSTALL_ENV)/lib/librufl.a
$(INSTALL) rufl.h $(GCCSDK_INSTALL_ENV)/include/rufl.h
else
# compiling on RISC OS using Norcroft
@@ -49,19 +64,16 @@ MKDLK = makedlk
SOURCE += strfuncs.c
OBJS = $(SOURCE:.c=.o)
-all: rufl.o rufl/pyd rufl_test,ff8 rufl_chars,ff8
-rufl.o: o.rufl
-o.rufl: $(OBJS) rufl.h rufl_internal.h Glyphs
+all: librufl.a rufl/pyd rufl_test,ff8 rufl_chars,ff8
+
+librufl.a: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
-o.ruflmodule: ruflmodule.o rufl.o
+o.ruflmodule: ruflmodule.o librufl.a
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
ruflmodule.o: ruflmodule.c
$(CC) -fn -wp -IPyInc:Include,PyInc:RISCOS,TCPIPLibs:,OSLib: -c $@ $<
rufl/pyd: o.ruflmodule
$(MKDLK) -s <Python$$Dir>.RISCOS.s.linktab -o $< -d $@ -e initrufl
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
endif
@@ -69,12 +81,14 @@ endif
rufl_glyph_map.c: Glyphs makeglyphs
./makeglyphs < Glyphs > $@
-rufl_test,ff8: rufl_test.c rufl.o
+rufl_test$(EXEEXT): rufl_test.c librufl.a
$(CC) $(CFLAGS) $(LIBS) -o $@ $^
-rufl_chars,ff8: rufl_chars.c rufl.o
+rufl_chars$(EXEEXT): rufl_chars.c librufl.a
$(CC) $(CFLAGS) $(LIBS) -o $@ $^
+.c.o: $(HDRS)
+ $(CC) $(CFLAGS) -c -o $@ $<
clean:
- -rm rufl.o rufl_glyph_map.c rufl_test,ff8 rufl_chars,ff8
+ -rm *.o librufl.a rufl_glyph_map.c rufl_test$(EXEEXT) rufl_chars$(EXEEXT)
diff --git a/rufl.h b/rufl.h
index 1b853d7..767022e 100644
--- a/rufl.h
+++ b/rufl.h
@@ -51,7 +51,7 @@ typedef enum {
extern os_error *rufl_fm_error;
/** List of available font families. */
-extern char **rufl_family_list;
+extern const char **rufl_family_list;
/** Number of entries in rufl_family_list. */
extern unsigned int rufl_family_list_entries;
diff --git a/rufl_chars.c b/rufl_chars.c
index d9b9d6f..440a1d0 100644
--- a/rufl_chars.c
+++ b/rufl_chars.c
@@ -29,7 +29,7 @@ int main(void)
{
unsigned int i;
bool quit = false;
- wimp_MESSAGE_LIST(2) messages = { { message_MODE_CHANGE,
+ const wimp_MESSAGE_LIST(2) messages = { { message_MODE_CHANGE,
message_QUIT } };
wimp_t task;
wimp_menu *menu;
@@ -63,7 +63,7 @@ int main(void)
rufl_code code = rufl_OK;
error = xwimp_initialise(wimp_VERSION_RO3, "RUfl Chars",
- (wimp_message_list *) &messages,
+ (const wimp_message_list *) (const void *) &messages,
0, &task);
if (error) {
printf("error: xwimp_initialise: 0x%x: %s\n",
@@ -126,7 +126,7 @@ int main(void)
if (error)
die(error->errmess);
- error = xwimp_open_window((wimp_open *) &state);
+ error = xwimp_open_window((wimp_open *) (void *) &state);
if (error)
die(error->errmess);
diff --git a/rufl_decompose.c b/rufl_decompose.c
index 5889a7b..edf9748 100644
--- a/rufl_decompose.c
+++ b/rufl_decompose.c
@@ -72,6 +72,7 @@ rufl_code rufl_decompose_glyph(const char *font_family,
{
int *buf, *p, *ep;
int buf_size;
+ char *buf_end;
rufl_code err;
/* Get required buffer size */
@@ -92,14 +93,14 @@ rufl_code rufl_decompose_glyph(const char *font_family,
return err;
}
- rufl_fm_error = xfont_switch_output_to_buffer(0, 0,
- (char **)&buf_size);
+ rufl_fm_error = xfont_switch_output_to_buffer(0, NULL, &buf_end);
if (rufl_fm_error) {
LOG("xfont_switch_output_to_buffer: 0x%x: %s",
rufl_fm_error->errnum,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
+ buf_size = buf_end - (char *)NULL;
/* Allocate and initialise buffer */
buf = malloc(buf_size);
@@ -130,7 +131,7 @@ rufl_code rufl_decompose_glyph(const char *font_family,
return err;
}
- rufl_fm_error = xfont_switch_output_to_buffer(0, 0, (char **)&ep);
+ rufl_fm_error = xfont_switch_output_to_buffer(0, 0, &buf_end);
if (rufl_fm_error) {
LOG("xfont_switch_output_to_buffer: 0x%x: %s",
rufl_fm_error->errnum,
@@ -138,6 +139,7 @@ rufl_code rufl_decompose_glyph(const char *font_family,
free(buf);
return rufl_FONT_MANAGER_ERROR;
}
+ ep = (int *)(void *)buf_end;
/* Parse buffer, calling callbacks as required */
for (p = buf; p < ep;) {
diff --git a/rufl_find.c b/rufl_find.c
index 2ad4c92..6aad027 100644
--- a/rufl_find.c
+++ b/rufl_find.c
@@ -25,7 +25,7 @@ rufl_code rufl_find_font_family(const char *font_family,
rufl_style font_style, unsigned int *font,
unsigned int *slanted, struct rufl_character_set **charset)
{
- char **family;
+ const char **family;
unsigned int f;
unsigned int weight, slant, used_weight;
unsigned int search_direction;
diff --git a/rufl_init.c b/rufl_init.c
index 3ac39a3..6e75758 100644
--- a/rufl_init.c
+++ b/rufl_init.c
@@ -26,7 +26,7 @@
struct rufl_font_list_entry *rufl_font_list = 0;
unsigned int rufl_font_list_entries = 0;
-char **rufl_family_list = 0;
+const char **rufl_family_list = 0;
unsigned int rufl_family_list_entries = 0;
struct rufl_family_map_entry *rufl_family_map = 0;
os_error *rufl_fm_error = 0;
@@ -70,7 +70,7 @@ const struct rufl_weight_table_entry rufl_weight_table[] = {
static rufl_code rufl_init_font_list(void);
-static rufl_code rufl_init_add_font(char *identifier, char *local_name);
+static rufl_code rufl_init_add_font(const char *identifier, const char *local_name);
static int rufl_weight_table_cmp(const void *keyval, const void *datum);
static rufl_code rufl_init_scan_font(unsigned int font);
static bool rufl_is_space(unsigned int u);
@@ -142,7 +142,7 @@ rufl_code rufl_init(void)
xhourglass_off();
return code;
}
- LOG("%u faces, %u families", rufl_font_list_entries,
+ LOG("%u faces, %zu families", rufl_font_list_entries,
rufl_family_list_entries);
code = rufl_load_cache();
@@ -231,12 +231,12 @@ rufl_code rufl_init_font_list(void)
while (context != -1) {
/* read identifier */
- rufl_fm_error = xfont_list_fonts(identifier,
+ rufl_fm_error = xfont_list_fonts((byte *)identifier,
font_RETURN_FONT_NAME |
font_RETURN_LOCAL_FONT_NAME |
context,
sizeof identifier,
- local_name, sizeof local_name, 0,
+ (byte *)local_name, sizeof local_name, 0,
&context, 0, 0);
if (rufl_fm_error) {
LOG("xfont_list_fonts: 0x%x: %s",
@@ -256,13 +256,13 @@ rufl_code rufl_init_font_list(void)
}
-rufl_code rufl_init_add_font(char *identifier, char *local_name)
+rufl_code rufl_init_add_font(const char *identifier, const char *local_name)
{
- size_t size;
+ int size;
struct rufl_font_list_entry *font_list;
char *dot;
- char **family_list;
- char *family, *part;
+ const char **family_list;
+ const char *family, *part;
unsigned int weight = 0;
unsigned int slant = 0;
bool special = false;
@@ -760,7 +760,7 @@ rufl_code rufl_init_substitution_table(void)
rufl_substitution_table = malloc(65536 *
sizeof rufl_substitution_table[0]);
if (!rufl_substitution_table) {
- LOG("malloc(%u) failed", 65536 *
+ LOG("malloc(%zu) failed", 65536 *
sizeof rufl_substitution_table[0]);
return rufl_OUT_OF_MEMORY;
}
@@ -953,7 +953,7 @@ rufl_code rufl_load_cache(void)
identifier = malloc(len + 1);
if (!identifier) {
- LOG("malloc(%u) failed", len + 1);
+ LOG("malloc(%zu) failed", len + 1);
fclose(fp);
return rufl_OUT_OF_MEMORY;
}
@@ -981,7 +981,7 @@ rufl_code rufl_load_cache(void)
charset = malloc(size);
if (!charset) {
- LOG("malloc(%u) failed", size);
+ LOG("malloc(%zu) failed", size);
free(identifier);
fclose(fp);
return rufl_OUT_OF_MEMORY;
@@ -1002,7 +1002,7 @@ rufl_code rufl_load_cache(void)
if (rufl_old_font_manager) {
umap = malloc(sizeof *umap);
if (!umap) {
- LOG("malloc(%u) failed", sizeof *umap);
+ LOG("malloc(%zu) failed", sizeof *umap);
free(charset);
free(identifier);
fclose(fp);
@@ -1066,7 +1066,7 @@ rufl_code rufl_init_family_menu(void)
menu = malloc(wimp_SIZEOF_MENU(rufl_family_list_entries));
if (!menu)
return rufl_OUT_OF_MEMORY;
- menu->title_data.indirected_text.text = "Fonts";
+ menu->title_data.indirected_text.text = (char *) "Fonts";
menu->title_fg = wimp_COLOUR_BLACK;
menu->title_bg = wimp_COLOUR_LIGHT_GREY;
menu->work_fg = wimp_COLOUR_BLACK;
@@ -1082,7 +1082,7 @@ rufl_code rufl_init_family_menu(void)
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
menu->entries[i].data.indirected_text.text =
- rufl_family_list[i];
+ (char *) rufl_family_list[i];
menu->entries[i].data.indirected_text.validation = (char *) -1;
menu->entries[i].data.indirected_text.size =
strlen(rufl_family_list[i]);
@@ -1137,12 +1137,12 @@ void rufl_init_status_open(void)
os_error *error;
window.icons[0].data.indirected_text.text =
- "Scanning fonts - please wait";
- window.icons[0].data.indirected_text.validation = "";
- window.icons[1].data.indirected_text.text = "";
- window.icons[1].data.indirected_text.validation = "r2";
+ (char *) "Scanning fonts - please wait";
+ window.icons[0].data.indirected_text.validation = (char *) "";
+ window.icons[1].data.indirected_text.text = (char *) "";
+ window.icons[1].data.indirected_text.validation = (char *) "r2";
window.icons[3].data.indirected_text.text = rufl_status_buffer;
- window.icons[3].data.indirected_text.validation = "";
+ window.icons[3].data.indirected_text.validation = (char *) "";
xos_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XEIG_FACTOR,
&xeig_factor, 0);
@@ -1181,7 +1181,7 @@ void rufl_init_status_open(void)
xwimp_create_window((const wimp_window *) &window, &rufl_status_w);
state.w = rufl_status_w;
xwimp_get_window_state(&state);
- xwimp_open_window((wimp_open *) &state);
+ xwimp_open_window((wimp_open *) (void *) &state);
}
diff --git a/rufl_paint.c b/rufl_paint.c
index 8371025..8a8392a 100644
--- a/rufl_paint.c
+++ b/rufl_paint.c
@@ -355,7 +355,7 @@ rufl_code rufl_process_span(rufl_action action,
font_RETURN_CARET_POS : 0),
(click_x - *x) * 400, 0x7fffffff, 0, 0,
n * 2,
- (char **) &split_point, &x_out, &y_out, 0);
+ (char **)(void *)&split_point, &x_out, &y_out, 0);
*offset = split_point - s;
} else {
rufl_fm_error = xfont_scan_string(f, (const char *) s,
diff --git a/rufl_quit.c b/rufl_quit.c
index 587e07a..fc429c0 100644
--- a/rufl_quit.c
+++ b/rufl_quit.c
@@ -29,7 +29,7 @@ void rufl_quit(void)
rufl_font_list = 0;
for (i = 0; i != rufl_family_list_entries; i++)
- free(rufl_family_list[i]);
+ free((void *) rufl_family_list[i]);
free(rufl_family_list);
free(rufl_family_map);
rufl_family_list = 0;
diff --git a/rufl_test.c b/rufl_test.c
index a72017f..f07a9b7 100644
--- a/rufl_test.c
+++ b/rufl_test.c
@@ -47,13 +47,13 @@ int main(void)
utf8_test, sizeof utf8_test - 1,
x, &char_offset, &actual_x),
"rufl_x_to_offset");
- printf("x to offset: %i -> %i %i \"%s\"\n", x, actual_x,
+ printf("x to offset: %i -> %i %zi \"%s\"\n", x, actual_x,
char_offset, utf8_test + char_offset);
try(rufl_split("NewHall", rufl_WEIGHT_400, 240,
utf8_test, sizeof utf8_test - 1,
x, &char_offset, &actual_x),
"rufl_split");
- printf("split: %i -> %i %i \"%s\"\n", x, actual_x,
+ printf("split: %i -> %i %zi \"%s\"\n", x, actual_x,
char_offset, utf8_test + char_offset);
}
try(rufl_decompose_glyph("Homerton", rufl_WEIGHT_400, 1280,