diff options
author | Ron Yorston <rmy@pobox.com> | 2021-02-05 11:24:06 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-02-05 11:24:06 +0000 |
commit | 32e19e7ae8b0d76d69871ba234e8f0af31baff4e (patch) | |
tree | 6fdc833a444e0dd6fd359b21a8d463856917a387 /libbb/compare_string_array.c | |
parent | 4fb71406b884c6ac0a9a4d2acf7a32b544611f70 (diff) | |
parent | cad3fc743aa7c7744e4fcf044371f0fda50fa51f (diff) | |
download | busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.tar.gz busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.tar.bz2 busybox-w32-32e19e7ae8b0d76d69871ba234e8f0af31baff4e.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/compare_string_array.c')
-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 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 | ||
105 | int FAST_FUNC index_in_strings(const char *strings, const char *key) | 105 | int 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; |