]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1300: wrong detection of -inf v9.1.1300
authorJohn Marriott <basilisk@internode.on.net>
Mon, 14 Apr 2025 19:19:34 +0000 (21:19 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 14 Apr 2025 19:19:34 +0000 (21:19 +0200)
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>
src/float.c
src/testdir/test_viminfo.vim
src/version.c

index 9e8074de8e78da27894925ae10e868ab3a0b2b4d..4c8e5fe10ad9cc21980ae58816bc9b8a2791a3df 100644 (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;
index 7aab271336538c3833a8fceeb2d885de49e52c4d..2bbca3e5d3bf260703ee1acef538008ac1373b0f 100644 (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
index e4a0b0ed1eb66715c09dec2acc6f2ae631925ba6..0a5b4ecf5dc7b9d12bc5fa30ca8a5544bf535f97 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1300,
 /**/
     1299,
 /**/