Tcl Source Code

Check-in [5a8767b61e]
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: 5a8767b61e40202e9274c81f401808e55955dc3e28bd9774b48f51c8ddccf1f6
User & Date: jan.nijtmans 2019-02-25 21:15:40
Context
2019-02-27
21:10
merge 8.7 check-in: ce752a257a user: jan.nijtmans tags: trunk
2019-02-26
20:18
Merge 8.7 Closed-Leaf check-in: 13cda7b91c user: jan.nijtmans tags: mistake
2019-02-25
21:15
Merge 8.7 check-in: 5a8767b61e user: jan.nijtmans tags: trunk
21:13
Merge 8.6 check-in: 64a59508ae user: jan.nijtmans tags: core-8-branch
2019-02-24
17:20
Merge 8.7 check-in: fb23ac1e71 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to .travis.yml.

     1      1   sudo: false
     2      2   language: c
     3      3   
     4      4   matrix:
     5      5     include:
     6      6       - os: linux
     7         -      dist: trusty
            7  +      dist: xenial
     8      8         compiler: clang
     9      9         env:
    10     10           - BUILD_DIR=unix
    11     11       - os: linux
    12         -      dist: trusty
           12  +      dist: xenial
    13     13         compiler: clang
    14     14         env:
    15     15           - CFGOPT=--disable-shared
    16     16           - BUILD_DIR=unix
    17     17       - os: linux
    18         -      dist: trusty
           18  +      dist: xenial
    19     19         compiler: gcc
    20     20         env:
    21     21           - BUILD_DIR=unix
    22     22       - os: linux
    23         -      dist: trusty
           23  +      dist: xenial
    24     24         compiler: gcc
    25     25         env:
    26     26           - CFGOPT=--disable-shared
    27     27           - BUILD_DIR=unix
    28     28       - os: linux
    29         -      dist: trusty
           29  +      dist: xenial
    30     30         compiler: gcc-4.9
    31     31         addons:
    32     32           apt:
    33     33             sources:
    34     34               - ubuntu-toolchain-r-test
    35     35             packages:
    36     36               - g++-4.9
    37     37         env:
    38     38           - BUILD_DIR=unix
    39     39       - os: linux
    40         -      dist: trusty
           40  +      dist: xenial
    41     41         compiler: gcc-5
    42     42         addons:
    43     43           apt:
    44     44             sources:
    45     45               - ubuntu-toolchain-r-test
    46     46             packages:
    47     47               - g++-5
    48     48         env:
    49     49           - BUILD_DIR=unix
    50     50       - os: linux
    51         -      dist: trusty
           51  +      dist: xenial
    52     52         compiler: gcc-6
    53     53         addons:
    54     54           apt:
    55     55             sources:
    56     56               - ubuntu-toolchain-r-test
    57     57             packages:
    58     58               - g++-6
    59     59         env:
    60     60           - BUILD_DIR=unix
    61     61       - os: linux
    62         -      dist: trusty
           62  +      dist: xenial
    63     63         compiler: gcc-7
    64     64         addons:
    65     65           apt:
    66     66             sources:
    67     67               - ubuntu-toolchain-r-test
    68     68             packages:
    69     69               - g++-7
................................................................................
    80     80           - NO_DIRECT_CONFIGURE=1
    81     81       - os: osx
    82     82         osx_image: xcode9
    83     83         env:
    84     84           - BUILD_DIR=macosx
    85     85           - NO_DIRECT_CONFIGURE=1
    86     86       - os: osx
    87         -      osx_image: xcode10
           87  +      osx_image: xcode10.2
    88     88         env:
    89     89           - BUILD_DIR=macosx
    90     90           - NO_DIRECT_CONFIGURE=1
    91     91   ### C builds not currently supported on Windows instances
    92     92   #    - os: windows
    93     93   #      env:
    94     94   #        - BUILD_DIR=win
    95     95   ### ... so proxy with a Mingw cross-compile
    96     96   # Test with mingw-w64 (32 bit)
    97     97       - os: linux
    98         -      dist: trusty
           98  +      dist: xenial
    99     99         compiler: i686-w64-mingw32-gcc
   100    100         addons:
   101    101           apt:
   102    102             packages:
   103    103               - gcc-mingw-w64-base
   104    104               - binutils-mingw-w64-i686
   105    105               - gcc-mingw-w64-i686
