]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2309: 0o777 not recognized as octal v8.2.2309
authorBram Moolenaar <Bram@vim.org>
Thu, 7 Jan 2021 18:36:30 +0000 (19:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 7 Jan 2021 18:36:30 +0000 (19:36 +0100)
Problem:    0o777 not recognized as octal.
Solution:   Use vim_isodigit(). (Ken Takata, closes #7633, closes #7631)

src/charset.c
src/testdir/test_eval_stuff.vim
src/version.c

index bf5af37205c14b3ae0929fc88ae7c03289a053bb..4289360e474a9c7ab397ac092143a6cc02467362 100644 (file)
@@ -1594,6 +1594,12 @@ vim_isbdigit(int c)
     return (c == '0' || c == '1');
 }
 
+    static int
+vim_isodigit(int c)
+{
+    return (c >= '0' && c <= '7');
+}
+
 /*
  * Vim's own character class functions.  These exist because many library
  * islower()/toupper() etc. do not work properly: they crash when used with
@@ -1831,7 +1837,7 @@ vim_str2nr(
            // binary
            ptr += 2;
        else if ((what & STR2NR_OOCT)
-               && (pre == 'O' || pre == 'o') && vim_isbdigit(ptr[2])
+               && (pre == 'O' || pre == 'o') && vim_isodigit(ptr[2])
                && (maxlen == 0 || maxlen > 2))
            // octal with prefix "0o"
            ptr += 2;
index 316fb42f22a44e0990e9947b7b672457e7adc9fe..e5f521c85c7c2d6b349e5dc8e6d86da71a7f3721 100644 (file)
@@ -218,6 +218,7 @@ func Test_vvar_scriptversion4()
   call assert_equal(15, 0o17)
   call assert_equal(15, 0O17)
   call assert_equal(18, 018)
+  call assert_equal(511, 0o777)
   call assert_equal(64, 0b1'00'00'00)
   call assert_equal(1048576, 0x10'00'00)
   call assert_equal(32768, 0o10'00'00)
@@ -233,6 +234,7 @@ func Test_vvar_scriptversion1()
   call assert_equal(15, 0o17)
   call assert_equal(15, 0O17)
   call assert_equal(18, 018)
+  call assert_equal(511, 0o777)
 endfunc
 
 func Test_scriptversion_fail()
index f39a0d36181fa3625ecef29c3ccb9999aa818b6f..f4a1d58c81a68d8ed2f307fce2a5d627d6a9c3d3 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2309,
 /**/
     2308,
 /**/