From 9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sun, 8 Apr 2007 15:02:26 +0000 Subject: Skip leading UTF8 BOM if present. Fixes the first line of the WPS not being understood as a comment when it is one. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13074 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 15 --------------- apps/gui/wps_parser.c | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 42ba17ad11..62a068f21d 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -60,21 +60,6 @@ /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 -#if 0 -/* Skip leading UTF-8 BOM, if present. */ -static char* skip_utf8_bom(char* buf) -{ - unsigned char* s = (unsigned char*) buf; - - if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf) - { - buf += 3; - } - - return buf; -} -#endif - /* draws the statusbar on the given wps-screen */ #ifdef HAVE_LCD_BITMAP void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index b2969ecb34..3a85b5fad5 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -671,7 +671,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) char *current_string = data->string_buffer; while(*wps_bufptr && data->num_tokens < WPS_MAX_TOKENS - 1 - && data->num_lines < WPS_MAX_LINES) + && data->num_lines < WPS_MAX_LINES) { switch(*wps_bufptr++) { @@ -906,6 +906,19 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) #endif /* HAVE_LCD_BITMAP */ +/* Skip leading UTF-8 BOM, if present. */ +static char *skip_utf8_bom(char *buf) +{ + unsigned char *s = (unsigned char *)buf; + + if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf) + { + buf += 3; + } + + return buf; +} + /* to setup up the wps-data from a format-buffer (isfile = false) from a (wps-)file (isfile = true)*/ bool wps_data_load(struct wps_data *wps_data, @@ -975,6 +988,9 @@ bool wps_data_load(struct wps_data *wps_data, clear_bmp_names(); #endif + /* Skip leading UTF-8 BOM, if present. */ + wps_buffer = skip_utf8_bom(wps_buffer); + /* parse the WPS source */ if (!wps_parse(wps_data, wps_buffer)) return false; -- cgit v1.2.3