Tcl Source Code

Check-in [3dcb7571f5]
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: 3dcb7571f51656f735e311523d49d0f37c564e931c50407f42e3c7dbf074d5bb
User & Date: jan.nijtmans 2019-03-15 21:17:24
Context
2019-03-17
22:17
Merge 8.7 check-in: 5bfbe84775 user: jan.nijtmans tags: trunk
2019-03-15
21:17
Merge 8.7 check-in: 3dcb7571f5 user: jan.nijtmans tags: trunk
20:52
Eliminate usage of mp_isneg(), just check bignum->sign directly (as libtommath itself does) Make Tcl... check-in: 515a22d41d user: jan.nijtmans tags: core-8-branch
2019-03-14
20:03
merge-mark check-in: 80c345bf67 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to .travis.yml.

    77     77             sources:
    78     78               - ubuntu-toolchain-r-test
    79     79             packages:
    80     80               - g++-7
    81     81         env:
    82     82           - BUILD_DIR=unix
    83     83           - CFGOPT=CFLAGS=-DTCL_UTF_MAX=6
           84  +    - os: linux
           85  +      dist: xenial
           86  +      compiler: gcc-7
           87  +      addons:
           88  +        apt:
           89  +          sources:
           90  +            - ubuntu-toolchain-r-test
           91  +          packages:
           92  +            - g++-7
           93  +      env:
           94  +        - BUILD_DIR=unix
           95  +        - CFGOPT=CFLAGS=-DTCL_NO_DEPRECATED=1
    84     96       - os: osx
    85     97         osx_image: xcode8
    86     98         env:
    87     99           - BUILD_DIR=unix
    88    100       - os: osx
    89    101         osx_image: xcode8
    90    102         env:
................................................................................
   134    146               - gcc-mingw-w64
   135    147               - gcc-multilib
   136    148               - wine
   137    149         env:
   138    150           - BUILD_DIR=win
   139    151           - CFGOPT="--host=i686-w64-mingw32 CFLAGS=-DTCL_UTF_MAX=6"
   140    152           - NO_DIRECT_TEST=1
          153  +    - os: linux
          154  +      dist: xenial
          155  +      compiler: i686-w64-mingw32-gcc
          156  +      addons:
          157  +        apt:
          158  +          packages:
          159  +            - gcc-mingw-w64-base
          160  +            - binutils-mingw-w64-i686
          161  +            - gcc-mingw-w64-i686
          162  +            - gcc-mingw-w64
          163  +            - gcc-multilib
          164  +            - wine
          165  +      env:
          166  +        - BUILD_DIR=win
          167  +        - CFGOPT="--host=i686-w64-mingw32 CFLAGS=-DTCL_NO_DEPRECATED=1"
          168  +        - NO_DIRECT_TEST=1
   141    169   # Test with mingw-w64 (64 bit)
   142    170       - os: linux
   143    171         dist: xenial
   144    172         compiler: x86_64-w64-mingw32-gcc
   145    173         addons:
   146    174           apt:
   147    175             packages:
................................................................................
   165    193               - gcc-mingw-w64-x86-64
   166    194               - gcc-mingw-w64
   167    195               - wine
   168    196         env:
   169    197           - BUILD_DIR=win
   170    198           - CFGOPT="--host=x86_64-w64-mingw32 --enable-64bit CFLAGS=-DTCL_UTF_MAX=6"
   171    199           - NO_DIRECT_TEST=1
   172         -
          200  +    - os: linux
          201  +      dist: xenial
          202  +      compiler: x86_64-w64-mingw32-gcc
          203  +      addons:
          204  +        apt:
          205  +          packages:
          206  +            - gcc-mingw-w64-base
          207  +            - binutils-mingw-w64-x86-64
          208  +            - gcc-mingw-w64-x86-64
          209  +            - gcc-mingw-w64
          210  +            - wine
          211  +      env:
          212  +        - BUILD_DIR=win
          213  +        - CFGOPT="--host=x86_64-w64-mingw32 --enable-64bit CFLAGS=-DTCL_NO_DEPRECATED=1"
          214  +        - NO_DIRECT_TEST=1
   173    215   before_install:
   174    216     - export ERROR_ON_FAILURES=1
   175    217     - cd ${BUILD_DIR}
   176    218   install:
   177    219     - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT}
   178    220   script:
   179    221     - make
   180    222     # The styles=develop avoids some weird problems on OSX
   181    223     - test -n "$NO_DIRECT_TEST" || make test styles=develop

