aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/CMakeLists.txt3
-rw-r--r--config/config.h.in3
-rw-r--r--runtime/lua/man.lua4
-rw-r--r--src/nvim/fileio.c48
-rw-r--r--src/nvim/os/fs.c16
-rw-r--r--test/functional/plugin/man_spec.lua33
6 files changed, 48 insertions, 59 deletions
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index 4fb44b9a27..82cb4d31ad 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -32,7 +32,6 @@ if(NOT HAVE_SYS_WAIT_H AND UNIX)
endif()
check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_files(termios.h HAVE_TERMIOS_H)
-check_include_files(utime.h HAVE_UTIME_H)
check_include_files(sys/uio.h HAVE_SYS_UIO_H)
# Functions
@@ -53,8 +52,6 @@ check_function_exists(setsid HAVE_SETSID)
check_function_exists(sigaction HAVE_SIGACTION)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(strncasecmp HAVE_STRNCASECMP)
-check_function_exists(utime HAVE_UTIME)
-check_function_exists(utimes HAVE_UTIMES)
# Symbols
check_symbol_exists(FD_CLOEXEC "fcntl.h" HAVE_FD_CLOEXEC)
diff --git a/config/config.h.in b/config/config.h.in
index 15881c4430..40baff95e8 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -38,9 +38,6 @@
#cmakedefine HAVE_SYS_UTSNAME_H
#cmakedefine HAVE_SYS_WAIT_H
#cmakedefine HAVE_TERMIOS_H
-#cmakedefine HAVE_UTIME
-#cmakedefine HAVE_UTIME_H
-#cmakedefine HAVE_UTIMES
#cmakedefine HAVE_WORKING_LIBINTL
#cmakedefine HAVE_WSL
#cmakedefine UNIX
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index 1da8ed85fc..ba6b9d09c9 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -107,7 +107,9 @@ local function highlight_line(line, linenr)
-- followed by '[', then a series of parameter and intermediate bytes in
-- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117)
local sgr = prev_char:match("^%[([\032-\063]*)m$")
- if sgr then
+ -- Ignore escape sequences with : characters, as specified by ITU's T.416
+ -- Open Document Architecture and interchange format.
+ if sgr and not string.find(sgr, ":") then
local match
while sgr and #sgr > 0 do
-- Match against SGR parameters, which may be separated by ';'
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index f2a664288b..645812eb75 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -58,10 +58,6 @@
#include "nvim/os/time.h"
#include "nvim/os/input.h"
-#if defined(HAVE_UTIME) && defined(HAVE_UTIME_H)
-# include <utime.h> /* for struct utimbuf */
-#endif
-
#define BUFSIZE 8192 /* size of normal write buffer */
#define SMBUFSIZE 256 /* size of emergency write buffer */
@@ -190,10 +186,6 @@ struct bw_info {
# include "fileio.c.generated.h"
#endif
-#ifdef UNIX
-#endif
-
-
static char *e_auchangedbuf = N_(
"E812: Autocommands changed buffer or buffer name");
@@ -2198,34 +2190,6 @@ static void check_marks_read(void)
curbuf->b_marks_read = true;
}
-#ifdef UNIX
-static void
-set_file_time (
- char_u *fname,
- time_t atime, /* access time */
- time_t mtime /* modification time */
-)
-{
-# if defined(HAVE_UTIME) && defined(HAVE_UTIME_H)
- struct utimbuf buf;
-
- buf.actime = atime;
- buf.modtime = mtime;
- (void)utime((char *)fname, &buf);
-# else
-# if defined(HAVE_UTIMES)
- struct timeval tvp[2];
-
- tvp[0].tv_sec = atime;
- tvp[0].tv_usec = 0;
- tvp[1].tv_sec = mtime;
- tvp[1].tv_usec = 0;
- (void)utimes((char *)fname, (const struct timeval *)&tvp);
-# endif
-# endif
-}
-#endif /* UNIX */
-
/*
* buf_write() - write to file "fname" lines "start" through "end"
*
@@ -2887,9 +2851,9 @@ buf_write (
}
#ifdef UNIX
- set_file_time(backup,
- file_info_old.stat.st_atim.tv_sec,
- file_info_old.stat.st_mtim.tv_sec);
+ os_file_settime((char *)backup,
+ file_info_old.stat.st_atim.tv_sec,
+ file_info_old.stat.st_mtim.tv_sec);
#endif
#ifdef HAVE_ACL
mch_set_acl(backup, acl);
@@ -3572,9 +3536,9 @@ restore_backup:
vim_rename(backup, (char_u *)org);
XFREE_CLEAR(backup); // don't delete the file
#ifdef UNIX
- set_file_time((char_u *)org,
- file_info_old.stat.st_atim.tv_sec,
- file_info_old.stat.st_mtim.tv_sec);
+ os_file_settime(org,
+ file_info_old.stat.st_atim.tv_sec,
+ file_info_old.stat.st_mtim.tv_sec);
#endif
}
}
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index d5500b230c..1ecca87cde 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -746,6 +746,22 @@ bool os_path_exists(const char_u *path)
return os_stat((char *)path, &statbuf) == kLibuvSuccess;
}
+/// Sets file access and modification times.
+///
+/// @see POSIX utime(2)
+///
+/// @param path File path.
+/// @param atime Last access time.
+/// @param mtime Last modification time.
+///
+/// @return 0 on success, or negative error code.
+int os_file_settime(const char *path, double atime, double mtime)
+{
+ int r;
+ RUN_UV_FS_FUNC(r, uv_fs_utime, path, atime, mtime, NULL);
+ return r;
+}
+
/// Check if a file is readable.
///
/// @return true if `name` is readable, otherwise false.
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index e5da7932a5..b25bd7e85a 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -1,23 +1,19 @@
local helpers = require('test.functional.helpers')(after_each)
local plugin_helpers = require('test.functional.plugin.helpers')
-
local Screen = require('test.functional.ui.screen')
-
local command, eval, rawfeed = helpers.command, helpers.eval, helpers.rawfeed
-
-before_each(function()
- plugin_helpers.reset()
- helpers.clear()
- command('syntax on')
- command('set filetype=man')
-end)
+local clear = helpers.clear
describe(':Man', function()
describe('man.lua: highlight_line()', function()
local screen
before_each(function()
- command('syntax off') -- Ignore syntax groups
+ plugin_helpers.reset()
+ clear()
+ command('syntax on')
+ command('set filetype=man')
+ command('syntax off') -- Ignore syntax groups
screen = Screen.new(52, 5)
screen:set_default_attr_ids({
b = { bold = true },
@@ -131,5 +127,22 @@ describe(':Man', function()
|
]])
end)
+
+ it('handles : characters in input', function()
+ rawfeed([[
+ i<C-v><C-[>[40m 0 <C-v><C-[>[41m 1 <C-v><C-[>[42m 2 <C-v><C-[>[43m 3
+ <C-v><C-[>[44m 4 <C-v><C-[>[45m 5 <C-v><C-[>[46m 6 <C-v><C-[>[47m 7 <C-v><C-[>[100m 8 <C-v><C-[>[101m 9
+ <C-v><C-[>[102m 10 <C-v><C-[>[103m 11 <C-v><C-[>[104m 12 <C-v><C-[>[105m 13 <C-v><C-[>[106m 14 <C-v><C-[>[107m 15
+ <C-v><C-[>[48:5:16m 16 <ESC>]])
+ eval('man#init_pager()')
+
+ screen:expect([[
+ ^ 0 1 2 3 |
+ 4 5 6 7 8 9 |
+ 10 11 12 13 14 15 |
+ 16 |
+ |
+ ]])
+ end)
end)
end)