diff options
-rw-r--r-- | libbb/compare_string_array.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c index a06e57d3d..d8cd033a3 100644 --- a/libbb/compare_string_array.c +++ b/libbb/compare_string_array.c | |||
@@ -63,13 +63,19 @@ int FAST_FUNC index_in_str_array(const char *const string_array[], const char *k | |||
63 | 63 | ||
64 | int FAST_FUNC index_in_strings(const char *strings, const char *key) | 64 | int FAST_FUNC index_in_strings(const char *strings, const char *key) |
65 | { | 65 | { |
66 | int idx = 0; | 66 | int j, idx = 0; |
67 | 67 | ||
68 | while (*strings) { | 68 | while (*strings) { |
69 | if (strcmp(strings, key) == 0) { | 69 | /* Do we see "key\0" at current position in strings? */ |
70 | return idx; | 70 | for (j = 0; *strings == key[j]; ++j) { |
71 | if (*strings++ == '\0') { | ||
72 | //bb_error_msg("found:'%s' i:%u", key, idx); | ||
73 | return idx; /* yes */ | ||
74 | } | ||
71 | } | 75 | } |
72 | strings += strlen(strings) + 1; /* skip NUL */ | 76 | /* No. Move to the start of the next string. */ |
77 | while (*strings++ != '\0') | ||
78 | continue; | ||
73 | idx++; | 79 | idx++; |
74 | } | 80 | } |
75 | return -1; | 81 | return -1; |