Tcl Source Code

Check-in [a765f37f78]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Slight improvement: if cs = "\xC0\x80" and ct = "\x00", loop would continue after NUL-byte, this should not happen.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3613609
Files: files | file ages | folders
SHA1: a765f37f7893e23f18bdc72a8e982cb2b5086eb9
User & Date: jan.nijtmans 2013-05-21 09:38:05
Context
2013-05-22
12:32
Improved tests. check-in: 1fbbe4aec3 user: dkf tags: bug-3613609
2013-05-21
09:38
Slight improvement: if cs = "\xC0\x80" and ct = "\x00", loop would continue after NUL-byte, this sho... check-in: a765f37f78 user: jan.nijtmans tags: bug-3613609
09:27
Proposed solution for 3613609: lsort -nocase does not sort non-ASCII correctly check-in: 66c30c4369 user: jan.nijtmans tags: bug-3613609
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclUtf.c.

1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
/* Replacement for strcasecmp in Tcl core, in places where UTF-8 should be handled. */
int
TclUtfCasecmp(
    CONST char *cs,		/* UTF string to compare to ct. */
    CONST char *ct)		/* UTF string cs is compared to. */
{
    Tcl_UniChar ch1, ch2;
    char c;

    do {

	/* If c == '\0', loop should end. */
   	c = *cs;

	cs += TclUtfToUniChar(cs, &ch1);
	ct += TclUtfToUniChar(ct, &ch2);
	if (ch1 != ch2) {
	    ch1 = Tcl_UniCharToLower(ch1);
	    ch2 = Tcl_UniCharToLower(ch2);
	    if (ch1 != ch2) break;
	}
    } while (c);
    return (ch1 - ch2);
}

 
/*
 *----------------------------------------------------------------------
 *






|



|
|








|







1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
/* Replacement for strcasecmp in Tcl core, in places where UTF-8 should be handled. */
int
TclUtfCasecmp(
    CONST char *cs,		/* UTF string to compare to ct. */
    CONST char *ct)		/* UTF string cs is compared to. */
{
    Tcl_UniChar ch1, ch2;
    int goOn;

    do {

	/* If *cs == '\0' or *ct == '\0', loop should end. */
	goOn = *cs && *ct;

	cs += TclUtfToUniChar(cs, &ch1);
	ct += TclUtfToUniChar(ct, &ch2);
	if (ch1 != ch2) {
	    ch1 = Tcl_UniCharToLower(ch1);
	    ch2 = Tcl_UniCharToLower(ch2);
	    if (ch1 != ch2) break;
	}
    } while (goOn);
    return (ch1 - ch2);
}

 
/*
 *----------------------------------------------------------------------
 *