summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-11-09 18:55:13 (GMT)
committerhobbs <hobbs>2007-11-09 18:55:13 (GMT)
commit2ebefee1b05df6c41125e6bc8ed768c0cc4f50dc (patch)
tree2279f9c57d51ffd67adb4ac91577b40b49ecd3ad /generic/tclUtil.c
parent51c3524facba45f2ebda897b58b073fb0e932024 (diff)
downloadtcl-2ebefee1b05df6c41125e6bc8ed768c0cc4f50dc.zip
tcl-2ebefee1b05df6c41125e6bc8ed768c0cc4f50dc.tar.gz
tcl-2ebefee1b05df6c41125e6bc8ed768c0cc4f50dc.tar.bz2
* generic/tclInt.decls, generic/tclIntDecls.h: Use unsigned char for
* generic/tclExecute.c, generic/tclUtil.c: TclByteArrayMatch and don't allow a nocase option. [Bug 1828296] For INST_STR_MATCH, ignore pattern type for TclByteArrayMatch case.
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index a95f250..815769a 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.85 2007/11/08 00:50:32 hobbs Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.86 2007/11/09 18:55:16 hobbs Exp $
*/
#include "tclInt.h"
@@ -1555,9 +1555,9 @@ Tcl_StringCaseMatch(
*
* TclByteArrayMatch --
*
- * See if a particular string matches a particular pattern. Allows case
- * insensitivity.
- * Parallels tclUtf.c:TclUniCharMatch, adjusted for char*.
+ * See if a particular string matches a particular pattern. Does not
+ * allow for case insensitivity.
+ * Parallels tclUtf.c:TclUniCharMatch, adjusted for char* and sans nocase.
*
* Results:
* The return value is 1 if string matches pattern, and 0 otherwise. The
@@ -1572,15 +1572,14 @@ Tcl_StringCaseMatch(
int
TclByteArrayMatch(
- CONST char *string, /* String. */
- int strLen, /* Length of String */
- CONST char *pattern, /* Pattern, which may contain special
- * characters. */
- int ptnLen, /* Length of Pattern */
- int nocase) /* 0 for case sensitive, 1 for insensitive */
+ const unsigned char *string, /* String. */
+ int strLen, /* Length of String */
+ const unsigned char *pattern, /* Pattern, which may contain special
+ * characters. */
+ int ptnLen) /* Length of Pattern */
{
- CONST char *stringEnd, *patternEnd;
- char p;
+ const unsigned char *stringEnd, *patternEnd;
+ unsigned char p;
stringEnd = string + strLen;
patternEnd = pattern + ptnLen;
@@ -1620,9 +1619,6 @@ TclByteArrayMatch(
return 1;
}
p = *pattern;
- if (nocase) {
- p = tolower(p);
- }
while (1) {
/*
* Optimization for matching - cruise through the string
@@ -1631,19 +1627,12 @@ TclByteArrayMatch(
*/
if ((p != '[') && (p != '?') && (p != '\\')) {
- if (nocase) {
- while ((string < stringEnd) && (p != *string)
- && (p != tolower(*string))) {
- string++;
- }
- } else {
- while ((string < stringEnd) && (p != *string)) {
- string++;
- }
+ while ((string < stringEnd) && (p != *string)) {
+ string++;
}
}
if (TclByteArrayMatch(string, stringEnd - string,
- pattern, patternEnd - pattern, nocase)) {
+ pattern, patternEnd - pattern)) {
return 1;
}
if (string == stringEnd) {
@@ -1671,23 +1660,23 @@ TclByteArrayMatch(
*/
if (p == '[') {
- char ch1, startChar, endChar;
+ unsigned char ch1, startChar, endChar;
pattern++;
- ch1 = (nocase ? tolower(*string) : *string);
+ ch1 = *string;
string++;
while (1) {
if ((*pattern == ']') || (pattern == patternEnd)) {
return 0;
}
- startChar = (nocase ? tolower(*pattern) : *pattern);
+ startChar = *pattern;
pattern++;
if (*pattern == '-') {
pattern++;
if (pattern == patternEnd) {
return 0;
}
- endChar = (nocase ? tolower(*pattern) : *pattern);
+ endChar = *pattern;
pattern++;
if (((startChar <= ch1) && (ch1 <= endChar))
|| ((endChar <= ch1) && (ch1 <= startChar))) {
@@ -1727,11 +1716,7 @@ TclByteArrayMatch(
* each string match.
*/
- if (nocase) {
- if (tolower(*string) != tolower(*pattern)) {
- return 0;
- }
- } else if (*string != *pattern) {
+ if (*string != *pattern) {
return 0;
}
string++;