]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1139: [fifo] is not displayed when editing a fifo v9.1.1139
authorChristian Brabandt <cb@256bit.org>
Sun, 23 Feb 2025 08:36:56 +0000 (09:36 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 23 Feb 2025 08:36:56 +0000 (09:36 +0100)
Problem:  [fifo] is not displayed when editing a fifo
          (after v7.4.2189)
Solution: stat the filename and detect the type correctly

fixes: #16702
closes: #16705

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/buffer.c
src/fileio.c
src/testdir/test_startup_utf8.vim
src/version.c

index a925552199a513e626b27b3b1924f45cb0d660e6..68388db088818c7686058ad6397a0e61c3000914 100644 (file)
@@ -275,6 +275,8 @@ open_buffer(
        {
            curbuf->b_p_bin = save_bin;
            if (retval == OK)
+               // don't add READ_FIFO here, otherwise we won't be able to
+               // detect the encoding
                retval = read_buffer(FALSE, eap, flags);
        }
 #endif
index a2031e96f7f09f29292921cbd18026d095edf02b..24a01a010c27def700a8e87e51b9ff25734cc5e3 100644 (file)
@@ -366,15 +366,18 @@ readfile(
            goto theend;
        }
     }
-
-    if (!read_stdin && !read_buffer && !read_fifo)
-    {
 #if defined(UNIX) || defined(VMS)
+    if (!read_stdin && fname != NULL)
        /*
         * On Unix it is possible to read a directory, so we have to
         * check for it before the mch_open().
         */
        perm = mch_getperm(fname);
+#endif
+
+    if (!read_stdin && !read_buffer && !read_fifo)
+    {
+#if defined(UNIX) || defined(VMS)
        if (perm >= 0 && !S_ISREG(perm)             // not a regular file ...
                      && !S_ISFIFO(perm)            // ... or fifo
                      && !S_ISSOCK(perm)            // ... or socket
index e8b99e793762e5bf27795c785808a53f5761f3f7..937766767c6c9420127cf9cb4bd1a5fc19f9d195 100644 (file)
@@ -60,6 +60,33 @@ func Test_read_fifo_utf8()
   call delete('Xtestout')
 endfunc
 
+func Test_detect_fifo()
+  CheckUnix
+  " Using bash/zsh's process substitution.
+  if executable('bash')
+    set shell=bash
+  elseif executable('zsh')
+    set shell=zsh
+  else
+    throw 'Skipped: bash or zsh is required'
+  endif
+  let linesin = ['one', 'two']
+  call writefile(linesin, 'Xtestin_fifo', 'D')
+  let after = [
+       \ 'call writefile(split(execute(":mess"), "\\n"), "Xtestout")',
+       \ 'quit!',
+       \ ]
+  if RunVim([], after, '<(cat Xtestin_fifo)')
+    let lines = readfile('Xtestout')
+    call assert_match('\[fifo\]', lines[0])
+    call assert_match('\[fifo\]', lines[1])
+  else
+    call assert_equal('', 'RunVim failed.')
+  endif
+
+  call delete('Xtestout')
+endfunc
+
 func Test_detect_ambiwidth()
   CheckRunVimInTerminal
 
index 87ed0591ccfbd3df0e4d4db2a4dbdf8cc48b98ce..fe6ebd28db16f86a2b2799445aa01ad1f7c48dde 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1139,
 /**/
     1138,
 /**/