1
0
forked from aniani/vim

patch 8.2.0271: the "num64" feature is available everywhere

Problem:    The "num64" feature is available everywhere and building without
            it causes problems.
Solution:   Graduage the "num64" feature. (James McCoy, closes #5650)
This commit is contained in:
Bram Moolenaar
2020-02-17 22:12:50 +01:00
parent bc2b71d44a
commit 82f654e092
9 changed files with 53 additions and 119 deletions

View File

@@ -3545,9 +3545,7 @@ f_has(typval_T *argvars, typval_T *rettv)
"mzscheme", "mzscheme",
#endif #endif
#endif #endif
#ifdef FEAT_NUM64
"num64", "num64",
#endif
#ifdef FEAT_OLE #ifdef FEAT_OLE
"ole", "ole",
#endif #endif

View File

@@ -285,16 +285,12 @@
* +eval Built-in script language and expression evaluation, * +eval Built-in script language and expression evaluation,
* ":let", ":if", etc. * ":let", ":if", etc.
* +float Floating point variables. * +float Floating point variables.
* +num64 64-bit Number.
*/ */
#ifdef FEAT_NORMAL #ifdef FEAT_NORMAL
# define FEAT_EVAL # define FEAT_EVAL
# if defined(HAVE_FLOAT_FUNCS) || defined(MSWIN) || defined(MACOS_X) # if defined(HAVE_FLOAT_FUNCS) || defined(MSWIN) || defined(MACOS_X)
# define FEAT_FLOAT # define FEAT_FLOAT
# endif # endif
# if defined(HAVE_STDINT_H) || defined(MSWIN) || (VIM_SIZEOF_LONG >= 8)
# define FEAT_NUM64
# endif
#endif #endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL

View File

@@ -4246,10 +4246,8 @@ vim_vsnprintf_typval(
# define TMP_LEN 350 // On my system 1e308 is the biggest number possible. # define TMP_LEN 350 // On my system 1e308 is the biggest number possible.
// That sounds reasonable to use as the maximum // That sounds reasonable to use as the maximum
// printable. // printable.
# elif defined(FEAT_NUM64)
# define TMP_LEN 66
# else # else
# define TMP_LEN 34 # define TMP_LEN 66
# endif # endif
char tmp[TMP_LEN]; char tmp[TMP_LEN];
@@ -4374,11 +4372,7 @@ vim_vsnprintf_typval(
if (length_modifier == 'l' && *p == 'l') if (length_modifier == 'l' && *p == 'l')
{ {
// double l = long long // double l = long long
# ifdef FEAT_NUM64
length_modifier = 'L'; length_modifier = 'L';
# else
length_modifier = 'l'; // treat it as a single 'l'
# endif
p++; p++;
} }
} }
@@ -4394,7 +4388,7 @@ vim_vsnprintf_typval(
default: break; default: break;
} }
# if defined(FEAT_EVAL) && defined(FEAT_NUM64) # if defined(FEAT_EVAL)
switch (fmt_spec) switch (fmt_spec)
{ {
case 'd': case 'u': case 'o': case 'x': case 'X': case 'd': case 'u': case 'o': case 'x': case 'X':
@@ -4516,11 +4510,9 @@ vim_vsnprintf_typval(
long int long_arg = 0; long int long_arg = 0;
unsigned long int ulong_arg = 0; unsigned long int ulong_arg = 0;
# ifdef FEAT_NUM64
// only defined for length modifier ll // only defined for length modifier ll
varnumber_T llong_arg = 0; varnumber_T llong_arg = 0;
uvarnumber_T ullong_arg = 0; uvarnumber_T ullong_arg = 0;
# endif
// only defined for b conversion // only defined for b conversion
uvarnumber_T bin_arg = 0; uvarnumber_T bin_arg = 0;
@@ -4581,7 +4573,6 @@ vim_vsnprintf_typval(
else if (long_arg < 0) else if (long_arg < 0)
arg_sign = -1; arg_sign = -1;
break; break;
# ifdef FEAT_NUM64
case 'L': case 'L':
llong_arg = llong_arg =
# if defined(FEAT_EVAL) # if defined(FEAT_EVAL)
@@ -4593,7 +4584,6 @@ vim_vsnprintf_typval(
else if (llong_arg < 0) else if (llong_arg < 0)
arg_sign = -1; arg_sign = -1;
break; break;
# endif
} }
} }
else else
@@ -4622,7 +4612,6 @@ vim_vsnprintf_typval(
if (ulong_arg != 0) if (ulong_arg != 0)
arg_sign = 1; arg_sign = 1;
break; break;
# ifdef FEAT_NUM64
case 'L': case 'L':
ullong_arg = ullong_arg =
# if defined(FEAT_EVAL) # if defined(FEAT_EVAL)
@@ -4633,7 +4622,6 @@ vim_vsnprintf_typval(
if (ullong_arg != 0) if (ullong_arg != 0)
arg_sign = 1; arg_sign = 1;
break; break;
# endif
} }
} }
@@ -4687,7 +4675,6 @@ vim_vsnprintf_typval(
; ;
else if (length_modifier == 'L') else if (length_modifier == 'L')
{ {
# ifdef FEAT_NUM64
# ifdef MSWIN # ifdef MSWIN
f[f_l++] = 'I'; f[f_l++] = 'I';
f[f_l++] = '6'; f[f_l++] = '6';
@@ -4695,9 +4682,6 @@ vim_vsnprintf_typval(
# else # else
f[f_l++] = 'l'; f[f_l++] = 'l';
f[f_l++] = 'l'; f[f_l++] = 'l';
# endif
# else
f[f_l++] = 'l';
# endif # endif
} }
else else
@@ -4735,11 +4719,9 @@ vim_vsnprintf_typval(
case 'l': str_arg_l += sprintf( case 'l': str_arg_l += sprintf(
tmp + str_arg_l, f, long_arg); tmp + str_arg_l, f, long_arg);
break; break;
# ifdef FEAT_NUM64
case 'L': str_arg_l += sprintf( case 'L': str_arg_l += sprintf(
tmp + str_arg_l, f, llong_arg); tmp + str_arg_l, f, llong_arg);
break; break;
# endif
} }
} }
else else
@@ -4754,11 +4736,9 @@ vim_vsnprintf_typval(
case 'l': str_arg_l += sprintf( case 'l': str_arg_l += sprintf(
tmp + str_arg_l, f, ulong_arg); tmp + str_arg_l, f, ulong_arg);
break; break;
# ifdef FEAT_NUM64
case 'L': str_arg_l += sprintf( case 'L': str_arg_l += sprintf(
tmp + str_arg_l, f, ullong_arg); tmp + str_arg_l, f, ullong_arg);
break; break;
# endif
} }
} }

