forked from len0rd/rockbox
Trim a bunch of long lines and fix an infinite loop and buffer overrun in the impossible case that a WPS line ends with a litteral string but without a newline char (wps_parser.c:774).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13306 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2a20bfe153
commit
aa220d5acd
3 changed files with 94 additions and 60 deletions
|
|
@ -769,8 +769,8 @@ static char *get_token_value(struct gui_wps *gwps,
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
struct tm* tm = NULL;
|
struct tm* tm = NULL;
|
||||||
|
|
||||||
/* if the token is an RTC one, update the time and do the necessary checks */
|
/* if the token is an RTC one, update the time
|
||||||
|
and do the necessary checks */
|
||||||
if (token->type >= WPS_TOKENS_RTC_BEGIN
|
if (token->type >= WPS_TOKENS_RTC_BEGIN
|
||||||
&& token->type <= WPS_TOKENS_RTC_END)
|
&& token->type <= WPS_TOKENS_RTC_END)
|
||||||
{
|
{
|
||||||
|
|
@ -1313,7 +1313,7 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index)
|
||||||
/* intval is now the number of the enum option we want to read,
|
/* intval is now the number of the enum option we want to read,
|
||||||
starting from 1. If intval is -1, we check if value is empty. */
|
starting from 1. If intval is -1, we check if value is empty. */
|
||||||
if (intval == -1)
|
if (intval == -1)
|
||||||
intval = value && strlen(value) ? 1 : num_options;
|
intval = (value && *value) ? 1 : num_options;
|
||||||
else if (intval > num_options || intval < 1)
|
else if (intval > num_options || intval < 1)
|
||||||
intval = num_options;
|
intval = num_options;
|
||||||
|
|
||||||
|
|
@ -1543,12 +1543,14 @@ static bool update_curr_subline(struct gui_wps *gwps, int line)
|
||||||
|
|
||||||
/* if back where we started after search or
|
/* if back where we started after search or
|
||||||
only one subline is defined on the line */
|
only one subline is defined on the line */
|
||||||
if (((search > 0) && (data->lines[line].curr_subline == search_start)) ||
|
if (((search > 0) &&
|
||||||
|
(data->lines[line].curr_subline == search_start)) ||
|
||||||
only_one_subline)
|
only_one_subline)
|
||||||
{
|
{
|
||||||
/* no other subline with a time > 0 exists */
|
/* no other subline with a time > 0 exists */
|
||||||
data->lines[line].subline_expire_time = (reset_subline ?
|
data->lines[line].subline_expire_time = (reset_subline ?
|
||||||
current_tick : data->lines[line].subline_expire_time) + 100 * HZ;
|
current_tick :
|
||||||
|
data->lines[line].subline_expire_time) + 100 * HZ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1565,7 +1567,7 @@ static bool update_curr_subline(struct gui_wps *gwps, int line)
|
||||||
new_subline_refresh = true;
|
new_subline_refresh = true;
|
||||||
data->lines[line].subline_expire_time = (reset_subline ?
|
data->lines[line].subline_expire_time = (reset_subline ?
|
||||||
current_tick : data->lines[line].subline_expire_time) +
|
current_tick : data->lines[line].subline_expire_time) +
|
||||||
BASE_SUBLINE_TIME * data->sublines[subline_idx].time_mult;
|
BASE_SUBLINE_TIME*data->sublines[subline_idx].time_mult;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1820,7 +1822,8 @@ bool gui_wps_refresh(struct gui_wps *gwps,
|
||||||
/* get current subline for the line */
|
/* get current subline for the line */
|
||||||
new_subline_refresh = update_curr_subline(gwps, line);
|
new_subline_refresh = update_curr_subline(gwps, line);
|
||||||
|
|
||||||
subline_idx = wps_subline_index(data, line, data->lines[line].curr_subline);
|
subline_idx = wps_subline_index(data, line,
|
||||||
|
data->lines[line].curr_subline);
|
||||||
flags = data->sublines[subline_idx].line_type;
|
flags = data->sublines[subline_idx].line_type;
|
||||||
|
|
||||||
if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode)
|
if (refresh_mode == WPS_REFRESH_ALL || (flags & refresh_mode)
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,8 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
snprintf(buf, sizeof(buf), "rtc: day of month (01..31)");
|
snprintf(buf, sizeof(buf), "rtc: day of month (01..31)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
|
case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
|
||||||
snprintf(buf, sizeof(buf), "rtc: day of month, blank padded ( 1..31)");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: day of month, blank padded ( 1..31)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
|
case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
|
||||||
snprintf(buf, sizeof(buf), "rtc: hour (00..23)");
|
snprintf(buf, sizeof(buf), "rtc: hour (00..23)");
|
||||||
|
|
@ -173,28 +174,35 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
snprintf(buf, sizeof(buf), "rtc: second (00..59)");
|
snprintf(buf, sizeof(buf), "rtc: second (00..59)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_YEAR_2_DIGITS:
|
case WPS_TOKEN_RTC_YEAR_2_DIGITS:
|
||||||
snprintf(buf, sizeof(buf), "rtc: last two digits of year (00..99)");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: last two digits of year (00..99)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_YEAR_4_DIGITS:
|
case WPS_TOKEN_RTC_YEAR_4_DIGITS:
|
||||||
snprintf(buf, sizeof(buf), "rtc: year (1970...)");
|
snprintf(buf, sizeof(buf), "rtc: year (1970...)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_AM_PM_UPPER:
|
case WPS_TOKEN_RTC_AM_PM_UPPER:
|
||||||
snprintf(buf, sizeof(buf), "rtc: upper case AM or PM indicator");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: upper case AM or PM indicator");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_AM_PM_LOWER:
|
case WPS_TOKEN_RTC_AM_PM_LOWER:
|
||||||
snprintf(buf, sizeof(buf), "rtc: lower case am or pm indicator");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: lower case am or pm indicator");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_WEEKDAY_NAME:
|
case WPS_TOKEN_RTC_WEEKDAY_NAME:
|
||||||
snprintf(buf, sizeof(buf), "rtc: abbreviated weekday name (Sun..Sat)");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: abbreviated weekday name (Sun..Sat)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_MONTH_NAME:
|
case WPS_TOKEN_RTC_MONTH_NAME:
|
||||||
snprintf(buf, sizeof(buf), "rtc: abbreviated month name (Jan..Dec)");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: abbreviated month name (Jan..Dec)");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
||||||
snprintf(buf, sizeof(buf), "rtc: day of week (1..7); 1 is Monday");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: day of week (1..7); 1 is Monday");
|
||||||
break;
|
break;
|
||||||
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
|
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
|
||||||
snprintf(buf, sizeof(buf), "rtc: day of week (0..6); 0 is Sunday");
|
snprintf(buf, sizeof(buf),
|
||||||
|
"rtc: day of week (0..6); 0 is Sunday");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -265,31 +273,38 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_ARTIST:
|
case WPS_TOKEN_METADATA_ARTIST:
|
||||||
snprintf(buf, sizeof(buf), "%strack artist", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack artist",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_COMPOSER:
|
case WPS_TOKEN_METADATA_COMPOSER:
|
||||||
snprintf(buf, sizeof(buf), "%strack composer", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack composer",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_ALBUM:
|
case WPS_TOKEN_METADATA_ALBUM:
|
||||||
snprintf(buf, sizeof(buf), "%strack album", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack album",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_GENRE:
|
case WPS_TOKEN_METADATA_GENRE:
|
||||||
snprintf(buf, sizeof(buf), "%strack genre", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack genre",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_TRACK_NUMBER:
|
case WPS_TOKEN_METADATA_TRACK_NUMBER:
|
||||||
snprintf(buf, sizeof(buf), "%strack number", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack number",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_TRACK_TITLE:
|
case WPS_TOKEN_METADATA_TRACK_TITLE:
|
||||||
snprintf(buf, sizeof(buf), "%strack title", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack title",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_VERSION:
|
case WPS_TOKEN_METADATA_VERSION:
|
||||||
snprintf(buf, sizeof(buf), "%strack ID3 version", next_str(next));
|
snprintf(buf, sizeof(buf), "%strack ID3 version",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_METADATA_YEAR:
|
case WPS_TOKEN_METADATA_YEAR:
|
||||||
|
|
@ -325,7 +340,8 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_FILE_FREQUENCY:
|
case WPS_TOKEN_FILE_FREQUENCY:
|
||||||
snprintf(buf, sizeof(buf), "%sfile audio frequency", next_str(next));
|
snprintf(buf, sizeof(buf), "%sfile audio frequency",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_FILE_NAME:
|
case WPS_TOKEN_FILE_NAME:
|
||||||
|
|
@ -333,7 +349,8 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
|
case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
|
||||||
snprintf(buf, sizeof(buf), "%sfile name with extension", next_str(next));
|
snprintf(buf, sizeof(buf), "%sfile name with extension",
|
||||||
|
next_str(next));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_FILE_PATH:
|
case WPS_TOKEN_FILE_PATH:
|
||||||
|
|
@ -349,8 +366,8 @@ static void dump_wps_tokens(struct wps_data *data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPS_TOKEN_FILE_DIRECTORY:
|
case WPS_TOKEN_FILE_DIRECTORY:
|
||||||
snprintf(buf, sizeof(buf), "%sfile directory, level: %d", next_str(next),
|
snprintf(buf, sizeof(buf), "%sfile directory, level: %d",
|
||||||
token->value.i);
|
next_str(next), token->value.i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -421,9 +438,11 @@ static void print_wps_strings(struct wps_data *data)
|
||||||
DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
|
DEBUGF("%2d: (%2d) '%s'\n", i, len, data->strings[i]);
|
||||||
}
|
}
|
||||||
DEBUGF("\n");
|
DEBUGF("\n");
|
||||||
DEBUGF("Number of strings: %d out of an allowed %d\n", data->num_strings, WPS_MAX_STRINGS);
|
DEBUGF("Number of strings: %d out of an allowed %d\n",
|
||||||
|
data->num_strings, WPS_MAX_STRINGS);
|
||||||
DEBUGF("Total string length: %d\n", total_len);
|
DEBUGF("Total string length: %d\n", total_len);
|
||||||
DEBUGF("String buffer used: %d out of %d bytes\n", buf_used, STRING_BUFFER_SIZE);
|
DEBUGF("String buffer used: %d out of %d bytes\n",
|
||||||
|
buf_used, STRING_BUFFER_SIZE);
|
||||||
DEBUGF("\n");
|
DEBUGF("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ static const struct wps_tag all_tags[] = {
|
||||||
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
{ WPS_TOKEN_RTC_DAY_OF_MONTH, "cd", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_RTC_DAY_OF_MONTH, "cd", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED, "ce", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,"ce", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED, "cH", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED, "cH", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_RTC_HOUR_24, "ck", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_RTC_HOUR_24, "ck", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED, "cI", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED, "cI", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
|
|
@ -164,7 +164,8 @@ static const struct wps_tag all_tags[] = {
|
||||||
{ WPS_TOKEN_FILE_PATH, "fp", WPS_REFRESH_STATIC, NULL },
|
{ WPS_TOKEN_FILE_PATH, "fp", WPS_REFRESH_STATIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_SIZE, "fs", WPS_REFRESH_STATIC, NULL },
|
{ WPS_TOKEN_FILE_SIZE, "fs", WPS_REFRESH_STATIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_VBR, "fv", WPS_REFRESH_STATIC, NULL },
|
{ WPS_TOKEN_FILE_VBR, "fv", WPS_REFRESH_STATIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_DIRECTORY, "d", WPS_REFRESH_STATIC, parse_dir_level },
|
{ WPS_TOKEN_FILE_DIRECTORY, "d", WPS_REFRESH_STATIC,
|
||||||
|
parse_dir_level },
|
||||||
|
|
||||||
/* next file */
|
/* next file */
|
||||||
{ WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_FILE_BITRATE, "Fb", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
|
|
@ -175,7 +176,8 @@ static const struct wps_tag all_tags[] = {
|
||||||
{ WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_FILE_PATH, "Fp", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_FILE_SIZE, "Fs", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_FILE_VBR, "Fv", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
{ WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_DYNAMIC, parse_dir_level },
|
{ WPS_TOKEN_FILE_DIRECTORY, "D", WPS_REFRESH_DYNAMIC,
|
||||||
|
parse_dir_level },
|
||||||
|
|
||||||
/* current metadata */
|
/* current metadata */
|
||||||
{ WPS_TOKEN_METADATA_ARTIST, "ia", WPS_REFRESH_STATIC, NULL },
|
{ WPS_TOKEN_METADATA_ARTIST, "ia", WPS_REFRESH_STATIC, NULL },
|
||||||
|
|
@ -222,9 +224,11 @@ static const struct wps_tag all_tags[] = {
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
{ WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL },
|
{ WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL },
|
||||||
#else
|
#else
|
||||||
{ WPS_TOKEN_PLAYER_PROGRESSBAR, "pf", WPS_REFRESH_DYNAMIC | WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar },
|
{ WPS_TOKEN_PLAYER_PROGRESSBAR, "pf",
|
||||||
|
WPS_REFRESH_DYNAMIC | WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar },
|
||||||
#endif
|
#endif
|
||||||
{ WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS, parse_progressbar },
|
{ WPS_TOKEN_PROGRESSBAR, "pb", WPS_REFRESH_PLAYER_PROGRESS,
|
||||||
|
parse_progressbar },
|
||||||
|
|
||||||
{ WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL },
|
{ WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL },
|
||||||
|
|
||||||
|
|
@ -254,7 +258,8 @@ static const struct wps_tag all_tags[] = {
|
||||||
|
|
||||||
{ WPS_NO_TOKEN, "xl", 0, parse_image_load },
|
{ WPS_NO_TOKEN, "xl", 0, parse_image_load },
|
||||||
|
|
||||||
{ WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC, parse_image_display },
|
{ WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC,
|
||||||
|
parse_image_display },
|
||||||
|
|
||||||
{ WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load },
|
{ WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load },
|
||||||
{ WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special },
|
{ WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special },
|
||||||
|
|
@ -622,7 +627,8 @@ static int parse_token(const char *wps_bufptr, struct wps_data *wps_data)
|
||||||
|
|
||||||
taglen = (tag->type != WPS_TOKEN_UNKNOWN) ? strlen(tag->name) : 2;
|
taglen = (tag->type != WPS_TOKEN_UNKNOWN) ? strlen(tag->name) : 2;
|
||||||
token->type = tag->type;
|
token->type = tag->type;
|
||||||
wps_data->sublines[wps_data->num_sublines].line_type |= tag->refresh_type;
|
wps_data->sublines[wps_data->num_sublines].line_type |=
|
||||||
|
tag->refresh_type;
|
||||||
|
|
||||||
/* if the tag has a special parsing function, we call it */
|
/* if the tag has a special parsing function, we call it */
|
||||||
if (tag->parse_func)
|
if (tag->parse_func)
|
||||||
|
|
@ -633,7 +639,8 @@ static int parse_token(const char *wps_bufptr, struct wps_data *wps_data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* tags that start with 'F', 'I' or 'D' are for the next file */
|
/* tags that start with 'F', 'I' or 'D' are for the next file */
|
||||||
if ( *(tag->name) == 'I' || *(tag->name) == 'F' || *(tag->name) == 'D')
|
if ( *(tag->name) == 'I' || *(tag->name) == 'F' ||
|
||||||
|
*(tag->name) == 'D')
|
||||||
token->next = true;
|
token->next = true;
|
||||||
|
|
||||||
wps_data->num_tokens++;
|
wps_data->num_tokens++;
|
||||||
|
|
@ -758,8 +765,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
|
||||||
if ((data->num_lines < WPS_MAX_LINES) &&
|
if ((data->num_lines < WPS_MAX_LINES) &&
|
||||||
(data->num_sublines < WPS_MAX_SUBLINES))
|
(data->num_sublines < WPS_MAX_SUBLINES))
|
||||||
{
|
{
|
||||||
data->lines[data->num_lines].first_subline_idx = data->num_sublines;
|
data->lines[data->num_lines].first_subline_idx =
|
||||||
data->sublines[data->num_sublines].first_token_idx = data->num_tokens;
|
data->num_sublines;
|
||||||
|
|
||||||
|
data->sublines[data->num_sublines].first_token_idx =
|
||||||
|
data->num_tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -771,7 +781,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
|
||||||
const char *string_start = wps_bufptr - 1;
|
const char *string_start = wps_bufptr - 1;
|
||||||
|
|
||||||
/* find the length of the string */
|
/* find the length of the string */
|
||||||
while (wps_bufptr && *wps_bufptr != '#' &&
|
while (*wps_bufptr && *wps_bufptr != '#' &&
|
||||||
*wps_bufptr != '%' && *wps_bufptr != ';' &&
|
*wps_bufptr != '%' && *wps_bufptr != ';' &&
|
||||||
*wps_bufptr != '<' && *wps_bufptr != '>' &&
|
*wps_bufptr != '<' && *wps_bufptr != '>' &&
|
||||||
*wps_bufptr != '|' && *wps_bufptr != '\n')
|
*wps_bufptr != '|' && *wps_bufptr != '\n')
|
||||||
|
|
@ -812,7 +822,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
|
||||||
data->strings[data->num_strings] = stringbuf;
|
data->strings[data->num_strings] = stringbuf;
|
||||||
stringbuf += len + 1;
|
stringbuf += len + 1;
|
||||||
stringbuf_used += len + 1;
|
stringbuf_used += len + 1;
|
||||||
data->tokens[data->num_tokens].value.i = data->num_strings;
|
data->tokens[data->num_tokens].value.i =
|
||||||
|
data->num_strings;
|
||||||
data->num_strings++;
|
data->num_strings++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1021,7 +1032,8 @@ bool wps_data_load(struct wps_data *wps_data,
|
||||||
if (!wps_buffer)
|
if (!wps_buffer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* copy the file's content to the buffer for parsing */
|
/* copy the file's content to the buffer for parsing,
|
||||||
|
ensuring that every line ends with a newline char. */
|
||||||
unsigned int start = 0;
|
unsigned int start = 0;
|
||||||
while(read_line(fd, wps_buffer + start, buffersize - start) > 0)
|
while(read_line(fd, wps_buffer + start, buffersize - start) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue