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.tar.gz rockbox-149f31ca66b7db306f70bd1559e2a9162a531963.zip |
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 a6ef9b04d3..7590f493e8 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, | |||
55 | /* 3% of 30min file == 54s step size */ | 55 | /* 3% of 30min file == 54s step size */ |
56 | #define MIN_FF_REWIND_STEP 500 | 56 | #define MIN_FF_REWIND_STEP 500 |
57 | 57 | ||
58 | /* Skip leading UTF-8 BOM, if present. */ | ||
59 | static char* skip_utf8_bom(char* buf) | ||
60 | { | ||
61 | unsigned char* s = (unsigned char*) buf; | ||
62 | |||
63 | if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf) | ||
64 | { | ||
65 | buf += 3; | ||
66 | } | ||
67 | |||
68 | return buf; | ||
69 | } | ||
70 | |||
58 | /* | 71 | /* |
59 | * returns the image_id between | 72 | * returns the image_id between |
60 | * a..z and A..Z | 73 | * a..z and A..Z |
@@ -81,7 +94,7 @@ static int get_image_id(int c) | |||
81 | * it returns true if one of these tags is found and handled | 94 | * it returns true if one of these tags is found and handled |
82 | * false otherwise | 95 | * false otherwise |
83 | */ | 96 | */ |
84 | bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, | 97 | bool wps_data_preload_tags(struct wps_data *data, char *buf, |
85 | const char *bmpdir, size_t bmpdirlen) | 98 | const char *bmpdir, size_t bmpdirlen) |
86 | { | 99 | { |
87 | if(!data || !buf) return false; | 100 | if(!data || !buf) return false; |
@@ -92,14 +105,7 @@ bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, | |||
92 | (void)bmpdir; | 105 | (void)bmpdir; |
93 | (void)bmpdirlen; | 106 | (void)bmpdirlen; |
94 | #endif | 107 | #endif |
95 | /* jump over the UTF-8 BOM(Byte Order Mark) if exist | 108 | buf = skip_utf8_bom(buf); |
96 | * the BOM for UTF-8 is 3 bytes long and looks like so: | ||
97 | * 1. Byte: 0xEF | ||
98 | * 2. Byte: 0xBB | ||
99 | * 3. Byte: 0xBF | ||
100 | */ | ||
101 | if(buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) | ||
102 | buf+=3; | ||
103 | 109 | ||
104 | if(*buf == '#') | 110 | if(*buf == '#') |
105 | return true; | 111 | return true; |
@@ -1122,6 +1128,7 @@ void gui_wps_format(struct wps_data *data) | |||
1122 | 1128 | ||
1123 | line = 0; | 1129 | line = 0; |
1124 | subline = 0; | 1130 | subline = 0; |
1131 | buf = skip_utf8_bom(buf); | ||
1125 | data->format_lines[line][subline] = buf; | 1132 | data->format_lines[line][subline] = buf; |
1126 | 1133 | ||
1127 | while ((*buf) && (line < WPS_MAX_LINES)) | 1134 | while ((*buf) && (line < WPS_MAX_LINES)) |
diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h index 7909270419..ecda1d47ea 100644 --- a/apps/gui/gwps-common.h +++ b/apps/gui/gwps-common.h | |||
@@ -33,7 +33,7 @@ void setvol(void); | |||
33 | bool update_onvol_change(struct gui_wps * gwps); | 33 | bool update_onvol_change(struct gui_wps * gwps); |
34 | bool update(struct gui_wps *gwps); | 34 | bool update(struct gui_wps *gwps); |
35 | bool ffwd_rew(int button); | 35 | bool ffwd_rew(int button); |
36 | bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, | 36 | bool wps_data_preload_tags(struct wps_data *data, char *buf, |
37 | const char *bmpdir, size_t bmpdirlen); | 37 | const char *bmpdir, size_t bmpdirlen); |
38 | #ifdef WPS_KEYLOCK | 38 | #ifdef WPS_KEYLOCK |
39 | void display_keylock_text(bool locked); | 39 | void display_keylock_text(bool locked); |