summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
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++;