diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-09-14 18:13:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-14 09:13:34 -0700 |
| commit | 0a83017fe95df0290adb98ec6bf457b96a3fab17 (patch) | |
| tree | 41362f11095eff22795474e035c5d91d3fb4a7d8 /src | |
| parent | 516775e9d84c5eda9c1d014ff052132737361d90 (diff) | |
| download | rneovim-0a83017fe95df0290adb98ec6bf457b96a3fab17.tar.gz rneovim-0a83017fe95df0290adb98ec6bf457b96a3fab17.tar.bz2 rneovim-0a83017fe95df0290adb98ec6bf457b96a3fab17.zip | |
refactor: format files with uncrustify #15663
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/event/libuv_process.c | 7 | ||||
| -rw-r--r-- | src/nvim/event/loop.c | 1 | ||||
| -rw-r--r-- | src/nvim/event/multiqueue.c | 7 | ||||
| -rw-r--r-- | src/nvim/event/process.c | 74 | ||||
| -rw-r--r-- | src/nvim/event/rstream.c | 28 | ||||
| -rw-r--r-- | src/nvim/event/socket.c | 38 | ||||
| -rw-r--r-- | src/nvim/event/stream.c | 9 | ||||
| -rw-r--r-- | src/nvim/event/time.c | 4 | ||||
| -rw-r--r-- | src/nvim/event/wstream.c | 12 | ||||
| -rw-r--r-- | src/nvim/os/dl.c | 36 | ||||
| -rw-r--r-- | src/nvim/os/env.c | 78 | ||||
| -rw-r--r-- | src/nvim/os/fileio.c | 36 | ||||
| -rw-r--r-- | src/nvim/os/fs.c | 125 | ||||
| -rw-r--r-- | src/nvim/os/input.c | 53 | ||||
| -rw-r--r-- | src/nvim/os/os_win_console.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/process.c | 6 | ||||
| -rw-r--r-- | src/nvim/os/pty_conpty_win.c | 108 | ||||
| -rw-r--r-- | src/nvim/os/pty_process_unix.c | 12 | ||||
| -rw-r--r-- | src/nvim/os/pty_process_win.c | 89 | ||||
| -rw-r--r-- | src/nvim/os/shell.c | 85 | ||||
| -rw-r--r-- | src/nvim/os/signal.c | 87 | ||||
| -rw-r--r-- | src/nvim/os/stdpaths.c | 9 | ||||
| -rw-r--r-- | src/nvim/os/time.c | 12 | ||||
| -rw-r--r-- | src/nvim/os/users.c | 3 | ||||
| -rw-r--r-- | src/nvim/tui/terminfo.c | 15 |
25 files changed, 432 insertions, 504 deletions
diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index c02f730431..0251ea9957 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -2,14 +2,13 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> - #include <uv.h> +#include "nvim/event/libuv_process.h" #include "nvim/event/loop.h" +#include "nvim/event/process.h" #include "nvim/event/rstream.h" #include "nvim/event/wstream.h" -#include "nvim/event/process.h" -#include "nvim/event/libuv_process.h" #include "nvim/log.h" #include "nvim/macros.h" #include "nvim/os/os.h" @@ -68,7 +67,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) #ifdef WIN32 // pipe must be readable for IOCP to work on Windows. uvproc->uvstdio[1].flags |= proc->overlapped ? - (UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0; + (UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0; #endif uvproc->uvstdio[1].data.stream = STRUCT_CAST(uv_stream_t, &proc->out.uv.pipe); diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index e341513ae1..892c46dd04 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -3,7 +3,6 @@ #include <stdarg.h> #include <stdint.h> - #include <uv.h> #include "nvim/event/loop.h" diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c index f534fc483f..a90cbc4e80 100644 --- a/src/nvim/event/multiqueue.c +++ b/src/nvim/event/multiqueue.c @@ -49,8 +49,6 @@ #include <stdarg.h> #include <stdbool.h> #include <stdint.h> - - #include <uv.h> #include "nvim/event/multiqueue.h" @@ -89,7 +87,7 @@ typedef struct { # include "event/multiqueue.c.generated.h" #endif -static Event NILEVENT = { .handler = NULL, .argv = {NULL} }; +static Event NILEVENT = { .handler = NULL, .argv = { NULL } }; MultiQueue *multiqueue_new_parent(PutCallback put_cb, void *data) { @@ -104,8 +102,7 @@ MultiQueue *multiqueue_new_child(MultiQueue *parent) return multiqueue_new(parent, NULL, NULL); } -static MultiQueue *multiqueue_new(MultiQueue *parent, PutCallback put_cb, - void *data) +static MultiQueue *multiqueue_new(MultiQueue *parent, PutCallback put_cb, void *data) { MultiQueue *rv = xmalloc(sizeof(MultiQueue)); QUEUE_INIT(&rv->headtail); diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 8b366d0f3c..dae4dad16d 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -3,20 +3,19 @@ #include <assert.h> #include <stdlib.h> - #include <uv.h> -#include "nvim/os/shell.h" +#include "nvim/event/libuv_process.h" #include "nvim/event/loop.h" +#include "nvim/event/process.h" #include "nvim/event/rstream.h" #include "nvim/event/wstream.h" -#include "nvim/event/process.h" -#include "nvim/event/libuv_process.h" -#include "nvim/os/process.h" -#include "nvim/os/pty_process.h" #include "nvim/globals.h" -#include "nvim/macros.h" #include "nvim/log.h" +#include "nvim/macros.h" +#include "nvim/os/process.h" +#include "nvim/os/pty_process.h" +#include "nvim/os/shell.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/process.c.generated.h" @@ -62,14 +61,14 @@ int process_spawn(Process *proc, bool in, bool out, bool err) int status; switch (proc->type) { - case kProcessTypeUv: - status = libuv_process_spawn((LibuvProcess *)proc); - break; - case kProcessTypePty: - status = pty_process_spawn((PtyProcess *)proc); - break; - default: - abort(); + case kProcessTypeUv: + status = libuv_process_spawn((LibuvProcess *)proc); + break; + case kProcessTypePty: + status = pty_process_spawn((PtyProcess *)proc); + break; + default: + abort(); } if (status) { @@ -139,9 +138,8 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL } // Wait until all children exit and all close events are processed. - LOOP_PROCESS_EVENTS_UNTIL( - loop, loop->events, -1, - kl_empty(loop->children) && multiqueue_empty(loop->events)); + LOOP_PROCESS_EVENTS_UNTIL(loop, loop->events, -1, + kl_empty(loop->children) && multiqueue_empty(loop->events)); pty_process_teardown(loop); } @@ -189,7 +187,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events) // We can only return if all streams/handles are closed and the job // exited. LOOP_PROCESS_EVENTS_UNTIL(proc->loop, events, -1, - proc->refcount == 1); + proc->refcount == 1); } else { LOOP_PROCESS_EVENTS(proc->loop, events, 0); } @@ -222,16 +220,16 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL proc->exit_signal = SIGTERM; switch (proc->type) { - case kProcessTypeUv: - os_proc_tree_kill(proc->pid, SIGTERM); - break; - case kProcessTypePty: - // close all streams for pty processes to send SIGHUP to the process - process_close_streams(proc); - pty_process_close_master((PtyProcess *)proc); - break; - default: - abort(); + case kProcessTypeUv: + os_proc_tree_kill(proc->pid, SIGTERM); + break; + case kProcessTypePty: + // close all streams for pty processes to send SIGHUP to the process + process_close_streams(proc); + pty_process_close_master((PtyProcess *)proc); + break; + default: + abort(); } // (Re)start timer to verify that stopped process(es) died. @@ -325,14 +323,14 @@ static void process_close(Process *proc) } switch (proc->type) { - case kProcessTypeUv: - libuv_process_close((LibuvProcess *)proc); - break; - case kProcessTypePty: - pty_process_close((PtyProcess *)proc); - break; - default: - abort(); + case kProcessTypeUv: + libuv_process_close((LibuvProcess *)proc); + break; + case kProcessTypePty: + pty_process_close((PtyProcess *)proc); + break; + default: + abort(); } } @@ -369,7 +367,7 @@ static void flush_stream(Process *proc, Stream *stream) // Poll for data and process the generated events. loop_poll_events(proc->loop, 0); if (stream->events) { - multiqueue_process_events(stream->events); + multiqueue_process_events(stream->events); } // Stream can be closed if it is empty. diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index efa56932d2..f070c8179f 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -2,19 +2,18 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> -#include <stdint.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> - #include <uv.h> -#include "nvim/event/rstream.h" #include "nvim/ascii.h" -#include "nvim/vim.h" -#include "nvim/memory.h" +#include "nvim/event/loop.h" +#include "nvim/event/rstream.h" #include "nvim/log.h" +#include "nvim/memory.h" #include "nvim/misc1.h" -#include "nvim/event/loop.h" +#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/rstream.c.generated.h" @@ -160,14 +159,13 @@ static void fread_idle_cb(uv_idle_t *handle) } // Synchronous read - uv_fs_read( - handle->loop, - &req, - stream->fd, - &stream->uvbuf, - 1, - (int64_t) stream->fpos, - NULL); + uv_fs_read(handle->loop, + &req, + stream->fd, + &stream->uvbuf, + 1, + (int64_t)stream->fpos, + NULL); uv_fs_req_cleanup(&req); @@ -178,7 +176,7 @@ static void fread_idle_cb(uv_idle_t *handle) } // no errors (req.result (ssize_t) is positive), it's safe to cast. - size_t nread = (size_t) req.result; + size_t nread = (size_t)req.result; rbuffer_produced(stream->buffer, nread); stream->fpos += nread; invoke_read_cb(stream, nread, false); diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 23228aa63a..7948a7be83 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -3,30 +3,28 @@ #include <assert.h> #include <stdint.h> - #include <uv.h> +#include "nvim/ascii.h" +#include "nvim/charset.h" #include "nvim/event/loop.h" -#include "nvim/event/socket.h" #include "nvim/event/rstream.h" +#include "nvim/event/socket.h" #include "nvim/event/wstream.h" -#include "nvim/os/os.h" -#include "nvim/ascii.h" -#include "nvim/vim.h" -#include "nvim/strings.h" -#include "nvim/path.h" +#include "nvim/log.h" +#include "nvim/macros.h" #include "nvim/main.h" #include "nvim/memory.h" -#include "nvim/macros.h" -#include "nvim/charset.h" -#include "nvim/log.h" +#include "nvim/os/os.h" +#include "nvim/path.h" +#include "nvim/strings.h" +#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/socket.c.generated.h" #endif -int socket_watcher_init(Loop *loop, SocketWatcher *watcher, - const char *endpoint) +int socket_watcher_init(Loop *loop, SocketWatcher *watcher, const char *endpoint) FUNC_ATTR_NONNULL_ALL { xstrlcpy(watcher->addr, endpoint, sizeof(watcher->addr)); @@ -56,9 +54,9 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher, int retval = uv_getaddrinfo(&loop->uv, &request, NULL, addr, port, &(struct addrinfo){ - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - }); + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM, + }); if (retval != 0) { ELOG("Host lookup failed: %s", endpoint); return retval; @@ -106,7 +104,7 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) uv_tcp_getsockname(&watcher->uv.tcp.handle, (struct sockaddr *)&sas, &(int){ sizeof(sas) }); uint16_t port = (uint16_t)( - (sas.ss_family == AF_INET) + (sas.ss_family == AF_INET) ? (STRUCT_CAST(struct sockaddr_in, &sas))->sin_port : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); // v:servername uses the string from watcher->addr @@ -183,7 +181,7 @@ static void connection_cb(uv_stream_t *handle, int status) { SocketWatcher *watcher = handle->data; CREATE_EVENT(watcher->events, connection_event, 2, watcher, - (void *)(uintptr_t)status); + (void *)(uintptr_t)status); } static void close_cb(uv_handle_t *handle) @@ -203,9 +201,8 @@ static void connect_cb(uv_connect_t *req, int status) } } -bool socket_connect(Loop *loop, Stream *stream, - bool is_tcp, const char *address, - int timeout, const char **error) +bool socket_connect(Loop *loop, Stream *stream, bool is_tcp, const char *address, int timeout, + const char **error) { bool success = false; int status; @@ -243,7 +240,6 @@ tcp_retry: uv_tcp_nodelay(tcp, true); uv_tcp_connect(&req, tcp, addrinfo->ai_addr, connect_cb); uv_stream = (uv_stream_t *)tcp; - } else { uv_pipe_t *pipe = &stream->uv.pipe; uv_pipe_init(&loop->uv, pipe, 0); diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index a8ded66ea5..8569b92d56 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -2,15 +2,14 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> -#include <stdio.h> #include <stdbool.h> - +#include <stdio.h> #include <uv.h> +#include "nvim/event/stream.h" #include "nvim/log.h" -#include "nvim/rbuffer.h" #include "nvim/macros.h" -#include "nvim/event/stream.h" +#include "nvim/rbuffer.h" #ifdef WIN32 # include "nvim/os/os_win_console.h" #endif @@ -77,7 +76,7 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) uv_pipe_open(&stream->uv.pipe, fd); stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); #ifdef WIN32 - } + } #endif } } diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c index b7e30e392b..aa7b9cf2a1 100644 --- a/src/nvim/event/time.c +++ b/src/nvim/event/time.c @@ -2,7 +2,6 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <stdint.h> - #include <uv.h> #include "nvim/event/loop.h" @@ -23,8 +22,7 @@ void time_watcher_init(Loop *loop, TimeWatcher *watcher, void *data) watcher->blockable = false; } -void time_watcher_start(TimeWatcher *watcher, time_cb cb, uint64_t timeout, - uint64_t repeat) +void time_watcher_start(TimeWatcher *watcher, time_cb cb, uint64_t timeout, uint64_t repeat) FUNC_ATTR_NONNULL_ALL { watcher->cb = cb; diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index 2baa667e7d..d81ffa5c15 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -2,17 +2,16 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <assert.h> -#include <stdint.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> - #include <uv.h> -#include "nvim/log.h" #include "nvim/event/loop.h" #include "nvim/event/wstream.h" -#include "nvim/vim.h" +#include "nvim/log.h" #include "nvim/memory.h" +#include "nvim/vim.h" #define DEFAULT_MAXMEM 1024 * 1024 * 2000 @@ -117,10 +116,7 @@ err: /// @param cb Pointer to function that will be responsible for freeing /// the buffer data(passing 'free' will work as expected). /// @return The allocated WBuffer instance -WBuffer *wstream_new_buffer(char *data, - size_t size, - size_t refcount, - wbuffer_data_finalizer cb) +WBuffer *wstream_new_buffer(char *data, size_t size, size_t refcount, wbuffer_data_finalizer cb) FUNC_ATTR_NONNULL_ARG(1) { WBuffer *rv = xmalloc(sizeof(WBuffer)); diff --git a/src/nvim/os/dl.c b/src/nvim/os/dl.c index 8483d316f3..b2e3994d10 100644 --- a/src/nvim/os/dl.c +++ b/src/nvim/os/dl.c @@ -7,10 +7,10 @@ #include <stdint.h> #include <uv.h> -#include "nvim/os/dl.h" -#include "nvim/os/os.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/os/dl.h" +#include "nvim/os/os.h" /// possible function prototypes that can be called by os_libcall() /// int -> int @@ -38,12 +38,8 @@ typedef int (*int_int_fn)(int i); /// not NULL. NULL when using `int_out`. /// @param[out] int_out the output integer param /// @return true on success, false on failure -bool os_libcall(const char *libname, - const char *funcname, - const char *argv, - int argi, - char **str_out, - int *int_out) +bool os_libcall(const char *libname, const char *funcname, const char *argv, int argi, + char **str_out, int *int_out) { if (!libname || !funcname) { return false; @@ -53,17 +49,17 @@ bool os_libcall(const char *libname, // open the dynamic loadable library if (uv_dlopen(libname, &lib)) { - EMSG2(_("dlerror = \"%s\""), uv_dlerror(&lib)); - uv_dlclose(&lib); - return false; + EMSG2(_("dlerror = \"%s\""), uv_dlerror(&lib)); + uv_dlclose(&lib); + return false; } // find and load the requested function in the library gen_fn fn; - if (uv_dlsym(&lib, funcname, (void **) &fn)) { - EMSG2(_("dlerror = \"%s\""), uv_dlerror(&lib)); - uv_dlclose(&lib); - return false; + if (uv_dlsym(&lib, funcname, (void **)&fn)) { + EMSG2(_("dlerror = \"%s\""), uv_dlerror(&lib)); + uv_dlclose(&lib); + return false; } // call the library and save the result @@ -71,17 +67,17 @@ bool os_libcall(const char *libname, // exceptions. jmp's on Unix seem to interact trickily with signals as // well. So for now we only support those libraries that are well-behaved. if (str_out) { - str_str_fn sfn = (str_str_fn) fn; - int_str_fn ifn = (int_str_fn) fn; + str_str_fn sfn = (str_str_fn)fn; + int_str_fn ifn = (int_str_fn)fn; const char *res = argv ? sfn(argv) : ifn(argi); // assume that ptr values of NULL, 1 or -1 are illegal - *str_out = (res && (intptr_t) res != 1 && (intptr_t) res != -1) + *str_out = (res && (intptr_t)res != 1 && (intptr_t)res != -1) ? xstrdup(res) : NULL; } else { - str_int_fn sfn = (str_int_fn) fn; - int_int_fn ifn = (int_int_fn) fn; + str_int_fn sfn = (str_int_fn)fn; + int_int_fn ifn = (int_int_fn)fn; *int_out = argv ? sfn(argv) : ifn(argi); } diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 92b5e14824..0fc3f35ffc 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -6,20 +6,20 @@ #include <assert.h> #include <uv.h> -#include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/charset.h" +#include "nvim/eval.h" +#include "nvim/ex_getln.h" #include "nvim/fileio.h" -#include "nvim/os/os.h" +#include "nvim/macros.h" +#include "nvim/map.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/os/os.h" #include "nvim/path.h" -#include "nvim/macros.h" #include "nvim/strings.h" -#include "nvim/eval.h" -#include "nvim/ex_getln.h" #include "nvim/version.h" -#include "nvim/map.h" +#include "nvim/vim.h" #ifdef WIN32 #include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 @@ -206,7 +206,7 @@ size_t os_get_fullenv_size(void) # if defined(HAVE__NSGETENVIRON) char **environ = *_NSGetEnviron(); # else - extern char **environ; + extern char **environ; # endif while (environ[len] != NULL) { @@ -219,7 +219,9 @@ size_t os_get_fullenv_size(void) void os_free_fullenv(char **env) { - if (!env) { return; } + if (!env) { + return; + } for (char **it = env; *it; it++) { XFREE_CLEAR(*it); } @@ -262,7 +264,7 @@ void os_copy_fullenv(char **env, size_t env_size) # if defined(HAVE__NSGETENVIRON) char **environ = *_NSGetEnviron(); # else - extern char **environ; + extern char **environ; # endif for (size_t i = 0; i < env_size && environ[i] != NULL; i++) { @@ -322,7 +324,7 @@ char *os_getenvname_at_index(size_t index) # if defined(HAVE__NSGETENVIRON) char **environ = *_NSGetEnviron(); # else - extern char **environ; + extern char **environ; # endif // check if index is inside the environ array @@ -566,16 +568,12 @@ void expand_env(char_u *src, char_u *dst, int dstlen) /// @param esc Escape spaces in expanded variables /// @param one `srcp` is a single filename /// @param prefix Start again after this (can be NULL) -void expand_env_esc(char_u *restrict srcp, - char_u *restrict dst, - int dstlen, - bool esc, - bool one, +void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, bool esc, bool one, char_u *prefix) FUNC_ATTR_NONNULL_ARG(1, 2) { - char_u *tail; - char_u *var; + char_u *tail; + char_u *var; bool copy_char; bool mustfree; // var was allocated, need to free it later bool at_start = true; // at start of a name @@ -621,7 +619,7 @@ void expand_env_esc(char_u *restrict srcp, while (c-- > 0 && *tail != NUL && *tail != '}') { *var++ = *tail++; } - } else // NOLINT + } else // NOLINT #endif { while (c-- > 0 && *tail != NUL && vim_isIDc(*tail)) { @@ -642,7 +640,7 @@ void expand_env_esc(char_u *restrict srcp, var = (char_u *)vim_getenv((char *)dst); mustfree = true; #if defined(UNIX) - } + } #endif } else if (src[1] == NUL // home directory || vim_ispathsep(src[1]) @@ -673,7 +671,7 @@ void expand_env_esc(char_u *restrict srcp, ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; var = ExpandOne(&xpc, dst, NULL, - WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); + WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); mustfree = true; } #else @@ -687,7 +685,7 @@ void expand_env_esc(char_u *restrict srcp, // If 'shellslash' is set change backslashes to forward slashes. // Can't use slash_adjust(), p_ssl may be set temporarily. if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) { - char_u *p = vim_strsave(var); + char_u *p = vim_strsave(var); if (mustfree) { xfree(var); @@ -701,7 +699,7 @@ void expand_env_esc(char_u *restrict srcp, // If "var" contains white space, escape it with a backslash. // Required for ":e ~/tt" when $HOME includes a space. if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL) { - char_u *p = vim_strsave_escaped(var, (char_u *)" \t"); + char_u *p = vim_strsave_escaped(var, (char_u *)" \t"); if (mustfree) { xfree(var); @@ -721,8 +719,9 @@ void expand_env_esc(char_u *restrict srcp, #if defined(BACKSLASH_IN_FILENAME) && dst[-1] != ':' #endif - && vim_ispathsep(*tail)) + && vim_ispathsep(*tail)) { ++tail; + } dst += c; src = tail; copy_char = false; @@ -826,14 +825,11 @@ static char *remove_tail(char *path, char *pend, char *dirname) /// @param[out] len Location where current directory length should be saved. /// /// @return Next iter argument value or NULL when iteration should stop. -const void *vim_env_iter(const char delim, - const char *const val, - const void *const iter, - const char **const dir, - size_t *const len) +const void *vim_env_iter(const char delim, const char *const val, const void *const iter, + const char **const dir, size_t *const len) FUNC_ATTR_NONNULL_ARG(2, 4, 5) FUNC_ATTR_WARN_UNUSED_RESULT { - const char *varval = (const char *) iter; + const char *varval = (const char *)iter; if (varval == NULL) { varval = val; } @@ -843,7 +839,7 @@ const void *vim_env_iter(const char delim, *len = strlen(varval); return NULL; } else { - *len = (size_t) (dirend - varval); + *len = (size_t)(dirend - varval); return dirend + 1; } } @@ -861,14 +857,11 @@ const void *vim_env_iter(const char delim, /// @param[out] len Location where current directory length should be saved. /// /// @return Next iter argument value or NULL when iteration should stop. -const void *vim_env_iter_rev(const char delim, - const char *const val, - const void *const iter, - const char **const dir, - size_t *const len) +const void *vim_env_iter_rev(const char delim, const char *const val, const void *const iter, + const char **const dir, size_t *const len) FUNC_ATTR_NONNULL_ARG(2, 4, 5) FUNC_ATTR_WARN_UNUSED_RESULT { - const char *varend = (const char *) iter; + const char *varend = (const char *)iter; if (varend == NULL) { varend = val + strlen(val) - 1; } @@ -880,7 +873,7 @@ const void *vim_env_iter_rev(const char delim, return NULL; } else { *dir = colon + 1; - *len = (size_t) (varend - colon); + *len = (size_t)(varend - colon); return colon - 1; } } @@ -955,10 +948,9 @@ char *vim_getenv(const char *name) // Find runtime path relative to the nvim binary: ../share/nvim/runtime if (vim_path == NULL) { vim_get_prefix_from_exepath(exe_name); - if (append_path( - exe_name, - "share" _PATHSEPSTR "nvim" _PATHSEPSTR "runtime" _PATHSEPSTR, - MAXPATHL) == OK) { + if (append_path(exe_name, + "share" _PATHSEPSTR "nvim" _PATHSEPSTR "runtime" _PATHSEPSTR, + MAXPATHL) == OK) { vim_path = exe_name; // -V507 } } @@ -1043,8 +1035,8 @@ char *vim_getenv(const char *name) /// a list of them. /// /// @return length of the string put into dst, does not include NUL byte. -size_t home_replace(const buf_T *const buf, const char_u *src, - char_u *const dst, size_t dstlen, const bool one) +size_t home_replace(const buf_T *const buf, const char_u *src, char_u *const dst, size_t dstlen, + const bool one) FUNC_ATTR_NONNULL_ARG(3) { size_t dirlen = 0; diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index fa359fa32e..1ae6ca4244 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -8,9 +8,9 @@ /// replacement. #include <assert.h> -#include <stddef.h> -#include <stdbool.h> #include <fcntl.h> +#include <stdbool.h> +#include <stddef.h> #include "auto/config.h" @@ -20,13 +20,13 @@ #include <uv.h> -#include "nvim/os/fileio.h" -#include "nvim/memory.h" -#include "nvim/os/os.h" #include "nvim/globals.h" -#include "nvim/rbuffer.h" #include "nvim/macros.h" +#include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/os/fileio.h" +#include "nvim/os/os.h" +#include "nvim/rbuffer.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/fileio.c.generated.h" @@ -44,8 +44,8 @@ /// does not have kFileCreate\*). /// /// @return Error code, or 0 on success. @see os_strerror() -int file_open(FileDescriptor *const ret_fp, const char *const fname, - const int flags, const int mode) +int file_open(FileDescriptor *const ret_fp, const char *const fname, const int flags, + const int mode) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { int os_open_flags = 0; @@ -99,8 +99,7 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, /// FILE_WRITE_ONLY or FILE_READ_ONLY is required. /// /// @return Error code (@see os_strerror()) or 0. Currently always returns 0. -int file_open_fd(FileDescriptor *const ret_fp, const int fd, - const int flags) +int file_open_fd(FileDescriptor *const ret_fp, const int fd, const int flags) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { ret_fp->wr = !!(flags & (kFileCreate @@ -131,8 +130,8 @@ int file_open_fd(FileDescriptor *const ret_fp, const int fd, /// does not have kFileCreate\*). /// /// @return [allocated] Opened file or NULL in case of error. -FileDescriptor *file_open_new(int *const error, const char *const fname, - const int flags, const int mode) +FileDescriptor *file_open_new(int *const error, const char *const fname, const int flags, + const int mode) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { FileDescriptor *const fp = xmalloc(sizeof(*fp)); @@ -152,8 +151,7 @@ FileDescriptor *file_open_new(int *const error, const char *const fname, /// does not have FILE_CREATE\*). /// /// @return [allocated] Opened file or NULL in case of error. -FileDescriptor *file_open_fd_new(int *const error, const int fd, - const int flags) +FileDescriptor *file_open_fd_new(int *const error, const int fd, const int flags) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESU |