summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-08 15:02:26 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-08 15:02:26 +0000
commit9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c (patch)
tree695b0450ae3552be36e1576ae12f98b86cc04bd7 /apps/gui
parentfd19b8dba443b24edf9a669b34f65066aba784cc (diff)
downloadrockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.tar.gz
rockbox-9ce77aa55415bf94d11f7a3ff3bcf0df57a3408c.zip
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/gui')
-rw-r--r--apps/gui/gwps-common.c15
-rw-r--r--apps/gui/wps_parser.c18
2 files changed, 17 insertions, 16 deletions
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 @@
60 /* 3% of 30min file == 54s step size */ 60 /* 3% of 30min file == 54s step size */
61#define MIN_FF_REWIND_STEP 500 61#define MIN_FF_REWIND_STEP 500
62 62
63#if 0
64/* Skip leading UTF-8 BOM, if present. */
65static char* skip_utf8_bom(char* buf)
66{
67 unsigned char* s = (unsigned char*) buf;
68
69 if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf)
70 {
71 buf += 3;
72 }
73
74 return buf;
75}
76#endif
77
78/* draws the statusbar on the given wps-screen */ 63/* draws the statusbar on the given wps-screen */
79#ifdef HAVE_LCD_BITMAP 64#ifdef HAVE_LCD_BITMAP
80void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) 65void 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)
671 char *current_string = data->string_buffer; 671 char *current_string = data->string_buffer;
672 672
673 while(*wps_bufptr && data->num_tokens < WPS_MAX_TOKENS - 1 673 while(*wps_bufptr && data->num_tokens < WPS_MAX_TOKENS - 1
674 && data->num_lines < WPS_MAX_LINES) 674 && data->num_lines < WPS_MAX_LINES)
675 { 675 {
676 switch(*wps_bufptr++) 676 switch(*wps_bufptr++)
677 { 677 {
@@ -906,6 +906,19 @@ static void load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
906 906
907#endif /* HAVE_LCD_BITMAP */ 907#endif /* HAVE_LCD_BITMAP */
908 908
909/* Skip leading UTF-8 BOM, if present. */
910static char *skip_utf8_bom(char *buf)
911{
912 unsigned char *s = (unsigned char *)buf;
913
914 if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf)
915 {
916 buf += 3;
917 }
918
919 return buf;
920}
921
909/* to setup up the wps-data from a format-buffer (isfile = false) 922/* to setup up the wps-data from a format-buffer (isfile = false)
910 from a (wps-)file (isfile = true)*/ 923 from a (wps-)file (isfile = true)*/
911bool wps_data_load(struct wps_data *wps_data, 924bool wps_data_load(struct wps_data *wps_data,
@@ -975,6 +988,9 @@ bool wps_data_load(struct wps_data *wps_data,
975 clear_bmp_names(); 988 clear_bmp_names();
976#endif 989#endif
977 990
991 /* Skip leading UTF-8 BOM, if present. */
992 wps_buffer = skip_utf8_bom(wps_buffer);
993
978 /* parse the WPS source */ 994 /* parse the WPS source */
979 if (!wps_parse(wps_data, wps_buffer)) 995 if (!wps_parse(wps_data, wps_buffer))
980 return false; 996 return false;