mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
replace more strcmp if then trees with string_option()
1 Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
This commit is contained in:
parent
a62d36d9e7
commit
2352cef6d0
6 changed files with 82 additions and 80 deletions
|
|
@ -260,32 +260,16 @@ bool skip_id3v2(int fd, struct mp3entry *id3)
|
|||
*/
|
||||
int string_option(const char *option, const char *const oplist[], bool ignore_case)
|
||||
{
|
||||
int i;
|
||||
int ifound = -1;
|
||||
const char *op;
|
||||
if (ignore_case)
|
||||
int (*cmp_fn)(const char*, const char*) = &strcasecmp;
|
||||
if (!ignore_case)
|
||||
cmp_fn = strcmp;
|
||||
for (int i=0; (op=oplist[i]) != NULL; i++)
|
||||
{
|
||||
for (i=0; (op=oplist[i]) != NULL; i++)
|
||||
{
|
||||
if (strcasecmp(op, option) == 0)
|
||||
{
|
||||
ifound = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmp_fn(op, option) == 0)
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; (op=oplist[i]) != NULL; i++)
|
||||
{
|
||||
if (strcmp(op, option) == 0)
|
||||
{
|
||||
ifound = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ifound;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue