summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-06-08 12:50:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-06-08 12:50:00 (GMT)
commit7bf7c6e7d90d4b7913115508c91115db89868d48 (patch)
tree4be3daeed3b84d3d735bc003b5de8c808b2a4f92
parent4276e234955e8ecdc91fd5d2ebee1acbb35753ad (diff)
downloadtcl-7bf7c6e7d90d4b7913115508c91115db89868d48.zip
tcl-7bf7c6e7d90d4b7913115508c91115db89868d48.tar.gz
tcl-7bf7c6e7d90d4b7913115508c91115db89868d48.tar.bz2
Revert part of [95d096e0378b460c6c5168bb55bb2ca8b2fd799e|95d096e037]: Missed the fact that tolower() was optimized for the ASCII case as well, so this was a mistake!
-rw-r--r--generic/tclUtil.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 3fdf54b..553593c 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -2162,9 +2162,14 @@ Tcl_StringCaseMatch(
* This is a special case optimization for single-byte utf.
*/
- TclUtfToUniChar(pattern, &ch2);
- if (nocase) {
- ch2 = Tcl_UniCharToLower(ch2);
+ if (UCHAR(*pattern) < 0x80) {
+ ch2 = (Tcl_UniChar)
+ (nocase ? tolower(UCHAR(*pattern)) : UCHAR(*pattern));
+ } else {
+ Tcl_UtfToUniChar(pattern, &ch2);
+ if (nocase) {
+ ch2 = Tcl_UniCharToLower(ch2);
+ }
}
while (1) {
@@ -2230,26 +2235,44 @@ Tcl_StringCaseMatch(
Tcl_UniChar startChar, endChar;
pattern++;
- str += TclUtfToUniChar(str, &ch1);
- if (nocase) {
- ch1 = Tcl_UniCharToLower(ch1);
+ if (UCHAR(*str) < 0x80) {
+ ch1 = (Tcl_UniChar)
+ (nocase ? tolower(UCHAR(*str)) : UCHAR(*str));
+ str++;
+ } else {
+ str += Tcl_UtfToUniChar(str, &ch1);
+ if (nocase) {
+ ch1 = Tcl_UniCharToLower(ch1);
+ }
}
while (1) {
if ((*pattern == ']') || (*pattern == '\0')) {
return 0;
}
- pattern += TclUtfToUniChar(pattern, &startChar);
- if (nocase) {
- startChar = Tcl_UniCharToLower(startChar);
+ if (UCHAR(*pattern) < 0x80) {
+ startChar = (Tcl_UniChar) (nocase
+ ? tolower(UCHAR(*pattern)) : UCHAR(*pattern));
+ pattern++;
+ } else {
+ pattern += Tcl_UtfToUniChar(pattern, &startChar);
+ if (nocase) {
+ startChar = Tcl_UniCharToLower(startChar);
+ }
}
if (*pattern == '-') {
pattern++;
if (*pattern == '\0') {
return 0;
}
- pattern += TclUtfToUniChar(pattern, &endChar);
- if (nocase) {
- endChar = Tcl_UniCharToLower(endChar);
+ if (UCHAR(*pattern) < 0x80) {
+ endChar = (Tcl_UniChar) (nocase
+ ? tolower(UCHAR(*pattern)) : UCHAR(*pattern));
+ pattern++;
+ } else {
+ pattern += Tcl_UtfToUniChar(pattern, &endChar);
+ if (nocase) {
+ endChar = Tcl_UniCharToLower(endChar);
+ }
}
if (((startChar <= ch1) && (ch1 <= endChar))
|| ((endChar <= ch1) && (ch1 <= startChar))) {