summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCmdMZ.c15
-rw-r--r--tests/regexp.test14
3 files changed, 32 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9bd668d..74c119d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-13 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * generic/tclCmdMZ.c:
+ * tests/regexp.test: fix to [Bug 823524] in regsub; added three
+ new tests.
+
2003-10-12 Jeff Hobbs <jeffh@ActiveState.com>
* unix/tclUnixTest.c (TestalarmCmd): don't bother checking return
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index eac4bda..45f375b 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.8 2003/10/03 20:31:24 dgp Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.9 2003/10/14 18:21:59 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -738,7 +738,7 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv)
match = Tcl_RegExpExecObj(interp, regExpr, objPtr, offset,
10 /* matches */, ((offset > 0 &&
- (Tcl_GetUniChar(objPtr,offset-1) != (Tcl_UniChar)'\n'))
+ (wstring[offset-1] != (Tcl_UniChar)'\n'))
? TCL_REG_NOTBOL : 0));
if (match < 0) {
@@ -833,6 +833,17 @@ Tcl_RegsubObjCmd(dummy, interp, objc, objv)
offset++;
} else {
offset += end;
+ if (start == end) {
+ /*
+ * We matched an empty string, which means we must go
+ * forward one more step so we don't match again at the
+ * same spot.
+ */
+ if (offset < wlen) {
+ Tcl_AppendUnicodeToObj(resultPtr, wstring + offset, 1);
+ }
+ offset++;
+ }
}
if (!all) {
break;
diff --git a/tests/regexp.test b/tests/regexp.test
index 08ec147..1403e9d 100644
--- a/tests/regexp.test
+++ b/tests/regexp.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: regexp.test,v 1.22.2.2 2003/10/07 04:48:07 dgp Exp $
+# RCS: @(#) $Id: regexp.test,v 1.22.2.3 2003/10/14 18:22:10 vincentdarley Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -616,6 +616,18 @@ test regexp-21.10 {multiple matches handle newlines} {
regsub -all -lineanchor -- {^#[^\n]*\n} "#one\n#two\n#three\n" foo\n
} "foo\nfoo\nfoo\n"
+test regexp-21.11 {multiple matches handle newlines} {
+ regsub -all -line -- ^ "a\nb\nc" \#
+} "\#a\n\#b\n\#c"
+
+test regexp-21.12 {multiple matches handle newlines} {
+ regsub -all -line -- ^ "\n\n" \#
+} "\#\n\#\n\#"
+
+test regexp-21.13 {multiple matches handle newlines} {
+ regexp -all -inline -indices -line -- ^ "a\nb\nc"
+} {{0 -1} {2 1} {4 3}}
+
# cleanup
::tcltest::cleanupTests
return