Changes to doc/timerate.n.

    52     52   .TP
    53     53   \fI-calibrate\fR
    54     54   .
    55     55   To measure very fast scripts as exact as posible the calibration process
    56     56   may be required.
    57     57   
    58     58   The \fI-calibrate\fR option is used to calibrate timerate, calculating the
    59         -estimated overhead of the given script as the default overhead for future 
    60         -invocations of the \fBtimerate\fR command. If the \fItime\fR parameter is not 
           59  +estimated overhead of the given script as the default overhead for future
           60  +invocations of the \fBtimerate\fR command. If the \fItime\fR parameter is not
    61     61   specified, the calibrate procedure runs for up to 10 seconds.
    62     62   .TP
    63     63   \fI-overhead double\fR
    64     64   .
    65     65   The \fI-overhead\fR parameter supplies an estimate (in microseconds) of the
    66     66   measurement overhead of each iteration of the tested script. This quantity
    67     67   will be subtracted from the measured time prior to reporting results.

Changes to generic/tclBasic.c.

  6825   6825   	    }
  6826   6826   	}
  6827   6827   	break;
  6828   6828       case TCL_NUMBER_BIG:
  6829   6829   	if (Tcl_GetBignumFromObj(interp, objv[1], &big) != TCL_OK) {
  6830   6830   	    return TCL_ERROR;
  6831   6831   	}
  6832         -	if (mp_isneg(&big)) {
         6832  +	if (big.sign != MP_ZPOS) {
  6833   6833   	    mp_clear(&big);
  6834   6834   	    goto negarg;
  6835   6835   	}
  6836   6836   	break;
  6837   6837       default:
  6838   6838   	if (TclGetWideIntFromObj(interp, objv[1], &w) != TCL_OK) {
  6839   6839   	    return TCL_ERROR;
................................................................................
  7054   7054       if (TclGetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
  7055   7055   	return TCL_ERROR;
  7056   7056       }
  7057   7057   
  7058   7058       if (type == TCL_NUMBER_INT) {
  7059   7059   	Tcl_WideInt l = *((const Tcl_WideInt *) ptr);
  7060   7060   
  7061         -	if (l > (Tcl_WideInt)0) {
         7061  +	if (l > 0) {
  7062   7062   	    goto unChanged;
  7063         -	} else if (l == (Tcl_WideInt)0) {
         7063  +	} else if (l == 0) {
  7064   7064   	    if (TclHasStringRep(objv[1])) {
  7065   7065   		size_t numBytes;
  7066   7066   		const char *bytes = TclGetStringFromObj(objv[1], &numBytes);
  7067   7067   
  7068   7068   		while (numBytes) {
  7069   7069   		    if (*bytes == '-') {
  7070   7070   			Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
................................................................................
  7099   7099   	    goto unChanged;
  7100   7100   	}
  7101   7101   	Tcl_SetObjResult(interp, Tcl_NewDoubleObj(-d));
  7102   7102   	return TCL_OK;
  7103   7103       }
  7104   7104   
  7105   7105       if (type == TCL_NUMBER_BIG) {
  7106         -	if (mp_isneg((const mp_int *) ptr)) {
         7106  +	if (((const mp_int *) ptr)->sign != MP_ZPOS) {
  7107   7107   	    Tcl_GetBignumFromObj(NULL, objv[1], &big);
  7108   7108   	tooLarge:
  7109   7109   	    mp_neg(&big, &big);
  7110   7110   	    Tcl_SetObjResult(interp, Tcl_NewBignumObj(&big));
  7111   7111   	} else {
  7112   7112   	unChanged:
  7113   7113   	    Tcl_SetObjResult(interp, objv[1]);

Changes to generic/tclExecute.c.

  7611   7611   		/*
  7612   7612   		 * Force Tcl's integer division rules.
  7613   7613   		 * TODO: examine for logic simplification
  7614   7614   		 */
  7615   7615   
  7616   7616   		if (((wQuotient < (Tcl_WideInt) 0)
  7617   7617   			|| ((wQuotient == (Tcl_WideInt) 0)
  7618         -			&& ((w1 < (Tcl_WideInt)0 && w2 > (Tcl_WideInt)0)
  7619         -			|| (w1 > (Tcl_WideInt)0 && w2 < (Tcl_WideInt)0))))
         7618  +			&& ((w1 < 0 && w2 > 0)
         7619  +			|| (w1 > 0 && w2 < 0))))
  7620   7620   			&& (wQuotient * w2 != w1)) {
  7621   7621   		    wQuotient -= (Tcl_WideInt) 1;
  7622   7622   		}
  7623   7623   		wRemainder = w1 - w2*wQuotient;
  7624   7624   		WIDE_RESULT(wRemainder);
  7625   7625   	    }
  7626   7626   
................................................................................
  7646   7646   	    return NULL;
  7647   7647   	}
  7648   7648   	Tcl_GetBignumFromObj(NULL, valuePtr, &big1);
  7649   7649   	Tcl_GetBignumFromObj(NULL, value2Ptr, &big2);
  7650   7650   	mp_init(&bigResult);
  7651   7651   	mp_init(&bigRemainder);
  7652   7652   	mp_div(&big1, &big2, &bigResult, &bigRemainder);
  7653         -	if (!mp_iszero(&bigRemainder) && (bigRemainder.sign != big2.sign)) {
         7653  +	if ((bigRemainder.used != 0) && (bigRemainder.sign != big2.sign)) {
  7654   7654   	    /*
  7655   7655   	     * Convert to Tcl's integer division rules.
  7656   7656   	     */
  7657   7657   
  7658   7658   	    mp_sub_d(&bigResult, 1, &bigResult);
  7659   7659   	    mp_add(&bigRemainder, &big2, &bigRemainder);
  7660   7660   	}
................................................................................
  7668   7668       case INST_RSHIFT: {
  7669   7669   	/*
  7670   7670   	 * Reject negative shift argument.
  7671   7671   	 */
  7672   7672   
  7673   7673   	switch (type2) {
  7674   7674   	case TCL_NUMBER_INT:
  7675         -	    invalid = (*((const Tcl_WideInt *)ptr2) < (Tcl_WideInt)0);
         7675  +	    invalid = (*((const Tcl_WideInt *)ptr2) < 0);
  7676   7676   	    break;
  7677   7677   	case TCL_NUMBER_BIG:
  7678   7678   	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
  7679         -	    invalid = mp_isneg(&big2);
         7679  +	    invalid = big2.sign != MP_ZPOS;
  7680   7680   	    mp_clear(&big2);
  7681   7681   	    break;
  7682   7682   	default:
  7683   7683   	    /* Unused, here to silence compiler warning */
  7684   7684   	    invalid = 0;
  7685   7685   	}
  7686   7686   	if (invalid) {
................................................................................
  7689   7689   	    return GENERAL_ARITHMETIC_ERROR;
  7690   7690   	}
  7691   7691   
  7692   7692   	/*
  7693   7693   	 * Zero shifted any number of bits is still zero.
  7694   7694   	 */
  7695   7695   
  7696         -	if ((type1==TCL_NUMBER_INT) && (*((const Tcl_WideInt *)ptr1) == (Tcl_WideInt)0)) {
         7696  +	if ((type1==TCL_NUMBER_INT) && (*((const Tcl_WideInt *)ptr1) == 0)) {
  7697   7697   	    return constants[0];
  7698   7698   	}
  7699   7699   
  7700   7700   	if (opcode == INST_LSHIFT) {
  7701   7701   	    /*
  7702   7702   	     * Large left shifts create integer overflow.
  7703   7703   	     *
................................................................................
  7747   7747   		 * not take us to the result of 0 or -1, but since we're using
  7748   7748   		 * mp_div_2d to do the work, and it takes only an int
  7749   7749   		 * argument, we draw the line there.
  7750   7750   		 */
  7751   7751   
  7752   7752   		switch (type1) {
  7753   7753   		case TCL_NUMBER_INT:
  7754         -		    zero = (*(const Tcl_WideInt *)ptr1 > (Tcl_WideInt)0);
         7754  +		    zero = (*(const Tcl_WideInt *)ptr1 > 0);
  7755   7755   		    break;
  7756   7756   		case TCL_NUMBER_BIG:
  7757   7757   		    Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
  7758         -		    zero = (!mp_isneg(&big1));
         7758  +		    zero = (big1.sign == MP_ZPOS);
  7759   7759   		    mp_clear(&big1);
  7760   7760   		    break;
  7761   7761   		default:
  7762   7762   		    /* Unused, here to silence compiler warning. */
  7763   7763   		    zero = 0;
  7764   7764   		}
  7765   7765   		if (zero) {
................................................................................
  7772   7772   	    /*
  7773   7773   	     * Handle shifts within the native wide range.
  7774   7774   	     */
  7775   7775   
  7776   7776   	    if (type1 == TCL_NUMBER_INT) {
  7777   7777   		w1 = *(const Tcl_WideInt *)ptr1;
  7778   7778   		if ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideInt)) {
  7779         -		    if (w1 >= (Tcl_WideInt)0) {
         7779  +		    if (w1 >= 0) {
  7780   7780   			return constants[0];
  7781   7781   		    }
  7782   7782   		    WIDE_RESULT(-1);
  7783   7783   		}
  7784   7784   		WIDE_RESULT(w1 >> shift);
  7785   7785   	    }
  7786   7786   	}
................................................................................
  7875   7875   		return NULL;
  7876   7876   	    }
  7877   7877   
  7878   7878   	    negativeExponent = (w2 < 0);
  7879   7879   	    oddExponent = (int) (w2 & (Tcl_WideInt)1);
  7880   7880   	} else {
  7881   7881   	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
  7882         -	    negativeExponent = mp_isneg(&big2);
         7882  +	    negativeExponent = big2.sign != MP_ZPOS;
  7883   7883   	    mp_mod_2d(&big2, 1, &big2);
  7884         -	    oddExponent = !mp_iszero(&big2);
         7884  +	    oddExponent = big2.used != 0;
  7885   7885   	    mp_clear(&big2);
  7886   7886   	}
  7887   7887   
  7888   7888   	if (type1 == TCL_NUMBER_INT) {
  7889   7889   	    w1 = *((const Tcl_WideInt *)ptr1);
  7890   7890   
  7891   7891   	    if (negativeExponent) {
................................................................................
  8194   8194   	case INST_SUB:
  8195   8195   	    mp_sub(&big1, &big2, &bigResult);
  8196   8196   	    break;
  8197   8197   	case INST_MULT:
  8198   8198   	    mp_mul(&big1, &big2, &bigResult);
  8199   8199   	    break;
  8200   8200   	case INST_DIV:
  8201         -	    if (mp_iszero(&big2)) {
         8201  +	    if (big2.used == 0) {
  8202   8202   		mp_clear(&big1);
  8203   8203   		mp_clear(&big2);
  8204   8204   		mp_clear(&bigResult);
  8205   8205   		return DIVIDED_BY_ZERO;
  8206   8206   	    }
  8207   8207   	    mp_init(&bigRemainder);
  8208   8208   	    mp_div(&big1, &big2, &bigResult, &bigRemainder);
  8209   8209   	    /* TODO: internals intrusion */
  8210         -	    if (!mp_iszero(&bigRemainder)
         8210  +	    if ((bigRemainder.used != 0)
  8211   8211   		    && (bigRemainder.sign != big2.sign)) {
  8212   8212   		/*
  8213   8213   		 * Convert to Tcl's integer division rules.
  8214   8214   		 */
  8215   8215   
  8216   8216   		mp_sub_d(&bigResult, 1, &bigResult);
  8217   8217   		mp_add(&bigRemainder, &big2, &bigRemainder);
................................................................................
  8350   8350   	    if (d2 > (double)WIDE_MAX) {
  8351   8351   		return MP_LT;
  8352   8352   	    }
  8353   8353   	    w2 = (Tcl_WideInt) d2;
  8354   8354   	    goto wideCompare;
  8355   8355   	case TCL_NUMBER_BIG:
  8356   8356   	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
  8357         -	    if (mp_isneg(&big2)) {
         8357  +	    if (big2.sign != MP_ZPOS) {
  8358   8358   		compare = MP_GT;
  8359   8359   	    } else {
  8360   8360   		compare = MP_LT;
  8361   8361   	    }
  8362   8362   	    mp_clear(&big2);
  8363   8363   	    return compare;
  8364   8364   	}
................................................................................
  8387   8387   	    goto wideCompare;
  8388   8388   	case TCL_NUMBER_BIG:
  8389   8389   	    if (TclIsInfinite(d1)) {
  8390   8390   		return (d1 > 0.0) ? MP_GT : MP_LT;
  8391   8391   	    }
  8392   8392   	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
  8393   8393   	    if ((d1 < (double)WIDE_MAX) && (d1 > (double)WIDE_MIN)) {
  8394         -		if (mp_isneg(&big2)) {
         8394  +		if (big2.sign != MP_ZPOS) {
  8395   8395   		    compare = MP_GT;
  8396   8396   		} else {
  8397   8397   		    compare = MP_LT;
  8398   8398   		}
  8399   8399   		mp_clear(&big2);
  8400   8400   		return compare;
  8401   8401   	    }

Changes to generic/tclInt.h.

  2985   2985   MODULE_SCOPE int	TclInfoGlobalsCmd(void *dummy, Tcl_Interp *interp,
  2986   2986   			    int objc, Tcl_Obj *const objv[]);
  2987   2987   MODULE_SCOPE int	TclInfoLocalsCmd(void *dummy, Tcl_Interp *interp,
  2988   2988   			    int objc, Tcl_Obj *const objv[]);
  2989   2989   MODULE_SCOPE int	TclInfoVarsCmd(void *dummy, Tcl_Interp *interp,
  2990   2990   			    int objc, Tcl_Obj *const objv[]);
  2991   2991   MODULE_SCOPE void	TclInitAlloc(void);
  2992         -MODULE_SCOPE void	TclInitBignumFromLong(mp_int *, long);
  2993   2992   MODULE_SCOPE void	TclInitBignumFromWideInt(mp_int *, Tcl_WideInt);
  2994   2993   MODULE_SCOPE void	TclInitBignumFromWideUInt(mp_int *, Tcl_WideUInt);
  2995   2994   MODULE_SCOPE void	TclInitDbCkalloc(void);
  2996   2995   MODULE_SCOPE void	TclInitDoubleConversion(void);
  2997   2996   MODULE_SCOPE void	TclInitEmbeddedConfigurationInformation(
  2998   2997   			    Tcl_Interp *interp);
  2999   2998   MODULE_SCOPE void	TclInitEncodingSubsystem(void);

Changes to generic/tclPipe.c.

   329    329   	 * Make sure we start at the beginning of the file.
   330    330   	 */
   331    331   
   332    332   	if (interp != NULL) {
   333    333   	    int count;
   334    334   	    Tcl_Obj *objPtr;
   335    335   
   336         -	    Tcl_Seek(errorChan, (Tcl_WideInt)0, SEEK_SET);
          336  +	    Tcl_Seek(errorChan, 0, SEEK_SET);
   337    337   	    objPtr = Tcl_NewObj();
   338    338   	    count = Tcl_ReadChars(errorChan, objPtr, -1, 0);
   339    339   	    if (count == -1) {
   340    340   		result = TCL_ERROR;
   341    341   		Tcl_DecrRefCount(objPtr);
   342    342   		Tcl_ResetResult(interp);
   343    343   		Tcl_SetObjResult(interp, Tcl_ObjPrintf(

Changes to generic/tclScan.c.

   939    939   		}
   940    940   	    } else if (flags & SCAN_BIG) {
   941    941   		if (flags & SCAN_UNSIGNED) {
   942    942   		    mp_int big;
   943    943   		    int code = Tcl_GetBignumFromObj(interp, objPtr, &big);
   944    944   
   945    945   		    if (code == TCL_OK) {
   946         -			if (mp_isneg(&big)) {
          946  +			if (big.sign != MP_ZPOS) {
   947    947   			    code = TCL_ERROR;
   948    948   			}
   949    949   			mp_clear(&big);
   950    950   		    }
   951    951   
   952    952   		    if (code == TCL_ERROR) {
   953    953   			if (objs != NULL) {

Changes to generic/tclStrToD.c.

   525    525       size_t acceptLen;		/* Number of characters following that
   526    526   				 * point. */
   527    527       int status = TCL_OK;	/* Status to return to caller. */
   528    528       char d = 0;			/* Last hexadecimal digit scanned; initialized
   529    529   				 * to avoid a compiler warning. */
   530    530       int shift = 0;		/* Amount to shift when accumulating binary */
   531    531   
   532         -#define ALL_BITS	(~(Tcl_WideUInt)0)
          532  +#define ALL_BITS	((Tcl_WideUInt)-1)
   533    533   #define MOST_BITS	(ALL_BITS >> 1)
   534    534   
   535    535       /*
   536    536        * Initialize bytes to start of the object's string rep if the caller
   537    537        * didn't pass anything else.
   538    538        */
   539    539   
................................................................................
   700    700   			 * too large shifts first.
   701    701   			 */
   702    702   
   703    703   			if ((octalSignificandWide != 0)
   704    704   				&& (((size_t)shift >=
   705    705   					CHAR_BIT*sizeof(Tcl_WideUInt))
   706    706   				|| (octalSignificandWide >
   707         -					(~(Tcl_WideUInt)0 >> shift)))) {
          707  +					((Tcl_WideUInt)-1 >> shift)))) {
   708    708   			    octalSignificandOverflow = 1;
   709    709   			    TclInitBignumFromWideUInt(&octalSignificandBig,
   710    710   				    octalSignificandWide);
   711    711   			}
   712    712   		    }
   713    713   		    if (!octalSignificandOverflow) {
   714    714   			octalSignificandWide =
................................................................................
   765    765   		     * Shifting by more bits than are in the value being
   766    766   		     * shifted is at least de facto nonportable. Check for too
   767    767   		     * large shifts first.
   768    768   		     */
   769    769   
   770    770   		    if (significandWide != 0 &&
   771    771   			    ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
   772         -			    significandWide > (~(Tcl_WideUInt)0 >> shift))) {
          772  +			    significandWide > ((Tcl_WideUInt)-1 >> shift))) {
   773    773   			significandOverflow = 1;
   774    774   			TclInitBignumFromWideUInt(&significandBig,
   775    775   				significandWide);
   776    776   		    }
   777    777   		}
   778    778   		if (!significandOverflow) {
   779    779   		    significandWide = (significandWide << shift) + d;
................................................................................
   806    806   		     * Shifting by more bits than are in the value being
   807    807   		     * shifted is at least de facto nonportable. Check for too
   808    808   		     * large shifts first.
   809    809   		     */
   810    810   
   811    811   		    if (significandWide != 0 &&
   812    812   			    ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) ||
   813         -			    significandWide > (~(Tcl_WideUInt)0 >> shift))) {
          813  +			    significandWide > ((Tcl_WideUInt)-1 >> shift))) {
   814    814   			significandOverflow = 1;
   815    815   			TclInitBignumFromWideUInt(&significandBig,
   816    816   				significandWide);
   817    817   		    }
   818    818   		}
   819    819   		if (!significandOverflow) {
   820    820   		    significandWide = (significandWide << shift) + 1;
................................................................................
  1384   1384   	    /*
  1385   1385   	     * There's no need to multiply if the multiplicand is zero.
  1386   1386   	     */
  1387   1387   
  1388   1388   	    *wideRepPtr = digit;
  1389   1389   	    return 0;
  1390   1390   	} else if (numZeros >= maxpow10_wide
  1391         -		|| w > ((~(Tcl_WideUInt)0)-digit)/pow10_wide[numZeros+1]) {
         1391  +		|| w > ((Tcl_WideUInt)-1-digit)/pow10_wide[numZeros+1]) {
  1392   1392   	    /*
  1393   1393   	     * Wide multiplication will overflow.  Expand the number to a
  1394   1394   	     * bignum and fall through into the bignum case.
  1395   1395   	     */
  1396   1396   
  1397   1397   	    TclInitBignumFromWideUInt(bignumRepPtr, w);
  1398   1398   	} else {
................................................................................
  4581   4581   TclCeil(
  4582   4582       const mp_int *a)			/* Integer to convert. */
  4583   4583   {
  4584   4584       double r = 0.0;
  4585   4585       mp_int b;
  4586   4586   
  4587   4587       mp_init(&b);
  4588         -    if (mp_isneg(a)) {
         4588  +    if (a->sign != MP_ZPOS) {
  4589   4589   	mp_neg(a, &b);
  4590   4590   	r = -TclFloor(&b);
  4591   4591       } else {
  4592   4592   	int bits = mp_count_bits(a);
  4593   4593   
  4594   4594   	if (bits > DBL_MAX_EXP*log2FLT_RADIX) {
  4595   4595   	    r = HUGE_VAL;
................................................................................
  4598   4598   
  4599   4599   	    if (shift > 0) {
  4600   4600   		mp_mul_2d(a, shift, &b);
  4601   4601   	    } else if (shift < 0) {
  4602   4602   		mp_int d;
  4603   4603   		mp_init(&d);
  4604   4604   		mp_div_2d(a, -shift, &b, &d);
  4605         -		exact = mp_iszero(&d);
         4605  +		exact = d.used == 0;
  4606   4606   		mp_clear(&d);
  4607   4607   	    } else {
  4608   4608   		mp_copy(a, &b);
  4609   4609   	    }
  4610   4610   	    if (!exact) {
  4611   4611   		mp_add_d(&b, 1, &b);
  4612   4612   	    }
................................................................................
  4638   4638   TclFloor(
  4639   4639       const mp_int *a)			/* Integer to convert. */
  4640   4640   {
  4641   4641       double r = 0.0;
  4642   4642       mp_int b;
  4643   4643   
  4644   4644       mp_init(&b);
  4645         -    if (mp_isneg(a)) {
         4645  +    if (a->sign != MP_ZPOS) {
  4646   4646   	mp_neg(a, &b);
  4647   4647   	r = -TclCeil(&b);
  4648   4648       } else {
  4649   4649   	int bits = mp_count_bits(a);
  4650   4650   
  4651   4651   	if (bits > DBL_MAX_EXP*log2FLT_RADIX) {
  4652   4652   	    r = DBL_MAX;

Changes to generic/tclTomMathInterface.c.

    85     85    */
    86     86   
    87     87   int
    88     88   TclBN_revision(void)
    89     89   {
    90     90       return TCLTOMMATH_REVISION;
    91     91   }
    92         -
    93         -/*
    94         - *----------------------------------------------------------------------
    95         - *
    96         - * TclInitBignumFromLong --
    97         - *
    98         - *	Allocate and initialize a 'bignum' from a native 'long'.
    99         - *
   100         - * Results:
   101         - *	None.
   102         - *
   103         - * Side effects:
   104         - *	The 'bignum' is constructed.
   105         - *
   106         - *----------------------------------------------------------------------
   107         - */
   108         -
   109         -void
   110         -TclInitBignumFromLong(
   111         -    mp_int *a,
   112         -    long v)
   113         -{
   114         -    if (mp_init_size(a, (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) {
   115         -	Tcl_Panic("initialization failure in TclInitBignumFromLong");
   116         -    }
   117         -    if (v < (long)0) {
   118         -	mp_set_long_long(a, (Tcl_WideUInt)(-(Tcl_WideInt)v));
   119         -	mp_neg(a, a);
   120         -    } else {
   121         -	mp_set_long_long(a, (Tcl_WideUInt)v);
   122         -    }
   123         -}
   124     92   
   125     93   /*
   126     94    *----------------------------------------------------------------------
   127     95    *
   128     96    * TclInitBignumFromWideInt --
   129     97    *
   130     98    *	Allocate and initialize a 'bignum' from a Tcl_WideInt

Changes to generic/tclUtil.c.

  3442   3442   	if (numType != TCL_NUMBER_BIG) {
  3443   3443   	    /* Must be a double -> not a valid index */
  3444   3444   	    goto parseError;
  3445   3445   	}
  3446   3446   
  3447   3447   	/* objPtr holds an integer outside the signed wide range */
  3448   3448   	/* Truncate to the signed wide range. */
  3449         -	*widePtr = mp_isneg((mp_int *)cd) ? WIDE_MIN : WIDE_MAX;
         3449  +	*widePtr = (((mp_int *)cd)->sign != MP_ZPOS) ? WIDE_MIN : WIDE_MAX;
  3450   3450       return TCL_OK;
  3451   3451       }
  3452   3452   
  3453   3453       /* objPtr does not hold a number, check the end+/- format... */
  3454   3454       if (GetEndOffsetFromObj(objPtr, endValue, widePtr) == TCL_OK) {
  3455   3455   	return TCL_OK;
  3456   3456       }
................................................................................
  3555   3555   
  3556   3556   		if (numType == TCL_NUMBER_INT) {
  3557   3557   		    /* sum holds an integer in the signed wide range */
  3558   3558   			*widePtr = *(Tcl_WideInt *)cd;
  3559   3559   		} else {
  3560   3560   		    /* sum holds an integer outside the signed wide range */
  3561   3561   		    /* Truncate to the signed wide range. */
  3562         -		    if (mp_isneg((mp_int *)cd)) {
         3562  +		    if (((mp_int *)cd)->sign != MP_ZPOS) {
  3563   3563   			*widePtr = WIDE_MIN;
  3564   3564   		    } else {
  3565   3565   			*widePtr = WIDE_MAX;
  3566   3566   		    }
  3567   3567   		}
  3568   3568   		Tcl_DecrRefCount(sum);
  3569   3569   	    }
................................................................................
  3708   3708   	    }
  3709   3709   
  3710   3710   	    /* Got an integer offset; pull it from where parser left it. */
  3711   3711   	    TclGetNumberFromObj(NULL, objPtr, &cd, &t);
  3712   3712   
  3713   3713   	    if (t == TCL_NUMBER_BIG) {
  3714   3714   		/* Truncate to the signed wide range. */
  3715         -		if (mp_isneg((mp_int *)cd)) {
         3715  +		if (((mp_int *)cd)->sign != MP_ZPOS) {
  3716   3716   		    offset = (bytes[3] == '-') ? WIDE_MAX : WIDE_MIN;
  3717   3717   		} else {
  3718   3718   		    offset = (bytes[3] == '-') ? WIDE_MIN : WIDE_MAX;
  3719   3719   		}
  3720   3720   	    } else {
  3721   3721   		/* assert (t == TCL_NUMBER_INT); */
  3722   3722   		offset = (*(Tcl_WideInt *)cd);