diff options
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/apps/misc.c b/apps/misc.c index 350537dc31..a4958a59ea 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1389,35 +1389,18 @@ int split_string(char *str, const char split_char, char *vector[], const int vec | |||
1389 | * option list is array of char pointers with the final item set to null | 1389 | * option list is array of char pointers with the final item set to null |
1390 | * ex - const char *option[] = { "op_a", "op_b", "op_c", NULL} | 1390 | * ex - const char *option[] = { "op_a", "op_b", "op_c", NULL} |
1391 | */ | 1391 | */ |
1392 | |||
1393 | int string_option(const char *option, const char *const oplist[], bool ignore_case) | 1392 | int string_option(const char *option, const char *const oplist[], bool ignore_case) |
1394 | { | 1393 | { |
1395 | int i; | ||
1396 | int ifound = -1; | ||
1397 | const char *op; | 1394 | const char *op; |
1398 | if (ignore_case) | 1395 | int (*cmp_fn)(const char*, const char*) = &strcasecmp; |
1396 | if (!ignore_case) | ||
1397 | cmp_fn = strcmp; | ||
1398 | for (int i=0; (op=oplist[i]) != NULL; i++) | ||
1399 | { | 1399 | { |
1400 | for (i=0; (op=oplist[i]) != NULL; i++) | 1400 | if (cmp_fn(op, option) == 0) |
1401 | { | 1401 | return i; |
1402 | if (strcasecmp(op, option) == 0) | ||
1403 | { | ||
1404 | ifound = i; | ||
1405 | break; | ||
1406 | } | ||
1407 | } | ||
1408 | } | ||
1409 | else | ||
1410 | { | ||
1411 | for (i=0; (op=oplist[i]) != NULL; i++) | ||
1412 | { | ||
1413 | if (strcmp(op, option) == 0) | ||
1414 | { | ||
1415 | ifound = i; | ||
1416 | break; | ||
1417 | } | ||
1418 | } | ||
1419 | } | 1402 | } |
1420 | return ifound; | 1403 | return -1; |
1421 | } | 1404 | } |
1422 | 1405 | ||
1423 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. | 1406 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. |