basic/extract-word: allow escape character to be escaped

With EXTRACT_UNESCAPE_SEPARATORS, backslash is used to escape the separator.
But it wasn't possible to insert the backslash itself. Let's allow this and
add test.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-03-11 09:21:07 +01:00
parent 8723c716c7
commit 76c4e48ee6
2 changed files with 26 additions and 2 deletions
+2 -2
View File
@@ -102,8 +102,8 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
else
sz += utf8_encode_unichar(s + sz, u);
} else if ((flags & EXTRACT_UNESCAPE_SEPARATORS) &&
strchr(separators, **p))
/* An escaped separator char */
(strchr(separators, **p) || **p == '\\'))
/* An escaped separator char or the escape char itself */
s[sz++] = c;
else if (flags & EXTRACT_CUNESCAPE_RELAX) {
s[sz++] = '\\';