mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +00:00
freetdm: change CLI parsing (ftdm_separate_string) to properly ignore white space (fixes Sangoma issue #778)
minor change into SS7 CLI to use ftdm_array_len() instead of duplicating it
This commit is contained in:
@@ -5771,6 +5771,9 @@ FT_DECLARE(uint32_t) ftdm_separate_string(char *buf, char delim, char **array, i
|
||||
|
||||
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++) {
|
||||
@@ -5782,6 +5785,8 @@ FT_DECLARE(uint32_t) ftdm_separate_string(char *buf, char delim, char **array, i
|
||||
}
|
||||
} else if ((*ptr == delim) && !quot) {
|
||||
*ptr++ = '\0';
|
||||
/* we swallow separators that are contiguous */
|
||||
while (*ptr == delim) ptr++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5791,22 +5796,13 @@ FT_DECLARE(uint32_t) ftdm_separate_string(char *buf, char delim, char **array, i
|
||||
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;
|
||||
|
Reference in New Issue
Block a user