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
This commit is contained in:
Nicolas Pennequin 2007-04-08 15:02:26 +00:00
parent fd19b8dba4
commit 9ce77aa554
2 changed files with 17 additions and 16 deletions

View file

@ -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)

View file

@ -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;