1
0
Fork 0
forked from len0rd/rockbox

Introduce a new WPS parsing error case: limits exceeded. It includes the cases when there are too many tokens, lines, sublines, viewports, strings, characters or conditional levels. This prevents the parser from failing silently or going on, as it used to do in those cases. Thanks to fml (Alexander Levin) for mentioning this issue.

I also changed the error types from #defines to an enum, for cleanliness.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18015 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nicolas Pennequin 2008-07-12 15:12:09 +00:00
parent 70029587ca
commit ae05501716
3 changed files with 54 additions and 42 deletions

View file

@ -30,11 +30,6 @@
#include "debug.h"
#endif
#define PARSE_FAIL_UNCLOSED_COND 1
#define PARSE_FAIL_INVALID_CHAR 2
#define PARSE_FAIL_COND_SYNTAX_ERROR 3
#define PARSE_FAIL_COND_INVALID_PARAM 4
#if defined(SIMULATOR) || defined(__PCTOOL__)
extern bool debug_wps;
extern int wps_verbose_level;
@ -574,7 +569,7 @@ static void print_wps_strings(struct wps_data *data)
}
#endif
void print_debug_info(struct wps_data *data, int fail, int line)
void print_debug_info(struct wps_data *data, enum wps_parse_error fail, int line)
{
#if defined(SIMULATOR) || defined(__PCTOOL__)
if (debug_wps && wps_verbose_level)
@ -590,13 +585,16 @@ void print_debug_info(struct wps_data *data, int fail, int line)
WPS_MAX_TOKENS - 1);
}
if (fail)
if (fail != PARSE_OK)
{
char buf[64];
DEBUGF("Failed parsing on line %d : ", line);
switch (fail)
{
case PARSE_OK:
break;
case PARSE_FAIL_UNCLOSED_COND:
DEBUGF("Unclosed conditional");
break;
@ -624,6 +622,10 @@ void print_debug_info(struct wps_data *data, int fail, int line)
buf, sizeof(buf))
);
break;
case PARSE_FAIL_LIMITS_EXCEEDED:
DEBUGF("Limits exceeded");
break;
}
DEBUGF("\n");
}