From dfe0bb63c25ec4b9669b67071a6540448d5a7379 Mon Sep 17 00:00:00 2001
From: dgp <dgp@users.sourceforge.net>
Date: Tue, 26 Oct 2004 21:52:35 +0000
Subject:         * generic/tclParse.c (Tcl_SubstObj):    Fix for failed
 subst-12.3 test.         * tests/subst.test (subst-12.3-5):      More tests
 for Bug 1036649.

---
 ChangeLog          |  3 ++-
 generic/tclParse.c |  4 ++--
 tests/subst.test   | 10 +++++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d0f582b..c53a1bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,7 +14,8 @@
 
 2004-10-26  Don Porter  <dgp@users.sourceforge.net>
 
-        * tests/subst.test (subst-12.3,4):      More tests for Bug 1036649.
+	* generic/tclParse.c (Tcl_SubstObj):	Fix for failed subst-12.3 test.
+        * tests/subst.test (subst-12.3-5):      More tests for Bug 1036649.
 
         * unix/Makefile.in (install-libraries): Updated the installation
         of the http, msgcat, and tcltest packages to install as Tcl Modules
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 8b5315c..09894bc 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -13,7 +13,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * RCS: @(#) $Id: tclParse.c,v 1.38 2004/10/06 13:50:07 dkf Exp $
+ * RCS: @(#) $Id: tclParse.c,v 1.39 2004/10/26 21:52:37 dgp Exp $
  */
 
 #include "tclInt.h"
@@ -1840,7 +1840,7 @@ Tcl_SubstObj(interp, objPtr, flags)
 			Tcl_FreeParse(&nested);
 			p = nested.term + (nested.term < nested.end);
 			length = nested.end - p;
-			if (length == 0) {
+			if ((length == 0) && (nested.term == nested.end)) {
 			    /*
 			     * If we run out of string, blame the missing
 			     * close bracket on the last command, and do
diff --git a/tests/subst.test b/tests/subst.test
index ad788e2..a336c1b 100644
--- a/tests/subst.test
+++ b/tests/subst.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: subst.test,v 1.17 2004/10/26 21:04:37 dgp Exp $
+# RCS: @(#) $Id: subst.test,v 1.18 2004/10/26 21:52:41 dgp Exp $
 
 if {[lsearch [namespace children] ::tcltest] == -1} {
     package require tcltest 2.1
@@ -250,6 +250,14 @@ test subst-12.4 {nasty case, Bug 1036649} {
     }
     list $res $x
 } {{1 {missing close-bracket}} 10}
+test subst-12.5 {nasty case, Bug 1036649} {
+    set x 0
+    for {set i 0} {$i < 10} {incr i} {
+	set res [list [catch {subst "\[incr x"} msg] $msg]
+	if {$msg ne "missing close-bracket"} break
+    }
+    list $res $x
+} {{1 {missing close-bracket}} 0}
 
 # cleanup
 ::tcltest::cleanupTests
-- 
cgit v0.12