View File

@@ -1245,9 +1245,8 @@ typedef struct hashtable_S
typedef long_u hash_T; // Type for hi_hash typedef long_u hash_T; // Type for hi_hash
#ifdef FEAT_NUM64
// Use 64-bit Number. // Use 64-bit Number.
# ifdef MSWIN #ifdef MSWIN
# ifdef PROTO # ifdef PROTO
typedef long varnumber_T; typedef long varnumber_T;
typedef unsigned long uvarnumber_T; typedef unsigned long uvarnumber_T;
@@ -1261,26 +1260,18 @@ typedef unsigned __int64 uvarnumber_T;
# define VARNUM_MAX _I64_MAX # define VARNUM_MAX _I64_MAX
# define UVARNUM_MAX _UI64_MAX # define UVARNUM_MAX _UI64_MAX
# endif # endif
# elif defined(HAVE_STDINT_H) #elif defined(HAVE_STDINT_H)
typedef int64_t varnumber_T; typedef int64_t varnumber_T;
typedef uint64_t uvarnumber_T; typedef uint64_t uvarnumber_T;
# define VARNUM_MIN INT64_MIN # define VARNUM_MIN INT64_MIN
# define VARNUM_MAX INT64_MAX # define VARNUM_MAX INT64_MAX
# define UVARNUM_MAX UINT64_MAX # define UVARNUM_MAX UINT64_MAX
# else #else
typedef long varnumber_T; typedef long varnumber_T;
typedef unsigned long uvarnumber_T; typedef unsigned long uvarnumber_T;
# define VARNUM_MIN LONG_MIN # define VARNUM_MIN LONG_MIN
# define VARNUM_MAX LONG_MAX # define VARNUM_MAX LONG_MAX
# define UVARNUM_MAX ULONG_MAX # define UVARNUM_MAX ULONG_MAX
# endif
#else
// Use 32-bit Number.
typedef int varnumber_T;
typedef unsigned int uvarnumber_T;
# define VARNUM_MIN INT_MIN
# define VARNUM_MAX INT_MAX
# define UVARNUM_MAX UINT_MAX
#endif #endif
typedef double float_T; typedef double float_T;

