diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-16 23:21:20 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-16 23:21:20 (GMT) |
commit | 4b1dc921ef04bb9bce6f37daf7c15c30f325ff5e (patch) | |
tree | 52cba60bacedffb3570138e2bd4a6096981d8c37 | |
parent | bf9931fbfa4e7ff35d60d115f5f63e886305af3d (diff) | |
download | tcl-4b1dc921ef04bb9bce6f37daf7c15c30f325ff5e.zip tcl-4b1dc921ef04bb9bce6f37daf7c15c30f325ff5e.tar.gz tcl-4b1dc921ef04bb9bce6f37daf7c15c30f325ff5e.tar.bz2 |
Revise macro usage
-rw-r--r-- | generic/tclBinary.c | 2 | ||||
-rw-r--r-- | generic/tclCkalloc.c | 4 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 4 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 9 | ||||
-rw-r--r-- | generic/tclIO.c | 2 | ||||
-rw-r--r-- | generic/tclIOCmd.c | 6 | ||||
-rw-r--r-- | generic/tclIORChan.c | 4 | ||||
-rw-r--r-- | generic/tclInt.h | 30 | ||||
-rw-r--r-- | generic/tclLink.c | 2 | ||||
-rw-r--r-- | generic/tclObj.c | 13 | ||||
-rw-r--r-- | generic/tclProc.c | 2 | ||||
-rw-r--r-- | generic/tclScan.c | 2 | ||||
-rw-r--r-- | generic/tclTimer.c | 2 | ||||
-rw-r--r-- | generic/tclZlib.c | 8 | ||||
-rw-r--r-- | unix/tclUnixFCmd.c | 8 |
15 files changed, 39 insertions, 59 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 545ff7d..429f7c1 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2629,7 +2629,7 @@ BinaryEncode64( } switch (index) { case OPT_MAXLEN: - if (Tcl_GetWideIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) { return TCL_ERROR; } if (maxlen < 0) { diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 324755d..6b989c9 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -837,7 +837,7 @@ MemoryCmd( if (objc != 3) { goto argError; } - if (Tcl_GetWideIntFromObj(interp, objv[2], &value) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[2], &value) != TCL_OK) { return TCL_ERROR; } break_on_malloc = value; @@ -922,7 +922,7 @@ MemoryCmd( if (objc != 3) { goto argError; } - if (Tcl_GetWideIntFromObj(interp, objv[2], &value) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[2], &value) != TCL_OK) { return TCL_ERROR; } trace_on_at_malloc = value; diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 6644d45..fb31d44 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3468,7 +3468,7 @@ Tcl_LsearchObjCmd( result = TCL_ERROR; goto done; } - if (Tcl_GetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) { result = TCL_ERROR; goto done; } @@ -4722,7 +4722,7 @@ Tcl_LsortObjCmd( sortInfo.resultCode = TCL_ERROR; goto done; } - if (Tcl_GetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i+1], &wide) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; goto done; } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 7231548..74d6a83 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -2662,7 +2662,7 @@ StringEqualCmd( goto str_cmp_args; } i++; - if (Tcl_GetWideIntFromObj(interp, objv[i], &reqlength) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i], &reqlength) != TCL_OK) { return TCL_ERROR; } if ((Tcl_WideUInt)reqlength > TCL_SIZE_MAX) { @@ -2765,7 +2765,7 @@ StringCmpOpts( goto str_cmp_args; } i++; - if (Tcl_GetWideIntFromObj(interp, objv[i], &wreqlength) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i], &wreqlength) != TCL_OK) { return TCL_ERROR; } if ((Tcl_WideUInt)wreqlength > TCL_SIZE_MAX) { @@ -4202,14 +4202,15 @@ Tcl_TimeRateObjCmd( } objPtr = objv[i++]; if (i < objc) { /* max-time */ - result = Tcl_GetWideIntFromObj(interp, objv[i++], &maxms); + result = TclGetWideIntFromObj(interp, objv[i], &maxms); + i++; // Keep this separate from TclGetWideIntFromObj macro above! if (result != TCL_OK) { return result; } if (i < objc) { /* max-count*/ Tcl_WideInt v; - result = Tcl_GetWideIntFromObj(interp, objv[i], &v); + result = TclGetWideIntFromObj(interp, objv[i], &v); if (result != TCL_OK) { return result; } diff --git a/generic/tclIO.c b/generic/tclIO.c index 1234946..635144f 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8170,7 +8170,7 @@ Tcl_SetChannelOption( obj.length = strlen(newValue); obj.typePtr = NULL; - code = Tcl_GetWideIntFromObj(interp, &obj, &newBufferSize); + code = TclGetWideIntFromObj(interp, &obj, &newBufferSize); TclFreeInternalRep(&obj); if (code == TCL_ERROR) { diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index a664893..7a180e6 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -510,7 +510,7 @@ Tcl_SeekObjCmd( if (TclGetChannelFromObj(interp, objv[1], &chan, NULL, 0) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetWideIntFromObj(interp, objv[2], &offset) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[2], &offset) != TCL_OK) { return TCL_ERROR; } mode = SEEK_SET; @@ -1738,7 +1738,7 @@ Tcl_FcopyObjCmd( } switch (index) { case FcopySize: - if (Tcl_GetWideIntFromObj(interp, objv[i+1], &toRead) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[i+1], &toRead) != TCL_OK) { return TCL_ERROR; } if (toRead < 0) { @@ -1865,7 +1865,7 @@ ChanTruncateObjCmd( * User is supplying an explicit length. */ - if (Tcl_GetWideIntFromObj(interp, objv[2], &length) != TCL_OK) { + if (TclGetWideIntFromObj(interp, objv[2], &length) != TCL_OK) { return TCL_ERROR; } if (length < 0) { diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 93a8b5a..4a86c11 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -1617,7 +1617,7 @@ ReflectSeekWide( goto invalid; } - if (Tcl_GetWideIntFromObj(rcPtr->interp, resObj, &newLoc) != TCL_OK) { + if (TclGetWideIntFromObj(rcPtr->interp, resObj, &newLoc) != TCL_OK) { Tcl_SetChannelError(rcPtr->chan, MarshallError(rcPtr->interp)); goto invalid; } @@ -3212,7 +3212,7 @@ ForwardProc( Tcl_WideInt newLoc; - if (Tcl_GetWideIntFromObj(interp, resObj, &newLoc) == TCL_OK) { + if (TclGetWideIntFromObj(interp, resObj, &newLoc) == TCL_OK) { if (newLoc < 0) { ForwardSetStaticError(paramPtr, msg_seek_beforestart); paramPtr->seek.offset = -1; diff --git a/generic/tclInt.h b/generic/tclInt.h index 984b5c5..6dc35c3 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4061,36 +4061,6 @@ MODULE_SCOPE int TclCommandWordLimitError(Tcl_Interp *interp, Tcl_Size count); #define TCL_INDEX_START ((Tcl_Size)0) /* - *------------------------------------------------------------------------ - * - * TclGetSizeIntFromObj -- - * - * Extract a Tcl_Size from a Tcl_Obj - * - * Results: - * TCL_OK / TCL_ERROR - * - * Side effects: - * On success, the integer value is stored in *sizePtr. On error, - * an error message in interp it it is not NULL. - * - *------------------------------------------------------------------------ - */ -static inline int TclGetSizeIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr) { - if (sizeof(Tcl_Size) == sizeof(int)) { - return TclGetIntFromObj(interp, objPtr, (int *)sizePtr); - } else { - Tcl_WideInt wide; - if (TclGetWideIntFromObj(interp, objPtr, &wide) != TCL_OK) { - return TCL_ERROR; - } - *sizePtr = (Tcl_Size)wide; - return TCL_OK; - } -} - - -/* *---------------------------------------------------------------------- * * TclScaleTime -- diff --git a/generic/tclLink.c b/generic/tclLink.c index cb56bd6..05692db 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -511,7 +511,7 @@ GetWide( Tcl_Obj *objPtr, Tcl_WideInt *widePtr) { - if (Tcl_GetWideIntFromObj(NULL, objPtr, widePtr) != TCL_OK) { + if (TclGetWideIntFromObj(NULL, objPtr, widePtr) != TCL_OK) { int intValue; if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) { diff --git a/generic/tclObj.c b/generic/tclObj.c index aed24cd..b929592 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2592,7 +2592,7 @@ SetIntFromAny( Tcl_Obj *objPtr) /* Pointer to the object to convert */ { Tcl_WideInt w; - return Tcl_GetWideIntFromObj(interp, objPtr, &w); + return TclGetWideIntFromObj(interp, objPtr, &w); } /* @@ -3147,7 +3147,16 @@ Tcl_GetSizeIntFromObj( Tcl_Obj *objPtr, /* The object from which to get a int. */ Tcl_Size *sizePtr) /* Place to store resulting int. */ { - return TclGetSizeIntFromObj(interp, objPtr, sizePtr); + if (sizeof(Tcl_Size) == sizeof(int)) { + return TclGetIntFromObj(interp, objPtr, (int *)sizePtr); + } else { + Tcl_WideInt wide; + if (TclGetWideIntFromObj(interp, objPtr, &wide) != TCL_OK) { + return TCL_ERROR; + } + *sizePtr = (Tcl_Size)wide; + return TCL_OK; + } } /* diff --git a/generic/tclProc.c b/generic/tclProc.c index c789768..1633a09 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -784,7 +784,7 @@ TclObjGetFrame( if (objPtr == NULL) { /* Do nothing */ } else if (TCL_OK == Tcl_GetIntFromObj(NULL, objPtr, &level)) { - Tcl_GetWideIntFromObj(NULL, objPtr, &w); + TclGetWideIntFromObj(NULL, objPtr, &w); if (w < 0 || w > INT_MAX || curLevel > w + INT_MAX) { result = -1; } else { diff --git a/generic/tclScan.c b/generic/tclScan.c index 222b06d..3dcc9ea 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -942,7 +942,7 @@ Tcl_ScanObjCmd( break; } if (flags & SCAN_LONGER) { - if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) { + if (TclGetWideIntFromObj(NULL, objPtr, &wideValue) != TCL_OK) { if (TclGetString(objPtr)[0] == '-') { wideValue = WIDE_MIN; } else { diff --git a/generic/tclTimer.c b/generic/tclTimer.c index 528958c..c1d4d7d 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -817,7 +817,7 @@ Tcl_AfterObjCmd( * First lets see if the command was passed a number as the first argument. */ - if (Tcl_GetWideIntFromObj(NULL, objv[1], &ms) != TCL_OK) { + if (TclGetWideIntFromObj(NULL, objv[1], &ms) != TCL_OK) { if (Tcl_GetIndexFromObj(NULL, objv[1], afterSubCmds, "", 0, &index) != TCL_OK) { const char *arg = TclGetString(objv[1]); diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 739e506..8ec9303 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -518,7 +518,7 @@ GenerateHeader( if (GetValue(interp, dictObj, "time", &value) != TCL_OK) { goto error; - } else if (value != NULL && Tcl_GetWideIntFromObj(interp, value, + } else if (value != NULL && TclGetWideIntFromObj(interp, value, &wideValue) != TCL_OK) { goto error; } @@ -2146,7 +2146,7 @@ ZlibCmd( return TCL_ERROR; } if (objc > 3) { - if (Tcl_GetWideIntFromObj(interp, objv[3], + if (TclGetWideIntFromObj(interp, objv[3], &wideLen) != TCL_OK) { return TCL_ERROR; } @@ -2166,7 +2166,7 @@ ZlibCmd( return TCL_ERROR; } if (objc > 3) { - if (Tcl_GetWideIntFromObj(interp, objv[3], + if (TclGetWideIntFromObj(interp, objv[3], &wideLen) != TCL_OK) { return TCL_ERROR; } @@ -2198,7 +2198,7 @@ ZlibCmd( } switch (option) { case 0: - if (Tcl_GetWideIntFromObj(interp, objv[i+1], + if (TclGetWideIntFromObj(interp, objv[i+1], &wideLen) != TCL_OK) { return TCL_ERROR; } diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index ec936e0..48023b1 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -1510,7 +1510,7 @@ SetGroupAttribute( int result; const char *native; - if (Tcl_GetWideIntFromObj(NULL, attributePtr, &gid) != TCL_OK) { + if (TclGetWideIntFromObj(NULL, attributePtr, &gid) != TCL_OK) { Tcl_DString ds; struct group *groupPtr = NULL; const char *string; @@ -1581,7 +1581,7 @@ SetOwnerAttribute( int result; const char *native; - if (Tcl_GetWideIntFromObj(NULL, attributePtr, &uid) != TCL_OK) { + if (TclGetWideIntFromObj(NULL, attributePtr, &uid) != TCL_OK) { Tcl_DString ds; struct passwd *pwPtr = NULL; const char *string; @@ -1667,11 +1667,11 @@ SetPermissionsAttribute( TclNewLiteralStringObj(modeObj, "0o"); Tcl_AppendToObj(modeObj, modeStringPtr+scanned+1, TCL_INDEX_NONE); - result = Tcl_GetWideIntFromObj(NULL, modeObj, &mode); + result = TclGetWideIntFromObj(NULL, modeObj, &mode); Tcl_DecrRefCount(modeObj); } if (result == TCL_OK - || Tcl_GetWideIntFromObj(NULL, attributePtr, &mode) == TCL_OK) { + || TclGetWideIntFromObj(NULL, attributePtr, &mode) == TCL_OK) { newMode = (mode_t) (mode & 0x00007FFF); } else { Tcl_StatBuf buf; |