................................................................................
   108    108               - wine
   109    109         env:
   110    110           - BUILD_DIR=win
   111    111           - CFGOPT=--host=i686-w64-mingw32
   112    112           - NO_DIRECT_TEST=1
   113    113   # Test with mingw-w64 (64 bit)
   114    114       - os: linux
   115         -      dist: trusty
          115  +      dist: xenial
   116    116         compiler: x86_64-w64-mingw32-gcc
   117    117         addons:
   118    118           apt:
   119    119             packages:
   120    120               - gcc-mingw-w64-base
   121    121               - binutils-mingw-w64-x86-64
   122    122               - gcc-mingw-w64-x86-64

Changes to generic/tclBasic.c.

  7154   7154   
  7155   7155       if (objc != 2) {
  7156   7156   	MathFuncWrongNumArgs(interp, 2, objc, objv);
  7157   7157   	return TCL_ERROR;
  7158   7158       }
  7159   7159       if (Tcl_GetDoubleFromObj(interp, objv[1], &dResult) != TCL_OK) {
  7160   7160   #ifdef ACCEPT_NAN
  7161         -	if (objv[1]->typePtr == &tclDoubleType) {
         7161  +	if (TclHasIntRep(objv[1], &tclDoubleType)) {
  7162   7162   	    Tcl_SetObjResult(interp, objv[1]);
  7163   7163   	    return TCL_OK;
  7164   7164   	}
  7165   7165   #endif
  7166   7166   	return TCL_ERROR;
  7167   7167       }
  7168   7168       Tcl_SetObjResult(interp, Tcl_NewDoubleObj(dResult));

Changes to generic/tclBinary.c.

   287    287   #define SET_BYTEARRAY(irPtr, baPtr) \
   288    288   		(irPtr)->twoPtrValue.ptr1 = (baPtr)
   289    289   
   290    290   int
   291    291   TclIsPureByteArray(
   292    292       Tcl_Obj * objPtr)
   293    293   {
   294         -    return objPtr->typePtr == &properByteArrayType;
          294  +    return TclHasIntRep(objPtr, &properByteArrayType);
   295    295   }
   296    296   
   297    297   /*
   298    298    *----------------------------------------------------------------------
   299    299    *
   300    300    * Tcl_NewByteArrayObj --
   301    301    *
................................................................................
   550    550       int improper = 0;
   551    551       const char *src, *srcEnd;
   552    552       unsigned char *dst;
   553    553       Tcl_UniChar ch = 0;
   554    554       ByteArray *byteArrayPtr;
   555    555       Tcl_ObjIntRep ir;
   556    556   
   557         -    if (objPtr->typePtr == &properByteArrayType) {
          557  +    if (TclHasIntRep(objPtr, &properByteArrayType)) {
   558    558   	return TCL_OK;
   559    559       }
   560         -    if (objPtr->typePtr == &tclByteArrayType) {
          560  +    if (TclHasIntRep(objPtr, &tclByteArrayType)) {
   561    561   	return TCL_OK;
   562    562       }
   563    563   
   564    564       src = TclGetStringFromObj(objPtr, &length);
   565    565       srcEnd = src + length;
   566    566   
   567    567       byteArrayPtr = Tcl_Alloc(BYTEARRAY_SIZE(length));

Changes to generic/tclClock.c.

   448    448       }
   449    449   
   450    450       /*
   451    451        * fields.seconds could be an unsigned number that overflowed. Make sure
   452    452        * that it isn't.
   453    453        */
   454    454   
   455         -    if (objv[1]->typePtr == &tclBignumType) {
          455  +    if (TclHasIntRep(objv[1], &tclBignumType)) {
   456    456   	Tcl_SetObjResult(interp, literals[LIT_INTEGER_VALUE_TOO_LARGE]);
   457    457   	return TCL_ERROR;
   458    458       }
   459    459   
   460    460       /*
   461    461        * Convert UTC time to local.
   462    462        */

Changes to generic/tclCmdMZ.c.

  1640   1640   	}
  1641   1641   	break;
  1642   1642       }
  1643   1643       case STR_IS_DIGIT:
  1644   1644   	chcomp = Tcl_UniCharIsDigit;
  1645   1645   	break;
  1646   1646       case STR_IS_DOUBLE: {
  1647         -	if ((objPtr->typePtr == &tclDoubleType) ||
  1648         -		(objPtr->typePtr == &tclIntType) ||
  1649         -		(objPtr->typePtr == &tclBignumType)) {
         1647  +	if (TclHasIntRep(objPtr, &tclDoubleType) ||
         1648  +		TclHasIntRep(objPtr, &tclIntType) ||
         1649  +		TclHasIntRep(objPtr, &tclBignumType)) {
  1650   1650   	    break;
  1651   1651   	}
  1652   1652   	string1 = TclGetStringFromObj(objPtr, &length1);
  1653   1653   	if (length1 == 0) {
  1654   1654   	    if (strict) {
  1655   1655   		result = 0;
  1656   1656   	    }
................................................................................
  1671   1671   	break;
  1672   1672       }
  1673   1673       case STR_IS_GRAPH:
  1674   1674   	chcomp = Tcl_UniCharIsGraph;
  1675   1675   	break;
  1676   1676       case STR_IS_INT:
  1677   1677       case STR_IS_ENTIER:
  1678         -	if ((objPtr->typePtr == &tclIntType) ||
  1679         -		(objPtr->typePtr == &tclBignumType)) {
         1678  +	if (TclHasIntRep(objPtr, &tclIntType) ||
         1679  +		TclHasIntRep(objPtr, &tclBignumType)) {
  1680   1680   	    break;
  1681   1681   	}
  1682   1682   	string1 = TclGetStringFromObj(objPtr, &length1);
  1683   1683   	if (length1 == 0) {
  1684   1684   	    if (strict) {
  1685   1685   		result = 0;
  1686   1686   	    }
................................................................................
  1953   1953   
  1954   1954       /*
  1955   1955        * This test is tricky, but has to be that way or you get other strange
  1956   1956        * inconsistencies (see test string-10.20.1 for illustration why!)
  1957   1957        */
  1958   1958   
  1959   1959       if (!TclHasStringRep(objv[objc-2])
  1960         -	    && (objv[objc-2]->typePtr == &tclDictType)){
         1960  +	    && TclHasIntRep(objv[objc-2], &tclDictType)){
  1961   1961   	int i, done;
  1962   1962   	Tcl_DictSearch search;
  1963   1963   
  1964   1964   	/*
  1965   1965   	 * We know the type exactly, so all dict operations will succeed for
  1966   1966   	 * sure. This shortens this code quite a bit.
  1967   1967   	 */

Changes to generic/tclDictObj.c.

   609    609   
   610    610       /*
   611    611        * Since lists and dictionaries have very closely-related string
   612    612        * representations (i.e. the same parsing code) we can safely special-case
   613    613        * the conversion from lists to dictionaries.
   614    614        */
   615    615   
   616         -    if (objPtr->typePtr == &tclListType) {
          616  +    if (TclHasIntRep(objPtr, &tclListType)) {
   617    617   	int objc, i;
   618    618   	Tcl_Obj **objv;
   619    619   
   620    620   	/* Cannot fail, we already know the Tcl_ObjType is "list". */
   621    621   	TclListObjGetElements(NULL, objPtr, &objc, &objv);
   622    622   	if (objc & 1) {
   623    623   	    goto missingValue;

Changes to generic/tclDisassemble.c.

  1379   1379   	 */
  1380   1380   
  1381   1381   	if (objc != 3) {
  1382   1382   	    Tcl_WrongNumArgs(interp, 2, objv, "script");
  1383   1383   	    return TCL_ERROR;
  1384   1384   	}
  1385   1385   
  1386         -	if ((objv[2]->typePtr != &tclByteCodeType) && (TCL_OK
         1386  +	if (!TclHasIntRep(objv[2], &tclByteCodeType) && (TCL_OK
  1387   1387   		!= TclSetByteCodeFromAny(interp, objv[2], NULL, NULL))) {
  1388   1388   	    return TCL_ERROR;
  1389   1389   	}
  1390   1390   	codeObjPtr = objv[2];
  1391   1391   	break;
  1392   1392   
  1393   1393       case DISAS_CLASS_CONSTRUCTOR:
................................................................................
  1430   1430   	    return TCL_ERROR;
  1431   1431   	}
  1432   1432   
  1433   1433   	/*
  1434   1434   	 * Compile if necessary.
  1435   1435   	 */
  1436   1436   
  1437         -	if (procPtr->bodyPtr->typePtr != &tclByteCodeType) {
         1437  +	if (!TclHasIntRep(procPtr->bodyPtr, &tclByteCodeType)) {
  1438   1438   	    Command cmd;
  1439   1439   
  1440   1440   	    /*
  1441   1441   	     * Yes, this is ugly, but we need to pass the namespace in to the
  1442   1442   	     * compiler in two places.
  1443   1443   	     */
  1444   1444   
................................................................................
  1495   1495   	    return TCL_ERROR;
  1496   1496   	}
  1497   1497   
  1498   1498   	/*
  1499   1499   	 * Compile if necessary.
  1500   1500   	 */
  1501   1501   
  1502         -	if (procPtr->bodyPtr->typePtr != &tclByteCodeType) {
         1502  +	if (!TclHasIntRep(procPtr->bodyPtr, &tclByteCodeType)) {
  1503   1503   	    Command cmd;
  1504   1504   
  1505   1505   	    /*
  1506   1506   	     * Yes, this is ugly, but we need to pass the namespace in to the
  1507   1507   	     * compiler in two places.
  1508   1508   	     */
  1509   1509   
................................................................................
  1580   1580   	if (procPtr == NULL) {
  1581   1581   	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
  1582   1582   		    "body not available for this kind of method", -1));
  1583   1583   	    Tcl_SetErrorCode(interp, "TCL", "OPERATION", "DISASSEMBLE",
  1584   1584   		    "METHODTYPE", NULL);
  1585   1585   	    return TCL_ERROR;
  1586   1586   	}
  1587         -	if (procPtr->bodyPtr->typePtr != &tclByteCodeType) {
         1587  +	if (!TclHasIntRep(procPtr->bodyPtr, &tclByteCodeType)) {
  1588   1588   	    Command cmd;
  1589   1589   
  1590   1590   	    /*
  1591   1591   	     * Yes, this is ugly, but we need to pass the namespace in to the
  1592   1592   	     * compiler in two places.
  1593   1593   	     */
  1594   1594   

Changes to generic/tclExecute.c.

  4555   4555   	TRACE(("\"%.30s\" \"%.30s\" => ", O2S(valuePtr), O2S(value2Ptr)));
  4556   4556   
  4557   4557   	/*
  4558   4558   	 * Extract the desired list element.
  4559   4559   	 */
  4560   4560   
  4561   4561   	if ((TclListObjGetElements(interp, valuePtr, &objc, &objv) == TCL_OK)
  4562         -		&& (value2Ptr->typePtr != &tclListType)
         4562  +		&& !TclHasIntRep(value2Ptr, &tclListType)
  4563   4563   		&& (TclGetIntForIndexM(NULL, value2Ptr, objc-1,
  4564   4564   			&index) == TCL_OK)) {
  4565   4565   	    TclDecrRefCount(value2Ptr);
  4566   4566   	    tosPtr--;
  4567   4567   	    pcAdjustment = 1;
  4568   4568   	    goto lindexFastPath;
  4569   4569   	}
................................................................................
  6732   6732   	    TclNewObj(statePtr);
  6733   6733   	    ir.twoPtrValue.ptr1 = searchPtr;
  6734   6734   	    ir.twoPtrValue.ptr2 = dictPtr;
  6735   6735   	    Tcl_StoreIntRep(statePtr, &dictIteratorType, &ir);
  6736   6736   	}
  6737   6737   	varPtr = LOCAL(opnd);
  6738   6738   	if (varPtr->value.objPtr) {
  6739         -	    if (varPtr->value.objPtr->typePtr == &dictIteratorType) {
         6739  +	    if (TclHasIntRep(varPtr->value.objPtr, &dictIteratorType)) {
  6740   6740   		Tcl_Panic("mis-issued dictFirst!");
  6741   6741   	    }
  6742   6742   	    TclDecrRefCount(varPtr->value.objPtr);
  6743   6743   	}
  6744   6744   	varPtr->value.objPtr = statePtr;
  6745   6745   	Tcl_IncrRefCount(statePtr);
  6746   6746   	goto pushDictIteratorResult;
................................................................................
  9240   9240       objBytesIfUnshared = 0.0;
  9241   9241       strBytesIfUnshared = 0.0;
  9242   9242       strBytesSharedMultX = 0.0;
  9243   9243       strBytesSharedOnce = 0.0;
  9244   9244       for (i = 0;  i < globalTablePtr->numBuckets;  i++) {
  9245   9245   	for (entryPtr = globalTablePtr->buckets[i];  entryPtr != NULL;
  9246   9246   		entryPtr = entryPtr->nextPtr) {
  9247         -	    if (entryPtr->objPtr->typePtr == &tclByteCodeType) {
         9247  +	    if (TclHasIntRep(entryPtr->objPtr, &tclByteCodeType)) {
  9248   9248   		numByteCodeLits++;
  9249   9249   	    }
  9250   9250   	    (void) TclGetStringFromObj(entryPtr->objPtr, &length);
  9251   9251   	    refCountSum += entryPtr->refCount;
  9252   9252   	    objBytesIfUnshared += (entryPtr->refCount * sizeof(Tcl_Obj));
  9253   9253   	    strBytesIfUnshared += (entryPtr->refCount * (length+1));
  9254   9254   	    if (entryPtr->refCount > 1) {

Changes to generic/tclInt.h.

  4571   4571    * MODULE_SCOPE int	TclIsPureByteArray(Tcl_Obj *objPtr);
  4572   4572    *----------------------------------------------------------------
  4573   4573    */
  4574   4574   
  4575   4575   MODULE_SCOPE int	TclIsPureByteArray(Tcl_Obj *objPtr);
  4576   4576   #define TclIsPureDict(objPtr) \
  4577   4577   	(((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclDictType))
         4578  +#define TclHasIntRep(objPtr, type) \
         4579  +	((objPtr)->typePtr == (type)) 
  4578   4580   #define TclFetchIntRep(objPtr, type) \
  4579         -	(((objPtr)->typePtr == type) ? &((objPtr)->internalRep) : NULL)
         4581  +	(TclHasIntRep((objPtr), (type)) ? &((objPtr)->internalRep) : NULL)
  4580   4582   
  4581   4583   
  4582   4584   /*
  4583   4585    *----------------------------------------------------------------
  4584   4586    * Macro used by the Tcl core to compare Unicode strings. On big-endian
  4585   4587    * systems we can use the more efficient memcmp, but this would not be
  4586   4588    * lexically correct on little-endian systems. The ANSI C "prototype" for

Changes to generic/tclListObj.c.

  1979   1979        * Dictionaries are a special case; they have a string representation such
  1980   1980        * that *all* valid dictionaries are valid lists. Hence we can convert
  1981   1981        * more directly. Only do this when there's no existing string rep; if
  1982   1982        * there is, it is the string rep that's authoritative (because it could
  1983   1983        * describe duplicate keys).
  1984   1984        */
  1985   1985   
  1986         -    if (!TclHasStringRep(objPtr) && (objPtr->typePtr == &tclDictType)) {
         1986  +    if (!TclHasStringRep(objPtr) && TclHasIntRep(objPtr, &tclDictType)) {
  1987   1987   	Tcl_Obj *keyPtr, *valuePtr;
  1988   1988   	Tcl_DictSearch search;
  1989   1989   	int done, size;
  1990   1990   
  1991   1991   	/*
  1992   1992   	 * Create the new list representation. Note that we do not need to do
  1993   1993   	 * anything with the string representation as the transformation (and