diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-16 21:10:20 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-16 21:10:20 (GMT) |
commit | bc2c8431fc3b9961eabac2d1d2dd19f4325ce0a9 (patch) | |
tree | fadd915985c2810d77c7d8558fe2d51260975db9 /generic | |
parent | 842878d2d0eee1bafcd57bc809ddac15b27c0510 (diff) | |
parent | 2ff70c01f60ef1dbb586489d97b1f36368ad6741 (diff) | |
download | tcl-bc2c8431fc3b9961eabac2d1d2dd19f4325ce0a9.zip tcl-bc2c8431fc3b9961eabac2d1d2dd19f4325ce0a9.tar.gz tcl-bc2c8431fc3b9961eabac2d1d2dd19f4325ce0a9.tar.bz2 |
Merge 8.7
Move up some stub entries related to Tcl_UniChar
Use TCL_UTF_MAX=4 for full Unicode in stead of TCL_UTF_MAX=6 (TCL_UTF_MAX: 3 is default)
Diffstat (limited to 'generic')
-rw-r--r-- | generic/regcustom.h | 2 | ||||
-rw-r--r-- | generic/tcl.decls | 56 | ||||
-rw-r--r-- | generic/tcl.h | 8 | ||||
-rw-r--r-- | generic/tclBasic.c | 8 | ||||
-rw-r--r-- | generic/tclBinary.c | 4 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 6 | ||||
-rw-r--r-- | generic/tclCompCmdsSZ.c | 2 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 2 | ||||
-rw-r--r-- | generic/tclCompile.c | 4 | ||||
-rw-r--r-- | generic/tclDecls.h | 75 | ||||
-rw-r--r-- | generic/tclDisassemble.c | 2 | ||||
-rw-r--r-- | generic/tclEncoding.c | 18 | ||||
-rw-r--r-- | generic/tclExecute.c | 32 | ||||
-rw-r--r-- | generic/tclIO.c | 8 | ||||
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclMain.c | 6 | ||||
-rw-r--r-- | generic/tclParse.c | 6 | ||||
-rw-r--r-- | generic/tclPipe.c | 2 | ||||
-rw-r--r-- | generic/tclScan.c | 6 | ||||
-rw-r--r-- | generic/tclStrToD.c | 16 | ||||
-rw-r--r-- | generic/tclStringObj.c | 8 | ||||
-rw-r--r-- | generic/tclStubInit.c | 31 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 19 | ||||
-rw-r--r-- | generic/tclTomMathInterface.c | 38 | ||||
-rw-r--r-- | generic/tclUniData.c | 8 | ||||
-rw-r--r-- | generic/tclUtf.c | 42 | ||||
-rw-r--r-- | generic/tclUtil.c | 8 |
27 files changed, 212 insertions, 208 deletions
diff --git a/generic/regcustom.h b/generic/regcustom.h index 095385d..e4db7cb 100644 --- a/generic/regcustom.h +++ b/generic/regcustom.h @@ -88,7 +88,7 @@ typedef int celt; /* Type to hold chr, or NOCELT */ #define NOCELT (-1) /* Celt value which is not valid chr */ #define CHR(c) (UCHAR(c)) /* Turn char literal into chr literal */ #define DIGITVAL(c) ((c)-'0') /* Turn chr digit into its value */ -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 #define CHRBITS 32 /* Bits in a chr; must not use sizeof */ #define CHR_MIN 0x00000000 /* Smallest and largest chr; the value */ #define CHR_MAX 0x10ffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ diff --git a/generic/tcl.decls b/generic/tcl.decls index 7ceb8c0..6187cfc 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1197,9 +1197,9 @@ declare 334 { declare 335 { int Tcl_UtfToTitle(char *src) } -declare 336 { - int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr) -} +#declare 336 { +# int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr) +#} declare 337 { int Tcl_UtfToUpper(char *src) } @@ -1245,21 +1245,21 @@ declare 350 { declare 351 { int Tcl_UniCharIsWordChar(int ch) } -declare 352 { - int Tcl_UniCharLen(const Tcl_UniChar *uniStr) -} -declare 353 { - int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, - unsigned long numChars) -} -declare 354 { - char *Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr, - int uniLength, Tcl_DString *dsPtr) -} -declare 355 { - Tcl_UniChar *Tcl_UtfToUniCharDString(const char *src, - int length, Tcl_DString *dsPtr) -} +#declare 352 { +# int Tcl_UniCharLen(const Tcl_UniChar *uniStr) +#} +#declare 353 { +# int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, +# unsigned long numChars) +#} +#declare 354 { +# char *Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr, +# int uniLength, Tcl_DString *dsPtr) +#} +#declare 355 { +# Tcl_UniChar *Tcl_UtfToUniCharDString(const char *src, +# int length, Tcl_DString *dsPtr) +#} declare 356 { Tcl_RegExp Tcl_GetRegExpFromObj(Tcl_Interp *interp, Tcl_Obj *patObj, int flags) @@ -2379,12 +2379,32 @@ declare 643 { int Tcl_IsShared(Tcl_Obj *objPtr) } +# TIP #??? declare 644 { int *Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr) } declare 645 { Tcl_Obj *Tcl_NewUnicodeObj(const int *unicode, int numChars) } +declare 646 { + int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr) +} +declare 647 { + int Tcl_UniCharLen(const Tcl_UniChar *uniStr) +} +declare 648 { + int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, + unsigned long numChars) +} +declare 649 { + char *Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr, + int uniLength, Tcl_DString *dsPtr) +} +declare 650 { + Tcl_UniChar *Tcl_UtfToUniCharDString(const char *src, + int length, Tcl_DString *dsPtr) +} + # ----- BASELINE -- FOR -- 8.7.0 ----- # diff --git a/generic/tcl.h b/generic/tcl.h index 27cf7c3..63d845d 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2142,7 +2142,7 @@ typedef struct Tcl_EncodingType { */ #ifndef TCL_UTF_MAX -#define TCL_UTF_MAX 4 +#define TCL_UTF_MAX 3 #endif /* @@ -2150,7 +2150,7 @@ typedef struct Tcl_EncodingType { * reflected in regcustom.h. */ -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 /* * unsigned int isn't 100% accurate as it should be a strict 4-byte value * (perhaps wchar_t). 64-bit systems may have troubles. The size of this @@ -2339,10 +2339,10 @@ typedef int (Tcl_NRPostProc) (ClientData data[], Tcl_Interp *interp, /* *---------------------------------------------------------------------------- * The following constant is used to test for older versions of Tcl in the - * stubs tables. If TCL_UTF_MAX>4 use a different value. + * stubs tables. */ -#define TCL_STUB_MAGIC ((int) 0xFCA3BACF + (TCL_UTF_MAX>4)) +#define TCL_STUB_MAGIC ((int) 0xFCA3BACF) /* * The following function is required to be defined in all stubs aware diff --git a/generic/tclBasic.c b/generic/tclBasic.c index d914690..1806557 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7560,7 +7560,7 @@ ExprIsqrtFunc( if (Tcl_GetBignumFromObj(interp, objv[1], &big) != TCL_OK) { return TCL_ERROR; } - if (mp_isneg(&big)) { + if (big.sign != MP_ZPOS) { mp_clear(&big); goto negarg; } @@ -7789,9 +7789,9 @@ ExprAbsFunc( if (type == TCL_NUMBER_INT) { Tcl_WideInt l = *((const Tcl_WideInt *) ptr); - if (l > (Tcl_WideInt)0) { + if (l > 0) { goto unChanged; - } else if (l == (Tcl_WideInt)0) { + } else if (l == 0) { if (TclHasStringRep(objv[1])) { int numBytes; const char *bytes = TclGetStringFromObj(objv[1], &numBytes); @@ -7834,7 +7834,7 @@ ExprAbsFunc( } if (type == TCL_NUMBER_BIG) { - if (mp_isneg((const mp_int *) ptr)) { + if (((const mp_int *) ptr)->sign != MP_ZPOS) { Tcl_GetBignumFromObj(NULL, objv[1], &big); tooLarge: mp_neg(&big, &big); diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 1f78d18..8600b3f 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -1354,7 +1354,7 @@ BinaryFormatCmd( badField: { Tcl_UniChar ch = 0; - char buf[TCL_UTF_MAX + 1] = ""; + char buf[5] = ""; TclUtfToUniChar(errorString, &ch); buf[Tcl_UniCharToUtf(ch, buf)] = '\0'; @@ -1724,7 +1724,7 @@ BinaryScanCmd( badField: { Tcl_UniChar ch = 0; - char buf[TCL_UTF_MAX + 1] = ""; + char buf[5] = ""; TclUtfToUniChar(errorString, &ch); buf[Tcl_UniCharToUtf(ch, buf)] = '\0'; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 01d9c27..2f01ad6 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1221,7 +1221,7 @@ Tcl_SplitObjCmd( len = TclUtfToUniChar(stringPtr, &ch); fullchar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(stringPtr + len, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; @@ -1445,7 +1445,7 @@ StringIndexCmd( Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(&uch, 1)); } else { - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; length = Tcl_UniCharToUtf(ch, buf); if ((ch >= 0xD800) && (length < 3)) { @@ -1854,7 +1854,7 @@ StringIsCmd( int fullchar; length2 = TclUtfToUniChar(string1, &ch); fullchar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (length2 < 3)) { length2 += TclUtfToUniChar(string1 + length2, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index b97121e..07e7bcc 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -1502,7 +1502,7 @@ TclSubstCompile( for (endTokenPtr = tokenPtr + parse.numTokens; tokenPtr < endTokenPtr; tokenPtr = TokenAfter(tokenPtr)) { int length, literal, catchRange, breakJump; - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; JumpFixup startFixup, okFixup, returnFixup, breakFixup; JumpFixup continueFixup, otherFixup, endFixup; diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index f88b2d6..56c8931 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2066,7 +2066,7 @@ ParseLexeme( if (Tcl_UtfCharComplete(start, numBytes)) { scanned = TclUtfToUniChar(start, &ch); } else { - char utfBytes[TCL_UTF_MAX]; + char utfBytes[4]; memcpy(utfBytes, start, numBytes); utfBytes[numBytes] = '\0'; diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 3621cc2..c0e8c62 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1744,7 +1744,7 @@ TclWordKnownAtCompileTime( case TCL_TOKEN_BS: if (tempPtr != NULL) { - char utfBuf[TCL_UTF_MAX] = ""; + char utfBuf[4] = ""; int length = TclParseBackslash(tokenPtr->start, tokenPtr->size, NULL, utfBuf); @@ -2358,7 +2358,7 @@ TclCompileTokens( { Tcl_DString textBuffer; /* Holds concatenated chars from adjacent * TCL_TOKEN_TEXT, TCL_TOKEN_BS tokens. */ - char buffer[TCL_UTF_MAX] = ""; + char buffer[4] = ""; int i, numObjsToConcat, length, adjust; unsigned char *entryCodeNext = envPtr->codeNext; #define NUM_STATIC_POS 20 diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 6f1a956..b9f710f 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1025,8 +1025,7 @@ EXTERN char * Tcl_UtfToExternalDString(Tcl_Encoding encoding, EXTERN int Tcl_UtfToLower(char *src); /* 335 */ EXTERN int Tcl_UtfToTitle(char *src); -/* 336 */ -EXTERN int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr); +/* Slot 336 is reserved */ /* 337 */ EXTERN int Tcl_UtfToUpper(char *src); /* 338 */ @@ -1060,18 +1059,10 @@ EXTERN int Tcl_UniCharIsSpace(int ch); EXTERN int Tcl_UniCharIsUpper(int ch); /* 351 */ EXTERN int Tcl_UniCharIsWordChar(int ch); -/* 352 */ -EXTERN int Tcl_UniCharLen(const Tcl_UniChar *uniStr); -/* 353 */ -EXTERN int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, - const Tcl_UniChar *uct, - unsigned long numChars); -/* 354 */ -EXTERN char * Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr, - int uniLength, Tcl_DString *dsPtr); -/* 355 */ -EXTERN Tcl_UniChar * Tcl_UtfToUniCharDString(const char *src, int length, - Tcl_DString *dsPtr); +/* Slot 352 is reserved */ +/* Slot 353 is reserved */ +/* Slot 354 is reserved */ +/* Slot 355 is reserved */ /* 356 */ EXTERN Tcl_RegExp Tcl_GetRegExpFromObj(Tcl_Interp *interp, Tcl_Obj *patObj, int flags); @@ -1900,6 +1891,20 @@ EXTERN int * Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr); /* 645 */ EXTERN Tcl_Obj * Tcl_NewUnicodeObj(const int *unicode, int numChars); +/* 646 */ +EXTERN int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr); +/* 647 */ +EXTERN int Tcl_UniCharLen(const Tcl_UniChar *uniStr); +/* 648 */ +EXTERN int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, + const Tcl_UniChar *uct, + unsigned long numChars); +/* 649 */ +EXTERN char * Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr, + int uniLength, Tcl_DString *dsPtr); +/* 650 */ +EXTERN Tcl_UniChar * Tcl_UtfToUniCharDString(const char *src, int length, + Tcl_DString *dsPtr); typedef struct { const struct TclPlatStubs *tclPlatStubs; @@ -2271,7 +2276,7 @@ typedef struct TclStubs { char * (*tcl_UtfToExternalDString) (Tcl_Encoding encoding, const char *src, int srcLen, Tcl_DString *dsPtr); /* 333 */ int (*tcl_UtfToLower) (char *src); /* 334 */ int (*tcl_UtfToTitle) (char *src); /* 335 */ - int (*tcl_UtfToUniChar) (const char *src, Tcl_UniChar *chPtr); /* 336 */ + void (*reserved336)(void); int (*tcl_UtfToUpper) (char *src); /* 337 */ int (*tcl_WriteChars) (Tcl_Channel chan, const char *src, int srcLen); /* 338 */ int (*tcl_WriteObj) (Tcl_Channel chan, Tcl_Obj *objPtr); /* 339 */ @@ -2287,10 +2292,10 @@ typedef struct TclStubs { int (*tcl_UniCharIsSpace) (int ch); /* 349 */ int (*tcl_UniCharIsUpper) (int ch); /* 350 */ int (*tcl_UniCharIsWordChar) (int ch); /* 351 */ - int (*tcl_UniCharLen) (const Tcl_UniChar *uniStr); /* 352 */ - int (*tcl_UniCharNcmp) (const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars); /* 353 */ - char * (*tcl_UniCharToUtfDString) (const Tcl_UniChar *uniStr, int uniLength, Tcl_DString *dsPtr); /* 354 */ - Tcl_UniChar * (*tcl_UtfToUniCharDString) (const char *src, int length, Tcl_DString *dsPtr); /* 355 */ + void (*reserved352)(void); + void (*reserved353)(void); + void (*reserved354)(void); + void (*reserved355)(void); Tcl_RegExp (*tcl_GetRegExpFromObj) (Tcl_Interp *interp, Tcl_Obj *patObj, int flags); /* 356 */ TCL_DEPRECATED_API("Use Tcl_EvalTokensStandard") Tcl_Obj * (*tcl_EvalTokens) (Tcl_Interp *interp, Tcl_Token *tokenPtr, int count); /* 357 */ void (*tcl_FreeParse) (Tcl_Parse *parsePtr); /* 358 */ @@ -2581,6 +2586,11 @@ typedef struct TclStubs { int (*tcl_IsShared) (Tcl_Obj *objPtr); /* 643 */ int * (*tcl_GetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 644 */ Tcl_Obj * (*tcl_NewUnicodeObj) (const int *unicode, int numChars); /* 645 */ + int (*tcl_UtfToUniChar) (const char *src, Tcl_UniChar *chPtr); /* 646 */ + int (*tcl_UniCharLen) (const Tcl_UniChar *uniStr); /* 647 */ + int (*tcl_UniCharNcmp) (const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars); /* 648 */ + char * (*tcl_UniCharToUtfDString) (const Tcl_UniChar *uniStr, int uniLength, Tcl_DString *dsPtr); /* 649 */ + Tcl_UniChar * (*tcl_UtfToUniCharDString) (const char *src, int length, Tcl_DString *dsPtr); /* 650 */ } TclStubs; extern const TclStubs *tclStubsPtr; @@ -3283,8 +3293,7 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UtfToLower) /* 334 */ #define Tcl_UtfToTitle \ (tclStubsPtr->tcl_UtfToTitle) /* 335 */ -#define Tcl_UtfToUniChar \ - (tclStubsPtr->tcl_UtfToUniChar) /* 336 */ +/* Slot 336 is reserved */ #define Tcl_UtfToUpper \ (tclStubsPtr->tcl_UtfToUpper) /* 337 */ #define Tcl_WriteChars \ @@ -3315,14 +3324,10 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UniCharIsUpper) /* 350 */ #define Tcl_UniCharIsWordChar \ (tclStubsPtr->tcl_UniCharIsWordChar) /* 351 */ -#define Tcl_UniCharLen \ - (tclStubsPtr->tcl_UniCharLen) /* 352 */ -#define Tcl_UniCharNcmp \ - (tclStubsPtr->tcl_UniCharNcmp) /* 353 */ -#define Tcl_UniCharToUtfDString \ - (tclStubsPtr->tcl_UniCharToUtfDString) /* 354 */ -#define Tcl_UtfToUniCharDString \ - (tclStubsPtr->tcl_UtfToUniCharDString) /* 355 */ +/* Slot 352 is reserved */ +/* Slot 353 is reserved */ +/* Slot 354 is reserved */ +/* Slot 355 is reserved */ #define Tcl_GetRegExpFromObj \ (tclStubsPtr->tcl_GetRegExpFromObj) /* 356 */ #define Tcl_EvalTokens \ @@ -3903,6 +3908,16 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_GetUnicodeFromObj) /* 644 */ #define Tcl_NewUnicodeObj \ (tclStubsPtr->tcl_NewUnicodeObj) /* 645 */ +#define Tcl_UtfToUniChar \ + (tclStubsPtr->tcl_UtfToUniChar) /* 646 */ +#define Tcl_UniCharLen \ + (tclStubsPtr->tcl_UniCharLen) /* 647 */ +#define Tcl_UniCharNcmp \ + (tclStubsPtr->tcl_UniCharNcmp) /* 648 */ +#define Tcl_UniCharToUtfDString \ + (tclStubsPtr->tcl_UniCharToUtfDString) /* 649 */ +#define Tcl_UtfToUniCharDString \ + (tclStubsPtr->tcl_UtfToUniCharDString) /* 650 */ #endif /* defined(USE_TCL_STUBS) */ @@ -4084,7 +4099,7 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_BackgroundError #define Tcl_BackgroundError(interp) Tcl_BackgroundException((interp), TCL_ERROR) -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 # undef Tcl_GetUnicodeFromObj # define Tcl_GetUnicodeFromObj Tcl_GetUtf16FromObj # undef Tcl_NewUnicodeObj diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index e5fce72..afa76c3 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -903,7 +903,7 @@ PrintSourceToObj( i += 2; continue; default: -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 if (ch > 0xffff) { Tcl_AppendPrintfToObj(appendObj, "\\U%08x", ch); i += 10; diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 0827907..3c73c68 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -1297,7 +1297,7 @@ Tcl_ExternalToUtf( if (*dstCharsPtr <= maxChars) { break; } - dstLen = Tcl_UtfAtIndex(dst, maxChars) - 1 - dst + TCL_UTF_MAX; + dstLen = Tcl_UtfAtIndex(dst, maxChars) - dst + (TCL_UTF_MAX - 1); flags = savedFlags; *statePtr = savedState; } while (1); @@ -2401,7 +2401,7 @@ UtfToUtfProc( int len = TclUtfToUniChar(src, chPtr); src += len; dst += Tcl_UniCharToUtf(*chPtr, dst); -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((*chPtr >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src + len, chPtr); dst += Tcl_UniCharToUtf(*chPtr, dst); @@ -2590,7 +2590,7 @@ UtfToUtf16Proc( */ #ifdef WORDS_BIGENDIAN -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 if (*chPtr <= 0xFFFF) { *dst++ = (*chPtr >> 8); *dst++ = (*chPtr & 0xFF); @@ -2605,7 +2605,7 @@ UtfToUtf16Proc( *dst++ = (*chPtr & 0xFF); #endif #else -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 if (*chPtr <= 0xFFFF) { *dst++ = (*chPtr & 0xFF); *dst++ = (*chPtr >> 8); @@ -2673,7 +2673,7 @@ UtfToUcs2Proc( { const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd; int result, numChars; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 int len; #endif Tcl_UniChar ch = 0; @@ -2703,7 +2703,7 @@ UtfToUcs2Proc( result = TCL_CONVERT_NOSPACE; break; } -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 src += (len = TclUtfToUniChar(src, &ch)); if ((ch >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src, &ch); @@ -2927,7 +2927,7 @@ TableFromUtfProc( } len = TclUtfToUniChar(src, &ch); -#if TCL_UTF_MAX > 4 +#if TCL_UTF_MAX > 3 /* * This prevents a crash condition. More evaluation is required for * full support of int Tcl_UniChar. [Bug 1004065] @@ -3138,7 +3138,7 @@ Iso88591FromUtfProc( */ if (ch > 0xff -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 || ((ch >= 0xD800) && (len < 3)) #endif ) { @@ -3146,7 +3146,7 @@ Iso88591FromUtfProc( result = TCL_CONVERT_UNKNOWN; break; } -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) len = 4; #endif /* diff --git a/generic/tclExecute.c b/generic/tclExecute.c index dfb1140..903e8d7 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5215,7 +5215,7 @@ TEBCresume( objResultPtr = Tcl_NewStringObj((const char *) valuePtr->bytes+index, 1); } else { - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; int ch = Tcl_GetUniChar(valuePtr, index); /* @@ -7985,8 +7985,8 @@ ExecuteExtendedBinaryMathOp( if (((wQuotient < (Tcl_WideInt) 0) || ((wQuotient == (Tcl_WideInt) 0) - && ((w1 < (Tcl_WideInt)0 && w2 > (Tcl_WideInt)0) - || (w1 > (Tcl_WideInt)0 && w2 < (Tcl_WideInt)0)))) + && ((w1 < 0 && w2 > 0) + || (w1 > 0 && w2 < 0)))) && (wQuotient * w2 != w1)) { wQuotient -= (Tcl_WideInt) 1; } @@ -8020,7 +8020,7 @@ ExecuteExtendedBinaryMathOp( mp_init(&bigResult); mp_init(&bigRemainder); mp_div(&big1, &big2, &bigResult, &bigRemainder); - if (!mp_iszero(&bigRemainder) && (bigRemainder.sign != big2.sign)) { + if ((bigRemainder.used != 0) && (bigRemainder.sign != big2.sign)) { /* * Convert to Tcl's integer division rules. */ @@ -8042,11 +8042,11 @@ ExecuteExtendedBinaryMathOp( switch (type2) { case TCL_NUMBER_INT: - invalid = (*((const Tcl_WideInt *)ptr2) < (Tcl_WideInt)0); + invalid = (*((const Tcl_WideInt *)ptr2) < 0); break; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - invalid = mp_isneg(&big2); + invalid = big2.sign != MP_ZPOS; mp_clear(&big2); break; default: @@ -8063,7 +8063,7 @@ ExecuteExtendedBinaryMathOp( * Zero shifted any number of bits is still zero. */ - if ((type1==TCL_NUMBER_INT) && (*((const Tcl_WideInt *)ptr1) == (Tcl_WideInt)0)) { + if ((type1==TCL_NUMBER_INT) && (*((const Tcl_WideInt *)ptr1) == 0)) { return constants[0]; } @@ -8121,11 +8121,11 @@ ExecuteExtendedBinaryMathOp( switch (type1) { case TCL_NUMBER_INT: - zero = (*(const Tcl_WideInt *)ptr1 > (Tcl_WideInt)0); + zero = (*(const Tcl_WideInt *)ptr1 > 0); break; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, valuePtr, &big1); - zero = (!mp_isneg(&big1)); + zero = (big1.sign == MP_ZPOS); mp_clear(&big1); break; default: @@ -8146,7 +8146,7 @@ ExecuteExtendedBinaryMathOp( if (type1 == TCL_NUMBER_INT) { w1 = *(const Tcl_WideInt *)ptr1; if ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideInt)) { - if (w1 >= (Tcl_WideInt)0) { + if (w1 >= 0) { return constants[0]; } WIDE_RESULT(-1); @@ -8249,9 +8249,9 @@ ExecuteExtendedBinaryMathOp( oddExponent = (int) (w2 & (Tcl_WideInt)1); } else { Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - negativeExponent = mp_isneg(&big2); + negativeExponent = big2.sign != MP_ZPOS; mp_mod_2d(&big2, 1, &big2); - oddExponent = !mp_iszero(&big2); + oddExponent = big2.used != 0; mp_clear(&big2); } @@ -8568,7 +8568,7 @@ ExecuteExtendedBinaryMathOp( mp_mul(&big1, &big2, &bigResult); break; case INST_DIV: - if (mp_iszero(&big2)) { + if (big2.used == 0) { mp_clear(&big1); mp_clear(&big2); mp_clear(&bigResult); @@ -8577,7 +8577,7 @@ ExecuteExtendedBinaryMathOp( mp_init(&bigRemainder); mp_div(&big1, &big2, &bigResult, &bigRemainder); /* TODO: internals intrusion */ - if (!mp_iszero(&bigRemainder) + if ((bigRemainder.used != 0) && (bigRemainder.sign != big2.sign)) { /* * Convert to Tcl's integer division rules. @@ -8724,7 +8724,7 @@ TclCompareTwoNumbers( goto wideCompare; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - if (mp_isneg(&big2)) { + if (big2.sign != MP_ZPOS) { compare = MP_GT; } else { compare = MP_LT; @@ -8761,7 +8761,7 @@ TclCompareTwoNumbers( } Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); if ((d1 < (double)WIDE_MAX) && (d1 > (double)WIDE_MIN)) { - if (mp_isneg(&big2)) { + if (big2.sign != MP_ZPOS) { compare = MP_GT; } else { compare = MP_LT; diff --git a/generic/tclIO.c b/generic/tclIO.c index 3879aa9..f49ea95 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4705,7 +4705,7 @@ Tcl_GetsObj( * Skip the raw bytes that make up the '\n'. */ - char tmp[TCL_UTF_MAX]; + char tmp[4]; int rawRead; bufPtr = gs.bufPtr; @@ -6216,7 +6216,7 @@ ReadChars( * and do not encounter the eof char this time. */ - dstLimit = dstRead - 1 + TCL_UTF_MAX; + dstLimit = dstRead + (TCL_UTF_MAX - 1); statePtr->flags = savedFlags; statePtr->inputEncodingFlags = savedIEFlags; statePtr->inputEncodingState = savedState; @@ -6241,7 +6241,7 @@ ReadChars( * here in this call. */ - dstLimit = dstRead - 1 + TCL_UTF_MAX; + dstLimit = dstRead + (TCL_UTF_MAX - 1); statePtr->flags = savedFlags; statePtr->inputEncodingFlags = savedIEFlags; statePtr->inputEncodingState = savedState; @@ -6258,7 +6258,7 @@ ReadChars( */ if (code != TCL_OK) { - char buffer[TCL_UTF_MAX + 1]; + char buffer[5]; int read, decoded, count; /* diff --git a/generic/tclInt.h b/generic/tclInt.h index b95bee9..99a2a58 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3060,7 +3060,6 @@ MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp, MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TclInitAlloc(void); -MODULE_SCOPE void TclInitBignumFromLong(mp_int *, long); MODULE_SCOPE void TclInitBignumFromWideInt(mp_int *, Tcl_WideInt); MODULE_SCOPE void TclInitBignumFromWideUInt(mp_int *, Tcl_WideUInt); MODULE_SCOPE void TclInitDbCkalloc(void); @@ -3241,7 +3240,7 @@ MODULE_SCOPE const char*TclGetCommandTypeName(Tcl_Command command); MODULE_SCOPE void TclRegisterCommandTypeName( Tcl_ObjCmdProc *implementationProc, const char *nameStr); -#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32)) +#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32)) MODULE_SCOPE int TclUtfToUtf16(const char *src, unsigned short *chPtr); MODULE_SCOPE char * Tcl_Utf16ToUtfDString(const unsigned short *uniStr, int uniLength, Tcl_DString *dsPtr); diff --git a/generic/tclMain.c b/generic/tclMain.c index 4b8fa8c..f7a4cf8 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -59,9 +59,9 @@ * encoding to UTF-8). */ -#if defined(UNICODE) && (TCL_UTF_MAX <= 4) +#if defined(UNICODE) && (TCL_UTF_MAX == 3) # define NewNativeObj Tcl_NewUnicodeObj -#else /* !UNICODE || (TCL_UTF_MAX > 4) */ +#else /* !UNICODE || (TCL_UTF_MAX > 3) */ static inline Tcl_Obj * NewNativeObj( TCHAR *string, @@ -79,7 +79,7 @@ NewNativeObj( #endif return TclDStringToObj(&ds); } -#endif /* !UNICODE || (TCL_UTF_MAX > 4) */ +#endif /* !UNICODE || (TCL_UTF_MAX > 3) */ /* * Declarations for various library functions and variables (don't want to diff --git a/generic/tclParse.c b/generic/tclParse.c index 2419026..093fbea 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -791,7 +791,7 @@ TclParseBackslash( Tcl_UniChar unichar = 0; int result; int count; - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; if (numBytes == 0) { if (readPtr != NULL) { @@ -924,7 +924,7 @@ TclParseBackslash( if (Tcl_UtfCharComplete(p, numBytes - 1)) { count = TclUtfToUniChar(p, &unichar) + 1; /* +1 for '\' */ } else { - char utfBytes[TCL_UTF_MAX]; + char utfBytes[5]; memcpy(utfBytes, p, numBytes - 1); utfBytes[numBytes - 1] = '\0'; @@ -2151,7 +2151,7 @@ TclSubstTokens( Tcl_Obj *appendObj = NULL; const char *append = NULL; int appendByteLength = 0; - char utfCharBytes[TCL_UTF_MAX] = ""; + char utfCharBytes[4] = ""; switch (tokenPtr->type) { case TCL_TOKEN_TEXT: diff --git a/generic/tclPipe.c b/generic/tclPipe.c index f94fe5c..63fd2fa 100644 --- a/generic/tclPipe.c +++ b/generic/tclPipe.c @@ -333,7 +333,7 @@ TclCleanupChildren( int count; Tcl_Obj *objPtr; - Tcl_Seek(errorChan, (Tcl_WideInt)0, SEEK_SET); + Tcl_Seek(errorChan, 0, SEEK_SET); objPtr = Tcl_NewObj(); count = Tcl_ReadChars(errorChan, objPtr, -1, 0); if (count < 0) { diff --git a/generic/tclScan.c b/generic/tclScan.c index 0f578d8..068450c 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -261,7 +261,7 @@ ValidateFormat( Tcl_UniChar ch = 0; int objIndex, xpgSize, nspace = numVars; int *nassign = TclStackAlloc(interp, nspace * sizeof(int)); - char buf[TCL_UTF_MAX+1] = ""; + char buf[5] = ""; Tcl_Obj *errorMsg; /* Place to build an error messages. Note that * these are messy operations because we do * not want to use the formatting engine; @@ -881,7 +881,7 @@ Tcl_ScanObjCmd( offset = TclUtfToUniChar(string, &sch); i = (int)sch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((sch >= 0xD800) && (offset < 3)) { offset += TclUtfToUniChar(string+offset, &sch); i = (((i<<10) & 0x0FFC00) + 0x10000) + (sch & 0x3FF); @@ -943,7 +943,7 @@ Tcl_ScanObjCmd( int code = Tcl_GetBignumFromObj(interp, objPtr, &big); if (code == TCL_OK) { - if (mp_isneg(&big)) { + if (big.sign != MP_ZPOS) { code = TCL_ERROR; } mp_clear(&big); diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index b7f35e6..e7cb2c5 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -530,7 +530,7 @@ TclParseNumber( int shift = 0; /* Amount to shift when accumulating binary */ int explicitOctal = 0; -#define ALL_BITS (~(Tcl_WideUInt)0) +#define ALL_BITS ((Tcl_WideUInt)-1) #define MOST_BITS (ALL_BITS >> 1) /* @@ -709,7 +709,7 @@ TclParseNumber( && (((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) || (octalSignificandWide > - (~(Tcl_WideUInt)0 >> shift)))) { + ((Tcl_WideUInt)-1 >> shift)))) { octalSignificandOverflow = 1; TclInitBignumFromWideUInt(&octalSignificandBig, octalSignificandWide); @@ -826,7 +826,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; TclInitBignumFromWideUInt(&significandBig, significandWide); @@ -867,7 +867,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > (~(Tcl_WideUInt)0 >> shift))) { + significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; TclInitBignumFromWideUInt(&significandBig, significandWide); @@ -1451,7 +1451,7 @@ AccumulateDecimalDigit( *wideRepPtr = digit; return 0; } else if (numZeros >= maxpow10_wide - || w > ((~(Tcl_WideUInt)0)-digit)/pow10_wide[numZeros+1]) { + || w > ((Tcl_WideUInt)-1-digit)/pow10_wide[numZeros+1]) { /* * Wide multiplication will overflow. Expand the number to a * bignum and fall through into the bignum case. @@ -4649,7 +4649,7 @@ TclCeil( mp_int b; mp_init(&b); - if (mp_isneg(a)) { + if (a->sign != MP_ZPOS) { mp_neg(a, &b); r = -TclFloor(&b); } else { @@ -4666,7 +4666,7 @@ TclCeil( mp_int d; mp_init(&d); mp_div_2d(a, -shift, &b, &d); - exact = mp_iszero(&d); + exact = d.used == 0; mp_clear(&d); } else { mp_copy(a, &b); @@ -4706,7 +4706,7 @@ TclFloor( mp_int b; mp_init(&b); - if (mp_isneg(a)) { + if (a->sign != MP_ZPOS) { mp_neg(a, &b); r = -TclCeil(&b); } else { diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 6cbf5e7..205db00 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -568,7 +568,7 @@ Tcl_GetUniChar( return -1; } ch = stringPtr->unicode[index]; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* See: bug [11ae2be95dac9417] */ if ((ch & 0xF800) == 0xD800) { if (ch & 0x400) { @@ -606,7 +606,7 @@ Tcl_GetUniChar( *---------------------------------------------------------------------- */ -#if !defined(TCL_NO_DEPRECATED) && (TCL_UTF_MAX<=4) +#if !defined(TCL_NO_DEPRECATED) && (TCL_UTF_MAX==3) #undef Tcl_GetUnicode unsigned short * Tcl_GetUnicode( @@ -752,7 +752,7 @@ Tcl_GetRange( if (last < first) { return Tcl_NewObj(); } -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* See: bug [11ae2be95dac9417] */ if ((first > 0) && ((stringPtr->unicode[first] & 0xFC00) == 0xDC00) && ((stringPtr->unicode[first-1] & 0xFC00) == 0xD800)) { @@ -2041,7 +2041,7 @@ Tcl_AppendFormatToObj( } break; case 'c': { - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; int code, length; if (TclGetIntFromObj(interp, segment, &code) != TCL_OK) { diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index da25b2a..b85c360 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -57,19 +57,20 @@ #undef TclWinSetSockOpt #undef TclWinNToHS #undef TclStaticPackage +#undef TclBNInitBignumFromLong #undef Tcl_BackgroundError #define TclStaticPackage Tcl_StaticPackage #undef Tcl_GetUnicodeFromObj #undef Tcl_NewUnicodeObj static void uniCodePanic() { -#if TCL_UTF_MAX <= 4 - Tcl_Panic("This extension is compiled with -DTCL_UTF_MAX=6, but Tcl is compiled with -DTCL_UTF_MAX=4"); +#if TCL_UTF_MAX == 3 + Tcl_Panic("This extension is compiled with -DTCL_UTF_MAX>3, but Tcl is compiled with -DTCL_UTF_MAX==3"); #else - Tcl_Panic("This extension is compiled with -DTCL_UTF_MAX=4, but Tcl is compiled with -DTCL_UTF_MAX=6"); + Tcl_Panic("This extension is compiled with -DTCL_UTF_MAX==3, but Tcl is compiled with -DTCL_UTF_MAX>3"); #endif } -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 # define Tcl_GetUnicodeFromObj (int *(*)(Tcl_Obj *, int *)) uniCodePanic # define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const int *, int)) uniCodePanic #else @@ -120,8 +121,12 @@ static int TclSockMinimumBuffersOld(int sock, int size) # define Tcl_NewLongObj 0 # define Tcl_DbNewLongObj 0 # define Tcl_BackgroundError 0 - #else +#define TclBNInitBignumFromLong initBignumFromLong +static void TclBNInitBignumFromLong(mp_int *a, long b) +{ + TclInitBignumFromWideInt(a, b); +} #define TclSetStartupScriptPath setStartupScriptPath static void TclSetStartupScriptPath(Tcl_Obj *path) { @@ -172,7 +177,6 @@ TclWinGetPlatformId(void) #endif # define TclBNInitBignumFromWideUInt TclInitBignumFromWideUInt # define TclBNInitBignumFromWideInt TclInitBignumFromWideInt -# define TclBNInitBignumFromLong TclInitBignumFromLong #endif /* TCL_NO_DEPRECATED */ #ifdef _WIN32 @@ -1331,7 +1335,7 @@ const TclStubs tclStubs = { Tcl_UtfToExternalDString, /* 333 */ Tcl_UtfToLower, /* 334 */ Tcl_UtfToTitle, /* 335 */ - Tcl_UtfToUniChar, /* 336 */ + 0, /* 336 */ Tcl_UtfToUpper, /* 337 */ Tcl_WriteChars, /* 338 */ Tcl_WriteObj, /* 339 */ @@ -1347,10 +1351,10 @@ const TclStubs tclStubs = { Tcl_UniCharIsSpace, /* 349 */ Tcl_UniCharIsUpper, /* 350 */ Tcl_UniCharIsWordChar, /* 351 */ - Tcl_UniCharLen, /* 352 */ - Tcl_UniCharNcmp, /* 353 */ - Tcl_UniCharToUtfDString, /* 354 */ - Tcl_UtfToUniCharDString, /* 355 */ + 0, /* 352 */ + 0, /* 353 */ + 0, /* 354 */ + 0, /* 355 */ Tcl_GetRegExpFromObj, /* 356 */ Tcl_EvalTokens, /* 357 */ Tcl_FreeParse, /* 358 */ @@ -1641,6 +1645,11 @@ const TclStubs tclStubs = { Tcl_IsShared, /* 643 */ Tcl_GetUnicodeFromObj, /* 644 */ Tcl_NewUnicodeObj, /* 645 */ + Tcl_UtfToUniChar, /* 646 */ + Tcl_UniCharLen, /* 647 */ + Tcl_UniCharNcmp, /* 648 */ + Tcl_UniCharToUtfDString, /* 649 */ + Tcl_UtfToUniCharDString, /* 650 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index b7cf97f..cb99df7 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -30,19 +30,12 @@ /* Define custom memory allocation for libtommath */ -/* MODULE_SCOPE void* TclBNAlloc( size_t ); */ -#define TclBNAlloc(s) ((void*)ckalloc((size_t)(s))) -/* MODULE_SCOPE void* TclBNRealloc( void*, size_t ); */ -#define TclBNRealloc(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s))) -/* MODULE_SCOPE void TclBNFree( void* ); */ -#define TclBNFree(x) (ckfree((char*)(x))) -/* MODULE_SCOPE void* TclBNCalloc( size_t, size_t ); */ -/* unused - no macro */ - -#define XMALLOC(x) TclBNAlloc(x) -#define XFREE(x) TclBNFree(x) -#define XREALLOC(x,n) TclBNRealloc(x,n) -#define XCALLOC(n,x) TclBNCalloc(n,x) +/* MODULE_SCOPE void* XMALLOC( size_t ); */ +#define XMALLOC(s) ((void*)ckalloc((size_t)(s))) +/* MODULE_SCOPE void* XREALLOC( void*, size_t ); */ +#define XREALLOC(x,s) ((void*)ckrealloc((char*)(x),(size_t)(s))) +/* MODULE_SCOPE void XFREE( void* ); */ +#define XFREE(x) (ckfree((char*)(x))) /* Rename the global symbols in libtommath to avoid linkage conflicts */ diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c index 9e7bf4b..236a8cf 100644 --- a/generic/tclTomMathInterface.c +++ b/generic/tclTomMathInterface.c @@ -93,39 +93,7 @@ TclBN_revision(void) /* *---------------------------------------------------------------------- * - * TclInitBignumFromLong -- - * - * Allocate and initialize a 'bignum' from a native 'long'. - * - * Results: - * None. - * - * Side effects: - * The 'bignum' is constructed. - * - *---------------------------------------------------------------------- - */ - -void -TclInitBignumFromLong( - mp_int *a, - long v) -{ - if (mp_init_size(a, (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { - Tcl_Panic("initialization failure in TclInitBignumFromLong"); - } - if (v < (long)0) { - mp_set_long_long(a, (Tcl_WideUInt)(-(Tcl_WideInt)v)); - mp_neg(a, a); - } else { - mp_set_long_long(a, (Tcl_WideUInt)v); - } -} - -/* - *---------------------------------------------------------------------- - * - * TclBNInitBignumFromWideInt -- + * TclInitBignumFromWideInt -- * * Allocate and initialize a 'bignum' from a Tcl_WideInt * @@ -146,7 +114,7 @@ TclInitBignumFromWideInt( if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { Tcl_Panic("initialization failure in TclInitBignumFromWideInt"); } - if (v < (Tcl_WideInt)0) { + if (v < 0) { mp_set_long_long(a, (Tcl_WideUInt)(-v)); mp_neg(a, a); } else { @@ -157,7 +125,7 @@ TclInitBignumFromWideInt( /* *---------------------------------------------------------------------- * - * TclBNInitBignumFromWideUInt -- + * TclInitBignumFromWideUInt -- * * Allocate and initialize a 'bignum' from a Tcl_WideUInt * diff --git a/generic/tclUniData.c b/generic/tclUniData.c index 942e2f0..1cc84fd 100644 --- a/generic/tclUniData.c +++ b/generic/tclUniData.c @@ -195,7 +195,7 @@ static const unsigned short pageMap[] = { 1344, 1344, 1344, 1344, 10176, 10208, 1344, 10240, 1344, 10272, 10304, 10336, 10368, 10400, 10432, 1344, 1344, 1344, 10464, 10496, 64, 10528, 10560, 10592, 4736, 10624, 10656 -#if TCL_UTF_MAX > 3 +#if TCL_UTF_MAX > 3 || TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6 ,10688, 10720, 10752, 1824, 1344, 1344, 1344, 8288, 10784, 10816, 10848, 10880, 10912, 10944, 10976, 11008, 1824, 1824, 1824, 1824, 9280, 1344, 11040, 11072, 1344, 11104, 11136, 11168, 11200, 1344, 11232, 1824, @@ -1153,7 +1153,7 @@ static const unsigned char groupMap[] = { 0, 0, 15, 15, 15, 15, 15, 15, 0, 0, 15, 15, 15, 15, 15, 15, 0, 0, 15, 15, 15, 0, 0, 0, 4, 4, 7, 11, 14, 4, 4, 0, 14, 7, 7, 7, 7, 14, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 14, 14, 0, 0 -#if TCL_UTF_MAX > 3 +#if TCL_UTF_MAX > 3 || TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6 ,15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, @@ -1613,7 +1613,7 @@ static const int groups[] = { 18, 17, 10305, 10370, 8769, 8834 }; -#if TCL_UTF_MAX > 3 +#if TCL_UTF_MAX > 3 || TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6 # define UNICODE_OUT_OF_RANGE(ch) (((ch) & 0x1fffff) >= 0x2fa20) #else # define UNICODE_OUT_OF_RANGE(ch) (((ch) & 0x1f0000) != 0) @@ -1672,7 +1672,7 @@ enum { * Unicode character tables. */ -#if TCL_UTF_MAX > 3 +#if TCL_UTF_MAX > 3 || TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6 # define GetUniCharInfo(ch) (groups[groupMap[pageMap[((ch) & 0x1fffff) >> OFFSET_BITS] | ((ch) & ((1 << OFFSET_BITS)-1))]]) #else # define GetUniCharInfo(ch) (groups[groupMap[pageMap[((ch) & 0xffff) >> OFFSET_BITS] | ((ch) & ((1 << OFFSET_BITS)-1))]]) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 7e9c36c..ff8f6bd 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -266,7 +266,7 @@ Tcl_UniCharToUtfDString( return string; } -#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32)) +#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32)) char * Tcl_Utf16ToUtfDString( const unsigned short *uniStr, /* Utf-16 string to convert to UTF-8. */ @@ -373,7 +373,7 @@ Tcl_UtfToUniChar( * characters representing themselves. */ -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* If *chPtr contains a high surrogate (produced by a previous * Tcl_UtfToUniChar() call) and the next 3 bytes are UTF-8 continuation * bytes, then we must produce a follow-up low surrogate. We only @@ -432,7 +432,7 @@ Tcl_UtfToUniChar( /* * Four-byte-character lead byte followed by three trail bytes. */ -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 Tcl_UniChar high = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2) | ((src[2] & 0x3F) >> 4)) - 0x40; if (high >= 0x400) { @@ -461,7 +461,7 @@ Tcl_UtfToUniChar( return 1; } -#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32)) +#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32)) int TclUtfToUtf16( const char *src, /* The UTF-8 string. */ @@ -634,7 +634,7 @@ Tcl_UtfToUniCharDString( return wString; } -#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32)) +#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32)) unsigned short * Tcl_UtfToUtf16DString( const char *src, /* UTF-8 string to convert to Unicode. */ @@ -805,7 +805,7 @@ Tcl_UtfFindFirst( while (1) { len = TclUtfToUniChar(src, &find); fullchar = find; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; @@ -853,7 +853,7 @@ Tcl_UtfFindLast( while (1) { len = TclUtfToUniChar(src, &find); fullchar = find; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; @@ -896,7 +896,7 @@ Tcl_UtfNext( Tcl_UniChar ch = 0; int len = TclUtfToUniChar(src, &ch); -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); } @@ -978,19 +978,19 @@ Tcl_UniCharAtIndex( { Tcl_UniChar ch = 0; int fullchar = 0; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 int len = 0; #endif while (index-- >= 0) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 src += (len = TclUtfToUniChar(src, &ch)); #else src += TclUtfToUniChar(src, &ch); #endif } fullchar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { /* If last Tcl_UniChar was a high surrogate, combine with low surrogate */ (void)TclUtfToUniChar(src, &ch); @@ -1006,7 +1006,7 @@ Tcl_UniCharAtIndex( * Tcl_UtfAtIndex -- * * Returns a pointer to the specified character (not byte) position in - * the UTF-8 string. If TCL_UTF_MAX <= 4, characters > U+FFFF count as + * the UTF-8 string. If TCL_UTF_MAX == 3, characters > U+FFFF count as * 2 positions, but then the pointer should never be placed between * the two positions. * @@ -1031,7 +1031,7 @@ Tcl_UtfAtIndex( len = TclUtfToUniChar(src, &ch); src += len; } -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { /* Index points at character following high Surrogate */ src += TclUtfToUniChar(src, &ch); @@ -1128,7 +1128,7 @@ Tcl_UtfToUpper( while (*src) { len = TclUtfToUniChar(src, &ch); upChar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1190,7 +1190,7 @@ Tcl_UtfToLower( while (*src) { len = TclUtfToUniChar(src, &ch); lowChar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1255,7 +1255,7 @@ Tcl_UtfToTitle( if (*src) { len = TclUtfToUniChar(src, &ch); titleChar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1275,7 +1275,7 @@ Tcl_UtfToTitle( while (*src) { len = TclUtfToUniChar(src, &ch); lowChar = ch; -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1387,7 +1387,7 @@ Tcl_UtfNcmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1438,7 +1438,7 @@ Tcl_UtfNcasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1487,7 +1487,7 @@ TclUtfCmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1533,7 +1533,7 @@ TclUtfCasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX == 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { diff --git a/generic/tclUtil.c b/generic/tclUtil.c index e6576a5..0788aed 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1654,7 +1654,7 @@ Tcl_Backslash( int *readPtr) /* Fill in with number of characters read from * src, unless NULL. */ { - char buf[TCL_UTF_MAX] = ""; + char buf[4] = ""; Tcl_UniChar ch = 0; Tcl_UtfBackslash(src, readPtr, buf); @@ -3726,7 +3726,7 @@ GetWideForIndex( /* objPtr holds an integer outside the signed wide range */ /* Truncate to the signed wide range. */ - *widePtr = mp_isneg((mp_int *)cd) ? WIDE_MIN : WIDE_MAX; + *widePtr = (((mp_int *)cd)->sign != MP_ZPOS) ? WIDE_MIN : WIDE_MAX; return TCL_OK; } @@ -3839,7 +3839,7 @@ GetWideForIndex( } else { /* sum holds an integer outside the signed wide range */ /* Truncate to the signed wide range. */ - if (mp_isneg((mp_int *)cd)) { + if (((mp_int *)cd)->sign != MP_ZPOS) { *widePtr = WIDE_MIN; } else { *widePtr = WIDE_MAX; @@ -3986,7 +3986,7 @@ GetEndOffsetFromObj( if (t == TCL_NUMBER_BIG) { /* Truncate to the signed wide range. */ - if (mp_isneg((mp_int *)cd)) { + if (((mp_int *)cd)->sign != MP_ZPOS) { offset = (bytes[3] == '-') ? WIDE_MAX : WIDE_MIN; } else { offset = (bytes[3] == '-') ? WIDE_MIN : WIDE_MAX; |