diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-04-29 11:10:44 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-04-29 11:10:44 (GMT) |
commit | 45b096ac88e551fb40f84b02f14bd6bb2cdfdcdb (patch) | |
tree | bcfb07fec474c675fe1700fd288ce349f47bf603 /generic/tclTest.c | |
parent | 3f01cc8310e47f5510f89433b511863751e92c3a (diff) | |
download | tcl-45b096ac88e551fb40f84b02f14bd6bb2cdfdcdb.zip tcl-45b096ac88e551fb40f84b02f14bd6bb2cdfdcdb.tar.gz tcl-45b096ac88e551fb40f84b02f14bd6bb2cdfdcdb.tar.bz2 |
Better structurize the UTF-8 (mainly around Tcl_UtfNext()/Tcl_UtfPrev(), but not only those) test-cases:
Selector "ucs2" is meant for Tcl 8.5: No knowledge at all about 4-byte sequences.
Selector "ucs4" is meant for Tcl 8.5 or 8.7 with TCL_UTF_MAX=4 or Tcl 8.6 with TCL_UTF_MAX=6
Selector "tip389" is meant for Tcl 8.6 with TCL_UTF_MAX=4 and Tcl 8.7 with TCL_UTF_MAX=3
(of course, this is too simple: there will be testcases needing more than those 3
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r-- | generic/tclTest.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c index 2178647..4c13850 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -6825,21 +6825,14 @@ TestUtfNextCmd( char *bytes; const char *result, *first; char buffer[32]; - static const char tobetested[] = "\xFF\xFE\xF4\xF2\xF0\xEF\xE8\xE3\xE2\xE1\xE0\xC2\xC1\xC0\x82"; + static const char tobetested[] = "A\xA0\xC0\xC1\xC2\xD0\xE0\xE8\xF2\xF7\xF8\xFE\xFF"; const char *p = tobetested; - if (objc != 3 || strcmp(Tcl_GetString(objv[1]), "-bytestring")) { - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "?-bytestring? bytes"); - return TCL_ERROR; - } - bytes = Tcl_GetStringFromObj(objv[1], &numBytes); - } else { - bytes = (char *) TclGetBytesFromObj(interp, objv[2], &numBytes); - if (bytes == NULL) { - return TCL_ERROR; - } + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "?-bytestring? bytes"); + return TCL_ERROR; } + bytes = Tcl_GetStringFromObj(objv[1], &numBytes); if (numBytes > (int)sizeof(buffer)-3) { Tcl_AppendResult(interp, "\"testutfnext\" can only handle 29 bytes", NULL); @@ -6888,17 +6881,13 @@ TestUtfPrevCmd( int numBytes, offset; char *bytes; const char *result; - Tcl_Obj *copy; if (objc < 2 || objc > 3) { Tcl_WrongNumArgs(interp, 1, objv, "bytes ?offset?"); return TCL_ERROR; } - bytes = (char *) TclGetBytesFromObj(interp, objv[1], &numBytes); - if (bytes == NULL) { - return TCL_ERROR; - } + bytes = Tcl_GetStringFromObj(objv[1], &numBytes); if (objc == 3) { if (TCL_OK != Tcl_GetIntForIndex(interp, objv[2], numBytes, &offset)) { @@ -6913,14 +6902,8 @@ TestUtfPrevCmd( } else { offset = numBytes; } - copy = Tcl_DuplicateObj(objv[1]); - bytes = (char *) Tcl_SetByteArrayLength(copy, numBytes+1); - bytes[numBytes] = '\0'; - result = TclUtfPrev(bytes + offset, bytes); Tcl_SetObjResult(interp, Tcl_NewIntObj(result - bytes)); - - Tcl_DecrRefCount(copy); return TCL_OK; } |