|
|
@ -11,16 +11,21 @@ const char *whitespace = " \f\n\r\t\v";
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: This returns 8 characters for trimmed_start per tab character. */
|
|
|
|
/* Note: This returns 8 characters for trimmed_start per tab character. */
|
|
|
|
char *strip_whitespace(char *_str) {
|
|
|
|
char *strip_whitespace(char *_str) {
|
|
|
|
int ws = strspn(_str, whitespace);
|
|
|
|
if (*_str == '\0')
|
|
|
|
int len = strlen(_str) - ws + 1;
|
|
|
|
return _str;
|
|
|
|
sway_log(L_DEBUG,"%d, %d..",ws,len);
|
|
|
|
char *strold = _str;
|
|
|
|
char *str = malloc(len);
|
|
|
|
while (*_str == ' ' || *_str == '\t') {
|
|
|
|
strcpy(str, _str+ws);
|
|
|
|
_str++;
|
|
|
|
free(_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *str = malloc(strlen(_str) + 1);
|
|
|
|
|
|
|
|
strcpy(str, _str);
|
|
|
|
|
|
|
|
free(strold);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; str[i] != '\0'; ++i);
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
len--;
|
|
|
|
i--;
|
|
|
|
} while (len >= 0 && (str[len] == ' ' || str[len] == '\t'));
|
|
|
|
} while (i >= 0 && (str[i] == ' ' || str[i] == '\t'));
|
|
|
|
str[len + 1] = '\0';
|
|
|
|
str[i + 1] = '\0';
|
|
|
|
return str;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|