summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-31 07:08:34 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-31 07:08:34 (GMT)
commit3185a0b150227fd5a8b75fe426d4f4caa0931e77 (patch)
tree9b7857ba093185ae02263f3fa0c7251bd4a7c5aa /generic/tclStringObj.c
parenta2a0ca2a1734d496f9500dc2ae02772a9eac548d (diff)
parentb1a8dc460f2e7f8a7ff436f52729f729ead3b92d (diff)
downloadtcl-3185a0b150227fd5a8b75fe426d4f4caa0931e77.zip
tcl-3185a0b150227fd5a8b75fe426d4f4caa0931e77.tar.gz
tcl-3185a0b150227fd5a8b75fe426d4f4caa0931e77.tar.bz2
Merge 9.0. Restore some testcases working correctly with TCL_UTF_MAX=3
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index fdc39cf..f1dc0f5 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -70,8 +70,14 @@ static void SetUnicodeObj(Tcl_Obj *objPtr,
static size_t UnicodeLength(const Tcl_UniChar *unicode);
static void UpdateStringOfString(Tcl_Obj *objPtr);
+#if TCL+UTF_MAX > 3
#define ISCONTINUATION(bytes) (\
((bytes)[0] & 0xC0) == 0x80)
+#else
+#define ISCONTINUATION(bytes) (\
+ ((((bytes)[0] & 0xC0) == 0x80) || (((bytes)[0] == '\xED') \
+ && (((bytes)[1] & 0xF0) == 0xB0) && (((bytes)[2] & 0xC0) == 0x80))))
+#endif
/*
@@ -673,9 +679,6 @@ Tcl_GetRange(
if (first == TCL_INDEX_NONE) {
first = TCL_INDEX_START;
}
- if (last + 2 <= first + 1) {
- return Tcl_NewObj();
- }
/*
* Optimize the case where we're really dealing with a bytearray object
@@ -688,7 +691,7 @@ Tcl_GetRange(
if (last >= length) {
last = length - 1;
}
- if (last < first) {
+ if (last + 1 < first + 1) {
TclNewObj(newObjPtr);
return newObjPtr;
}
@@ -714,7 +717,7 @@ Tcl_GetRange(
if (last >= stringPtr->numChars) {
last = stringPtr->numChars - 1;
}
- if (last < first) {
+ if (last + 1 < first + 1) {
TclNewObj(newObjPtr);
return newObjPtr;
}
@@ -735,7 +738,7 @@ Tcl_GetRange(
if (last >= stringPtr->numChars) {
last = stringPtr->numChars - 1;
}
- if (last < first) {
+ if (last + 1 < first + 1) {
TclNewObj(newObjPtr);
return newObjPtr;
}