From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/assert.h | 2 +- src/nvim/buffer.c | 10 +++--- src/nvim/change.c | 18 +++++------ src/nvim/charset.c | 4 +-- src/nvim/cursor_shape.c | 34 ++++++++++---------- src/nvim/diff.c | 10 +++--- src/nvim/drawline.c | 11 +++---- src/nvim/edit.c | 18 +++++------ src/nvim/eval.c | 12 +++---- src/nvim/eval/funcs.c | 62 ++++++++++++++++++------------------- src/nvim/eval/typval.c | 4 +-- src/nvim/eval/typval.h | 2 +- src/nvim/eval/userfunc.c | 2 +- src/nvim/eval/vars.c | 6 ++-- src/nvim/ex_cmds.c | 36 ++++++++++----------- src/nvim/ex_docmd.c | 18 +++++------ src/nvim/ex_getln.c | 6 ++-- src/nvim/ex_session.c | 2 +- src/nvim/fileio.c | 12 +++---- src/nvim/fold.c | 12 +++---- src/nvim/generators/gen_options.lua | 2 +- src/nvim/getchar.c | 40 ++++++++++++------------ src/nvim/help.c | 2 +- src/nvim/highlight_group.c | 2 +- src/nvim/indent.c | 6 ++-- src/nvim/input.c | 2 +- src/nvim/insexpand.c | 6 ++-- src/nvim/lua/executor.c | 2 +- src/nvim/lua/spell.c | 2 +- src/nvim/lua/stdlib.c | 8 ++--- src/nvim/lua/xdiff.c | 20 ++++++------ src/nvim/main.c | 6 ++-- src/nvim/mark.c | 12 +++---- src/nvim/mbyte.c | 2 +- src/nvim/memfile.c | 2 +- src/nvim/memline.c | 20 ++++++------ src/nvim/message.c | 2 +- src/nvim/mouse.c | 8 ++--- src/nvim/normal.c | 44 +++++++++++++------------- src/nvim/ops.c | 46 +++++++++++++-------------- src/nvim/os/shell.c | 10 +++--- src/nvim/profile.c | 4 +-- src/nvim/quickfix.c | 4 +-- src/nvim/regexp.c | 46 +++++++++++++-------------- src/nvim/search.c | 48 ++++++++++++++-------------- src/nvim/search.h | 2 +- src/nvim/shada.c | 6 ++-- src/nvim/sign.c | 8 ++--- src/nvim/spell.c | 2 +- src/nvim/spellsuggest.c | 4 +-- src/nvim/statusline.c | 8 ++--- src/nvim/syntax.c | 20 ++++++------ src/nvim/tag.c | 4 +-- src/nvim/textobject.c | 30 +++++++++--------- src/nvim/undo.c | 6 ++-- src/nvim/window.c | 8 ++--- src/xdiff/xdiff.h | 4 +-- 57 files changed, 362 insertions(+), 367 deletions(-) (limited to 'src') diff --git a/src/nvim/assert.h b/src/nvim/assert.h index 1941f4c33c..90d242fd3e 100644 --- a/src/nvim/assert.h +++ b/src/nvim/assert.h @@ -57,7 +57,7 @@ // the easiest case, when the mode is C11 (generic compiler) or Clang // advertises explicit support for c_static_assert, meaning it won't warn. -#if __STDC_VERSION__ >= 201112L || __has_feature(c_static_assert) +#if __STDC_VERSION__ >= 201112 || __has_feature(c_static_assert) # define STATIC_ASSERT_STATEMENT(cond, msg) _Static_assert(cond, msg) // if we're dealing with gcc >= 4.6 in C99 mode, we can still use // _Static_assert but we need to suppress warnings, this is pretty ugly. diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 076cf63913..86b16c18da 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -987,7 +987,7 @@ void handle_swap_exists(bufref_T *old_curbuf) || old_curbuf->br_buf == curbuf) { // Block autocommands here because curwin->w_buffer is NULL. block_autocmds(); - buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED); + buf = buflist_new(NULL, NULL, 1, BLN_CURBUF | BLN_LISTED); unblock_autocmds(); } else { buf = old_curbuf->br_buf; @@ -1886,7 +1886,7 @@ buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags) emsg(_("W14: Warning: List of file names overflow")); if (emsg_silent == 0 && !in_assert_fails) { ui_flush(); - os_delay(3001L, true); // make sure it is noticed + os_delay(3001, true); // make sure it is noticed } top_file_num = 1; } @@ -3496,9 +3496,9 @@ void get_rel_pos(win_T *wp, char *buf, int buflen) } else if (above <= 0) { xstrlcpy(buf, _("Top"), (size_t)buflen); } else { - int perc = (above > 1000000L - ? (int)(above / ((above + below) / 100L)) - : (int)(above * 100L / (above + below))); + int perc = (above > 1000000 + ? (above / ((above + below) / 100)) + : (above * 100 / (above + below))); char *p = buf; size_t l = (size_t)buflen; diff --git a/src/nvim/change.c b/src/nvim/change.c index acc657a1c2..a2657b86aa 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -92,7 +92,7 @@ void change_warning(buf_T *buf, int col) (void)msg_end(); if (msg_silent == 0 && !silent_mode && ui_active()) { ui_flush(); - os_delay(1002L, true); // give the user time to think about it + os_delay(1002, true); // give the user time to think about it } buf->b_did_warn = true; redraw_cmdline = false; // don't redraw and erase the message @@ -131,7 +131,7 @@ void changed(buf_T *buf) // and don't let the emsg() set msg_scroll. if (need_wait_return && emsg_silent == 0 && !in_assert_fails) { ui_flush(); - os_delay(2002L, true); + os_delay(2002, true); wait_return(true); msg_scroll = save_msg_scroll; } else { @@ -457,7 +457,7 @@ void appended_lines(linenr_T lnum, linenr_T count) /// Like appended_lines(), but adjust marks first. void appended_lines_mark(linenr_T lnum, int count) { - mark_adjust(lnum + 1, (linenr_T)MAXLNUM, (linenr_T)count, 0L, kExtmarkUndo); + mark_adjust(lnum + 1, (linenr_T)MAXLNUM, (linenr_T)count, 0, kExtmarkUndo); changed_lines(curbuf, lnum + 1, 0, lnum + 1, (linenr_T)count, true); } @@ -552,7 +552,7 @@ void changed_lines(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnume, linen wlnum = diff_lnum_win(lnum, wp); if (wlnum > 0) { buf_redraw_changed_lines_later(wp->w_buffer, wlnum, - lnume - lnum + wlnum, 0L); + lnume - lnum + wlnum, 0); } } } @@ -823,7 +823,7 @@ int del_char(bool fixpos) if (*get_cursor_pos_ptr() == NUL) { return FAIL; } - return del_chars(1L, fixpos); + return del_chars(1, fixpos); } /// Like del_bytes(), but delete characters instead of bytes. @@ -1731,7 +1731,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } // Postpone calling changed_lines(), because it would mess up folding // with markers. - mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L, kExtmarkNOOP); + mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1, 0, kExtmarkNOOP); did_append = true; } else { // In MODE_VREPLACE state we are starting to replace the next line. @@ -1822,14 +1822,14 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) saved_line = NULL; if (did_append) { changed_lines(curbuf, curwin->w_cursor.lnum, curwin->w_cursor.col, - curwin->w_cursor.lnum + 1, 1L, true); + curwin->w_cursor.lnum + 1, 1, true); did_append = false; // Move marks after the line break to the new line. if (flags & OPENLINE_MARKFIX) { mark_col_adjust(curwin->w_cursor.lnum, curwin->w_cursor.col + less_cols_off, - 1L, -less_cols, 0); + 1, -less_cols, 0); } // Always move extmarks - Here we move only the line where the // cursor is, the previous mark_adjust takes care of the lines after @@ -1847,7 +1847,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) curwin->w_cursor.lnum = old_cursor.lnum + 1; } if (did_append) { - changed_lines(curbuf, curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L, true); + changed_lines(curbuf, curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1, true); // bail out and just get the final length of the line we just manipulated bcount_t extra = (bcount_t)strlen(ml_get(curwin->w_cursor.lnum)); extmark_splice(curbuf, (int)curwin->w_cursor.lnum - 1, 0, diff --git a/src/nvim/charset.c b/src/nvim/charset.c index c2722af971..eb858b8d5e 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1167,14 +1167,14 @@ long getdigits_long(char **pp, bool strict, long def) /// Gets a int32_t number from a string. /// /// @see getdigits -int32_t getdigits_int32(char **pp, bool strict, long def) +int32_t getdigits_int32(char **pp, bool strict, int32_t def) { intmax_t number = getdigits(pp, strict, def); #if SIZEOF_INTMAX_T > 4 if (strict) { assert(number >= INT32_MIN && number <= INT32_MAX); } else if (!(number >= INT32_MIN && number <= INT32_MAX)) { - return (int32_t)def; + return def; } #endif return (int32_t)number; diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index ba5f30c20f..92b7568593 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -32,23 +32,23 @@ static const char e_digit_expected[] = N_("E548: Digit expected"); cursorentry_T shape_table[SHAPE_IDX_COUNT] = { // Values are set by 'guicursor' and 'mouseshape'. // Adjust the SHAPE_IDX_ defines when changing this! - { "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR + SHAPE_MOUSE }, - { "visual", 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR + SHAPE_MOUSE }, - { "insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR + SHAPE_MOUSE }, - { "replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR + SHAPE_MOUSE }, - { "cmdline_normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR + SHAPE_MOUSE }, - { "cmdline_insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR + SHAPE_MOUSE }, - { "cmdline_replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR + SHAPE_MOUSE }, - { "operator", 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR + SHAPE_MOUSE }, - { "visual_select", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR + SHAPE_MOUSE }, - { "cmdline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE }, - { "statusline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE }, - { "statusline_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE }, - { "vsep_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE }, - { "vsep_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE }, - { "more", 0, 0, 0, 0L, 0L, 0L, 0, 0, "m", SHAPE_MOUSE }, - { "more_lastline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "ml", SHAPE_MOUSE }, - { "showmatch", 0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR }, + { "normal", 0, 0, 0, 700, 400, 250, 0, 0, "n", SHAPE_CURSOR + SHAPE_MOUSE }, + { "visual", 0, 0, 0, 700, 400, 250, 0, 0, "v", SHAPE_CURSOR + SHAPE_MOUSE }, + { "insert", 0, 0, 0, 700, 400, 250, 0, 0, "i", SHAPE_CURSOR + SHAPE_MOUSE }, + { "replace", 0, 0, 0, 700, 400, 250, 0, 0, "r", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_normal", 0, 0, 0, 700, 400, 250, 0, 0, "c", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_insert", 0, 0, 0, 700, 400, 250, 0, 0, "ci", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_replace", 0, 0, 0, 700, 400, 250, 0, 0, "cr", SHAPE_CURSOR + SHAPE_MOUSE }, + { "operator", 0, 0, 0, 700, 400, 250, 0, 0, "o", SHAPE_CURSOR + SHAPE_MOUSE }, + { "visual_select", 0, 0, 0, 700, 400, 250, 0, 0, "ve", SHAPE_CURSOR + SHAPE_MOUSE }, + { "cmdline_hover", 0, 0, 0, 0, 0, 0, 0, 0, "e", SHAPE_MOUSE }, + { "statusline_hover", 0, 0, 0, 0, 0, 0, 0, 0, "s", SHAPE_MOUSE }, + { "statusline_drag", 0, 0, 0, 0, 0, 0, 0, 0, "sd", SHAPE_MOUSE }, + { "vsep_hover", 0, 0, 0, 0, 0, 0, 0, 0, "vs", SHAPE_MOUSE }, + { "vsep_drag", 0, 0, 0, 0, 0, 0, 0, 0, "vd", SHAPE_MOUSE }, + { "more", 0, 0, 0, 0, 0, 0, 0, 0, "m", SHAPE_MOUSE }, + { "more_lastline", 0, 0, 0, 0, 0, 0, 0, 0, "ml", SHAPE_MOUSE }, + { "showmatch", 0, 0, 0, 100, 100, 100, 0, 0, "sm", SHAPE_CURSOR }, }; /// Converts cursor_shapes into an Array of Dictionaries diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 8516e33638..920a535ddf 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -106,9 +106,9 @@ typedef struct { // used for recording hunks from xdiff typedef struct { linenr_T lnum_orig; - long count_orig; + int count_orig; linenr_T lnum_new; - long count_new; + int count_new; } diffhunk_T; // two diff inputs and one result @@ -771,7 +771,7 @@ static int diff_write_buffer(buf_T *buf, mmfile_t *m, linenr_T start, linenr_T e return FAIL; } m->ptr = ptr; - m->size = (long)len; + m->size = (int)len; len = 0; for (linenr_T lnum = start; lnum <= end; lnum++) { @@ -2571,7 +2571,7 @@ int diffopt_changed(void) // recompute the scroll binding with the new option value, may // remove or add filler lines - check_scrollbind((linenr_T)0, 0L); + check_scrollbind(0, 0); return OK; } @@ -3217,7 +3217,7 @@ bool diff_mode_buf(buf_T *buf) /// @param count /// /// @return FAIL if there isn't such a diff block. -int diff_move_to(int dir, long count) +int diff_move_to(int dir, int count) { linenr_T lnum = curwin->w_cursor.lnum; int idx = diff_buf_idx(curbuf); diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 3d63d2c24c..a28b6a8aa1 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2832,12 +2832,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl } if (((wp->w_p_cuc - && (int)wp->w_virtcol >= VCOL_HLC - eol_hl_off - && (int)wp->w_virtcol < - (long)grid->cols * (wlv.row - startrow + 1) + v + && wp->w_virtcol >= VCOL_HLC - eol_hl_off + && wp->w_virtcol < grid->cols * (ptrdiff_t)(wlv.row - startrow + 1) + v && lnum != wp->w_cursor.lnum) || draw_color_col || wlv.line_attr_lowprio || wlv.line_attr - || wlv.diff_hlf != (hlf_T)0 || has_virttext)) { + || wlv.diff_hlf != 0 || has_virttext)) { int rightmost_vcol = 0; if (wp->w_p_cuc) { @@ -2881,7 +2880,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl int col_attr = base_attr; - if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol) { + if (wp->w_p_cuc && VCOL_HLC == wp->w_virtcol) { col_attr = cuc_attr; } else if (draw_color_col && VCOL_HLC == *color_cols) { col_attr = hl_combine_attr(wlv.line_attr_lowprio, mc_attr); @@ -2978,7 +2977,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl && search_attr == 0 && area_attr == 0 && wlv.filler_todo <= 0) { - if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol + if (wp->w_p_cuc && VCOL_HLC == wp->w_virtcol && lnum != wp->w_cursor.lnum) { vcol_save_attr = wlv.char_attr; wlv.char_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUC), wlv.char_attr); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1e1b67483c..2b332ea414 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -760,7 +760,7 @@ static int insert_handle_key(InsertState *s) case Ctrl_A: // For ^@ the trailing ESC will end the insert, unless there is an // error. - if (stuff_inserted(NUL, 1L, (s->c == Ctrl_A)) == FAIL + if (stuff_inserted(NUL, 1, (s->c == Ctrl_A)) == FAIL && s->c != Ctrl_A) { return 0; // exit insert mode } @@ -2066,7 +2066,7 @@ void insertchar(int c, int flags, int second_indent) if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0 && (force_format || virtcol > (colnr_T)textwidth)) { - do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0); + do_internal = (fex_format(curwin->w_cursor.lnum, 1, c) != 0); // It may be required to save for undo again, e.g. when setline() // was called. ins_need_undo = true; @@ -2634,7 +2634,7 @@ int cursor_up(linenr_T n, int upd_topline) /// Move the cursor down "n" lines in window "wp". /// Takes care of closed folds. -void cursor_down_inner(win_T *wp, long n) +void cursor_down_inner(win_T *wp, int n) { linenr_T lnum = wp->w_cursor.lnum; linenr_T line_count = wp->w_buffer->b_ml.ml_line_count; @@ -2667,7 +2667,7 @@ void cursor_down_inner(win_T *wp, long n) } /// @param upd_topline When true: update topline -int cursor_down(long n, int upd_topline) +int cursor_down(int n, int upd_topline) { // This fails if the cursor is already in the last line. if (n > 0 && curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) { @@ -2692,7 +2692,7 @@ int cursor_down(long n, int upd_topline) /// @param c Command character to be inserted /// @param count Repeat this many times /// @param no_esc Don't add an ESC at the end -int stuff_inserted(int c, long count, int no_esc) +int stuff_inserted(int c, int count, int no_esc) { char *esc_ptr; char *ptr; @@ -4099,7 +4099,7 @@ static void ins_s_left(void) if (!end_change) { AppendCharToRedobuff(K_S_LEFT); } - (void)bck_word(1L, false, false); + (void)bck_word(1, false, false); curwin->w_set_curswant = true; } else { vim_beep(BO_CRSR); @@ -4158,7 +4158,7 @@ static void ins_s_right(void) if (!end_change) { AppendCharToRedobuff(K_S_RIGHT); } - (void)fwd_word(1L, false, 0); + (void)fwd_word(1, false, 0); curwin->w_set_curswant = true; } else { vim_beep(BO_CRSR); @@ -4175,7 +4175,7 @@ static void ins_up(bool startcol) undisplay_dollar(); tpos = curwin->w_cursor; - if (cursor_up(1L, true) == OK) { + if (cursor_up(1, true) == OK) { if (startcol) { coladvance(getvcol_nolist(&Insstart)); } @@ -4223,7 +4223,7 @@ static void ins_down(bool startcol) undisplay_dollar(); tpos = curwin->w_cursor; - if (cursor_down(1L, true) == OK) { + if (cursor_down(1, true) == OK) { if (startcol) { coladvance(getvcol_nolist(&Insstart)); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8ffc6fd179..a3ea5169fd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -454,8 +454,8 @@ void eval_init(void) set_vim_var_dict(VV_EVENT, tv_dict_alloc_lock(VAR_FIXED)); set_vim_var_list(VV_ERRORS, tv_list_alloc(kListLenUnknown)); set_vim_var_nr(VV_STDERR, CHAN_STDERR); - set_vim_var_nr(VV_SEARCHFORWARD, 1L); - set_vim_var_nr(VV_HLSEARCH, 1L); + set_vim_var_nr(VV_SEARCHFORWARD, 1); + set_vim_var_nr(VV_HLSEARCH, 1); set_vim_var_nr(VV_COUNT1, 1); set_vim_var_nr(VV_TYPE_NUMBER, VAR_TYPE_NUMBER); set_vim_var_nr(VV_TYPE_STRING, VAR_TYPE_STRING); @@ -6629,14 +6629,14 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret } // Get the line number. - pos.lnum = (linenr_T)tv_list_find_nr(l, 0L, &error); + pos.lnum = (linenr_T)tv_list_find_nr(l, 0, &error); if (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count) { // Invalid line number. return NULL; } // Get the column number. - pos.col = (colnr_T)tv_list_find_nr(l, 1L, &error); + pos.col = (colnr_T)tv_list_find_nr(l, 1, &error); if (error) { return NULL; } @@ -6648,7 +6648,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret } // We accept "$" for the column number: last column. - listitem_T *li = tv_list_find(l, 1L); + listitem_T *li = tv_list_find(l, 1); if (li != NULL && TV_LIST_ITEM_TV(li)->v_type == VAR_STRING && TV_LIST_ITEM_TV(li)->vval.v_string != NULL && strcmp(TV_LIST_ITEM_TV(li)->vval.v_string, "$") == 0) { @@ -6663,7 +6663,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret pos.col--; // Get the virtual offset. Defaults to zero. - pos.coladd = (colnr_T)tv_list_find_nr(l, 2L, &error); + pos.coladd = (colnr_T)tv_list_find_nr(l, 2, &error); if (error) { pos.coladd = 0; } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index c12fd9fd31..505a91813a 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -983,7 +983,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) int64_t idx = 0; if (argvars[2].v_type != VAR_UNKNOWN && argvars[3].v_type != VAR_UNKNOWN) { - idx = (long)tv_get_number_chk(&argvars[3], &error); + idx = (int64_t)tv_get_number_chk(&argvars[3], &error); } if (!error) { n = count_list(argvars[0].vval.v_list, &argvars[1], idx, ic); @@ -1860,11 +1860,11 @@ static void flatten_common(typval_T *argvars, typval_T *rettv, bool make_copy) return; } - long maxdepth; + int maxdepth; if (argvars[1].v_type == VAR_UNKNOWN) { maxdepth = 999999; } else { - maxdepth = (long)tv_get_number_chk(&argvars[1], &error); + maxdepth = (int)tv_get_number_chk(&argvars[1], &error); if (error) { return; } @@ -1929,7 +1929,7 @@ static void extend_list(typval_T *argvars, const char *arg_errmsg, bool is_new, listitem_T *item; if (argvars[2].v_type != VAR_UNKNOWN) { - long before = (long)tv_get_number_chk(&argvars[2], &error); + int before = (int)tv_get_number_chk(&argvars[2], &error); if (error) { return; // Type error; errmsg already given. } @@ -1937,7 +1937,7 @@ static void extend_list(typval_T *argvars, const char *arg_errmsg, bool is_new, if (before == tv_list_len(l1)) { item = NULL; } else { - item = tv_list_find(l1, (int)before); + item = tv_list_find(l1, before); if (item == NULL) { semsg(_(e_list_index_out_of_range_nr), (int64_t)before); return; @@ -3394,7 +3394,7 @@ static void f_indent(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "index()" function static void f_index(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - long idx = 0; + int idx = 0; bool ic = false; rettv->vval.v_number = -1; @@ -3421,7 +3421,7 @@ static void f_index(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) for (idx = start; idx < tv_blob_len(b); idx++) { typval_T tv; tv.v_type = VAR_NUMBER; - tv.vval.v_number = tv_blob_get(b, (int)idx); + tv.vval.v_number = tv_blob_get(b, idx); if (tv_equal(&tv, &argvars[1], ic, false)) { rettv->vval.v_number = idx; return; @@ -3447,7 +3447,7 @@ static void f_index(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (error || idx == -1) { item = NULL; } else { - item = tv_list_find(l, (int)idx); + item = tv_list_find(l, idx); assert(item != NULL); } if (argvars[3].v_type != VAR_UNKNOWN) { @@ -3690,11 +3690,11 @@ static void f_insert(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - long before = 0; + int before = 0; const int len = tv_blob_len(b); if (argvars[2].v_type != VAR_UNKNOWN) { - before = (long)tv_get_number_chk(&argvars[2], &error); + before = (int)tv_get_number_chk(&argvars[2], &error); if (error) { return; // type error; errmsg already given } @@ -4511,7 +4511,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, colnr_T startcol = 0; bool match = false; list_T *l = NULL; - long idx = 0; + int idx = 0; char *tofree = NULL; // Make 'cpoptions' empty, the 'l' flag should not be used here. @@ -4550,7 +4550,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, li = tv_list_first(l); } else { expr = str = (char *)tv_get_string(&argvars[0]); - len = (long)strlen(str); + len = (int64_t)strlen(str); } char patbuf[NUMBUFLEN]; @@ -4571,7 +4571,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, if (idx == -1) { goto theend; } - li = tv_list_find(l, (int)idx); + li = tv_list_find(l, idx); } else { if (start < 0) { start = 0; @@ -5414,10 +5414,10 @@ static void f_rand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) goto theend; } - typval_T *const tvx = TV_LIST_ITEM_TV(tv_list_find(l, 0L)); - typval_T *const tvy = TV_LIST_ITEM_TV(tv_list_find(l, 1L)); - typval_T *const tvz = TV_LIST_ITEM_TV(tv_list_find(l, 2L)); - typval_T *const tvw = TV_LIST_ITEM_TV(tv_list_find(l, 3L)); + typval_T *const tvx = TV_LIST_ITEM_TV(tv_list_find(l, 0)); + typval_T *const tvy = TV_LIST_ITEM_TV(tv_list_find(l, 1)); + typval_T *const tvz = TV_LIST_ITEM_TV(tv_list_find(l, 2)); + typval_T *const tvw = TV_LIST_ITEM_TV(tv_list_find(l, 3)); if (tvx->v_type != VAR_NUMBER) { goto theend; } @@ -5861,8 +5861,8 @@ static int list2proftime(typval_T *arg, proftime_T *tm) FUNC_ATTR_NONNULL_ALL } bool error = false; - varnumber_T n1 = tv_list_find_nr(arg->vval.v_list, 0L, &error); - varnumber_T n2 = tv_list_find_nr(arg->vval.v_list, 1L, &error); + varnumber_T n1 = tv_list_find_nr(arg->vval.v_list, 0, &error); + varnumber_T n2 = tv_list_find_nr(arg->vval.v_list, 1, &error); if (error) { return FAIL; } @@ -7050,8 +7050,8 @@ static int searchpair_cmn(typval_T *argvars, pos_T *match_pos) } } - retval = (int)do_searchpair(spat, mpat, epat, dir, skip, - flags, match_pos, lnum_stop, time_limit); + retval = do_searchpair(spat, mpat, epat, dir, skip, + flags, match_pos, lnum_stop, time_limit); theend: p_ws = save_p_ws; @@ -7096,12 +7096,12 @@ static void f_searchpairpos(typval_T *argvars, typval_T *rettv, EvalFuncData fpt /// @param time_limit stop after this many msec /// /// @returns 0 or -1 for no match, -long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir, - const typval_T *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, - int64_t time_limit) +int do_searchpair(const char *spat, const char *mpat, const char *epat, int dir, + const typval_T *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, + int64_t time_limit) FUNC_ATTR_NONNULL_ARG(1, 2, 3) { - long retval = 0; + int retval = 0; int nest = 1; bool use_skip = false; int options = SEARCH_KEEP; @@ -7147,7 +7147,7 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir .sa_tm = &tm, }; - int n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, + int n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1, options, RE_SEARCH, &sia); if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) { // didn't find it or found the first match again: FAIL @@ -7489,7 +7489,7 @@ static void f_setpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } /// Translate a register type string to the yank type and block length -static int get_yank_type(char **const pp, MotionType *const yank_type, long *const block_len) +static int get_yank_type(char **const pp, MotionType *const yank_type, int *const block_len) FUNC_ATTR_NONNULL_ALL { char *stropt = *pp; @@ -7507,7 +7507,7 @@ static int get_yank_type(char **const pp, MotionType *const yank_type, long *con *yank_type = kMTBlockWise; if (ascii_isdigit(stropt[1])) { stropt++; - *block_len = getdigits_long(&stropt, false, 0) - 1; + *block_len = getdigits_int(&stropt, false, 0) - 1; stropt--; } break; @@ -7523,7 +7523,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { bool append = false; - long block_len = -1; + int block_len = -1; MotionType yank_type = kMTUnknown; rettv->vval.v_number = 1; // FAIL is default. @@ -7735,11 +7735,11 @@ static void f_shiftwidth(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) rettv->vval.v_number = 0; if (argvars[0].v_type != VAR_UNKNOWN) { - long col = (long)tv_get_number_chk(argvars, NULL); + colnr_T col = (colnr_T)tv_get_number_chk(argvars, NULL); if (col < 0) { return; // type error; errmsg already given } - rettv->vval.v_number = get_sw_value_col(curbuf, (colnr_T)col); + rettv->vval.v_number = get_sw_value_col(curbuf, col); return; } rettv->vval.v_number = get_sw_value(curbuf); diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index badb948584..3657e182af 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -678,7 +678,7 @@ int tv_list_assign_range(list_T *const dest, list_T *const src, const int idx1_a listitem_T *src_li; // Check whether any of the list items is locked before making any changes. - long idx = idx1; + int idx = idx1; listitem_T *dest_li = first_li; for (src_li = tv_list_first(src); src_li != NULL && dest_li != NULL;) { if (value_check_lock(TV_LIST_ITEM_TV(dest_li)->v_lock, varname, TV_CSTRING)) { @@ -738,7 +738,7 @@ int tv_list_assign_range(list_T *const dest, list_T *const src, const int idx1_a /// @param[in] maxdepth Maximum depth that will be flattened /// /// @return OK or FAIL -void tv_list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdepth) +void tv_list_flatten(list_T *list, listitem_T *first, int64_t maxitems, int64_t maxdepth) FUNC_ATTR_NONNULL_ARG(1) { listitem_T *item; diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 7a168ba183..d2baabb424 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -235,7 +235,7 @@ static inline long tv_dict_len(const dict_T *d) static inline long tv_dict_len(const dict_T *const d) { if (d == NULL) { - return 0L; + return 0; } return (long)d->dv_hashtab.ht_used; } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index ff86f74338..6e7b1e4d67 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2422,7 +2422,7 @@ void ex_function(exarg_T *eap) } else { xfree(line_to_free); if (eap->getline == NULL) { - theline = getcmdline(':', 0L, indent, do_concat); + theline = getcmdline(':', 0, indent, do_concat); } else { theline = eap->getline(':', eap->cookie, indent, do_concat); } diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index ed400b2ee9..33256b78e1 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1088,13 +1088,13 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_ /// Unlet one item or a range of items from a list. /// Return OK or FAIL. -static void tv_list_unlet_range(list_T *const l, listitem_T *const li_first, const long n1_arg, - const bool has_n2, const long n2) +static void tv_list_unlet_range(list_T *const l, listitem_T *const li_first, const int n1_arg, + const bool has_n2, const int n2) { assert(l != NULL); // Delete a range of List items. listitem_T *li_last = li_first; - long n1 = n1_arg; + int n1 = n1_arg; while (true) { listitem_T *const li = TV_LIST_ITEM_NEXT(l, li_last); n1++; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index fa10dd0805..2857465db0 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -323,7 +323,7 @@ void ex_align(exarg_T *eap) } (void)set_indent(new_indent, 0); // set indent } - changed_lines(curbuf, eap->line1, 0, eap->line2 + 1, 0L, true); + changed_lines(curbuf, eap->line1, 0, eap->line2 + 1, 0, true); curwin->w_cursor = save_curpos; beginline(BL_WHITE | BL_FIX); } @@ -696,7 +696,7 @@ void ex_sort(exarg_T *eap) mark_adjust(eap->line2 - deleted, eap->line2, MAXLNUM, -deleted, kExtmarkNOOP); msgmore(-deleted); } else if (deleted < 0) { - mark_adjust(eap->line2, MAXLNUM, -deleted, 0L, kExtmarkNOOP); + mark_adjust(eap->line2, MAXLNUM, -deleted, 0, kExtmarkNOOP); } if (change_occurred || deleted != 0) { @@ -783,7 +783,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) // And Finally we adjust the marks we put at the end of the file back to // their final destination at the new text position -- webb last_line = curbuf->b_ml.ml_line_count; - mark_adjust_nofold(line1, line2, last_line - line2, 0L, kExtmarkNOOP); + mark_adjust_nofold(line1, line2, last_line - line2, 0, kExtmarkNOOP); disable_fold_update++; changed_lines(curbuf, last_line - num_lines + 1, 0, last_line + 1, num_lines, false); @@ -792,7 +792,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) int line_off = 0; bcount_t byte_off = 0; if (dest >= line2) { - mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L, kExtmarkNOOP); + mark_adjust_nofold(line2 + 1, dest, -num_lines, 0, kExtmarkNOOP); FOR_ALL_TAB_WINDOWS(tab, win) { if (win->w_buffer == curbuf) { foldMoveRange(win, &win->w_folds, line1, line2, dest); @@ -805,7 +805,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) line_off = -num_lines; byte_off = -extent_byte; } else { - mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0L, kExtmarkNOOP); + mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0, kExtmarkNOOP); FOR_ALL_TAB_WINDOWS(tab, win) { if (win->w_buffer == curbuf) { foldMoveRange(win, &win->w_folds, dest + 1, line1 - 1, line2); @@ -820,7 +820,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) curbuf->b_op_start.col = curbuf->b_op_end.col = 0; } mark_adjust_nofold(last_line - num_lines + 1, last_line, - -(last_line - dest - extra), 0L, kExtmarkNOOP); + -(last_line - dest - extra), 0, kExtmarkNOOP); disable_fold_update++; changed_lines(curbuf, last_line - num_lines + 1, 0, last_line + 1, -extra, false); @@ -861,9 +861,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) if (dest > last_line + 1) { dest = last_line + 1; } - changed_lines(curbuf, line1, 0, dest, 0L, false); + changed_lines(curbuf, line1, 0, dest, 0, false); } else { - changed_lines(curbuf, dest + 1, 0, line1 + num_lines, 0L, false); + changed_lines(curbuf, dest + 1, 0, line1 + num_lines, 0, false); } // send nvim_buf_lines_event regarding lines that were deleted @@ -1243,13 +1243,13 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b // end of each line? if (read_linecount >= linecount) { // move all marks from old lines to new lines - mark_adjust(line1, line2, linecount, 0L, kExtmarkNOOP); + mark_adjust(line1, line2, linecount, 0, kExtmarkNOOP); } else { // move marks from old lines to new lines, delete marks // that are in deleted lines - mark_adjust(line1, line1 + read_linecount - 1, linecount, 0L, + mark_adjust(line1, line1 + read_linecount - 1, linecount, 0, kExtmarkNOOP); - mark_adjust(line1 + read_linecount, line2, MAXLNUM, 0L, + mark_adjust(line1 + read_linecount, line2, MAXLNUM, 0, kExtmarkNOOP); } } @@ -2283,7 +2283,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum if (command != NULL) { tlnum = (linenr_T)atol(command); if (tlnum <= 0) { - tlnum = 1L; + tlnum = 1; } } // Add BLN_NOCURWIN to avoid a new wininfo items are associated @@ -2295,7 +2295,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum } goto theend; } - buf = buflist_new(ffname, sfname, 0L, + buf = buflist_new(ffname, sfname, 0, BLN_CURBUF | (flags & ECMD_SET_HELP ? 0 : BLN_LISTED)); // Autocmds may change curwin and curbuf. if (oldwin != NULL) { @@ -2861,16 +2861,16 @@ void ex_append(exarg_T *eap) ml_append(lnum, theline, (colnr_T)0, false); if (empty) { // there are no marks below the inserted lines - appended_lines(lnum, 1L); + appended_lines(lnum, 1); } else { - appended_lines_mark(lnum, 1L); + appended_lines_mark(lnum, 1); } xfree(theline); lnum++; if (empty) { - ml_delete(2L, false); + ml_delete(2, false); empty = 0; } } @@ -4020,10 +4020,10 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n *p1 = NUL; // truncate up to the CR ml_append(lnum - 1, new_start, (colnr_T)(p1 - new_start + 1), false); - mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L, kExtmarkNOOP); + mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1, 0, kExtmarkNOOP); if (subflags.do_ask) { - appended_lines(lnum - 1, 1L); + appended_lines(lnum - 1, 1); } else { if (first_line == 0) { first_line = lnum; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7e750dfcc3..c83b00f77f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -939,7 +939,7 @@ static char *get_loop_line(int c, void *cookie, int indent, bool do_concat) char *line; // First time inside the ":while"/":for": get line normally. if (cp->getline == NULL) { - line = getcmdline(c, 0L, indent, do_concat); + line = getcmdline(c, 0, indent, do_concat); } else { line = cp->getline(c, cp->cookie, indent, do_concat); } @@ -3431,7 +3431,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int } searchcmdlen = 0; flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; - if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) { + if (!do_search(NULL, c, c, cmd, 1, flags, NULL)) { curwin->w_cursor = pos; cmd = NULL; goto error; @@ -3468,7 +3468,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int pos.coladd = 0; if (searchit(curwin, curbuf, &pos, NULL, *cmd == '?' ? BACKWARD : FORWARD, - "", 1L, SEARCH_MSG, i, NULL) != FAIL) { + "", 1, SEARCH_MSG, i, NULL) != FAIL) { lnum = pos.lnum; } else { cmd = NULL; @@ -5576,13 +5576,13 @@ static void ex_read(exarg_T *eap) } else { lnum = 1; } - if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) { + if (*ml_get(lnum) == NUL && u_savedel(lnum, 1) == OK) { ml_delete(lnum, false); if (curwin->w_cursor.lnum > 1 && curwin->w_cursor.lnum >= lnum) { curwin->w_cursor.lnum--; } - deleted_lines_mark(lnum, 1L); + deleted_lines_mark(lnum, 1); } } redraw_curbuf_later(UPD_VALID); @@ -5812,7 +5812,7 @@ static void ex_sleep(exarg_T *eap) case 'm': break; case NUL: - len *= 1000L; break; + len *= 1000; break; default: semsg(_(e_invarg2), eap->arg); return; } @@ -5877,7 +5877,7 @@ static void ex_wincmd(exarg_T *eap) // Pass flags on for ":vertical wincmd ]". postponed_split_flags = cmdmod.cmod_split; postponed_split_tab = cmdmod.cmod_tab; - do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); + do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0, xchar); postponed_split_flags = 0; postponed_split_tab = 0; } @@ -6630,7 +6630,7 @@ void exec_normal(bool was_typed) static void ex_checkpath(exarg_T *eap) { - find_pattern_in_path(NULL, 0, 0, false, false, CHECK_PATH, 1L, + 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); } @@ -6986,7 +6986,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum break; case SPEC_CFILE: // file name under cursor - result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); + result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1, NULL); if (result == NULL) { *errormsg = ""; return NULL; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 80a1410dbc..dbf14f20ad 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -453,7 +453,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state ui_flush(); emsg_off++; // So it doesn't beep if bad expr // Set the time limit to half a second. - tm = profile_setlimit(500L); + tm = profile_setlimit(500); if (!p_hls) { search_flags += SEARCH_KEEP; } @@ -2747,7 +2747,7 @@ char *getcmdline_prompt(const int firstc, const char *const prompt, const int at int msg_silent_saved = msg_silent; msg_silent = 0; - char *const ret = (char *)command_line_enter(firstc, 1L, 0, false); + char *const ret = (char *)command_line_enter(firstc, 1, 0, false); if (did_save_ccline) { restore_cmdline(&save_ccline); @@ -2947,7 +2947,7 @@ char *getexline(int c, void *cookie, int indent, bool do_concat) (void)vgetc(); } - return getcmdline(c, 1L, indent, do_concat); + return getcmdline(c, 1, indent, do_concat); } bool cmdline_overstrike(void) diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index bbe57b486d..32235e158b 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -629,7 +629,7 @@ static int makeopens(FILE *fd, char *dirnow) && buf->b_p_bl) { if (fprintf(fd, "badd +%" PRId64 " ", buf->b_wininfo == NULL - ? (int64_t)1L + ? 1 : (int64_t)buf->b_wininfo->wi_mark.mark.lnum) < 0 || ses_fname(fd, buf, &ssop_flags, true) == FAIL) { return FAIL; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9e60f30cb5..804c9cec11 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -718,7 +718,7 @@ retry: if (read_buffer) { read_buf_lnum = 1; read_buf_col = 0; - } else if (read_stdin || vim_lseek(fd, (off_T)0L, SEEK_SET) != 0) { + } else if (read_stdin || vim_lseek(fd, 0, SEEK_SET) != 0) { // Can't rewind the file, give up. error = true; goto failed; @@ -880,9 +880,9 @@ retry: // Use buffer >= 64K. Add linerest to double the size if the // line gets very long, to avoid a lot of copying. But don't // read more than 1 Mbyte at a time, so we can be interrupted. - size = 0x10000L + linerest; - if (size > 0x100000L) { - size = 0x100000L; + size = 0x10000 + linerest; + if (size > 0x100000) { + size = 0x100000; } } @@ -1531,7 +1531,7 @@ rewind_retry: if (try_unix && !read_stdin && (read_buffer - || vim_lseek(fd, (off_T)0L, SEEK_SET) == 0)) { + || vim_lseek(fd, 0, SEEK_SET) == 0)) { fileformat = EOL_UNIX; if (set_options) { set_fileformat(EOL_UNIX, OPT_LOCAL); @@ -3054,7 +3054,7 @@ int buf_check_timestamp(buf_T *buf) if (emsg_silent == 0 && !in_assert_fails) { ui_flush(); // give the user some time to think about it - os_delay(1004L, true); + os_delay(1004, true); // don't redraw and erase the message redraw_cmdline = false; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index a3aabede5e..fa33abdce7 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -650,7 +650,7 @@ void foldCreate(win_T *wp, pos_T start, pos_T end) // We want the new fold to be closed. If it would remain open because // of using 'foldlevel', need to adjust fd_flags of containing folds. if (use_level && !closed && level < wp->w_p_fdl) { - closeFold(start, 1L); + closeFold(start, 1); } if (!use_level) { wp->w_fold_manual = true; @@ -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, 0L, false); + changed_lines(wp->w_buffer, first_lnum, (colnr_T)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 @@ -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, 0L, false); + changed_lines(buf, start.lnum, (colnr_T)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 @@ -2295,7 +2295,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, // nested folds (with relative line numbers) down. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, (linenr_T)0, (linenr_T)MAXLNUM, - (fp->fd_top - firstlnum), 0L); + (fp->fd_top - firstlnum), 0); } else { // Will move fold down, move nested folds relatively up. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, @@ -2367,7 +2367,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, fp->fd_len = startlnum - fp->fd_top; foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, fp->fd_len, (linenr_T)MAXLNUM, - (linenr_T)MAXLNUM, 0L); + (linenr_T)MAXLNUM, 0); fold_changed = true; } } else { @@ -2861,7 +2861,7 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2) // If the last nested fold in fp1 touches the first nested fold in fp2, // merge them recursively. - if (foldFind(gap1, fp1->fd_len - 1, &fp3) && foldFind(gap2, 0L, &fp4)) { + if (foldFind(gap1, fp1->fd_len - 1, &fp3) && foldFind(gap2, 0, &fp4)) { foldMerge(wp, fp3, gap2, fp4); } diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 05def71caa..c9878bf3b0 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -112,7 +112,7 @@ local value_dumpers = { string=cstr, boolean=function(v) return v and 'true' or 'false' end, number=function(v) return ('%iL'):format(v) end, - ['nil']=function(_) return '0L' end, + ['nil']=function(_) return '0' end, } local get_value = function(v) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5f3b143998..8b1e2f9105 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -295,7 +295,7 @@ static void add_num_buff(buffheader_T *buf, int n) { char number[32]; snprintf(number, sizeof(number), "%d", n); - add_buff(buf, number, -1L); + add_buff(buf, number, -1); } /// Add character 'c' to buffer "buf". @@ -327,7 +327,7 @@ static void add_char_buff(buffheader_T *buf, int c) temp[0] = (char)c; temp[1] = NUL; } - add_buff(buf, temp, -1L); + add_buff(buf, temp, -1); } } @@ -419,7 +419,7 @@ void flush_buffers(flush_buffers_T flush_typeahead) // We have to get all characters, because we may delete the first // part of an escape sequence. In an xterm we get one char at a // time and we have to get them all. - while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0) {} + while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10) != 0) {} } typebuf.tb_off = MAXMAPLEN; typebuf.tb_len = 0; @@ -488,7 +488,7 @@ void saveRedobuff(save_redo_T *save_redo) return; } - add_buff(&redobuff, s, -1L); + add_buff(&redobuff, s, -1); xfree(s); } @@ -507,7 +507,7 @@ void restoreRedobuff(save_redo_T *save_redo) void AppendToRedobuff(const char *s) { if (!block_redo) { - add_buff(&redobuff, s, -1L); + add_buff(&redobuff, s, -1); } } @@ -553,7 +553,7 @@ void AppendToRedobuffLit(const char *str, int len) // CTRL-V '0' must be inserted as CTRL-V 048. if (*s == NUL && c == '0') { - add_buff(&redobuff, "048", 3L); + add_buff(&redobuff, "048", 3); } else { add_char_buff(&redobuff, c); } @@ -571,7 +571,7 @@ void AppendToRedobuffSpec(const char *s) while (*s != NUL) { if ((uint8_t)(*s) == K_SPECIAL && s[1] != NUL && s[2] != NUL) { // Insert special key literally. - add_buff(&redobuff, s, 3L); + add_buff(&redobuff, s, 3); s += 3; } else { add_char_buff(&redobuff, mb_cptr2char_adv(&s)); @@ -600,14 +600,14 @@ void AppendNumberToRedobuff(int n) /// K_SPECIAL must already have been escaped. void stuffReadbuff(const char *s) { - add_buff(&readbuf1, s, -1L); + add_buff(&readbuf1, s, -1); } /// Append string "s" to the redo stuff buffer. /// @remark K_SPECIAL must already have been escaped. void stuffRedoReadbuff(const char *s) { - add_buff(&readbuf2, s, -1L); + add_buff(&readbuf2, s, -1); } void stuffReadbuffLen(const char *s, ptrdiff_t len) @@ -764,7 +764,7 @@ int start_redo(int count, bool old_redo) // copy the buffer name, if present if (c == '"') { - add_buff(&readbuf2, "\"", 1L); + add_buff(&readbuf2, "\"", 1); c = read_redo(false, old_redo); // if a numbered buffer is used, increment the number @@ -822,7 +822,7 @@ int start_redo_ins(void) while ((c = read_redo(false, false)) != NUL) { if (vim_strchr("AaIiRrOo", c) != NULL) { if (c == 'O' || c == 'o') { - add_buff(&readbuf2, NL_STR, -1L); + add_buff(&readbuf2, NL_STR, -1); } break; } @@ -2424,7 +2424,7 @@ static int vgetorpeek(bool advance) int keylen = 0; if (got_int) { // flush all input - c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L); + c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0); // If inchar() returns true (script file was active) or we // are inside a mapping, get out of Insert mode. @@ -2503,7 +2503,7 @@ static int vgetorpeek(bool advance) && typebuf.tb_maplen == 0 && (State & MODE_INSERT) && (p_timeout || (keylen == KEYLEN_PART_KEY && p_ttimeout)) - && (c = inchar(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len, 3, 25L)) == 0) { + && (c = inchar(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len, 3, 25)) == 0) { if (mode_displayed) { unshowmode(true); mode_deleted = true; @@ -2688,16 +2688,16 @@ static int vgetorpeek(bool advance) timedout = false; } - long wait_time = 0; + int wait_time = 0; if (advance) { if (typebuf.tb_len == 0 || !(p_timeout || (p_ttimeout && keylen == KEYLEN_PART_KEY))) { // blocking wait - wait_time = -1L; + wait_time = -1; } else if (keylen == KEYLEN_PART_KEY && p_ttm >= 0) { - wait_time = (long)p_ttm; + wait_time = (int)p_ttm; } else { - wait_time = (long)p_tm; + wait_time = (int)p_tm; } } @@ -2802,7 +2802,7 @@ int inchar(uint8_t *buf, int maxlen, long wait_time) int retesc = false; // Return ESC with gotint. const int tb_change_cnt = typebuf.tb_change_cnt; - if (wait_time == -1L || wait_time > 100L) { + if (wait_time == -1 || wait_time > 100) { // flush output before waiting ui_flush(); } @@ -2852,7 +2852,7 @@ int inchar(uint8_t *buf, int maxlen, long wait_time) uint8_t dum[DUM_LEN + 1]; while (true) { - len = os_inchar(dum, DUM_LEN, 0L, 0, NULL); + len = os_inchar(dum, DUM_LEN, 0, 0, NULL); if (len == 0 || (len == 1 && dum[0] == Ctrl_C)) { break; } @@ -2862,7 +2862,7 @@ int inchar(uint8_t *buf, int maxlen, long wait_time) // Always flush the output characters when getting input characters // from the user and not just peeking. - if (wait_time == -1L || wait_time > 10L) { + if (wait_time == -1 || wait_time > 10) { ui_flush(); } diff --git a/src/nvim/help.c b/src/nvim/help.c index d8b6afec27..3b4889fb0e 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -838,7 +838,7 @@ void fix_help_buffer(void) } linenr_T appended = lnum - lnum_start; if (appended) { - mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0L, kExtmarkUndo); + mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0, kExtmarkUndo); buf_redraw_changed_lines_later(curbuf, lnum_start + 1, lnum_start + 1, appended); } break; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index e21277b0db..ec35da54d2 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -2288,7 +2288,7 @@ static void highlight_list_two(int cnt, int attr) msg_puts_attr(&("N \bI \b! \b"[cnt / 11]), attr); msg_clr_eos(); ui_flush(); - os_delay(cnt == 99 ? 40L : (uint64_t)cnt * 50L, false); + os_delay(cnt == 99 ? 40 : (uint64_t)cnt * 50, false); } /// Function given to ExpandGeneric() to obtain the list of group names. diff --git a/src/nvim/indent.c b/src/nvim/indent.c index d19164b24f..65eabd72c3 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -800,7 +800,7 @@ int get_breakindent_win(win_T *wp, char *line) FUNC_ATTR_NONNULL_ALL { static int prev_indent = 0; // cached indent value - static OptInt prev_ts = 0L; // cached tabstop value + static OptInt prev_ts = 0; // cached tabstop value static int prev_fnum = 0; // cached buffer number static char *prev_line = NULL; // cached copy of "line" static varnumber_T prev_tick = 0; // changedtick of cached value @@ -1018,7 +1018,7 @@ void ex_retab(exarg_T *eap) // len is actual number of white characters used len = num_spaces + num_tabs; old_len = (int)strlen(ptr); - const long new_len = old_len - col + start_col + len + 1; + const int new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { emsg_text_too_long(); break; @@ -1083,7 +1083,7 @@ void ex_retab(exarg_T *eap) redraw_curbuf_later(UPD_NOT_VALID); } if (first_line != 0) { - changed_lines(curbuf, first_line, 0, last_line + 1, 0L, true); + changed_lines(curbuf, first_line, 0, last_line + 1, 0, true); } curwin->w_p_list = save_list; // restore 'list' diff --git a/src/nvim/input.c b/src/nvim/input.c index 955cb0a21c..acac240a8b 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -112,7 +112,7 @@ int get_keystroke(MultiQueue *events) // First time: blocking wait. Second time: wait up to 100ms for a // terminal code to complete. - n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0, events); + n = os_inchar(buf + len, maxlen, len == 0 ? -1 : 100, 0, events); if (n > 0) { // Replace zero and K_SPECIAL by a special key code. n = fix_input_buffer(buf + len, n); diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index fa08064eb5..78654d8b14 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -474,7 +474,7 @@ bool check_compl_option(bool dict_opt) vim_beep(BO_COMPL); setcursor(); ui_flush(); - os_delay(2004L, false); + os_delay(2004, false); } return false; } @@ -2986,7 +2986,7 @@ static void get_next_include_file_completion(int compl_type) ((compl_type == CTRL_X_PATH_DEFINES && !(compl_cont_status & CONT_SOL)) ? FIND_DEFINE : FIND_ANY), - 1L, ACTION_EXPAND, 1, MAXLNUM); + 1, ACTION_EXPAND, 1, MAXLNUM); } /// Get the next set of words matching "compl_pattern" in dictionary or @@ -3208,7 +3208,7 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_ compl_direction, compl_pattern); } else { found_new_match = searchit(NULL, st->ins_buf, st->cur_match_pos, - NULL, compl_direction, compl_pattern, 1L, + NULL, compl_direction, compl_pattern, 1, SEARCH_KEEP + SEARCH_NFMSG, RE_LAST, NULL); } msg_silent--; diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 3975312703..b389f33d8d 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -619,7 +619,7 @@ static bool nlua_init_packages(lua_State *lstate, bool is_standalone) lua_getfield(lstate, -1, "preload"); // [package, preload] for (size_t i = 0; i < ARRAY_SIZE(builtin_modules); i++) { ModuleDef def = builtin_modules[i]; - lua_pushinteger(lstate, (long)i); // [package, preload, i] + lua_pushinteger(lstate, (lua_Integer)i); // [package, preload, i] lua_pushcclosure(lstate, nlua_module_preloader, 1); // [package, preload, cclosure] lua_setfield(lstate, -2, def.name); // [package, preload] diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 04304719d0..8f80744ac8 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -80,7 +80,7 @@ int nlua_spell_check(lua_State *lstate) lua_rawseti(lstate, -2, 2); // +1 for 1-indexing - lua_pushinteger(lstate, (long)pos + 1); + lua_pushinteger(lstate, (lua_Integer)pos + 1); lua_rawseti(lstate, -2, 3); lua_rawseti(lstate, -2, ++no_res); diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 60be771b6c..606c9878e6 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -183,8 +183,8 @@ int nlua_str_utfindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL size_t codepoints = 0, codeunits = 0; mb_utflen(s1, (size_t)idx, &codepoints, &codeunits); - lua_pushinteger(lstate, (long)codepoints); - lua_pushinteger(lstate, (long)codeunits); + lua_pushinteger(lstate, (lua_Integer)codepoints); + lua_pushinteger(lstate, (lua_Integer)codeunits); return 2; } @@ -204,7 +204,7 @@ static int nlua_str_utf_pos(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL size_t clen; for (size_t i = 0; i < s1_len && s1[i] != NUL; i += clen) { clen = (size_t)utf_ptr2len_len(s1 + i, (int)(s1_len - i)); - lua_pushinteger(lstate, (long)i + 1); + lua_pushinteger(lstate, (lua_Integer)i + 1); lua_rawseti(lstate, -2, (int)idx); idx++; } @@ -276,7 +276,7 @@ int nlua_str_byteindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL return luaL_error(lstate, "index out of range"); } - lua_pushinteger(lstate, (long)byteidx); + lua_pushinteger(lstate, (lua_Integer)byteidx); return 1; } diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index 56d1fdb8ab..e131bbb586 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -64,12 +64,12 @@ static void lua_pushhunk(lua_State *lstate, long start_a, long count_a, long sta lua_rawseti(lstate, -2, (signed)lua_objlen(lstate, -2) + 1); } -static void get_linematch_results(lua_State *lstate, mmfile_t *ma, mmfile_t *mb, long start_a, - long count_a, long start_b, long count_b, bool iwhite) +static void get_linematch_results(lua_State *lstate, mmfile_t *ma, mmfile_t *mb, int start_a, + int count_a, int start_b, int count_b, bool iwhite) { // get the pointer to char of the start of the diff to pass it to linematch algorithm const char *diff_begin[2] = { ma->ptr, mb->ptr }; - int diff_length[2] = { (int)count_a, (int)count_b }; + int diff_length[2] = { count_a, count_b }; fastforward_buf_to_lnum(&diff_begin[0], (linenr_T)start_a + 1); fastforward_buf_to_lnum(&diff_begin[1], (linenr_T)start_b + 1); @@ -77,12 +77,12 @@ static void get_linematch_results(lua_State *lstate, mmfile_t *ma, mmfile_t *mb, int *decisions = NULL; size_t decisions_length = linematch_nbuffers(diff_begin, diff_length, 2, &decisions, iwhite); - long lnuma = start_a, lnumb = start_b; + int lnuma = start_a, lnumb = start_b; - long hunkstarta = lnuma; - long hunkstartb = lnumb; - long hunkcounta = 0; - long hunkcountb = 0; + int hunkstarta = lnuma; + int hunkstartb = lnumb; + int hunkcounta = 0; + int hunkcountb = 0; for (size_t i = 0; i < decisions_length; i++) { if (i && (decisions[i - 1] != decisions[i])) { lua_pushhunk(lstate, hunkstarta, hunkcounta, hunkstartb, hunkcountb); @@ -110,8 +110,8 @@ static int write_string(void *priv, mmbuffer_t *mb, int nbuf) { luaL_Buffer *buf = (luaL_Buffer *)priv; for (int i = 0; i < nbuf; i++) { - const long size = mb[i].size; - for (long total = 0; total < size; total += LUAL_BUFFERSIZE) { + const int size = mb[i].size; + for (int total = 0; total < size; total += LUAL_BUFFERSIZE) { const int tocopy = MIN((int)(size - total), LUAL_BUFFERSIZE); char *p = luaL_prepbuffer(buf); if (!p) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 88d198bfa5..433b735c2e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -585,7 +585,7 @@ int main(int argc, char **argv) // 'autochdir' has been postponed. do_autochdir(); - set_vim_var_nr(VV_VIM_DID_ENTER, 1L); + set_vim_var_nr(VV_VIM_DID_ENTER, 1); apply_autocmds(EVENT_VIMENTER, NULL, NULL, false, curbuf); TIME_MSG("VimEnter autocommands"); if (use_remote_ui) { @@ -610,7 +610,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, 0L); + check_scrollbind((linenr_T)0, 0); TIME_MSG("diff scrollbinding"); } @@ -1027,7 +1027,7 @@ static void command_line_scan(mparm_T *parmp) int argv_idx; // index in argv[n][] bool had_minmin = false; // found "--" argument int want_argument; // option argument with argument - long n; + int n; argc--; argv++; diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 19fad179c6..1885ec74cd 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -441,11 +441,11 @@ fmark_T *mark_get_motion(buf_T *buf, win_T *win, int name) listcmd_busy = true; // avoid that '' is changed if (name == '{' || name == '}') { // to previous/next paragraph oparg_T oa; - if (findpar(&oa.inclusive, name == '}' ? FORWARD : BACKWARD, 1L, NUL, false)) { + if (findpar(&oa.inclusive, name == '}' ? FORWARD : BACKWARD, 1, NUL, false)) { mark = pos_to_mark(buf, NULL, win->w_cursor); } } else if (name == '(' || name == ')') { // to previous/next sentence - if (findsent(name == ')' ? FORWARD : BACKWARD, 1L)) { + if (findsent(name == ')' ? FORWARD : BACKWARD, 1)) { mark = pos_to_mark(buf, NULL, win->w_cursor); } } @@ -1064,10 +1064,10 @@ void ex_changes(exarg_T *eap) if (got_int) { break; } - snprintf(IObuff, IOSIZE, "%c %3d %5ld %4d ", + snprintf(IObuff, IOSIZE, "%c %3d %5" PRIdLINENR " %4d ", i == curwin->w_changelistidx ? '>' : ' ', i > curwin->w_changelistidx ? i - curwin->w_changelistidx : curwin->w_changelistidx - i, - (long)curbuf->b_changelist[i].mark.lnum, + curbuf->b_changelist[i].mark.lnum, curbuf-