diff options
-rw-r--r-- | apps/misc.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/apps/misc.c b/apps/misc.c index 338ef9be19..fcdbb28fce 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1384,20 +1384,16 @@ void format_time(char* buf, int buf_size, long t) | |||
1384 | int split_string(char *str, const char split_char, char *vector[], const int vector_length) | 1384 | int split_string(char *str, const char split_char, char *vector[], const int vector_length) |
1385 | { | 1385 | { |
1386 | int i; | 1386 | int i; |
1387 | char *p = str; | 1387 | char sep[2] = {split_char, '\0'}; |
1388 | 1388 | char *e, *p = strtok_r(str, sep, &e); | |
1389 | /* skip leading splitters */ | ||
1390 | while(*p == split_char) p++; | ||
1391 | 1389 | ||
1392 | /* *p in the condition takes care of trailing splitters */ | 1390 | /* *p in the condition takes care of trailing splitters */ |
1393 | for(i = 0; p && *p && i < vector_length; i++) | 1391 | for(i = 0; i < vector_length; i++) |
1394 | { | 1392 | { |
1395 | vector[i] = p; | 1393 | vector[i] = p; |
1396 | if ((p = strchr(p, split_char))) | 1394 | if (!p) |
1397 | { | 1395 | break; |
1398 | *p++ = '\0'; | 1396 | p = strtok_r(NULL, sep, &e); |
1399 | while(*p == split_char) p++; /* skip successive splitters */ | ||
1400 | } | ||
1401 | } | 1397 | } |
1402 | 1398 | ||
1403 | return i; | 1399 | return i; |