summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-19 19:38:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-19 19:38:10 (GMT)
commit9589c85462da7e8d01fe0154de892c6d30d92f0d (patch)
tree748e6bc9110e6e510384467e0bddc482b5037aaa /generic/tclCmdMZ.c
parent2473a591bfbd5b346e1900e3c1088496b0d17590 (diff)
downloadtcl-9589c85462da7e8d01fe0154de892c6d30d92f0d.zip
tcl-9589c85462da7e8d01fe0154de892c6d30d92f0d.tar.gz
tcl-9589c85462da7e8d01fe0154de892c6d30d92f0d.tar.bz2
Minor optimizations
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index c17c4f1..a289a5c 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1221,7 +1221,7 @@ Tcl_SplitObjCmd(
fullchar = ch;
#if TCL_UTF_MAX <= 4
- if ((len == 1) && ((ch & 0xFC00) == 0xD800)) {
+ if ((ch >= 0xD800) && (len < 3)) {
len += TclUtfToUniChar(stringPtr + len, &ch);
fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
}
@@ -1447,8 +1447,8 @@ StringIndexCmd(
char buf[4];
length = Tcl_UniCharToUtf(ch, buf);
- if (!length) {
- length = Tcl_UniCharToUtf(-1, buf);
+ if ((ch >= 0xD800) && (length < 3)) {
+ length = Tcl_UniCharToUtf(-1, buf + length);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, length));
}
@@ -1854,7 +1854,7 @@ StringIsCmd(
length2 = TclUtfToUniChar(string1, &ch);
fullchar = ch;
#if TCL_UTF_MAX <= 4
- if ((length2 == 1) && ((ch & 0xFC00) == 0xD800)) {
+ if ((ch >= 0xD800) && (length2 < 3)) {
length2 += TclUtfToUniChar(string1 + length2, &ch);
fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000;
}
@@ -1935,7 +1935,7 @@ StringMapCmd(
const char *string = TclGetStringFromObj(objv[1], &length2);
if ((length2 > 1) &&
- strncmp(string, "-nocase", (size_t) length2) == 0) {
+ strncmp(string, "-nocase", length2) == 0) {
nocase = 1;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2203,7 +2203,7 @@ StringMatchCmd(
const char *string = TclGetStringFromObj(objv[1], &length);
if ((length > 1) &&
- strncmp(string, "-nocase", (size_t) length) == 0) {
+ strncmp(string, "-nocase", length) == 0) {
nocase = TCL_MATCH_NOCASE;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2605,10 +2605,10 @@ StringEqualCmd(
for (i = 1; i < objc-2; i++) {
string2 = TclGetStringFromObj(objv[i], &length);
- if ((length > 1) && !strncmp(string2, "-nocase", (size_t)length)) {
+ if ((length > 1) && !strncmp(string2, "-nocase", length)) {
nocase = 1;
} else if ((length > 1)
- && !strncmp(string2, "-length", (size_t)length)) {
+ && !strncmp(string2, "-length", length)) {
if (i+1 >= objc-2) {
goto str_cmp_args;
}
@@ -2703,10 +2703,10 @@ TclStringCmpOpts(
for (i = 1; i < objc-2; i++) {
string = TclGetStringFromObj(objv[i], &length);
- if ((length > 1) && !strncmp(string, "-nocase", (size_t)length)) {
+ if ((length > 1) && !strncmp(string, "-nocase", length)) {
*nocase = 1;
} else if ((length > 1)
- && !strncmp(string, "-length", (size_t)length)) {
+ && !strncmp(string, "-length", length)) {
if (i+1 >= objc-2) {
goto str_cmp_args;
}