diff options
author | stanton <stanton> | 1999-06-03 18:43:30 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-06-03 18:43:30 (GMT) |
commit | 1ee755b0c7f5e4fdcfcce9b291e9eef6aa37c18c (patch) | |
tree | c08c858dca740efb49396a89896647c6016c2393 /generic/tclCmdMZ.c | |
parent | afdabb4790d357c3b065250f1af0b9ce4860f8b1 (diff) | |
download | tcl-1ee755b0c7f5e4fdcfcce9b291e9eef6aa37c18c.zip tcl-1ee755b0c7f5e4fdcfcce9b291e9eef6aa37c18c.tar.gz tcl-1ee755b0c7f5e4fdcfcce9b291e9eef6aa37c18c.tar.bz2 |
* generic/tclCmdMZ.c (Tcl_StringObjCmd):
* tests/string.test: Fixed bug where string equal/compare -nocase
reported wrong result on null strings. [Bug: 2138]
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index fdc89b7..19b9ece 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.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: tclCmdMZ.c,v 1.11 1999/06/02 01:53:31 stanton Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.12 1999/06/03 18:43:30 stanton Exp $ */ #include "tclInt.h" @@ -876,21 +876,32 @@ Tcl_StringObjCmd(dummy, interp, objc, objv) /* * Anything matches at 0 chars, right? */ + match = 0; } else if (nocase || ((reqlength > 0) && (reqlength <= length))) { /* * with -nocase or -length we have to check true char length * as it could be smaller than expected */ + length1 = Tcl_NumUtfChars(string1, length1); length2 = Tcl_NumUtfChars(string2, length2); length = (length1 < length2) ? length1 : length2; + /* * Do the reqlength check again, against 0 as well for * the benfit of nocase */ + if ((reqlength > 0) && (reqlength < length)) { length = reqlength; + } else if (reqlength < 0) { + /* + * The requested length is negative, so we ignore it by + * setting it to the longer of the two lengths. + */ + + reqlength = (length1 > length2) ? length1 : length2; } if (nocase) { match = Tcl_UtfNcasecmp(string1, string2, |