sed(1): partial fix for the case of the regex delimited with '['.
We don't generally support the weird case of regular expresions delimited by an opening square bracket ('[') but POSIX says that inside bracket expressions, escaping is not possible and both '[' and '\' represent themselves. PR: 230198 (exp-run) Obtained from: OpenBSD
This commit is contained in:
parent
17cfcf1dc2
commit
5102499601
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337419
@ -393,11 +393,11 @@ compile_delimited(char *p, char *d, int is_tr)
|
|||||||
if ((d = compile_ccl(&p, d)) == NULL)
|
if ((d = compile_ccl(&p, d)) == NULL)
|
||||||
errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname);
|
errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname);
|
||||||
continue;
|
continue;
|
||||||
|
} else if (*p == '\\' && p[1] == c) {
|
||||||
|
p++;
|
||||||
} else if (*p == '\\' && p[1] == '[') {
|
} else if (*p == '\\' && p[1] == '[') {
|
||||||
*d++ = *p++;
|
*d++ = *p++;
|
||||||
} else if (*p == '\\' && p[1] == c)
|
} else if (*p == '\\' && p[1] == 'n') {
|
||||||
p++;
|
|
||||||
else if (*p == '\\' && p[1] == 'n') {
|
|
||||||
*d++ = '\n';
|
*d++ = '\n';
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user