diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-01 08:50:34 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-01 08:50:34 (GMT) |
commit | f712d20c4f1fe203f78c14d4d8b1052de0314ff7 (patch) | |
tree | cbd8488c9c8f4c8b20c9d7e21b3a99d137e231c9 /generic | |
parent | beea0edb4db4751be42b6fbfb15df659cf6d0811 (diff) | |
parent | 1997e71e603d7d479143da6fdf0db628f8f9ba82 (diff) | |
download | tcl-f712d20c4f1fe203f78c14d4d8b1052de0314ff7.zip tcl-f712d20c4f1fe203f78c14d4d8b1052de0314ff7.tar.gz tcl-f712d20c4f1fe203f78c14d4d8b1052de0314ff7.tar.bz2 |
merge trunk
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tcl.h | 2 | ||||
-rw-r--r-- | generic/tclTomMath.h | 47 | ||||
-rw-r--r-- | generic/tclUtf.c | 12 |
3 files changed, 29 insertions, 32 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index ea52ebf..d0e4eb1 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2263,6 +2263,8 @@ typedef struct mp_int mp_int; #define MP_INT_DECLARED typedef unsigned int mp_digit; #define MP_DIGIT_DECLARED +typedef unsigned TCL_WIDE_INT_TYPE mp_word; +#define MP_WORD_DECLARED /* *---------------------------------------------------------------------------- diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index 001019c..39132ed 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -46,7 +46,10 @@ extern "C" { typedef uint8_t mp_digit; #define MP_DIGIT_DECLARED #endif +#ifndef MP_WORD_DECLARED typedef uint16_t mp_word; +#define MP_WORD_DECLARED +#endif #define MP_SIZEOF_MP_DIGIT 1 #ifdef DIGIT_BIT #error You must not define DIGIT_BIT when using MP_8BIT @@ -56,30 +59,34 @@ extern "C" { typedef uint16_t mp_digit; #define MP_DIGIT_DECLARED #endif +#ifndef MP_WORD_DECLARED typedef uint32_t mp_word; +#define MP_WORD_DECLARED +#endif #define MP_SIZEOF_MP_DIGIT 2 #ifdef DIGIT_BIT #error You must not define DIGIT_BIT when using MP_16BIT #endif #elif defined(MP_64BIT) /* for GCC only on supported platforms */ -#ifndef CRYPT - typedef unsigned long long ulong64; - typedef signed long long long64; -#endif - #ifndef MP_DIGIT_DECLARED - typedef ulong64 mp_digit; + typedef uint64_t mp_digit; #define MP_DIGIT_DECLARED #endif #if defined(_WIN32) +#ifndef MP_WORD_DECLARED typedef unsigned __int128 mp_word; +#define MP_WORD_DECLARED +#endif #elif defined(__GNUC__) typedef unsigned long mp_word __attribute__ ((mode(TI))); #else /* it seems you have a problem * but we assume you can somewhere define your own uint128_t */ +#ifndef MP_WORD_DECLARED typedef uint128_t mp_word; +#define MP_WORD_DECLARED +#endif #endif #define DIGIT_BIT 60 @@ -87,16 +94,14 @@ extern "C" { /* this is the default case, 28-bit digits */ /* this is to make porting into LibTomCrypt easier :-) */ -#ifndef CRYPT - typedef unsigned long long ulong64; - typedef signed long long long64; -#endif - #ifndef MP_DIGIT_DECLARED typedef uint32_t mp_digit; #define MP_DIGIT_DECLARED #endif - typedef ulong64 mp_word; +#ifndef MP_WORD_DECLARED + typedef uint64_t mp_word; +#define MP_WORD_DECLARED +#endif #ifdef MP_31BIT /* this is an extension that uses 31-bit digits */ @@ -116,16 +121,16 @@ extern "C" { typedef mp_digit mp_min_u32; #endif -/* platforms that can use a better rand function */ +/* use arc4random on platforms that support it */ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) - #define MP_USE_ALT_RAND 1 + #define MP_GEN_RANDOM() arc4random() + #define MP_GEN_RANDOM_MAX 0xffffffff #endif -/* use arc4random on platforms that support it */ -#ifdef MP_USE_ALT_RAND - #define MP_GEN_RANDOM() arc4random() -#else +/* use rand() as fall-back if there's no better rand function */ +#ifndef MP_GEN_RANDOM #define MP_GEN_RANDOM() rand() + #define MP_GEN_RANDOM_MAX RAND_MAX #endif #define MP_DIGIT_BIT DIGIT_BIT @@ -796,7 +801,7 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream); #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: tag: v1.0.1, master */ +/* git commit: 5953f62e42b24af93748b1ee5e1d062e242c2546 */ +/* commit time: 2017-08-29 22:27:36 +0200 */ diff --git a/generic/tclUtf.c b/generic/tclUtf.c index ae00f5e..94dd628 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -266,16 +266,6 @@ Tcl_UniCharToUtfDString( * *chPtr is filled with the Tcl_UniChar, and the return value is the * number of bytes from the UTF-8 string that were consumed. * - * If TCL_UTF_MAX == 4, special handling of Surrogate pairs is done: - * - * If the UTF-8 string represents a character outside of the BMP, the - * first call to this function will fill *chPtr with the high surrogate - * and generate a return value of 0. Calling Tcl_UtfToUniChar again - * will produce the low surrogate and a return value of 4. Because *chPtr - * is used to remember whether the high surrogate is already produced, it - * is recommended to initialize the variable it points to as 0 before - * the first call to Tcl_UtfToUniChar is done. - * * Side effects: * None. * @@ -349,7 +339,7 @@ Tcl_UtfToUniChar( byte = (((byte & 0x07) << 18) | ((src[1] & 0x3F) << 12) | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F)) - 0x10000; - surrogate = 0xD800 + (byte >> 10); + surrogate = (Tcl_UniChar) (0xD800 + (byte >> 10)); if (byte & 0x100000) { /* out of range, < 0x10000 or > 0x10ffff */ } else if (*chPtr != surrogate) { |