diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-02 21:38:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-02 21:38:22 +0200 |
commit | c17e66c5c0acd5038f1eb3d7b3049b64bb6ea30b (patch) | |
tree | 580fb479d6dc515270ec050a4913303d2e7fea37 /src/charset.c | |
parent | 3ac498c8a1c3570c296093a5d9425b2a3a7cdb29 (diff) | |
download | vim-git-c17e66c5c0acd5038f1eb3d7b3049b64bb6ea30b.tar.gz |
patch 8.2.0886: cannot use octal numbers in scriptversion 4v8.2.0886
Problem: Cannot use octal numbers in scriptversion 4.
Solution: Add the "0o" notation. (Ken Takata, closes #5304)
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c index 7415c2471..6cf4a2bb1 100644 --- a/src/charset.c +++ b/src/charset.c @@ -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 |