summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2009-05-11 10:30:54 +0200
committerPaolo Bonzini <bonzini@gnu.org>2009-05-11 10:47:06 +0200
commit601f290184a39dd78545b3f833c5c00f8a97a3ca (patch)
treedca6866f66a8b7cbd7e5d611b066e5e0e1697ecb
parentff839b08be5e2ed97bc29639d4844ae1a1ba6d66 (diff)
downloadsed-601f290184a39dd78545b3f833c5c00f8a97a3ca.tar.gz
fix bug with s/[[[]//
2009-05-11 Paolo Bonzini <bonzini@gnu.org> * sed/compile.c (snarf_char_class): Fix logic bug with [[[ in regular expressions (and a possibly uninitialized use of variable delim stemming from the bug). Uninitialized variable bug reported by Zhongxing Xu. * testsuite/brackets.good: New. * testsuite/brackets.inp: New. * testsuite/brackets.sed: New. * testsuite/Makefile.am: Add test. * testsuite/Makefile.tests: Add test. 2009-05-11 Paolo Bonzini <bonzini@gnu.org>
-rw-r--r--ChangeLog11
-rw-r--r--NEWS5
-rw-r--r--THANKS1
-rw-r--r--doc/sed.14
-rw-r--r--sed/compile.c7
-rw-r--r--testsuite/Makefile.am3
-rw-r--r--testsuite/Makefile.tests2
-rw-r--r--testsuite/brackets.good1
-rw-r--r--testsuite/brackets.inp1
-rw-r--r--testsuite/brackets.sed8
10 files changed, 36 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c4919c3..9855aef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2009-05-11 Paolo Bonzini <bonzini@gnu.org>
+ * sed/compile.c (snarf_char_class): Fix logic bug with [[[ in regular
+ expressions (and a possibly uninitialized use of variable delim stemming
+ from the bug). Uninitialized variable bug reported by Zhongxing Xu.
+ * testsuite/brackets.good: New.
+ * testsuite/brackets.inp: New.
+ * testsuite/brackets.sed: New.
+ * testsuite/Makefile.am: Add test.
+ * testsuite/Makefile.tests: Add test.
+
+2009-05-11 Paolo Bonzini <bonzini@gnu.org>
+
* configure.ac: Define COPYRIGHT_YEAR.
* Makefile.am (dist-hook): Test it.
* sed/mbcs.c: Fix copyright years.
diff --git a/NEWS b/NEWS
index 2799009..2c68c73 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Sed 4.2a
+
+* fix parsing of s/[[[[[[[[[]//
+
+----------------------------------------------------------------------------
Sed 4.2
* now released under GPLv3
diff --git a/THANKS b/THANKS
index 932c49b..b231ff7 100644
--- a/THANKS
+++ b/THANKS
@@ -48,5 +48,6 @@ Ulrich Drepper <drepper@redhat.com>
Vladimir Marek <vladimir.marek@sun.com>
Vladimir Volovich <vvv@vvv.vsu.ru>
Wichert Akkerman <wakkerma@debian.org>
+Zhongxing Xu <xuzhongxing@gmail.com>
And the GNU translation teams.
diff --git a/doc/sed.1 b/doc/sed.1
index 3322d1d..4aad03c 100644
--- a/doc/sed.1
+++ b/doc/sed.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
-.TH SED "1" "April 2009" "sed version 4.2" "User Commands"
+.TH SED "1" "May 2009" "sed version 4.2" "User Commands"
.SH NAME
sed \- stream editor for filtering and transforming text
.SH SYNOPSIS
@@ -367,7 +367,7 @@ Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
Also, please include the output of ``sed --version'' in the body
of your report if at all possible.
.SH COPYRIGHT
-Copyright \(co 2003 Free Software Foundation, Inc.
+Copyright \(co 2009 Free Software Foundation, Inc.
.br
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
diff --git a/sed/compile.c b/sed/compile.c
index f48f8ec..c4a5250 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -489,10 +489,10 @@ snarf_char_class(b, cur_stat)
if (state == 1)
{
delim = ch;
- state++;
+ state = 2;
}
else if (state == 2 && ch == delim)
- state++;
+ state = 3;
else
break;
@@ -502,7 +502,8 @@ snarf_char_class(b, cur_stat)
if (pending_mb)
continue;
- state++;
+ if (state == 0)
+ state = 1;
continue;
case CLOSE_BRACKET:
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 47062e0..b8e60cb 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -24,7 +24,7 @@ SEDTESTS += \
fasts uniq manis khadafy linecnt eval distrib 8to7 y-bracket \
y-newline allsub cv-vars classes middle bsd stdin flipcase \
insens subwrite writeout readin insert utf8-1 utf8-2 utf8-3 utf8-4 \
- badenc inplace-hold \
+ badenc inplace-hold brackets \
help version file quiet \
factor binary3 binary2 binary dc
@@ -42,6 +42,7 @@ EXTRA_DIST = \
appquit.good appquit.inp appquit.sed \
binary.good binary.inp binary.sed binary2.sed binary3.sed \
bkslashes.good bkslashes.inp bkslashes.sed \
+ brackets.good brackets.inp brackets.sed \
bsd.good bsd.sh \
cv-vars.good cv-vars.inp cv-vars.sed \
classes.good classes.inp classes.sed \
diff --git a/testsuite/Makefile.tests b/testsuite/Makefile.tests
index f6402dd..1f04290 100644
--- a/testsuite/Makefile.tests
+++ b/testsuite/Makefile.tests
@@ -21,7 +21,7 @@ SKIP = :>$@.skip; exit 77
enable sep inclib 8bit 8to7 newjis xabcx dollar noeol bkslashes \
numsub head madding mac-mf empty xbxcx xbxcx3 recall recall2 xemacs \
appquit fasts uniq manis linecnt khadafy allsub flipcase space modulo \
-y-bracket y-newline insert::
+y-bracket y-newline insert brackets::
$(SEDENV) $(SED) -f $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out
$(CMP) $(srcdir)/$@.good $@.out
diff --git a/testsuite/brackets.good b/testsuite/brackets.good
new file mode 100644
index 0000000..73f87e7
--- /dev/null
+++ b/testsuite/brackets.good
@@ -0,0 +1 @@
+abcdefgh[
diff --git a/testsuite/brackets.inp b/testsuite/brackets.inp
new file mode 100644
index 0000000..3cc5802
--- /dev/null
+++ b/testsuite/brackets.inp
@@ -0,0 +1 @@
+[[[[[[[[[
diff --git a/testsuite/brackets.sed b/testsuite/brackets.sed
new file mode 100644
index 0000000..3c70da8
--- /dev/null
+++ b/testsuite/brackets.sed
@@ -0,0 +1,8 @@
+s/[[]/a/
+s/[[[]/b/
+s/[[[[]/c/
+s/[[[[[]/d/
+s/[[[[[[]/e/
+s/[[[[[[[]/f/
+s/[[[[[[[[]/g/
+s/[[[[[[[[[]/h/