aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorckelsel <ckelsel@hotmail.com>2017-08-12 08:28:10 +0800
committerckelsel <ckelsel@hotmail.com>2017-08-12 08:28:10 +0800
commitd59e9a2c25c563e3460b1eeb31ab4d5971097331 (patch)
tree26f42a8d349db94f9faf87846aaae116582a76e7 /src
parent9a5d309b5743d70832b4daedcea934af5e6cc127 (diff)
parentf2fd5afb48786c4272105b0adda6977ee1fd6f2e (diff)
downloadrneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.tar.gz
rneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.tar.bz2
rneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r--src/nvim/README.md5
-rw-r--r--src/nvim/fileio.c11
-rw-r--r--src/nvim/log.c25
-rw-r--r--src/nvim/log.h1
-rw-r--r--src/nvim/os/fs.c9
-rw-r--r--src/nvim/regexp_nfa.c16
-rw-r--r--src/nvim/tui/tui.c2
-rw-r--r--src/nvim/version.c2
8 files changed, 39 insertions, 32 deletions
diff --git a/src/nvim/README.md b/src/nvim/README.md
index 1c1c3c364e..0caf71e2c5 100644
--- a/src/nvim/README.md
+++ b/src/nvim/README.md
@@ -11,8 +11,9 @@ Logs
Low-level log messages sink to `$NVIM_LOG_FILE`.
-You can use `LOG_CALLSTACK()` anywhere in the source to log the current
-stacktrace. (Currently Linux-only.)
+You can use `LOG_CALLSTACK();` anywhere in the source to log the current
+stacktrace. To log in an alternate file, e.g. stderr, use
+`LOG_CALLSTACK_TO_FILE(FILE*)`. (Currently Linux-only.)
UI events are logged at level 0 (`DEBUG_LOG_LEVEL`).
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 643020df5e..feb16f44d4 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2570,11 +2570,9 @@ buf_write (
perm = -1;
}
}
-#else /* win32 */
- /*
- * Check for a writable device name.
- */
- c = os_nodetype((char *)fname);
+#else // win32
+ // Check for a writable device name.
+ c = fname == NULL ? NODE_OTHER : os_nodetype((char *)fname);
if (c == NODE_OTHER) {
SET_ERRMSG_NUM("E503", _("is not a file or writable device"));
goto fail;
@@ -2594,9 +2592,8 @@ buf_write (
if (overwriting) {
os_fileinfo((char *)fname, &file_info_old);
}
-
}
-#endif /* !UNIX */
+#endif // !UNIX
if (!device && !newfile) {
/*
diff --git a/src/nvim/log.c b/src/nvim/log.c
index b64aef3cac..3baf0b2ebd 100644
--- a/src/nvim/log.c
+++ b/src/nvim/log.c
@@ -178,7 +178,8 @@ FILE *open_log_file(void)
}
#ifdef HAVE_EXECINFO_BACKTRACE
-void log_callstack(const char *const func_name, const int line_num)
+void log_callstack_to_file(FILE *log_file, const char *const func_name,
+ const int line_num)
{
void *trace[100];
int trace_size = backtrace(trace, ARRAY_SIZE(trace));
@@ -190,8 +191,6 @@ void log_callstack(const char *const func_name, const int line_num)
}
assert(24 + exepathlen < IOSIZE); // Must fit in `cmdbuf` below.
- do_log(DEBUG_LOG_LEVEL, func_name, line_num, true, "trace:");
-
char cmdbuf[IOSIZE + (20 * ARRAY_SIZE(trace))];
snprintf(cmdbuf, sizeof(cmdbuf), "addr2line -e %s -f -p", exepath);
for (int i = 1; i < trace_size; i++) {
@@ -202,12 +201,8 @@ void log_callstack(const char *const func_name, const int line_num)
// Now we have a command string like:
// addr2line -e /path/to/exe -f -p 0x123 0x456 ...
- log_lock();
- FILE *log_file = open_log_file();
- if (log_file == NULL) {
- goto end;
- }
-
+ do_log_to_file(log_file, DEBUG_LOG_LEVEL, func_name, line_num, true,
+ "trace:");
FILE *fp = popen(cmdbuf, "r");
char linebuf[IOSIZE];
while (fgets(linebuf, sizeof(linebuf) - 1, fp) != NULL) {
@@ -218,6 +213,18 @@ void log_callstack(const char *const func_name, const int line_num)
if (log_file != stderr && log_file != stdout) {
fclose(log_file);
}
+}
+
+void log_callstack(const char *const func_name, const int line_num)
+{
+ log_lock();
+ FILE *log_file = open_log_file();
+ if (log_file == NULL) {
+ goto end;
+ }
+
+ log_callstack_to_file(log_file, func_name, line_num);
+
end:
log_unlock();
}
diff --git a/src/nvim/log.h b/src/nvim/log.h
index 743a8d17aa..5064d9333b 100644
--- a/src/nvim/log.h
+++ b/src/nvim/log.h
@@ -63,6 +63,7 @@
#ifdef HAVE_EXECINFO_BACKTRACE
# define LOG_CALLSTACK() log_callstack(__func__, __LINE__)
+# define LOG_CALLSTACK_TO_FILE(fp) log_callstack_to_file(fp, __func__, __LINE__)
#endif
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 9e3025cf89..6ac9d682d7 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -605,8 +605,11 @@ int os_fsync(int fd)
///
/// @return libuv return code.
static int os_stat(const char *name, uv_stat_t *statbuf)
- FUNC_ATTR_NONNULL_ALL
+ FUNC_ATTR_NONNULL_ARG(2)
{
+ if (!name) {
+ return UV_ENOENT;
+ }
uv_fs_t request;
int result = uv_fs_stat(&fs_loop, &request, name, NULL);
*statbuf = request.statbuf;
@@ -618,7 +621,6 @@ static int os_stat(const char *name, uv_stat_t *statbuf)
///
/// @return libuv error code on error.
int32_t os_getperm(const char *name)
- FUNC_ATTR_NONNULL_ALL
{
uv_stat_t statbuf;
int stat_result = os_stat(name, &statbuf);
@@ -657,7 +659,6 @@ int os_fchown(int fd, uv_uid_t owner, uv_gid_t group)
///
/// @return `true` if `path` exists
bool os_path_exists(const char_u *path)
- FUNC_ATTR_NONNULL_ALL
{
uv_stat_t statbuf;
return os_stat((char *)path, &statbuf) == kLibuvSuccess;
@@ -847,7 +848,7 @@ int os_remove(const char *path)
/// @param[out] file_info Pointer to a FileInfo to put the information in.
/// @return `true` on success, `false` for failure.
bool os_fileinfo(const char *path, FileInfo *file_info)
- FUNC_ATTR_NONNULL_ALL
+ FUNC_ATTR_NONNULL_ARG(2)
{
return os_stat(path, &(file_info->stat)) == kLibuvSuccess;
}
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 5d708febea..93ba9ce097 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -56,13 +56,13 @@ enum {
NFA_RANGE_MIN, /* low end of a range */
NFA_RANGE_MAX, /* high end of a range */
- NFA_CONCAT, /* concatenate two previous items (postfix
- * only) */
- NFA_OR, /* \| (postfix only) */
- NFA_STAR, /* greedy * (posfix only) */
- NFA_STAR_NONGREEDY, /* non-greedy * (postfix only) */
- NFA_QUEST, /* greedy \? (postfix only) */
- NFA_QUEST_NONGREEDY, /* non-greedy \? (postfix only) */
+ NFA_CONCAT, // concatenate two previous items (postfix
+ // only)
+ NFA_OR, // \| (postfix only)
+ NFA_STAR, // greedy * (postfix only)
+ NFA_STAR_NONGREEDY, // non-greedy * (postfix only)
+ NFA_QUEST, // greedy \? (postfix only)
+ NFA_QUEST_NONGREEDY, // non-greedy \? (postfix only)
NFA_BOL, /* ^ Begin line */
NFA_EOL, /* $ End line */
@@ -1988,7 +1988,7 @@ static int nfa_regpiece(void)
// The engine is very inefficient (uses too many states) when the maximum
// is much larger than the minimum and when the maximum is large. Bail out
// if we can use the other engine.
- if ((nfa_re_flags & RE_AUTO) && (maxval > minval + 200 || maxval > 500)) {
+ if ((nfa_re_flags & RE_AUTO) && (maxval > 500 || maxval > minval + 200)) {
return FAIL;
}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index c29ec09638..97a0398c80 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -45,7 +45,7 @@
#define OUTBUF_SIZE 0xffff
#define TOO_MANY_EVENTS 1000000
-#define STARTS_WITH(str, prefix) (strlen(term) >= (sizeof(prefix) - 1) \
+#define STARTS_WITH(str, prefix) (strlen(str) >= (sizeof(prefix) - 1) \
&& 0 == memcmp((str), (prefix), sizeof(prefix) - 1))
#define TMUX_WRAP(is_tmux, seq) ((is_tmux) \
? "\x1bPtmux;\x1b" seq "\x1b\\" : seq)
diff --git a/src/nvim/version.c b/src/nvim/version.c
index fa179b4f63..72af7dbafd 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -787,7 +787,7 @@ static const int included_patches[] = {
168,
167,
// 166,
- // 165,
+ 165,
// 164,
// 163 NA
// 162 NA