mirror of
https://github.com/neovim/neovim.git
synced 2026-07-13 04:40:42 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -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`).
|
||||
|
||||
|
||||
@@ -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) {
|
||||
/*
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -787,7 +787,7 @@ static const int included_patches[] = {
|
||||
168,
|
||||
167,
|
||||
// 166,
|
||||
// 165,
|
||||
165,
|
||||
// 164,
|
||||
// 163 NA
|
||||
// 162 NA
|
||||
|
||||
@@ -862,6 +862,11 @@ describe('fs.c', function()
|
||||
end
|
||||
|
||||
describe('os_fileinfo', function()
|
||||
itp('returns false if path=NULL', function()
|
||||
local file_info = file_info_new()
|
||||
assert.is_false((fs.os_fileinfo(nil, file_info)))
|
||||
end)
|
||||
|
||||
itp('returns false if given a non-existing file', function()
|
||||
local file_info = file_info_new()
|
||||
assert.is_false((fs.os_fileinfo('/non-existent', file_info)))
|
||||
|
||||
Reference in New Issue
Block a user