From 710445dbed83ad9c1926d84500d59719893a739d Mon Sep 17 00:00:00 2001
From: dgp <dgp@users.sourceforge.net>
Date: Thu, 6 Apr 2006 18:57:12 +0000
Subject:         * generic/tclIndexObj.c (Tcl_GetIndexFromObjStruct):    It
 seems         * tests/indexObj.test:  there are extensions that rely on the
 prior         * doc/GetIndex.3:        behavior that the empty string cannot
 succeed         as a unique prefix matcher, so I'm restoring Donal Fellow's
 solution.         Added mention of this detail to the documentation.  [Bug
 1464039]

---
 ChangeLog             |  8 ++++++++
 doc/GetIndex.3        |  4 ++--
 generic/tclIndexObj.c |  4 ++--
 tests/indexObj.test   | 10 +++++++---
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0161b0..2e8e623 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-06  Don Porter  <dgp@users.sourceforge.net>
+
+	* generic/tclIndexObj.c (Tcl_GetIndexFromObjStruct):	It seems
+	* tests/indexObj.test:	there are extensions that rely on the prior
+	* doc/GetIndex.3:	 behavior that the empty string cannot succeed
+	as a unique prefix matcher, so I'm restoring Donal Fellow's solution.
+	Added mention of this detail to the documentation.  [Bug 1464039]
+
 2006-04-06  Daniel Steffen  <das@users.sourceforge.net>
 
 	* unix/tcl.m4: removed TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING
diff --git a/doc/GetIndex.3 b/doc/GetIndex.3
index 82f978a..8ed972b 100644
--- a/doc/GetIndex.3
+++ b/doc/GetIndex.3
@@ -4,7 +4,7 @@
 '\" See the file "license.terms" for information on usage and redistribution
 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 '\" 
-'\" RCS: @(#) $Id: GetIndex.3,v 1.10.2.1 2003/07/18 15:20:51 dgp Exp $
+'\" RCS: @(#) $Id: GetIndex.3,v 1.10.2.2 2006/04/06 18:57:24 dgp Exp $
 '\" 
 .so man.macros
 .TH Tcl_GetIndexFromObj 3 8.1 Tcl "Tcl Library Procedures"
@@ -64,7 +64,7 @@ an object must be one of a predefined set of values.
 \fIObjPtr\fR is compared against each of
 the strings in \fItablePtr\fR to find a match.  A match occurs if
 \fIobjPtr\fR's string value is identical to one of the strings in
-\fItablePtr\fR, or if it is a unique abbreviation
+\fItablePtr\fR, or if it is a non-empty unique abbreviation
 for exactly one of the strings in \fItablePtr\fR and the
 \fBTCL_EXACT\fR flag was not specified; in either case
 the index of the matching entry is stored at \fI*indexPtr\fR
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index f22e7d4..02f8491 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -10,7 +10,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * RCS: @(#) $Id: tclIndexObj.c,v 1.16.2.4 2006/04/05 15:17:05 dgp Exp $
+ * RCS: @(#) $Id: tclIndexObj.c,v 1.16.2.5 2006/04/06 18:57:24 dgp Exp $
  */
 
 #include "tclInt.h"
@@ -229,7 +229,7 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
     /*
      * Check if we were instructed to disallow abbreviations. 
      */
-    if ((flags & TCL_EXACT) || (numAbbrev != 1)) {
+    if ((flags & TCL_EXACT) || (key[0] == '\0') || (numAbbrev != 1)) {
 	goto error;
     }
 
diff --git a/tests/indexObj.test b/tests/indexObj.test
index 0d8a21d..c72729f 100644
--- a/tests/indexObj.test
+++ b/tests/indexObj.test
@@ -8,7 +8,7 @@
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
-# RCS: @(#) $Id: indexObj.test,v 1.7.18.3 2006/04/05 15:17:06 dgp Exp $
+# RCS: @(#) $Id: indexObj.test,v 1.7.18.4 2006/04/06 18:57:30 dgp Exp $
 
 if {[lsearch [namespace children] ::tcltest] == -1} {
     package require tcltest
@@ -75,8 +75,12 @@ test indexObj-2.8 {exact match of empty values: singleton case} {
     list [catch {testindexobj 1 0 {} a} msg] $msg
 } {1 {bad token "": must be a}}
 test indexObj-2.9 {non-exact match of empty values: singleton case} {
-    testindexobj 1 1 {} a
-} 0
+    # NOTE this is a special case.  Although the empty string is a
+    # unique prefix, we have an established history of rejecting
+    # empty lookup keys, requiring any unique prefix match to have
+    # at least one character.
+    list [catch {testindexobj 1 1 {} a} msg] $msg
+} {1 {bad token "": must be a}}
 
 test indexObj-3.1 {cache result to skip next lookup} {
     testindexobj check 42
-- 
cgit v0.12