OSDN Git Service

Fix sed bug where any ] right after [ was skipped, not just first one in range.
authorRob Landley <rob@landley.net>
Thu, 5 Nov 2015 06:13:27 +0000 (00:13 -0600)
committerRob Landley <rob@landley.net>
Thu, 5 Nov 2015 06:13:27 +0000 (00:13 -0600)
tests/sed.test
toys/posix/sed.c

index 56d68fd..805184e 100755 (executable)
@@ -129,6 +129,7 @@ testing "" "sed '1a\
 hello'" "merp\nhello\n" "" "merp"
 
 testing "" "sed -e '/x/c\' -e 'y'" 'y\n' '' 'x\n'
+testing "" "sed -e 's/a[([]*b/X/'" 'X' '' 'a[(b'
 
 #echo meep | sed/sed -e '1a\' -e 'huh'
 #echo blah | sed/sed -f <(echo -e "1a\\\\\nboom")
index 9d377cd..a57891e 100644 (file)
@@ -718,7 +718,7 @@ static char *unescape_delimited_string(char **pstr, char *delim, int regex)
     if (!*from) return 0;
 
     // delimiter in regex character range doesn't count
-    if (*from == '[') {
+    if (!mode && *from == '[') {
       mode = '[';
       if (from[1] == ']') *(to++) = *(from++);
     } else if (mode && *from == ']') mode = 0;