aboutsummaryrefslogtreecommitdiff
path: root/libbb/compare_string_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/compare_string_array.c')
-rw-r--r--libbb/compare_string_array.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c
index ede5a97e3..70a4c29cf 100644
--- a/libbb/compare_string_array.c
+++ b/libbb/compare_string_array.c
@@ -104,13 +104,19 @@ int FAST_FUNC index_in_str_array(const char *const string_array[], const char *k
104 104
105int FAST_FUNC index_in_strings(const char *strings, const char *key) 105int FAST_FUNC index_in_strings(const char *strings, const char *key)
106{ 106{
107 int idx = 0; 107 int j, idx = 0;
108 108
109 while (*strings) { 109 while (*strings) {
110 if (strcmp(strings, key) == 0) { 110 /* Do we see "key\0" at current position in strings? */
111 return idx; 111 for (j = 0; *strings == key[j]; ++j) {
112 if (*strings++ == '\0') {
113 //bb_error_msg("found:'%s' i:%u", key, idx);
114 return idx; /* yes */
115 }
112 } 116 }
113 strings += strlen(strings) + 1; /* skip NUL */ 117 /* No. Move to the start of the next string. */
118 while (*strings++ != '\0')
119 continue;
114 idx++; 120 idx++;
115 } 121 }
116 return -1; 122 return -1;