diff options
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/process.c | 16 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 41 | ||||
-rw-r--r-- | src/nvim/os/stdpaths.c | 2 |
3 files changed, 30 insertions, 29 deletions
diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index e23ba8a4ee..a67e7487eb 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -12,12 +12,16 @@ # include <tlhelp32.h> // for CreateToolhelp32Snapshot #endif -#if defined(__FreeBSD__) // XXX: OpenBSD, NetBSD ? +#if defined(__FreeBSD__) // XXX: OpenBSD ? # include <string.h> # include <sys/types.h> # include <sys/user.h> #endif +#if defined(__NetBSD__) || defined(__OpenBSD__) +# include <sys/param.h> +#endif + #if defined(__APPLE__) || defined(BSD) # include <sys/sysctl.h> # include <pwd.h> @@ -155,7 +159,13 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) # define KP_PID(o) o.p_pid # define KP_PPID(o) o.p_ppid # endif +# ifdef __NetBSD__ + static int name[] = { + CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0, (int)(sizeof(struct kinfo_proc2)), 0 + }; +# else static int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 }; +# endif // Get total process count. size_t len = 0; @@ -165,7 +175,11 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) } // Get ALL processes. +# ifdef __NetBSD__ + struct kinfo_proc2 *p_list = xmalloc(len); +# else struct kinfo_proc *p_list = xmalloc(len); +# endif rv = sysctl(name, ARRAY_SIZE(name) - 1, p_list, &len, NULL, 0); if (rv) { xfree(p_list); diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index f650a51fe7..04f59d7522 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -136,7 +136,7 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args) xfree(input.data); if (output) { - (void)write_output(output, nread, true, true); + (void)write_output(output, nread, true); xfree(output); } @@ -388,10 +388,10 @@ static bool out_data_decide_throttle(size_t size) pulse_msg[1] = (tick == 0 || 1 == tick) ? ' ' : '.'; pulse_msg[2] = (tick == 0 || 1 == tick || 2 == tick) ? ' ' : '.'; if (visit == 1) { - screen_del_lines(0, 0, 1, (int)Rows, NULL); + msg_putchar('\n'); } - int lastrow = (int)Rows - 1; - screen_puts_len((char_u *)pulse_msg, ARRAY_SIZE(pulse_msg), lastrow, 0, 0); + msg_putchar('\r'); // put cursor at start of line + msg_puts(pulse_msg); ui_flush(); return true; } @@ -609,28 +609,20 @@ static void read_input(DynamicBuffer *buf) } } -static size_t write_output(char *output, size_t remaining, bool to_buffer, - bool eof) +static size_t write_output(char *output, size_t remaining, bool eof) { if (!output) { return 0; } - char replacement_NUL = to_buffer ? NL : 1; char *start = output; size_t off = 0; - int lastrow = (int)Rows - 1; while (off < remaining) { if (output[off] == NL) { // Insert the line - if (to_buffer) { - output[off] = NUL; - ml_append(curwin->w_cursor.lnum++, (char_u *)output, (int)off + 1, - false); - } else { - screen_del_lines(0, 0, 1, (int)Rows, NULL); - screen_puts_len((char_u *)output, (int)off, lastrow, 0, 0); - } + output[off] = NUL; + ml_append(curwin->w_cursor.lnum++, (char_u *)output, (int)off + 1, + false); size_t skip = off + 1; output += skip; remaining -= skip; @@ -640,24 +632,19 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, if (output[off] == NUL) { // Translate NUL to NL - output[off] = replacement_NUL; + output[off] = NL; } off++; } if (eof) { if (remaining) { - if (to_buffer) { - // append unfinished line - ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false); - // remember that the NL was missing - curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; - } else { - screen_del_lines(0, 0, 1, (int)Rows, NULL); - screen_puts_len((char_u *)output, (int)remaining, lastrow, 0, 0); - } + // append unfinished line + ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false); + // remember that the NL was missing + curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; output += remaining; - } else if (to_buffer) { + } else { curbuf->b_no_eol_lnum = 0; } } diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index a41fb7c621..866a005228 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -88,7 +88,7 @@ char *stdpaths_get_xdg_var(const XDGVarType idx) /// /// In WIN32 get_xdg_home(kXDGDataHome) returns `{xdg_directory}/nvim-data` to /// avoid storing configuration and data files in the same path. -static char *get_xdg_home(const XDGVarType idx) +char *get_xdg_home(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { char *dir = stdpaths_get_xdg_var(idx); |