summaryrefslogtreecommitdiffstats
path: root/generic/tclIndexObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2006-04-05 13:20:00 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2006-04-05 13:20:00 (GMT)
commit1fbc814589c815aba033653af3694fc122ce1538 (patch)
treeed8642772af66b092f9cf09cb49a3c50497782cf /generic/tclIndexObj.c
parenta9e197a7ae5fbaf4553abbe4bdd7b287c6fe16b1 (diff)
downloadtcl-1fbc814589c815aba033653af3694fc122ce1538.zip
tcl-1fbc814589c815aba033653af3694fc122ce1538.tar.gz
tcl-1fbc814589c815aba033653af3694fc122ce1538.tar.bz2
Fix [Bug 1646039]
Diffstat (limited to 'generic/tclIndexObj.c')
-rw-r--r--generic/tclIndexObj.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index bdfca15..7bc046d 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.2 2006/02/16 20:21:54 dgp Exp $
+ * RCS: @(#) $Id: tclIndexObj.c,v 1.16.2.3 2006/04/05 13:20:09 dkf Exp $
*/
#include "tclInt.h"
@@ -171,7 +171,7 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
int flags; /* 0 or TCL_EXACT */
int *indexPtr; /* Place to store resulting integer index. */
{
- int index, length, i, numAbbrev;
+ int index, i, numAbbrev;
char *key, *p1;
CONST char *p2;
CONST char * CONST *entryPtr;
@@ -195,19 +195,11 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
* abbreviations unless TCL_EXACT is set in flags.
*/
- key = Tcl_GetStringFromObj(objPtr, &length);
+ key = TclGetString(objPtr);
index = -1;
numAbbrev = 0;
/*
- * The key should not be empty, otherwise it's not a match.
- */
-
- if (key[0] == '\0') {
- goto error;
- }
-
- /*
* Scan the table looking for one of:
* - An exact match (always preferred)
* - A single abbreviation (allowed depending on flags)
@@ -235,9 +227,13 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
}
}
/*
- * Check if we were instructed to disallow abbreviations.
+ * Check if we were instructed to disallow abbreviations. Note that we do
+ * not allow the empty string as an abbreviation of anything; it is only
+ * processed by this function as a non-error case if the table of strings
+ * has an entry in it that is itself an empty string. This only matters in
+ * the case where the table has a singleton entry.
*/
- if ((flags & TCL_EXACT) || (numAbbrev != 1)) {
+ if ((flags & TCL_EXACT) || (key[0] == '\0') || (numAbbrev != 1)) {
goto error;
}