From 0861ea6949a0c7281c56083092d389cae5d7bde8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Feb 2025 17:06:54 +0800 Subject: vim-patch:9.1.1139: [fifo] is not displayed when editing a fifo Problem: [fifo] is not displayed when editing a fifo (after v7.4.2189) Solution: stat the filename and detect the type correctly fixes: vim/vim#16702 closes: vim/vim#16705 https://github.com/vim/vim/commit/f1c3134ee1f263e537212a3072e8aa4cb7e8d953 Co-authored-by: Christian Brabandt --- src/nvim/buffer.c | 2 ++ src/nvim/fileio.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 9e6877cbfa..5fec2f1211 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -305,6 +305,8 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) if (read_fifo) { 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); } } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 61b252f823..7c41c84838 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -353,10 +353,11 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, } } - if (!read_buffer && !read_stdin && !read_fifo) { + if (!read_stdin && fname != NULL) { perm = os_getperm(fname); // On Unix it is possible to read a directory, so we have to // check for it before os_open(). + } #ifdef OPEN_CHR_FILES # define IS_CHR_DEV(perm, fname) S_ISCHR(perm) && is_dev_fd_file(fname) @@ -364,6 +365,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, # define IS_CHR_DEV(perm, fname) false #endif + if (!read_stdin && !read_buffer && !read_fifo) { if (perm >= 0 && !S_ISREG(perm) // not a regular file ... && !S_ISFIFO(perm) // ... or fifo && !S_ISSOCK(perm) // ... or socket -- cgit From 365b865d6b92f3035e95ddbc1a7d111413cbe141 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Feb 2025 17:13:47 +0800 Subject: vim-patch:9.1.1141: Misplaced comment in readfile() Problem: Misplaced comment in readfile(). (after v9.1.1139) Solution: Move the comment above S_ISDIR(). (zeertzjq) closes: vim/vim#16714 https://github.com/vim/vim/commit/b8989fb860808bbcb0e90b2ba597f66a092277d8 --- src/nvim/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 7c41c84838..b79ecf22d7 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -355,8 +355,6 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, if (!read_stdin && fname != NULL) { perm = os_getperm(fname); - // On Unix it is possible to read a directory, so we have to - // check for it before os_open(). } #ifdef OPEN_CHR_FILES @@ -372,6 +370,8 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, && !(IS_CHR_DEV(perm, fname)) // ... or a character special file named /dev/fd/ ) { + // On Unix it is possible to read a directory, so we have to + // check for it before os_open(). if (S_ISDIR(perm)) { if (!silent) { filemess(curbuf, fname, _(msg_is_a_directory)); -- cgit