From 88456cd3c49a3dd1fda17cf350daa9b8216b1aa6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 18 Nov 2022 22:14:09 +0000 Subject: [PATCH] patch 9.0.0904: various comment and indent flaws Problem: Various comment and indent flaws. Solution: Improve comments and indenting. --- Filelist | 3 +++ src/Makefile | 4 +++- src/eval.c | 3 +-- src/evalwindow.c | 1 + src/getchar.c | 20 ++++++++--------- src/match.c | 2 +- src/message.c | 5 ++--- src/move.c | 3 ++- src/os_unix.c | 35 +++++++++++++++++------------ src/regexp_nfa.c | 3 +-- src/testdir/test_fileformat.vim | 7 +++++- src/testdir/test_function_lists.vim | 12 +++++----- src/version.c | 2 ++ src/winclip.c | 3 ++- 14 files changed, 61 insertions(+), 42 deletions(-) diff --git a/Filelist b/Filelist index 9825e4598..30d5d589d 100644 --- a/Filelist +++ b/Filelist @@ -12,6 +12,7 @@ SRC_ALL = \ .github/workflows/ci.yml \ .github/workflows/codeql-analysis.yml \ .github/workflows/coverity.yml \ + .github/dependabot.yml \ .gitignore \ .hgignore \ .lgtm.yml \ @@ -396,6 +397,7 @@ SRC_ALL = \ src/libvterm/t/66screen_extent.test \ src/libvterm/t/67screen_dbl_wh.test \ src/libvterm/t/68screen_termprops.test \ + src/libvterm/t/69screen_reflow.test \ src/libvterm/t/90vttest_01-movement-1.test \ src/libvterm/t/90vttest_01-movement-2.test \ src/libvterm/t/90vttest_01-movement-3.test \ @@ -643,6 +645,7 @@ SRC_MAC = \ src/os_mac_conv.c \ src/os_macosx.m \ src/proto/os_mac_conv.pro \ + src/proto/os_macosx.pro \ # source files for VMS (in the extra archive) SRC_VMS = \ diff --git a/src/Makefile b/src/Makefile index bd6c18755..57f9aade0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -396,7 +396,9 @@ CClink = $(CC) # MZSCHEME # Uncomment this when you want to include the MzScheme interface. -# You may have to build racket from source to make this work. +# You may have to build racket from source to make this work. Version 7.9 has +# been reported to work, version 8.0 probably doesn't work, version 8.5 has +# been reported to work. # NOTE: does not work well together with valgrind. #CONF_OPT_MZSCHEME = --enable-mzschemeinterp # PLT/mrscheme/drscheme Home dir; the PLTHOME environment variable also works diff --git a/src/eval.c b/src/eval.c index c57f6a4a0..84a7b2620 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1366,7 +1366,6 @@ get_lval( if (rettv != NULL && lp->ll_dict->dv_scope != 0) { int prevval; - int wrong; if (len != -1) { @@ -1375,7 +1374,7 @@ get_lval( } else prevval = 0; // avoid compiler warning - wrong = (lp->ll_dict->dv_scope == VAR_DEF_SCOPE + int wrong = (lp->ll_dict->dv_scope == VAR_DEF_SCOPE && (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_PARTIAL) && var_wrong_func_name(key, lp->ll_di == NULL)) diff --git a/src/evalwindow.c b/src/evalwindow.c index bc5925182..3578669ae 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -89,6 +89,7 @@ win_id2wp(int id) /* * Return the window and tab pointer of window "id". + * Returns NULL when not found. */ win_T * win_id2wp_tp(int id, tabpage_T **tpp) diff --git a/src/getchar.c b/src/getchar.c index 57e184b90..9ead903d0 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -968,18 +968,18 @@ noremap_keys(void) * Insert a string in position 'offset' in the typeahead buffer (for "@r" * and ":normal" command, vgetorpeek() and check_termcode()). * - * If noremap is REMAP_YES, new string can be mapped again. - * If noremap is REMAP_NONE, new string cannot be mapped again. - * If noremap is REMAP_SKIP, first char of new string cannot be mapped again, + * If "noremap" is REMAP_YES, new string can be mapped again. + * If "noremap" is REMAP_NONE, new string cannot be mapped again. + * If "noremap" is REMAP_SKIP, first char of new string cannot be mapped again, * but abbreviations are allowed. - * If noremap is REMAP_SCRIPT, new string cannot be mapped again, except for + * If "noremap" is REMAP_SCRIPT, new string cannot be mapped again, except for * script-local mappings. - * If noremap is > 0, that many characters of the new string cannot be mapped. + * If "noremap" is > 0, that many characters of the new string cannot be mapped. * - * If nottyped is TRUE, the string does not return KeyTyped (don't use when - * offset is non-zero!). + * If "nottyped" is TRUE, the string does not return KeyTyped (don't use when + * "offset" is non-zero!). * - * If silent is TRUE, cmd_silent is set when the characters are obtained. + * If "silent" is TRUE, cmd_silent is set when the characters are obtained. * * return FAIL for failure, OK otherwise */ @@ -1601,8 +1601,8 @@ before_blocking(void) } /* - * updatescript() is called when a character can be written into the script file - * or when we have waited some time for a character (c == 0) + * updatescript() is called when a character can be written into the script + * file or when we have waited some time for a character (c == 0) * * All the changed memfiles are synced if c == 0 or when the number of typed * characters reaches 'updatecount' and 'updatecount' is non-zero. diff --git a/src/match.c b/src/match.c index ceb317c38..6ac6513ca 100644 --- a/src/match.c +++ b/src/match.c @@ -435,7 +435,7 @@ next_search_hl( colnr_T matchcol; long nmatched; int called_emsg_before = called_emsg; - int timed_out = FALSE; + int timed_out = FALSE; // for :{range}s/pat only highlight inside the range if ((lnum < search_first_line || lnum > search_last_line) && cur == NULL) diff --git a/src/message.c b/src/message.c index d90666f0a..a60d330ee 100644 --- a/src/message.c +++ b/src/message.c @@ -1311,9 +1311,8 @@ wait_return(int redraw) || c == K_X2MOUSE)) ); ui_breakcheck(); - /* - * Avoid that the mouse-up event causes visual mode to start. - */ + + // Avoid that the mouse-up event causes Visual mode to start. if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); diff --git a/src/move.c b/src/move.c index aac2c243d..66e8c18c5 100644 --- a/src/move.c +++ b/src/move.c @@ -2852,7 +2852,8 @@ cursor_correct(void) static void get_scroll_overlap(lineoff_T *lp, int dir); /* - * Move screen "count" pages up or down and update screen. + * Move screen "count" pages up ("dir" is BACKWARD) or down ("dir" is FORWARD) + * and update the screen. * * Return FAIL for failure, OK otherwise. */ diff --git a/src/os_unix.c b/src/os_unix.c index 814f3ad57..db57902dc 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2352,6 +2352,7 @@ mch_restore_title(int which) /* * Return TRUE if "name" looks like some xterm name. + * This matches "xterm.*", thus "xterm-256color", "xterm-kitty", etc. * Seiichi Sato mentioned that "mlterm" works like xterm. */ int @@ -2409,6 +2410,9 @@ use_xterm_mouse(void) return 0; } +/* + * Return TRUE if "name" is an iris-ansi terminal name. + */ int vim_is_iris(char_u *name) { @@ -2418,14 +2422,18 @@ vim_is_iris(char_u *name) || STRCMP(name, "builtin_iris-ansi") == 0); } +/* + * Return TRUE if "name" is a vt300-like terminal name. + */ int vim_is_vt300(char_u *name) { if (name == NULL) - return FALSE; // actually all ANSI comp. terminals should be here - // catch VT100 - VT5xx + return FALSE; + // Actually all ANSI compatible terminals should be here. + // Catch at least VT1xx - VT5xx return ((STRNICMP(name, "vt", 2) == 0 - && vim_strchr((char_u *)"12345", name[2]) != NULL) + && vim_strchr((char_u *)"12345", name[2]) != NULL) || STRCMP(name, "builtin_vt320") == 0); } @@ -5011,8 +5019,7 @@ mch_call_shell_fork( || (!curbuf->b_p_bin && curbuf->b_p_fixeol) || (lnum != curbuf->b_no_eol_lnum - && (lnum != - curbuf->b_ml.ml_line_count + && (lnum != curbuf->b_ml.ml_line_count || curbuf->b_p_eol))) vim_ignored = write(toshell_fd, "\n", (size_t)1); @@ -8309,8 +8316,8 @@ stop_timeout(void) start_timeout(long msec) { struct itimerspec interval = { - {0, 0}, // Do not repeat. - {msec / 1000, (msec % 1000) * 1000000}}; // Timeout interval + {0, 0}, // Do not repeat. + {msec / 1000, (msec % 1000) * 1000000}}; // Timeout interval int ret; // This is really the caller's responsibility, but let's make sure the @@ -8323,8 +8330,8 @@ start_timeout(long msec) action.sigev_notify = SIGEV_THREAD; action.sigev_notify_function = set_flag; - ret = timer_create(CLOCK_MONOTONIC, &action, &timer_id); - if (ret < 0) + ret = timer_create(CLOCK_MONOTONIC, &action, &timer_id); + if (ret < 0) { semsg(_(e_could_not_set_timeout_str), strerror(errno)); return &timeout_flag; @@ -8362,10 +8369,10 @@ delete_timer(void) * Implement timeout with setitimer() */ static struct sigaction prev_sigaction; -static volatile sig_atomic_t timeout_flag = FALSE; -static int timer_active = FALSE; +static volatile sig_atomic_t timeout_flag = FALSE; +static int timer_active = FALSE; static int timer_handler_active = FALSE; -static volatile sig_atomic_t alarm_pending = FALSE; +static volatile sig_atomic_t alarm_pending = FALSE; /* * Handle SIGALRM for a timeout. @@ -8424,8 +8431,8 @@ stop_timeout(void) start_timeout(long msec) { struct itimerval interval = { - {0, 0}, // Do not repeat. - {msec / 1000, (msec % 1000) * 1000}}; // Timeout interval + {0, 0}, // Do not repeat. + {msec / 1000, (msec % 1000) * 1000}}; // Timeout interval struct sigaction handle_alarm; int ret; sigset_t sigs; diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index fc1a99339..b829a3a81 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -6782,8 +6782,7 @@ nfa_regmatch( if (REG_MULTI && (lnum <= 0 || lnum > wp->w_buffer->b_ml.ml_line_count)) lnum = 1; - vcol = (long_u)win_linetabsize(wp, lnum, - rex.line, col); + vcol = (long_u)win_linetabsize(wp, lnum, rex.line, col); result = nfa_re_num_cmp(t->state->val, op, vcol + 1); } if (result) diff --git a/src/testdir/test_fileformat.vim b/src/testdir/test_fileformat.vim index e7d19861e..7d919c24a 100644 --- a/src/testdir/test_fileformat.vim +++ b/src/testdir/test_fileformat.vim @@ -76,7 +76,12 @@ func Test_fileformats() call s:concat_files('XXMac', 'XXEol', 'XXMacEol') call s:concat_files('XXUxDs', 'XXMac', 'XXUxDsMc') - new + " The :bwipe commands below cause us to get back to the current buffer. + " Avoid stray errors for various 'fileformat' values which may cause a + " modeline to be misinterpreted by wiping the buffer and editing a new one. + only! + bwipe! + enew " Test 1: try reading and writing with 'fileformats' empty set fileformats= diff --git a/src/testdir/test_function_lists.vim b/src/testdir/test_function_lists.vim index 027a7a5cf..dd69b8326 100644 --- a/src/testdir/test_function_lists.vim +++ b/src/testdir/test_function_lists.vim @@ -1,11 +1,11 @@ -" Test to verify that the three function lists, +" Test to verify that the three function lists: " -" global_functions[] in src/evalfunc.c -" *functions* in runtime/doc/builtin.txt -" *function-list* in runtime/doc/usr_41.txt +" - global_functions[] in src/evalfunc.c +" - *functions* in runtime/doc/builtin.txt +" - *function-list* in runtime/doc/usr_41.txt " -" contain the same functions and that the global_functions and ":help -" functions" lists are in ASCII order. +" contain the same functions and that the global_functions and +" ":help functions" lists are in ASCII order. func Test_function_lists() diff --git a/src/version.c b/src/version.c index e0ba0ab97..fbb68419d 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 904, /**/ 903, /**/ diff --git a/src/winclip.c b/src/winclip.c index 560759efe..73fe92aa0 100644 --- a/src/winclip.c +++ b/src/winclip.c @@ -728,7 +728,8 @@ utf16_to_enc(short_u *str, int *lenp) /* * Convert from the active codepage to 'encoding'. * Input is "str[str_size]". - * The result is in allocated memory: "out[outlen]". With terminating NUL. + * The result is in allocated memory: "out[outlen]". "outlen" includes the + * terminating NUL. */ void acp_to_enc( -- 2.40.0