diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2013-02-26 21:12:00 +1100 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2013-02-26 21:18:16 +1100 |
| commit | d76dca165bd3312d78df7f6794d5fbab7f634ecd (patch) | |
| tree | 294a83908804b7e61e5b9b82f407a9df65cc42a9 | |
| parent | 657b91acfa86430750cebb82d0ea3aaf635953bf (diff) | |
| download | rockbox-d76dca165bd3312d78df7f6794d5fbab7f634ecd.zip rockbox-d76dca165bd3312d78df7f6794d5fbab7f634ecd.tar.gz rockbox-d76dca165bd3312d78df7f6794d5fbab7f634ecd.tar.bz2 rockbox-d76dca165bd3312d78df7f6794d5fbab7f634ecd.tar.xz | |
checkwps: show a helpful error if the parser callback errors out
Change-Id: Ie3e35292ba8d74f0ff3d1bb3483a5e83aae0e6b6
| -rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 6 | ||||
| -rw-r--r-- | lib/skin_parser/skin_debug.c | 3 | ||||
| -rw-r--r-- | lib/skin_parser/skin_parser.c | 6 | ||||
| -rw-r--r-- | lib/skin_parser/skin_parser.h | 3 |
4 files changed, 14 insertions, 4 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 9439664..a0386c5 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -465,7 +465,7 @@ static int parse_font_load(struct skin_element *element, if (id < 2) { DEBUGF("font id must be >= 2 (%d)\n", id); - return 1; + return -1; } #if defined(DEBUG) || defined(SIMULATOR) if (skinfonts[id-2].name != NULL) @@ -543,7 +543,7 @@ static int parse_listitem(struct skin_element *element, (void)wps_data; struct listitem *li = skin_buffer_alloc(sizeof(*li)); if (!li) - return 1; + return -1; token->value.data = PTRTOSKINOFFSET(skin_buffer, li); if (element->params_count == 0) li->offset = 0; @@ -2227,7 +2227,7 @@ static int skin_element_callback(struct skin_element* element, void* data) } if (function) { - if (function(element, token, wps_data) < 0) + if (function(element, token, wps_data) != 0) return CALLBACK_ERROR; } /* tags that start with 'F', 'I' or 'D' are for the next file */ diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c index 9537182..a204274 100644 --- a/lib/skin_parser/skin_debug.c +++ b/lib/skin_parser/skin_debug.c @@ -105,6 +105,9 @@ void skin_error(enum skin_errorcode error, const char* cursor) case MULTILINE_EXPECTED: error_message = "Expected subline separator"; break; + case GOT_CALLBACK_ERROR: + error_message = "Parser callback returned error"; + break; }; } diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 1f4b87a..39a41e9 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -546,7 +546,10 @@ static int skin_parse_tag(struct skin_element* element, const char** document) if (callback) { if (callback(element, callback_data) == CALLBACK_ERROR) + { + skin_error(GOT_CALLBACK_ERROR, cursor); return 0; + } } #endif *document = cursor; @@ -822,7 +825,10 @@ static int skin_parse_tag(struct skin_element* element, const char** document) if (callback) { if (callback(element, callback_data) == CALLBACK_ERROR) + { + skin_error(GOT_CALLBACK_ERROR, *document); return 0; + } } #endif *document = cursor; diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h index ec51b64..c53896c 100644 --- a/lib/skin_parser/skin_parser.h +++ b/lib/skin_parser/skin_parser.h @@ -79,7 +79,8 @@ enum skin_errorcode DECIMAL_EXPECTED, SEPARATOR_EXPECTED, CLOSE_EXPECTED, - MULTILINE_EXPECTED + MULTILINE_EXPECTED, + GOT_CALLBACK_ERROR }; /* Holds a tag parameter, either numeric or text */ |