size_t len;
if (zstr(sp)) {
- return (char *) sp;
+ return strdup(SWITCH_BLANK_STRING);
}
while ((*sp == 13 ) || (*sp == 10 ) || (*sp == 9 ) || (*sp == 32) || (*sp == 11) ) {
}
if (zstr(sp)) {
- return (char *) sp;
+ return strdup(SWITCH_BLANK_STRING);
}
s = strdup(sp);
if ((len = strlen(s)) > 0) {
p = s + (len - 1);
- while (p > s && ((*p == 13 ) || (*p == 10 ) || (*p == 9 ) || (*p == 32) || (*p == 11))) {
+ while ((p >= s) && ((*p == 13 ) || (*p == 10 ) || (*p == 9 ) || (*p == 32) || (*p == 11))) {
*p-- = '\0';
}
}
size_t len;
if (zstr(sp)) {
- return sp;
+ return dup ? strdup(SWITCH_BLANK_STRING) : sp;
}
while (*sp == ' ') {
if ((len = strlen(s)) > 0) {
p = s + (len - 1);
- while (p && *p && p > s && *p == ' ') {
+ while (p && *p && (p >= s) && *p == ' ') {
*p-- = '\0';
}
}