diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-04-15 19:54:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-04-15 19:54:58 (GMT) |
commit | 53e02bac83ed7e43fb2c36f14b70a7b083de580f (patch) | |
tree | 68e6ca99d3ce79ff5db7cd5d740409b5721d045d | |
parent | ccded0d96e80633b00f0fa1435643ba755a488b7 (diff) | |
parent | 2ca7fe6104b48f174bf68f4b3179b19f660fc0ab (diff) | |
download | tcl-53e02bac83ed7e43fb2c36f14b70a7b083de580f.zip tcl-53e02bac83ed7e43fb2c36f14b70a7b083de580f.tar.gz tcl-53e02bac83ed7e43fb2c36f14b70a7b083de580f.tar.bz2 |
Merge 8.6
-rw-r--r-- | generic/tclTest.c | 59 | ||||
-rw-r--r-- | generic/tclUtf.c | 4 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 2 |
3 files changed, 57 insertions, 8 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c index 157f0c1..c872bd0 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -316,6 +316,7 @@ static Tcl_FSListVolumesProc SimpleListVolumes; static Tcl_FSPathInFilesystemProc SimplePathInFilesystem; static Tcl_Obj * SimpleRedirect(Tcl_Obj *pathPtr); static Tcl_FSMatchInDirectoryProc SimpleMatchInDirectory; +static Tcl_ObjCmdProc TestUtfNextCmd; static Tcl_ObjCmdProc TestUtfPrevCmd; static Tcl_ObjCmdProc TestNumUtfCharsCmd; static Tcl_ObjCmdProc TestFindFirstCmd; @@ -578,8 +579,10 @@ Tcltest_Init( NULL, NULL); Tcl_CreateObjCommand(interp, "testsetobjerrorcode", TestsetobjerrorcodeCmd, NULL, NULL); + Tcl_CreateObjCommand(interp, "testutfnext", + TestUtfNextCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testutfprev", - TestUtfPrevCmd, (ClientData) 0, NULL); + TestUtfPrevCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testnumutfchars", TestNumUtfCharsCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testfindfirst", @@ -6811,6 +6814,52 @@ SimpleListVolumes(void) } /* + * Used to check operations of Tcl_UtfNext. + * + * Usage: testutfnext $bytes $offset + */ + +static int +TestUtfNextCmd( + TCL_UNUSED(void *), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) +{ + int numBytes, offset = 0; + 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 *) Tcl_GetByteArrayFromObj(objv[1], &numBytes); + + if (objc == 3) { + if (TCL_OK != Tcl_GetIntForIndex(interp, objv[2], numBytes, &offset)) { + return TCL_ERROR; + } + if (offset < 0) { + offset = 0; + } + if (offset > numBytes) { + offset = numBytes; + } + } + copy = Tcl_DuplicateObj(objv[1]); + bytes = (char *) Tcl_SetByteArrayLength(copy, numBytes+1); + bytes[numBytes] = '\0'; + + result = Tcl_UtfNext(bytes + offset); + Tcl_SetObjResult(interp, Tcl_NewIntObj(result - bytes)); + + Tcl_DecrRefCount(copy); + return TCL_OK; +} +/* * Used to check operations of Tcl_UtfPrev. * * Usage: testutfprev $bytes $offset @@ -6827,16 +6876,16 @@ TestUtfPrevCmd( 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 *) Tcl_GetByteArrayFromObj(objv[1], &numBytes); - + if (objc == 3) { - if (TCL_OK != Tcl_GetIntFromObj(interp, objv[2], &offset)) { + if (TCL_OK != Tcl_GetIntForIndex(interp, objv[2], numBytes, &offset)) { return TCL_ERROR; } if (offset < 0) { @@ -6853,9 +6902,9 @@ TestUtfPrevCmd( bytes[numBytes] = '\0'; result = Tcl_UtfPrev(bytes + offset, bytes); + Tcl_SetObjResult(interp, Tcl_NewIntObj(result - bytes)); Tcl_DecrRefCount(copy); - Tcl_SetObjResult(interp, Tcl_NewIntObj(result - bytes)); return TCL_OK; } diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 5908f36..2a04414 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -898,7 +898,7 @@ Tcl_UtfNext( * starts a character when characters are read starting at start and * that character might include the byte src[-1]. The routine will * examine only those bytes in the range that might be returned. - * It will not examine the byte *src, and because of that cannot + * It will not examine the byte *src, and because of that cannot * determine for certain in all circumstances whether the character * that begins with the returned pointer will or will not include * the byte src[-1]. In the scenario, where src points to the end of @@ -913,7 +913,7 @@ Tcl_UtfNext( * prevented from running past the beginning of the string. * * In a string where all characters are complete and properly formed, - * and the value of src points to the first byte of a character, + * and the value of src points to the first byte of a character, * repeated Tcl_UtfPrev calls will step to the starting bytes of * characters, one character at a time. Within those limitations, * Tcl_UtfPrev and Tcl_UtfNext are inverses. If either condition cannot diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index b707be4..cb20166 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -1009,7 +1009,7 @@ TcpThreadActionProc( if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) { /* * Async-connecting socket must get reassigned handler if it have been - * transferred to another thread. Remove the handler if the socket is + * transferred to another thread. Remove the handler if the socket is * not managed by this thread anymore and create new handler (TSD related) * so the callback will run in the correct thread, bug [f583715154]. */ |