From 28add0c150860d7b0ddbee462e76b17aa2089862 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 20 Mar 2023 21:06:09 +0000 Subject: More TclNewIndexObj() usages (for values between -1 and SIZE_MAX-1) --- generic/tcl.decls | 2 +- generic/tcl.h | 2 +- generic/tclBasic.c | 35 ++++++++++++++++++----------------- generic/tclEncoding.c | 14 +++++++------- generic/tclIOCmd.c | 5 ++++- tests/icuUcmTests.tcl | 2 +- 6 files changed, 32 insertions(+), 28 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index 1608a88..6d0cd3e 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2506,7 +2506,7 @@ declare 658 { int Tcl_ExternalToUtfDStringEx(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, Tcl_Size *errorLocationPtr) -} +} declare 659 { int Tcl_UtfToExternalDStringEx(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_DString *dsPtr, diff --git a/generic/tcl.h b/generic/tcl.h index 94a4c9b..ae0e19e 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1947,7 +1947,7 @@ typedef struct Tcl_EncodingType { * TCL_ENCODING_PROFILE_* - Mutually exclusive encoding profile ids. Note * these are bit masks. * - * NOTE: THESE BIT DEFINITIONS SHOULD NOT OVERLAP WITH INTERNAL USE BITS + * NOTE: THESE BIT DEFINITIONS SHOULD NOT OVERLAP WITH INTERNAL USE BITS * DEFINED IN tclEncoding.c (ENCODING_INPUT et al). Be cognizant of this * when adding bits. */ diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 381d127..9b1b5a5 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -9554,24 +9554,25 @@ InjectHandler( Tcl_Obj **objv; if (!isProbe) { - /* - * If this is [coroinject], add the extra arguments now. - */ - - if (nargs == COROUTINE_ARGUMENTS_SINGLE_OPTIONAL) { - Tcl_ListObjAppendElement(NULL, listPtr, - Tcl_NewStringObj("yield", TCL_INDEX_NONE)); - } else if (nargs == COROUTINE_ARGUMENTS_ARBITRARY) { - Tcl_ListObjAppendElement(NULL, listPtr, - Tcl_NewStringObj("yieldto", TCL_INDEX_NONE)); - } else { - /* - * I don't think this is reachable... - */ + /* + * If this is [coroinject], add the extra arguments now. + */ - Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewWideIntObj((Tcl_WideInt)(nargs + 1U) - 1)); - } - Tcl_ListObjAppendElement(NULL, listPtr, Tcl_GetObjResult(interp)); + if (nargs == COROUTINE_ARGUMENTS_SINGLE_OPTIONAL) { + Tcl_ListObjAppendElement(NULL, listPtr, + Tcl_NewStringObj("yield", TCL_INDEX_NONE)); + } else if (nargs == COROUTINE_ARGUMENTS_ARBITRARY) { + Tcl_ListObjAppendElement(NULL, listPtr, + Tcl_NewStringObj("yieldto", TCL_INDEX_NONE)); + } else { + /* + * I don't think this is reachable... + */ + Tcl_Obj *nargsObj; + TclNewIndexObj(nargsObj, nargs); + Tcl_ListObjAppendElement(NULL, listPtr, nargsObj); + } + Tcl_ListObjAppendElement(NULL, listPtr, Tcl_GetObjResult(interp)); } /* diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index f9a5e6a..1e76dc4 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -553,11 +553,11 @@ FillEncodingFileMap(void) *--------------------------------------------------------------------------- */ -/* - * NOTE: THESE BIT DEFINITIONS SHOULD NOT OVERLAP WITH INTERNAL USE BITS +/* + * NOTE: THESE BIT DEFINITIONS SHOULD NOT OVERLAP WITH INTERNAL USE BITS * DEFINED IN tcl.h (TCL_ENCODING_* et al). Be cognizant of this * when adding bits. TODO - should really be defined in a single file. - * + * * To prevent conflicting bits, only define bits within 0xff00 mask here. */ #define TCL_ENCODING_LE 0x100 /* Used to distinguish LE/BE variants */ @@ -2815,7 +2815,7 @@ Utf32ToUtfProc( break; } else if (PROFILE_REPLACE(flags) && SURROGATE(ch)) { ch = UNICODE_REPLACE_CHAR; - } + } /* * Special case for 1-byte utf chars for speed. Make sure we work with @@ -3060,7 +3060,7 @@ Utf16ToUtfProc( numChars--; break; } else if (PROFILE_REPLACE(flags)) { - /* + /* * Previous loop wrote a single byte to mark the high surrogate. * Replace it with the replacement character. Further, restart * current loop iteration since need to recheck destination space @@ -4509,7 +4509,7 @@ TclEncodingProfileNameToId( if (interp) { Tcl_Obj *errorObj; /* This code assumes at least two profiles :-) */ - errorObj = + errorObj = Tcl_ObjPrintf("bad profile name \"%s\": must be", profileName); for (i = 0; i < (numProfiles - 1); ++i) { @@ -4576,7 +4576,7 @@ TclEncodingProfileIdToName( * is mapped to the TCL_ENCODING_PROFILE_STRICT overwriting any profile * specified. * - * If no profile or an invalid profile is specified, it is set to + * If no profile or an invalid profile is specified, it is set to * the default. * * Results: diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 6ec5891..cdb8083 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -10,6 +10,7 @@ */ #include "tclInt.h" +#include "tclTomMath.h" /* * Callback structure for accept callback in a TCP server. @@ -330,7 +331,9 @@ Tcl_GetsObjCmd( code = TCL_ERROR; goto done; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)((Tcl_WideUInt)(lineLen + 1U)) - 1)); + Tcl_Obj *lineLenObj; + TclNewIndexObj(lineLenObj, lineLen); + Tcl_SetObjResult(interp, lineLenObj); } else { Tcl_SetObjResult(interp, linePtr); } diff --git a/tests/icuUcmTests.tcl b/tests/icuUcmTests.tcl index 0c4071f..3b70748 100644 --- a/tests/icuUcmTests.tcl +++ b/tests/icuUcmTests.tcl @@ -45,7 +45,7 @@ if {[info commands printable] eq ""} { return $print } } - + # # cp1250 (generated from glibc-CP1250-2.1.2) -- cgit v0.12