summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls74
-rw-r--r--generic/tclDecls.h152
-rw-r--r--generic/tclInt.h11
-rw-r--r--generic/tclStringObj.c2
-rw-r--r--generic/tclStubInit.c44
-rw-r--r--generic/tclUtf.c362
-rw-r--r--generic/tclUtil.c2
7 files changed, 460 insertions, 187 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 6187cfc..2c21b91 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_UtfToUtf16(const char *src, unsigned short *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_Utf16Len(const unsigned short *uniStr)
+}
+declare 353 {
+ int Tcl_Utf16Ncmp(const unsigned short *ucs, const unsigned short *uct,
+ unsigned long numChars)
+}
+declare 354 {
+ char *Tcl_Utf16ToUtfDString(const unsigned short *uniStr,
+ int uniLength, Tcl_DString *dsPtr)
+}
+declare 355 {
+ unsigned short *Tcl_UtfToUtf16DString(const char *src,
+ int length, Tcl_DString *dsPtr)
+}
declare 356 {
Tcl_RegExp Tcl_GetRegExpFromObj(Tcl_Interp *interp, Tcl_Obj *patObj,
int flags)
@@ -1342,7 +1342,7 @@ declare 378 {
Tcl_Obj *Tcl_NewUtf16Obj(const unsigned short *unicode, int numChars)
}
declare 379 {
- void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode,
+ void Tcl_SetUtf16Obj(Tcl_Obj *objPtr, const unsigned short *unicode,
int numChars)
}
declare 380 {
@@ -1358,7 +1358,7 @@ declare 383 {
Tcl_Obj *Tcl_GetRange(Tcl_Obj *objPtr, int first, int last)
}
declare 384 {
- void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode,
+ void Tcl_AppendUtf16ToObj(Tcl_Obj *objPtr, const unsigned short *unicode,
int length)
}
declare 385 {
@@ -1484,12 +1484,12 @@ declare 418 {
int Tcl_IsChannelExisting(const char *channelName)
}
declare 419 {
- int Tcl_UniCharNcasecmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct,
+ int Tcl_Utf16Ncasecmp(const unsigned short *ucs, const unsigned short *uct,
unsigned long numChars)
}
declare 420 {
- int Tcl_UniCharCaseMatch(const Tcl_UniChar *uniStr,
- const Tcl_UniChar *uniPattern, int nocase)
+ int Tcl_Utf16CaseMatch(const unsigned short *uniStr,
+ const unsigned short *uniPattern, int nocase)
}
declare 421 {
Tcl_HashEntry *Tcl_FindHashEntry(Tcl_HashTable *tablePtr, const void *key)
@@ -2387,23 +2387,39 @@ declare 645 {
Tcl_Obj *Tcl_NewUnicodeObj(const int *unicode, int numChars)
}
declare 646 {
- int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr)
+ int Tcl_UtfToUniChar(const char *src, int *chPtr)
}
declare 647 {
- int Tcl_UniCharLen(const Tcl_UniChar *uniStr)
+ int Tcl_UniCharLen(const int *uniStr)
}
declare 648 {
- int Tcl_UniCharNcmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct,
+ int Tcl_UniCharNcmp(const int *ucs, const int *uct,
unsigned long numChars)
}
declare 649 {
- char *Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr,
- int uniLength, Tcl_DString *dsPtr)
+ int Tcl_UniCharNcasecmp(const int *ucs, const int *uct,
+ unsigned long numChars)
}
declare 650 {
- Tcl_UniChar *Tcl_UtfToUniCharDString(const char *src,
+ char *Tcl_UniCharToUtfDString(const int *uniStr,
+ int uniLength, Tcl_DString *dsPtr)
+}
+declare 651 {
+ int *Tcl_UtfToUniCharDString(const char *src,
int length, Tcl_DString *dsPtr)
}
+declare 652 {
+ int Tcl_UniCharCaseMatch(const int *uniStr,
+ const int *uniPattern, int nocase)
+}
+declare 653 {
+ void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, const int *unicode,
+ int length)
+}
+declare 654 {
+ void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, const int *unicode,
+ int numChars)
+}
# ----- BASELINE -- FOR -- 8.7.0 ----- #
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index b9f710f..f0d0b4c 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1025,7 +1025,9 @@ EXTERN char * Tcl_UtfToExternalDString(Tcl_Encoding encoding,
EXTERN int Tcl_UtfToLower(char *src);
/* 335 */
EXTERN int Tcl_UtfToTitle(char *src);
-/* Slot 336 is reserved */
+/* 336 */
+EXTERN int Tcl_UtfToUtf16(const char *src,
+ unsigned short *chPtr);
/* 337 */
EXTERN int Tcl_UtfToUpper(char *src);
/* 338 */
@@ -1059,10 +1061,18 @@ EXTERN int Tcl_UniCharIsSpace(int ch);
EXTERN int Tcl_UniCharIsUpper(int ch);
/* 351 */
EXTERN int Tcl_UniCharIsWordChar(int ch);
-/* Slot 352 is reserved */
-/* Slot 353 is reserved */
-/* Slot 354 is reserved */
-/* Slot 355 is reserved */
+/* 352 */
+EXTERN int Tcl_Utf16Len(const unsigned short *uniStr);
+/* 353 */
+EXTERN int Tcl_Utf16Ncmp(const unsigned short *ucs,
+ const unsigned short *uct,
+ unsigned long numChars);
+/* 354 */
+EXTERN char * Tcl_Utf16ToUtfDString(const unsigned short *uniStr,
+ int uniLength, Tcl_DString *dsPtr);
+/* 355 */
+EXTERN unsigned short * Tcl_UtfToUtf16DString(const char *src, int length,
+ Tcl_DString *dsPtr);
/* 356 */
EXTERN Tcl_RegExp Tcl_GetRegExpFromObj(Tcl_Interp *interp,
Tcl_Obj *patObj, int flags);
@@ -1133,8 +1143,8 @@ EXTERN void Tcl_RegExpGetInfo(Tcl_RegExp regexp,
EXTERN Tcl_Obj * Tcl_NewUtf16Obj(const unsigned short *unicode,
int numChars);
/* 379 */
-EXTERN void Tcl_SetUnicodeObj(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int numChars);
+EXTERN void Tcl_SetUtf16Obj(Tcl_Obj *objPtr,
+ const unsigned short *unicode, int numChars);
/* 380 */
EXTERN int Tcl_GetCharLength(Tcl_Obj *objPtr);
/* 381 */
@@ -1145,8 +1155,8 @@ unsigned short * 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 Tcl_UniChar *unicode, int length);
+EXTERN void Tcl_AppendUtf16ToObj(Tcl_Obj *objPtr,
+ const unsigned short *unicode, int length);
/* 385 */
EXTERN int Tcl_RegExpMatchObj(Tcl_Interp *interp,
Tcl_Obj *textObj, Tcl_Obj *patternObj);
@@ -1239,12 +1249,12 @@ EXTERN void Tcl_ClearChannelHandlers(Tcl_Channel channel);
/* 418 */
EXTERN int Tcl_IsChannelExisting(const char *channelName);
/* 419 */
-EXTERN int Tcl_UniCharNcasecmp(const Tcl_UniChar *ucs,
- const Tcl_UniChar *uct,
+EXTERN int Tcl_Utf16Ncasecmp(const unsigned short *ucs,
+ const unsigned short *uct,
unsigned long numChars);
/* 420 */
-EXTERN int Tcl_UniCharCaseMatch(const Tcl_UniChar *uniStr,
- const Tcl_UniChar *uniPattern, int nocase);
+EXTERN int Tcl_Utf16CaseMatch(const unsigned short *uniStr,
+ const unsigned short *uniPattern, int nocase);
/* 421 */
EXTERN Tcl_HashEntry * Tcl_FindHashEntry(Tcl_HashTable *tablePtr,
const void *key);
@@ -1892,19 +1902,30 @@ EXTERN int * Tcl_GetUnicodeFromObj(Tcl_Obj *objPtr,
/* 645 */
EXTERN Tcl_Obj * Tcl_NewUnicodeObj(const int *unicode, int numChars);
/* 646 */
-EXTERN int Tcl_UtfToUniChar(const char *src, Tcl_UniChar *chPtr);
+EXTERN int Tcl_UtfToUniChar(const char *src, int *chPtr);
/* 647 */
-EXTERN int Tcl_UniCharLen(const Tcl_UniChar *uniStr);
+EXTERN int Tcl_UniCharLen(const int *uniStr);
/* 648 */
-EXTERN int Tcl_UniCharNcmp(const Tcl_UniChar *ucs,
- const Tcl_UniChar *uct,
+EXTERN int Tcl_UniCharNcmp(const int *ucs, const int *uct,
unsigned long numChars);
/* 649 */
-EXTERN char * Tcl_UniCharToUtfDString(const Tcl_UniChar *uniStr,
- int uniLength, Tcl_DString *dsPtr);
+EXTERN int Tcl_UniCharNcasecmp(const int *ucs, const int *uct,
+ unsigned long numChars);
/* 650 */
-EXTERN Tcl_UniChar * Tcl_UtfToUniCharDString(const char *src, int length,
+EXTERN char * Tcl_UniCharToUtfDString(const int *uniStr,
+ int uniLength, Tcl_DString *dsPtr);
+/* 651 */
+EXTERN int * Tcl_UtfToUniCharDString(const char *src, int length,
Tcl_DString *dsPtr);
+/* 652 */
+EXTERN int Tcl_UniCharCaseMatch(const int *uniStr,
+ const int *uniPattern, int nocase);
+/* 653 */
+EXTERN void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr,
+ const int *unicode, int length);
+/* 654 */
+EXTERN void Tcl_SetUnicodeObj(Tcl_Obj *objPtr,
+ const int *unicode, int numChars);
typedef struct {
const struct TclPlatStubs *tclPlatStubs;
@@ -2276,7 +2297,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 */
- void (*reserved336)(void);
+ int (*tcl_UtfToUtf16) (const char *src, unsigned short *chPtr); /* 336 */
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 */
@@ -2292,10 +2313,10 @@ typedef struct TclStubs {
int (*tcl_UniCharIsSpace) (int ch); /* 349 */
int (*tcl_UniCharIsUpper) (int ch); /* 350 */
int (*tcl_UniCharIsWordChar) (int ch); /* 351 */
- void (*reserved352)(void);
- void (*reserved353)(void);
- void (*reserved354)(void);
- void (*reserved355)(void);
+ int (*tcl_Utf16Len) (const unsigned short *uniStr); /* 352 */
+ int (*tcl_Utf16Ncmp) (const unsigned short *ucs, const unsigned short *uct, unsigned long numChars); /* 353 */
+ char * (*tcl_Utf16ToUtfDString) (const unsigned short *uniStr, int uniLength, Tcl_DString *dsPtr); /* 354 */
+ unsigned short * (*tcl_UtfToUtf16DString) (const char *src, int length, Tcl_DString *dsPtr); /* 355 */
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 */
@@ -2319,12 +2340,12 @@ typedef struct TclStubs {
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_NewUtf16Obj) (const unsigned short *unicode, int numChars); /* 378 */
- void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars); /* 379 */
+ void (*tcl_SetUtf16Obj) (Tcl_Obj *objPtr, const unsigned short *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_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */
- void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */
+ void (*tcl_AppendUtf16ToObj) (Tcl_Obj *objPtr, const unsigned short *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 */
@@ -2359,8 +2380,8 @@ typedef struct TclStubs {
void (*tcl_SpliceChannel) (Tcl_Channel channel); /* 416 */
void (*tcl_ClearChannelHandlers) (Tcl_Channel channel); /* 417 */
int (*tcl_IsChannelExisting) (const char *channelName); /* 418 */
- int (*tcl_UniCharNcasecmp) (const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsigned long numChars); /* 419 */
- int (*tcl_UniCharCaseMatch) (const Tcl_UniChar *uniStr, const Tcl_UniChar *uniPattern, int nocase); /* 420 */
+ int (*tcl_Utf16Ncasecmp) (const unsigned short *ucs, const unsigned short *uct, unsigned long numChars); /* 419 */
+ int (*tcl_Utf16CaseMatch) (const unsigned short *uniStr, const unsigned short *uniPattern, int nocase); /* 420 */
Tcl_HashEntry * (*tcl_FindHashEntry) (Tcl_HashTable *tablePtr, const void *key); /* 421 */
Tcl_HashEntry * (*tcl_CreateHashEntry) (Tcl_HashTable *tablePtr, const void *key, int *newPtr); /* 422 */
void (*tcl_InitCustomHashTable) (Tcl_HashTable *tablePtr, int keyType, const Tcl_HashKeyType *typePtr); /* 423 */
@@ -2586,11 +2607,15 @@ 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 */
+ int (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */
+ int (*tcl_UniCharLen) (const int *uniStr); /* 647 */
+ int (*tcl_UniCharNcmp) (const int *ucs, const int *uct, unsigned long numChars); /* 648 */
+ int (*tcl_UniCharNcasecmp) (const int *ucs, const int *uct, unsigned long numChars); /* 649 */
+ char * (*tcl_UniCharToUtfDString) (const int *uniStr, int uniLength, Tcl_DString *dsPtr); /* 650 */
+ int * (*tcl_UtfToUniCharDString) (const char *src, int length, Tcl_DString *dsPtr); /* 651 */
+ int (*tcl_UniCharCaseMatch) (const int *uniStr, const int *uniPattern, int nocase); /* 652 */
+ void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const int *unicode, int length); /* 653 */
+ void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const int *unicode, int numChars); /* 654 */
} TclStubs;
extern const TclStubs *tclStubsPtr;
@@ -3293,7 +3318,8 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_UtfToLower) /* 334 */
#define Tcl_UtfToTitle \
(tclStubsPtr->tcl_UtfToTitle) /* 335 */
-/* Slot 336 is reserved */
+#define Tcl_UtfToUtf16 \
+ (tclStubsPtr->tcl_UtfToUtf16) /* 336 */
#define Tcl_UtfToUpper \
(tclStubsPtr->tcl_UtfToUpper) /* 337 */
#define Tcl_WriteChars \
@@ -3324,10 +3350,14 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_UniCharIsUpper) /* 350 */
#define Tcl_UniCharIsWordChar \
(tclStubsPtr->tcl_UniCharIsWordChar) /* 351 */
-/* Slot 352 is reserved */
-/* Slot 353 is reserved */
-/* Slot 354 is reserved */
-/* Slot 355 is reserved */
+#define Tcl_Utf16Len \
+ (tclStubsPtr->tcl_Utf16Len) /* 352 */
+#define Tcl_Utf16Ncmp \
+ (tclStubsPtr->tcl_Utf16Ncmp) /* 353 */
+#define Tcl_Utf16ToUtfDString \
+ (tclStubsPtr->tcl_Utf16ToUtfDString) /* 354 */
+#define Tcl_UtfToUtf16DString \
+ (tclStubsPtr->tcl_UtfToUtf16DString) /* 355 */
#define Tcl_GetRegExpFromObj \
(tclStubsPtr->tcl_GetRegExpFromObj) /* 356 */
#define Tcl_EvalTokens \
@@ -3374,8 +3404,8 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_RegExpGetInfo) /* 377 */
#define Tcl_NewUtf16Obj \
(tclStubsPtr->tcl_NewUtf16Obj) /* 378 */
-#define Tcl_SetUnicodeObj \
- (tclStubsPtr->tcl_SetUnicodeObj) /* 379 */
+#define Tcl_SetUtf16Obj \
+ (tclStubsPtr->tcl_SetUtf16Obj) /* 379 */
#define Tcl_GetCharLength \
(tclStubsPtr->tcl_GetCharLength) /* 380 */
#define Tcl_GetUniChar \
@@ -3384,8 +3414,8 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_GetUnicode) /* 382 */
#define Tcl_GetRange \
(tclStubsPtr->tcl_GetRange) /* 383 */
-#define Tcl_AppendUnicodeToObj \
- (tclStubsPtr->tcl_AppendUnicodeToObj) /* 384 */
+#define Tcl_AppendUtf16ToObj \
+ (tclStubsPtr->tcl_AppendUtf16ToObj) /* 384 */
#define Tcl_RegExpMatchObj \
(tclStubsPtr->tcl_RegExpMatchObj) /* 385 */
#define Tcl_SetNotifier \
@@ -3454,10 +3484,10 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_ClearChannelHandlers) /* 417 */
#define Tcl_IsChannelExisting \
(tclStubsPtr->tcl_IsChannelExisting) /* 418 */
-#define Tcl_UniCharNcasecmp \
- (tclStubsPtr->tcl_UniCharNcasecmp) /* 419 */
-#define Tcl_UniCharCaseMatch \
- (tclStubsPtr->tcl_UniCharCaseMatch) /* 420 */
+#define Tcl_Utf16Ncasecmp \
+ (tclStubsPtr->tcl_Utf16Ncasecmp) /* 419 */
+#define Tcl_Utf16CaseMatch \
+ (tclStubsPtr->tcl_Utf16CaseMatch) /* 420 */
#define Tcl_FindHashEntry \
(tclStubsPtr->tcl_FindHashEntry) /* 421 */
#define Tcl_CreateHashEntry \
@@ -3914,10 +3944,18 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_UniCharLen) /* 647 */
#define Tcl_UniCharNcmp \
(tclStubsPtr->tcl_UniCharNcmp) /* 648 */
+#define Tcl_UniCharNcasecmp \
+ (tclStubsPtr->tcl_UniCharNcasecmp) /* 649 */
#define Tcl_UniCharToUtfDString \
- (tclStubsPtr->tcl_UniCharToUtfDString) /* 649 */
+ (tclStubsPtr->tcl_UniCharToUtfDString) /* 650 */
#define Tcl_UtfToUniCharDString \
- (tclStubsPtr->tcl_UtfToUniCharDString) /* 650 */
+ (tclStubsPtr->tcl_UtfToUniCharDString) /* 651 */
+#define Tcl_UniCharCaseMatch \
+ (tclStubsPtr->tcl_UniCharCaseMatch) /* 652 */
+#define Tcl_AppendUnicodeToObj \
+ (tclStubsPtr->tcl_AppendUnicodeToObj) /* 653 */
+#define Tcl_SetUnicodeObj \
+ (tclStubsPtr->tcl_SetUnicodeObj) /* 654 */
#endif /* defined(USE_TCL_STUBS) */
@@ -4104,6 +4142,22 @@ extern const TclStubs *tclStubsPtr;
# define Tcl_GetUnicodeFromObj Tcl_GetUtf16FromObj
# undef Tcl_NewUnicodeObj
# define Tcl_NewUnicodeObj Tcl_NewUtf16Obj
+# undef Tcl_SetUnicodeObj
+# define Tcl_SetUnicodeObj Tcl_SetUtf16Obj
+# undef Tcl_AppendUnicodeToObj
+# define Tcl_AppendUnicodeToObj Tcl_AppendUtf16ToObj
+# undef Tcl_UniCharToUtfDString
+# define Tcl_UniCharToUtfDString Tcl_Utf16ToUtfDString
+# undef Tcl_UtfToUniCharDString
+# define Tcl_UtfToUniCharDString Tcl_UtfToUtf16DString
+# undef Tcl_UtfToUniChar
+# define Tcl_UtfToUniChar Tcl_UtfToUtf16
+# undef Tcl_UniCharNcmp
+# define Tcl_UniCharNcmp Tcl_Utf16Ncmp
+# undef Tcl_UniCharNcasecmp
+# define Tcl_UniCharNcasecmp Tcl_Utf16Ncasecmp
+# undef Tcl_UniCharCaseMatch
+# define Tcl_UniCharCaseMatch Tcl_Utf16CaseMatch
#endif
/*
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 99a2a58..37f4795 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3240,17 +3240,6 @@ MODULE_SCOPE const char*TclGetCommandTypeName(Tcl_Command command);
MODULE_SCOPE void TclRegisterCommandTypeName(
Tcl_ObjCmdProc *implementationProc,
const char *nameStr);
-#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);
-MODULE_SCOPE unsigned short * Tcl_UtfToUtf16DString(const char *src,
- int length, Tcl_DString *dsPtr);
-#else
-# define TclUtfToUtf16 TclUtfToUniChar
-# define Tcl_Utf16ToUtfDString Tcl_UniCharToUtfDString
-# define Tcl_UtfToUtf16DString Tcl_UtfToUniCharDString
-#endif
MODULE_SCOPE int TclUtfCmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
MODULE_SCOPE int TclUtfCount(int ch);
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 205db00..46bd26f 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -613,7 +613,7 @@ Tcl_GetUnicode(
Tcl_Obj *objPtr) /* The object to find the unicode string
* for. */
{
- return Tcl_GetUtf16FromObj(objPtr, NULL);
+ return Tcl_GetUnicodeFromObj(objPtr, NULL);
}
#endif /* TCL_NO_DEPRECATED */
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index b85c360..ca26e8d 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -62,6 +62,14 @@
#define TclStaticPackage Tcl_StaticPackage
#undef Tcl_GetUnicodeFromObj
#undef Tcl_NewUnicodeObj
+#undef Tcl_SetUnicodeObj
+#undef Tcl_UniCharToUtfDString
+#undef Tcl_UtfToUniCharDString
+#undef Tcl_UtfToUniChar
+#undef Tcl_UniCharNcmp
+#undef Tcl_UniCharNcasecmp
+#undef Tcl_UniCharCaseMatch
+#undef Tcl_AppendUnicodeToObj
static void uniCodePanic() {
#if TCL_UTF_MAX == 3
@@ -70,13 +78,21 @@ static void uniCodePanic() {
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 == 3
+#ifdef TCL_NO_DEPRECATED
+# define Tcl_GetUnicode 0
+#endif
# define Tcl_GetUnicodeFromObj (int *(*)(Tcl_Obj *, int *)) uniCodePanic
# define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const int *, int)) uniCodePanic
+# define Tcl_SetUnicodeObj (void(*)(Tcl_Obj *,const int *, int)) uniCodePanic
+# define Tcl_AppendUnicodeToObj (void(*)(Tcl_Obj *, const int *, int)) uniCodePanic
#else
-# define Tcl_GetUtf16FromObj (unsigned short *(*)(Tcl_Obj *, int *)) uniCodePanic
# define Tcl_GetUnicode (unsigned short *(*)(Tcl_Obj *)) uniCodePanic
+# define Tcl_GetUtf16FromObj (unsigned short *(*)(Tcl_Obj *, int *)) uniCodePanic
# define Tcl_NewUtf16Obj (Tcl_Obj *(*)(const unsigned short *, int)) uniCodePanic
+# define Tcl_SetUtf16Obj (void(*)(Tcl_Obj *, const unsigned short *, int)) uniCodePanic
+# define Tcl_AppendUtf16ToObj (void(*)(Tcl_Obj *, const unsigned short *, int)) uniCodePanic
#endif
/* See bug 510001: TclSockMinimumBuffers needs plat imp */
@@ -1335,7 +1351,7 @@ const TclStubs tclStubs = {
Tcl_UtfToExternalDString, /* 333 */
Tcl_UtfToLower, /* 334 */
Tcl_UtfToTitle, /* 335 */
- 0, /* 336 */
+ Tcl_UtfToUtf16, /* 336 */
Tcl_UtfToUpper, /* 337 */
Tcl_WriteChars, /* 338 */
Tcl_WriteObj, /* 339 */
@@ -1351,10 +1367,10 @@ const TclStubs tclStubs = {
Tcl_UniCharIsSpace, /* 349 */
Tcl_UniCharIsUpper, /* 350 */
Tcl_UniCharIsWordChar, /* 351 */
- 0, /* 352 */
- 0, /* 353 */
- 0, /* 354 */
- 0, /* 355 */
+ Tcl_Utf16Len, /* 352 */
+ Tcl_Utf16Ncmp, /* 353 */
+ Tcl_Utf16ToUtfDString, /* 354 */
+ Tcl_UtfToUtf16DString, /* 355 */
Tcl_GetRegExpFromObj, /* 356 */
Tcl_EvalTokens, /* 357 */
Tcl_FreeParse, /* 358 */
@@ -1378,12 +1394,12 @@ const TclStubs tclStubs = {
Tcl_RegExpExecObj, /* 376 */
Tcl_RegExpGetInfo, /* 377 */
Tcl_NewUtf16Obj, /* 378 */
- Tcl_SetUnicodeObj, /* 379 */
+ Tcl_SetUtf16Obj, /* 379 */
Tcl_GetCharLength, /* 380 */
Tcl_GetUniChar, /* 381 */
Tcl_GetUnicode, /* 382 */
Tcl_GetRange, /* 383 */
- Tcl_AppendUnicodeToObj, /* 384 */
+ Tcl_AppendUtf16ToObj, /* 384 */
Tcl_RegExpMatchObj, /* 385 */
Tcl_SetNotifier, /* 386 */
Tcl_GetAllocMutex, /* 387 */
@@ -1418,8 +1434,8 @@ const TclStubs tclStubs = {
Tcl_SpliceChannel, /* 416 */
Tcl_ClearChannelHandlers, /* 417 */
Tcl_IsChannelExisting, /* 418 */
- Tcl_UniCharNcasecmp, /* 419 */
- Tcl_UniCharCaseMatch, /* 420 */
+ Tcl_Utf16Ncasecmp, /* 419 */
+ Tcl_Utf16CaseMatch, /* 420 */
Tcl_FindHashEntry, /* 421 */
Tcl_CreateHashEntry, /* 422 */
Tcl_InitCustomHashTable, /* 423 */
@@ -1648,8 +1664,12 @@ const TclStubs tclStubs = {
Tcl_UtfToUniChar, /* 646 */
Tcl_UniCharLen, /* 647 */
Tcl_UniCharNcmp, /* 648 */
- Tcl_UniCharToUtfDString, /* 649 */
- Tcl_UtfToUniCharDString, /* 650 */
+ Tcl_UniCharNcasecmp, /* 649 */
+ Tcl_UniCharToUtfDString, /* 650 */
+ Tcl_UtfToUniCharDString, /* 651 */
+ Tcl_UniCharCaseMatch, /* 652 */
+ Tcl_AppendUnicodeToObj, /* 653 */
+ Tcl_SetUnicodeObj, /* 654 */
};
/* !END!: Do not edit above this line. */
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index ff8f6bd..c5a2ca5 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -223,17 +223,17 @@ three:
*---------------------------------------------------------------------------
*/
+#undef Tcl_UniCharToUtfDString
char *
Tcl_UniCharToUtfDString(
- const Tcl_UniChar *uniStr, /* Unicode string to convert to UTF-8. */
- int uniLength, /* Length of Unicode string in Tcl_UniChars
- * (must be >= 0). */
+ const int *uniStr, /* Unicode string to convert to UTF-8. */
+ int uniLength, /* Length of Unicode string (must be >= 0). */
Tcl_DString *dsPtr) /* UTF-8 representation of string is appended
* to this previously initialized DString. */
{
- const Tcl_UniChar *w, *wEnd;
+ const int *w, *wEnd;
char *p, *string;
- int oldLength, len = 1;
+ int oldLength;
/*
* UTF-8 string length in bytes will be <= Unicode string length * 4.
@@ -246,27 +246,14 @@ Tcl_UniCharToUtfDString(
p = string;
wEnd = uniStr + uniLength;
for (w = uniStr; w < wEnd; ) {
- if (!len && ((*w & 0xFC00) != 0xDC00)) {
- /* Special case for handling high surrogates. */
- p += Tcl_UniCharToUtf(-1, p);
- }
- len = Tcl_UniCharToUtf(*w, p);
- p += len;
- if ((*w >= 0xD800) && (len < 3)) {
- len = 0; /* Indication that high surrogate was found */
- }
+ p += Tcl_UniCharToUtf(*w, p);
w++;
}
- if (!len) {
- /* Special case for handling high surrogates. */
- p += Tcl_UniCharToUtf(-1, p);
- }
Tcl_DStringSetLength(dsPtr, oldLength + (p - string));
return string;
}
-#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32))
char *
Tcl_Utf16ToUtfDString(
const unsigned short *uniStr, /* Utf-16 string to convert to UTF-8. */
@@ -279,11 +266,11 @@ Tcl_Utf16ToUtfDString(
int oldLength, len = 1;
/*
- * UTF-8 string length in bytes will be <= Unicode string length * 4.
+ * UTF-8 string length in bytes will be <= Utf16 string length * 3.
*/
oldLength = Tcl_DStringLength(dsPtr);
- Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 4);
+ Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 3);
string = Tcl_DStringValue(dsPtr) + oldLength;
p = string;
@@ -308,7 +295,6 @@ Tcl_Utf16ToUtfDString(
return string;
}
-#endif
/*
*---------------------------------------------------------------------------
*
@@ -351,13 +337,14 @@ static const unsigned short cp1252[32] = {
0x2DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x9D, 0x017E, 0x0178
};
+#undef Tcl_UtfToUniChar
int
Tcl_UtfToUniChar(
- register const char *src, /* The UTF-8 string. */
- register Tcl_UniChar *chPtr)/* Filled with the Tcl_UniChar represented by
+ const char *src, /* The UTF-8 string. */
+ int *chPtr)/* Filled with the Unicode represented by
* the UTF-8 string. */
{
- Tcl_UniChar byte;
+ int byte;
/*
* Unroll 1 to 4 byte UTF-8 sequences.
@@ -373,20 +360,6 @@ Tcl_UtfToUniChar(
* characters representing themselves.
*/
-#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
- * do that if the high surrogate matches the bits we encounter.
- */
- if ((byte >= 0x80)
- && (((((byte - 0x10) << 2) & 0xFC) | 0xD800) == (*chPtr & 0xFCFC))
- && ((src[1] & 0xF0) == (((*chPtr << 4) & 0x30) | 0x80))
- && ((src[2] & 0xC0) == 0x80)) {
- *chPtr = ((src[1] & 0x0F) << 6) + (src[2] & 0x3F) + 0xDC00;
- return 3;
- }
-#endif
if ((unsigned)(byte-0x80) < (unsigned)0x20) {
*chPtr = cp1252[byte-0x80];
} else {
@@ -432,23 +405,11 @@ Tcl_UtfToUniChar(
/*
* Four-byte-character lead byte followed by three trail bytes.
*/
-#if TCL_UTF_MAX == 3
- Tcl_UniChar high = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2)
- | ((src[2] & 0x3F) >> 4)) - 0x40;
- if (high >= 0x400) {
- /* out of range, < 0x10000 or > 0x10ffff */
- } else {
- /* produce high surrogate, advance source pointer */
- *chPtr = 0xD800 + high;
- return 1;
- }
-#else
*chPtr = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12)
| ((src[2] & 0x3F) << 6) | (src[3] & 0x3F));
if (((unsigned)(*chPtr) - 0x10000) <= 0xFFFFF) {
return 4;
}
-#endif
}
/*
@@ -461,9 +422,8 @@ Tcl_UtfToUniChar(
return 1;
}
-#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32))
int
-TclUtfToUtf16(
+Tcl_UtfToUtf16(
const char *src, /* The UTF-8 string. */
unsigned short *chPtr)/* Filled with the Utf-16 representation of
* the UTF-8 string. */
@@ -561,7 +521,6 @@ TclUtfToUtf16(
*chPtr = byte;
return 1;
}
-#endif
/*
*---------------------------------------------------------------------------
@@ -581,7 +540,8 @@ TclUtfToUtf16(
*---------------------------------------------------------------------------
*/
-Tcl_UniChar *
+#undef Tcl_UtfToUniCharDString
+int *
Tcl_UtfToUniCharDString(
const char *src, /* UTF-8 string to convert to Unicode. */
int length, /* Length of UTF-8 string in bytes, or -1 for
@@ -590,7 +550,7 @@ Tcl_UtfToUniCharDString(
* appended to this previously initialized
* DString. */
{
- Tcl_UniChar ch = 0, *w, *wString;
+ int ch = 0, *w, *wString;
const char *p, *end;
int oldLength;
@@ -606,8 +566,8 @@ Tcl_UtfToUniCharDString(
oldLength = Tcl_DStringLength(dsPtr);
Tcl_DStringSetLength(dsPtr,
- oldLength + (int) ((length + 1) * sizeof(Tcl_UniChar)));
- wString = (Tcl_UniChar *) (Tcl_DStringValue(dsPtr) + oldLength);
+ oldLength + (int) ((length + 1) * sizeof(int)));
+ wString = (int *) (Tcl_DStringValue(dsPtr) + oldLength);
w = wString;
p = src;
@@ -634,7 +594,6 @@ Tcl_UtfToUniCharDString(
return wString;
}
-#if (TCL_UTF_MAX > 3) && (defined(__CYGWIN__) || defined(_WIN32))
unsigned short *
Tcl_UtfToUtf16DString(
const char *src, /* UTF-8 string to convert to Unicode. */
@@ -667,13 +626,13 @@ Tcl_UtfToUtf16DString(
p = src;
end = src + length - 4;
while (p < end) {
- p += TclUtfToUtf16(p, &ch);
+ p += Tcl_UtfToUtf16(p, &ch);
*w++ = ch;
}
end += 4;
while (p < end) {
if (Tcl_UtfCharComplete(p, end-p)) {
- p += TclUtfToUtf16(p, &ch);
+ p += Tcl_UtfToUtf16(p, &ch);
} else if (((UCHAR(*p)-0x80)) < 0x20) {
ch = cp1252[UCHAR(*p++)-0x80];
} else {
@@ -687,7 +646,6 @@ Tcl_UtfToUtf16DString(
return wString;
}
-#endif
/*
*---------------------------------------------------------------------------
*
@@ -734,6 +692,13 @@ Tcl_UtfCharComplete(
*---------------------------------------------------------------------------
*/
+#if TCL_UTF_MAX == 3
+# undef Tcl_UtfToUniChar
+# define Tcl_UtfToUniChar Tcl_UtfToUtf16
+# undef Tcl_UniCharLen
+# define Tcl_UniCharLen Tcl_Utf16Len
+#endif
+
int
Tcl_NumUtfChars(
register const char *src, /* The UTF-8 string to measure. */
@@ -1671,9 +1636,10 @@ Tcl_UniCharToTitle(
*----------------------------------------------------------------------
*/
+#undef Tcl_UniCharLen
int
Tcl_UniCharLen(
- const Tcl_UniChar *uniStr) /* Unicode string to find length of. */
+ const int *uniStr) /* Unicode string to find length of. */
{
int len = 0;
@@ -1684,6 +1650,19 @@ Tcl_UniCharLen(
return len;
}
+int
+Tcl_Utf16Len(
+ const unsigned short *utf16Str) /* Unicode string to find length of. */
+{
+ int len = 0;
+
+ while (*utf16Str != '\0') {
+ len++;
+ utf16Str++;
+ }
+ return len;
+}
+
/*
*----------------------------------------------------------------------
*
@@ -1701,10 +1680,11 @@ Tcl_UniCharLen(
*----------------------------------------------------------------------
*/
+#undef Tcl_UniCharNcmp
int
Tcl_UniCharNcmp(
- const Tcl_UniChar *ucs, /* Unicode string to compare to uct. */
- const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */
+ const int *ucs, /* Unicode string to compare to uct. */
+ const int *uct, /* Unicode string ucs is compared to. */
unsigned long numChars) /* Number of unichars to compare. */
{
#ifdef WORDS_BIGENDIAN
@@ -1712,7 +1692,7 @@ Tcl_UniCharNcmp(
* We are definitely on a big-endian machine; memcmp() is safe
*/
- return memcmp(ucs, uct, numChars*sizeof(Tcl_UniChar));
+ return memcmp(ucs, uct, numChars*sizeof(int));
#else /* !WORDS_BIGENDIAN */
/*
@@ -1727,7 +1707,34 @@ Tcl_UniCharNcmp(
return 0;
#endif /* WORDS_BIGENDIAN */
}
-
+
+int
+Tcl_Utf16Ncmp(
+ const unsigned short *ucs, /* Unicode string to compare to uct. */
+ const unsigned short *uct, /* Unicode string ucs is compared to. */
+ unsigned long numChars) /* Number of unichars to compare. */
+{
+#ifdef WORDS_BIGENDIAN
+ /*
+ * We are definitely on a big-endian machine; memcmp() is safe
+ */
+
+ return memcmp(ucs, uct, numChars*sizeof(unsigned short));
+
+#else /* !WORDS_BIGENDIAN */
+ /*
+ * We can't simply call memcmp() because that is not lexically correct.
+ */
+
+ for ( ; numChars != 0; ucs++, uct++, numChars--) {
+ if (*ucs != *uct) {
+ return (*ucs - *uct);
+ }
+ }
+ return 0;
+#endif /* WORDS_BIGENDIAN */
+}
+
/*
*----------------------------------------------------------------------
*
@@ -1746,16 +1753,17 @@ Tcl_UniCharNcmp(
*----------------------------------------------------------------------
*/
+#undef Tcl_UniCharNcasecmp
int
Tcl_UniCharNcasecmp(
- const Tcl_UniChar *ucs, /* Unicode string to compare to uct. */
- const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */
+ const int *ucs, /* Unicode string to compare to uct. */
+ const int *uct, /* Unicode string ucs is compared to. */
unsigned long numChars) /* Number of unichars to compare. */
{
for ( ; numChars != 0; numChars--, ucs++, uct++) {
if (*ucs != *uct) {
- Tcl_UniChar lcs = Tcl_UniCharToLower(*ucs);
- Tcl_UniChar lct = Tcl_UniCharToLower(*uct);
+ int lcs = Tcl_UniCharToLower(*ucs);
+ int lct = Tcl_UniCharToLower(*uct);
if (lcs != lct) {
return (lcs - lct);
@@ -1764,7 +1772,25 @@ Tcl_UniCharNcasecmp(
}
return 0;
}
-
+int
+Tcl_Utf16Ncasecmp(
+ const unsigned short *ucs, /* Utf16 string to compare to uct. */
+ const unsigned short *uct, /* Utf16 string ucs is compared to. */
+ unsigned long numChars) /* Number of Utf16 characters to compare. */
+{
+ for ( ; numChars != 0; numChars--, ucs++, uct++) {
+ if (*ucs != *uct) {
+ int lcs = Tcl_UniCharToLower(*ucs);
+ int lct = Tcl_UniCharToLower(*uct);
+
+ if (lcs != lct) {
+ return (lcs - lct);
+ }
+ }
+ }
+ return 0;
+}
+
/*
*----------------------------------------------------------------------
*
@@ -2097,15 +2123,16 @@ Tcl_UniCharIsWordChar(
*----------------------------------------------------------------------
*/
+#undef Tcl_UniCharCaseMatch
int
Tcl_UniCharCaseMatch(
- const Tcl_UniChar *uniStr, /* Unicode String. */
- const Tcl_UniChar *uniPattern,
+ const int *uniStr, /* Unicode String. */
+ const int *uniPattern,
/* Pattern, which may contain special
* characters. */
int nocase) /* 0 for case sensitive, 1 for insensitive */
{
- Tcl_UniChar ch1 = 0, p;
+ int ch1 = 0, p;
while (1) {
p = *uniPattern;
@@ -2156,7 +2183,7 @@ Tcl_UniCharCaseMatch(
if ((p != '[') && (p != '?') && (p != '\\')) {
if (nocase) {
while (*uniStr && (p != *uniStr)
- && (p != (Tcl_UniChar)Tcl_UniCharToLower(*uniStr))) {
+ && (p != Tcl_UniCharToLower(*uniStr))) {
uniStr++;
}
} else {
@@ -2193,16 +2220,16 @@ Tcl_UniCharCaseMatch(
*/
if (p == '[') {
- Tcl_UniChar startChar, endChar;
+ int startChar, endChar;
uniPattern++;
- ch1 = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*uniStr) : *uniStr);
+ ch1 = (nocase ? Tcl_UniCharToLower(*uniStr) : *uniStr);
uniStr++;
while (1) {
if ((*uniPattern == ']') || (*uniPattern == 0)) {
return 0;
}
- startChar = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*uniPattern)
+ startChar = (nocase ? Tcl_UniCharToLower(*uniPattern)
: *uniPattern);
uniPattern++;
if (*uniPattern == '-') {
@@ -2210,7 +2237,7 @@ Tcl_UniCharCaseMatch(
if (*uniPattern == 0) {
return 0;
}
- endChar = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*uniPattern)
+ endChar = (nocase ? Tcl_UniCharToLower(*uniPattern)
: *uniPattern);
uniPattern++;
if (((startChar <= ch1) && (ch1 <= endChar))
@@ -2264,6 +2291,173 @@ Tcl_UniCharCaseMatch(
}
}
+int
+Tcl_Utf16CaseMatch(
+ const unsigned short *uniStr, /* Unicode String. */
+ const unsigned short *uniPattern,
+ /* Pattern, which may contain special
+ * characters. */
+ int nocase) /* 0 for case sensitive, 1 for insensitive */
+{
+ unsigned short ch1 = 0, p;
+
+ while (1) {
+ p = *uniPattern;
+
+ /*
+ * See if we're at the end of both the pattern and the string. If so,
+ * we succeeded. If we're at the end of the pattern but not at the end
+ * of the string, we failed.
+ */
+
+ if (p == 0) {
+ return (*uniStr == 0);
+ }
+ if ((*uniStr == 0) && (p != '*')) {
+ return 0;
+ }
+
+ /*
+ * Check for a "*" as the next pattern character. It matches any
+ * substring. We handle this by skipping all the characters up to the
+ * next matching one in the pattern, and then calling ourselves
+ * recursively for each postfix of string, until either we match or we
+ * reach the end of the string.
+ */
+
+ if (p == '*') {
+ /*
+ * Skip all successive *'s in the pattern
+ */
+
+ while (*(++uniPattern) == '*') {
+ /* empty body */
+ }
+ p = *uniPattern;
+ if (p == 0) {
+ return 1;
+ }
+ if (nocase) {
+ p = Tcl_UniCharToLower(p);
+ }
+ while (1) {
+ /*
+ * Optimization for matching - cruise through the string
+ * quickly if the next char in the pattern isn't a special
+ * character
+ */
+
+ if ((p != '[') && (p != '?') && (p != '\\')) {
+ if (nocase) {
+ while (*uniStr && (p != *uniStr)
+ && (p != Tcl_UniCharToLower(*uniStr))) {
+ uniStr++;
+ }
+ } else {
+ while (*uniStr && (p != *uniStr)) {
+ uniStr++;
+ }
+ }
+ }
+ if (Tcl_Utf16CaseMatch(uniStr, uniPattern, nocase)) {
+ return 1;
+ }
+ if (*uniStr == 0) {
+ return 0;
+ }
+ uniStr++;
+ }
+ }
+
+ /*
+ * Check for a "?" as the next pattern character. It matches any
+ * single character.
+ */
+
+ if (p == '?') {
+ uniPattern++;
+ uniStr++;
+ continue;
+ }
+
+ /*
+ * Check for a "[" as the next pattern character. It is followed by a
+ * list of characters that are acceptable, or by a range (two
+ * characters separated by "-").
+ */
+
+ if (p == '[') {
+ unsigned short startChar, endChar;
+
+ uniPattern++;
+ ch1 = (nocase ? Tcl_UniCharToLower(*uniStr) : *uniStr);
+ uniStr++;
+ while (1) {
+ if ((*uniPattern == ']') || (*uniPattern == 0)) {
+ return 0;
+ }
+ startChar = (nocase ? Tcl_UniCharToLower(*uniPattern)
+ : *uniPattern);
+ uniPattern++;
+ if (*uniPattern == '-') {
+ uniPattern++;
+ if (*uniPattern == 0) {
+ return 0;
+ }
+ endChar = (nocase ? Tcl_UniCharToLower(*uniPattern)
+ : *uniPattern);
+ uniPattern++;
+ if (((startChar <= ch1) && (ch1 <= endChar))
+ || ((endChar <= ch1) && (ch1 <= startChar))) {
+ /*
+ * Matches ranges of form [a-z] or [z-a].
+ */
+ break;
+ }
+ } else if (startChar == ch1) {
+ break;
+ }
+ }
+ while (*uniPattern != ']') {
+ if (*uniPattern == 0) {
+ uniPattern--;
+ break;
+ }
+ uniPattern++;
+ }
+ uniPattern++;
+ continue;
+ }
+
+ /*
+ * If the next pattern character is '\', just strip off the '\' so we
+ * do exact matching on the character that follows.
+ */
+
+ if (p == '\\') {
+ if (*(++uniPattern) == '\0') {
+ return 0;
+ }
+ }
+
+ /*
+ * There's no special character. Just make sure that the next bytes of
+ * each string match.
+ */
+
+ if (nocase) {
+ if (Tcl_UniCharToLower(*uniStr) !=
+ Tcl_UniCharToLower(*uniPattern)) {
+ return 0;
+ }
+ } else if (*uniStr != *uniPattern) {
+ return 0;
+ }
+ uniStr++;
+ uniPattern++;
+ }
+}
+
/*
*----------------------------------------------------------------------
*
@@ -2348,7 +2542,7 @@ TclUniCharMatch(
if ((p != '[') && (p != '?') && (p != '\\')) {
if (nocase) {
while ((string < stringEnd) && (p != *string)
- && (p != (Tcl_UniChar)Tcl_UniCharToLower(*string))) {
+ && (p != Tcl_UniCharToLower(*string))) {
string++;
}
} else {
@@ -2389,20 +2583,20 @@ TclUniCharMatch(
Tcl_UniChar ch1, startChar, endChar;
pattern++;
- ch1 = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*string) : *string);
+ ch1 = (nocase ? Tcl_UniCharToLower(*string) : *string);
string++;
while (1) {
if ((*pattern == ']') || (pattern == patternEnd)) {
return 0;
}
- startChar = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*pattern) : *pattern);
+ startChar = (nocase ? Tcl_UniCharToLower(*pattern) : *pattern);
pattern++;
if (*pattern == '-') {
pattern++;
if (pattern == patternEnd) {
return 0;
}
- endChar = (nocase ? (Tcl_UniChar)Tcl_UniCharToLower(*pattern)
+ endChar = (nocase ? Tcl_UniCharToLower(*pattern)
: *pattern);
pattern++;
if (((startChar <= ch1) && (ch1 <= endChar))
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 0788aed..e432560 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -2302,7 +2302,7 @@ Tcl_StringCaseMatch(
if (nocase) {
while (*str) {
charLen = TclUtfToUniChar(str, &ch1);
- if (ch2==ch1 || ch2==(Tcl_UniChar)Tcl_UniCharToLower(ch1)) {
+ if (ch2==ch1 || ch2==Tcl_UniCharToLower(ch1)) {
break;
}
str += charLen;