Skin parser: Use parse_list() when possible

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23846 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-12-04 13:10:06 +00:00
parent cc9e336fa1
commit 8db32ddfee

View file

@ -1099,15 +1099,9 @@ static int parse_albumart_load(const char *wps_bufptr,
/* extract max width data */ /* extract max width data */
if (*_pos != '|') if (*_pos != '|')
{ {
if (!isdigit(*_pos)) /* malformed token: e.g. %Cl|7|59|# */ _pos = parse_list("d", NULL, '|', _pos, &aa->width);
if (!_pos || _pos > newline || *_pos != '|')
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
aa->width = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline)
return WPS_ERROR_INVALID_PARAM; /* malformed token: no | after width field
e.g. %Cl|7|59|200\n */
} }
/* parsing height field */ /* parsing height field */
@ -1148,15 +1142,9 @@ static int parse_albumart_load(const char *wps_bufptr,
/* extract max height data */ /* extract max height data */
if (*_pos != '|') if (*_pos != '|')
{ {
if (!isdigit(*_pos)) _pos = parse_list("d", NULL, '|', _pos, &aa->height);
return WPS_ERROR_INVALID_PARAM; /* malformed token e.g. %Cl|7|59|200|@ */ if (!_pos || _pos > newline || *_pos != '|')
return WPS_ERROR_INVALID_PARAM;
aa->height = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline)
return WPS_ERROR_INVALID_PARAM; /* malformed token: no closing |
e.g. %Cl|7|59|200|200\n */
} }
/* if we got here, we parsed everything ok .. ! */ /* if we got here, we parsed everything ok .. ! */
@ -1179,9 +1167,7 @@ static int parse_albumart_load(const char *wps_bufptr,
albumart_slot = playback_claim_aa_slot(&dimensions); albumart_slot = playback_claim_aa_slot(&dimensions);
if (albumart_slot < 0) /* didn't get a slot ? */ if (0 <= albumart_slot)
return skip_end_of_line(wps_bufptr);
else
wps_data->playback_aa_slot = albumart_slot; wps_data->playback_aa_slot = albumart_slot;
/* Skip the rest of the line */ /* Skip the rest of the line */