From 543e0256c19f397921a332e06b423215fd9aecb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Nov 2023 15:51:05 +0800 Subject: build: don't define FUNC_ATTR_* as empty in headers (#26317) FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header. --- src/nvim/bufwrite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index f774fcb057..06bd05b11d 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -23,7 +23,6 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/highlight.h" -- cgit From 69bc519b53ebf78fd95c8256468e7d538ebcb948 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 12 Dec 2023 15:40:21 +0100 Subject: refactor: move non-symbols to defs.h headers --- src/nvim/bufwrite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 06bd05b11d..f8df273375 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -37,6 +37,7 @@ #include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/sha256.h" -- cgit From 7f6b775b45de5011ff1c44e63e57551566d80704 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 16 Dec 2023 22:14:28 +0100 Subject: refactor: use `bool` to represent boolean values --- src/nvim/bufwrite.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index f8df273375..67e5fb3b6f 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -799,7 +799,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o char *backup_ext = *p_bex == NUL ? ".bak" : p_bex; if (*backup_copyp) { - int some_error = false; + bool some_error = false; // Try to make the backup in each directory in the 'bdir' option. // @@ -1059,14 +1059,14 @@ nobackup: /// /// @return FAIL for failure, OK otherwise int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T end, exarg_T *eap, - int append, int forceit, int reset_changed, int filtering) + bool append, bool forceit, bool reset_changed, bool filtering) { int retval = OK; int msg_save = msg_scroll; - int prev_got_int = got_int; + bool prev_got_int = got_int; // writing everything - int whole = (start == 1 && end == buf->b_ml.ml_line_count); - int write_undo_file = false; + bool whole = (start == 1 && end == buf->b_ml.ml_line_count); + bool write_undo_file = false; context_sha256_T sha_ctx; unsigned bkc = get_bkc_value(buf); @@ -1245,7 +1245,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } #if defined(UNIX) - int made_writable = false; // 'w' bit has been set + bool made_writable = false; // 'w' bit has been set // When using ":w!" and the file was read-only: make it writable if (forceit && perm >= 0 && !(perm & 0200) @@ -1352,7 +1352,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } } - int notconverted = false; + bool notconverted = false; if (converted && wb_flags == 0 && write_info.bw_iconv_fd == (iconv_t)-1 @@ -1364,7 +1364,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en notconverted = true; } - int no_eol = false; // no end-of-line written + bool no_eol = false; // no end-of-line written int nchars; linenr_T lnum; int fileformat; -- cgit From 8533adb4844b771b84dac2141fa2fa60e0487b47 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Dec 2023 16:50:05 +0800 Subject: refactor(IWYU): move decor provider types to decoration_defs.h (#26692) --- src/nvim/bufwrite.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 67e5fb3b6f..c506cfdfa3 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -13,12 +13,10 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/bufwrite.h" #include "nvim/change.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" -- cgit From af93a74a0f4afa9a3a4f55ffdf28141eaf776d22 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 18 Dec 2023 10:55:23 +0100 Subject: refactor: run IWYU on entire repo Reference: https://github.com/neovim/neovim/issues/6371. --- src/nvim/bufwrite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index c506cfdfa3..7f44cdfb2c 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -17,6 +17,7 @@ #include "nvim/change.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" -- cgit From c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 28 Dec 2023 13:42:24 +0100 Subject: refactor: follow style guide --- src/nvim/bufwrite.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 7f44cdfb2c..25f69094f4 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -186,7 +186,7 @@ static int buf_write_convert_with_iconv(struct bw_info *ip, char **bufp, int *le size_t save_len = tolen; // output the initial shift state sequence - (void)iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen); + iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen); // There is a bug in iconv() on Linux (which appears to be // wide-spread) which sets "to" to NULL and messes up "tolen". @@ -378,7 +378,7 @@ static int make_bom(char *buf_in, char *name) return 3; } char *p = (char *)buf; - (void)ucs2bytes(0xfeff, &p, flags); + ucs2bytes(0xfeff, &p, flags); return (int)((uint8_t *)p - buf); } @@ -480,8 +480,7 @@ static int buf_write_do_autocmds(buf_T *buf, char **fnamep, char **sfnamep, char semsg(_(e_no_matching_autocommands_for_buftype_str_buffer), curbuf->b_p_bt); } - if (nofile_err - || aborting()) { + if (nofile_err || aborting()) { // An aborting error, interrupt or exception in the // autocommands. return FAIL; @@ -720,7 +719,7 @@ static int get_fileinfo(buf_T *buf, char *fname, bool overwriting, bool forceit, static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_old, vim_acl_T acl, int perm, unsigned bkc, bool file_readonly, bool forceit, - int *backup_copyp, char **backupp, Error_T *err) + bool *backup_copyp, char **backupp, Error_T *err) { FileInfo file_info; const bool no_prepend_dot = false; @@ -897,7 +896,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o // set file protection same as original file, but // strip s-bit. - (void)os_setperm(*backupp, perm & 0777); + os_setperm(*backupp, perm & 0777); #ifdef UNIX // @@ -1134,8 +1133,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en fname = sfname; #endif -// true if writing over original - int overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0; + // true if writing over original + bool overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0; no_wait_return++; // don't wait for return yet @@ -1218,7 +1217,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en dobackup = false; } - int backup_copy = false; // copy the original file? + bool backup_copy = false; // copy the original file? // Save the value of got_int and reset it. We don't want a previous // interruption cancel writing, only hitting CTRL-C while writing should @@ -1251,7 +1250,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en && file_info_old.stat.st_uid == getuid() && vim_strchr(p_cpo, CPO_FWRITE) == NULL) { perm |= 0200; - (void)os_setperm(fname, perm); + os_setperm(fname, perm); made_writable = true; } #endif @@ -1278,8 +1277,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en // This makes all block numbers positive so that recovery does not need // the original file. // Don't do this if there is a backup file and we are exiting. - if (reset_changed && !newfile && overwriting - && !(exiting && backup != NULL)) { + if (reset_changed && !newfile && overwriting && !(exiting && backup != NULL)) { ml_preserve(buf, false, !!p_fs); if (got_int) { err = set_err(_(e_interr)); @@ -1303,7 +1301,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } // Check if the file needs to be converted. - int converted = need_conversion(fenc); + bool converted = need_conversion(fenc); int wb_flags = 0; // Check if UTF-8 to UCS-2/4 or Latin1 conversion needs to be done. Or @@ -1367,7 +1365,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en int nchars; linenr_T lnum; int fileformat; - int checking_conversion; + bool checking_conversion; int fd; @@ -1605,7 +1603,7 @@ restore_backup: if (!buf->b_p_fixeol && buf->b_p_eof) { // write trailing CTRL-Z - (void)write_eintr(write_info.bw_fd, "\x1a", 1); + write_eintr(write_info.bw_fd, "\x1a", 1); } // Stop when writing done or an error was encountered. @@ -1654,7 +1652,7 @@ restore_backup: || file_info.stat.st_gid != file_info_old.stat.st_gid) { os_fchown(fd, (uv_uid_t)file_info_old.stat.st_uid, (uv_gid_t)file_info_old.stat.st_gid); if (perm >= 0) { // Set permission again, may have changed. - (void)os_setperm(wfname, perm); + os_setperm(wfname, perm); } } buf_set_file_id(buf); @@ -1675,7 +1673,7 @@ restore_backup: } #endif if (perm >= 0) { // Set perm. of new file same as old file. - (void)os_setperm(wfname, perm); + os_setperm(wfname, perm); } // Probably need to set the ACL before changing the user (can't set the // ACL on a file the user doesn't own). -- cgit From 1813661a6197c76ea6621284570aca1d56597099 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 4 Jan 2024 15:38:16 +0100 Subject: refactor(IWYU): fix headers Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want. --- src/nvim/bufwrite.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/bufwrite.c') diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 25f69094f4..94a6604fc1 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -12,7 +12,9 @@ #include "auto/config.h" #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" +#include "nvim/buffer_defs.h" #include "nvim/bufwrite.h" #include "nvim/change.h" #include "nvim/drawscreen.h" @@ -22,19 +24,22 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" -#include "nvim/gettext.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/highlight.h" +#include "nvim/highlight_defs.h" #include "nvim/iconv_defs.h" #include "nvim/input.h" #include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" +#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" #include "nvim/option_vars.h" #include "nvim/os/fs.h" +#include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os_defs.h" #include "nvim/path.h" @@ -44,6 +49,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" +#include "nvim/undo_defs.h" #include "nvim/vim_defs.h" static const char *err_readonly = "is read-only (cannot override: \"W\" in 'cpoptions')"; -- cgit