From 12085b8014234b10739d5cf22ed6c6d055ce8741 Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 29 Jul 2013 16:25:20 +1000 Subject: [PATCH] Fix compiler warnings, operating system dependancies, and non-portable code. --- src/gdisp/fonts.c | 1 - src/gdisp/mcufont/mf_config.h | 3 +++ src/gdisp/mcufont/mf_encoding.c | 10 ++++++++++ src/gdisp/mcufont/mf_encoding.h | 10 ++-------- src/gdisp/mcufont/mf_font.h | 4 ++-- src/gdisp/mcufont/mf_justify.c | 3 ++- src/gdisp/mcufont/mf_kerning.h | 6 ++---- src/gdisp/mcufont/mf_rlefont.c | 1 + src/gdisp/mcufont/mf_wordwrap.c | 1 - 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/gdisp/fonts.c b/src/gdisp/fonts.c index 8486e1e5..c688137c 100644 --- a/src/gdisp/fonts.c +++ b/src/gdisp/fonts.c @@ -50,7 +50,6 @@ static bool_t matchfont(const char *pattern, const char *name) { font_t gdispOpenFont(const char *name) { const struct mf_font_list_s *fp; - int i; fp = mf_get_font_list(); diff --git a/src/gdisp/mcufont/mf_config.h b/src/gdisp/mcufont/mf_config.h index f9210123..4614fb0c 100644 --- a/src/gdisp/mcufont/mf_config.h +++ b/src/gdisp/mcufont/mf_config.h @@ -12,6 +12,9 @@ #include +/* Prevent double definitions of standard int types */ +#define MF_NO_STDINT_H + /* Mapping from uGFX settings to mcufont settings */ #if GDISP_NEED_UTF8 #define MF_ENCODING MF_ENCODING_UTF8 diff --git a/src/gdisp/mcufont/mf_encoding.c b/src/gdisp/mcufont/mf_encoding.c index f736651b..2c8abf3a 100644 --- a/src/gdisp/mcufont/mf_encoding.c +++ b/src/gdisp/mcufont/mf_encoding.c @@ -73,4 +73,14 @@ void mf_rewind(mf_str *str) (*str)--; } +#else + +mf_char mf_getchar(mf_str *str) { + return *(*str)++; +} + +void mf_rewind(mf_str *str) { + (*str)--; +} + #endif diff --git a/src/gdisp/mcufont/mf_encoding.h b/src/gdisp/mcufont/mf_encoding.h index d2673d16..d8b7b70e 100644 --- a/src/gdisp/mcufont/mf_encoding.h +++ b/src/gdisp/mcufont/mf_encoding.h @@ -13,7 +13,9 @@ #define _MF_ENCODING_H_ #include "mf_config.h" +#ifndef MF_NO_STDINT_H #include +#endif /* Type used to represent characters internally. */ #if MF_ENCODING == MF_ENCODING_ASCII @@ -42,19 +44,11 @@ typedef const wchar_t * mf_str; * * Returns: The next character, as unicode codepoint. */ -#if MF_ENCODING == MF_ENCODING_UTF8 MF_EXTERN mf_char mf_getchar(mf_str *str); -#else -static mf_char mf_getchar(mf_str *str) { return *(*str)++; } -#endif /* Moves back the pointer to the beginning of the previous character. * Be careful not to go beyond the start of the string. */ -#if MF_ENCODING == MF_ENCODING_UTF8 MF_EXTERN void mf_rewind(mf_str *str); -#else -static void mf_rewind(mf_str *str) { (*str)--; } -#endif #endif diff --git a/src/gdisp/mcufont/mf_font.h b/src/gdisp/mcufont/mf_font.h index 0e5612ce..1166fa3b 100644 --- a/src/gdisp/mcufont/mf_font.h +++ b/src/gdisp/mcufont/mf_font.h @@ -120,6 +120,6 @@ MF_EXTERN uint8_t mf_character_width(const struct mf_font_s *font, MF_EXTERN const struct mf_font_s *mf_find_font(const char *name); /* Get the list of included fonts */ -MF_EXTERN const struct mf_font_list_s *mf_get_font_list(); +MF_EXTERN const struct mf_font_list_s *mf_get_font_list(void); -#endif \ No newline at end of file +#endif diff --git a/src/gdisp/mcufont/mf_justify.c b/src/gdisp/mcufont/mf_justify.c index 072eef0c..488478ef 100644 --- a/src/gdisp/mcufont/mf_justify.c +++ b/src/gdisp/mcufont/mf_justify.c @@ -82,7 +82,7 @@ static uint16_t strip_spaces(mf_str text, uint16_t count, mf_char *last_char) { i++; tmp = mf_getchar(&text); - if (tmp != ' ' && tmp != 0xA0 && tmp != '\n' && + if (tmp != ' ' && tmp != (mf_char)0xA0 && tmp != '\n' && tmp != '\r' && tmp != '\t') { result = i; @@ -234,6 +234,7 @@ void mf_render_justified(const struct mf_font_s *font, mf_character_callback_t callback, void *state) { + (void) width; mf_render_aligned(font, x0, y0, MF_ALIGN_LEFT, text, count, callback, state); } diff --git a/src/gdisp/mcufont/mf_kerning.h b/src/gdisp/mcufont/mf_kerning.h index 1014c8dd..043265c7 100644 --- a/src/gdisp/mcufont/mf_kerning.h +++ b/src/gdisp/mcufont/mf_kerning.h @@ -28,9 +28,7 @@ MF_EXTERN int8_t mf_compute_kerning(const struct mf_font_s *font, mf_char c1, mf_char c2); #else -static int8_t mf_compute_kerning(const struct mf_font_s *font, - mf_char c1, mf_char c2) -{ return 0; } +#define mf_compute_kerning(font, c1, c2) 0 #endif -#endif \ No newline at end of file +#endif diff --git a/src/gdisp/mcufont/mf_rlefont.c b/src/gdisp/mcufont/mf_rlefont.c index ec0025dd..ca628674 100644 --- a/src/gdisp/mcufont/mf_rlefont.c +++ b/src/gdisp/mcufont/mf_rlefont.c @@ -160,6 +160,7 @@ static void write_bin_codeword(const struct mf_rlefont_s *font, uint8_t bitcount = fillentry_bitcount(code); uint8_t byte = code - DICT_START7BIT; uint8_t runlen = 0; + (void) font; while (bitcount--) { diff --git a/src/gdisp/mcufont/mf_wordwrap.c b/src/gdisp/mcufont/mf_wordwrap.c index 4650c24a..ebf3a537 100644 --- a/src/gdisp/mcufont/mf_wordwrap.c +++ b/src/gdisp/mcufont/mf_wordwrap.c @@ -227,7 +227,6 @@ void mf_wordwrap(const struct mf_font_s *font, int16_t width, void mf_wordwrap(const struct mf_font_s *font, int16_t width, mf_str text, mf_line_callback_t callback, void *state) { - mf_str orig = text; mf_str linestart; /* Current line width and character count */