diff options
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 206 |
1 files changed, 102 insertions, 104 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 87d9c312d9..f8186c000e 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -329,9 +329,9 @@ void ex_align(exarg_T *eap) */ static int linelen(int *has_tab) { - char_u *line; - char_u *first; - char_u *last; + char_u *line; + char_u *first; + char_u *last; int save; int len; @@ -363,8 +363,8 @@ static int linelen(int *has_tab) /* Buffer for two lines used during sorting. They are allocated to * contain the longest line being sorted. */ -static char_u *sortbuf1; -static char_u *sortbuf2; +static char_u *sortbuf1; +static char_u *sortbuf2; static int sort_lc; ///< sort using locale static int sort_ic; ///< ignore case @@ -461,9 +461,9 @@ void ex_sort(exarg_T *eap) long maxlen = 0; size_t count = (size_t)(eap->line2 - eap->line1 + 1); size_t i; - char_u *p; - char_u *s; - char_u *s2; + char_u *p; + char_u *s; + char_u *s2; char_u c; // temporary character storage bool unique = false; long deleted; @@ -609,7 +609,7 @@ void ex_sort(exarg_T *eap) } else { nrs[lnum - eap->line1].st_u.num.is_number = true; vim_str2nr(s, NULL, NULL, sort_what, - &nrs[lnum - eap->line1].st_u.num.value, NULL, 0); + &nrs[lnum - eap->line1].st_u.num.value, NULL, 0, false); } } else { s = skipwhite(p); @@ -738,9 +738,9 @@ void ex_retab(exarg_T *eap) long start_col = 0; // For start of white-space string long start_vcol = 0; // For start of white-space string long old_len; - char_u *ptr; - char_u *new_line = (char_u *)1; // init to non-NULL - int did_undo; // called u_save for current line + char_u *ptr; + char_u *new_line = (char_u *)1; // init to non-NULL + bool did_undo; // called u_save for current line long *new_vts_array = NULL; char_u *new_ts_str; // string value of tab argument @@ -772,7 +772,7 @@ void ex_retab(exarg_T *eap) ptr = ml_get(lnum); col = 0; vcol = 0; - did_undo = FALSE; + did_undo = false; for (;; ) { if (ascii_iswhite(ptr[col])) { if (!got_tab && num_spaces == 0) { @@ -906,7 +906,7 @@ void ex_retab(exarg_T *eap) */ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) { - char_u *str; + char_u *str; linenr_T l; linenr_T extra; // Num lines added before line1 linenr_T num_lines; // Num lines moved @@ -1058,7 +1058,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) { linenr_T count; - char_u *p; + char_u *p; count = line2 - line1 + 1; curbuf->b_op_start.lnum = n + 1; @@ -1107,7 +1107,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) msgmore((long)count); } -static char_u *prevcmd = NULL; // the previous command +static char_u *prevcmd = NULL; // the previous command #if defined(EXITFREE) void free_prev_shellcmd(void) @@ -1130,9 +1130,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out linenr_T line2 = eap->line2; // end of range char_u *newcmd = NULL; // the new command bool free_newcmd = false; // need to free() newcmd - char_u *t; - char_u *p; - char_u *trailarg; + char_u *t; + char_u *p; + char_u *trailarg; int len; int scroll_save = msg_scroll; @@ -1240,7 +1240,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out /* Careful: This may recursively call do_bang() again! (because of * autocommands) */ do_filter(line1, line2, eap, newcmd, do_in, do_out); - apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, false, curbuf); } if (free_newcmd) { xfree(newcmd); @@ -1265,13 +1265,13 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, bool do_in, bool do_out) { - char_u *itmp = NULL; - char_u *otmp = NULL; + char_u *itmp = NULL; + char_u *otmp = NULL; linenr_T linecount; linenr_T read_linecount; pos_T cursor_save; - char_u *cmd_buf; - buf_T *old_curbuf = curbuf; + char_u *cmd_buf; + buf_T *old_curbuf = curbuf; int shell_flags = 0; const int stmp = p_stmp; @@ -1353,7 +1353,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, ui_cursor_goto(Rows - 1, 0); if (do_out) { - if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL) { + if (u_save((line2), (linenr_T)(line2 + 1)) == FAIL) { xfree(cmd_buf); goto error; } @@ -1519,7 +1519,7 @@ void do_shell(char_u *cmd, int flags) msg_row = Rows - 1; msg_col = 0; - apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, false, curbuf); } #if !defined(UNIX) @@ -1684,11 +1684,11 @@ void print_line(linenr_T lnum, int use_number, int list) int rename_buffer(char_u *new_fname) { - char_u *fname, *sfname, *xfname; - buf_T *buf; + char_u *fname, *sfname, *xfname; + buf_T *buf; buf = curbuf; - apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf); // buffer changed, don't change name now if (buf != curbuf) { return FAIL; @@ -1722,7 +1722,7 @@ int rename_buffer(char_u *new_fname) } xfree(fname); xfree(sfname); - apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf); // Change directories when the 'acd' option is set. do_autochdir(); return OK; @@ -1795,11 +1795,11 @@ void ex_write(exarg_T *eap) int do_write(exarg_T *eap) { int other; - char_u *fname = NULL; // init to shut up gcc - char_u *ffname; + char_u *fname = NULL; // init to shut up gcc + char_u *ffname; int retval = FAIL; - char_u *free_fname = NULL; - buf_T *alt_buf = NULL; + char_u *free_fname = NULL; + buf_T *alt_buf = NULL; int name_was_missing; if (not_writing()) { // check 'write' option @@ -1879,10 +1879,10 @@ int do_write(exarg_T *eap) if (check_overwrite(eap, curbuf, fname, ffname, other) == OK) { if (eap->cmdidx == CMD_saveas && alt_buf != NULL) { - buf_T *was_curbuf = curbuf; + buf_T *was_curbuf = curbuf; - apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); - apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, alt_buf); + apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf); + apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, alt_buf); if (curbuf != was_curbuf || aborting()) { // buffer changed, don't change name now retval = FAIL; @@ -1903,8 +1903,8 @@ int do_write(exarg_T *eap) alt_buf->b_sfname = curbuf->b_sfname; curbuf->b_sfname = fname; buf_name_changed(curbuf); - apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); - apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, alt_buf); + apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf); + apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, alt_buf); if (!alt_buf->b_p_bl) { alt_buf->b_p_bl = TRUE; apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, alt_buf); @@ -1999,9 +1999,9 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int // For ":w! filename" check that no swap file exists for "filename". if (other && !emsg_silent) { - char_u *dir; - char_u *p; - char_u *swapname; + char_u *dir; + char_u *p; + char_u *swapname; /* We only try the first entry in 'directory', without checking if * it's writable. If the "." directory is not writable the write @@ -2196,7 +2196,7 @@ int getfile(int fnum, char_u *ffname_arg, char_u *sfname_arg, int setpm, linenr_ char_u *sfname = sfname_arg; int other; int retval; - char_u *free_me = NULL; + char_u *free_me = NULL; if (text_locked()) { return GETFILE_ERROR; @@ -2287,25 +2287,25 @@ theend: int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin) { - int other_file; // TRUE if editing another file + bool other_file; // true if editing another file int oldbuf; // TRUE if using existing buffer - int auto_buf = FALSE; /* TRUE if autocommands brought us - into the buffer unexpectedly */ - char_u *new_name = NULL; - int did_set_swapcommand = FALSE; - buf_T *buf; + bool auto_buf = false; // true if autocommands brought us + // into the buffer unexpectedly + char_u *new_name = NULL; + bool did_set_swapcommand = false; + buf_T *buf; bufref_T bufref; bufref_T old_curbuf; - char_u *free_fname = NULL; + char_u *free_fname = NULL; int retval = FAIL; long n; pos_T orig_pos; linenr_T topline = 0; int newcol = -1; int solcol = -1; - pos_T *pos; - char_u *command = NULL; - int did_get_winopts = FALSE; + pos_T *pos; + char_u *command = NULL; + bool did_get_winopts = false; int readfile_flags = 0; bool did_inc_redrawing_disabled = false; long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; @@ -2320,7 +2320,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new if (fnum == curbuf->b_fnum) { // file is already being edited return OK; // nothing to do } - other_file = TRUE; + other_file = true; } else { // if no short name given, use ffname for short name if (sfname == NULL) { @@ -2338,11 +2338,9 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new } if (ffname == NULL) { - other_file = TRUE; - } - // there is no file name - else if (*ffname == NUL && curbuf->b_ffname == NULL) { - other_file = FALSE; + other_file = true; + } else if (*ffname == NUL && curbuf->b_ffname == NULL) { // there is no file name + other_file = false; } else { if (*ffname == NUL) { // re-edit with same file name ffname = curbuf->b_ffname; @@ -2397,7 +2395,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new vim_snprintf(p, len, "%" PRId64 "G", (int64_t)newlnum); } set_vim_var_string(VV_SWAPCOMMAND, p, -1); - did_set_swapcommand = TRUE; + did_set_swapcommand = true; xfree(p); } @@ -2584,7 +2582,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new * before, reset the local window options to the global * values. Also restores old folding stuff. */ get_winopts(curbuf); - did_get_winopts = TRUE; + did_get_winopts = true; } xfree(new_name); au_new_curbuf.br_buf = NULL; @@ -2836,17 +2834,17 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new msg_scroll = FALSE; } if (!msg_scroll) { // wait a bit when overwriting an error msg - check_for_delay(FALSE); + check_for_delay(false); } msg_start(); msg_scroll = msg_scroll_save; - msg_scrolled_ign = TRUE; + msg_scrolled_ign = true; if (!shortmess(SHM_FILEINFO)) { fileinfo(false, true, false); } - msg_scrolled_ign = FALSE; + msg_scrolled_ign = false; } curbuf->b_last_used = time(NULL); @@ -2911,11 +2909,11 @@ static int append_indent = 0; // autoindent for first line */ void ex_append(exarg_T *eap) { - char_u *theline; + char_u *theline; bool did_undo = false; linenr_T lnum = eap->line2; int indent = 0; - char_u *p; + char_u *p; int vcol; int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); @@ -3070,7 +3068,7 @@ void ex_change(exarg_T *eap) // make sure the cursor is not beyond the end of the file now check_cursor_lnum(); - deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum)); + deleted_lines_mark(eap->line1, (eap->line2 - lnum)); // ":append" on the line above the deleted lines. eap->line2 = eap->line1; @@ -3079,9 +3077,9 @@ void ex_change(exarg_T *eap) void ex_z(exarg_T *eap) { - char_u *x; + char_u *x; int64_t bigness; - char_u *kind; + char_u *kind; int minus = 0; linenr_T start, end, curs, i; int j; @@ -3459,8 +3457,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle int delimiter; bool has_second_delim = false; int sublen; - int got_quit = false; - int got_match = false; + bool got_quit = false; + bool got_match = false; int which_pat; char_u *cmd = eap->arg; linenr_T first_line = 0; // first changed line @@ -3648,9 +3646,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle colnr_T copycol; colnr_T matchcol; colnr_T prev_matchcol = MAXCOL; - char_u *new_end, *new_start = NULL; - char_u *p1; - int did_sub = FALSE; + char_u *new_end, *new_start = NULL; + char_u *p1; + bool did_sub = false; int lastone; long nmatch_tl = 0; // nr of lines matched below lnum int do_again; // do it again after joining lines @@ -3708,7 +3706,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // At first match, remember current cursor position. if (!got_match) { setpcmark(); - got_match = TRUE; + got_match = true; } /* @@ -3798,9 +3796,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle skip_match = true; } sub_nsubs++; - did_sub = TRUE; - /* Skip the substitution, unless an expression is used, - * then it is evaluated in the sandbox. */ + did_sub = true; + // Skip the substitution, unless an expression is used, + // then it is evaluated in the sandbox. if (!(sub[0] == '\\' && sub[1] == '=')) { goto skip; } @@ -3831,8 +3829,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle */ while (subflags.do_ask) { if (exmode_active) { - char *prompt; - char_u *resp; + char *prompt; + char_u *resp; colnr_T sc, ec; print_line_no_prefix(lnum, subflags.do_number, subflags.do_list); @@ -4087,7 +4085,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle + copy_len + sublen + 1); // copy the text up to the part that matched - memmove(new_end, sub_firstline + copycol, (size_t)copy_len); + memmove(new_end, sub_firstline + copycol, copy_len); new_end += copy_len; // Finally, at this point we can know where the match actually will @@ -4435,7 +4433,7 @@ skip: /// /// @param count_only used 'n' flag for ":s" /// -/// @return TRUE if a message was given. +/// @return true if a message was given. bool do_sub_msg(bool count_only) { /* @@ -4513,10 +4511,10 @@ void ex_global(exarg_T *eap) linenr_T lnum; // line number according to old situation int ndone = 0; int type; // first char of cmd: 'v' or 'g' - char_u *cmd; // command argument + char_u *cmd; // command argument char_u delim; // delimiter, normally '/' - char_u *pat; + char_u *pat; regmmatch_T regmatch; int match; int which_pat; @@ -4683,7 +4681,7 @@ void free_old_sub(void) /// /// @param undo_sync sync undo when leaving the window /// -/// @return TRUE when it was created. +/// @return true when it was created. bool prepare_tagpreview(bool undo_sync) { /* @@ -4726,20 +4724,20 @@ bool prepare_tagpreview(bool undo_sync) */ void ex_help(exarg_T *eap) { - char_u *arg; - char_u *tag; - FILE *helpfd; // file descriptor of help file + char_u *arg; + char_u *tag; + FILE *helpfd; // file descriptor of help file int n; int i; - win_T *wp; + win_T *wp; int num_matches; - char_u **matches; - char_u *p; + char_u **matches; + char_u *p; int empty_fnum = 0; int alt_fnum = 0; - buf_T *buf; + buf_T *buf; int len; - char_u *lang; + char_u *lang; const bool old_KeyTyped = KeyTyped; if (eap != NULL) { @@ -4940,7 +4938,7 @@ char_u *check_help_lang(char_u *arg) int help_heuristic(char_u *matched_string, int offset, int wrong_case) { int num_letters; - char_u *p; + char_u *p; num_letters = 0; for (p = matched_string; *p; p++) { @@ -4982,8 +4980,8 @@ int help_heuristic(char_u *matched_string, int offset, int wrong_case) */ static int help_compare(const void *s1, const void *s2) { - char *p1; - char *p2; + char *p1; + char *p2; p1 = *(char **)s1 + strlen(*(char **)s1) + 1; p2 = *(char **)s2 + strlen(*(char **)s2) + 1; @@ -5274,7 +5272,7 @@ static void prepare_help_buffer(void) void fix_help_buffer(void) { linenr_T lnum; - char_u *line; + char_u *line; bool in_example = false; // Set filetype to "help". @@ -5338,10 +5336,10 @@ void fix_help_buffer(void) if (rt != NULL && path_full_compare(rt, NameBuff, false, true) != kEqualFiles) { int fcount; - char_u **fnames; - char_u *s; + char_u **fnames; + char_u *s; vimconv_T vc; - char_u *cp; + char_u *cp; // Find all "doc/ *.txt" files in this directory. if (!add_pathsep((char *)NameBuff) @@ -5498,9 +5496,9 @@ static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname, { garray_T ga; int filecount; - char_u **files; - char_u *p1, *p2; - char_u *s; + char_u **files; + char_u *p1, *p2; + char_u *s; TriState utf8 = kNone; bool mix = false; // detected mixed encodings @@ -6125,7 +6123,7 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags) /// List v:oldfiles in a nice way. void ex_oldfiles(exarg_T *eap) { - list_T *l = get_vim_var_list(VV_OLDFILES); + list_T *l = get_vim_var_list(VV_OLDFILES); long nr = 0; if (l == NULL) { |