diff options
| author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-08 15:02:26 +0000 |
|---|---|---|
| committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-08 15:02:26 +0000 |
| commit | 9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c (patch) | |
| tree | 695b0450ae3552be36e1576ae12f98b86cc04bd7 /apps | |
| parent | fd19b8dba443b24edf9a669b34f65066aba784cc (diff) | |
| download | rockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.zip rockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.tar.gz rockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.tar.bz2 rockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.tar.xz | |
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
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/gui/gwps-common.c | 15 | ||||
| -rw-r--r-- | apps/gui/wps_parser.c | 18 |
2 files changed, 17 insertions, 16 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 42ba17a..62a068f 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 b2969ec..3a85b5f 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; |