diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 14:31:02 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 14:31:02 -0400 |
commit | 2352cef6d0757a4d31a18561a09a10f031388e12 (patch) | |
tree | 81d555acb1f7382d7c8c7c4180cfb9aa5b028d8b /lib/rbcodec/metadata/metadata_common.c | |
parent | a62d36d9e7fd89adfd55ae2428fa9df4243bc435 (diff) | |
download | rockbox-2352cef6d0757a4d31a18561a09a10f031388e12.tar.gz rockbox-2352cef6d0757a4d31a18561a09a10f031388e12.zip |
replace more strcmp if then trees with string_option()
1
Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
Diffstat (limited to 'lib/rbcodec/metadata/metadata_common.c')
-rw-r--r-- | lib/rbcodec/metadata/metadata_common.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/lib/rbcodec/metadata/metadata_common.c b/lib/rbcodec/metadata/metadata_common.c index 202da49522..59c2f01840 100644 --- a/lib/rbcodec/metadata/metadata_common.c +++ b/lib/rbcodec/metadata/metadata_common.c | |||
@@ -260,32 +260,16 @@ bool skip_id3v2(int fd, struct mp3entry *id3) | |||
260 | */ | 260 | */ |
261 | int string_option(const char *option, const char *const oplist[], bool ignore_case) | 261 | int string_option(const char *option, const char *const oplist[], bool ignore_case) |
262 | { | 262 | { |
263 | int i; | ||
264 | int ifound = -1; | ||
265 | const char *op; | 263 | const char *op; |
266 | if (ignore_case) | 264 | int (*cmp_fn)(const char*, const char*) = &strcasecmp; |
265 | if (!ignore_case) | ||
266 | cmp_fn = strcmp; | ||
267 | for (int i=0; (op=oplist[i]) != NULL; i++) | ||
267 | { | 268 | { |
268 | for (i=0; (op=oplist[i]) != NULL; i++) | 269 | if (cmp_fn(op, option) == 0) |
269 | { | 270 | return i; |
270 | if (strcasecmp(op, option) == 0) | ||
271 | { | ||
272 | ifound = i; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | for (i=0; (op=oplist[i]) != NULL; i++) | ||
280 | { | ||
281 | if (strcmp(op, option) == 0) | ||
282 | { | ||
283 | ifound = i; | ||
284 | break; | ||
285 | } | ||
286 | } | ||
287 | } | 271 | } |
288 | return ifound; | 272 | return -1; |
289 | } | 273 | } |
290 | #endif | 274 | #endif |
291 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. | 275 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. |