Instead of using a custom parse function to process {}, treat it as a

set of statements and parse with yacc, then convert back to a string as
the last step. This means the rules are consistent inside and outside
{}, %if and friends work at the right time, and the final result isn't
littered with unnecessary newlines.
This commit is contained in:
nicm
2020-06-04 07:12:05 +00:00
parent 3f6af4156f
commit b3782d2dc8
4 changed files with 85 additions and 160 deletions

View File

@ -227,6 +227,11 @@ args_escape(const char *s)
return (escaped);
}
if (strchr(s, ' ') != NULL && strchr(s, '\'') == NULL) {
xasprintf(&escaped, "'%s'", s);
return (escaped);
}
flags = VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL;
if (s[strcspn(s, quoted)] != '\0')
flags |= VIS_DQ;