inpcom.c, cleanup inp_remove_ws(), reorder loop, reveal obscure behaviour

This commit is contained in:
rlar 2014-12-31 16:52:41 +01:00
parent bd055c1a98
commit d623763e58
1 changed files with 15 additions and 5 deletions

View File

@ -2204,12 +2204,27 @@ inp_remove_ws(char *s)
char *buffer;
bool is_expression = FALSE;
/* preserve at least one whitespace at beginning of line
* fixme,
* is this really necessary ?
* or is this an artefact of original inp_remove_ws() implementation ?
*/
if (isspace(*s))
*d++ = *s++;
while (*s != '\0') {
if (*s == '{')
is_expression = TRUE;
if (*s == '}')
is_expression = FALSE;
if (isspace(*s)) {
s = skip_ws(s);
if (!(*s == '\0' || *s == '=' || (is_expression && (is_arith_char(*s) || *s == ','))))
*d++ = ' ';
continue;
}
if (*s == '=' || (is_expression && (is_arith_char(*s) || *s == ','))) {
*d++ = *s++;
s = skip_ws(s);
@ -2224,11 +2239,6 @@ inp_remove_ws(char *s)
}
*d++ = *s++;
if (isspace(*s)) {
s = skip_ws(s);
if (!(*s == '\0' || *s == '=' || (is_expression && (is_arith_char(*s) || *s == ','))))
*d++ = ' ';
}
}
*d = '\0';