mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
vim-patch:8.1.2035: recognizing octal numbers is confusing
Problem: Recognizing octal numbers is confusing.
Solution: Introduce scriptversion 4: do not use octal and allow for single
quote inside numbers.
60a8de28d1
:scriptversion is N/A.
Cherry-pick Test_readfile_binary() from v8.1.0742.
Note that this patch was missing vim_str2nr() changes, and so fails the
tests; this was fixed in v8.1.2036.
This commit is contained in:
@@ -9998,7 +9998,7 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
int base = 10;
|
||||
varnumber_T n;
|
||||
int what;
|
||||
int what = 0;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
base = tv_get_number(&argvars[1]);
|
||||
@@ -10006,6 +10006,9 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
EMSG(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
if (argvars[2].v_type != VAR_UNKNOWN && tv_get_number(&argvars[2])) {
|
||||
what |= STR2NR_QUOTE;
|
||||
}
|
||||
}
|
||||
|
||||
char_u *p = skipwhite((const char_u *)tv_get_string(&argvars[0]));
|
||||
@@ -10015,20 +10018,17 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
switch (base) {
|
||||
case 2: {
|
||||
what = STR2NR_BIN | STR2NR_FORCE;
|
||||
what |= STR2NR_BIN | STR2NR_FORCE;
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
what = STR2NR_OCT | STR2NR_FORCE;
|
||||
what |= STR2NR_OCT | STR2NR_FORCE;
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
what = STR2NR_HEX | STR2NR_FORCE;
|
||||
what |= STR2NR_HEX | STR2NR_FORCE;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
what = 0;
|
||||
}
|
||||
}
|
||||
vim_str2nr(p, NULL, NULL, what, &n, NULL, 0, false);
|
||||
// Text after the number is silently ignored.
|
||||
|
Reference in New Issue
Block a user