diff options
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/fs.c | 2 | ||||
-rw-r--r-- | src/nvim/os/pty_process_unix.c | 4 | ||||
-rw-r--r-- | src/nvim/os/pty_process_unix.h | 1 | ||||
-rw-r--r-- | src/nvim/os/pty_process_win.c | 24 | ||||
-rw-r--r-- | src/nvim/os/pty_process_win.h | 1 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 8 | ||||
-rw-r--r-- | src/nvim/os/time.c | 17 |
7 files changed, 35 insertions, 22 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index a3bef3389c..d0fa74a77f 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -471,8 +471,6 @@ FILE *os_fopen(const char *path, const char *flags) abort(); } } - // Per open(2) manpage. - assert((iflags|O_RDONLY) || (iflags|O_WRONLY) || (iflags|O_RDWR)); // Per fopen(3) manpage: default to 0666, it will be umask-adjusted. int fd = os_open(path, iflags, 0666); if (fd < 0) { diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index d794969ab5..36d6dbe2db 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -175,7 +175,7 @@ static void init_child(PtyProcess *ptyproc) Process *proc = (Process *)ptyproc; if (proc->cwd && os_chdir(proc->cwd) != 0) { - ELOG("chdir failed: %s", strerror(errno)); + ELOG("chdir(%s) failed: %s", proc->cwd, strerror(errno)); return; } @@ -184,7 +184,7 @@ static void init_child(PtyProcess *ptyproc) assert(proc->env); environ = tv_dict_to_env(proc->env); execvp(prog, proc->argv); - ELOG("execvp failed: %s: %s", strerror(errno), prog); + ELOG("execvp(%s) failed: %s", prog, strerror(errno)); _exit(122); // 122 is EXEC_FAILED in the Vim source. } diff --git a/src/nvim/os/pty_process_unix.h b/src/nvim/os/pty_process_unix.h index 8c822eafad..765490b92b 100644 --- a/src/nvim/os/pty_process_unix.h +++ b/src/nvim/os/pty_process_unix.h @@ -7,7 +7,6 @@ typedef struct pty_process { Process process; - char *term_name; uint16_t width, height; struct winsize winsize; int tty_fd; diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 52d2f84ace..2bf73d08e6 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -203,11 +203,13 @@ int pty_process_spawn(PtyProcess *ptyproc) cleanup: if (status) { // In the case of an error of MultiByteToWideChar or CreateProcessW. - ELOG("pty_process_spawn: %s: error code: %d", emsg, status); + ELOG("pty_process_spawn(%s): %s: error code: %d", + proc->argv[0], emsg, status); status = os_translate_sys_error(status); } else if (err != NULL) { status = (int)winpty_error_code(err); - ELOG("pty_process_spawn: %s: error code: %d", emsg, status); + ELOG("pty_process_spawn(%s): %s: error code: %d", + proc->argv[0], emsg, status); status = translate_winpty_error(status); } winpty_error_free(err); @@ -343,19 +345,17 @@ static int build_cmd_line(char **argv, wchar_t **cmd_line, bool is_cmdexe) utf8_cmd_line_len += argc; char *utf8_cmd_line = xmalloc(utf8_cmd_line_len); *utf8_cmd_line = NUL; - while (1) { - QUEUE *head = QUEUE_HEAD(&args_q); - QUEUE_REMOVE(head); - ArgNode *arg_node = QUEUE_DATA(head, ArgNode, node); + QUEUE *q; + QUEUE_FOREACH(q, &args_q, { + ArgNode *arg_node = QUEUE_DATA(q, ArgNode, node); xstrlcat(utf8_cmd_line, arg_node->arg, utf8_cmd_line_len); xfree(arg_node->arg); xfree(arg_node); - if (QUEUE_EMPTY(&args_q)) { - break; - } else { + QUEUE_REMOVE(q); + if (!QUEUE_EMPTY(&args_q)) { xstrlcat(utf8_cmd_line, " ", utf8_cmd_line_len); } - } + }) int result = utf8_to_utf16(utf8_cmd_line, -1, cmd_line); xfree(utf8_cmd_line); @@ -507,11 +507,11 @@ static int build_env_block(dict_T *denv, wchar_t **env_block) *env_block = xmalloc(sizeof(**env_block) * env_block_len); wchar_t *pos = *env_block; - QUEUE_FOREACH(q, &env_q) { + QUEUE_FOREACH(q, &env_q, { EnvNode *env_node = QUEUE_DATA(q, EnvNode, node); memcpy(pos, env_node->str, env_node->len * sizeof(*pos)); pos += env_node->len; - } + }) *pos = L'\0'; diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h index f8ec79a3d6..3f6cc58e3e 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_process_win.h @@ -15,7 +15,6 @@ typedef enum { typedef struct pty_process { Process process; - char *term_name; uint16_t width, height; union { winpty_t *winpty; diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index b5d890bf52..2974245857 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -123,7 +123,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, int shell_style = STYLE_ECHO; int check_spaces; static bool did_find_nul = false; - bool ampersent = false; + bool ampersand = false; // vimglob() function to define for Posix shell static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >"; @@ -245,7 +245,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, p--; } if (*p == '&') { // remove trailing '&' - ampersent = true; + ampersand = true; *p = ' '; } STRCAT(command, ">"); @@ -309,7 +309,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, shellopts |= kShellOptHideMess; } - if (ampersent) { + if (ampersand) { STRCAT(command, "&"); // put the '&' after the redirection } @@ -331,7 +331,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, // When running in the background, give it some time to create the temp // file, but don't wait for it to finish. - if (ampersent) { + if (ampersand) { os_delay(10L, true); } diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index 5cf628935f..9ea74716aa 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -62,6 +62,7 @@ uint64_t os_now(void) /// @param ignoreinput If true, only SIGINT (CTRL-C) can interrupt. void os_delay(uint64_t ms, bool ignoreinput) { + DLOG("%" PRIu64 " ms", ms); if (ignoreinput) { if (ms > INT_MAX) { ms = INT_MAX; @@ -196,6 +197,22 @@ char *os_ctime(char *result, size_t result_len) return os_ctime_r(&rawtime, result, result_len); } +/// Portable version of POSIX strptime() +/// +/// @param str[in] string to convert +/// @param format[in] format to parse "str" +/// @param tm[out] time representation of "str" +/// @return Pointer to first unprocessed character or NULL +char *os_strptime(const char *str, const char *format, struct tm *tm) + FUNC_ATTR_NONNULL_ALL +{ +#ifdef HAVE_STRPTIME + return strptime(str, format, tm); +#else + return NULL; +#endif +} + /// Obtains the current Unix timestamp. /// /// @return Seconds since epoch. |