summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclEncoding.c12
-rw-r--r--generic/tclInt.h4
-rw-r--r--generic/tclStubInit.c13
-rw-r--r--generic/tclTomMath.decls22
-rw-r--r--generic/tclTomMathDecls.h55
-rw-r--r--generic/tclUtf.c25
6 files changed, 81 insertions, 50 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 74e7513..0827907 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2672,7 +2672,10 @@ UtfToUcs2Proc(
* output buffer. */
{
const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
- int result, numChars, len;
+ int result, numChars;
+#if TCL_UTF_MAX <= 4
+ int len;
+#endif
Tcl_UniChar ch = 0;
srcStart = src;
@@ -2700,11 +2703,18 @@ UtfToUcs2Proc(
result = TCL_CONVERT_NOSPACE;
break;
}
+#if TCL_UTF_MAX <= 4
src += (len = TclUtfToUniChar(src, &ch));
if ((ch >= 0xD800) && (len < 3)) {
src += TclUtfToUniChar(src, &ch);
ch = 0xFFFD;
}
+#else
+ src += TclUtfToUniChar(src, &ch);
+ if (ch > 0xFFFF) {
+ ch = 0xFFFD;
+ }
+#endif
/*
* Need to handle this in a way that won't cause misalignment by
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 0db08f9..b95bee9 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3242,13 +3242,13 @@ MODULE_SCOPE void TclRegisterCommandTypeName(
Tcl_ObjCmdProc *implementationProc,
const char *nameStr);
#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32))
-MODULE_SCOPE int TclUtfToWChar(const char *src, WCHAR *chPtr);
+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 TclUtfToWChar TclUtfToUniChar
+# define TclUtfToUtf16 TclUtfToUniChar
# define Tcl_Utf16ToUtfDString Tcl_UniCharToUtfDString
# define Tcl_UtfToUtf16DString Tcl_UtfToUniCharDString
#endif
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 3cafbc0..da25b2a 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -280,7 +280,7 @@ Tcl_WinTCharToUtf(
} else {
len /= 2;
}
- return Tcl_Utf16ToUtfDString((const WCHAR *)string, len, dsPtr);
+ return Tcl_Utf16ToUtfDString((const unsigned short *)string, len, dsPtr);
}
#if defined(TCL_WIDE_INT_IS_LONG)
@@ -429,6 +429,17 @@ static int uniCharNcasecmp(const Tcl_UniChar *ucs, const Tcl_UniChar *uct, unsig
# define Tcl_SetPanicProc 0
# define Tcl_FindExecutable 0
# define TclOldFreeObj 0
+# define TclBN_reverse 0
+# define TclBN_fast_s_mp_mul_digs 0
+# define TclBN_fast_s_mp_sqr 0
+# define TclBN_mp_karatsuba_mul 0
+# define TclBN_mp_karatsuba_sqr 0
+# define TclBN_mp_toom_mul 0
+# define TclBN_mp_toom_sqr 0
+# define TclBN_s_mp_add 0
+# define TclBN_s_mp_mul_digs 0
+# define TclBN_s_mp_sqr 0
+# define TclBN_s_mp_sub 0
#else /* TCL_NO_DEPRECATED */
# define Tcl_SeekOld seekOld
# define Tcl_TellOld tellOld
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index 8b45dc8..7221dcf 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -178,37 +178,37 @@ declare 49 {
# internal routines to libtommath - should not be called but must be
# exported to accommodate the "tommath" extension
-declare 50 {
+declare 50 {deprecated {is private function in libtommath}} {
void TclBN_reverse(unsigned char *s, int len)
}
-declare 51 {
+declare 51 {deprecated {is private function in libtommath}} {
int TclBN_fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
}
-declare 52 {
+declare 52 {deprecated {is private function in libtommath}} {
int TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b)
}
-declare 53 {
+declare 53 {deprecated {is private function in libtommath}} {
int TclBN_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
}
-declare 54 {
+declare 54 {deprecated {is private function in libtommath}} {
int TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b)
}
-declare 55 {
+declare 55 {deprecated {is private function in libtommath}} {
int TclBN_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
}
-declare 56 {
+declare 56 {deprecated {is private function in libtommath}} {
int TclBN_mp_toom_sqr(const mp_int *a, mp_int *b)
}
-declare 57 {
+declare 57 {deprecated {is private function in libtommath}} {
int TclBN_s_mp_add(const mp_int *a, const mp_int *b, mp_int *c)
}
-declare 58 {
+declare 58 {deprecated {is private function in libtommath}} {
int TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
}
-declare 59 {
+declare 59 {deprecated {is private function in libtommath}} {
int TclBN_s_mp_sqr(const mp_int *a, mp_int *b)
}
-declare 60 {
+declare 60 {deprecated {is private function in libtommath}} {
int TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c)
}
declare 61 {
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index c82d70d..b7cf97f 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -273,32 +273,43 @@ EXTERN int TclBN_mp_xor(const mp_int *a, const mp_int *b,
/* 49 */
EXTERN void TclBN_mp_zero(mp_int *a);
/* 50 */
-EXTERN void TclBN_reverse(unsigned char *s, int len);
+TCL_DEPRECATED("is private function in libtommath")
+void TclBN_reverse(unsigned char *s, int len);
/* 51 */
-EXTERN int TclBN_fast_s_mp_mul_digs(const mp_int *a,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_fast_s_mp_mul_digs(const mp_int *a,
const mp_int *b, mp_int *c, int digs);
/* 52 */
-EXTERN int TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b);
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_fast_s_mp_sqr(const mp_int *a, mp_int *b);
/* 53 */
-EXTERN int TclBN_mp_karatsuba_mul(const mp_int *a,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_mp_karatsuba_mul(const mp_int *a,
const mp_int *b, mp_int *c);
/* 54 */
-EXTERN int TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
/* 55 */
-EXTERN int TclBN_mp_toom_mul(const mp_int *a, const mp_int *b,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_mp_toom_mul(const mp_int *a, const mp_int *b,
mp_int *c);
/* 56 */
-EXTERN int TclBN_mp_toom_sqr(const mp_int *a, mp_int *b);
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_mp_toom_sqr(const mp_int *a, mp_int *b);
/* 57 */
-EXTERN int TclBN_s_mp_add(const mp_int *a, const mp_int *b,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_s_mp_add(const mp_int *a, const mp_int *b,
mp_int *c);
/* 58 */
-EXTERN int TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b,
mp_int *c, int digs);
/* 59 */
-EXTERN int TclBN_s_mp_sqr(const mp_int *a, mp_int *b);
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_s_mp_sqr(const mp_int *a, mp_int *b);
/* 60 */
-EXTERN int TclBN_s_mp_sub(const mp_int *a, const mp_int *b,
+TCL_DEPRECATED("is private function in libtommath")
+int TclBN_s_mp_sub(const mp_int *a, const mp_int *b,
mp_int *c);
/* 61 */
EXTERN int TclBN_mp_init_set_int(mp_int *a, unsigned long i);
@@ -398,17 +409,17 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */
int (*tclBN_mp_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 48 */
void (*tclBN_mp_zero) (mp_int *a); /* 49 */
- void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */
- int (*tclBN_fast_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 51 */
- int (*tclBN_fast_s_mp_sqr) (const mp_int *a, mp_int *b); /* 52 */
- int (*tclBN_mp_karatsuba_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 53 */
- int (*tclBN_mp_karatsuba_sqr) (const mp_int *a, mp_int *b); /* 54 */
- int (*tclBN_mp_toom_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 55 */
- int (*tclBN_mp_toom_sqr) (const mp_int *a, mp_int *b); /* 56 */
- int (*tclBN_s_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 57 */
- int (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */
- int (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */
- int (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */
+ TCL_DEPRECATED_API("is private function in libtommath") void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_fast_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 51 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_fast_s_mp_sqr) (const mp_int *a, mp_int *b); /* 52 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_mp_karatsuba_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 53 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_mp_karatsuba_sqr) (const mp_int *a, mp_int *b); /* 54 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_mp_toom_mul) (const mp_int *a, const mp_int *b, mp_int *c); /* 55 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_mp_toom_sqr) (const mp_int *a, mp_int *b); /* 56 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_s_mp_add) (const mp_int *a, const mp_int *b, mp_int *c); /* 57 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */
+ TCL_DEPRECATED_API("is private function in libtommath") int (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */
int (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */
int (*tclBN_mp_set_int) (mp_int *a, unsigned long i); /* 62 */
int (*tclBN_mp_cnt_lsb) (const mp_int *a); /* 63 */
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index cea0875..7e9c36c 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -269,9 +269,8 @@ Tcl_UniCharToUtfDString(
#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32))
char *
Tcl_Utf16ToUtfDString(
- const unsigned short *uniStr, /* WCHAR string to convert to UTF-8. */
- int uniLength, /* Length of WCHAR string in Tcl_UniChars
- * (must be >= 0). */
+ const unsigned short *uniStr, /* Utf-16 string to convert to UTF-8. */
+ int uniLength, /* Length of Utf-16 string (must be >= 0). */
Tcl_DString *dsPtr) /* UTF-8 representation of string is appended
* to this previously initialized DString. */
{
@@ -446,7 +445,7 @@ Tcl_UtfToUniChar(
#else
*chPtr = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12)
| ((src[2] & 0x3F) << 6) | (src[3] & 0x3F));
- if ((*chPtr - 0x10000) <= 0xFFFFF) {
+ if (((unsigned)(*chPtr) - 0x10000) <= 0xFFFFF) {
return 4;
}
#endif
@@ -464,12 +463,12 @@ Tcl_UtfToUniChar(
#if (TCL_UTF_MAX > 4) && (defined(__CYGWIN__) || defined(_WIN32))
int
-TclUtfToWChar(
+TclUtfToUtf16(
const char *src, /* The UTF-8 string. */
- WCHAR *chPtr)/* Filled with the WCHAR represented by
+ unsigned short *chPtr)/* Filled with the Utf-16 representation of
* the UTF-8 string. */
{
- WCHAR byte;
+ unsigned short byte;
/*
* Unroll 1 to 4 byte UTF-8 sequences.
@@ -542,7 +541,7 @@ TclUtfToWChar(
/*
* Four-byte-character lead byte followed by three trail bytes.
*/
- WCHAR high = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2)
+ unsigned short high = (((byte & 0x07) << 8) | ((src[1] & 0x3F) << 2)
| ((src[2] & 0x3F) >> 4)) - 0x40;
if (high >= 0x400) {
/* out of range, < 0x10000 or > 0x10ffff */
@@ -645,7 +644,7 @@ Tcl_UtfToUtf16DString(
* appended to this previously initialized
* DString. */
{
- WCHAR ch = 0, *w, *wString;
+ unsigned short ch = 0, *w, *wString;
const char *p, *end;
int oldLength;
@@ -661,20 +660,20 @@ Tcl_UtfToUtf16DString(
oldLength = Tcl_DStringLength(dsPtr);
Tcl_DStringSetLength(dsPtr,
- oldLength + (int) ((length + 1) * sizeof(WCHAR)));
- wString = (WCHAR *) (Tcl_DStringValue(dsPtr) + oldLength);
+ oldLength + (int) ((length + 1) * sizeof(unsigned short)));
+ wString = (unsigned short *) (Tcl_DStringValue(dsPtr) + oldLength);
w = wString;
p = src;
end = src + length - 4;
while (p < end) {
- p += TclUtfToWChar(p, &ch);
+ p += TclUtfToUtf16(p, &ch);
*w++ = ch;
}
end += 4;
while (p < end) {
if (Tcl_UtfCharComplete(p, end-p)) {
- p += TclUtfToWChar(p, &ch);
+ p += TclUtfToUtf16(p, &ch);
} else if (((UCHAR(*p)-0x80)) < 0x20) {
ch = cp1252[UCHAR(*p++)-0x80];
} else {