diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-04-10 14:47:21 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-04-10 14:47:21 (GMT) |
commit | 2ffd22efd1279d41b6a871510d564e8a5151a948 (patch) | |
tree | ece226b385bf0b07f5910bee412698ac534b425e | |
parent | dfe9963d735b0e1754db2e270b91e3c45ece3636 (diff) | |
parent | fdc1bcf721aa672b0170af25adfe16a7650aab44 (diff) | |
download | tcl-2ffd22efd1279d41b6a871510d564e8a5151a948.zip tcl-2ffd22efd1279d41b6a871510d564e8a5151a948.tar.gz tcl-2ffd22efd1279d41b6a871510d564e8a5151a948.tar.bz2 |
Merge 8.6 Use TclHasInternalRep() macro in more places.
-rwxr-xr-x | generic/tclArithSeries.c | 6 | ||||
-rw-r--r-- | generic/tclClock.c | 6 | ||||
-rw-r--r-- | generic/tclDictObj.c | 2 | ||||
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclIOCmd.c | 2 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 13 | ||||
-rw-r--r-- | generic/tclListObj.c | 2 | ||||
-rw-r--r-- | generic/tclMain.c | 2 | ||||
-rw-r--r-- | generic/tclObj.c | 66 | ||||
-rw-r--r-- | generic/tclStringObj.c | 6 | ||||
-rw-r--r-- | generic/tclTest.c | 4 | ||||
-rw-r--r-- | unix/tclUnixChan.c | 2 | ||||
-rw-r--r-- | win/tclWinChan.c | 2 | ||||
-rw-r--r-- | win/tclWinPipe.c | 2 |
14 files changed, 57 insertions, 60 deletions
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index 48e9f80..7a41518 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -591,7 +591,7 @@ TclArithSeriesObjIndex( { ArithSeries *arithSeriesRepPtr; - if (arithSeriesObj->typePtr != &tclArithSeriesType) { + if (!TclHasInternalRep(arithSeriesObj, &tclArithSeriesType)) { Tcl_Panic("TclArithSeriesObjIndex called with a not ArithSeries Obj."); } arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj); @@ -658,7 +658,7 @@ ArithSeriesObjStep( ArithSeries *arithSeriesRepPtr; Tcl_Obj *stepObj; - if (arithSeriesObj->typePtr != &tclArithSeriesType) { + if (!TclHasInternalRep(arithSeriesObj, &tclArithSeriesType)) { Tcl_Panic("ArithSeriesObjStep called with a not ArithSeries Obj."); } arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj); @@ -865,7 +865,7 @@ TclArithSeriesGetElements( Tcl_Obj ***objvPtr) /* Where to store the pointer to an array of * pointers to the list's objects. */ { - if (TclHasInternalRep(objPtr,&tclArithSeriesType)) { + if (TclHasInternalRep(objPtr, &tclArithSeriesType)) { ArithSeries *arithSeriesRepPtr; Tcl_Obj **objv; int i, objc; diff --git a/generic/tclClock.c b/generic/tclClock.c index f79a5b4..100cfd6 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -3456,7 +3456,7 @@ ClockParseFmtScnArgs( goto baseNow; } - if (baseObj->typePtr == &tclBignumType) { + if (TclHasInternalRep(baseObj, &tclBignumType)) { goto baseOverflow; } @@ -3472,7 +3472,7 @@ ClockParseFmtScnArgs( * Note the year is currently an integer, thus avoid to overflow it also. */ - if ( baseObj->typePtr == &tclBignumType + if (TclHasInternalRep(baseObj, &tclBignumType) || baseVal < TCL_MIN_SECONDS || baseVal > TCL_MAX_SECONDS ) { baseOverflow: @@ -4463,7 +4463,7 @@ ClockAddObjCmd( &unitIndex) != TCL_OK) { goto done; } - if (objv[i]->typePtr == &tclBignumType + if (TclHasInternalRep(objv[i], &tclBignumType) || offs > (unitIndex < CLC_ADD_HOURS ? 0x7fffffff : TCL_MAX_SECONDS) || offs < (unitIndex < CLC_ADD_HOURS ? -0x7fffffff : TCL_MIN_SECONDS) ) { diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 4ab78fd..8f8755c 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -2085,7 +2085,7 @@ TclDictObjSmartRef( Tcl_Obj *result; Dict *dict; - if (dictPtr->typePtr != &tclDictType + if (!TclHasInternalRep(dictPtr, &tclDictType) && SetDictFromAny(interp, dictPtr) != TCL_OK) { return NULL; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 91caca1..380a0a3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8764,7 +8764,7 @@ ExecuteExtendedBinaryMathOp( overflowExpon: if ((TclGetWideIntFromObj(NULL, value2Ptr, &w2) != TCL_OK) - || (value2Ptr->typePtr != &tclIntType) + || !TclHasInternalRep(value2Ptr, &tclIntType) || (Tcl_WideUInt)w2 >= (1<<28)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "exponent too large", -1)); diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 808ce97..3a9fb89 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -1168,7 +1168,7 @@ Tcl_OpenObjCmd( } else { int flags = TCL_STDERR | TCL_ENFORCE_MODE; - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { + switch (mode & O_ACCMODE) { case O_RDONLY: flags |= TCL_STDOUT; break; diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 4f6a008..aa675f5 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -1480,7 +1480,6 @@ TclGetOpenModeEx( int mode, c, gotRW; Tcl_Size modeArgc, i; const char **modeArgv, *flag; -#define RW_MODES (O_RDONLY|O_WRONLY|O_RDWR) /* * Check for the simpler fopen-like access modes like "r" which are @@ -1490,7 +1489,7 @@ TclGetOpenModeEx( *seekFlagPtr = 0; *binaryPtr = 0; - mode = 0; + mode = O_RDONLY; /* * Guard against wide characters before using byte-oriented routines. @@ -1500,7 +1499,6 @@ TclGetOpenModeEx( && islower(UCHAR(modeString[0]))) { /* INTL: ISO only. */ switch (modeString[0]) { case 'r': - mode = O_RDONLY; break; case 'w': mode = O_WRONLY|O_CREAT|O_TRUNC; @@ -1529,8 +1527,7 @@ TclGetOpenModeEx( * 1773127] */ - mode &= ~(O_RDONLY|O_WRONLY|O_APPEND); - mode |= O_RDWR; + mode = (mode & ~(O_ACCMODE|O_APPEND)) | O_RDWR; break; case 'b': *binaryPtr = 1; @@ -1575,13 +1572,13 @@ TclGetOpenModeEx( flag = modeArgv[i]; c = flag[0]; if ((c == 'R') && (strcmp(flag, "RDONLY") == 0)) { - mode = (mode & ~RW_MODES) | O_RDONLY; + mode = (mode & ~O_ACCMODE) | O_RDONLY; gotRW = 1; } else if ((c == 'W') && (strcmp(flag, "WRONLY") == 0)) { - mode = (mode & ~RW_MODES) | O_WRONLY; + mode = (mode & ~O_ACCMODE) | O_WRONLY; gotRW = 1; } else if ((c == 'R') && (strcmp(flag, "RDWR") == 0)) { - mode = (mode & ~RW_MODES) | O_RDWR; + mode = (mode & ~O_ACCMODE) | O_RDWR; gotRW = 1; } else if ((c == 'A') && (strcmp(flag, "APPEND") == 0)) { mode |= O_APPEND; diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 181ae6b..1060333 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -68,7 +68,7 @@ /* Checks for when caller should have already converted to internal list type */ #define LIST_ASSERT_TYPE(listObj_) \ - LIST_ASSERT((listObj_)->typePtr == &tclListType); + LIST_ASSERT(TclHasInternalRep(listObj_, &tclListType)); /* diff --git a/generic/tclMain.c b/generic/tclMain.c index d23cd7b..3ee3fbc 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -360,7 +360,7 @@ Tcl_MainEx( is.tty = isatty(0); Tcl_SetVar2Ex(interp, "tcl_interactive", NULL, - Tcl_NewWideIntObj(!path && is.tty), TCL_GLOBAL_ONLY); + Tcl_NewBooleanObj(!path && is.tty), TCL_GLOBAL_ONLY); /* * Invoke application-specific initialization. diff --git a/generic/tclObj.c b/generic/tclObj.c index f3e1f7f..2ddabfb 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2140,15 +2140,15 @@ Tcl_GetBoolFromObj( return TCL_ERROR; } do { - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { result = (objPtr->internalRep.wideValue != 0); goto boolEnd; } - if (objPtr->typePtr == &tclBooleanType) { + if (TclHasInternalRep(objPtr, &tclBooleanType)) { result = objPtr->internalRep.longValue != 0; goto boolEnd; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { /* * Caution: Don't be tempted to check directly for the "double" * Tcl_ObjType and then compare the internalrep to 0.0. This isn't @@ -2165,7 +2165,7 @@ Tcl_GetBoolFromObj( result = (d != 0.0); goto boolEnd; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { result = 1; boolEnd: if (charPtr != NULL) { @@ -2238,18 +2238,18 @@ TclSetBooleanFromAny( */ if (objPtr->bytes == NULL) { - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { if ((Tcl_WideUInt)objPtr->internalRep.wideValue < 2) { return TCL_OK; } goto badBoolean; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { goto badBoolean; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { goto badBoolean; } } @@ -2551,7 +2551,7 @@ Tcl_GetDoubleFromObj( double *dblPtr) /* Place to store resulting double. */ { do { - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (isnan(objPtr->internalRep.doubleValue)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -2564,11 +2564,11 @@ Tcl_GetDoubleFromObj( *dblPtr = (double) objPtr->internalRep.doubleValue; return TCL_OK; } - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { *dblPtr = (double) objPtr->internalRep.wideValue; return TCL_OK; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { mp_int big; TclUnpackBignum(objPtr, big); @@ -3041,12 +3041,12 @@ Tcl_GetLongFromObj( { do { #ifdef TCL_WIDE_INT_IS_LONG - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { *longPtr = objPtr->internalRep.wideValue; return TCL_OK; } #else - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { /* * We return any integer in the range LONG_MIN to ULONG_MAX * converted to a long, ignoring overflow. The rule preserves @@ -3065,7 +3065,7 @@ Tcl_GetLongFromObj( goto tooLarge; } #endif - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer but got \"%s\"", @@ -3074,7 +3074,7 @@ Tcl_GetLongFromObj( } return TCL_ERROR; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { /* * Must check for those bignum values that can fit in a long, even * when auto-narrowing is enabled. Only those values in the signed @@ -3302,11 +3302,11 @@ Tcl_GetWideIntFromObj( /* Place to store resulting long. */ { do { - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { *wideIntPtr = objPtr->internalRep.wideValue; return TCL_OK; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer but got \"%s\"", @@ -3315,7 +3315,7 @@ Tcl_GetWideIntFromObj( } return TCL_ERROR; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { /* * Must check for those bignum values that can fit in a * Tcl_WideInt, even when auto-narrowing is enabled. @@ -3387,7 +3387,7 @@ Tcl_GetWideUIntFromObj( /* Place to store resulting long. */ { do { - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { if (objPtr->internalRep.wideValue < 0) { wideUIntOutOfRange: if (interp != NULL) { @@ -3401,10 +3401,10 @@ Tcl_GetWideUIntFromObj( *wideUIntPtr = (Tcl_WideUInt)objPtr->internalRep.wideValue; return TCL_OK; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { goto wideUIntOutOfRange; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { /* * Must check for those bignum values that can fit in a * Tcl_WideUInt, even when auto-narrowing is enabled. @@ -3471,11 +3471,11 @@ TclGetWideBitsFromObj( Tcl_WideInt *wideIntPtr) /* Place to store resulting wide integer. */ { do { - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { *wideIntPtr = objPtr->internalRep.wideValue; return TCL_OK; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer but got \"%s\"", @@ -3484,7 +3484,7 @@ TclGetWideBitsFromObj( } return TCL_ERROR; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { mp_int big; mp_err err; @@ -3733,7 +3733,7 @@ GetBignumFromObj( mp_int *bignumValue) /* Returned bignum value. */ { do { - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { if (copy || Tcl_IsShared(objPtr)) { mp_int temp; @@ -3758,14 +3758,14 @@ GetBignumFromObj( } return TCL_OK; } - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { if (mp_init_i64(bignumValue, objPtr->internalRep.wideValue) != MP_OKAY) { return TCL_ERROR; } return TCL_OK; } - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer but got \"%s\"", @@ -3968,7 +3968,7 @@ Tcl_GetNumberFromObj( int *typePtr) { do { - if (objPtr->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objPtr, &tclDoubleType)) { if (isnan(objPtr->internalRep.doubleValue)) { *typePtr = TCL_NUMBER_NAN; } else { @@ -3977,12 +3977,12 @@ Tcl_GetNumberFromObj( *clientDataPtr = &objPtr->internalRep.doubleValue; return TCL_OK; } - if (objPtr->typePtr == &tclIntType) { + if (TclHasInternalRep(objPtr, &tclIntType)) { *typePtr = TCL_NUMBER_INT; *clientDataPtr = &objPtr->internalRep.wideValue; return TCL_OK; } - if (objPtr->typePtr == &tclBignumType) { + if (TclHasInternalRep(objPtr, &tclBignumType)) { static Tcl_ThreadDataKey bignumKey; mp_int *bigPtr = (mp_int *)Tcl_GetThreadData(&bignumKey, sizeof(mp_int)); @@ -4590,7 +4590,7 @@ Tcl_GetCommandFromObj( */ resPtr = (ResolvedCmdName *)objPtr->internalRep.twoPtrValue.ptr1; - if (objPtr->typePtr == &tclCmdNameType) { + if (TclHasInternalRep(objPtr, &tclCmdNameType)) { Command *cmdPtr = resPtr->cmdPtr; if ((cmdPtr->cmdEpoch == resPtr->cmdEpoch) @@ -4705,7 +4705,7 @@ TclSetCmdNameObj( { ResolvedCmdName *resPtr; - if (objPtr->typePtr == &tclCmdNameType) { + if (TclHasInternalRep(objPtr, &tclCmdNameType)) { resPtr = (ResolvedCmdName *)objPtr->internalRep.twoPtrValue.ptr1; if (resPtr != NULL && resPtr->cmdPtr == cmdPtr) { return; @@ -4852,7 +4852,7 @@ SetCmdNameFromAny( } resPtr = (ResolvedCmdName *)objPtr->internalRep.twoPtrValue.ptr1; - if ((objPtr->typePtr == &tclCmdNameType) && (resPtr->refCount == 1)) { + if (TclHasInternalRep(objPtr, &tclCmdNameType) && (resPtr->refCount == 1)) { /* * Re-use existing ResolvedCmdName struct when possible. * Cleanup the old fields that need it. @@ -4913,7 +4913,7 @@ Tcl_RepresentationCmd( objv[1]->refCount, objv[1]); if (objv[1]->typePtr) { - if (objv[1]->typePtr == &tclDoubleType) { + if (TclHasInternalRep(objv[1], &tclDoubleType)) { Tcl_AppendPrintfToObj(descObj, ", internal representation %g", objv[1]->internalRep.doubleValue); } else { diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 41b2428..967fdd0 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -272,7 +272,7 @@ GrowStringBuffer( { /* * Preconditions: - * objPtr->typePtr == &tclStringType + * TclHasInternalRep(objPtr, &tclStringType) * needed > stringPtr->allocated * flag || objPtr->bytes != NULL */ @@ -323,7 +323,7 @@ GrowUnicodeBuffer( { /* * Preconditions: - * objPtr->typePtr == &tclStringType + * TclHasInternalRep(objPtr, &tclStringType) * needed > stringPtr->maxChars * needed < UNICHAR_STRING_MAXCHARS */ @@ -3528,7 +3528,7 @@ TclStringCat( binary = 0; if (ov > objv+1 && ISCONTINUATION(TclGetString(objPtr))) { forceUniChar = 1; - } else if ((objPtr->typePtr) && (objPtr->typePtr != &tclUniCharStringType)) { + } else if ((objPtr->typePtr) && !TclHasInternalRep(objPtr, &tclUniCharStringType)) { /* Prevent shimmer of non-string types. */ allowUniChar = 0; } diff --git a/generic/tclTest.c b/generic/tclTest.c index f85858f..7360c94 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -7566,7 +7566,7 @@ SimpleOpenFileChannel( Tcl_Obj *tempPtr; Tcl_Channel chan; - if ((mode != 0) && !(mode & O_RDONLY)) { + if ((mode & O_ACCMODE) != O_RDONLY) { Tcl_AppendResult(interp, "read-only", (char *)NULL); return NULL; } @@ -8453,7 +8453,7 @@ TestparseargsCmd( const Tcl_ArgvInfo argTable[] = { {TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL}, {TCL_ARGV_STRING, "-colormode" , NULL, &color, "color mode", NULL}, - {TCL_ARGV_GENFUNC, "-media", ParseMedia, &media, "media page size", NULL}, + {TCL_ARGV_GENFUNC, "-media", (void *)ParseMedia, &media, "media page size", NULL}, TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END }; diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 806d6fb..238c3d5 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -1837,7 +1837,7 @@ TclpOpenFileChannel( char channelName[16 + TCL_INTEGER_SPACE]; const Tcl_ChannelType *channelTypePtr; - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { + switch (mode & O_ACCMODE) { case O_RDONLY: channelPermissions = TCL_READABLE; break; diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 9b018e4..6ce0735 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -1106,7 +1106,7 @@ TclpOpenFileChannel( return NULL; } - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { + switch (mode & O_ACCMODE) { case O_RDONLY: accessMode = GENERIC_READ; channelPermissions = TCL_READABLE; diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index bb4983e..0d5e86e 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -538,7 +538,7 @@ TclpOpenFile( * Map the access bits to the NT access mode. */ - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { + switch (mode & O_ACCMODE) { case O_RDONLY: accessMode = GENERIC_READ; break; |