diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-12-01 21:11:22 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-12-01 21:11:22 +0100 |
commit | 5d18efecfd6c45d69f55268948a22cd0465bb955 (patch) | |
tree | 409afa09cb7fb8f4684e0399f2597ba5d16edbfa /src/evalfunc.c | |
parent | fa5612c7d836eb789e0f8ff4b10461b8640a14b2 (diff) |
patch 8.1.2378: using old C style commentsv8.1.2378
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 490 |
1 files changed, 244 insertions, 246 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index f6ea57c630..892a7538f1 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1290,7 +1290,7 @@ f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED) int size = split_message(msg, &array); int i; - /* Skip the first and last item, they are always empty. */ + // Skip the first and last item, they are always empty. for (i = 1; i < size - 1; ++i) list_append_string(rettv->vval.v_list, array[i].pum_text, -1); while (size > 0) @@ -1322,7 +1322,7 @@ tv_get_buf(typval_T *tv, int curtab_only) buf = buflist_find_by_name(name, curtab_only); - /* If not found, try expanding the name, like done for bufexists(). */ + // If not found, try expanding the name, like done for bufexists(). if (buf == NULL) buf = find_buffer(tv); @@ -1357,7 +1357,7 @@ f_byte2line(typval_T *argvars UNUSED, typval_T *rettv) #else long boff = 0; - boff = tv_get_number(&argvars[0]) - 1; /* boff gets -1 on type error */ + boff = tv_get_number(&argvars[0]) - 1; // boff gets -1 on type error if (boff < 0) rettv->vval.v_number = -1; else @@ -1382,7 +1382,7 @@ byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED) t = str; for ( ; idx > 0; idx--) { - if (*t == NUL) /* EOL reached */ + if (*t == NUL) // EOL reached return; if (enc_utf8 && comp) t += utf_ptr2len(t); @@ -1438,7 +1438,7 @@ f_call(typval_T *argvars, typval_T *rettv) else func = tv_get_string(&argvars[0]); if (*func == NUL) - return; /* type error or empty name */ + return; // type error or empty name if (argvars[2].v_type != VAR_UNKNOWN) { @@ -1533,7 +1533,7 @@ f_col(typval_T *argvars, typval_T *rettv) { if (fp->col == MAXCOL) { - /* '> can be MAXCOL, get the length of the line then */ + // '> can be MAXCOL, get the length of the line then if (fp->lnum <= curbuf->b_ml.ml_line_count) col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1; else @@ -1542,8 +1542,8 @@ f_col(typval_T *argvars, typval_T *rettv) else { col = fp->col + 1; - /* col(".") when the cursor is on the NUL at the end of the line - * because of "coladd" can be seen as an extra column. */ + // col(".") when the cursor is on the NUL at the end of the line + // because of "coladd" can be seen as an extra column. if (virtual_active() && fp == &curwin->w_cursor) { char_u *p = ml_get_cursor(); @@ -1701,16 +1701,16 @@ f_cursor(typval_T *argvars, typval_T *rettv) coladd = (long)tv_get_number_chk(&argvars[2], NULL); } if (line < 0 || col < 0 || coladd < 0) - return; /* type error; errmsg already given */ + return; // type error; errmsg already given if (line > 0) curwin->w_cursor.lnum = line; if (col > 0) curwin->w_cursor.col = col - 1; curwin->w_cursor.coladd = coladd; - /* Make sure the cursor is in a valid position. */ + // Make sure the cursor is in a valid position. check_cursor(); - /* Correct cursor for multi-byte character. */ + // Correct cursor for multi-byte character. if (has_mbyte) mb_adjust_cursor(); @@ -1949,9 +1949,9 @@ execute_redir_str(char_u *value, int value_len) int len; if (value_len == -1) - len = (int)STRLEN(value); /* Append the entire string */ + len = (int)STRLEN(value); // Append the entire string else - len = value_len; /* Append only "value_len" characters */ + len = value_len; // Append only "value_len" characters if (ga_grow(&redir_execute_ga, len) == OK) { mch_memmove((char *)redir_execute_ga.ga_data @@ -2009,7 +2009,7 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off) { list = argvars[arg_off].vval.v_list; if (list == NULL || list->lv_first == NULL) - /* empty list, no commands, empty output */ + // empty list, no commands, empty output return; ++list->lv_refcount; } @@ -2059,7 +2059,7 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off) --list->lv_refcount; } - /* Need to append a NUL to the result. */ + // Need to append a NUL to the result. if (ga_grow(&redir_execute_ga, 1) == OK) { ((char *)redir_execute_ga.ga_data)[redir_execute_ga.ga_len] = NUL; @@ -2109,27 +2109,27 @@ f_exists(typval_T *argvars, typval_T *rettv) int n = FALSE; p = tv_get_string(&argvars[0]); - if (*p == '$') /* environment variable */ + if (*p == '$') // environment variable { - /* first try "normal" environment variables (fast) */ + // first try "normal" environment variables (fast) if (mch_getenv(p + 1) != NULL) n = TRUE; else { - /* try expanding things like $VIM and ${HOME} */ + // try expanding things like $VIM and ${HOME} p = expand_env_save(p); if (p != NULL && *p != '$') n = TRUE; vim_free(p); } } - else if (*p == '&' || *p == '+') /* option */ + else if (*p == '&' || *p == '+') // option { n = (get_option_tv(&p, NULL, TRUE) == OK); if (*skipwhite(p) != NUL) - n = FALSE; /* trailing garbage */ + n = FALSE; // trailing garbage } - else if (*p == '*') /* internal or user defined function */ + else if (*p == '*') // internal or user defined function { n = function_exists(p + 1, FALSE); } @@ -2144,7 +2144,7 @@ f_exists(typval_T *argvars, typval_T *rettv) else n = au_exists(p + 1); } - else /* internal variable */ + else // internal variable { n = var_exists(p); } @@ -2207,8 +2207,8 @@ f_expand(typval_T *argvars, typval_T *rettv) } else { - /* When the optional second argument is non-zero, don't remove matches - * for 'wildignore' and don't put matches for 'suffixes' at the end. */ + // When the optional second argument is non-zero, don't remove matches + // for 'wildignore' and don't put matches for 'suffixes' at the end. if (argvars[1].v_type != VAR_UNKNOWN && tv_get_number_chk(&argvars[1], &error)) options |= WILD_KEEP_ALL; @@ -2281,9 +2281,9 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED) int lowlevel = FALSE; char_u *keys_esc; - /* This is not allowed in the sandbox. If the commands would still be - * executed in the sandbox it would be OK, but it probably happens later, - * when "sandbox" is no longer set. */ + // This is not allowed in the sandbox. If the commands would still be + // executed in the sandbox it would be OK, but it probably happens later, + // when "sandbox" is no longer set. if (check_secure()) return; @@ -2309,8 +2309,8 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED) if (*keys != NUL || execute) { - /* Need to escape K_SPECIAL and CSI before putting the string in the - * typeahead buffer. */ + // Need to escape K_SPECIAL and CSI before putting the string in the + // typeahead buffer. keys_esc = vim_strsave_escape_csi(keys); if (keys_esc != NULL) { @@ -2339,7 +2339,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED) { int save_msg_scroll = msg_scroll; - /* Avoid a 1 second delay when the keys start Insert mode. */ + // Avoid a 1 second delay when the keys start Insert mode. msg_scroll = FALSE; if (!dangerous) @@ -2446,19 +2446,19 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) if (argvars[0].v_type == VAR_FUNC) { - /* function(MyFunc, [arg], dict) */ + // function(MyFunc, [arg], dict) s = argvars[0].vval.v_string; } else if (argvars[0].v_type == VAR_PARTIAL && argvars[0].vval.v_partial != NULL) { - /* function(dict.MyFunc, [arg]) */ + // function(dict.MyFunc, [arg]) arg_pt = argvars[0].vval.v_partial; s = partial_name(arg_pt); } else { - /* function('MyFunc', [arg], dict) */ + // function('MyFunc', [arg], dict) s = tv_get_string(&argvars[0]); use_string = TRUE; } @@ -2475,7 +2475,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s)) || (is_funcref && trans_name == NULL)) semsg(_(e_invarg2), use_string ? tv_get_string(&argvars[0]) : s); - /* Don't check an autoload name for existence here. */ + // Don't check an autoload name for existence here. else if (trans_name != NULL && (is_funcref ? find_func(trans_name) == NULL : !translated_function_exists(trans_name))) @@ -2491,10 +2491,10 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) char sid_buf[25]; int off = *s == 's' ? 2 : 5; - /* Expand s: and <SID> into <SNR>nr_, so that the function can - * also be called from another script. Using trans_function_name() - * would also work, but some plugins depend on the name being - * printable text. */ + // Expand s: and <SID> into <SNR>nr_, so that the function can + // also be called from another script. Using trans_function_name() + // would also work, but some plugins depend on the name being + // printable text. sprintf(sid_buf, "<SNR>%ld_", (long)current_sctx.sc_sid); name = alloc(STRLEN(sid_buf) + STRLEN(s + off) + 1); if (name != NULL) @@ -2510,15 +2510,15 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) { if (argvars[2].v_type != VAR_UNKNOWN) { - /* function(name, [args], dict) */ + // function(name, [args], dict) arg_idx = 1; dict_idx = 2; } else if (argvars[1].v_type == VAR_DICT) - /* function(name, dict) */ + // function(name, dict) dict_idx = 1; else - /* function(name, [args]) */ + // function(name, [args]) arg_idx = 1; if (dict_idx > 0) { @@ -2554,7 +2554,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) { partial_T *pt = ALLOC_CLEAR_ONE(partial_T); - /* result is a VAR_PARTIAL */ + // result is a VAR_PARTIAL if (pt == NULL) vim_free(name); else @@ -2586,18 +2586,18 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) copy_tv(&li->li_tv, &pt->pt_argv[i++]); } - /* For "function(dict.func, [], dict)" and "func" is a partial - * use "dict". That is backwards compatible. */ + // For "function(dict.func, [], dict)" and "func" is a partial + // use "dict". That is backwards compatible. if (dict_idx > 0) { - /* The dict is bound explicitly, pt_auto is FALSE. */ + // The dict is bound explicitly, pt_auto is FALSE. pt->pt_dict = argvars[dict_idx].vval.v_dict; ++pt->pt_dict->dv_refcount; } else if (arg_pt != NULL) { - /* If the dict was bound automatically the result is also - * bound automatically. */ + // If the dict was bound automatically the result is also + // bound automatically. pt->pt_dict = arg_pt->pt_dict; pt->pt_auto = arg_pt->pt_auto; if (pt->pt_dict != NULL) @@ -2628,7 +2628,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref) } else { - /* result is a VAR_FUNC */ + // result is a VAR_FUNC rettv->v_type = VAR_FUNC; rettv->vval.v_string = name; func_ref(name); @@ -2662,8 +2662,8 @@ f_function(typval_T *argvars, typval_T *rettv) static void f_garbagecollect(typval_T *argvars, typval_T *rettv UNUSED) { - /* This is postponed until we are back at the toplevel, because we may be - * using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". */ + // This is postponed until we are back at the toplevel, because we may be + // using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". want_garbage_collect = TRUE; if (argvars[0].v_type != VAR_UNKNOWN && tv_get_number(&argvars[0]) == 1) @@ -2922,19 +2922,19 @@ f_getfontname(typval_T *argvars UNUSED, typval_T *rettv) if (argvars[0].v_type == VAR_UNKNOWN) { - /* Get the "Normal" font. Either the name saved by - * hl_set_font_name() or from the font ID. */ + // Get the "Normal" font. Either the name saved by + // hl_set_font_name() or from the font ID. font = gui.norm_font; name = hl_get_font_name(); } else { name = tv_get_string(&argvars[0]); - if (STRCMP(name, "*") == 0) /* don't use font dialog */ + if (STRCMP(name, "*") == 0) // don't use font dialog return; font = gui_mch_get_font(name, FALSE); if (font == NOFONT) - return; /* Invalid font name, return empty string. */ + return; // Invalid font name, return empty string. } rettv->vval.v_string = gui_mch_get_fontname(font, name); if (argvars[0].v_type != VAR_UNKNOWN) @@ -3137,7 +3137,7 @@ f_getregtype(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type != VAR_UNKNOWN) { strregname = tv_get_string_chk(&argvars[0]); - if (strregname == NULL) /* type error; errmsg already given */ + if (strregname == NULL) // type error; errmsg already given { rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; @@ -3145,7 +3145,7 @@ f_getregtype(typval_T *argvars, typval_T *rettv) } } else - /* Default to v:register */ + // Default to v:register strregname = get_vim_var_str(VV_REG); regname = (strregname == NULL ? '"' : *strregname); @@ -3188,7 +3188,7 @@ f_gettagstack(typval_T *argvars, typval_T *rettv) get_tagstack(wp, rettv->vval.v_dict); } -/* for VIM_VERSION_ defines */ +// for VIM_VERSION_ defines #include "version.h" /* @@ -3221,11 +3221,11 @@ f_has(typval_T *argvars, typval_T *rettv) "linux", #endif #ifdef MACOS_X - "mac", /* Mac OS X (and, once, Mac OS Classic) */ - "osx", /* Mac OS X */ + "mac", // Mac OS X (and, once, Mac OS Classic) + "osx", // Mac OS X # ifdef MACOS_X_DARWIN - "macunix", /* Mac OS X, with the darwin feature */ - "osxdarwin", /* synonym for macunix */ + "macunix", // Mac OS X, with the darwin feature + "osxdarwin", // synonym for macunix # endif #endif #ifdef __QNX__ @@ -3272,7 +3272,7 @@ f_has(typval_T *argvars, typval_T *rettv) #endif #ifdef FEAT_BEVAL_GUI "balloon_eval", -# ifndef FEAT_GUI_MSWIN /* other GUIs always have multiline balloons */ +# ifndef FEAT_GUI_MSWIN // other GUIs always have multiline balloons "balloon_multiline", # endif #endif @@ -3347,8 +3347,8 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_EMACS_TAGS "emacs_tags", #endif - "eval", /* always present, of course! */ - "ex_extra", /* graduated feature */ + "eval", // always present, of course! + "ex_extra", // graduated feature #ifdef FEAT_SEARCH_EXTRA "extra_search", #endif @@ -3422,7 +3422,7 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_KEYMAP "keymap", #endif - "lambda", /* always with FEAT_EVAL, since 7.4.2120 with closure */ + "lambda", // always with FEAT_EVAL, since 7.4.2120 with closure #ifdef FEAT_LANGMAP "langmap", #endif @@ -3629,7 +3629,7 @@ f_has(typval_T *argvars, typval_T *rettv) #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) "unnamedplus", #endif - "user-commands", /* was accidentally included in 5.4 */ + "user-commands", // was accidentally included in 5.4 "user_commands", #ifdef FEAT_VARTABS "vartabs", @@ -3670,7 +3670,7 @@ f_has(typval_T *argvars, typval_T *rettv) #endif #ifdef FEAT_XPM_W32 "xpm", - "xpm_w32", /* for backward compatibility */ + "xpm_w32", // for backward compatibility #else # if defined(HAVE_XPM) "xpm", @@ -3715,7 +3715,7 @@ f_has(typval_T *argvars, typval_T *rettv) int major = atoi((char *)name + 6); int minor = atoi((char *)name + 8); - /* Expect "patch-9.9.01234". */ + // Expect "patch-9.9.01234". n = (major < VIM_VERSION_MAJOR || (major == VIM_VERSION_MAJOR && (minor < VIM_VERSION_MINOR @@ -3791,7 +3791,7 @@ f_has(typval_T *argvars, typval_T *rettv) n = (gui.in_use || gui.starting); # ifdef FEAT_BROWSE else if (STRICMP(name, "browse") == 0) - n = gui.in_use; /* gui_mch_browse() works when GUI is running */ + n = gui.in_use; // gui_mch_browse() works when GUI is running # endif #endif #ifdef FEAT_SYN_HL @@ -3929,7 +3929,7 @@ f_iconv(typval_T *argvars UNUSED, typval_T *rettv) vimconv.vc_type = CONV_NONE; convert_setup(&vimconv, from, to); - /* If the encodings are equal, no conversion needed. */ + // If the encodings are equal, no conversion needed. if (vimconv.vc_type == CONV_NONE) rettv->vval.v_string = vim_strsave(str); else @@ -3999,8 +3999,8 @@ f_index(typval_T *argvars, typval_T *rettv) item = l->lv_first; if (argvars[2].v_type != VAR_UNKNOWN) { - /* Start at specified item. Use the cached index that list_find() - * sets, so that a negative number also works. */ + // Start at specified item. Use the cached index that list_find() + // sets, so that a negative number also works. item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error)); idx = l->lv_idx; if (argvars[3].v_type != VAR_UNKNOWN) @@ -4037,7 +4037,7 @@ f_input(typval_T *argvars, typval_T *rettv) f_inputdialog(typval_T *argvars, typval_T *rettv) { #if defined(FEAT_GUI_TEXTDIALOG) - /* Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions' */ + // Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions' if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL) { char_u *message; @@ -4082,8 +4082,8 @@ f_inputlist(typval_T *argvars, typval_T *rettv) int mouse_used; #ifdef NO_CONSOLE_INPUT - /* While starting up, there is no place to enter text. When running tests - * with --not-a-term we assume feedkeys() will be used. */ + // While starting up, there is no place to enter text. When running tests + // with --not-a-term we assume feedkeys() will be used. if (no_console_input() && !is_not_a_term()) return; #endif @@ -4094,8 +4094,8 @@ f_inputlist(typval_T *argvars, typval_T *rettv) } msg_start(); - msg_row = Rows - 1; /* for when 'cmdheight' > 1 */ - lines_left = Rows; /* avoid more prompt */ + msg_row = Rows - 1; // for when 'cmdheight' > 1 + lines_left = Rows; // avoid more prompt msg_scroll = TRUE; msg_clr_eos(); @@ -4105,7 +4105,7 @@ f_inputlist(typval_T *argvars, typval_T *rettv) msg_putchar('\n'); } - /* Ask for choice. */ + // Ask for choice. selected = prompt_for_number(&mouse_used); if (mouse_used) selected -= lines_left; @@ -4126,12 +4126,12 @@ f_inputrestore(typval_T *argvars UNUSED, typval_T *rettv) --ga_userinput.ga_len; restore_typeahead((tasave_T *)(ga_userinput.ga_data) + ga_userinput.ga_len); - /* default return is zero == OK */ + // default return is zero == OK } else if (p_verbose > 1) { verb_msg(_("called inputrestore() more often than inputsave()")); - rettv->vval.v_number = 1; /* Failed */ + rettv->vval.v_number = 1; // Failed } } @@ -4141,16 +4141,16 @@ f_inputrestore(typval_T *argvars UNUSED, typval_T *rettv) static void f_inputsave(typval_T *argvars UNUSED, typval_T *rettv) { - /* Add an entry to the stack of typeahead storage. */ + // Add an entry to the stack of typeahead storage. if (ga_grow(&ga_userinput, 1) == OK) { save_typeahead((tasave_T *)(ga_userinput.ga_data) + ga_userinput.ga_len); ++ga_userinput.ga_len; - /* default return is zero == OK */ + // default return is zero == OK } else - rettv->vval.v_number = 1; /* Failed */ + rettv->vval.v_number = 1; // Failed } /* @@ -4224,11 +4224,10 @@ f_islocked(typval_T *argvars, typval_T *rettv) di = find_var(lv.ll_name, NULL, TRUE); if (di != NULL) { - /* Consider a variable locked when: - * 1. the variable itself is locked - * 2. the value of the variable is locked. - * 3. the List or Dict value is locked. - */ + // Consider a variable locked when: + // 1. the variable itself is locked + // 2. the value of the variable is locked. + // 3. the List or Dict value is locked. rettv->vval.v_number = ((di->di_flags & DI_FLAGS_LOCK) || tv_islocked(&di->di_tv)); } @@ -4238,10 +4237,10 @@ f_islocked(typval_T *argvars, typval_T *rettv) else if (lv.ll_newkey != NULL) semsg(_(e_dictkey), lv.ll_newkey); else if (lv.ll_list != NULL) - /* List item. */ + // List item. rettv->vval.v_number = tv_islocked(&lv.ll_li->li_tv); else - /* Dictionary item. */ + // Dictionary item. rettv->vval.v_number = tv_islocked(&lv.ll_di->di_tv); } } @@ -4338,7 +4337,7 @@ libcall_common(typval_T *argvars UNUSED, typval_T *rettv, int type) return; #ifdef FEAT_LIBCALL - /* The first two args must be strings, otherwise it's meaningless */ + // The first two args must be strings, otherwise it's meaningless if (argvars[0].v_type == VAR_STRING && argvars[1].v_type == VAR_STRING) { string_in = NULL; @@ -4518,11 +4517,11 @@ f_mapcheck(typval_T *argvars, typval_T *rettv) typedef enum { - MATCH_END, /* matchend() */ - MATCH_MATCH, /* match() */ - MATCH_STR, /* matchstr() */ - MATCH_LIST, /* matchlist() */ - MATCH_POS /* matchstrpos() */ + MATCH_END, // matchend() + MATCH_MATCH, // match() + MATCH_STR, // matchstr() + MATCH_LIST, // matchlist() + MATCH_POS // matchstrpos() } matchtype_T; static void @@ -4545,15 +4544,15 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) long idx = 0; char_u *tofree = NULL; - /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ + // Make 'cpoptions' empty, the 'l' flag should not be used here. save_cpo = p_cpo; p_cpo = (char_u *)""; rettv->vval.v_number = -1; if (type == MATCH_LIST || type == MATCH_POS) { - /* type MATCH_LIST: return empty list when there are no matches. - * type MATCH_POS: return ["", -1, -1, -1] */ + // type MATCH_LIST: return empty list when there are no matches. + // type MATCH_POS: return ["", -1, -1, -1] if (rettv_list_alloc(rettv) == FAIL) goto theend; if (type == MATCH_POS @@ -4605,7 +4604,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) li = list_find(l, start); if (li == NULL) goto theend; - idx = l->lv_idx; /* use the cached index */ + idx = l->lv_idx; // use the cached index } else { @@ -4613,9 +4612,9 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) start = 0; if (start > len) goto theend; - /* When "count" argument is there ignore matches before "start", - * otherwise skip part of the string. Differs when pattern is "^" - * or "\<". */ + // When "count" argument is there ignore matches before "start", + // otherwise skip part of the string. Differs when pattern is "^" + // or "\<". if (argvars[3].v_type != VAR_UNKNOWN) startcol = start; else @@ -4658,7 +4657,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) if (l == NULL && !match) break; - /* Advance to just after the match. */ + // Advance to just after the match. if (l != NULL) { li = li->li_next; @@ -4700,7 +4699,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) { int i; - /* return list with matched string and submatches */ + // return list with matched string and submatches for (i = 0; i < NSUBEXP; ++i) { if (regmatch.endp[i] == NULL) @@ -4718,7 +4717,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) } else if (type == MATCH_STR) { - /* return matched string */ + // return matched string if (l != NULL) copy_tv(&li->li_tv, rettv); else @@ -4743,7 +4742,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type) theend: if (type == MATCH_POS && l == NULL && rettv->vval.v_list != NULL) - /* matchstrpos() without a list: drop the second item. */ + // matchstrpos() without a list: drop the second item. listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first->li_next); vim_free(tofree); @@ -5016,10 +5015,10 @@ f_prevnonblank(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = lnum; } -/* This dummy va_list is here because: - * - passing a NULL pointer doesn't work when va_list isn't a pointer - * - locally in the function results in a "used before set" warning - * - using va_start() to initialize it gives "function with fixed args" error */ +// This dummy va_list is here because: +// - passing a NULL pointer doesn't work when va_list isn't a pointer +// - locally in the function results in a "used before set" warning +// - using va_start() to initialize it gives "function with fixed args" error static va_list ap; /* @@ -5037,7 +5036,7 @@ f_printf(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; - /* Get the required length, allocate the buffer and do it for real. */ + // Get the required length, allocate the buffer and do it for real. did_emsg = FALSE; fmt = (char *)tv_get_string_buf(&argvars[0], buf); len = vim_vsnprintf_typval(NULL, 0, fmt, ap, argvars + 1); @@ -5244,7 +5243,7 @@ f_range(typval_T *argvars, typval_T *rettv) } if (error) - return; /* type error; errmsg already given */ + return; // type error; errmsg already given if (stride == 0) emsg(_("E726: Stride is zero")); else if (stride > 0 ? end + 1 < start : end - 1 > start) @@ -5312,7 +5311,7 @@ list2proftime(typval_T *arg, proftime_T *tm) # endif return error ? FAIL : OK; } -#endif /* FEAT_RELTIME */ +#endif // FEAT_RELTIME /* * "reltime()" function @@ -5326,7 +5325,7 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED) if (argvars[0].v_type == VAR_UNKNOWN) { - /* No arguments: get current time. */ + // No arguments: get current time. profile_start(&res); } else if (argvars[1].v_type == VAR_UNKNOWN) @@ -5337,7 +5336,7 @@ f_reltime(typval_T *argvars UNUSED, typval_T *rettv UNUSED) } else { - /* Two arguments: compute the difference. */ + // Two arguments: compute the difference. if (list2proftime(&argvars[0], &start) == FAIL || list2proftime(&argvars[1], &res) == FAIL) return; @@ -5456,7 +5455,7 @@ remote_common(typval_T *argvars, typval_T *rettv, int expr) server_name = tv_get_string_chk(&argvars[0]); if (server_name == NULL) - return; /* type error; errmsg already given */ + return; // type error; errmsg already given keys = tv_get_string_buf(&argvars[1], buf); # ifdef MSWIN if (serverSendToVim(server_name, keys, &r, &w, expr, timeout, TRUE) < 0) @@ -5517,7 +5516,7 @@ f_remote_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #ifdef FEAT_CLIENTSERVER # ifdef MSWIN - /* On Win32 it's done in this application. */ + // On Win32 it's done in this application. { char_u *server_name = tv_get_string_chk(&argvars[0]); @@ -5525,7 +5524,7 @@ f_remote_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED) serverForeground(server_name); } # else - /* Send a foreground() expression to the server. */ + // Send a foreground() expression to the server. argvars[1].v_type = VAR_STRING; argvars[1].vval.v_string = vim_strsave((char_u *)"foreground()"); argvars[2].v_type = VAR_UNKNOWN; @@ -5557,7 +5556,7 @@ f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv) if (serverid == NULL) { rettv->vval.v_number = -1; - return; /* type error; errmsg already given */ + return; // type error; errmsg already given } # ifdef MSWIN sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n); @@ -5604,7 +5603,7 @@ f_remote_read(typval_T *argvars UNUSED, typval_T *rettv) { int timeout = 0; # ifdef MSWIN - /* The server's HWND is encoded in the 'id' parameter */ + // The server's HWND is encoded in the 'id' parameter long_u n = 0; # endif @@ -5651,7 +5650,7 @@ f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED) char_u *server = tv_get_string_chk(&argvars[0]); if (server == NULL) - return; /* type error; errmsg already given */ + return; // type error; errmsg already given if (serverName != NULL) emsg(_("E941: already started a server")); else @@ -5728,14 +5727,14 @@ f_repeat(typval_T *argvars, typval_T *rettv) } } -#define SP_NOMOVE 0x01 /* don't move cursor */ -#define SP_REPEAT 0x02 /* repeat to find outer pair */ -#define SP_RETCOUNT 0x04 /* return matchcount */ -#define SP_SETPCMARK 0x08 /* set previous context mark */ -#define SP_START 0x10 /* accept match at start position */ -#define SP_SUBPAT 0x20 /* return nr of matching sub-pattern */ -#define SP_END 0x40 /* leave cursor at end of match */ -#define SP_COLUMN 0x80 /* start at cursor column */ +#define SP_NOMOVE 0x01 // don't move cursor +#define SP_REPEAT 0x02 // repeat to find outer pair +#define SP_RETCOUNT 0x04 // return matchcount +#define SP_SETPCMARK 0x08 // set previous context mark +#define SP_START 0x10 // accept match at start position +#define SP_SUBPAT 0x20 // return nr of matching sub-pattern +#define SP_END 0x40 // leave cursor at end of match +#define SP_COLUMN 0x80 // start at cursor column /* * Get flags for a search function. @@ -5754,7 +5753,7 @@ get_search_arg(typval_T *varp, int *flagsp) { flags = tv_get_string_buf_chk(varp, nbuf); if (flags == NULL) - return 0; /* type error; errmsg already given */ + return 0; // type error; errmsg already given while (*flags != NUL) { switch (*flags) @@ -5803,7 +5802,7 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) pos_T save_cursor; int save_p_ws = p_ws; int dir; - int retval = 0; /* default: FAIL */ + int retval = 0; // default: FAIL long lnum_stop = 0; #ifdef FEAT_RELTIME proftime_T tm; @@ -5814,7 +5813,7 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) searchit_arg_T sia; pat = tv_get_string(&argvars[0]); - dir = get_search_arg(&argvars[1], flagsp); /* may set p_ws */ + dir = get_search_arg(&argvars[1], flagsp); // may set p_ws if (dir == 0) goto theend; flags = *flagsp; @@ -5825,7 +5824,7 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) if (flags & SP_COLUMN) options |= SEARCH_COL; - /* Optional arguments: line number to stop searching and timeout. */ + // Optional arguments: line number to stop searching and timeout. if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) { lnum_stop = (long)tv_get_number_chk(&argvars[2], NULL); @@ -5842,7 +5841,7 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) } #ifdef FEAT_RELTIME - /* Set the time limit, if there is one. */ + // Set the time limit, if there is one. profile_setlimit(time_limit, &tm); #endif @@ -5878,16 +5877,16 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) curwin->w_cursor = pos; if (match_pos != NULL) { - /* Store the match cursor position */ + // Store the match cursor position match_pos->lnum = pos.lnum; match_pos->col = pos.col + 1; } - /* "/$" will put the cursor after the end of the line, may need to - * correct that here */ + // "/$" will put the cursor after the end of the line, may need to + // correct that here check_cursor(); } - /* If 'n' flag is used: restore cursor position. */ + // If 'n' flag is used: restore cursor position. if (flags & SP_NOMOVE) curwin->w_cursor = save_cursor; else @@ -6098,7 +6097,7 @@ f_searchdecl(typval_T *argvars, typval_T *rettv) int error = FALSE; char_u *name; - rettv->vval.v_number = 1; /* default: FAIL */ + rettv->vval.v_number = 1; // default: FAIL name = tv_get_string_chk(&argvars[0]); if (argvars[1].v_type != VAR_UNKNOWN) @@ -6125,26 +6124,25 @@ searchpair_cmn(typval_T *argvars, pos_T *match_pos) int flags = 0; char_u nbuf1[NUMBUFLEN]; char_u nbuf2[NUMBUFLEN]; - int retval = 0; /* default: FAIL */ + int retval = 0; // default: FAIL long lnum_stop = 0; long time_limit = 0; - /* Get the three pattern arguments: start, middle, end. Will result in an - * error if not a valid argument. */ + // Get the three pattern arguments: start, middle, end. Will result in an + // error if not a valid argument. spat = tv_get_string_chk(&argvars[0]); mpat = tv_get_string_buf_chk(&argvars[1], nbuf1); epat = tv_get_string_buf_chk(&argvars[2], nbuf2); if (spat == NULL || mpat == NULL || epat == NULL) - goto theend; /* type error */ + goto theend; // type error - /* Handle the optional fourth argument: flags */ - dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */ + // Handle the optional fourth argument: flags + dir = get_search_arg(&argvars[3], &flags); // may set p_ws if (dir == 0) goto theend; - /* Don't accept SP_END or SP_SUBPAT. - * Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set. - */ + // Don't accept SP_END or SP_SUBPAT. + // Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set. if ((flags & (SP_END | SP_SUBPAT)) != 0 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK))) { @@ -6152,11 +6150,11 @@ searchpair_cmn(typval_T *argvars, pos_T *match_pos) goto theend; } - /* Using 'r' implies 'W', otherwise it doesn't work. */ + // Using 'r' implies 'W', otherwise it doesn't work. if (flags & SP_REPEAT) p_ws = FALSE; - /* Optional fifth argument: skip expression */ + // Optional fifth argument: skip expression if (argvars[3].v_type == VAR_UNKNOWN || argvars[4].v_type == VAR_UNKNOWN) skip = NULL; @@ -6166,7 +6164,7 @@ searchpair_cmn(typval_T *argvars, pos_T *match_pos) if (skip->v_type != VAR_FUNC && skip->v_type != VAR_PARTIAL && skip->v_type != VAR_STRING) { - /* Type error */ + // Type error semsg(_(e_invarg2), tv_get_string(&argvars[4])); goto theend; } @@ -6240,15 +6238,15 @@ f_searchpairpos(typval_T *argvars, typval_T *rettv) */ long do_searchpair( - char_u *spat, /* start pattern */ - char_u *mpat, /* middle pattern */ - char_u *epat, /* end pattern */ - int dir, /* BACKWARD or FORWARD */ - typval_T *skip, /* skip expression */ - int flags, /* SP_SETPCMARK and other SP_ values */ + char_u *spat, // start pattern + char_u *mpat, // middle pattern + char_u *epat, // end pattern + int dir, // BACKWARD or FORWARD + typval_T *skip, // skip expression + int flags, // SP_SETPCMARK and other SP_ values pos_T *match_pos, - linenr_T lnum_stop, /* stop at this line if not zero */ - long time_limit UNUSED) /* stop after this many msec */ + linenr_T lnum_stop, // stop at this line if not zero + long time_limit UNUSED) // stop after this many msec { char_u *save_cpo; char_u *pat, *pat2 = NULL, *pat3 = NULL; @@ -6268,17 +6266,17 @@ do_searchpair( proftime_T tm; #endif - /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ + // Make 'cpoptions' empty, the 'l' flag should not be used here. save_cpo = p_cpo; p_cpo = empty_option; #ifdef FEAT_RELTIME - /* Set the time limit, if there is one. */ + // Set the time limit, if there is one. profile_setlimit(time_limit, &tm); #endif - /* Make two search patterns: start/end (pat2, for in nested pairs) and - * start/middle/end (pat3, for the top pair). */ + // Make two search patterns: start/end (pat2, for in nested pairs) and + // start/middle/end (pat3, for the top pair). pat2 = alloc(STRLEN(spat) + STRLEN(epat) + 17); pat3 = alloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25); if (pat2 == NULL || pat3 == NULL) @@ -6294,7 +6292,7 @@ do_searchpair( |