diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2002-01-02 13:52:03 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2002-01-02 13:52:03 (GMT) |
commit | 75c6074fa9ed66a5fe5ac9afbd633cf0207e0899 (patch) | |
tree | a705d6a0587c54ed5536496f94e042dd0c53b62c /generic | |
parent | eb8476367a6bc605f4c88e534db5caefc769f216 (diff) | |
download | tcl-75c6074fa9ed66a5fe5ac9afbd633cf0207e0899.zip tcl-75c6074fa9ed66a5fe5ac9afbd633cf0207e0899.tar.gz tcl-75c6074fa9ed66a5fe5ac9afbd633cf0207e0899.tar.bz2 |
Fixed fault with case-insensitive string matching (Bug#233257) and rewrote
some tests to test what they claimed to be testing.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclUtf.c | 5 | ||||
-rw-r--r-- | generic/tclUtil.c | 27 |
2 files changed, 24 insertions, 8 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 17990db..5bdf557 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -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: tclUtf.c,v 1.19 2001/10/16 05:31:19 dgp Exp $ + * RCS: @(#) $Id: tclUtf.c,v 1.20 2002/01/02 13:52:04 dkf Exp $ */ #include "tclInt.h" @@ -1691,6 +1691,9 @@ Tcl_UniCharCaseMatch(string, pattern, nocase) if (p == 0) { return 1; } + if (nocase) { + p = Tcl_UniCharToLower(p); + } while (1) { /* * Optimization for matching - cruise through the string diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 11134be..52a5566 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -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: tclUtil.c,v 1.26 2001/11/21 02:36:21 hobbs Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.27 2002/01/02 13:52:04 dkf Exp $ */ #include "tclInt.h" @@ -1227,6 +1227,10 @@ Tcl_StringCaseMatch(string, pattern, nocase) if (p == '\0') { return 1; } + Tcl_UtfToUniChar(pattern, &ch2); + if (nocase) { + ch2 = Tcl_UniCharToLower(ch2); + } while (1) { /* * Optimization for matching - cruise through the string @@ -1235,16 +1239,25 @@ Tcl_StringCaseMatch(string, pattern, nocase) */ if ((p != '[') && (p != '?') && (p != '\\')) { if (nocase) { - while (*string && (p != *string)) { - ch2 = Tcl_UtfToUniChar(string, &ch1); - if (p == Tcl_UniCharToLower(ch1)) { + while (*string) { + int charLen = Tcl_UtfToUniChar(string, &ch1); + if (ch2==ch1 || ch2==Tcl_UniCharToLower(ch1)) { break; } - string += ch2; + string += charLen; } } else { - while (*string && (p != *string)) { - string += Tcl_UtfToUniChar(string, &ch1); + /* + * There's no point in trying to make this code + * shorter, as the number of bytes you want to + * compare each time is non-constant. + */ + while (*string) { + int charLen = Tcl_UtfToUniChar(string, &ch1); + if (ch2 == ch1) { + break; + } + string += charLen; } } } |