Tcl Source Code

Check-in [ce752a257a]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge 8.7
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ce752a257a3f3b3f88cd5539afef4f14a77d0e0d03777974c5c52cffc8018da4
User & Date: jan.nijtmans 2019-02-27 21:10:53
Context
2019-02-27
21:58
Merge 8.7 check-in: 727e74f081 user: jan.nijtmans tags: trunk
21:10
merge 8.7 check-in: ce752a257a user: jan.nijtmans tags: trunk
08:34
More use of (efficient) TclHasIntRep() macro. Also eliminate many (size_t) and (unsigned) type-casts... check-in: 51c585131e user: jan.nijtmans tags: core-8-branch
2019-02-25
21:15
Merge 8.7 check-in: 5a8767b61e user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tclBinary.c.

   639    639   
   640    640       srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &tclByteArrayType));
   641    641       length = srcArrayPtr->used;
   642    642   
   643    643       copyArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
   644    644       copyArrayPtr->used = length;
   645    645       copyArrayPtr->allocated = length;
   646         -    memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, (size_t) length);
          646  +    memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
   647    647   
   648    648       SET_BYTEARRAY(&ir, copyArrayPtr);
   649    649       Tcl_StoreIntRep(copyPtr, &tclByteArrayType, &ir);
   650    650   }
   651    651   
   652    652   static void
   653    653   DupProperByteArrayInternalRep(
................................................................................
   660    660   
   661    661       srcArrayPtr = GET_BYTEARRAY(TclFetchIntRep(srcPtr, &properByteArrayType));
   662    662       length = srcArrayPtr->used;
   663    663   
   664    664       copyArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));
   665    665       copyArrayPtr->used = length;
   666    666       copyArrayPtr->allocated = length;
   667         -    memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, (size_t) length);
          667  +    memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
   668    668   
   669    669       SET_BYTEARRAY(&ir, copyArrayPtr);
   670    670       Tcl_StoreIntRep(copyPtr, &properByteArrayType, &ir);
   671    671   }
   672    672   
   673    673   /*
   674    674    *----------------------------------------------------------------------

Changes to generic/tclFileName.c.

  2547   2547    *---------------------------------------------------------------------------
  2548   2548    */
  2549   2549   
  2550   2550   unsigned
  2551   2551   Tcl_GetFSDeviceFromStat(
  2552   2552       const Tcl_StatBuf *statPtr)
  2553   2553   {
  2554         -    return (unsigned) statPtr->st_dev;
         2554  +    return statPtr->st_dev;
  2555   2555   }
  2556   2556   
  2557   2557   unsigned
  2558   2558   Tcl_GetFSInodeFromStat(
  2559   2559       const Tcl_StatBuf *statPtr)
  2560   2560   {
  2561         -    return (unsigned) statPtr->st_ino;
         2561  +    return statPtr->st_ino;
  2562   2562   }
  2563   2563   
  2564   2564   unsigned
  2565   2565   Tcl_GetModeFromStat(
  2566   2566       const Tcl_StatBuf *statPtr)
  2567   2567   {
  2568         -    return (unsigned) statPtr->st_mode;
         2568  +    return statPtr->st_mode;
  2569   2569   }
  2570   2570   
  2571   2571   int
  2572   2572   Tcl_GetLinkCountFromStat(
  2573   2573       const Tcl_StatBuf *statPtr)
  2574   2574   {
  2575   2575       return (int)statPtr->st_nlink;
................................................................................
  2638   2638   }
  2639   2639   
  2640   2640   unsigned
  2641   2641   Tcl_GetBlockSizeFromStat(
  2642   2642       const Tcl_StatBuf *statPtr)
  2643   2643   {
  2644   2644   #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
  2645         -    return (unsigned) statPtr->st_blksize;
         2645  +    return statPtr->st_blksize;
  2646   2646   #else
  2647   2647       /*
  2648   2648        * Not a great guess, but will do...
  2649   2649        */
  2650   2650   
  2651   2651       return GUESSED_BLOCK_SIZE;
  2652   2652   #endif

Changes to generic/tclPathObj.c.

   556    556   
   557    557   Tcl_Obj *
   558    558   TclPathPart(
   559    559       Tcl_Interp *interp,		/* Used for error reporting */
   560    560       Tcl_Obj *pathPtr,		/* Path to take dirname of */
   561    561       Tcl_PathPart portion)	/* Requested portion of name */
   562    562   {
   563         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
   564         -
   565         -    if (irPtr) {
          563  +    if (TclHasIntRep(pathPtr, &fsPathType)) {
   566    564   	FsPath *fsPathPtr = PATHOBJ(pathPtr);
   567    565   
   568    566   	if (PATHFLAGS(pathPtr) != 0) {
   569    567   	    switch (portion) {
   570    568   	    case TCL_PATH_DIRNAME: {
   571    569   		/*
   572    570   		 * Check if the joined-on bit has any directory delimiters in
................................................................................
  1153   1151   int
  1154   1152   Tcl_FSConvertToPathType(
  1155   1153       Tcl_Interp *interp,		/* Interpreter in which to store error message
  1156   1154   				 * (if necessary). */
  1157   1155       Tcl_Obj *pathPtr)		/* Object to convert to a valid, current path
  1158   1156   				 * type. */
  1159   1157   {
  1160         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
  1161         -
  1162   1158       /*
  1163   1159        * While it is bad practice to examine an object's type directly, this is
  1164   1160        * actually the best thing to do here. The reason is that if we are
  1165   1161        * converting this object to FsPath type for the first time, we don't need
  1166   1162        * to worry whether the 'cwd' has changed. On the other hand, if this
  1167   1163        * object is already of FsPath type, and is a relative path, we do have to
  1168   1164        * worry about the cwd. If the cwd has changed, we must recompute the
  1169   1165        * path.
  1170   1166        */
  1171   1167   
  1172         -    if (irPtr) {
         1168  +    if (TclHasIntRep(pathPtr, &fsPathType)) {
  1173   1169   	if (TclFSEpochOk(PATHOBJ(pathPtr)->filesystemEpoch)) {
  1174   1170   	    return TCL_OK;
  1175   1171   	}
  1176   1172   
  1177   1173   	TclGetString(pathPtr);
  1178   1174   	Tcl_StoreIntRep(pathPtr, &fsPathType, NULL);
  1179   1175       }
................................................................................
  1476   1472   
  1477   1473   static int
  1478   1474   MakePathFromNormalized(
  1479   1475       Tcl_Interp *interp,		/* Used for error reporting if not NULL. */
  1480   1476       Tcl_Obj *pathPtr)		/* The object to convert. */
  1481   1477   {
  1482   1478       FsPath *fsPathPtr;
  1483         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
  1484   1479   
  1485         -    if (irPtr) {
         1480  +    if (TclHasIntRep(pathPtr, &fsPathType)) {
  1486   1481   	return TCL_OK;
  1487   1482       }
  1488   1483   
  1489   1484       fsPathPtr = Tcl_Alloc(sizeof(FsPath));
  1490   1485   
  1491   1486       /*
  1492   1487        * It's a pure normalized absolute path.
................................................................................
  2083   2078   
  2084   2079   int
  2085   2080   TclFSEnsureEpochOk(
  2086   2081       Tcl_Obj *pathPtr,
  2087   2082       const Tcl_Filesystem **fsPtrPtr)
  2088   2083   {
  2089   2084       FsPath *srcFsPathPtr;
  2090         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
  2091   2085   
  2092         -    if (irPtr == NULL) {
         2086  +    if (!TclHasIntRep(pathPtr, &fsPathType)) {
  2093   2087   	return TCL_OK;
  2094   2088       }
  2095   2089   
  2096   2090       srcFsPathPtr = PATHOBJ(pathPtr);
  2097   2091   
  2098   2092       /*
  2099   2093        * Check if the filesystem has changed in some way since this object's
................................................................................
  2142   2136   void
  2143   2137   TclFSSetPathDetails(
  2144   2138       Tcl_Obj *pathPtr,
  2145   2139       const Tcl_Filesystem *fsPtr,
  2146   2140       ClientData clientData)
  2147   2141   {
  2148   2142       FsPath *srcFsPathPtr;
  2149         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);;
  2150   2143   
  2151   2144       /*
  2152   2145        * Make sure pathPtr is of the correct type.
  2153   2146        */
  2154   2147   
  2155         -    if (irPtr == NULL) {
         2148  +    if (!TclHasIntRep(pathPtr, &fsPathType)) {
  2156   2149   	if (SetFsPathFromAny(NULL, pathPtr) != TCL_OK) {
  2157   2150   	    return;
  2158   2151   	}
  2159   2152       }
  2160   2153   
  2161   2154       srcFsPathPtr = PATHOBJ(pathPtr);
  2162   2155       srcFsPathPtr->fsPtr = fsPtr;
................................................................................
  2247   2240       Tcl_Interp *interp,		/* Used for error reporting if not NULL. */
  2248   2241       Tcl_Obj *pathPtr)		/* The object to convert. */
  2249   2242   {
  2250   2243       size_t len;
  2251   2244       FsPath *fsPathPtr;
  2252   2245       Tcl_Obj *transPtr;
  2253   2246       char *name;
  2254         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
  2255   2247   
  2256         -    if (irPtr) {
         2248  +    if (TclHasIntRep(pathPtr, &fsPathType)) {
  2257   2249   	return TCL_OK;
  2258   2250       }
  2259   2251   
  2260   2252       /*
  2261   2253        * First step is to translate the filename. This is similar to
  2262   2254        * Tcl_TranslateFilename, but shouldn't convert everything to windows
  2263   2255        * backslashes on that platform. The current implementation of this piece
................................................................................
  2556   2548    */
  2557   2549   
  2558   2550   int
  2559   2551   TclNativePathInFilesystem(
  2560   2552       Tcl_Obj *pathPtr,
  2561   2553       ClientData *clientDataPtr)
  2562   2554   {
  2563         -    Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
  2564         -
  2565   2555       /*
  2566   2556        * A special case is required to handle the empty path "". This is a valid
  2567   2557        * path (i.e. the user should be able to do 'file exists ""' without
  2568   2558        * throwing an error), but equally the path doesn't exist. Those are the
  2569   2559        * semantics of Tcl (at present anyway), so we have to abide by them here.
  2570   2560        */
  2571   2561   
  2572         -    if (irPtr) {
         2562  +    if (TclHasIntRep(pathPtr, &fsPathType)) {
  2573   2563   	if (pathPtr->bytes != NULL && pathPtr->bytes[0] == '\0') {
  2574   2564   	    /*
  2575   2565   	     * We reject the empty path "".
  2576   2566   	     */
  2577   2567   
  2578   2568   	    return -1;
  2579   2569   	}