@@ -1773,6 +1773,7 @@ vim_isblankline(char_u *lbuf)
1773
1773
* If "what" contains STR2NR_OCT recognize octal numbers
1774
1774
* If "what" contains STR2NR_HEX recognize hex numbers
1775
1775
* If "what" contains STR2NR_FORCE always assume bin/oct/hex.
1776
+ * If "what" contains STR2NR_QUOTE ignore embedded single quotes
1776
1777
* If maxlen > 0, check at a maximum maxlen chars.
1777
1778
* If strict is TRUE, check the number strictly. return *len = 0 if fail.
1778
1779
*/
@@ -1841,7 +1842,8 @@ vim_str2nr(
1841
1842
1842
1843
// Do the conversion manually to avoid sscanf() quirks.
1843
1844
n = 1 ;
1844
- if (pre == 'B' || pre == 'b' || what == STR2NR_BIN + STR2NR_FORCE )
1845
+ if (pre == 'B' || pre == 'b'
1846
+ || ((what & STR2NR_BIN ) && (what & STR2NR_FORCE )))
1845
1847
{
1846
1848
/* bin */
1847
1849
if (pre != 0 )
@@ -1856,9 +1858,16 @@ vim_str2nr(
1856
1858
++ ptr ;
1857
1859
if (n ++ == maxlen )
1858
1860
break ;
1861
+ if ((what & STR2NR_QUOTE ) && * ptr == '\''
1862
+ && '0' <= ptr [1 ] && ptr [1 ] <= '1' )
1863
+ {
1864
+ ++ ptr ;
1865
+ if (n ++ == maxlen )
1866
+ break ;
1867
+ }
1859
1868
}
1860
1869
}
1861
- else if (pre == '0' || what == STR2NR_OCT + STR2NR_FORCE )
1870
+ else if (pre == '0' || (( what & STR2NR_OCT ) && ( what & STR2NR_FORCE )) )
1862
1871
{
1863
1872
/* octal */
1864
1873
while ('0' <= * ptr && * ptr <= '7' )
@@ -1871,9 +1880,16 @@ vim_str2nr(
1871
1880
++ ptr ;
1872
1881
if (n ++ == maxlen )
1873
1882
break ;
1883
+ if ((what & STR2NR_QUOTE ) && * ptr == '\''
1884
+ && '0' <= ptr [1 ] && ptr [1 ] <= '7' )
1885
+ {
1886
+ ++ ptr ;
1887
+ if (n ++ == maxlen )
1888
+ break ;
1889
+ }
1874
1890
}
1875
1891
}
1876
- else if (pre != 0 || what == STR2NR_HEX + STR2NR_FORCE )
1892
+ else if (pre != 0 || (( what & STR2NR_HEX ) && ( what & STR2NR_FORCE )) )
1877
1893
{
1878
1894
/* hex */
1879
1895
if (pre != 0 )
@@ -1888,6 +1904,12 @@ vim_str2nr(
1888
1904
++ ptr ;
1889
1905
if (n ++ == maxlen )
1890
1906
break ;
1907
+ if ((what & STR2NR_QUOTE ) && * ptr == '\'' && vim_isxdigit (ptr [1 ]))
1908
+ {
1909
+ ++ ptr ;
1910
+ if (n ++ == maxlen )
1911
+ break ;
1912
+ }
1891
1913
}
1892
1914
}
1893
1915
else
@@ -1906,8 +1928,15 @@ vim_str2nr(
1906
1928
++ ptr ;
1907
1929
if (n ++ == maxlen )
1908
1930
break ;
1931
+ if ((what & STR2NR_QUOTE ) && * ptr == '\'' && VIM_ISDIGIT (ptr [1 ]))
1932
+ {
1933
+ ++ ptr ;
1934
+ if (n ++ == maxlen )
1935
+ break ;
1936
+ }
1909
1937
}
1910
1938
}
1939
+
1911
1940
// Check for an alpha-numeric character immediately following, that is
1912
1941
// most likely a typo.
1913
1942
if (strict && n - 1 != maxlen && ASCII_ISALNUM (* ptr ))
0 commit comments