diff options
| author | Magnus Holmgren <magnushol@gmail.com> | 2005-12-07 21:18:54 +0000 |
|---|---|---|
| committer | Magnus Holmgren <magnushol@gmail.com> | 2005-12-07 21:18:54 +0000 |
| commit | 149f31ca66b7db306f70bd1559e2a9162a531963 (patch) | |
| tree | d95cc68c6a4522c4b3b5d6a7dc06485737a06139 | |
| parent | cc383764bdab15734288df82cc44172dbf7affb0 (diff) | |
| download | rockbox-149f31ca66b7db306f70bd1559e2a9162a531963.zip rockbox-149f31ca66b7db306f70bd1559e2a9162a531963.tar.gz rockbox-149f31ca66b7db306f70bd1559e2a9162a531963.tar.bz2 rockbox-149f31ca66b7db306f70bd1559e2a9162a531963.tar.xz | |
Forgot to add an extra BOM check. Probably killed a few gcc4 warnings too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8195 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/gui/gwps-common.c | 25 | ||||
| -rw-r--r-- | apps/gui/gwps-common.h | 2 |
2 files changed, 17 insertions, 10 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index a6ef9b0..7590f49 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -55,6 +55,19 @@ static void draw_player_fullbar(struct gui_wps *gwps, /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 +/* 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; +} + /* * returns the image_id between * a..z and A..Z @@ -81,7 +94,7 @@ static int get_image_id(int c) * it returns true if one of these tags is found and handled * false otherwise */ -bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, +bool wps_data_preload_tags(struct wps_data *data, char *buf, const char *bmpdir, size_t bmpdirlen) { if(!data || !buf) return false; @@ -92,14 +105,7 @@ bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, (void)bmpdir; (void)bmpdirlen; #endif - /* jump over the UTF-8 BOM(Byte Order Mark) if exist - * the BOM for UTF-8 is 3 bytes long and looks like so: - * 1. Byte: 0xEF - * 2. Byte: 0xBB - * 3. Byte: 0xBF - */ - if(buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) - buf+=3; + buf = skip_utf8_bom(buf); if(*buf == '#') return true; @@ -1122,6 +1128,7 @@ void gui_wps_format(struct wps_data *data) line = 0; subline = 0; + buf = skip_utf8_bom(buf); data->format_lines[line][subline] = buf; while ((*buf) && (line < WPS_MAX_LINES)) diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h index 7909270..ecda1d4 100644 --- a/apps/gui/gwps-common.h +++ b/apps/gui/gwps-common.h @@ -33,7 +33,7 @@ void setvol(void); bool update_onvol_change(struct gui_wps * gwps); bool update(struct gui_wps *gwps); bool ffwd_rew(int button); -bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, +bool wps_data_preload_tags(struct wps_data *data, char *buf, const char *bmpdir, size_t bmpdirlen); #ifdef WPS_KEYLOCK void display_keylock_text(bool locked); |