View File

@@ -382,9 +382,7 @@ function Test_max_min_errors()
endfunc endfunc
function Test_printf_64bit() function Test_printf_64bit()
if has('num64')
call assert_equal("123456789012345", printf('%d', 123456789012345)) call assert_equal("123456789012345", printf('%d', 123456789012345))
endif
endfunc endfunc
function Test_printf_spec_s() function Test_printf_spec_s()
@@ -423,12 +421,8 @@ function Test_printf_spec_b()
call assert_equal(" 0b1111011", printf('%#10b', 123)) call assert_equal(" 0b1111011", printf('%#10b', 123))
call assert_equal("0B01111011", printf('%#010B', 123)) call assert_equal("0B01111011", printf('%#010B', 123))
call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890)) call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890))
if has('num64')
call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345))
call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1))
else
call assert_equal("11111111111111111111111111111111", printf('%b', -1))
endif
endfunc endfunc
func Test_substitute_expr() func Test_substitute_expr()

View File

@@ -24,11 +24,6 @@ func Test_largefile()
w w
" Check if the file size is 4,000,000,000 bytes. " Check if the file size is 4,000,000,000 bytes.
let fsize=getfsize(fname) let fsize=getfsize(fname)
if has('num64')
call assert_true(fsize == 4000000000) call assert_true(fsize == 4000000000)
else
" getfsize() returns -2 if a Number is 32 bits.
call assert_true(fsize == -2)
endif
call delete(fname) call delete(fname)
endfunc endfunc

View File

@@ -1295,7 +1295,6 @@ abc
\ '2147483647'], getline(1, '$')) \ '2147483647'], getline(1, '$'))
bwipe! bwipe!
if has('num64')
new new
a a
-9223372036854775808 -9223372036854775808
@@ -1327,7 +1326,6 @@ abc
\ '9223372036854775807', \ '9223372036854775807',
\ '9223372036854775807'], getline(1, '$')) \ '9223372036854775807'], getline(1, '$'))
bwipe! bwipe!
endif
endfunc endfunc

View File

@@ -1416,10 +1416,6 @@ endfunc
"------------------------------------------------------------------------------- "-------------------------------------------------------------------------------
func Test_num64() func Test_num64()
if !has('num64')
return
endif
call assert_notequal( 4294967296, 0) call assert_notequal( 4294967296, 0)
call assert_notequal(-4294967296, 0) call assert_notequal(-4294967296, 0)
call assert_equal( 4294967296, 0xFFFFffff + 1) call assert_equal( 4294967296, 0xFFFFffff + 1)
@@ -1692,27 +1688,15 @@ func Test_compound_assignment_operators()
" Test special cases: division or modulus with 0. " Test special cases: division or modulus with 0.
let x = 1 let x = 1
let x /= 0 let x /= 0
if has('num64')
call assert_equal(0x7FFFFFFFFFFFFFFF, x) call assert_equal(0x7FFFFFFFFFFFFFFF, x)
else
call assert_equal(0x7fffffff, x)
endif
let x = -1 let x = -1
let x /= 0 let x /= 0
if has('num64')
call assert_equal(-0x7FFFFFFFFFFFFFFF, x) call assert_equal(-0x7FFFFFFFFFFFFFFF, x)
else
call assert_equal(-0x7fffffff, x)
endif
let x = 0 let x = 0
let x /= 0 let x /= 0
if has('num64')
call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x) call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x)
else
call assert_equal(-0x7FFFFFFF - 1, x)
endif
let x = 1 let x = 1
let x %= 0 let x %= 0

View File

@@ -436,11 +436,7 @@ static char *(features[]) =
#else #else
"-netbeans_intg", "-netbeans_intg",
#endif #endif
#ifdef FEAT_NUM64
"+num64", "+num64",
#else
"-num64",
#endif
#ifdef FEAT_GUI_MSWIN #ifdef FEAT_GUI_MSWIN
# ifdef FEAT_OLE # ifdef FEAT_OLE
"+ole", "+ole",
@@ -742,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
271,
/**/ /**/
270, 270,
/**/ /**/