summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-07-09 09:43:55 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-07-09 09:43:55 +0000
commit908b0495a8957b66025396a092b25ae6faeb3ba0 (patch)
treece6b75596595f962119b872ac8944895fc31d23c /usr.bin
parent81e24db8ee6aaddaf77adb227f6b91a752147786 (diff)
When using '[' as the delimiter in sed(1) s/// (don't do that, of course)
and then including '[' in the regular expression by prepending a backslash to it, remove the backslash before feeding the RE to the RE engine, just like we already do it for other special characters like .^$*+?{(|. This makes sed 's[\[xy][...[' treat the xy thingy as a char class. Joint work with martijn@, OK guenther@ martijn@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sed/compile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index f01e8f2d911..f15dd9f9303 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compile.c,v 1.47 2017/12/13 16:07:54 millert Exp $ */
+/* $OpenBSD: compile.c,v 1.48 2018/07/09 09:43:54 schwarze Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -367,10 +367,10 @@ compile_delimited(char *p, char *d)
if ((d = compile_ccl(&p, d)) == NULL)
error(COMPILE, "unbalanced brackets ([])");
continue;
- } else if (*p == '\\' && p[1] == '[') {
- *d++ = *p++;
} else if (*p == '\\' && p[1] == c) {
p++;
+ } else if (*p == '\\' && p[1] == '[') {
+ *d++ = *p++;
} else if (*p == '\\' && p[1] == 'n') {
*d++ = '\n';
p += 2;