From 04cdea5f4ac49fa62cc4091a5c26791b80b4cc4c Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index e907c45e79..eae3b4af1a 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -956,7 +956,7 @@ void ex_mkrc(exarg_T *eap) } // When using 'viewdir' may have to create the directory. - if (using_vdir && !os_isdir((char *)p_vdir)) { + if (using_vdir && !os_isdir(p_vdir)) { vim_mkdir_emsg((const char *)p_vdir, 0755); } @@ -1095,7 +1095,7 @@ static char *get_view_file(int c) len++; } } - char *retval = xmalloc(strlen(sname) + len + STRLEN(p_vdir) + 9); + char *retval = xmalloc(strlen(sname) + len + strlen(p_vdir) + 9); STRCPY(retval, p_vdir); add_pathsep(retval); char *s = retval + strlen(retval); -- cgit From 784e498c4a9c1f03266ced5ec3f55c3a6c94b80d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:47:44 +0200 Subject: refactor: clang-tidy fixes to silence clangd warning (#20683) * refactor: readability-uppercase-literal-suffix * refactor: readability-named-parameter * refactor: bugprone-suspicious-string-compare * refactor: google-readability-casting * refactor: readability-redundant-control-flow * refactor: bugprone-too-small-loop-variable * refactor: readability-non-const-parameter * refactor: readability-avoid-const-params-in-decls * refactor: google-readability-todo * refactor: readability-inconsistent-declaration-parameter-name * refactor: bugprone-suspicious-missing-comma * refactor: remove noisy or slow warnings --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index eae3b4af1a..887ba5400a 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -240,7 +240,7 @@ static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigne } /// @return the buffer name for `buf`. -static char *ses_get_fname(buf_T *buf, unsigned *flagp) +static char *ses_get_fname(buf_T *buf, const unsigned *flagp) { // Use the short file name if the current directory is known at the time // the session file will be sourced. -- cgit From 66360675cf4d091b7460e4a8e1435c13216c1929 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Sep 2022 17:12:44 +0200 Subject: build: allow IWYU to fix includes for all .c files Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers. --- src/nvim/ex_session.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 887ba5400a..2a80537a50 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -9,32 +9,36 @@ #include #include +#include #include -#include +#include #include #include "nvim/arglist.h" #include "nvim/ascii.h" #include "nvim/buffer.h" -#include "nvim/cursor.h" -#include "nvim/edit.h" #include "nvim/eval.h" +#include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/ex_session.h" #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/garray.h" +#include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/keycodes.h" +#include "nvim/macros.h" #include "nvim/mapping.h" -#include "nvim/move.h" +#include "nvim/mark_defs.h" +#include "nvim/memory.h" +#include "nvim/message.h" #include "nvim/option.h" -#include "nvim/os/input.h" #include "nvim/os/os.h" -#include "nvim/os/time.h" #include "nvim/path.h" +#include "nvim/pos.h" #include "nvim/runtime.h" +#include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit From 149209400383c673fdb4fdd1c9a7639139f17936 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 9 Jan 2023 14:13:06 +0100 Subject: refactor: replace char_u with char 17 - remove STRLCPY (#21235) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 2a80537a50..7bed8d5288 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -1007,7 +1007,7 @@ void ex_mkrc(exarg_T *eap) // // Change to session file's dir. // - if (os_dirname(dirnow, MAXPATHL) == FAIL + if (os_dirname((char *)dirnow, MAXPATHL) == FAIL || os_chdir((char *)dirnow) != 0) { *dirnow = NUL; } -- cgit From ef6750332008b7b61dde9eeab0da454bf3323ebb Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 10 Jan 2023 03:28:01 +0100 Subject: refactor: replace char_u with char 19 (#21241) * refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_session.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 7bed8d5288..48d52fa5f9 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -215,22 +215,22 @@ static int ses_do_win(win_T *wp) /// @returns FAIL if writing fails. static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp) { - char_u *buf = NULL; - char_u *s; + char *buf = NULL; + char *s; if (fprintf(fd, "%s\n%s\n", cmd, "%argdel") < 0) { return FAIL; } for (int i = 0; i < gap->ga_len; i++) { // NULL file names are skipped (only happens when out of memory). - s = (char_u *)alist_name(&((aentry_T *)gap->ga_data)[i]); + s = alist_name(&((aentry_T *)gap->ga_data)[i]); if (s != NULL) { if (fullname) { buf = xmalloc(MAXPATHL); - (void)vim_FullName((char *)s, (char *)buf, MAXPATHL, false); + (void)vim_FullName(s, buf, MAXPATHL, false); s = buf; } - char *fname_esc = ses_escape_fname((char *)s, flagp); + char *fname_esc = ses_escape_fname(s, flagp); if (fprintf(fd, "$argadd %s\n", fname_esc) < 0) { xfree(fname_esc); xfree(buf); @@ -268,7 +268,7 @@ static char *ses_get_fname(buf_T *buf, const unsigned *flagp) static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) { char *name = ses_get_fname(buf, flagp); - if (ses_put_fname(fd, (char_u *)name, flagp) == FAIL + if (ses_put_fname(fd, name, flagp) == FAIL || (add_eol && fprintf(fd, "\n") < 0)) { return FAIL; } @@ -303,9 +303,9 @@ static char *ses_escape_fname(char *name, unsigned *flagp) /// characters. /// /// @return FAIL if writing fails. -static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) +static int ses_put_fname(FILE *fd, char *name, unsigned *flagp) { - char *p = ses_escape_fname((char *)name, flagp); + char *p = ses_escape_fname(name, flagp); bool retval = fputs(p, fd) < 0 ? FAIL : OK; xfree(p); return retval; @@ -527,7 +527,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr if (wp->w_localdir != NULL && (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) { if (fputs("lcd ", fd) < 0 - || ses_put_fname(fd, (char_u *)wp->w_localdir, flagp) == FAIL + || ses_put_fname(fd, wp->w_localdir, flagp) == FAIL || fprintf(fd, "\n") < 0) { return FAIL; } @@ -546,7 +546,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr /// @param fd File descriptor to write to /// /// @return FAIL on error, OK otherwise. -static int makeopens(FILE *fd, char_u *dirnow) +static int makeopens(FILE *fd, char *dirnow) { int only_save_windows = true; int nr; @@ -585,7 +585,7 @@ static int makeopens(FILE *fd, char_u *dirnow) if (ssop_flags & SSOP_SESDIR) { PUTLINE_FAIL("exe \"cd \" . escape(expand(\":p:h\"), ' ')"); } else if (ssop_flags & SSOP_CURDIR) { - sname = home_replace_save(NULL, globaldir != NULL ? globaldir : (char *)dirnow); + sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); char *fname_esc = ses_escape_fname(sname, &ssop_flags); if (fprintf(fd, "cd %s\n", fname_esc) < 0) { xfree(fname_esc); @@ -832,7 +832,7 @@ static int makeopens(FILE *fd, char_u *dirnow) // Take care of tab-local working directories if applicable if (tp->tp_localdir) { if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0 - || ses_put_fname(fd, (char_u *)tp->tp_localdir, &ssop_flags) == FAIL + || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL || fputs(" | endif\n", fd) < 0) { return FAIL; } @@ -1001,14 +1001,14 @@ void ex_mkrc(exarg_T *eap) failed = true; } if (eap->cmdidx == CMD_mksession) { - char_u *dirnow; // current directory + char *dirnow; // current directory dirnow = xmalloc(MAXPATHL); // // Change to session file's dir. // - if (os_dirname((char *)dirnow, MAXPATHL) == FAIL - || os_chdir((char *)dirnow) != 0) { + if (os_dirname(dirnow, MAXPATHL) == FAIL + || os_chdir(dirnow) != 0) { *dirnow = NUL; } if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) { @@ -1028,7 +1028,7 @@ void ex_mkrc(exarg_T *eap) if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR) || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL))) { - if (os_chdir((char *)dirnow) != 0) { + if (os_chdir(dirnow) != 0) { emsg(_(e_prev_dir)); } shorten_fnames(true); -- cgit From e89c39d6f016a4140293755250e968e839009617 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:58:28 +0100 Subject: refactor: replace char_u with char 21 (#21779) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_session.c') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 48d52fa5f9..cae9c18309 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -964,7 +964,7 @@ void ex_mkrc(exarg_T *eap) vim_mkdir_emsg((const char *)p_vdir, 0755); } - fd = open_exfile((char_u *)fname, eap->forceit, WRITEBIN); + fd = open_exfile(fname, eap->forceit, WRITEBIN); if (fd != NULL) { if (eap->cmdidx == CMD_mkview) { flagp = &vop_flags; -- cgit