From 7803f31c531c75c75d57513caa14caa934edcf19 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Mon, 7 May 2012 18:27:46 +0200 Subject: Don't reinvent ctype.h functions Remove ctype.h functions in text_editor and rockboy, fix #define name clash in mpegplayer. Change-Id: Icb40cf45e27b793c62cb095197757a27f508f344 --- apps/plugin.h | 1 + apps/plugins/mpegplayer/mpegplayer.c | 32 ++++++++++++++++---------------- apps/plugins/rockboy/rockmacros.h | 6 ------ apps/plugins/text_editor.c | 6 ++---- 4 files changed, 19 insertions(+), 26 deletions(-) (limited to 'apps') diff --git a/apps/plugin.h b/apps/plugin.h index 4091cecc16..3f63b9a749 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -34,6 +34,7 @@ #include #include #include +#include #include "string-extra.h" #include "gcc_extensions.h" diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 033a3ed1cb..928c48ab11 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -526,15 +526,15 @@ static struct fps fps NOCACHEBSS_ATTR; /* Accessed on other processor */ static void osd_show(unsigned show); #ifdef LCD_LANDSCAPE - #define _X (x + osd.x) - #define _Y (y + osd.y) - #define _W width - #define _H height + #define __X (x + osd.x) + #define __Y (y + osd.y) + #define __W width + #define __H height #else - #define _X (LCD_WIDTH - (y + osd.y) - height) - #define _Y (x + osd.x) - #define _W height - #define _H width + #define __X (LCD_WIDTH - (y + osd.y) - height) + #define __Y (x + osd.x) + #define __W height + #define __H width #endif #ifdef HAVE_LCD_COLOR @@ -560,17 +560,17 @@ static unsigned draw_blendcolor(unsigned c1, unsigned c2, unsigned char amount) * The origin is the upper-left corner of the OSD area */ static void draw_update_rect(int x, int y, int width, int height) { - mylcd_update_rect(_X, _Y, _W, _H); + mylcd_update_rect(__X, __Y, __W, __H); } static void draw_clear_area(int x, int y, int width, int height) { #ifdef HAVE_LCD_COLOR - rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H); + rb->screen_clear_area(rb->screens[SCREEN_MAIN], __X, __Y, __W, __H); #else int oldmode = grey_get_drawmode(); grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); - grey_fillrect(_X, _Y, _W, _H); + grey_fillrect(__X, __Y, __W, __H); grey_set_drawmode(oldmode); #endif } @@ -582,7 +582,7 @@ static void draw_clear_area_rect(const struct vo_rect *rc) static void draw_fillrect(int x, int y, int width, int height) { - mylcd_fillrect(_X, _Y, _W, _H); + mylcd_fillrect(__X, __Y, __W, __H); } static void draw_hline(int x1, int x2, int y) @@ -967,10 +967,10 @@ static void fps_update_post_frame_callback(void) int height = cliprect.b - cliprect.t; /* OSD coordinates -> framebuffer coordinates */ - fps.pf_x = _X; - fps.pf_y = _Y; - fps.pf_width = _W; - fps.pf_height = _H; + fps.pf_x = __X; + fps.pf_y = __Y; + fps.pf_width = __W; + fps.pf_height = __H; cb = fps_post_frame_callback; } diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index 87e570b55a..2d3baf1680 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h @@ -52,11 +52,6 @@ void dynamic_recompile (struct dynarec_block *newblock); #define IBSS_ATTR #endif -/* libc functions */ -#define isdigit(c) ((c) >= '0' && (c) <= '9') -#define isalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && ((c) <= 'Z'))) -#define isalnum(c) (isdigit(c) || (isalpha(c))) - /* only 1 fixed argument for open, since variadic macros don't except empty * variable parameters */ #define open(a, ...) rb->open((a), __VA_ARGS__) @@ -79,7 +74,6 @@ void dynamic_recompile (struct dynarec_block *newblock); #define strcat(a,b) rb->strcat((a),(b)) #define snprintf(...) rb->snprintf(__VA_ARGS__) #define fdprintf(...) rb->fdprintf(__VA_ARGS__) -#define tolower(_A_) (isupper(_A_) ? (_A_ - 'A' + 'a') : _A_) /* Using #define isn't enough with GCC 4.0.1 */ void* memcpy(void* dst, const void* src, size_t size) ICODE_ATTR; diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 32013b6f28..6c1136cf48 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -287,12 +287,10 @@ static int do_item_menu(int cur_sel) } #ifdef HAVE_LCD_COLOR -/* in misc.h but no need to polute the api */ -#define toupper(c) (((c >= 'a') && (c <= 'z'))?c+'A':c) -#define isxdigit(c) ((c>='a' && c<= 'f') || (c>='A' && c<= 'F') \ - || (c>='0' && c<= '9')) + #define hex2dec(c) (((c) >= '0' && ((c) <= '9')) ? (toupper(c)) - '0' : \ (toupper(c)) - 'A' + 10) + static int my_hex_to_rgb(const char* hex, int* color) { int ok = 1; int i; -- cgit v1.2.3