patch 9.1.1300: wrong detection of -inf

Problem:  wrong detection of -inf
Solution: correctly compare 4 characters and not 3
          (John Marriott)

closes: #17109

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
John Marriott
2025-04-14 21:19:34 +02:00
committed by Christian Brabandt
parent 4ec93fec12
commit 10f69298b4
3 changed files with 29 additions and 1 deletions

View File

@ -41,7 +41,7 @@ string2float(
*value = INFINITY;
return 3;
}
if (STRNICMP(text, "-inf", 3) == 0)
if (STRNICMP(text, "-inf", 4) == 0)
{
*value = -INFINITY;
return 4;

View File

@ -1329,4 +1329,30 @@ func Test_viminfo_oldfiles_filter()
let &viminfofile = _viminfofile
endfunc
func Test_viminfo_global_var()
let _viminfofile = &viminfofile
let _viminfo = &viminfo
let &viminfofile=''
set viminfo+=!
let lines = [
\ '# comment line',
\ "",
\ '# Viminfo version',
\ '|1,4',
\ "",
\ '*encoding=utf-8',
\ "",
\ '# global variables:',
\ "!VAL\tFLO\t-in",
\ "!VAR\tFLO\t-inf",
\ "",
\ ]
call writefile(lines, 'Xviminfo2', 'D')
rviminfo! Xviminfo2
call assert_equal(0.0, g:VAL)
call assert_equal(str2float("-inf"), g:VAR)
let &viminfofile = _viminfofile
let &viminfo = _viminfo
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1300,
/**/
1299,
/**/