mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-2975
This commit is contained in:
parent
2e0747272f
commit
c6bdb303d4
@ -809,23 +809,29 @@ SWITCH_DECLARE(char *) switch_strip_whitespace(const char *str)
|
|||||||
{
|
{
|
||||||
const char *sp = str;
|
const char *sp = str;
|
||||||
char *p, *s = NULL;
|
char *p, *s = NULL;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (!sp)
|
if (zstr(sp)) {
|
||||||
return NULL;
|
return (char *) sp;
|
||||||
|
}
|
||||||
|
|
||||||
while ((*sp == 13 ) || (*sp == 10 ) || (*sp == 9 ) || (*sp == 32) || (*sp == 11) ) {
|
while ((*sp == 13 ) || (*sp == 10 ) || (*sp == 9 ) || (*sp == 32) || (*sp == 11) ) {
|
||||||
sp++;
|
sp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zstr(sp)) {
|
||||||
|
return (char *) sp;
|
||||||
|
}
|
||||||
|
|
||||||
s = strdup(sp);
|
s = strdup(sp);
|
||||||
|
switch_assert(s);
|
||||||
|
|
||||||
if (!s)
|
if ((len = strlen(s)) > 0) {
|
||||||
return NULL;
|
p = s + (len - 1);
|
||||||
|
|
||||||
p = s + (strlen(s) - 1);
|
while (p > s && ((*p == 13 ) || (*p == 10 ) || (*p == 9 ) || (*p == 32) || (*p == 11))) {
|
||||||
|
*p-- = '\0';
|
||||||
while ((*p == 13 ) || (*p == 10 ) || (*p == 9 ) || (*p == 32) || (*p == 11) ) {
|
}
|
||||||
*p-- = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -835,9 +841,11 @@ SWITCH_DECLARE(char *) switch_strip_spaces(char *str, switch_bool_t dup)
|
|||||||
{
|
{
|
||||||
char *sp = str;
|
char *sp = str;
|
||||||
char *p, *s = NULL;
|
char *p, *s = NULL;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (!sp)
|
if (zstr(sp)) {
|
||||||
return NULL;
|
return sp;
|
||||||
|
}
|
||||||
|
|
||||||
while (*sp == ' ') {
|
while (*sp == ' ') {
|
||||||
sp++;
|
sp++;
|
||||||
@ -845,17 +853,21 @@ SWITCH_DECLARE(char *) switch_strip_spaces(char *str, switch_bool_t dup)
|
|||||||
|
|
||||||
if (dup) {
|
if (dup) {
|
||||||
s = strdup(sp);
|
s = strdup(sp);
|
||||||
|
switch_assert(s);
|
||||||
} else {
|
} else {
|
||||||
s = sp;
|
s = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s)
|
if (zstr(s)) {
|
||||||
return NULL;
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
p = s + (strlen(s) - 1);
|
if ((len = strlen(s)) > 0) {
|
||||||
|
p = s + (len - 1);
|
||||||
|
|
||||||
while (*p == ' ') {
|
while (p && *p && p > s && *p == ' ') {
|
||||||
*p-- = '\0';
|
*p-- = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user