diff options
-rw-r--r-- | generic/tcl.decls | 38 | ||||
-rw-r--r-- | generic/tcl.h | 19 | ||||
-rw-r--r-- | generic/tclAlloc.c | 4 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 14 | ||||
-rw-r--r-- | generic/tclDecls.h | 101 | ||||
-rw-r--r-- | generic/tclEncoding.c | 10 | ||||
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclIO.c | 4 | ||||
-rw-r--r-- | generic/tclIOSock.c | 2 | ||||
-rw-r--r-- | generic/tclInt.decls | 9 | ||||
-rw-r--r-- | generic/tclInt.h | 7 | ||||
-rw-r--r-- | generic/tclIntDecls.h | 11 | ||||
-rw-r--r-- | generic/tclMain.c | 12 | ||||
-rw-r--r-- | generic/tclParse.c | 2 | ||||
-rw-r--r-- | generic/tclPlatDecls.h | 5 | ||||
-rw-r--r-- | generic/tclScan.c | 2 | ||||
-rw-r--r-- | generic/tclStringObj.c | 28 | ||||
-rw-r--r-- | generic/tclStubInit.c | 91 | ||||
-rw-r--r-- | generic/tclTestObj.c | 36 | ||||
-rw-r--r-- | generic/tclUtf.c | 91 | ||||
-rw-r--r-- | generic/tclZipfs.c | 2 | ||||
-rw-r--r-- | tests/cmdMZ.test | 2 | ||||
-rw-r--r-- | tests/http.test | 8 | ||||
-rw-r--r-- | win/tclWin32Dll.c | 4 | ||||
-rw-r--r-- | win/tclWinFCmd.c | 38 | ||||
-rw-r--r-- | win/tclWinFile.c | 30 | ||||
-rw-r--r-- | win/tclWinInit.c | 2 | ||||
-rw-r--r-- | win/tclWinLoad.c | 2 | ||||
-rw-r--r-- | win/tclWinPipe.c | 14 | ||||
-rw-r--r-- | win/tclWinSerial.c | 2 | ||||
-rw-r--r-- | win/tclWinSock.c | 2 |
31 files changed, 286 insertions, 308 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls index 6c0b3a8..68efba2 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1246,7 +1246,7 @@ declare 351 { int Tcl_UniCharIsWordChar(int ch) } declare 352 {deprecated {Use Tcl_GetCharLength}} { - int Tcl_UniCharLen(const unsigned short *uniStr) + int Tcl_UniCharLen(const Tcl_UniChar *uniStr) } declare 353 {deprecated {Use Tcl_UtfNcmp}} { int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, @@ -1338,11 +1338,11 @@ declare 376 { declare 377 { void Tcl_RegExpGetInfo(Tcl_RegExp regexp, Tcl_RegExpInfo *infoPtr) } -declare 378 { - Tcl_Obj *Tcl_NewUnicodeObj(const unsigned short *unicode, int numChars) +declare 378 {deprecated {Use Tcl_UniCharToUtfDString}} { + Tcl_Obj *Tcl_NewUnicodeObj(const Tcl_UniChar *unicode, int numChars) } -declare 379 { - void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, const unsigned short *unicode, +declare 379 {deprecated {Use Tcl_UniCharToUtfDString}} { + void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars) } declare 380 { @@ -1352,13 +1352,13 @@ declare 381 { int Tcl_GetUniChar(Tcl_Obj *objPtr, int index) } declare 382 {deprecated {No longer in use, changed to macro}} { - unsigned short *Tcl_GetUnicode(Tcl_Obj *objPtr) + Tcl_UniChar *Tcl_GetUnicode(Tcl_Obj *objPtr) } declare 383 { Tcl_Obj *Tcl_GetRange(Tcl_Obj *objPtr, int first, int last) } -declare 384 { - void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, const unsigned short *unicode, +declare 384 {deprecated {Use Tcl_AppendStringsToObj}} { + void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length) } declare 385 { @@ -1541,8 +1541,8 @@ declare 433 { } # introduced in 8.4a3 -declare 434 { - unsigned short *Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr) +declare 434 {deprecated {Use Tcl_UtfToUniCharDString}} { + Tcl_UniChar *Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr) } # TIP#15 (math function introspection) dkf @@ -2384,11 +2384,13 @@ declare 644 { int Tcl_LinkArray(Tcl_Interp *interp, const char *varName, void *addr, int type, int size) } + declare 645 { int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr) } -# TIP #542 + +# TIP #548 declare 646 { int Tcl_UtfToUniChar(const char *src, int *chPtr) } @@ -2400,20 +2402,6 @@ declare 648 { int *Tcl_UtfToUniCharDString(const char *src, int length, Tcl_DString *dsPtr) } -declare 649 { - void TclSetUnicodeObj(Tcl_Obj *objPtr, const int *unicode, - int numChars) -} -declare 650 { - Tcl_Obj *TclNewUnicodeObj(const int *unicode, int numChars) -} -declare 651 { - int *TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr) -} -declare 652 { - void TclAppendUnicodeToObj(Tcl_Obj *objPtr, const int *unicode, - int length) -} # ----- BASELINE -- FOR -- 8.7.0 ----- # diff --git a/generic/tcl.h b/generic/tcl.h index 82b8521..8f796cc 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2135,15 +2135,16 @@ typedef struct Tcl_EncodingType { /* * The maximum number of bytes that are necessary to represent a single - * Unicode character in UTF-8. The valid values are 3 and 4 (or 6) - * (or perhaps 1 if we want to support a non-unicode enabled core). If 3, - * then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If > 3, + * Unicode character in UTF-8. The valid values are 4 and 6 + * (or perhaps 1 if we want to support a non-unicode enabled core). If 4, + * then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6, * then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode - * is the default and recommended mode. + * is the default and recommended mode. UCS-4 is experimental and not + * recommended. It works for the core, but most extensions expect UCS-2. */ #ifndef TCL_UTF_MAX -#define TCL_UTF_MAX 3 +#define TCL_UTF_MAX 4 #endif /* @@ -2154,8 +2155,12 @@ typedef struct Tcl_EncodingType { #if TCL_UTF_MAX > 3 /* * int isn't 100% accurate as it should be a strict 4-byte value - * (perhaps wchar_t). ILP64 systems may have troubles. The size of this - * value must be reflected correctly in regcustom.h. + * (perhaps wchar_t). 64-bit systems may have troubles. The size of this + * value must be reflected correctly in regcustom.h and + * in tclEncoding.c. + * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode + * XXX: string rep that Tcl_UniChar represents. Changing the size + * XXX: of Tcl_UniChar is /not/ supported. */ typedef int Tcl_UniChar; #else diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c index bad3d8a..c02c7e4 100644 --- a/generic/tclAlloc.c +++ b/generic/tclAlloc.c @@ -304,7 +304,7 @@ TclpAlloc( #endif Tcl_MutexUnlock(allocMutexPtr); - return (void *)(overPtr+1); + return (char *)(overPtr+1); } /* @@ -592,7 +592,7 @@ TclpRealloc( } if (expensive) { - void *newPtr; + char *newPtr; Tcl_MutexUnlock(allocMutexPtr); diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b3ccac3..ae98648 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -619,7 +619,7 @@ Tcl_RegsubObjCmd( */ if (wstring < wend) { - resultPtr = TclNewUnicodeObj(wstring, 0); + resultPtr = Tcl_NewUnicodeObj(wstring, 0); Tcl_IncrRefCount(resultPtr); for (; wstring < wend; wstring++) { TclAppendUnicodeToObj(resultPtr, wsubspec, wsublen); @@ -636,7 +636,7 @@ Tcl_RegsubObjCmd( (slen==1 || (strCmpFn(wstring, wsrc, (unsigned long) slen) == 0))) { if (numMatches == 0) { - resultPtr = TclNewUnicodeObj(wstring, 0); + resultPtr = Tcl_NewUnicodeObj(wstring, 0); Tcl_IncrRefCount(resultPtr); } if (p != wstring) { @@ -742,7 +742,7 @@ Tcl_RegsubObjCmd( break; } if (numMatches == 0) { - resultPtr = TclNewUnicodeObj(wstring, 0); + resultPtr = Tcl_NewUnicodeObj(wstring, 0); Tcl_IncrRefCount(resultPtr); if (offset > 0) { /* @@ -785,7 +785,7 @@ Tcl_RegsubObjCmd( subStart = info.matches[idx].start; subEnd = info.matches[idx].end; if ((subStart >= 0) && (subEnd >= 0)) { - args[idx + numParts] = TclNewUnicodeObj( + args[idx + numParts] = Tcl_NewUnicodeObj( wstring + offset + subStart, subEnd - subStart); } else { args[idx + numParts] = Tcl_NewObj(); @@ -1221,7 +1221,7 @@ Tcl_SplitObjCmd( len = TclUtfToUniChar(stringPtr, &ch); fullchar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(stringPtr + len, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; @@ -1911,7 +1911,7 @@ StringIsCmd( int fullchar; length2 = TclUtfToUniChar(string1, &ch); fullchar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (length2 < 3)) { length2 += TclUtfToUniChar(string1 + length2, &ch); fullchar = (((fullchar & 0x3ff) << 10) | (ch & 0x3ff)) + 0x10000; @@ -2096,7 +2096,7 @@ StringMapCmd( * Force result to be Unicode */ - resultPtr = TclNewUnicodeObj(ustring1, 0); + resultPtr = Tcl_NewUnicodeObj(ustring1, 0); if (mapElemc == 2) { /* diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 11c62cc..c993602 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1064,7 +1064,7 @@ EXTERN int Tcl_UniCharIsUpper(int ch); EXTERN int Tcl_UniCharIsWordChar(int ch); /* 352 */ TCL_DEPRECATED("Use Tcl_GetCharLength") -int Tcl_UniCharLen(const unsigned short *uniStr); +int Tcl_UniCharLen(const Tcl_UniChar *uniStr); /* 353 */ TCL_DEPRECATED("Use Tcl_UtfNcmp") int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, @@ -1143,23 +1143,26 @@ EXTERN int Tcl_RegExpExecObj(Tcl_Interp *interp, EXTERN void Tcl_RegExpGetInfo(Tcl_RegExp regexp, Tcl_RegExpInfo *infoPtr); /* 378 */ -EXTERN Tcl_Obj * Tcl_NewUnicodeObj(const unsigned short *unicode, +TCL_DEPRECATED("Use Tcl_UniCharToUtfDString") +Tcl_Obj * Tcl_NewUnicodeObj(const Tcl_UniChar *unicode, int numChars); /* 379 */ -EXTERN void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, - const unsigned short *unicode, int numChars); +TCL_DEPRECATED("Use Tcl_UniCharToUtfDString") +void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, + const Tcl_UniChar *unicode, int numChars); /* 380 */ EXTERN int Tcl_GetCharLength(Tcl_Obj *objPtr); /* 381 */ EXTERN int Tcl_GetUniChar(Tcl_Obj *objPtr, int index); /* 382 */ TCL_DEPRECATED("No longer in use, changed to macro") -unsigned short * Tcl_GetUnicode(Tcl_Obj *objPtr); +Tcl_UniChar * Tcl_GetUnicode(Tcl_Obj *objPtr); /* 383 */ EXTERN Tcl_Obj * Tcl_GetRange(Tcl_Obj *objPtr, int first, int last); /* 384 */ -EXTERN void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, - const unsigned short *unicode, int length); +TCL_DEPRECATED("Use Tcl_AppendStringsToObj") +void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, + const Tcl_UniChar *unicode, int length); /* 385 */ EXTERN int Tcl_RegExpMatchObj(Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); @@ -1301,7 +1304,8 @@ EXTERN int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr, int length); /* 433 */ EXTERN Tcl_ThreadId Tcl_GetChannelThread(Tcl_Channel channel); /* 434 */ -EXTERN unsigned short * Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, +TCL_DEPRECATED("Use Tcl_UtfToUniCharDString") +Tcl_UniChar * Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr); /* 435 */ TCL_DEPRECATED("") @@ -1917,16 +1921,6 @@ EXTERN char * Tcl_UniCharToUtfDString(const int *uniStr, /* 648 */ EXTERN int * Tcl_UtfToUniCharDString(const char *src, int length, Tcl_DString *dsPtr); -/* 649 */ -EXTERN void TclSetUnicodeObj(Tcl_Obj *objPtr, const int *unicode, - int numChars); -/* 650 */ -EXTERN Tcl_Obj * TclNewUnicodeObj(const int *unicode, int numChars); -/* 651 */ -EXTERN int * TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr); -/* 652 */ -EXTERN void TclAppendUnicodeToObj(Tcl_Obj *objPtr, - const int *unicode, int length); typedef struct { const struct TclPlatStubs *tclPlatStubs; @@ -2314,7 +2308,7 @@ typedef struct TclStubs { int (*tcl_UniCharIsSpace) (int ch); /* 349 */ int (*tcl_UniCharIsUpper) (int ch); /* 350 */ int (*tcl_UniCharIsWordChar) (int ch); /* 351 */ - TCL_DEPRECATED_API("Use Tcl_GetCharLength") int (*tcl_UniCharLen) (const unsigned short *uniStr); /* 352 */ + TCL_DEPRECATED_API("Use Tcl_GetCharLength") int (*tcl_UniCharLen) (const Tcl_UniChar *uniStr); /* 352 */ TCL_DEPRECATED_API("Use Tcl_UtfNcmp") int (*tcl_UniCharNcmp) (const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars); /* 353 */ char * (*tcl_Char16ToUtfDString) (const unsigned short *uniStr, int uniLength, Tcl_DString *dsPtr); /* 354 */ unsigned short * (*tcl_UtfToChar16DString) (const char *src, int length, Tcl_DString *dsPtr); /* 355 */ @@ -2340,13 +2334,13 @@ typedef struct TclStubs { int (*tcl_UniCharIsPunct) (int ch); /* 375 */ int (*tcl_RegExpExecObj) (Tcl_Interp *interp, Tcl_RegExp regexp, Tcl_Obj *textObj, int offset, int nmatches, int flags); /* 376 */ void (*tcl_RegExpGetInfo) (Tcl_RegExp regexp, Tcl_RegExpInfo *infoPtr); /* 377 */ - Tcl_Obj * (*tcl_NewUnicodeObj) (const unsigned short *unicode, int numChars); /* 378 */ - void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const unsigned short *unicode, int numChars); /* 379 */ + TCL_DEPRECATED_API("Use Tcl_UniCharToUtfDString") Tcl_Obj * (*tcl_NewUnicodeObj) (const Tcl_UniChar *unicode, int numChars); /* 378 */ + TCL_DEPRECATED_API("Use Tcl_UniCharToUtfDString") void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars); /* 379 */ int (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 380 */ int (*tcl_GetUniChar) (Tcl_Obj *objPtr, int index); /* 381 */ - TCL_DEPRECATED_API("No longer in use, changed to macro") unsigned short * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */ + TCL_DEPRECATED_API("No longer in use, changed to macro") Tcl_UniChar * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */ Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */ - void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const unsigned short *unicode, int length); /* 384 */ + TCL_DEPRECATED_API("Use Tcl_AppendStringsToObj") void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */ int (*tcl_RegExpMatchObj) (Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); /* 385 */ void (*tcl_SetNotifier) (Tcl_NotifierProcs *notifierProcPtr); /* 386 */ Tcl_Mutex * (*tcl_GetAllocMutex) (void); /* 387 */ @@ -2396,7 +2390,7 @@ typedef struct TclStubs { char * (*tcl_AttemptDbCkrealloc) (char *ptr, unsigned int size, const char *file, int line); /* 431 */ int (*tcl_AttemptSetObjLength) (Tcl_Obj *objPtr, int length); /* 432 */ Tcl_ThreadId (*tcl_GetChannelThread) (Tcl_Channel channel); /* 433 */ - unsigned short * (*tcl_GetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 434 */ + TCL_DEPRECATED_API("Use Tcl_UtfToUniCharDString") Tcl_UniChar * (*tcl_GetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 434 */ TCL_DEPRECATED_API("") int (*tcl_GetMathFuncInfo) (Tcl_Interp *interp, const char *name, int *numArgsPtr, Tcl_ValueType **argTypesPtr, Tcl_MathProc **procPtr, ClientData *clientDataPtr); /* 435 */ TCL_DEPRECATED_API("") Tcl_Obj * (*tcl_ListMathFuncs) (Tcl_Interp *interp, const char *pattern); /* 436 */ Tcl_Obj * (*tcl_SubstObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); /* 437 */ @@ -2611,10 +2605,6 @@ typedef struct TclStubs { int (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */ char * (*tcl_UniCharToUtfDString) (const int *uniStr, int uniLength, Tcl_DString *dsPtr); /* 647 */ int * (*tcl_UtfToUniCharDString) (const char *src, int length, Tcl_DString *dsPtr); /* 648 */ - void (*tclSetUnicodeObj) (Tcl_Obj *objPtr, const int *unicode, int numChars); /* 649 */ - Tcl_Obj * (*tclNewUnicodeObj) (const int *unicode, int numChars); /* 650 */ - int * (*tclGetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 651 */ - void (*tclAppendUnicodeToObj) (Tcl_Obj *objPtr, const int *unicode, int length); /* 652 */ } TclStubs; extern const TclStubs *tclStubsPtr; @@ -3943,14 +3933,6 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_UniCharToUtfDString) /* 647 */ #define Tcl_UtfToUniCharDString \ (tclStubsPtr->tcl_UtfToUniCharDString) /* 648 */ -#define TclSetUnicodeObj \ - (tclStubsPtr->tclSetUnicodeObj) /* 649 */ -#define TclNewUnicodeObj \ - (tclStubsPtr->tclNewUnicodeObj) /* 650 */ -#define TclGetUnicodeFromObj \ - (tclStubsPtr->tclGetUnicodeFromObj) /* 651 */ -#define TclAppendUnicodeToObj \ - (tclStubsPtr->tclAppendUnicodeToObj) /* 652 */ #endif /* defined(USE_TCL_STUBS) */ @@ -4130,41 +4112,40 @@ extern const TclStubs *tclStubsPtr; #undef Tcl_SetLongObj #define Tcl_SetLongObj(objPtr, value) Tcl_SetWideIntObj((objPtr), (long)(value)) #undef Tcl_GetUnicode -#define Tcl_GetUnicode(objPtr) TclGetUnicodeFromObj((objPtr), NULL) +#define Tcl_GetUnicode(objPtr) Tcl_GetUnicodeFromObj((objPtr), NULL) #undef Tcl_BackgroundError #define Tcl_BackgroundError(interp) Tcl_BackgroundException((interp), TCL_ERROR) #undef Tcl_StringMatch #define Tcl_StringMatch(str, pattern) Tcl_StringCaseMatch((str), (pattern), 0) -#if TCL_UTF_MAX == 3 -# undef TclGetUnicodeFromObj -# define TclGetUnicodeFromObj Tcl_GetUnicodeFromObj -# undef TclNewUnicodeObj -# define TclNewUnicodeObj Tcl_NewUnicodeObj -# undef TclSetUnicodeObj -# define TclSetUnicodeObj Tcl_SetUnicodeObj -# undef TclAppendUnicodeToObj -# define TclAppendUnicodeToObj Tcl_AppendUnicodeToObj +#if TCL_UTF_MAX <= 3 # undef Tcl_UniCharToUtfDString # define Tcl_UniCharToUtfDString Tcl_Char16ToUtfDString # undef Tcl_UtfToUniCharDString # define Tcl_UtfToUniCharDString Tcl_UtfToChar16DString -# undef Tcl_UtfToUniChar -# define Tcl_UtfToUniChar Tcl_UtfToChar16 -#endif - -#if TCL_UTF_MAX > 3 || defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 -# undef Tcl_UniCharLen +# undef Tcl_UtfToUniChar +# define Tcl_UtfToUniChar Tcl_UtfToChar16 #endif - - #if defined(USE_TCL_STUBS) -# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) ? (char *(*)(const wchar_t *, int, Tcl_DString *))tclStubsPtr->tcl_UniCharToUtfDString : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) -# define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) ? (wchar_t *(*)(const char *, int, Tcl_DString *))tclStubsPtr->tcl_UtfToUniCharDString : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) -# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) ? tclStubsPtr->tcl_UtfToChar16 : Tcl_UtfToUniChar) +#if defined(USE_TCL_STUBS) +# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \ + ? (char *(*)(const wchar_t *, int, Tcl_DString *))tclStubsPtr->tcl_UniCharToUtfDString \ + : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) +# define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) \ + ? (wchar_t *(*)(const char *, int, Tcl_DString *))tclStubsPtr->tcl_UtfToUniCharDString \ + : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) +# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \ + ? (int (*)(const char *, wchar_t *))tclStubsPtr->tcl_UtfToChar16 \ + : (int (*)(const char *, wchar_t *))Tcl_UtfToUniChar) #else -# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) ? (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_UniCharToUtfDString : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) -# define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) ? (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToUniCharDString : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) -# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) ? Tcl_UtfToChar16 : Tcl_UtfToUniChar) +# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \ + ? (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_UniCharToUtfDString \ + : (char *(*)(const wchar_t *, int, Tcl_DString *))Tcl_Char16ToUtfDString) +# define Tcl_UtfToWCharDString (sizeof(wchar_t) != sizeof(short) \ + ? (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToUniCharDString \ + : (wchar_t *(*)(const char *, int, Tcl_DString *))Tcl_UtfToChar16DString) +# define Tcl_UtfToWChar (sizeof(wchar_t) != sizeof(short) \ + ? (int (*)(const char *, wchar_t *))Tcl_UtfToChar16 \ + : (int (*)(const char *, wchar_t *))Tcl_UtfToUniChar) #endif /* diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 34fd551..e7cc344 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2418,7 +2418,7 @@ UtfToUtfProc( int len = TclUtfToUniChar(src, chPtr); src += len; dst += Tcl_UniCharToUtf(*chPtr, dst); -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((*chPtr >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src + len, chPtr); dst += Tcl_UniCharToUtf(*chPtr, dst); @@ -2691,7 +2691,7 @@ UtfToUcs2Proc( { const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd; int result, numChars; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 int len; #endif Tcl_UniChar ch = 0; @@ -2721,7 +2721,7 @@ UtfToUcs2Proc( result = TCL_CONVERT_NOSPACE; break; } -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 src += (len = TclUtfToUniChar(src, &ch)); if ((ch >= 0xD800) && (len < 3)) { src += TclUtfToUniChar(src, &ch); @@ -3156,7 +3156,7 @@ Iso88591FromUtfProc( */ if (ch > 0xff -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 || ((ch >= 0xD800) && (len < 3)) #endif ) { @@ -3164,7 +3164,7 @@ Iso88591FromUtfProc( result = TCL_CONVERT_UNKNOWN; break; } -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) len = 4; #endif /* diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 9f420b2..962a1aa 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5439,7 +5439,7 @@ TEBCresume( } ustring3 = TclGetUnicodeFromObj(value3Ptr, &length3); - objResultPtr = TclNewUnicodeObj(ustring1, 0); + objResultPtr = Tcl_NewUnicodeObj(ustring1, 0); p = ustring1; end = ustring1 + length; for (; ustring1 < end; ustring1++) { diff --git a/generic/tclIO.c b/generic/tclIO.c index 40b32cc..118820a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4712,7 +4712,7 @@ Tcl_GetsObj( * Skip the raw bytes that make up the '\n'. */ - char tmp[4]; + char tmp[TCL_UTF_MAX]; int rawRead; bufPtr = gs.bufPtr; @@ -6265,7 +6265,7 @@ ReadChars( */ if (code != TCL_OK) { - char buffer[5]; + char buffer[TCL_UTF_MAX + 1]; int read, decoded, count; /* diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c index e9f9066..adf729a 100644 --- a/generic/tclIOSock.c +++ b/generic/tclIOSock.c @@ -35,7 +35,7 @@ gai_strerror( Tcl_DStringInit(&tsdPtr->errorMsg); tsdPtr->initialized = 1; } - Tcl_Char16ToUtfDString(gai_strerrorW(code), -1, &tsdPtr->errorMsg); + Tcl_WCharToUtfDString(gai_strerrorW(code), -1, &tsdPtr->errorMsg); return Tcl_DStringValue(&tsdPtr->errorMsg); } #endif diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 556da28..49fa228 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -1034,6 +1034,15 @@ declare 258 { Tcl_Obj *TclpCreateTemporaryDirectory(Tcl_Obj *dirObj, Tcl_Obj *basenameObj) } +# TIP 548 +declare 259 { + Tcl_UniChar *TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr) +} +declare 260 { + void TclAppendUnicodeToObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, + int length) +} + ############################################################################## diff --git a/generic/tclInt.h b/generic/tclInt.h index e86e7ad..26f1840 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4620,10 +4620,17 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, *---------------------------------------------------------------- */ +#if TCL_UTF_MAX > 3 #define TclUtfToUniChar(str, chPtr) \ ((((unsigned char) *(str)) < 0x80) ? \ ((*(chPtr) = (unsigned char) *(str)), 1) \ : Tcl_UtfToUniChar(str, chPtr)) +#else +#define TclUtfToUniChar(str, chPtr) \ + ((((unsigned char) *(str)) < 0x80) ? \ + ((*(chPtr) = (unsigned char) *(str)), 1) \ + : Tcl_UtfToChar16(str, chPtr)) +#endif /* *---------------------------------------------------------------- diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 16bcdf8..721d34d 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -658,6 +658,11 @@ EXTERN void TclStaticPackage(Tcl_Interp *interp, /* 258 */ EXTERN Tcl_Obj * TclpCreateTemporaryDirectory(Tcl_Obj *dirObj, Tcl_Obj *basenameObj); +/* 259 */ +EXTERN Tcl_UniChar * TclGetUnicodeFromObj(Tcl_Obj *objPtr, int *lengthPtr); +/* 260 */ +EXTERN void TclAppendUnicodeToObj(Tcl_Obj *objPtr, + const Tcl_UniChar *unicode, int length); typedef struct TclIntStubs { int magic; @@ -922,6 +927,8 @@ typedef struct TclIntStubs { int (*tclPtrUnsetVar) (Tcl_Interp *interp, Tcl_Var varPtr, Tcl_Var arrayPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, const int flags); /* 256 */ void (*tclStaticPackage) (Tcl_Interp *interp, const char *pkgName, Tcl_PackageInitProc *initProc, Tcl_PackageInitProc *safeInitProc); /* 257 */ Tcl_Obj * (*tclpCreateTemporaryDirectory) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj); /* 258 */ + Tcl_UniChar * (*tclGetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 259 */ + void (*tclAppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 260 */ } TclIntStubs; extern const TclIntStubs *tclIntStubsPtr; @@ -1367,6 +1374,10 @@ extern const TclIntStubs *tclIntStubsPtr; (tclIntStubsPtr->tclStaticPackage) /* 257 */ #define TclpCreateTemporaryDirectory \ (tclIntStubsPtr->tclpCreateTemporaryDirectory) /* 258 */ +#define TclGetUnicodeFromObj \ + (tclIntStubsPtr->tclGetUnicodeFromObj) /* 259 */ +#define TclAppendUnicodeToObj \ + (tclIntStubsPtr->tclAppendUnicodeToObj) /* 260 */ #endif /* defined(USE_TCL_STUBS) */ diff --git a/generic/tclMain.c b/generic/tclMain.c index 276922f..b7d740a 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -53,15 +53,6 @@ # define _tcscmp strcmp #endif -/* - * Further on, in UNICODE mode we just use Tcl_NewUnicodeObj, otherwise - * NewNativeObj is needed (which provides proper conversion from native - * encoding to UTF-8). - */ - -#if defined(UNICODE) && (TCL_UTF_MAX == 3) -# define NewNativeObj TclNewUnicodeObj -#else /* !UNICODE || (TCL_UTF_MAX > 3) */ static inline Tcl_Obj * NewNativeObj( TCHAR *string, @@ -71,13 +62,12 @@ NewNativeObj( #ifdef UNICODE Tcl_DStringInit(&ds); - Tcl_Char16ToUtfDString(string, length, &ds); + Tcl_WCharToUtfDString(string, length, &ds); #else Tcl_ExternalToUtfDString(NULL, (char *) string, length, &ds); #endif return TclDStringToObj(&ds); } -#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 89b810f..448ce5e 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -923,7 +923,7 @@ TclParseBackslash( if (Tcl_UtfCharComplete(p, numBytes - 1)) { count = TclUtfToUniChar(p, &unichar) + 1; /* +1 for '\' */ } else { - char utfBytes[5]; + char utfBytes[TCL_UTF_MAX]; memcpy(utfBytes, p, numBytes - 1); utfBytes[numBytes - 1] = '\0'; diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index c4b01d0..354d752 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -118,16 +118,15 @@ extern const TclPlatStubs *tclPlatStubsPtr; #define TCL_STORAGE_CLASS DLLIMPORT #if defined(USE_TCL_STUBS) && (defined(_WIN32) || defined(__CYGWIN__))\ - && ((TCL_UTF_MAX > 4) || defined(TCL_NO_DEPRECATED)) + && (defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8) #undef Tcl_WinUtfToTChar #undef Tcl_WinTCharToUtf #ifdef _WIN32 #define Tcl_WinUtfToTChar(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \ (TCHAR *)Tcl_UtfToChar16DString((string), (len), (dsPtr))) - #define Tcl_WinTCharToUtf(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \ (char *)Tcl_Char16ToUtfDString((string), ((((len) + 2) >> 1) - 1), (dsPtr))) - #endif #endif + #endif /* _TCLPLATDECLS */ diff --git a/generic/tclScan.c b/generic/tclScan.c index b03664f..916809f 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -881,7 +881,7 @@ Tcl_ScanObjCmd( offset = TclUtfToUniChar(string, &sch); i = (int)sch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((sch >= 0xD800) && (offset < 3)) { offset += TclUtfToUniChar(string+offset, &sch); i = (((i<<10) & 0x0FFC00) + 0x10000) + (sch & 0x3FF); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 8652363..95891c5 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -354,7 +354,7 @@ Tcl_DbNewStringObj( /* *--------------------------------------------------------------------------- * - * TclNewUnicodeObj -- + * Tcl_NewUnicodeObj -- * * This function is creates a new String object and initializes it from * the given Unicode String. If the Utf String is the same size as the @@ -371,7 +371,7 @@ Tcl_DbNewStringObj( */ Tcl_Obj * -TclNewUnicodeObj( +Tcl_NewUnicodeObj( const Tcl_UniChar *unicode, /* The unicode string used to initialize the * new object. */ int numChars) /* Number of characters in the unicode @@ -568,7 +568,7 @@ Tcl_GetUniChar( return -1; } ch = stringPtr->unicode[index]; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* See: bug [11ae2be95dac9417] */ if ((ch & 0xF800) == 0xD800) { if (ch & 0x400) { @@ -606,9 +606,9 @@ Tcl_GetUniChar( *---------------------------------------------------------------------- */ -#if !defined(TCL_NO_DEPRECATED) && (TCL_UTF_MAX==3) +#ifndef TCL_NO_DEPRECATED #undef Tcl_GetUnicode -unsigned short * +Tcl_UniChar * Tcl_GetUnicode( Tcl_Obj *objPtr) /* The object to find the unicode string * for. */ @@ -620,7 +620,7 @@ Tcl_GetUnicode( /* *---------------------------------------------------------------------- * - * Tcl_GetUnicodeFromObj -- + * TclGetUnicodeFromObj -- * * Get the Unicode form of the String object with length. If the object * is not already a String object, it will be converted to one. If the @@ -752,7 +752,7 @@ Tcl_GetRange( if (last < first) { return Tcl_NewObj(); } -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* See: bug [11ae2be95dac9417] */ if ((first > 0) && ((stringPtr->unicode[first] & 0xFC00) == 0xDC00) && ((stringPtr->unicode[first-1] & 0xFC00) == 0xD800)) { @@ -764,7 +764,7 @@ Tcl_GetRange( ++last; } #endif - return TclNewUnicodeObj(stringPtr->unicode + first, last - first + 1); + return Tcl_NewUnicodeObj(stringPtr->unicode + first, last - first + 1); } /* @@ -1057,7 +1057,7 @@ Tcl_AttemptSetObjLength( */ void -TclSetUnicodeObj( +Tcl_SetUnicodeObj( Tcl_Obj *objPtr, /* The object to set the string of. */ const Tcl_UniChar *unicode, /* The unicode string used to initialize the * object. */ @@ -1234,7 +1234,7 @@ Tcl_AppendToObj( /* *---------------------------------------------------------------------- * - * Tcl_AppendUnicodeToObj -- + * TclAppendUnicodeToObj -- * * This function appends a Unicode string to an object in the most * efficient manner possible. Length must be >= 0. @@ -2913,7 +2913,7 @@ TclStringRepeat( */ if (!inPlace || Tcl_IsShared(objPtr)) { - objResultPtr = TclNewUnicodeObj(Tcl_GetUnicode(objPtr), length); + objResultPtr = Tcl_NewUnicodeObj(Tcl_GetUnicode(objPtr), length); } else { TclInvalidateStringRep(objPtr); objResultPtr = objPtr; @@ -3258,7 +3258,7 @@ TclStringCat( Tcl_UniChar ch = 0; /* Ugly interface! No scheme to init array size. */ - objResultPtr = TclNewUnicodeObj(&ch, 0); /* PANIC? */ + objResultPtr = Tcl_NewUnicodeObj(&ch, 0); /* PANIC? */ if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) { Tcl_DecrRefCount(objResultPtr); if (interp) { @@ -3789,7 +3789,7 @@ TclStringReverse( * Tcl_SetObjLength into growing the unicode rep buffer. */ - objPtr = TclNewUnicodeObj(&ch, 1); + objPtr = Tcl_NewUnicodeObj(&ch, 1); Tcl_SetObjLength(objPtr, stringPtr->numChars); to = Tcl_GetUnicode(objPtr); while (--src >= from) { @@ -3991,7 +3991,7 @@ TclStringReplace( /* TODO: Is there an in-place option worth pursuing here? */ - result = TclNewUnicodeObj(ustring, first); + result = Tcl_NewUnicodeObj(ustring, first); if (insertPtr) { Tcl_AppendObjToObj(result, insertPtr); } diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6ef55bd..f825b61 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -39,6 +39,14 @@ #undef Tcl_NewObj #undef Tcl_NewStringObj #undef Tcl_GetUnicode +#undef Tcl_GetUnicodeFromObj +#undef Tcl_AppendUnicodeToObj +#undef Tcl_NewUnicodeObj +#undef Tcl_SetUnicodeObj +#undef Tcl_UniCharNcasecmp +#undef Tcl_UniCharCaseMatch +#undef Tcl_UniCharLen +#undef Tcl_UniCharNcmp #undef Tcl_DumpActiveMemory #undef Tcl_ValidateAllMemory #undef Tcl_FindHashEntry @@ -60,39 +68,9 @@ #undef TclBNInitBignumFromLong #undef Tcl_BackgroundError #define TclStaticPackage Tcl_StaticPackage -#undef TclGetUnicodeFromObj -#undef TclNewUnicodeObj -#undef TclSetUnicodeObj #undef Tcl_UniCharToUtfDString #undef Tcl_UtfToUniCharDString #undef Tcl_UtfToUniChar -#undef TclAppendUnicodeToObj - -static void uniCodePanic() { -#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==3, but Tcl is compiled with -DTCL_UTF_MAX==%d", TCL_UTF_MAX); -#endif -} - -#if TCL_UTF_MAX == 3 -# define TclGetUnicodeFromObj (int *(*)(Tcl_Obj *, int *)) uniCodePanic -# define TclNewUnicodeObj (Tcl_Obj *(*)(const int *, int)) uniCodePanic -# define TclSetUnicodeObj (void (*)(Tcl_Obj *,const int *, int)) uniCodePanic -# define TclAppendUnicodeToObj (void (*)(Tcl_Obj *, const int *, int)) uniCodePanic -# define Tcl_UtfToUniChar (int (*)(const char *, int *)) uniCodePanic -# define Tcl_UniCharToUtfDString (char *(*)(const int *, int, Tcl_DString *)) uniCodePanic -# define Tcl_UtfToUniCharDString (int *(*)(const char *, int, Tcl_DString *)) uniCodePanic -#else -#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 -# define Tcl_GetUnicode (unsigned short *(*)(Tcl_Obj *)) uniCodePanic -# endif -# define Tcl_GetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, int *)) uniCodePanic -# define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const unsigned short *, int)) uniCodePanic -# define Tcl_SetUnicodeObj (void(*)(Tcl_Obj *, const unsigned short *, int)) uniCodePanic -# define Tcl_AppendUnicodeToObj (void(*)(Tcl_Obj *, const unsigned short *, int)) uniCodePanic -#endif #undef TclBN_mp_tc_and #undef TclBN_mp_tc_or @@ -143,8 +121,6 @@ static int TclSockMinimumBuffersOld(int sock, int size) # define Tcl_NewLongObj 0 # define Tcl_DbNewLongObj 0 # define Tcl_BackgroundError 0 -# define Tcl_GetUnicode 0 - #else #define TclBNInitBignumFromLong initBignumFromLong static void TclBNInitBignumFromLong(mp_int *a, long b) @@ -280,7 +256,7 @@ TclpGetPid(Tcl_Pid pid) return (int) (size_t) pid; } -#if (TCL_UTF_MAX == 3) && !defined(TCL_NO_DEPRECATED) +#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 #undef Tcl_WinUtfToTChar char * Tcl_WinUtfToTChar( @@ -341,6 +317,10 @@ static int exprIntObj(Tcl_Interp *interp, Tcl_Obj*expr, int *ptr){ return result; } #define Tcl_ExprLongObj (int(*)(Tcl_Interp*,Tcl_Obj*,long*))exprIntObj +static int uniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned int n){ + return Tcl_UniCharNcmp(ucs, uct, (unsigned long)n); +} +#define Tcl_UniCharNcmp (int(*)(const Tcl_UniChar*,const Tcl_UniChar*,unsigned long))uniCharNcmp static int utfNcmp(const char *s1, const char *s2, unsigned int n){ return Tcl_UtfNcmp(s1, s2, (unsigned long)n); } @@ -349,25 +329,10 @@ static int utfNcasecmp(const char *s1, const char *s2, unsigned int n){ return Tcl_UtfNcasecmp(s1, s2, (unsigned long)n); } #define Tcl_UtfNcasecmp (int(*)(const char*,const char*,unsigned long))utfNcasecmp -#if TCL_UTF_MAX > 3 -static int uniCharNcmp(const int *ucs, const int *uct, unsigned int n){ - return Tcl_UniCharNcmp(ucs, uct, (unsigned long)n); -} -#define Tcl_UniCharNcmp (int(*)(const int*,const int*,unsigned long))uniCharNcmp -static int uniCharNcasecmp(const int *ucs, const int *uct, unsigned int n){ +static int uniCharNcasecmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned int n){ return Tcl_UniCharNcasecmp(ucs, uct, (unsigned long)n); } -#define Tcl_UniCharNcasecmp (int(*)(const int*,const int*,unsigned long))uniCharNcasecmp -#else -static int utf16Ncmp(const unsigned short *ucs, const unsigned short *uct, unsigned int n){ - return Tcl_UniCharNcmp(ucs, uct, (unsigned long)n); -} -#define Tcl_UniCharNcmp (int(*)(const unsigned short*,const unsigned short*,unsigned long))utf16Ncmp -static int utf16Ncasecmp(const unsigned short *ucs, const unsigned short *uct, unsigned int n){ - return Tcl_UniCharNcasecmp(ucs, uct, (unsigned long)n); -} -#define Tcl_UniCharNcasecmp (int(*)(const unsigned short*,const unsigned short*,unsigned long))utf16Ncasecmp -#endif +#define Tcl_UniCharNcasecmp (int(*)(const Tcl_UniChar*,const Tcl_UniChar*,unsigned long))uniCharNcasecmp #endif /* TCL_WIDE_INT_IS_LONG */ @@ -462,6 +427,15 @@ static int utf16Ncasecmp(const unsigned short *ucs, const unsigned short *uct, u # define Tcl_SetExitProc 0 # define Tcl_SetPanicProc 0 # define Tcl_FindExecutable 0 +# define Tcl_GetUnicodeFromObj 0 +# define Tcl_GetUnicode 0 +# define Tcl_AppendUnicodeToObj 0 +# define Tcl_NewUnicodeObj 0 +# define Tcl_SetUnicodeObj 0 +# define Tcl_UniCharNcasecmp 0 +# define Tcl_UniCharCaseMatch 0 +# define Tcl_UniCharLen 0 +# define Tcl_UniCharNcmp 0 # define TclOldFreeObj 0 # undef Tcl_StringMatch # define Tcl_StringMatch 0 @@ -498,6 +472,8 @@ static int utf16Ncasecmp(const unsigned short *ucs, const unsigned short *uct, u # define TclpLocaltime_unix TclpLocaltime # define TclpGmtime_unix TclpGmtime # define TclOldFreeObj TclFreeObj +# define Tcl_GetUnicodeFromObj TclGetUnicodeFromObj +# define Tcl_AppendUnicodeToObj TclAppendUnicodeToObj static int seekOld( @@ -516,14 +492,7 @@ tellOld( } #endif /* !TCL_NO_DEPRECATED */ -#if TCL_UTF_MAX > 3 || defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 -# define Tcl_UniCharCaseMatch 0 -# define Tcl_UniCharLen 0 -# define XTcl_UniCharNcmp 0 -# define XTcl_UniCharNcasecmp 0 -#endif - -#if (TCL_UTF_MAX > 3) || defined(TCL_NO_DEPRECATED) +#if defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 #define Tcl_WinUtfToTChar 0 #define Tcl_WinTCharToUtf 0 #endif @@ -810,6 +779,8 @@ static const TclIntStubs tclIntStubs = { TclPtrUnsetVar, /* 256 */ TclStaticPackage, /* 257 */ TclpCreateTemporaryDirectory, /* 258 */ + TclGetUnicodeFromObj, /* 259 */ + TclAppendUnicodeToObj, /* 260 */ }; static const TclIntPlatStubs tclIntPlatStubs = { @@ -1694,10 +1665,6 @@ const TclStubs tclStubs = { Tcl_UtfToUniChar, /* 646 */ Tcl_UniCharToUtfDString, /* 647 */ Tcl_UtfToUniCharDString, /* 648 */ - TclSetUnicodeObj, /* 649 */ - TclNewUnicodeObj, /* 650 */ - TclGetUnicodeFromObj, /* 651 */ - TclAppendUnicodeToObj, /* 652 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 6ffb7a4..a8b7e9f 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -1170,6 +1170,7 @@ TeststringobjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + Tcl_UniChar *unicode; int varIndex, option, i, length; #define MAX_STRINGS 11 const char *index, *string, *strings[MAX_STRINGS+1]; @@ -1178,7 +1179,7 @@ TeststringobjCmd( static const char *const options[] = { "append", "appendstrings", "get", "get2", "length", "length2", "set", "set2", "setlength", "maxchars", "getunicode", - "appendself", NULL + "appendself", "appendself2", NULL }; if (objc < 3) { @@ -1347,7 +1348,7 @@ TeststringobjCmd( if (objc != 3) { goto wrongNumArgs; } - Tcl_GetUnicode(varPtr[varIndex]); + TclGetUnicodeFromObj(varPtr[varIndex], NULL); break; case 11: /* appendself */ if (objc != 4) { @@ -1380,6 +1381,37 @@ TeststringobjCmd( Tcl_AppendToObj(varPtr[varIndex], string + i, length - i); Tcl_SetObjResult(interp, varPtr[varIndex]); break; + case 12: /* appendself2 */ + if (objc != 4) { + goto wrongNumArgs; + } + if (varPtr[varIndex] == NULL) { + SetVarToObj(varPtr, varIndex, Tcl_NewObj()); + } + + /* + * If the object bound to variable "varIndex" is shared, we must + * "copy on write" and append to a copy of the object. + */ + + if (Tcl_IsShared(varPtr[varIndex])) { + SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex])); + } + + unicode = TclGetUnicodeFromObj(varPtr[varIndex], &length); + + if (Tcl_GetIntFromObj(interp, objv[3], &i) != TCL_OK) { + return TCL_ERROR; + } + if ((i < 0) || (i > length)) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "index value out of range", -1)); + return TCL_ERROR; + } + + TclAppendUnicodeToObj(varPtr[varIndex], unicode + i, length - i); + Tcl_SetObjResult(interp, varPtr[varIndex]); + break; } return TCL_OK; diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 3f5a78d..2870c44 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -221,7 +221,7 @@ three: *--------------------------------------------------------------------------- */ -#if TCL_UTF_MAX > 3 +#undef Tcl_UniCharToUtfDString char * Tcl_UniCharToUtfDString( const int *uniStr, /* Unicode string to convert to UTF-8. */ @@ -262,7 +262,6 @@ Tcl_UniCharToUtfDString( return string; } -#endif /* TCL_UTF_MAX > 3 */ char * Tcl_Char16ToUtfDString( @@ -359,11 +358,11 @@ static const unsigned short cp1252[32] = { 0x2DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x9D, 0x017E, 0x0178 }; -#if TCL_UTF_MAX > 3 +#undef Tcl_UtfToUniChar int Tcl_UtfToUniChar( - const char *src, /* The UTF-8 string. */ - int *chPtr)/* Filled with the Unicode represented by + register const char *src, /* The UTF-8 string. */ + register int *chPtr)/* Filled with the unsigned int represented by * the UTF-8 string. */ { int byte; @@ -443,12 +442,11 @@ Tcl_UtfToUniChar( *chPtr = byte; return 1; } -#endif /* TCL_UTF_MAX > 3 */ int Tcl_UtfToChar16( const char *src, /* The UTF-8 string. */ - unsigned short *chPtr)/* Filled with the Utf-16 representation of + unsigned short *chPtr)/* Filled with the unsigned short represented by * the UTF-8 string. */ { unsigned short byte; @@ -563,7 +561,7 @@ Tcl_UtfToChar16( *--------------------------------------------------------------------------- */ -#if TCL_UTF_MAX > 3 +#undef Tcl_UtfToUniCharDString int * Tcl_UtfToUniCharDString( const char *src, /* UTF-8 string to convert to Unicode. */ @@ -599,13 +597,13 @@ Tcl_UtfToUniCharDString( p = src; end = src + length - 4; while (p < end) { - p += TclUtfToUniChar(p, &ch); + p += Tcl_UtfToUniChar(p, &ch); *w++ = ch; } end += 4; while (p < end) { if (Tcl_UtfCharComplete(p, end-p)) { - p += TclUtfToUniChar(p, &ch); + p += Tcl_UtfToUniChar(p, &ch); } else { ch = UCHAR(*p++); } @@ -617,7 +615,6 @@ Tcl_UtfToUniCharDString( return wString; } -#endif /* TCL_UTF_MAX > 3 */ unsigned short * Tcl_UtfToChar16DString( @@ -628,7 +625,8 @@ Tcl_UtfToChar16DString( * appended to this previously initialized * DString. */ { - unsigned short ch = 0, *w, *wString; + unsigned short ch = 0; + unsigned short *w, *wString; const char *p, *end; int oldLength; @@ -647,7 +645,7 @@ Tcl_UtfToChar16DString( oldLength = Tcl_DStringLength(dsPtr); Tcl_DStringSetLength(dsPtr, - oldLength + (int) ((length + 1) * sizeof(unsigned short))); + oldLength + ((length + 1) * sizeof(unsigned short))); wString = (unsigned short *) (Tcl_DStringValue(dsPtr) + oldLength); w = wString; @@ -718,11 +716,6 @@ Tcl_UtfCharComplete( *--------------------------------------------------------------------------- */ -#if TCL_UTF_MAX == 3 -# undef Tcl_UtfToUniChar -# define Tcl_UtfToUniChar Tcl_UtfToChar16 -#endif - int Tcl_NumUtfChars( register const char *src, /* The UTF-8 string to measure. */ @@ -794,7 +787,7 @@ Tcl_UtfFindFirst( while (1) { len = TclUtfToUniChar(src, &find); fullchar = find; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; @@ -842,7 +835,7 @@ Tcl_UtfFindLast( while (1) { len = TclUtfToUniChar(src, &find); fullchar = find; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &find); fullchar = (((fullchar & 0x3ff) << 10) | (find & 0x3ff)) + 0x10000; @@ -885,7 +878,7 @@ Tcl_UtfNext( Tcl_UniChar ch = 0; int len = TclUtfToUniChar(src, &ch); -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); } @@ -967,19 +960,19 @@ Tcl_UniCharAtIndex( { Tcl_UniChar ch = 0; int fullchar = 0; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 int len = 0; #endif while (index-- >= 0) { -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 src += (len = TclUtfToUniChar(src, &ch)); #else src += TclUtfToUniChar(src, &ch); #endif } fullchar = ch; -#if TCL_UTF_MAX == 3 +#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); @@ -995,7 +988,7 @@ Tcl_UniCharAtIndex( * Tcl_UtfAtIndex -- * * Returns a pointer to the specified character (not byte) position in - * the UTF-8 string. If TCL_UTF_MAX == 3, 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. * @@ -1020,7 +1013,7 @@ Tcl_UtfAtIndex( len = TclUtfToUniChar(src, &ch); src += len; } -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { /* Index points at character following high Surrogate */ src += TclUtfToUniChar(src, &ch); @@ -1117,7 +1110,7 @@ Tcl_UtfToUpper( while (*src) { len = TclUtfToUniChar(src, &ch); upChar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1179,7 +1172,7 @@ Tcl_UtfToLower( while (*src) { len = TclUtfToUniChar(src, &ch); lowChar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1244,7 +1237,7 @@ Tcl_UtfToTitle( if (*src) { len = TclUtfToUniChar(src, &ch); titleChar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1264,7 +1257,7 @@ Tcl_UtfToTitle( while (*src) { len = TclUtfToUniChar(src, &ch); lowChar = ch; -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 if ((ch >= 0xD800) && (len < 3)) { len += TclUtfToUniChar(src + len, &ch); /* Combine surrogates */ @@ -1376,7 +1369,7 @@ Tcl_UtfNcmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1427,7 +1420,7 @@ Tcl_UtfNcasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1476,7 +1469,7 @@ TclUtfCmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1522,7 +1515,7 @@ TclUtfCasecmp( cs += TclUtfToUniChar(cs, &ch1); ct += TclUtfToUniChar(ct, &ch2); if (ch1 != ch2) { -#if TCL_UTF_MAX == 3 +#if TCL_UTF_MAX <= 3 /* Surrogates always report higher than non-surrogates */ if (((ch1 & 0xFC00) == 0xD800)) { if ((ch2 & 0xFC00) != 0xD800) { @@ -1660,21 +1653,19 @@ Tcl_UniCharToTitle( *---------------------------------------------------------------------- */ -#if TCL_UTF_MAX == 3 && !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 int Tcl_UniCharLen( - const unsigned short *utf16Str) /* Unicode string to find length of. */ + const Tcl_UniChar *uniStr) /* Unicode string to find length of. */ { int len = 0; - while (*utf16Str != '\0') { + while (*uniStr != '\0') { len++; - utf16Str++; + uniStr++; } return len; } -#endif /* TCL_UTF_MAX == 3 && !defined(TCL_NO_DEPRECATED) */ - + /* *---------------------------------------------------------------------- * @@ -1703,7 +1694,7 @@ Tcl_UniCharNcmp( * We are definitely on a big-endian machine; memcmp() is safe */ - return memcmp(ucs, uct, numChars*sizeof(unsigned short)); + return memcmp(ucs, uct, numChars*sizeof(Tcl_UniChar)); #else /* !WORDS_BIGENDIAN */ /* @@ -1718,7 +1709,7 @@ Tcl_UniCharNcmp( return 0; #endif /* WORDS_BIGENDIAN */ } - + /* *---------------------------------------------------------------------- * @@ -1739,14 +1730,14 @@ Tcl_UniCharNcmp( int Tcl_UniCharNcasecmp( - const Tcl_UniChar *ucs, /* Utf16 string to compare to uct. */ - const Tcl_UniChar *uct, /* Utf16 string ucs is compared to. */ - unsigned long numChars) /* Number of Utf16 characters to compare. */ + const Tcl_UniChar *ucs, /* Unicode string to compare to uct. */ + const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */ + unsigned long numChars) /* Number of unichars to compare. */ { for ( ; numChars != 0; numChars--, ucs++, uct++) { if (*ucs != *uct) { - int lcs = Tcl_UniCharToLower(*ucs); - int lct = Tcl_UniCharToLower(*uct); + Tcl_UniChar lcs = Tcl_UniCharToLower(*ucs); + Tcl_UniChar lct = Tcl_UniCharToLower(*uct); if (lcs != lct) { return (lcs - lct); @@ -1755,7 +1746,7 @@ Tcl_UniCharNcasecmp( } return 0; } - + /* *---------------------------------------------------------------------- * @@ -2088,7 +2079,6 @@ Tcl_UniCharIsWordChar( *---------------------------------------------------------------------- */ -#if !defined(TCL_NO_DEPRECATED) && TCL_UTF_MAX == 3 && TCL_MAJOR_VERSION < 9 int Tcl_UniCharCaseMatch( const Tcl_UniChar *uniStr, /* Unicode String. */ @@ -2255,8 +2245,7 @@ Tcl_UniCharCaseMatch( uniPattern++; } } -#endif /* defined(TCL_NO_DEPRECATED) */ - + /* *---------------------------------------------------------------------- * diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 3cb271b..0dca6f1 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -4930,7 +4930,7 @@ TclZipfs_AppHook( Tcl_DString ds; Tcl_DStringInit(&ds); - archive = Tcl_Char16ToUtfDString((*argvPtr)[1], -1, &ds); + archive = Tcl_WCharToUtfDString((*argvPtr)[1], -1, &ds); #else /* !_WIN32 */ archive = (*argvPtr)[1]; #endif /* _WIN32 */ diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index a6f7361..9df6d20 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -395,7 +395,7 @@ test cmdMZ-6.5a {Tcl_TimeRateObjCmd: result format and one iteration} { test cmdMZ-6.5b {Tcl_TimeRateObjCmd: result format without iterations} { regexp {^0 \ws/# 0 # 0 #/sec 0 net-ms$} [timerate {} 0 0] } 1 -test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} { +test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} knownMsvcBug { set m1 [timerate {_nrt_sleep 0} 20] set m2 [timerate {_nrt_sleep 0.2} 20] list \ diff --git a/tests/http.test b/tests/http.test index cf30348..2184449 100644 --- a/tests/http.test +++ b/tests/http.test @@ -186,7 +186,7 @@ test http-3.7 {http::geturl} -body { <h2>GET $tail</h2> </body></html>" test http-3.8 {http::geturl} -body { - set token [http::geturl $url -query Name=Value&Foo=Bar -timeout 2000] + set token [http::geturl $url -query Name=Value&Foo=Bar -timeout 3000] http::data $token } -cleanup { http::cleanup $token @@ -352,7 +352,7 @@ test http-3.24 {http::geturl parse failures} -body { test http-3.25 {http::meta} -setup { unset -nocomplain m token } -body { - set token [http::geturl $url -timeout 2000] + set token [http::geturl $url -timeout 3000] array set m [http::meta $token] lsort [array names m] } -cleanup { @@ -362,7 +362,7 @@ test http-3.25 {http::meta} -setup { test http-3.26 {http::meta} -setup { unset -nocomplain m token } -body { - set token [http::geturl $url -headers {X-Check 1} -timeout 2000] + set token [http::geturl $url -headers {X-Check 1} -timeout 3000] array set m [http::meta $token] lsort [array names m] } -cleanup { @@ -588,7 +588,7 @@ test http-4.14 {http::Event} -body { test http-4.15 {http::Event} -body { # This test may fail if you use a proxy server. That is to be # expected and is not a problem with Tcl. - set token [http::geturl //not_a_host.tcl.tk -timeout 1000 -command \#] + set token [http::geturl //not_a_host.tcl.tk -timeout 3000 -command \#] http::wait $token http::status $token # error codes vary among platforms. diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index b8d325e..668412f 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -474,7 +474,7 @@ Tcl_WinUtfToTChar( * converted string is stored. */ { Tcl_DStringInit(dsPtr); - return Tcl_UtfToChar16DString(string, len, dsPtr); + return Tcl_UtfToWCharDString(string, len, dsPtr); } #undef Tcl_WinTCharToUtf char * @@ -486,7 +486,7 @@ Tcl_WinTCharToUtf( * converted string is stored. */ { Tcl_DStringInit(dsPtr); - return Tcl_Char16ToUtfDString((unsigned short *)string, len >> 1, dsPtr); + return Tcl_WCharToUtfDString(string, len >> 1, dsPtr); } #endif /* !defined(TCL_NO_DEPRECATED) */ diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 9361051..f8fa463 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -330,8 +330,8 @@ DoRenameFile( Tcl_DStringInit(&srcString); Tcl_DStringInit(&dstString); - src = Tcl_Char16ToUtfDString(nativeSrcPath, -1, &srcString); - dst = Tcl_Char16ToUtfDString(nativeDstPath, -1, &dstString); + src = Tcl_WCharToUtfDString(nativeSrcPath, -1, &srcString); + dst = Tcl_WCharToUtfDString(nativeDstPath, -1, &dstString); /* * Check whether the destination path is actually inside the @@ -915,8 +915,8 @@ TclpObjCopyDirectory( Tcl_DStringInit(&srcString); Tcl_DStringInit(&dstString); - Tcl_UtfToChar16DString(Tcl_GetString(normSrcPtr), -1, &srcString); - Tcl_UtfToChar16DString(Tcl_GetString(normDestPtr), -1, &dstString); + Tcl_UtfToWCharDString(Tcl_GetString(normSrcPtr), -1, &srcString); + Tcl_UtfToWCharDString(Tcl_GetString(normDestPtr), -1, &dstString); ret = TraverseWinTree(TraversalCopy, &srcString, &dstString, &ds); @@ -989,7 +989,7 @@ TclpObjRemoveDirectory( return TCL_ERROR; } Tcl_DStringInit(&native); - Tcl_UtfToChar16DString(Tcl_GetString(normPtr), -1, &native); + Tcl_UtfToWCharDString(Tcl_GetString(normPtr), -1, &native); ret = DoRemoveDirectory(&native, recursive, &ds); Tcl_DStringFree(&native); } else { @@ -1117,7 +1117,7 @@ DoRemoveJustDirectory( char *p; Tcl_DStringInit(errorPtr); - p = Tcl_Char16ToUtfDString(nativePath, -1, errorPtr); + p = Tcl_WCharToUtfDString(nativePath, -1, errorPtr); for (; *p; ++p) { if (*p == '\\') *p = '/'; } @@ -1332,7 +1332,7 @@ TraverseWinTree( TclWinConvertError(GetLastError()); if (errorPtr != NULL) { Tcl_DStringInit(errorPtr); - Tcl_Char16ToUtfDString(nativeErrfile, -1, errorPtr); + Tcl_WCharToUtfDString(nativeErrfile, -1, errorPtr); } result = TCL_ERROR; } @@ -1398,7 +1398,7 @@ TraversalCopy( if (errorPtr != NULL) { Tcl_DStringInit(errorPtr); - Tcl_Char16ToUtfDString(nativeDst, -1, errorPtr); + Tcl_WCharToUtfDString(nativeDst, -1, errorPtr); } return TCL_ERROR; } @@ -1454,7 +1454,7 @@ TraversalDelete( if (errorPtr != NULL) { Tcl_DStringInit(errorPtr); - Tcl_Char16ToUtfDString(nativeSrc, -1, errorPtr); + Tcl_WCharToUtfDString(nativeSrc, -1, errorPtr); } return TCL_ERROR; } @@ -1663,7 +1663,7 @@ ConvertFileNameFormat( tempString = TclGetStringFromObj(tempPath, &length); Tcl_DStringInit(&ds); - nativeName = Tcl_UtfToChar16DString(tempString, length, &ds); + nativeName = Tcl_UtfToWCharDString(tempString, length, &ds); Tcl_DecrRefCount(tempPath); handle = FindFirstFile(nativeName, &data); if (handle == INVALID_HANDLE_VALUE) { @@ -1700,7 +1700,7 @@ ConvertFileNameFormat( } /* - * Purify reports a extraneous UMR in Tcl_Char16ToUtfDString() trying + * Purify reports a extraneous UMR in Tcl_WCharToUtfDString() trying * to dereference nativeName as a Unicode string. I have proven to * myself that purify is wrong by running the following example * when nativeName == data.w.cAlternateFileName and noting that @@ -1712,7 +1712,7 @@ ConvertFileNameFormat( */ Tcl_DStringInit(&dsTemp); - Tcl_Char16ToUtfDString(nativeName, -1, &dsTemp); + Tcl_WCharToUtfDString(nativeName, -1, &dsTemp); Tcl_DStringFree(&ds); /* @@ -2008,9 +2008,9 @@ TclpCreateTemporaryDirectory( goto useSystemTemp; } Tcl_DStringInit(&base); - Tcl_UtfToChar16DString(Tcl_GetString(dirObj), -1, &base); + Tcl_UtfToWCharDString(Tcl_GetString(dirObj), -1, &base); if (dirObj->bytes[dirObj->length - 1] != '\\') { - Tcl_UtfToChar16DString("\\", -1, &base); + Tcl_UtfToWCharDString("\\", -1, &base); } } else { useSystemTemp: @@ -2026,11 +2026,11 @@ TclpCreateTemporaryDirectory( #define SUFFIX_LENGTH 8 if (basenameObj) { - Tcl_UtfToChar16DString(Tcl_GetString(basenameObj), -1, &base); + Tcl_UtfToWCharDString(Tcl_GetString(basenameObj), -1, &base); } else { - Tcl_UtfToChar16DString(DEFAULT_TEMP_DIR_PREFIX, -1, &base); + Tcl_UtfToWCharDString(DEFAULT_TEMP_DIR_PREFIX, -1, &base); } - Tcl_UtfToChar16DString("_", -1, &base); + Tcl_UtfToWCharDString("_", -1, &base); /* * Now we keep on trying random suffixes until we get one that works @@ -2057,7 +2057,7 @@ TclpCreateTemporaryDirectory( tempbuf[i] = randChars[(int) (rand() % numRandChars)]; } Tcl_DStringSetLength(&base, baseLen); - Tcl_UtfToChar16DString(tempbuf, -1, &base); + Tcl_UtfToWCharDString(tempbuf, -1, &base); } while (!CreateDirectoryW((LPCWSTR) Tcl_DStringValue(&base), NULL) && (error = GetLastError()) == ERROR_ALREADY_EXISTS); @@ -2078,7 +2078,7 @@ TclpCreateTemporaryDirectory( */ Tcl_DStringInit(&name); - Tcl_Char16ToUtfDString((LPCWSTR) Tcl_DStringValue(&base), -1, &name); + Tcl_WCharToUtfDString((LPCWSTR) Tcl_DStringValue(&base), -1, &name); Tcl_DStringFree(&base); return TclDStringToObj(&name); } diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 9320c3a..f3c45ef 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -635,7 +635,7 @@ WinReadLinkDirectory( } Tcl_DStringInit(&ds); - Tcl_Char16ToUtfDString( + Tcl_WCharToUtfDString( reparseBuffer->MountPointReparseBuffer.PathBuffer, reparseBuffer->MountPointReparseBuffer .SubstituteNameLength>>1, &ds); @@ -1025,7 +1025,7 @@ TclpMatchInDirectory( } Tcl_DStringInit(&ds); - native = Tcl_UtfToChar16DString(dirName, -1, &ds); + native = Tcl_UtfToWCharDString(dirName, -1, &ds); if ((types == NULL) || (types->type != TCL_GLOB_TYPE_DIR)) { handle = FindFirstFile(native, &data); } else { @@ -1099,7 +1099,7 @@ TclpMatchInDirectory( native = data.cFileName; attr = data.dwFileAttributes; Tcl_DStringInit(&ds); - utfname = Tcl_Char16ToUtfDString(native, -1, &ds); + utfname = Tcl_WCharToUtfDString(native, -1, &ds); if (!matchSpecialDots) { /* @@ -1474,14 +1474,14 @@ TclpGetUserHome( Tcl_DStringFree(&ds); } else { Tcl_DStringInit(&ds); - wName = Tcl_UtfToChar16DString(domain + 1, -1, &ds); + wName = Tcl_UtfToWCharDString(domain + 1, -1, &ds); rc = NetGetDCName(NULL, wName, (LPBYTE *) &wDomain); Tcl_DStringFree(&ds); nameLen = domain - name; } if (rc == 0) { Tcl_DStringInit(&ds); - wName = Tcl_UtfToChar16DString(name, nameLen, &ds); + wName = Tcl_UtfToWCharDString(name, nameLen, &ds); while (NetUserGetInfo(wDomain, wName, 1, (LPBYTE *) &uiPtr) != 0) { /* * User does not exist; if domain was not specified, try again @@ -1509,7 +1509,7 @@ TclpGetUserHome( wHomeDir = uiPtr->usri1_home_dir; if ((wHomeDir != NULL) && (wHomeDir[0] != '\0')) { size = lstrlenW(wHomeDir); - Tcl_Char16ToUtfDString(wHomeDir, size, bufferPtr); + Tcl_WCharToUtfDString(wHomeDir, size, bufferPtr); } else { /* * User exists but has no home dir. Return @@ -1517,7 +1517,7 @@ TclpGetUserHome( */ GetProfilesDirectoryW(buf, &size); - Tcl_Char16ToUtfDString(buf, size-1, bufferPtr); + Tcl_WCharToUtfDString(buf, size-1, bufferPtr); Tcl_DStringAppend(bufferPtr, "/", 1); Tcl_DStringAppend(bufferPtr, name, nameLen); } @@ -1986,7 +1986,7 @@ TclpGetCwd( native += 2; } Tcl_DStringInit(bufferPtr); - Tcl_Char16ToUtfDString(native, -1, bufferPtr); + Tcl_WCharToUtfDString(native, -1, bufferPtr); /* * Convert to forward slashes for easier use in scripts. @@ -2195,7 +2195,7 @@ NativeDev( GetFullPathName(nativePath, MAX_PATH, nativeFullPath, &nativePart); Tcl_DStringInit(&ds); - fullPath = Tcl_Char16ToUtfDString(nativeFullPath, -1, &ds); + fullPath = Tcl_WCharToUtfDString(nativeFullPath, -1, &ds); if ((fullPath[0] == '\\') && (fullPath[1] == '\\')) { const char *p; @@ -2217,7 +2217,7 @@ NativeDev( p++; } Tcl_DStringInit(&volString); - nativeVol = Tcl_UtfToChar16DString(fullPath, p - fullPath, &volString); + nativeVol = Tcl_UtfToWCharDString(fullPath, p - fullPath, &volString); dw = (DWORD) -1; GetVolumeInformation(nativeVol, NULL, 0, &dw, NULL, NULL, NULL, 0); @@ -2498,7 +2498,7 @@ TclpFilesystemPathType( Tcl_DString ds; Tcl_DStringInit(&ds); - Tcl_Char16ToUtfDString(volType, -1, &ds); + Tcl_WCharToUtfDString(volType, -1, &ds); return TclDStringToObj(&ds); } #undef VOL_BUF_SIZE @@ -2571,7 +2571,7 @@ TclpObjNormalizePath( const WCHAR *nativePath; Tcl_DStringInit(&ds); - nativePath = Tcl_UtfToChar16DString(path, + nativePath = Tcl_UtfToWCharDString(path, currentPathEndPosition - path, &ds); if (GetFileAttributesEx(nativePath, @@ -2778,7 +2778,7 @@ TclpObjNormalizePath( Tcl_DStringInit(&ds); nativePath = - Tcl_UtfToChar16DString(path, lastValidPathEnd - path, &ds); + Tcl_UtfToWCharDString(path, lastValidPathEnd - path, &ds); wpathlen = GetLongPathNameProc(nativePath, (WCHAR *) wpath, MAX_PATH); /* @@ -2808,7 +2808,7 @@ TclpObjNormalizePath( */ Tcl_DStringInit(&ds); - Tcl_Char16ToUtfDString((const WCHAR *) Tcl_DStringValue(&dsNorm), + Tcl_WCharToUtfDString((const WCHAR *) Tcl_DStringValue(&dsNorm), Tcl_DStringLength(&dsNorm)>>1, &ds); nextCheckpoint = Tcl_DStringLength(&ds); if (*lastValidPathEnd != 0) { @@ -2985,7 +2985,7 @@ TclpNativeToNormalized( char *copy, *p; Tcl_DStringInit(&ds); - Tcl_Char16ToUtfDString((const WCHAR *) clientData, -1, &ds); + Tcl_WCharToUtfDString((const WCHAR *) clientData, -1, &ds); copy = Tcl_DStringValue(&ds); len = Tcl_DStringLength(&ds); diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 1bd962d..29ace66 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -477,7 +477,7 @@ TclpGetUserName( } cchUserNameLen--; Tcl_DStringInit(bufferPtr); - Tcl_Char16ToUtfDString(szUserName, cchUserNameLen, bufferPtr); + Tcl_WCharToUtfDString(szUserName, cchUserNameLen, bufferPtr); } return Tcl_DStringValue(bufferPtr); } diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c index 011ebd7..ae68956 100644 --- a/win/tclWinLoad.c +++ b/win/tclWinLoad.c @@ -96,7 +96,7 @@ TclpDlopen( ERROR_MOD_NOT_FOUND : GetLastError(); Tcl_DStringInit(&ds); - nativeName = Tcl_UtfToChar16DString(Tcl_GetString(pathPtr), -1, &ds); + nativeName = Tcl_UtfToWCharDString(Tcl_GetString(pathPtr), -1, &ds); hInstance = LoadLibraryEx(nativeName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); Tcl_DStringFree(&ds); diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index fafdf49..902e01c 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -578,7 +578,7 @@ TclpOpenFile( } Tcl_DStringInit(&ds); - nativePath = Tcl_UtfToChar16DString(path, -1, &ds); + nativePath = Tcl_UtfToWCharDString(path, -1, &ds); /* * If the file is not being created, use the existing file attributes. @@ -1292,7 +1292,7 @@ ApplicationType( Tcl_DStringSetLength(&nameBuf, nameLen); Tcl_DStringAppend(&nameBuf, extensions[i], -1); Tcl_DStringInit(&ds); - nativeName = Tcl_UtfToChar16DString(Tcl_DStringValue(&nameBuf), + nativeName = Tcl_UtfToWCharDString(Tcl_DStringValue(&nameBuf), Tcl_DStringLength(&nameBuf), &ds); found = SearchPath(NULL, nativeName, NULL, MAX_PATH, nativeFullPath, &rest); @@ -1311,7 +1311,7 @@ ApplicationType( continue; } Tcl_DStringInit(&ds); - strcpy(fullName, Tcl_Char16ToUtfDString(nativeFullPath, -1, &ds)); + strcpy(fullName, Tcl_WCharToUtfDString(nativeFullPath, -1, &ds)); Tcl_DStringFree(&ds); ext = strrchr(fullName, '.'); @@ -1403,7 +1403,7 @@ ApplicationType( GetShortPathName(nativeFullPath, nativeFullPath, MAX_PATH); Tcl_DStringInit(&ds); - strcpy(fullName, Tcl_Char16ToUtfDString(nativeFullPath, -1, &ds)); + strcpy(fullName, Tcl_WCharToUtfDString(nativeFullPath, -1, &ds)); Tcl_DStringFree(&ds); } return applType; @@ -1732,7 +1732,7 @@ BuildCommandLine( } Tcl_DStringFree(linePtr); Tcl_DStringInit(linePtr); - Tcl_UtfToChar16DString(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); + Tcl_UtfToWCharDString(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), linePtr); Tcl_DStringFree(&ds); } @@ -3215,7 +3215,7 @@ TclpOpenTemporaryFile( const char *string = TclGetStringFromObj(basenameObj, &length); Tcl_DStringInit(&buf); - Tcl_UtfToChar16DString(string, length, &buf); + Tcl_UtfToWCharDString(string, length, &buf); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)); namePtr += Tcl_DStringLength(&buf); Tcl_DStringFree(&buf); @@ -3236,7 +3236,7 @@ TclpOpenTemporaryFile( sprintf(number, "%d.TMP", counter); counter = (unsigned short) (counter + 1); Tcl_DStringInit(&buf); - Tcl_UtfToChar16DString(number, strlen(number), &buf); + Tcl_UtfToWCharDString(number, strlen(number), &buf); Tcl_DStringSetLength(&buf, Tcl_DStringLength(&buf) + 1); memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf) + 1); Tcl_DStringFree(&buf); diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 3de91be..4411e89 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1670,7 +1670,7 @@ SerialSetOptionProc( goto getStateFailed; } Tcl_DStringInit(&ds); - native = Tcl_UtfToChar16DString(value, -1, &ds); + native = Tcl_UtfToWCharDString(value, -1, &ds); result = BuildCommDCB(native, &dcb); Tcl_DStringFree(&ds); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 88953c0..e483eb4 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -373,7 +373,7 @@ InitializeHostName( * Convert string from native to UTF then change to lowercase. */ - Tcl_UtfToLower(Tcl_Char16ToUtfDString(tbuf, -1, &ds)); + Tcl_UtfToLower(Tcl_WCharToUtfDString(tbuf, -1, &ds)); } else { if (TclpHasSockets(NULL) == TCL_OK) { |