Stricter syntax checking of the %V tag - pay attention to the return-code from parse_list, and check for the tailing | symbol.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16784 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2008-03-24 18:40:13 +00:00
parent 10e1acc7ad
commit 0bb2e05aef

View file

@ -26,6 +26,7 @@
#include "gwps.h"
#ifndef __PCTOOL__
#include "settings.h"
#include "misc.h"
#include "debug.h"
#include "plugin.h"
@ -562,28 +563,35 @@ static int parse_viewport(const char *wps_bufptr,
#ifdef HAVE_LCD_COLOR
if (depth == 16)
{
parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width,
&vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern);
if (!(ptr = parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width,
&vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern)))
return WPS_ERROR_INVALID_PARAM;
}
else
#endif
#if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)
if (depth == 2) {
parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width,
&vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern);
if (!(ptr = parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width,
&vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern)))
return WPS_ERROR_INVALID_PARAM;
}
else
#endif
#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
if (depth == 1)
{
parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width, &vp->height,
&vp->font);
if (!(ptr = parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width,
&vp->height, &vp->font)))
return WPS_ERROR_INVALID_PARAM;
}
else
#endif
{}
/* Check for trailing | */
if (*ptr != '|')
return WPS_ERROR_INVALID_PARAM;
/* Default to using the user font if the font was an invalid number */
if ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))
vp->font = FONT_UI;