Skip to content

Commit 1ac90b4

Browse files
committed
patch 8.1.2036: the str2nr() tests fail
Problem: The str2nr() tests fail. Solution: Add missing part of patch.
1 parent 60a8de2 commit 1ac90b4

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/charset.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,7 @@ vim_isblankline(char_u *lbuf)
17731773
* If "what" contains STR2NR_OCT recognize octal numbers
17741774
* If "what" contains STR2NR_HEX recognize hex numbers
17751775
* If "what" contains STR2NR_FORCE always assume bin/oct/hex.
1776+
* If "what" contains STR2NR_QUOTE ignore embedded single quotes
17761777
* If maxlen > 0, check at a maximum maxlen chars.
17771778
* If strict is TRUE, check the number strictly. return *len = 0 if fail.
17781779
*/
@@ -1841,7 +1842,8 @@ vim_str2nr(
18411842

18421843
// Do the conversion manually to avoid sscanf() quirks.
18431844
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)))
18451847
{
18461848
/* bin */
18471849
if (pre != 0)
@@ -1856,9 +1858,16 @@ vim_str2nr(
18561858
++ptr;
18571859
if (n++ == maxlen)
18581860
break;
1861+
if ((what & STR2NR_QUOTE) && *ptr == '\''
1862+
&& '0' <= ptr[1] && ptr[1] <= '1')
1863+
{
1864+
++ptr;
1865+
if (n++ == maxlen)
1866+
break;
1867+
}
18591868
}
18601869
}
1861-
else if (pre == '0' || what == STR2NR_OCT + STR2NR_FORCE)
1870+
else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE)))
18621871
{
18631872
/* octal */
18641873
while ('0' <= *ptr && *ptr <= '7')
@@ -1871,9 +1880,16 @@ vim_str2nr(
18711880
++ptr;
18721881
if (n++ == maxlen)
18731882
break;
1883+
if ((what & STR2NR_QUOTE) && *ptr == '\''
1884+
&& '0' <= ptr[1] && ptr[1] <= '7')
1885+
{
1886+
++ptr;
1887+
if (n++ == maxlen)
1888+
break;
1889+
}
18741890
}
18751891
}
1876-
else if (pre != 0 || what == STR2NR_HEX + STR2NR_FORCE)
1892+
else if (pre != 0 || ((what & STR2NR_HEX) && (what & STR2NR_FORCE)))
18771893
{
18781894
/* hex */
18791895
if (pre != 0)
@@ -1888,6 +1904,12 @@ vim_str2nr(
18881904
++ptr;
18891905
if (n++ == maxlen)
18901906
break;
1907+
if ((what & STR2NR_QUOTE) && *ptr == '\'' && vim_isxdigit(ptr[1]))
1908+
{
1909+
++ptr;
1910+
if (n++ == maxlen)
1911+
break;
1912+
}
18911913
}
18921914
}
18931915
else
@@ -1906,8 +1928,15 @@ vim_str2nr(
19061928
++ptr;
19071929
if (n++ == maxlen)
19081930
break;
1931+
if ((what & STR2NR_QUOTE) && *ptr == '\'' && VIM_ISDIGIT(ptr[1]))
1932+
{
1933+
++ptr;
1934+
if (n++ == maxlen)
1935+
break;
1936+
}
19091937
}
19101938
}
1939+
19111940
// Check for an alpha-numeric character immediately following, that is
19121941
// most likely a typo.
19131942
if (strict && n - 1 != maxlen && ASCII_ISALNUM(*ptr))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
2036,
760762
/**/
761763
2035,
762764
/**/

0 commit comments

Comments
 (0)