aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-06-03 02:45:36 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-11 15:36:04 +0100
commit26733dd488874fee8dfc70d54167f427d5f50516 (patch)
tree710415ca40a05bd41cacbe0bb6fcc1031d911d8a /src
parent90a4cf92d21b730fea7099fb3e12a9ef791a1a57 (diff)
downloadrneovim-26733dd488874fee8dfc70d54167f427d5f50516.tar.gz
rneovim-26733dd488874fee8dfc70d54167f427d5f50516.tar.bz2
rneovim-26733dd488874fee8dfc70d54167f427d5f50516.zip
vim-patch:8.2.2309: 0o777 not recognized as octal
Problem: 0o777 not recognized as octal. Solution: Use vim_isodigit(). (Ken Takata, closes vim/vim#7633, closes vim/vim#7631) https://github.com/vim/vim/commit/c37b655443e0a11a77a9f0707e3259ab4b8b3dda :scriptversion is N/A.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ascii.h8
-rw-r--r--src/nvim/charset.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h
index f41068ea70..7b5e82cd3f 100644
--- a/src/nvim/ascii.h
+++ b/src/nvim/ascii.h
@@ -169,6 +169,14 @@ static inline bool ascii_isbdigit(int c)
return (c == '0' || c == '1');
}
+/// Checks if `c` is an octal digit, that is, 0-7.
+///
+/// @see {ascii_isdigit}
+static inline bool ascii_isodigit(int c)
+{
+ return (c >= '0' && c <= '7');
+}
+
/// Checks if `c` is a white-space character, that is,
/// one of \f, \n, \r, \t, \v.
///
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 94b6b7a8d7..ab4e4ad4bd 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -1463,7 +1463,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
if (!STRING_ENDED(ptr + 2)
&& ptr[0] == '0'
&& (ptr[1] == 'o' || ptr[1] == 'O')
- && ascii_isbdigit(ptr[2])) {
+ && ascii_isodigit(ptr[2])) {
ptr += 2;
}
goto vim_str2nr_oct;
@@ -1499,14 +1499,14 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
if ((what & STR2NR_OOCT)
&& !STRING_ENDED(ptr + 2)
&& (pre == 'O' || pre == 'o')
- && ascii_isbdigit(ptr[2])) {
+ && ascii_isodigit(ptr[2])) {
ptr += 2;
goto vim_str2nr_oct;
}
// Detect old octal format: 0 followed by octal digits.
pre = 0;
if (!(what & STR2NR_OCT)
- || !('0' <= ptr[1] && ptr[1] <= '7')) {
+ || !ascii_isodigit(ptr[1])) {
goto vim_str2nr_dec;
}
for (int i = 2; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) {
@@ -1552,7 +1552,7 @@ vim_str2nr_bin:
PARSE_NUMBER(2, (*ptr == '0' || *ptr == '1'), (*ptr - '0'));
goto vim_str2nr_proceed;
vim_str2nr_oct:
- PARSE_NUMBER(8, ('0' <= *ptr && *ptr <= '7'), (*ptr - '0'));
+ PARSE_NUMBER(8, (ascii_isodigit(*ptr)), (*ptr - '0'));
goto vim_str2nr_proceed;
vim_str2nr_dec:
PARSE_NUMBER(10, (ascii_isdigit(*ptr)), (*ptr - '0'));