forked from len0rd/rockbox
checkwps: show a helpful error if the parser callback errors out
Change-Id: Ie3e35292ba8d74f0ff3d1bb3483a5e83aae0e6b6
This commit is contained in:
parent
657b91acfa
commit
d76dca165b
4 changed files with 14 additions and 4 deletions
|
@ -465,7 +465,7 @@ static int parse_font_load(struct skin_element *element,
|
||||||
if (id < 2)
|
if (id < 2)
|
||||||
{
|
{
|
||||||
DEBUGF("font id must be >= 2 (%d)\n", id);
|
DEBUGF("font id must be >= 2 (%d)\n", id);
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if defined(DEBUG) || defined(SIMULATOR)
|
#if defined(DEBUG) || defined(SIMULATOR)
|
||||||
if (skinfonts[id-2].name != NULL)
|
if (skinfonts[id-2].name != NULL)
|
||||||
|
@ -543,7 +543,7 @@ static int parse_listitem(struct skin_element *element,
|
||||||
(void)wps_data;
|
(void)wps_data;
|
||||||
struct listitem *li = skin_buffer_alloc(sizeof(*li));
|
struct listitem *li = skin_buffer_alloc(sizeof(*li));
|
||||||
if (!li)
|
if (!li)
|
||||||
return 1;
|
return -1;
|
||||||
token->value.data = PTRTOSKINOFFSET(skin_buffer, li);
|
token->value.data = PTRTOSKINOFFSET(skin_buffer, li);
|
||||||
if (element->params_count == 0)
|
if (element->params_count == 0)
|
||||||
li->offset = 0;
|
li->offset = 0;
|
||||||
|
@ -2227,7 +2227,7 @@ static int skin_element_callback(struct skin_element* element, void* data)
|
||||||
}
|
}
|
||||||
if (function)
|
if (function)
|
||||||
{
|
{
|
||||||
if (function(element, token, wps_data) < 0)
|
if (function(element, token, wps_data) != 0)
|
||||||
return CALLBACK_ERROR;
|
return CALLBACK_ERROR;
|
||||||
}
|
}
|
||||||
/* 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 */
|
||||||
|
|
|
@ -105,6 +105,9 @@ void skin_error(enum skin_errorcode error, const char* cursor)
|
||||||
case MULTILINE_EXPECTED:
|
case MULTILINE_EXPECTED:
|
||||||
error_message = "Expected subline separator";
|
error_message = "Expected subline separator";
|
||||||
break;
|
break;
|
||||||
|
case GOT_CALLBACK_ERROR:
|
||||||
|
error_message = "Parser callback returned error";
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,8 +546,11 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
if (callback(element, callback_data) == CALLBACK_ERROR)
|
if (callback(element, callback_data) == CALLBACK_ERROR)
|
||||||
|
{
|
||||||
|
skin_error(GOT_CALLBACK_ERROR, cursor);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
*document = cursor;
|
*document = cursor;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -822,8 +825,11 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
if (callback(element, callback_data) == CALLBACK_ERROR)
|
if (callback(element, callback_data) == CALLBACK_ERROR)
|
||||||
|
{
|
||||||
|
skin_error(GOT_CALLBACK_ERROR, *document);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
*document = cursor;
|
*document = cursor;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ enum skin_errorcode
|
||||||
DECIMAL_EXPECTED,
|
DECIMAL_EXPECTED,
|
||||||
SEPARATOR_EXPECTED,
|
SEPARATOR_EXPECTED,
|
||||||
CLOSE_EXPECTED,
|
CLOSE_EXPECTED,
|
||||||
MULTILINE_EXPECTED
|
MULTILINE_EXPECTED,
|
||||||
|
GOT_CALLBACK_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Holds a tag parameter, either numeric or text */
|
/* Holds a tag parameter, either numeric or text */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue