ptr = buf;
+ /* we swallow separators that are contiguous */
+ while (*ptr == delim) ptr++;
+
for (argc = 0; *ptr && (argc < arraylen - 1); argc++) {
array[argc] = ptr;
for (; *ptr; ptr++) {
}
} else if ((*ptr == delim) && !quot) {
*ptr++ = '\0';
+ /* we swallow separators that are contiguous */
+ while (*ptr == delim) ptr++;
break;
}
}
array[argc++] = ptr;
}
- /* strip quotes and leading / trailing spaces */
+ /* strip quotes */
for (x = 0; x < argc; x++) {
- char *p;
-
- while(*(array[x]) == ' ') {
- (array[x])++;
- }
- p = array[x];
+ char *p = array[x];
while((p = strchr(array[x], qc))) {
memmove(p, p+1, strlen(p));
p++;
}
- p = array[x] + (strlen(array[x]) - 1);
- while(*p == ' ') {
- *p-- = '\0';
- }
}
return argc;
if (data) {
mycmd = ftdm_strdup(data);
- argc = ftdm_separate_string(mycmd,' ',argv,(sizeof(argv) / sizeof(argv[0])));
+ argc = ftdm_separate_string(mycmd, ' ', argv, ftdm_array_len(argv));
}
if (check_arg_count(argc, 1)) goto handle_cli_error_argc;