From 94c317647845b92d675548a481f664a6a1808426 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 Aug 2022 15:44:55 +0800 Subject: refactor: use CLEAR_FIELD and CLEAR_POINTER macros (#19709) vim-patch:8.2.0559: clearing a struct is verbose Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER(). https://github.com/vim/vim/commit/a80faa8930ed5a554beeb2727762538873135e83 --- src/nvim/hardcopy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index d7f7b8eb92..96d3bfb4d3 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -632,8 +632,8 @@ void ex_hardcopy(exarg_T *eap) int page_line; int jobsplit; - memset(&settings, 0, sizeof(prt_settings_T)); - settings.has_color = TRUE; + CLEAR_FIELD(settings); + settings.has_color = true; if (*eap->arg == '>') { char *errormsg = NULL; @@ -734,7 +734,7 @@ void ex_hardcopy(exarg_T *eap) prt_pos_T page_prtpos; // print position at page start int side; - memset(&page_prtpos, 0, sizeof(prt_pos_T)); + CLEAR_FIELD(page_prtpos); page_prtpos.file_line = eap->line1; prtpos = page_prtpos; @@ -1718,7 +1718,7 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource) semsg(_("E624: Can't open file \"%s\""), resource->filename); return false; } - memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN); + CLEAR_FIELD(prt_resfile.buffer); // Parse first line to ensure valid resource file prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u), -- cgit From 094cdf2d691bc005dadb5a22bb83b85f3b6dff49 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Sun, 31 Jul 2022 16:20:57 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/hardcopy.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 96d3bfb4d3..14fb1111d9 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -292,8 +292,8 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ char *ret = NULL; char_u *stringp; char_u *colonp; - char_u *commap; - char_u *p; + char *commap; + char *p; size_t idx = 0; // init for GCC int len; @@ -315,9 +315,9 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ ret = N_("E550: Missing colon"); break; } - commap = (char_u *)vim_strchr((char *)stringp, ','); + commap = vim_strchr((char *)stringp, ','); if (commap == NULL) { - commap = option_str + STRLEN(option_str); + commap = (char *)option_str + STRLEN(option_str); } len = (int)(colonp - stringp); @@ -333,8 +333,8 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ break; } - p = colonp + 1; - table[idx].present = TRUE; + p = (char *)colonp + 1; + table[idx].present = true; if (table[idx].hasnum) { if (!ascii_isdigit(*p)) { @@ -342,13 +342,13 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ break; } - table[idx].number = getdigits_int((char **)&p, false, 0); + table[idx].number = getdigits_int(&p, false, 0); } - table[idx].string = p; + table[idx].string = (char_u *)p; table[idx].strlen = (int)(commap - p); - stringp = commap; + stringp = (char_u *)commap; if (*stringp == ',') { ++stringp; } -- cgit From 342d18b91ec176c5e3aa6d32d439d01e6ac88ee6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 21:16:28 +0800 Subject: refactor: remove some unused includes (#19740) Mostly avoids including eval.h, ex_cmds2.h and ex_docmd.h in other headers. --- src/nvim/hardcopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 14fb1111d9..0be45ec9ae 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -17,7 +17,6 @@ #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/eval.h" -#include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/fileio.h" #include "nvim/garray.h" @@ -31,6 +30,7 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" +#include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/syntax.h" -- cgit From 542fa8a9cc10abb8eddab25a19844d19b94f53c1 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 16 Aug 2022 12:26:08 +0100 Subject: refactor: change pre-decrement/increment to post (#19799) Co-authored-by: zeertzjq --- src/nvim/hardcopy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 0be45ec9ae..9c522e11d8 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -350,7 +350,7 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ stringp = (char_u *)commap; if (*stringp == ',') { - ++stringp; + stringp++; } } @@ -837,7 +837,7 @@ void ex_hardcopy(exarg_T *eap) } } if (settings.duplex && prtpos.file_line <= eap->line2) { - ++page_count; + page_count++; } // Remember the position where the next page starts. -- cgit From f7cfca49d6f1380b2ec0b0f7723ea308d0810857 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 22:18:34 +0800 Subject: refactor: remove some unused includes (#19820) Replace grid.h in screen.h and screen.h in buffer.h with grid_defs.h --- src/nvim/hardcopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 9c522e11d8..fa357f864e 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -20,6 +20,7 @@ #include "nvim/ex_docmd.h" #include "nvim/fileio.h" #include "nvim/garray.h" +#include "nvim/grid.h" #include "nvim/hardcopy.h" #include "nvim/highlight_group.h" #include "nvim/mbyte.h" @@ -31,7 +32,6 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/runtime.h" -#include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/ui.h" -- cgit From d879331b0dee66cb106b5bea9efc2f920caf9abd Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 25 Jul 2022 10:16:33 +0200 Subject: feat(ui): allow to set the highlight namespace per window - reimplement 'winhl' in terms of highlight namespaces - check for EOF in screen tests (to indicate a likely crash) --- src/nvim/hardcopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index fa357f864e..d811a78ca8 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -900,7 +900,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T } // syntax highlighting stuff. if (psettings->do_syntax) { - id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE); + id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, false); if (id > 0) { id = syn_get_final_id(id); } else { -- cgit From 2af9be3db59b2e26268dc62cb65e673e2f7d4783 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Aug 2022 19:20:39 +0800 Subject: vim-patch:8.1.1966: some code in options.c fits better elsewhere (#19840) Problem: Some code in options.c fits better elsewhere. Solution: Move functions from options.c to other files. (Yegappan Lakshmanan, closes vim/vim#4889) https://github.com/vim/vim/commit/e677df8d93772a705f40a94f3c871aee78fe4d99 --- src/nvim/hardcopy.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/hardcopy.c') diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index d811a78ca8..6a1bbcb089 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -23,6 +23,7 @@ #include "nvim/grid.h" #include "nvim/hardcopy.h" #include "nvim/highlight_group.h" +#include "nvim/indent.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" -- cgit