diff options
author | dundargoc <gocdundar@gmail.com> | 2023-11-11 11:20:08 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-11-11 13:31:17 +0100 |
commit | 8e58d37f2e15ac8540377148e55ed08a039aadb6 (patch) | |
tree | 799dd1f30d375ac8cdeae196fceec9d2ad0f134a /src | |
parent | c4ad15ae324f6460c683a64c44d65e693e1f39bb (diff) | |
download | rneovim-8e58d37f2e15ac8540377148e55ed08a039aadb6.tar.gz rneovim-8e58d37f2e15ac8540377148e55ed08a039aadb6.tar.bz2 rneovim-8e58d37f2e15ac8540377148e55ed08a039aadb6.zip |
refactor: remove redundant casts
Diffstat (limited to 'src')
45 files changed, 146 insertions, 152 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8446f5b383..86e542a1c7 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -923,7 +923,7 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err) FUNC_API_SINCE(6) { try_start(); - buf_T *buf = buflist_new(NULL, NULL, (linenr_T)0, + buf_T *buf = buflist_new(NULL, NULL, 0, BLN_NOOPT | BLN_NEW | (listed ? BLN_LISTED : 0)); try_end(err); if (buf == NULL) { diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index bcf343a5b4..c30734de74 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -393,7 +393,7 @@ static void arglist_del_files(garray_T *alist_ga) bool didone = false; for (int match = 0; match < ARGCOUNT; match++) { - if (vim_regexec(®match, alist_name(&ARGLIST[match]), (colnr_T)0)) { + if (vim_regexec(®match, alist_name(&ARGLIST[match]), 0)) { didone = true; xfree(ARGLIST[match].ae_fname); memmove(ARGLIST + match, ARGLIST + match + 1, diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 1a83dd30c0..b58b5784b4 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2594,7 +2594,7 @@ void do_autocmd_uienter(uint64_t chanid, bool attached) void do_autocmd_focusgained(bool gained) { static bool recursive = false; - static Timestamp last_time = (time_t)0; + static Timestamp last_time = 0; if (recursive) { return; // disallow recursion diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 86b16c18da..4ce4036ac9 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -146,12 +146,12 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags) line_count = curbuf->b_ml.ml_line_count; retval = readfile(read_stdin ? NULL : curbuf->b_ffname, read_stdin ? NULL : curbuf->b_fname, - line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, + line_count, 0, (linenr_T)MAXLNUM, eap, flags | READ_BUFFER, silent); if (retval == OK) { // Delete the binary lines. while (--line_count >= 0) { - ml_delete((linenr_T)1, false); + ml_delete(1, false); } } else { // Delete the converted lines. @@ -294,7 +294,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) #endif retval = readfile(curbuf->b_ffname, curbuf->b_fname, - (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, + 0, 0, (linenr_T)MAXLNUM, eap, flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent); #ifdef UNIX if (read_fifo) { @@ -317,8 +317,8 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) // it possible to retry when 'fileformat' or 'fileencoding' was // guessed wrong. curbuf->b_p_bin = true; - retval = readfile(NULL, NULL, (linenr_T)0, - (linenr_T)0, (linenr_T)MAXLNUM, NULL, + retval = readfile(NULL, NULL, 0, + 0, (linenr_T)MAXLNUM, NULL, flags | (READ_NEW + READ_STDIN), silent); curbuf->b_p_bin = save_bin; if (retval == OK) { @@ -753,7 +753,7 @@ void buf_clear(void) linenr_T line_count = curbuf->b_ml.ml_line_count; extmark_free_all(curbuf); // delete any extmarks while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) { - ml_delete((linenr_T)1, false); + ml_delete(1, false); } deleted_lines_mark(1, line_count); // prepare for display } @@ -1801,7 +1801,7 @@ buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags) xfree(ffname); if (lnum != 0) { buflist_setfpos(buf, (flags & BLN_NOCURWIN) ? NULL : curwin, - lnum, (colnr_T)0, false); + lnum, 0, false); } if ((flags & BLN_NOOPT) == 0) { // Copy the options now, if 'cpo' doesn't have 's' and not done already. @@ -2532,12 +2532,12 @@ static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case) // Ignore case when 'fileignorecase' or the argument is set. rmp->rm_ic = p_fic || ignore_case; - if (vim_regexec(rmp, name, (colnr_T)0)) { + if (vim_regexec(rmp, name, 0)) { match = name; } else if (rmp->regprog != NULL) { // Replace $(HOME) with '~' and try matching again. p = home_replace_save(NULL, name); - if (vim_regexec(rmp, p, (colnr_T)0)) { + if (vim_regexec(rmp, p, 0)) { match = name; } xfree(p); @@ -3035,7 +3035,7 @@ char *getaltfname(bool errmsg) /// Used by qf_init(), main() and doarglist() int buflist_add(char *fname, int flags) { - buf_T *buf = buflist_new(fname, NULL, (linenr_T)0, flags); + buf_T *buf = buflist_new(fname, NULL, 0, flags); if (buf != NULL) { return buf->b_fnum; } @@ -4231,7 +4231,7 @@ bool buf_contents_changed(buf_T *buf) bool differ = true; // Allocate a buffer without putting it in the buffer list. - buf_T *newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); + buf_T *newbuf = buflist_new(NULL, NULL, 1, BLN_DUMMY); if (newbuf == NULL) { return true; } @@ -4246,7 +4246,7 @@ bool buf_contents_changed(buf_T *buf) if (ml_open(curbuf) == OK && readfile(buf->b_ffname, buf->b_fname, - (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, + 0, 0, (linenr_T)MAXLNUM, &ea, READ_NEW | READ_DUMMY, false) == OK) { // compare the two files line by line if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) { diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 2351ddc61b..2b0e6b2525 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -138,7 +138,7 @@ static inline void buf_inc_changedtick(buf_T *const buf) static inline bool buf_is_empty(buf_T *buf) { return buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, (linenr_T)1) == '\0'; + && *ml_get_buf(buf, 1) == '\0'; } #endif // NVIM_BUFFER_H diff --git a/src/nvim/change.c b/src/nvim/change.c index a2657b86aa..39229e1cf0 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -623,7 +623,7 @@ bool file_ff_differs(buf_T *buf, bool ignore_empty) if (ignore_empty && (buf->b_flags & BF_NEW) && buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, (linenr_T)1) == NUL) { + && *ml_get_buf(buf, 1) == NUL) { return false; } if (buf->b_start_ffc != *buf->b_p_ff) { @@ -1726,7 +1726,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) curwin->w_cursor.lnum--; } if ((State & VREPLACE_FLAG) == 0 || old_cursor.lnum >= orig_line_count) { - if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, false) == FAIL) { + if (ml_append(curwin->w_cursor.lnum, p_extra, 0, false) == FAIL) { goto theend; } // Postpone calling changed_lines(), because it would mess up folding diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 51675b81bc..23948e16bb 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2855,7 +2855,7 @@ void ExpandGeneric(const char *const pat, expand_T *xp, regmatch_T *regmatch, ch int score = 0; if (xp->xp_pattern[0] != NUL) { if (!fuzzy) { - match = vim_regexec(regmatch, str, (colnr_T)0); + match = vim_regexec(regmatch, str, 0); } else { score = fuzzy_match_str(str, pat); match = (score != 0); @@ -3141,7 +3141,7 @@ static int ExpandUserDefined(const char *const pat, expand_T *xp, regmatch_T *re int score = 0; if (xp->xp_pattern[0] != NUL) { if (!fuzzy) { - match = vim_regexec(regmatch, s, (colnr_T)0); + match = vim_regexec(regmatch, s, 0); } else { score = fuzzy_match_str(s, pat); match = (score != 0); diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index f1c57c4613..5e196011d7 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -463,7 +463,7 @@ static int del_history_entry(int histype, char *str) if (hisptr->hisstr == NULL) { break; } - if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) { + if (vim_regexec(®match, hisptr->hisstr, 0)) { found = true; hist_free_entry(hisptr); } else { diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 755579a3bc..2d27ae4f0a 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -756,8 +756,8 @@ linenr_T dbg_find_breakpoint(bool file, char *fname, linenr_T after) /// @returns true if profiling is on for a function or sourced file. bool has_profiling(bool file, char *fname, bool *fp) { - return debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp) - != (linenr_T)0; + return debuggy_find(file, fname, 0, &prof_ga, fp) + != 0; } /// Common code for dbg_find_breakpoint() and has_profiling(). @@ -776,7 +776,7 @@ static linenr_T debuggy_find(bool file, char *fname, linenr_T after, garray_T *g // Return quickly when there are no breakpoints. if (GA_EMPTY(gap)) { - return (linenr_T)0; + return 0; } // Replace K_SNR in function name with "<SNR>". @@ -799,7 +799,7 @@ static linenr_T debuggy_find(bool file, char *fname, linenr_T after, garray_T *g // while matching should abort it. prev_got_int = got_int; got_int = false; - if (vim_regexec_prog(&bp->dbg_prog, false, name, (colnr_T)0)) { + if (vim_regexec_prog(&bp->dbg_prog, false, name, 0)) { lnum = bp->dbg_lnum; if (fp != NULL) { *fp = bp->dbg_forceit; diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 920a535ddf..27c4899e05 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -824,7 +824,7 @@ static int diff_write(buf_T *buf, diffin_T *din) // so it shouldn't update the '[ and '] marks. cmdmod.cmod_flags |= CMOD_LOCKMARKS; int r = buf_write(buf, din->din_fname, NULL, - (linenr_T)1, buf->b_ml.ml_line_count, + 1, buf->b_ml.ml_line_count, NULL, false, false, false, true); cmdmod.cmod_flags = save_cmod_flags; free_string_option(buf->b_p_ff); @@ -1208,7 +1208,7 @@ void ex_diffpatch(exarg_T *eap) // Write the current buffer to "tmp_orig". if (buf_write(curbuf, tmp_orig, NULL, - (linenr_T)1, curbuf->b_ml.ml_line_count, + 1, curbuf->b_ml.ml_line_count, NULL, false, false, false, true) == FAIL) { goto theend; } @@ -3106,7 +3106,7 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr // which results in inaccurate reporting of the byte count of // previous contents in buffer-update events. buf_empty = false; - ml_delete((linenr_T)2, false); + ml_delete(2, false); } } linenr_T new_count = dp->df_count[idx_to] + added; @@ -3360,7 +3360,7 @@ linenr_T diff_lnum_win(linenr_T lnum, win_T *wp) if (idx == DB_COUNT) { // safety check - return (linenr_T)0; + return 0; } if (curtab->tp_diff_invalid) { @@ -3386,7 +3386,7 @@ linenr_T diff_lnum_win(linenr_T lnum, win_T *wp) if (i == DB_COUNT) { // safety check - return (linenr_T)0; + return 0; } linenr_T n = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 390cdbb377..e1216663cd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2241,7 +2241,7 @@ int pattern_match(const char *pat, const char *text, bool ic) regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = ic; - matches = vim_regexec_nl(®match, text, (colnr_T)0); + matches = vim_regexec_nl(®match, text, 0); vim_regfree(regmatch.regprog); } p_cpo = save_cpo; @@ -8794,7 +8794,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments, boo return (typval_T){ .v_type = VAR_NUMBER, .v_lock = VAR_UNLOCKED, - .vval.v_number = (varnumber_T)0 + .vval.v_number = 0 }; } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 4b50710649..aff4f1de62 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -963,7 +963,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett funccall_T *fc = create_funccal(fp, rettv); fc->fc_level = ex_nesting_level; // Check if this function has a breakpoint. - fc->fc_breakpoint = dbg_find_breakpoint(false, fp->uf_name, (linenr_T)0); + fc->fc_breakpoint = dbg_find_breakpoint(false, fp->uf_name, 0); fc->fc_dbg_tick = debug_tick; // Set up fields for closure. ga_init(&fc->fc_ufuncs, sizeof(ufunc_T *), 1); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index bb3284a6b8..7400501ee3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -670,7 +670,7 @@ void ex_sort(exarg_T *eap) // Copy the line into a buffer, it may become invalid in // ml_append(). And it's needed for "unique". STRCPY(sortbuf1, s); - if (ml_append(lnum++, sortbuf1, (colnr_T)0, false) == FAIL) { + if (ml_append(lnum++, sortbuf1, 0, false) == FAIL) { break; } new_count += (bcount_t)bytelen; @@ -762,7 +762,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) } for (extra = 0, l = line1; l <= line2; l++) { char *str = xstrdup(ml_get(l + extra)); - ml_append(dest + l - line1, str, (colnr_T)0, false); + ml_append(dest + l - line1, str, 0, false); xfree(str); if (dest < line1) { extra++; @@ -900,7 +900,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) // need to use xstrdup() because the line will be unlocked within // ml_append() char *p = xstrdup(ml_get(line1)); - ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, false); + ml_append(curwin->w_cursor.lnum, p, 0, false); xfree(p); // situation 2: skip already copied lines @@ -1214,7 +1214,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b if (do_out) { if (otmp != NULL) { - if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, + if (readfile(otmp, NULL, line2, 0, (linenr_T)MAXLNUM, eap, READ_FILTER, false) != OK) { if (!aborting()) { msg_putchar('\n'); @@ -1682,7 +1682,7 @@ int do_write(exarg_T *eap) if (other) { if (vim_strchr(p_cpo, CPO_ALTWRITE) != NULL || eap->cmdidx == CMD_saveas) { - alt_buf = setaltfname(ffname, fname, (linenr_T)1); + alt_buf = setaltfname(ffname, fname, 1); } else { alt_buf = buflist_findname(ffname); } @@ -2243,7 +2243,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum oldwin = NULL; } - if ((command != NULL || newlnum > (linenr_T)0) + if ((command != NULL || newlnum > 0) && *get_vim_var_str(VV_SWAPCOMMAND) == NUL) { // Set v:swapcommand for the SwapExists autocommands. const size_t len = (command != NULL) ? strlen(command) + 3 : 30; @@ -2858,7 +2858,7 @@ void ex_append(exarg_T *eap) } did_undo = true; - ml_append(lnum, theline, (colnr_T)0, false); + ml_append(lnum, theline, 0, false); if (empty) { // there are no marks below the inserted lines appended_lines(lnum, 1); @@ -3524,7 +3524,7 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n || lnum <= curwin->w_botline); lnum++) { int nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum, - (colnr_T)0, NULL, NULL); + 0, NULL, NULL); if (nmatch) { colnr_T copycol; colnr_T matchcol; diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h index 148065e096..f101c1b710 100644 --- a/src/nvim/ex_cmds.h +++ b/src/nvim/ex_cmds.h @@ -20,9 +20,9 @@ #define ECMD_NOWINENTER 0x40 // do not trigger BufWinEnter // for lnum argument in do_ecmd() -#define ECMD_LASTL (linenr_T)0 // use last position in loaded file -#define ECMD_LAST ((linenr_T)(-1)) // use last position in all files -#define ECMD_ONE (linenr_T)1 // use first line +#define ECMD_LASTL 0 // use last position in loaded file +#define ECMD_LAST (-1) // use last position in all files +#define ECMD_ONE 1 // use first line /// Previous :substitute replacement string definition typedef struct { diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 199a5bdd43..e4c04007e0 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -436,7 +436,7 @@ int buf_write_all(buf_T *buf, int forceit) buf_T *old_curbuf = curbuf; retval = (buf_write(buf, buf->b_ffname, buf->b_fname, - (linenr_T)1, buf->b_ml.ml_line_count, NULL, + 1, buf->b_ml.ml_line_count, NULL, false, forceit, true, false)); if (curbuf != old_curbuf) { msg_source(HL_ATTR(HLF_W)); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ad09ee6bb1..e8233d512a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3124,7 +3124,7 @@ int cmd_exists(const char *const name) // For ":2match" and ":3match" we need to skip the number. exarg_T ea; ea.cmd = (char *)((*name == '2' || *name == '3') ? name + 1 : name); - ea.cmdidx = (cmdidx_T)0; + ea.cmdidx = 0; ea.flags = 0; int full = false; char *p = find_ex_command(&ea, &full); @@ -3155,7 +3155,7 @@ void f_fullcommand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) exarg_T ea; ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; - ea.cmdidx = (cmdidx_T)0; + ea.cmdidx = 0; ea.flags = 0; char *p = find_ex_command(&ea, NULL); if (p == NULL || ea.cmdidx == CMD_SIZE) { @@ -3177,7 +3177,7 @@ cmdidx_T excmd_get_cmdidx(const char *cmd, size_t len) cmdidx_T idx; if (!one_letter_cmd(cmd, &idx)) { - for (idx = (cmdidx_T)0; (int)idx < CMD_SIZE; idx = (cmdidx_T)((int)idx + 1)) { + for (idx = 0; (int)idx < CMD_SIZE; idx = (cmdidx_T)((int)idx + 1)) { if (strncmp(cmdnames[(int)idx].cmd_name, cmd, len) == 0) { break; } @@ -5554,13 +5554,13 @@ static void ex_read(exarg_T *eap) return; } i = readfile(curbuf->b_ffname, curbuf->b_fname, - eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); + eap->line2, 0, (linenr_T)MAXLNUM, eap, 0, false); } else { if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) { - (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); + (void)setaltfname(eap->arg, eap->arg, 1); } i = readfile(eap->arg, NULL, - eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); + eap->line2, 0, (linenr_T)MAXLNUM, eap, 0, false); } if (i != OK) { if (!aborting()) { @@ -6632,7 +6632,7 @@ static void ex_checkpath(exarg_T *eap) { find_pattern_in_path(NULL, 0, 0, false, false, CHECK_PATH, 1, eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, - (linenr_T)1, (linenr_T)MAXLNUM); + 1, (linenr_T)MAXLNUM); } /// ":psearch" diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index a47c9027a7..b7c07ce02c 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1396,7 +1396,7 @@ void ex_catch(exarg_T *eap) int prev_got_int = got_int; got_int = false; - caught = vim_regexec_nl(®match, current_exception->value, (colnr_T)0); + caught = vim_regexec_nl(®match, current_exception->value, 0); got_int |= prev_got_int; vim_regfree(regmatch.regprog); } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index dbf14f20ad..ce47471976 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4371,7 +4371,7 @@ static int open_cmdwin(void) i = 0; } if (get_histentry(histtype)[i].hisstr != NULL) { - ml_append(lnum++, get_histentry(histtype)[i].hisstr, (colnr_T)0, false); + ml_append(lnum++, get_histentry(histtype)[i].hisstr, 0, false); } } while (i != *get_hisidx(histtype)); } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 424bd33b6c..e57fb9664b 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3132,7 +3132,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options) savebuf = NULL; } else { // Allocate a buffer without putting it in the buffer list. - savebuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); + savebuf = buflist_new(NULL, NULL, 1, BLN_DUMMY); set_bufref(&bufref, savebuf); if (savebuf != NULL && buf == curbuf) { // Open the memline. @@ -3153,7 +3153,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options) if (saved == OK) { curbuf->b_flags |= BF_CHECK_RO; // check for RO again keep_filetype = true; // don't detect 'filetype' - if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, + if (readfile(buf->b_ffname, buf->b_fname, 0, 0, (linenr_T)MAXLNUM, &ea, flags, false) != OK) { if (!aborting()) { semsg(_("E321: Could not reload \"%s\""), buf->b_fname); @@ -3583,10 +3583,10 @@ bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname, // 3. the tail of the file name, when the pattern has no '/'. if (regmatch.regprog != NULL && ((allow_dirs - && (vim_regexec(®match, fname, (colnr_T)0) + && (vim_regexec(®match, fname, 0) || (sfname != NULL - && vim_regexec(®match, sfname, (colnr_T)0)))) - || (!allow_dirs && vim_regexec(®match, tail, (colnr_T)0)))) { + && vim_regexec(®match, sfname, 0)))) + || (!allow_dirs && vim_regexec(®match, tail, 0)))) { result = true; } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index fa33abdce7..b5b55b1b16 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -110,8 +110,8 @@ static const char *e_nofold = N_("E490: No fold found"); // While updating the folds lines between invalid_top and invalid_bot have an // undefined fold level. Only used for the window currently being updated. -static linenr_T invalid_top = (linenr_T)0; -static linenr_T invalid_bot = (linenr_T)0; +static linenr_T invalid_top = 0; +static linenr_T invalid_bot = 0; // When using 'foldexpr' we sometimes get the level of the next line, which // calls foldlevel() to get the level of the current line, which hasn't been @@ -268,7 +268,7 @@ static int foldLevel(linenr_T lnum) { // While updating the folds lines between invalid_top and invalid_bot have // an undefined fold level. Otherwise update the folds first. - if (invalid_top == (linenr_T)0) { + if (invalid_top == 0) { checkupdate(curwin); } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { return prev_lnum_lvl; @@ -748,7 +748,7 @@ void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const } if (last_lnum > 0) { - changed_lines(wp->w_buffer, first_lnum, (colnr_T)0, last_lnum, 0, false); + changed_lines(wp->w_buffer, first_lnum, 0, last_lnum, 0, false); // send one nvim_buf_lines_event at the end // last_lnum is the line *after* the last line of the outermost fold @@ -1129,7 +1129,7 @@ static void checkupdate(win_T *wp) return; } - foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all + foldUpdate(wp, 1, (linenr_T)MAXLNUM); // will update all wp->w_foldinvalid = false; } @@ -1364,7 +1364,7 @@ void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount, } // If appending a line in Insert mode, it should be included in the fold // just above the line. - if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) { + if ((State & MODE_INSERT) && amount == 1 && line2 == MAXLNUM) { line1--; } foldMarkAdjustRecurse(wp, &wp->w_folds, line1, line2, amount, amount_after); @@ -1382,7 +1382,7 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line // In Insert mode an inserted line at the top of a fold is considered part // of the fold, otherwise it isn't. - if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) { + if ((State & MODE_INSERT) && amount == 1 && line2 == MAXLNUM) { top = line1 + 1; } else { top = line1; @@ -1584,7 +1584,7 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end) // Update both changes here, to avoid all folds after the start are // changed when the start marker is inserted and the end isn't. - changed_lines(buf, start.lnum, (colnr_T)0, end.lnum, 0, false); + changed_lines(buf, start.lnum, 0, end.lnum, 0, false); // Note: foldAddMarker() may not actually change start and/or end if // u_save() is unable to save the buffer line, but we send the @@ -1911,7 +1911,7 @@ static void foldtext_cleanup(char *str) static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot) { // Avoid problems when being called recursively. - if (invalid_top != (linenr_T)0) { + if (invalid_top != 0) { return; } @@ -2132,7 +2132,7 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot) } } - invalid_top = (linenr_T)0; + invalid_top = 0; } // foldUpdateIEMSRecurse() {{{2 @@ -2294,12 +2294,12 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, // We will move the start of this fold up, hence we move all // nested folds (with relative line numbers) down. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, - (linenr_T)0, (linenr_T)MAXLNUM, + 0, (linenr_T)MAXLNUM, (fp->fd_top - firstlnum), 0); } else { // Will move fold down, move nested folds relatively up. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, - (linenr_T)0, + 0, (firstlnum - fp->fd_top - 1), (linenr_T)MAXLNUM, (fp->fd_top - firstlnum)); @@ -2537,7 +2537,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, if (fp2->fd_top < flp->lnum) { // Make fold that includes lnum start at lnum. foldMarkAdjustRecurse(flp->wp, &fp2->fd_nested, - (linenr_T)0, (flp->lnum - fp2->fd_top - 1), + 0, (flp->lnum - fp2->fd_top - 1), (linenr_T)MAXLNUM, (fp2->fd_top - flp->lnum)); fp2->fd_len -= flp->lnum - fp2->fd_top; fp2->fd_top = flp->lnum; @@ -2675,7 +2675,7 @@ static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bo if (fp->fd_top + fp->fd_len - 1 > bot) { // 5: Make fold that includes bot start below bot. foldMarkAdjustRecurse(wp, &fp->fd_nested, - (linenr_T)0, (bot - fp->fd_top), + 0, (bot - fp->fd_top), (linenr_T)MAXLNUM, (fp->fd_top - bot - 1)); fp->fd_len -= bot - fp->fd_top + 1; fp->fd_top = bot + 1; @@ -3132,7 +3132,7 @@ int put_folds(FILE *fd, win_T *wp) { if (foldmethodIsManual(wp)) { if (put_line(fd, "silent! normal! zE") == FAIL - || put_folds_recurse(fd, &wp->w_folds, (linenr_T)0) == FAIL + || put_folds_recurse(fd, &wp->w_folds, 0) == FAIL || put_line(fd, "let &fdl = &fdl") == FAIL) { return FAIL; } @@ -3140,7 +3140,7 @@ int put_folds(FILE *fd, win_T *wp) // If some folds are manually opened/closed, need to restore that. if (wp->w_fold_manual) { - return put_foldopen_recurse(fd, wp, &wp->w_folds, (linenr_T)0); + return put_foldopen_recurse(fd, wp, &wp->w_folds, 0); } return OK; diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 8f82220942..ba88d92b0a 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -411,7 +411,7 @@ hash_T hash_hash(const char *key) hash_T hash = (uint8_t)(*key); if (hash == 0) { - return (hash_T)0; + return 0; } // A simplistic algorithm that appears to do very well. diff --git a/src/nvim/help.c b/src/nvim/help.c index 3b4889fb0e..4040c93347 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -823,7 +823,7 @@ void fix_help_buffer(void) } convert_setup(&vc, NULL, NULL); - ml_append(lnum, cp, (colnr_T)0, false); + ml_append(lnum, cp, 0, false); if (cp != IObuff) { xfree(cp); } diff --git a/src/nvim/indent.c b/src/nvim/indent.c index ff21b11abb..05a4fd1450 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -731,7 +731,7 @@ int get_number_indent(linenr_T lnum) // vim_regexec() expects a pointer to a line. This lets us // start matching for the flp beyond any comment leader... - if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0)) { + if (vim_regexec(®match, ml_get(lnum) + lead_len, 0)) { pos.lnum = lnum; pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum)); pos.coladd = 0; diff --git a/src/nvim/main.c b/src/nvim/main.c index 42c98ead66..bb673b51dc 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -603,7 +603,7 @@ int main(int argc, char **argv) // scrollbind, sync the scrollbind now. if (curwin->w_p_diff && curwin->w_p_scb) { update_topline(curwin); - check_scrollbind((linenr_T)0, 0); + check_scrollbind(0, 0); TIME_MSG("diff scrollbinding"); } diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index b54b07fc20..467041e310 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -1339,7 +1339,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat bool match; int score = 0; if (!fuzzy) { - match = vim_regexec(regmatch, p, (colnr_T)0); + match = vim_regexec(regmatch, p, 0); } else { score = fuzzy_match_str(p, pat); match = (score != 0); @@ -1385,7 +1385,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat bool match; int score = 0; if (!fuzzy) { - match = vim_regexec(regmatch, p, (colnr_T)0); + match = vim_regexec(regmatch, p, 0); } else { score = fuzzy_match_str(p, pat); match = (score != 0); diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 1885ec74cd..2a786af802 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -676,7 +676,7 @@ static void fname2fnum(xfmark_T *fm) char *p = path_shorten_fname(NameBuff, IObuff); // buflist_new() will call fmarks_check_names() - (void)buflist_new(NameBuff, p, (linenr_T)1, 0); + (void)buflist_new(NameBuff, p, 1, 0); } // Check all file marks for a name that matches the file name in buf. diff --git a/src/nvim/memline.c b/src/nvim/memline.c index f19a2c5947..42852079ed 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1002,8 +1002,7 @@ void ml_recover(bool checkext) goto theend; } error++; - ml_append(lnum++, _("???MANY LINES MISSING"), - (colnr_T)0, true); + ml_append(lnum++, _("???MANY LINES MISSING"), 0, true); } else { // there is a block pp = hp->bh_data; if (pp->pb_id == PTR_ID) { // it is a pointer block @@ -1027,14 +1026,12 @@ void ml_recover(bool checkext) } if (line_count != 0) { error++; - ml_append(lnum++, _("???LINE COUNT WRONG"), - (colnr_T)0, true); + ml_append(lnum++, _("???LINE COUNT WRONG"), 0, true); } } if (pp->pb_count == 0) { - ml_append(lnum++, _("???EMPTY BLOCK"), - (colnr_T)0, true); + ml_append(lnum++, _("???EMPTY BLOCK"), 0, true); error++; } else if (idx < (int)pp->pb_count) { // go a block deeper if (pp->pb_pointer[idx].pe_bnum < 0) { @@ -1053,8 +1050,7 @@ void ml_recover(bool checkext) } if (cannot_open) { error++; - ml_append(lnum++, _("???LINES MISSING"), - (colnr_T)0, true); + ml_append(lnum++, _("???LINES MISSING"), 0, true); } idx++; // get same block again for next index continue; @@ -1081,8 +1077,7 @@ void ml_recover(bool checkext) goto theend; } error++; - ml_append(lnum++, _("???BLOCK MISSING"), - (colnr_T)0, true); + ml_append(lnum++, _("???BLOCK MISSING"), 0, true); } else { // It is a data block. // Append all the lines in this block. @@ -1093,7 +1088,7 @@ void ml_recover(bool checkext) if (page_count * mfp->mf_page_size != dp->db_txt_end) { ml_append(lnum++, _("??? from here until ???END lines" " may be messed up"), - (colnr_T)0, true); + 0, true); error++; has_error = true; dp->db_txt_end = page_count * mfp->mf_page_size; @@ -1109,7 +1104,7 @@ void ml_recover(bool checkext) ml_append(lnum++, _("??? from here until ???END lines" " may have been inserted/deleted"), - (colnr_T)0, true); + 0, true); error++; has_error = true; } @@ -1119,7 +1114,7 @@ void ml_recover(bool checkext) if ((char *)&(dp->db_index[i]) >= (char *)dp + dp->db_txt_start) { // line count must be wrong error++; - ml_append(lnum++, _("??? lines may be missing"), (colnr_T)0, true); + ml_append(lnum++, _("??? lines may be missing"), 0, true); break; } @@ -1137,10 +1132,10 @@ void ml_recover(bool checkext) did_questions = false; p = (char *)dp + txt_start; } - ml_append(lnum++, p, (colnr_T)0, true); + ml_append(lnum++, p, 0, true); } if (has_error) { - ml_append(lnum++, _("???END"), (colnr_T)0, true); + ml_append(lnum++, _("???END"), 0, true); } } } diff --git a/src/nvim/message.c b/src/nvim/message.c index 2c8c2eb52d..916b6f2464 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2284,7 +2284,7 @@ bool message_filtered(const char *msg) return false; } - bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0); + bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, 0); return cmdmod.cmod_filter_force ? match : !match; } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index b56d5e11ea..8acbf10efd 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2471,7 +2471,7 @@ int op_change(oparg_T *oap) const bool save_finish_op = finish_op; finish_op = false; - retval = edit(NUL, false, (linenr_T)1); + retval = edit(NUL, false, 1); finish_op = save_finish_op; @@ -3110,7 +3110,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags) MB_PTR_ADV(p); } ptr = xstrdup(p); - ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false); + ml_append(curwin->w_cursor.lnum, ptr, 0, false); xfree(ptr); oldp = get_cursor_line_ptr(); @@ -3254,8 +3254,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags) // add a new line if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { - if (ml_append(curbuf->b_ml.ml_line_count, "", - (colnr_T)1, false) == FAIL) { + if (ml_append(curbuf->b_ml.ml_line_count, "", 1, false) == FAIL) { break; } nr_lines++; @@ -3529,7 +3528,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags) STRCPY(newp, y_array[y_size - 1]); STRCAT(newp, ptr); // insert second line - ml_append(lnum, newp, (colnr_T)0, false); + ml_append(lnum, newp, 0, false); new_lnum++; xfree(newp); @@ -3547,7 +3546,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags) for (; i < y_size; i++) { if ((y_type != kMTCharWise || i < y_size - 1)) { - if (ml_append(lnum, y_array[i], (colnr_T)0, false) == FAIL) { + if (ml_append(lnum, y_array[i], 0, false) == FAIL) { goto error; } new_lnum++; @@ -4130,7 +4129,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions // what is added if it is inside these spaces. const int spaces_removed = (int)((curr - curr_start) - spaces[t]); linenr_T lnum = curwin->w_cursor.lnum + t; - colnr_T mincol = (colnr_T)0; + colnr_T mincol = 0; linenr_T lnum_amount = -t; colnr_T col_amount = (colnr_T)(cend - newp - spaces_removed); @@ -4703,7 +4702,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) if (do_unsigned && negative) { if (subtract) { // sticking at zero. - n = (uvarnumber_T)0; + n = 0; } else { // sticking at 2^64 - 1. n = (uvarnumber_T)(-1); diff --git a/src/nvim/option.c b/src/nvim/option.c index 690a03f1a0..b206d935d5 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5468,7 +5468,7 @@ static bool match_str(char *const str, regmatch_T *const regmatch, char **const const char *const fuzzystr, fuzmatch_str_T *const fuzmatch) { if (!fuzzy) { - if (vim_regexec(regmatch, str, (colnr_T)0)) { + if (vim_regexec(regmatch, str, 0)) { if (!test_only) { matches[idx] = xstrdup(str); } @@ -5536,7 +5536,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char *fuzzystr, int *numM count++; } } else if (!fuzzy && options[opt_idx].shortname != NULL - && vim_regexec(regmatch, options[opt_idx].shortname, (colnr_T)0)) { + && vim_regexec(regmatch, options[opt_idx].shortname, 0)) { // Compare against the abbreviated option name (for regular // expression match). Fuzzy matching (previous if) already // matches against both the expanded and abbreviated names. @@ -5709,7 +5709,7 @@ int ExpandSettingSubtract(expand_T *xp, regmatch_T *regmatch, int *numMatches, c continue; } - if (!vim_regexec(regmatch, item, (colnr_T)0)) { + if (!vim_regexec(regmatch, item, 0)) { continue; } diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index be76688e92..80f879e9db 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -561,7 +561,7 @@ static int expand_set_opt_string(optexpand_T *args, char **values, size_t numVal continue; } } - if (vim_regexec(regmatch, *val, (colnr_T)0)) { + if (vim_regexec(regmatch, *val, 0)) { (*matches)[count++] = xstrdup(*val); } } diff --git a/src/nvim/path.c b/src/nvim/path.c index 8cc824337c..f552f24495 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -995,7 +995,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern) if (pattern[0] == '*' && pattern[1] == '*' && vim_ispathsep_nocolon(pattern[2]) && path_cutoff != NULL - && vim_regexec(®match, path_cutoff, (colnr_T)0) + && vim_regexec(®match, path_cutoff, 0) && is_unique(path_cutoff, gap, i)) { sort_again = true; memmove(path, path_cutoff, strlen(path_cutoff) + 1); @@ -1004,7 +1004,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern) // unique path. We start at the end of the path. */ pathsep_p = path + len - 1; while (find_previous_pathsep(path, &pathsep_p)) { - if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) + if (vim_regexec(®match, pathsep_p + 1, 0) && is_unique(pathsep_p + 1, gap, i) && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) { sort_again = true; diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index af4ffd7829..0a5da7d36e 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -762,7 +762,7 @@ static bool pum_set_selected(int n, int repeat) && (curbuf->b_p_bh[0] == 'w')) { // Already a "wipeout" buffer, make it empty. while (!buf_is_empty(curbuf)) { - ml_delete((linenr_T)1, false); + ml_delete(1, false); } } else { // Don't want to sync undo in the current buffer. diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 61157301b6..a9d048d998 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -380,7 +380,7 @@ int qf_init(win_T *wp, const char *restrict efile, char *restrict errorformat, i } return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat, - newlist, (linenr_T)0, (linenr_T)0, qf_title, enc); + newlist, 0, 0, qf_title, enc); } // Maximum number of bytes allowed per line while reading an errorfile. @@ -1605,7 +1605,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf // Always ignore case when looking for a matching error. regmatch.rm_ic = true; regmatch.regprog = fmt_ptr->prog; - int r = vim_regexec(®match, linebuf, (colnr_T)0); + int r = vim_regexec(®match, linebuf, 0); fmt_ptr->prog = regmatch.regprog; int status = QF_FAIL; if (r) { @@ -2173,7 +2173,7 @@ static int qf_get_fnum(qf_list_T *qfl, char *directory, char *fname) xfree(ptr); } else { xfree(qf_last_bufname); - buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT); + buf = buflist_new(bufname, NULL, 0, BLN_NOOPT); qf_last_bufname = (bufname == ptr) ? bufname : xstrdup(bufname); set_bufref(&qf_last_bufref, buf); } @@ -2788,11 +2788,11 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int no_write_message(); return FAIL; } - retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, + retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, 1, ECMD_HIDE + ECMD_SET_HELP, prev_winid == curwin->handle ? curwin : NULL); } else { - retval = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1, + retval = buflist_getfile(qf_ptr->qf_fnum, 1, GETF_SETMARK | GETF_SWITCH, forceit); } // If a location list, check whether the associated window is still @@ -4137,7 +4137,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) { // If deletion fails, this loop may run forever, so // signal error and return. - if (ml_delete((linenr_T)1, false) == FAIL) { + if (ml_delete(1, false) == FAIL) { internal_error("qf_fill_buffer()"); return; } @@ -5450,7 +5450,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo // ":lcd %:p:h" changes the meaning of short path names. os_dirname(dirname_start, MAXPATHL); - time_t seconds = (time_t)0; + time_t seconds = 0; for (int fi = 0; fi < cmd_args->fcount && !got_int && cmd_args->tomatch > 0; fi++) { char *fname = path_try_shorten_fname(cmd_args->fnames[fi]); if (time(NULL) > seconds) { @@ -5688,7 +5688,7 @@ static void restore_start_dir(char *dirname_start) static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resulting_dir) { // Allocate a buffer without putting it in the buffer list. - buf_T *newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); + buf_T *newbuf = buflist_new(NULL, NULL, 1, BLN_DUMMY); if (newbuf == NULL) { return NULL; } @@ -5720,7 +5720,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin bufref_T newbuf_to_wipe; newbuf_to_wipe.br_buf = NULL; - int readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0, + int readfile_result = readfile(fname, NULL, 0, 0, (linenr_T)MAXLNUM, NULL, READ_NEW | READ_DUMMY, false); newbuf->b_locked--; @@ -5960,7 +5960,7 @@ static int qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict) qf_info_T *const qi = qf_alloc_stack(QFLT_INTERNAL); if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat, - true, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) { + true, 0, 0, NULL, NULL) > 0) { (void)get_errorlist(qi, NULL, 0, 0, l); qf_free(&qi->qf_lists[0]); } @@ -6588,7 +6588,7 @@ static int qf_setprop_items_from_lines(qf_info_T *qi, int qf_idx, const dict_T * qf_free_items(&qi->qf_lists[qf_idx]); } if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat, - false, (linenr_T)0, (linenr_T)0, NULL, NULL) >= 0) { + false, 0, 0, NULL, NULL) >= 0) { retval = OK; } @@ -7051,7 +7051,7 @@ void ex_cexpr(exarg_T *eap) int res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, (eap->cmdidx != CMD_caddexpr && eap->cmdidx != CMD_laddexpr), - (linenr_T)0, (linenr_T)0, + 0, 0, qf_cmdtitle(*eap->cmdlinep), NULL); if (qf_stack_empty(qi)) { decr_quickfix_busy(); @@ -7112,7 +7112,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch) while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { char *line = IObuff; - if (vim_regexec(p_regmatch, line, (colnr_T)0)) { + if (vim_regexec(p_regmatch, line, 0)) { int l = (int)strlen(line); // remove trailing CR, LF, spaces, etc. diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 99b62763ed..c908f94e5d 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -7287,7 +7287,7 @@ static int bt_regexec_both(uint8_t *line, colnr_T startcol, proftime_T *tm, int if (REG_MULTI) { prog = (bt_regprog_T *)rex.reg_mmatch->regprog; - line = (uint8_t *)reg_getline((linenr_T)0); + line = (uint8_t *)reg_getline(0); rex.reg_startpos = rex.reg_mmatch->startpos; rex.reg_endpos = rex.reg_mmatch->endpos; } else { @@ -7396,7 +7396,7 @@ static int bt_regexec_both(uint8_t *line, colnr_T startcol, proftime_T *tm, int // if not currently on the first line, get it again if (rex.lnum != 0) { rex.lnum = 0; - rex.line = (uint8_t *)reg_getline((linenr_T)0); + rex.line = (uint8_t *)reg_getline(0); } if (rex.line[col] == NUL) { break; @@ -15242,7 +15242,7 @@ static int nfa_regexec_both(uint8_t *line, colnr_T startcol, proftime_T *tm, int if (REG_MULTI) { prog = (nfa_regprog_T *)rex.reg_mmatch->regprog; - line = (uint8_t *)reg_getline((linenr_T)0); // relative to the cursor + line = (uint8_t *)reg_getline(0); // relative to the cursor rex.reg_startpos = rex.reg_mmatch->startpos; rex.reg_endpos = rex.reg_mmatch->endpos; } else { diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 360088758d..47bbe64c96 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2136,7 +2136,7 @@ int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid) cookie.finished = false; // Check if this script has a breakpoint. - cookie.breakpoint = dbg_find_breakpoint(true, fname_exp, (linenr_T)0); + cookie.breakpoint = dbg_find_breakpoint(true, fname_exp, 0); cookie.fname = fname_exp; cookie.dbg_tick = debug_tick; @@ -2495,7 +2495,7 @@ void f_getscriptinfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) continue; } - if (filterpat && !vim_regexec(®match, si->sn_name, (colnr_T)0)) { + if (filterpat && !vim_regexec(®match, si->sn_name, 0)) { continue; } diff --git a/src/nvim/search.c b/src/nvim/search.c index cee526d416..aa942d8185 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3635,7 +3635,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool while (true) { if (incl_regmatch.regprog != NULL - && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { + && vim_regexec(&incl_regmatch, line, 0)) { char *p_fname = (curr_fname == curbuf->b_fname) ? curbuf->b_ffname : curr_fname; @@ -3810,7 +3810,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool search_line: define_matched = false; if (def_regmatch.regprog != NULL - && vim_regexec(&def_regmatch, line, (colnr_T)0)) { + && vim_regexec(&def_regmatch, line, 0)) { // Pattern must be first identifier after 'define', so skip // to that position before checking for match of pattern. Also // don't let it match beyond the end of this identifier. diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 6a6adbd866..b70429928d 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -448,7 +448,7 @@ static linenr_T buf_change_sign_type(buf_T *buf, int markId, const char *group, } } - return (linenr_T)0; + return 0; } /// Return the sign attrs which has the attribute specified by 'type'. Returns diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 864a55b12b..5f5cabdc40 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3322,7 +3322,7 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg) if (do_region && region_names != NULL && pat == NULL) { vim_snprintf(IObuff, IOSIZE, "/regions=%s", region_names); - ml_append(lnum++, IObuff, (colnr_T)0, false); + ml_append(lnum++, IObuff, 0, false); } else { do_region = false; } @@ -3337,7 +3337,7 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg) if (pat == NULL) { vim_snprintf(IObuff, IOSIZE, "# file: %s", slang->sl_fname); - ml_append(lnum++, IObuff, (colnr_T)0, false); + ml_append(lnum++, IObuff, 0, false); } // When matching with a pattern and there are no prefixes only use @@ -3506,7 +3506,7 @@ static void dump_word(slang_T *slang, char *word, char *pat, Direction *dir, int } } - ml_append(lnum, p, (colnr_T)0, false); + ml_append(lnum, p, 0, false); } else if (((dumpflags & DUMPFLAG_ICASE) ? mb_strnicmp(p, pat, strlen(pat)) == 0 : strncmp(p, pat, strlen(pat)) == 0) diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 3d3da3c3d6..555af8bc50 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -3438,7 +3438,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_ && (ae->ae_chop == NULL || strlen(ae->ae_chop) < wordlen) && (ae->ae_prog == NULL - || vim_regexec_prog(&ae->ae_prog, false, word, (colnr_T)0)) + || vim_regexec_prog(&ae->ae_prog, false, word, 0)) && (((condit & CONDIT_CFIX) == 0) == ((condit & CONDIT_AFF) == 0 || ae->ae_flags == NULL @@ -4344,7 +4344,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname) // <HEADER>: <fileID> <versionnr> // <fileID> size_t fwv = fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, 1, fd); - if (fwv != (size_t)1) { + if (fwv != 1) { // Catch first write error, don't try writing more. goto theend; } @@ -4702,7 +4702,7 @@ theend: retval = FAIL; } - if (fwv != (size_t)1) { + if (fwv != 1) { retval = FAIL; } if (retval == FAIL) { @@ -5181,7 +5181,7 @@ static void sug_write(spellinfo_T *spin, char *fname) spell_message(spin, IObuff); // <SUGHEADER>: <fileID> <versionnr> <timestamp> - if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) { // <fileID> + if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, 1, fd) != 1) { // <fileID> emsg(_(e_write)); goto theend; } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 0d1fd2d966..42b2302fa5 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -758,7 +758,7 @@ static int syn_match_linecont(linenr_T lnum) regmatch.rmm_ic = syn_block->b_syn_linecont_ic; regmatch.regprog = syn_block->b_syn_linecont_prog; - int r = syn_regexec(®match, lnum, (colnr_T)0, + int r = syn_regexec(®match, lnum, 0, IF_SYN_TIME(&syn_block->b_syn_linecont_time)); syn_block->b_syn_linecont_prog = regmatch.regprog; @@ -5049,7 +5049,7 @@ static int get_id_list(char **const arg, const int keylen, int16_t **const list, regmatch.rm_ic = true; id = 0; for (int i = highlight_num_groups(); --i >= 0;) { - if (vim_regexec(®match, highlight_group_name(i), (colnr_T)0)) { + if (vim_regexec(®match, highlight_group_name(i), 0)) { if (round == 2) { // Got more items than expected; can happen // when adding items that match: diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 7a175926d2..a916313982 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1903,13 +1903,13 @@ static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_ if (!match && st->orgpat->regmatch.regprog != NULL) { char cc = *tagpp->tagname_end; *tagpp->tagname_end = NUL; - match = vim_regexec(&st->orgpat->regmatch, tagpp->tagname, (colnr_T)0); + match = vim_regexec(&st->orgpat->regmatch, tagpp->tagname, 0); if (match) { margs->matchoff = (int)(st->orgpat->regmatch.startp[0] - tagpp->tagname); if (st->orgpat->regmatch.rm_ic) { st->orgpat->regmatch.rm_ic = false; margs->match_no_ic = vim_regexec(&st->orgpat->regmatch, - tagpp->tagname, (colnr_T)0); + tagpp->tagname, 0); st->orgpat->regmatch.rm_ic = true; } } @@ -2932,7 +2932,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) if (getfile_result == GETFILE_UNUSED) { // Careful: getfile() may trigger autocommands and call jumpto_tag() // recursively. - getfile_result = getfile(0, fname, NULL, true, (linenr_T)0, forceit); + getfile_result = getfile(0, fname, NULL, true, 0, forceit); } keep_help_flag = false; diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 53424506f3..c17273255d 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1146,7 +1146,7 @@ again: if (do_searchpair("<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)", "", "</[^>]*>", BACKWARD, NULL, 0, - NULL, (linenr_T)0, 0) <= 0) { + NULL, 0, 0) <= 0) { curwin->w_cursor = old_pos; goto theend; } @@ -1172,7 +1172,7 @@ again: "<%.*s\\>\\%%(\\_s\\_[^>]\\{-}\\_[^/]>\\|\\_s\\?>\\)\\c", len, p); snprintf(epat, epat_len, "</%.*s>\\c", len, p); - const int r = do_searchpair(spat, "", epat, FORWARD, NULL, 0, NULL, (linenr_T)0, 0); + const int r = do_searchpair(spat, "", epat, FORWARD, NULL, 0, NULL, 0, 0); xfree(spat); xfree(epat); diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 4ced4e93c4..741c8b36e5 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -2358,9 +2358,9 @@ static void u_undoredo(int undo, bool do_buf_event) // If the file is empty, there is an empty line 1 that we // should get rid of, by replacing it with the new line if (empty_buffer && lnum == 0) { - ml_replace((linenr_T)1, uep->ue_array[i], true); + ml_replace(1, uep->ue_array[i], true); } else { - ml_append(lnum, uep->ue_array[i], (colnr_T)0, false); + ml_append(lnum, uep->ue_array[i], 0, false); } xfree(uep->ue_array[i]); } @@ -3029,7 +3029,7 @@ void u_undoline(void) // first save the line for the 'u' command if (u_savecommon(curbuf, curbuf->b_u_line_lnum - 1, - curbuf->b_u_line_lnum + 1, (linenr_T)0, false) == FAIL) { + curbuf->b_u_line_lnum + 1, 0, false) == FAIL) { return; } diff --git a/src/nvim/window.c b/src/nvim/window.c index d1b8d7c7b5..929047a330 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -228,7 +228,7 @@ void do_window(int nchar, int Prenum, int xchar) if (!curbuf_locked() && win_split(0, 0) == OK) { (void)buflist_getfile(Prenum == 0 ? curwin->w_alt_fnum : Prenum, - (linenr_T)0, GETF_ALT, false); + 0, GETF_ALT, false); } break; |