summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclInt.h6
-rw-r--r--generic/tclUtf.c35
2 files changed, 9 insertions, 32 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index a50bf7d..16e1aa8 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3251,7 +3251,11 @@ MODULE_SCOPE void TclRegisterCommandTypeName(
MODULE_SCOPE int TclUtfCmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCount(int ch);
-MODULE_SCOPE int TclUtfToUCS4(const char *src, int *ucs4Ptr);
+#if TCL_UTF_MAX > 3
+# define TclUtfToUCS4 Tcl_UtfToUniChar
+#else
+ MODULE_SCOPE int TclUtfToUCS4(const char *src, int *ucs4Ptr);
+#endif
MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData);
MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr);
MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr,
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index e65f44d..47855dd 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -2443,44 +2443,17 @@ TclUniCharMatch(
*---------------------------------------------------------------------------
*/
+#if TCL_UTF_MAX <= 3
int
TclUtfToUCS4(
const char *src, /* The UTF-8 string. */
int *ucs4Ptr) /* Filled with the UCS4 codepoint represented
* by the UTF-8 string. */
{
- int len, fullchar;
- Tcl_UniChar ch = 0;
-
- len = TclUtfToUniChar(src, &ch);
- fullchar = ch;
-
-#if TCL_UTF_MAX <= 3
- /* Limited interfaces -- must use and decode surrogates */
-
- if ((ch >= 0xD800) && len < 3) {
-/******
- ****** Note the #undef TCL_UtfToUniChar gets in our way here.
- ******
- len += Tcl_UtfToUniChar(src + len, &ch);
- ******
- ****** We have to do the subtitution ourselves.
- ******/
-
- len += Tcl_UtfToChar16(src + len, &ch);
-
-/******
- ****** We might also solve this by moving this routine higher in the file.
- ****** Or there might be a more sensible foundation in this branch.
- ******/
-
- fullchar = (((fullchar & 0x3FF) << 10) | (ch & 0x3FF)) + 0x10000;
- }
-#endif
-
- *ucs4Ptr = fullchar;
- return len;
+ /* Make use of the #undef Tcl_UtfToUniChar above, which already handles UCS4. */
+ return Tcl_UtfToUniChar(src, &ch);
}
+#endif
/*
* Local Variables: