1
0
forked from aniani/vim

patch 8.2.0886: cannot use octal numbers in scriptversion 4

Problem:    Cannot use octal numbers in scriptversion 4.
Solution:   Add the "0o" notation. (Ken Takata, closes #5304)
This commit is contained in:
Bram Moolenaar
2020-06-02 21:38:22 +02:00
parent 3ac498c8a1
commit c17e66c5c0
7 changed files with 48 additions and 20 deletions

View File

@@ -1764,6 +1764,8 @@ vim_isblankline(char_u *lbuf)
* If "prep" is not NULL, returns a flag to indicate the type of the number:
* 0 decimal
* '0' octal
* 'O' octal
* 'o' octal
* 'B' bin
* 'b' bin
* 'X' hex
@@ -1783,8 +1785,8 @@ vim_isblankline(char_u *lbuf)
vim_str2nr(
char_u *start,
int *prep, // return: type of number 0 = decimal, 'x'
// or 'X' is hex, '0' = octal, 'b' or 'B'
// is bin
// or 'X' is hex, '0', 'o' or 'O' is octal,
// 'b' or 'B' is bin
int *len, // return: detected length of number
int what, // what numbers to recognize
varnumber_T *nptr, // return: signed result
@@ -1822,6 +1824,11 @@ vim_str2nr(
&& (maxlen == 0 || maxlen > 2))
// binary
ptr += 2;
else if ((what & STR2NR_OOCT)
&& (pre == 'O' || pre == 'o') && vim_isbdigit(ptr[2])
&& (maxlen == 0 || maxlen > 2))
// octal with prefix "0o"
ptr += 2;
else
{
// decimal or octal, default is decimal
@@ -1869,9 +1876,12 @@ vim_str2nr(
}
}
}
else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE)))
else if (pre == 'O' || pre == 'o' ||
pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE)))
{
// octal
if (pre != 0 && pre != '0')
n += 2; // skip over "0o"
while ('0' <= *ptr && *ptr <= '7')
{
// avoid ubsan error for overflow