diff options
author | marius <marius@FreeBSD.org> | 2010-05-21 19:21:47 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2010-05-21 19:21:47 +0000 |
commit | e55ff4c6125f3dbeca0bdfc70826fcf252a1bf75 (patch) | |
tree | 2dbe35cab2716dd9a3ae3f4d4e140c835e4b241c | |
parent | 5b4ca952238ec7d5548343c0f15909a607b2fd9f (diff) | |
download | FreeBSD-src-e55ff4c6125f3dbeca0bdfc70826fcf252a1bf75.zip FreeBSD-src-e55ff4c6125f3dbeca0bdfc70826fcf252a1bf75.tar.gz |
MFC: r197356
Allow [ to be used as a delimiter.
Pointed by: Marius Strobl
Obtained from: Apple
-rw-r--r-- | tools/regression/usr.bin/sed/multitest.t | 9 | ||||
-rw-r--r-- | usr.bin/sed/compile.c | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/tools/regression/usr.bin/sed/multitest.t b/tools/regression/usr.bin/sed/multitest.t index 53c14c5..fefc70b 100644 --- a/tools/regression/usr.bin/sed/multitest.t +++ b/tools/regression/usr.bin/sed/multitest.t @@ -432,6 +432,15 @@ u2/g' lines1 # POSIX does not say that this should work, # but it does for GNU, BSD, and SunOS mark '8.17' ; $SED -e 's/[/]/Q/' lines1 + + COMMENT='[ as an s delimiter and its escapes' + mark '8.18' ; $SED -e 's[_[X[' lines1 + # This is a matter of interpretation + # POSIX 1003.1, 2004 says "Within the BRE and the replacement, + # the BRE delimiter itself can be used as a *literal* character + # if it is preceded by a backslash + mark '8.19' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X[' + mark '8.20' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X\[[' } test_error() diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index 53e2af7..a51a314 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -387,7 +387,7 @@ compile_delimited(char *p, char *d) errx(1, "%lu: %s: newline can not be used as a string delimiter", linenum, fname); while (*p) { - if (*p == '[') { + if (*p == '[' && *p != c) { if ((d = compile_ccl(&p, d)) == NULL) errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname); continue; |