diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-01-19 14:45:50 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-01-19 14:45:50 -0500 |
commit | 617c00bd49c2bdb05c8ef31f94e206ba3f80f694 (patch) | |
tree | 2804c90f676a47f3f8ca23a11f78e2b8c5446a66 /src | |
parent | d0debe243276804f59b24156c84174c394bc42bb (diff) | |
parent | dad1e39edf7f704dba40b182c7726ef4bc34c502 (diff) | |
download | rneovim-617c00bd49c2bdb05c8ef31f94e206ba3f80f694.tar.gz rneovim-617c00bd49c2bdb05c8ef31f94e206ba3f80f694.tar.bz2 rneovim-617c00bd49c2bdb05c8ef31f94e206ba3f80f694.zip |
Merge pull request #1812 from elmart/remove-long_u-5
Remove project-specific integer types: long_u. (5)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 13 | ||||
-rw-r--r-- | src/nvim/charset.c | 10 | ||||
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 19 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 28 | ||||
-rw-r--r-- | src/nvim/misc1.c | 8 | ||||
-rw-r--r-- | src/nvim/ops.c | 3 | ||||
-rw-r--r-- | src/nvim/option.c | 248 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 1 | ||||
-rw-r--r-- | src/nvim/regexp.c | 48 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 42 | ||||
-rw-r--r-- | src/nvim/spell.c | 3 | ||||
-rw-r--r-- | src/nvim/syntax.c | 2 | ||||
-rw-r--r-- | src/nvim/types.h | 5 |
15 files changed, 238 insertions, 195 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 5fe52e3323..4acc4b172d 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -72,7 +72,6 @@ set(CONV_SOURCES move.c normal.c ops.c - option.c os_unix.c path.c popupmnu.c diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index ff5f7853a3..d9684db3bc 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -2,6 +2,7 @@ #define NVIM_BUFFER_DEFS_H #include <stdbool.h> +#include <stdint.h> // for FILE #include <stdio.h> @@ -626,12 +627,12 @@ struct file_buffer { char_u *b_p_def; /* 'define' local value */ char_u *b_p_inc; /* 'include' */ char_u *b_p_inex; /* 'includeexpr' */ - long_u b_p_inex_flags; /* flags for 'includeexpr' */ + uint32_t b_p_inex_flags; /* flags for 'includeexpr' */ char_u *b_p_inde; /* 'indentexpr' */ - long_u b_p_inde_flags; /* flags for 'indentexpr' */ + uint32_t b_p_inde_flags; /* flags for 'indentexpr' */ char_u *b_p_indk; /* 'indentkeys' */ char_u *b_p_fex; /* 'formatexpr' */ - long_u b_p_fex_flags; /* flags for 'formatexpr' */ + uint32_t b_p_fex_flags; /* flags for 'formatexpr' */ char_u *b_p_kp; /* 'keywordprg' */ int b_p_lisp; /* 'lisp' */ char_u *b_p_mps; /* 'matchpairs' */ @@ -1082,9 +1083,9 @@ struct window_S { winopt_T w_allbuf_opt; /* A few options have local flags for P_INSECURE. */ - long_u w_p_stl_flags; /* flags for 'statusline' */ - long_u w_p_fde_flags; /* flags for 'foldexpr' */ - long_u w_p_fdt_flags; /* flags for 'foldtext' */ + uint32_t w_p_stl_flags; /* flags for 'statusline' */ + uint32_t w_p_fde_flags; /* flags for 'foldexpr' */ + uint32_t w_p_fdt_flags; /* flags for 'foldtext' */ int *w_p_cc_cols; /* array of columns to highlight or NULL */ int w_p_brimin; /* minimum width for breakindent */ int w_p_brishift; /* additional shift for breakindent */ diff --git a/src/nvim/charset.c b/src/nvim/charset.c index b86c66c3fe..86d6acc60b 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -791,15 +791,17 @@ int linetabsize_col(int startcol, char_u *s) /// @param len /// /// @return Number of characters the string will take on the screen. -int win_linetabsize(win_T *wp, char_u *line, colnr_T len) +unsigned int win_linetabsize(win_T *wp, char_u *line, colnr_T len) { colnr_T col = 0; - char_u *s; - for (s = line; *s != NUL && (len == MAXCOL || s < line + len); mb_ptr_adv(s)) { + for (char_u *s = line; + *s != NUL && (len == MAXCOL || s < line + len); + mb_ptr_adv(s)) { col += win_lbr_chartabsize(wp, line, s, col, NULL); } - return (int)col; + + return (unsigned int)col; } /// Return TRUE if 'c' is a normal identifier character: diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1833461fa9..8db473d4be 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10332,7 +10332,7 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog) if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN) { char_u *xp_name; int xp_namelen; - long argt; + uint32_t argt; /* input() with a third argument: completion */ rettv->vval.v_string = NULL; diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 0e13574321..1b920511b6 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -8,6 +8,7 @@ #define NVIM_EX_CMDS_DEFS_H #include <stdbool.h> +#include <stdint.h> #include "nvim/pos.h" // for linenr_T #include "nvim/normal.h" @@ -59,13 +60,13 @@ #define USECTRLV 0x2000 /* do not remove CTRL-V from argument */ #define NOTADR 0x4000 /* number before command is not an address */ #define EDITCMD 0x8000 /* allow "+command" argument */ -#define BUFNAME 0x10000L /* accepts buffer name */ -#define BUFUNL 0x20000L /* accepts unlisted buffer too */ -#define ARGOPT 0x40000L /* allow "++opt=val" argument */ -#define SBOXOK 0x80000L /* allowed in the sandbox */ -#define CMDWIN 0x100000L /* allowed in cmdline window */ -#define MODIFY 0x200000L /* forbidden in non-'modifiable' buffer */ -#define EXFLAGS 0x400000L /* allow flags after count in argument */ +#define BUFNAME 0x10000 /* accepts buffer name */ +#define BUFUNL 0x20000 /* accepts unlisted buffer too */ +#define ARGOPT 0x40000 /* allow "++opt=val" argument */ +#define SBOXOK 0x80000 /* allowed in the sandbox */ +#define CMDWIN 0x100000 /* allowed in cmdline window */ +#define MODIFY 0x200000 /* forbidden in non-'modifiable' buffer */ +#define EXFLAGS 0x400000 /* allow flags after count in argument */ #define FILES (XFILE | EXTRA) /* multiple extra files allowed */ #define WORD1 (EXTRA | NOSPC) /* one extra word allowed */ #define FILE1 (FILES | NOSPC) /* 1 file allowed, defaults to current file */ @@ -85,7 +86,7 @@ typedef char_u *(*LineGetter)(int, void *, int); typedef struct cmdname { char_u *cmd_name; ///< Name of the command. ex_func_T cmd_func; ///< Function with implementation of this command. - long_u cmd_argt; ///< Relevant flags from the declared above. + uint32_t cmd_argt; ///< Relevant flags from the declared above. } CommandDefinition; /// Arguments used for Ex commands. @@ -95,7 +96,7 @@ struct exarg { char_u *cmd; ///< the name of the command (except for :make) char_u **cmdlinep; ///< pointer to pointer of allocated cmdline cmdidx_T cmdidx; ///< the index for the command - long argt; ///< flags for the command + uint32_t argt; ///< flags for the command int skip; ///< don't execute the command, only parse it int forceit; ///< TRUE if ! present int addr_count; ///< the number of addresses given diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b4dfe99aed..065c27013e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -12,6 +12,7 @@ #include <string.h> #include <stdbool.h> +#include <stdint.h> #include <errno.h> #include <inttypes.h> @@ -77,7 +78,7 @@ static int ex_pressedreturn = FALSE; typedef struct ucmd { char_u *uc_name; /* The command name */ - long_u uc_argt; /* The argument type */ + uint32_t uc_argt; /* The argument type */ char_u *uc_rep; /* The command's replacement string */ long uc_def; /* The default value for a range/count */ int uc_compl; /* completion type */ @@ -1422,7 +1423,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) { ea.cmdidx = CMD_print; - ea.argt = RANGE+COUNT+TRLBAR; + ea.argt = RANGE | COUNT | TRLBAR; if ((errormsg = invalid_range(&ea)) == NULL) { correct_range(&ea); ex_print(&ea); @@ -1509,7 +1510,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, * 5. parse arguments */ if (!IS_USER_CMDIDX(ea.cmdidx)) { - ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; + ea.argt = cmdnames[(int)ea.cmdidx].cmd_argt; } if (!ea.skip) { @@ -2204,7 +2205,7 @@ find_ucmd ( eap->cmdidx = CMD_USER; else eap->cmdidx = CMD_USER_BUF; - eap->argt = (long)uc->uc_argt; + eap->argt = uc->uc_argt; eap->useridx = j; if (compl != NULL) @@ -2470,7 +2471,7 @@ set_one_cmd_context ( * 5. parse arguments */ if (!IS_USER_CMDIDX(ea.cmdidx)) { - ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; + ea.argt = cmdnames[(int)ea.cmdidx].cmd_argt; } arg = skipwhite(p); @@ -4122,7 +4123,9 @@ char_u *get_command_name(expand_T *xp, int idx) } -static int uc_add_command(char_u *name, size_t name_len, char_u *rep, long argt, long def, int flags, int compl, char_u *compl_arg, int force) +static int uc_add_command(char_u *name, size_t name_len, char_u *rep, + uint32_t argt, long def, int flags, int compl, + char_u *compl_arg, int force) { ucmd_T *cmd = NULL; char_u *p; @@ -4257,7 +4260,7 @@ static void uc_list(char_u *name, size_t name_len) int found = FALSE; ucmd_T *cmd; int len; - long a; + uint32_t a; garray_T *gap; gap = &curbuf->b_ucmds; @@ -4265,7 +4268,7 @@ static void uc_list(char_u *name, size_t name_len) int i; for (i = 0; i < gap->ga_len; ++i) { cmd = USER_CMD_GA(gap, i); - a = (long)cmd->uc_argt; + a = cmd->uc_argt; /* Skip commands which don't match the requested prefix */ if (STRNCMP(name, cmd->uc_name, name_len) != 0) @@ -4296,7 +4299,7 @@ static void uc_list(char_u *name, size_t name_len) len = 0; /* Arguments */ - switch ((int)(a & (EXTRA|NOSPC|NEEDARG))) { + switch (a & (EXTRA|NOSPC|NEEDARG)) { case 0: IObuff[len++] = '0'; break; case (EXTRA): IObuff[len++] = '*'; break; case (EXTRA|NOSPC): IObuff[len++] = '?'; break; @@ -4374,7 +4377,7 @@ static char_u *uc_fun_cmd(void) return IObuff; } -static int uc_scan_attr(char_u *attr, size_t len, long *argt, long *def, int *flags, int *compl, char_u **compl_arg) +static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def, int *flags, int *compl, char_u **compl_arg) { char_u *p; @@ -4493,7 +4496,7 @@ static void ex_command(exarg_T *eap) char_u *name; char_u *end; char_u *p; - long argt = 0; + uint32_t argt = 0; long def = -1; int flags = 0; int compl = EXPAND_NOTHING; @@ -5026,7 +5029,8 @@ char_u *get_user_cmd_complete(expand_T *xp, int idx) * copied to allocated memory and stored in "*compl_arg". * Returns FAIL if something is wrong. */ -int parse_compl_arg(char_u *value, int vallen, int *complp, long *argt, char_u **compl_arg) +int parse_compl_arg(char_u *value, int vallen, int *complp, + uint32_t *argt, char_u **compl_arg) { char_u *arg = NULL; size_t arglen = 0; diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index f756201efb..aa4d2b38db 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -10,6 +10,7 @@ * misc1.c: functions that didn't seem to fit elsewhere */ +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> @@ -1271,7 +1272,7 @@ plines_win_nofill ( int plines_win_nofold(win_T *wp, linenr_T lnum) { char_u *s; - long col; + unsigned int col; int width; s = ml_get_buf(wp->w_buffer, lnum, FALSE); @@ -1292,11 +1293,12 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) width = wp->w_width - win_col_off(wp); if (width <= 0) return 32000; - if (col <= width) + if (col <= (unsigned int)width) return 1; col -= width; width += win_col_off2(wp); - return (col + (width - 1)) / width + 1; + assert(col <= INT_MAX && (int)col < INT_MAX - (width -1)); + return ((int)col + (width - 1)) / width + 1; } /* diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 8fb3ba7f08..90fc89ee21 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4234,8 +4234,7 @@ int do_addsub(int command, linenr_T Prenum1) char_u buf2[NUMBUFLEN]; int hex; /* 'X' or 'x': hex; '0': octal */ static int hexupper = FALSE; /* 0xABC */ - unsigned long n; - long_u oldn; + unsigned long n, oldn; char_u *ptr; int c; int length = 0; /* character length of the number */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 88108b14a2..a167363abf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -31,9 +31,11 @@ */ #define IN_OPTION_C +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <stdint.h> #include <stdlib.h> @@ -297,10 +299,10 @@ static long p_wm_nopaste; static long p_sts_nopaste; static int p_ai_nopaste; -struct vimoption { +typedef struct vimoption { char *fullname; /* full option name */ char *shortname; /* permissible abbreviation */ - long_u flags; /* see below */ + uint32_t flags; /* see below */ char_u *var; /* global option: pointer to variable; * window-local option: VAR_WIN; * buffer-local option: global value */ @@ -309,7 +311,7 @@ struct vimoption { char_u *def_val[2]; /* default values for variable (vi and vim) */ scid_T scriptID; /* script in which the option was last set */ # define SCRIPTID_INIT , 0 -}; +} vimoption_T; #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ @@ -317,43 +319,43 @@ struct vimoption { /* * Flags */ -#define P_BOOL 0x01 /* the option is boolean */ -#define P_NUM 0x02 /* the option is numeric */ -#define P_STRING 0x04 /* the option is a string */ -#define P_ALLOCED 0x08 /* the string option is in allocated memory, - must use free_string_option() when - assigning new value. Not set if default is - the same. */ -#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can - never be used for local or hidden options! */ -#define P_NODEFAULT 0x40 /* don't set to default value */ -#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must +#define P_BOOL 0x01U /* the option is boolean */ +#define P_NUM 0x02U /* the option is numeric */ +#define P_STRING 0x04U /* the option is a string */ +#define P_ALLOCED 0x08U /* the string option is in allocated memory, + must use free_string_option() when + assigning new value. Not set if default is + the same. */ +#define P_EXPAND 0x10U /* environment expansion. NOTE: P_EXPAND can + never be used for local or hidden options */ +#define P_NODEFAULT 0x40U /* don't set to default value */ +#define P_DEF_ALLOCED 0x80U /* default value is in allocated memory, must use free() when assigning new value */ -#define P_WAS_SET 0x100 /* option has been set/reset */ -#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ -#define P_VI_DEF 0x400 /* Use Vi default for Vim */ -#define P_VIM 0x800 /* Vim option, reset when 'cp' set */ +#define P_WAS_SET 0x100U /* option has been set/reset */ +#define P_NO_MKRC 0x200U /* don't include in :mkvimrc output */ +#define P_VI_DEF 0x400U /* Use Vi default for Vim */ +#define P_VIM 0x800U /* Vim option, reset when 'cp' set */ /* when option changed, what to display: */ -#define P_RSTAT 0x1000 /* redraw status lines */ -#define P_RWIN 0x2000 /* redraw current window */ -#define P_RBUF 0x4000 /* redraw current buffer */ -#define P_RALL 0x6000 /* redraw all windows */ -#define P_RCLR 0x7000 /* clear and redraw all */ - -#define P_COMMA 0x8000 /* comma separated list */ -#define P_NODUP 0x10000L /* don't allow duplicate strings */ -#define P_FLAGLIST 0x20000L /* list of single-char flags */ - -#define P_SECURE 0x40000L /* cannot change in modeline or secure mode */ -#define P_GETTEXT 0x80000L /* expand default value with _() */ -#define P_NOGLOB 0x100000L /* do not use local value for global vimrc */ -#define P_NFNAME 0x200000L /* only normal file name chars allowed */ -#define P_INSECURE 0x400000L /* option was set from a modeline */ -#define P_PRI_MKRC 0x800000L /* priority for :mkvimrc (setting option has +#define P_RSTAT 0x1000U /* redraw status lines */ +#define P_RWIN 0x2000U /* redraw current window */ +#define P_RBUF 0x4000U /* redraw current buffer */ +#define P_RALL 0x6000U /* redraw all windows */ +#define P_RCLR 0x7000U /* clear and redraw all */ + +#define P_COMMA 0x8000U /* comma separated list */ +#define P_NODUP 0x10000U /* don't allow duplicate strings */ +#define P_FLAGLIST 0x20000U /* list of single-char flags */ + +#define P_SECURE 0x40000U /* cannot change in modeline or secure mode */ +#define P_GETTEXT 0x80000U /* expand default value with _() */ +#define P_NOGLOB 0x100000U /* do not use local value for global vimrc */ +#define P_NFNAME 0x200000U /* only normal file name chars allowed */ +#define P_INSECURE 0x400000U /* option was set from a modeline */ +#define P_PRI_MKRC 0x800000U /* priority for :mkvimrc (setting option has side effects) */ -#define P_NO_ML 0x1000000L /* not allowed in modeline */ -#define P_CURSWANT 0x2000000L /* update curswant required; not needed when +#define P_NO_ML 0x1000000U /* not allowed in modeline */ +#define P_CURSWANT 0x2000000U /* update curswant required; not needed when * there is a redraw flag */ #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" @@ -379,7 +381,7 @@ struct vimoption { * The options with a NULL variable are 'hidden': a set command for them is * ignored and they are not printed. */ -static struct vimoption +static vimoption_T options[] = { {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT, @@ -1848,7 +1850,6 @@ void set_init_1(void) { char_u *p; int opt_idx; - long_u n; langmap_init(); @@ -1884,7 +1885,7 @@ void set_init_1(void) int mustfree; ga_init(&ga, 1, 100); - for (n = 0; n < (long)ARRAY_SIZE(names); ++n) { + for (size_t n = 0; n < ARRAY_SIZE(names); ++n) { mustfree = FALSE; # ifdef UNIX if (*names[n] == NUL) @@ -1919,10 +1920,11 @@ void set_init_1(void) if (opt_idx >= 0) { { /* Use half of amount of memory available to Vim. */ - /* If too much to fit in long_u, get long_u max */ + /* If too much to fit in uintptr_t, get uintptr_t max */ uint64_t available_kib = os_get_total_mem_kib(); - n = available_kib / 2 > ULONG_MAX ? ULONG_MAX - : (long_u)(available_kib /2); + uintptr_t n = available_kib / 2 > UINTPTR_MAX + ? UINTPTR_MAX + : (uintptr_t)(available_kib /2); options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; opt_idx = findoption((char_u *)"maxmem"); if (opt_idx >= 0) { @@ -2133,12 +2135,10 @@ set_option_default ( { char_u *varp; /* pointer to variable for current option */ int dvi; /* index in def_val[] */ - long_u flags; - long_u *flagsp; int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); - flags = options[opt_idx].flags; + uint32_t flags = options[opt_idx].flags; if (varp != NULL) { /* skip hidden option, nothing to do for it */ dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; if (flags & P_STRING) { @@ -2177,7 +2177,7 @@ set_option_default ( } /* The default value is not insecure. */ - flagsp = insecure_flag(opt_idx, opt_flags); + uint32_t *flagsp = insecure_flag(opt_idx, opt_flags); *flagsp = *flagsp & ~P_INSECURE; } @@ -2425,8 +2425,8 @@ void set_helplang_default(char_u *lang) p_hlg = vim_strsave(lang); /* zh_CN becomes "cn", zh_TW becomes "tw". */ if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) { - p_hlg[0] = TOLOWER_ASC(p_hlg[3]); - p_hlg[1] = TOLOWER_ASC(p_hlg[4]); + p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]); + p_hlg[1] = (char_u)TOLOWER_ASC(p_hlg[4]); } p_hlg[2] = NUL; options[idx].flags |= P_ALLOCED; @@ -2444,7 +2444,7 @@ void set_helplang_default(char_u *lang) void set_title_defaults(void) { int idx1; - long val; + int val; /* * If GUI is (going to be) used, we can always set the window title and @@ -2454,13 +2454,13 @@ void set_title_defaults(void) idx1 = findoption((char_u *)"title"); if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) { val = mch_can_restore_title(); - options[idx1].def_val[VI_DEFAULT] = (char_u *)val; + options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)val; p_title = val; } idx1 = findoption((char_u *)"icon"); if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) { val = mch_can_restore_icon(); - options[idx1].def_val[VI_DEFAULT] = (char_u *)val; + options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)val; p_icon = val; } } @@ -2491,13 +2491,13 @@ do_set ( char_u errbuf[80]; char_u *startarg; int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ - int nextchar; /* next non-white char after option name */ + char_u nextchar; /* next non-white char after option name */ int afterchar; /* character just after option name */ int len; int i; long value; int key; - long_u flags; /* flags for current option */ + uint32_t flags; /* flags for current option */ char_u *varp = NULL; /* pointer to variable for current option */ int did_show = FALSE; /* already showed one value */ int adding; /* "opt+=arg" */ @@ -2632,11 +2632,11 @@ do_set ( } else { flags = P_STRING; if (key < 0) { - key_name[0] = KEY2TERMCAP0(key); + key_name[0] = (char_u)KEY2TERMCAP0(key); key_name[1] = KEY2TERMCAP1(key); } else { key_name[0] = KS_KEY; - key_name[1] = (key & 0xff); + key_name[1] = (char_u)(key & 0xff); } } @@ -3185,7 +3185,8 @@ skip: if (i + (arg - startarg) < IOSIZE) { /* append the argument with the error */ STRCAT(IObuff, ": "); - memmove(IObuff + i, startarg, (arg - startarg)); + assert(arg >= startarg); + memmove(IObuff + i, startarg, (size_t)(arg - startarg)); IObuff[i + (arg - startarg)] = NUL; } /* make sure all characters are printable */ @@ -3227,14 +3228,12 @@ did_set_option ( int new_value /* value was replaced completely */ ) { - long_u *p; - options[opt_idx].flags |= P_WAS_SET; /* When an option is set in the sandbox, from a modeline or in secure mode * set the P_INSECURE flag. Otherwise, if a new value is stored reset the * flag. */ - p = insecure_flag(opt_idx, opt_flags); + uint32_t *p = insecure_flag(opt_idx, opt_flags); if (secure #ifdef HAVE_SANDBOX || sandbox != 0 @@ -3581,10 +3580,9 @@ void set_term_option_alloced(char_u **p) int was_set_insecurely(char_u *opt, int opt_flags) { int idx = findoption(opt); - long_u *flagp; if (idx >= 0) { - flagp = insecure_flag(idx, opt_flags); + uint32_t *flagp = insecure_flag(idx, opt_flags); return (*flagp & P_INSECURE) != 0; } EMSG2(_(e_intern2), "was_set_insecurely()"); @@ -3595,7 +3593,7 @@ int was_set_insecurely(char_u *opt, int opt_flags) * Get a pointer to the flags used for the P_INSECURE flag of option * "opt_idx". For some local options a local flags field is used. */ -static long_u *insecure_flag(int opt_idx, int opt_flags) +static uint32_t *insecure_flag(int opt_idx, int opt_flags) { if (opt_flags & OPT_LOCAL) switch ((int)options[opt_idx].indir) { @@ -3755,7 +3753,7 @@ did_set_string_option ( char_u *s, *p; int did_chartab = FALSE; char_u **gvarp; - long_u free_oldval = (options[opt_idx].flags & P_ALLOCED); + bool free_oldval = (options[opt_idx].flags & P_ALLOCED); /* Get the global option to compare with, otherwise we would have to check * two values for all local options. */ @@ -4649,9 +4647,8 @@ char_u *check_colorcolumn(win_T *wp) { char_u *s; int col; - int count = 0; + unsigned int count = 0; int color_cols[256]; - int i; int j = 0; if (wp->w_buffer == NULL) @@ -4667,7 +4664,13 @@ char_u *check_colorcolumn(win_T *wp) col = col * getdigits_int(&s); if (wp->w_buffer->b_p_tw == 0) goto skip; /* 'textwidth' not set, skip this item */ - col += wp->w_buffer->b_p_tw; + assert((col >= 0 + && wp->w_buffer->b_p_tw <= INT_MAX - col + && wp->w_buffer->b_p_tw + col >= INT_MIN) + || (col < 0 + && wp->w_buffer->b_p_tw >= INT_MIN - col + && wp->w_buffer->b_p_tw + col <= INT_MAX)); + col += (int)wp->w_buffer->b_p_tw; if (col < 0) goto skip; } else if (VIM_ISDIGIT(*s)) @@ -4693,7 +4696,7 @@ skip: * win_line() */ qsort(color_cols, count, sizeof(int), int_cmp); - for (i = 0; i < count; ++i) + for (unsigned int i = 0; i < count; ++i) /* skip duplicates */ if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) wp->w_p_cc_cols[j++] = color_cols[i]; @@ -5558,8 +5561,10 @@ set_num_option ( /* Postpone the resizing; check the size and cmdline position for * messages. */ check_shellsize(); - if (cmdline_row > Rows - p_ch && Rows > p_ch) - cmdline_row = Rows - p_ch; + if (cmdline_row > Rows - p_ch && Rows > p_ch) { + assert(p_ch >= 0 && Rows - p_ch <= INT_MAX); + cmdline_row = (int)(Rows - p_ch); + } } if (p_window >= Rows || !option_was_set((char_u *)"window")) p_window = Rows - 1; @@ -5648,11 +5653,11 @@ set_num_option ( /* * Called after an option changed: check if something needs to be redrawn. */ -static void check_redraw(long_u flags) +static void check_redraw(uint32_t flags) { /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ - int doclear = (flags & P_RCLR) == P_RCLR; - int all = ((flags & P_RALL) == P_RALL || doclear); + bool doclear = (flags & P_RCLR) == P_RCLR; + bool all = ((flags & P_RALL) == P_RALL || doclear); if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ status_redraw_all(); @@ -5673,7 +5678,6 @@ static void check_redraw(long_u flags) */ static int findoption(char_u *arg) { - int opt_idx; char *s, *p; static short quick_tab[27] = {0, 0}; /* quick access table */ int is_term_opt; @@ -5685,12 +5689,12 @@ static int findoption(char_u *arg) */ if (quick_tab[1] == 0) { p = options[0].fullname; - for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) { + for (short int i = 1; (s = options[i].fullname) != NULL; i++) { if (s[0] != p[0]) { if (s[0] == 't' && s[1] == '_') - quick_tab[26] = opt_idx; + quick_tab[26] = i; else - quick_tab[CharOrdLow(s[0])] = opt_idx; + quick_tab[CharOrdLow(s[0])] = i; } p = s; } @@ -5702,6 +5706,7 @@ static int findoption(char_u *arg) if (arg[0] < 'a' || arg[0] > 'z') return -1; + int opt_idx; is_term_opt = (arg[0] == 't' && arg[1] == '_'); if (is_term_opt) opt_idx = quick_tab[26]; @@ -5799,7 +5804,7 @@ int get_option_value_strict(char *name, void *from) { char_u *varp = NULL; - struct vimoption *p; + vimoption_T *p; int rv = 0; int opt_idx = findoption((uint8_t *)name); if (opt_idx < 0) { @@ -5911,13 +5916,12 @@ set_option_value ( { int opt_idx; char_u *varp; - long_u flags; opt_idx = findoption(name); if (opt_idx < 0) EMSG2(_("E355: Unknown option: %s"), name); else { - flags = options[opt_idx].flags; + uint32_t flags = options[opt_idx].flags; #ifdef HAVE_SANDBOX /* Disallow changing some options in the sandbox */ if (sandbox > 0 && (flags & P_SECURE)) { @@ -6035,7 +6039,7 @@ showoptions ( int opt_flags /* OPT_LOCAL and/or OPT_GLOBAL */ ) { - struct vimoption *p; + vimoption_T *p; int col; int isterm; char_u *varp; @@ -6049,7 +6053,7 @@ showoptions ( #define INC 20 #define GAP 3 - struct vimoption **items = xmalloc(sizeof(struct vimoption *) * PARAM_COUNT); + vimoption_T **items = xmalloc(sizeof(vimoption_T *) * PARAM_COUNT); /* Highlight title */ if (all == 2) @@ -6099,7 +6103,11 @@ showoptions ( * display the items */ if (run == 1) { - cols = (Columns + GAP - 3) / INC; + assert(Columns <= LONG_MAX - GAP + && Columns + GAP >= LONG_MIN + 3 + && (Columns + GAP - 3) / INC >= INT_MIN + && (Columns + GAP - 3) / INC <= INT_MAX); + cols = (int)((Columns + GAP - 3) / INC); if (cols == 0) cols = 1; rows = (item_count + cols - 1) / cols; @@ -6125,7 +6133,7 @@ showoptions ( /* * Return TRUE if option "p" has its default value. */ -static int optval_default(struct vimoption *p, char_u *varp) +static int optval_default(vimoption_T *p, char_u *varp) { int dvi; @@ -6146,7 +6154,7 @@ static int optval_default(struct vimoption *p, char_u *varp) */ static void showoneopt ( - struct vimoption *p, + vimoption_T *p, int opt_flags /* OPT_LOCAL or OPT_GLOBAL */ ) { @@ -6202,7 +6210,7 @@ showoneopt ( */ int makeset(FILE *fd, int opt_flags, int local_only) { - struct vimoption *p; + vimoption_T *p; char_u *varp; /* currently used value */ char_u *varp_fresh; /* local value */ char_u *varp_local = NULL; /* fresh value */ @@ -6406,7 +6414,7 @@ void clear_termoptions(void) void free_termoptions(void) { - struct vimoption *p; + vimoption_T *p; for (p = &options[0]; p->fullname != NULL; p++) if (istermoption(p)) { @@ -6428,7 +6436,7 @@ void free_termoptions(void) */ void free_one_termoption(char_u *var) { - struct vimoption *p; + vimoption_T *p; for (p = &options[0]; p->fullname != NULL; p++) if (p->var == var) { @@ -6446,7 +6454,7 @@ void free_one_termoption(char_u *var) */ void set_term_defaults(void) { - struct vimoption *p; + vimoption_T *p; for (p = &options[0]; p->fullname != NULL; p++) { if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) { @@ -6466,7 +6474,7 @@ void set_term_defaults(void) /* * return TRUE if 'p' starts with 't_' */ -static int istermoption(struct vimoption *p) +static int istermoption(vimoption_T *p) { return p->fullname[0] == 't' && p->fullname[1] == '_'; } @@ -6497,8 +6505,14 @@ void comp_col(void) if (!p_ru || last_has_status) /* no need for separating space */ ++sc_col; } - sc_col = Columns - sc_col; - ru_col = Columns - ru_col; + assert(sc_col >= 0 + && INT_MIN + sc_col <= Columns + && Columns - sc_col <= INT_MAX); + sc_col = (int)(Columns - sc_col); + assert(ru_col >= 0 + && INT_MIN + ru_col <= Columns + && Columns - ru_col <= INT_MAX); + ru_col = (int)(Columns - ru_col); if (sc_col <= 0) /* screen too narrow, will become a mess */ sc_col = 1; if (ru_col <= 0) @@ -6508,7 +6522,7 @@ void comp_col(void) // Unset local option value, similar to ":set opt<". void unset_global_local_option(char *name, void *from) { - struct vimoption *p; + vimoption_T *p; buf_T *buf = (buf_T *)from; int opt_idx = findoption((uint8_t *)name); @@ -6576,7 +6590,7 @@ void unset_global_local_option(char *name, void *from) /* * Get pointer to option variable, depending on local or global scope. */ -static char_u *get_varp_scope(struct vimoption *p, int opt_flags) +static char_u *get_varp_scope(vimoption_T *p, int opt_flags) { if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) { if (p->var == VAR_WIN) @@ -6610,7 +6624,7 @@ static char_u *get_varp_scope(struct vimoption *p, int opt_flags) /* * Get pointer to option variable. */ -static char_u *get_varp(struct vimoption *p) +static char_u *get_varp(vimoption_T *p) { /* hidden option, always return NULL */ if (p->var == NULL) @@ -7088,8 +7102,8 @@ set_context_in_set_cmd ( int opt_flags /* OPT_GLOBAL and/or OPT_LOCAL */ ) { - int nextchar; - long_u flags = 0; /* init for GCC */ + char_u nextchar; + uint32_t flags = 0; /* init for GCC */ int opt_idx = 0; /* init for GCC */ char_u *p; char_u *s; @@ -7142,7 +7156,7 @@ set_context_in_set_cmd ( } nextchar = *++p; is_term_option = TRUE; - expand_option_name[2] = KEY2TERMCAP0(key); + expand_option_name[2] = (char_u)KEY2TERMCAP0(key); expand_option_name[3] = KEY2TERMCAP1(key); } else { if (p[0] == 't' && p[1] == '_') { @@ -7382,7 +7396,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** *num_file = num_term; else return OK; - *file = (char_u **)xmalloc(*num_file * sizeof(char_u *)); + *file = (char_u **)xmalloc((size_t)(*num_file) * sizeof(char_u *)); } } return OK; @@ -7437,7 +7451,7 @@ void ExpandOldSetting(int *num_file, char_u ***file) */ static void option_value2string ( - struct vimoption *opp, + vimoption_T *opp, int opt_flags /* OPT_GLOBAL and/or OPT_LOCAL */ ) { @@ -7512,12 +7526,13 @@ static garray_T langmap_mapga = GA_EMPTY_INIT_VALUE; static void langmap_set_entry(int from, int to) { langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); - int a = 0; - int b = langmap_mapga.ga_len; + unsigned int a = 0; + assert(langmap_mapga.ga_len >= 0); + unsigned int b = (unsigned int)langmap_mapga.ga_len; /* Do a binary search for an existing entry. */ while (a != b) { - int i = (a + b) / 2; + unsigned int i = (a + b) / 2; int d = entries[i].from - from; if (d == 0) { @@ -7535,7 +7550,7 @@ static void langmap_set_entry(int from, int to) /* insert new entry at position "a" */ entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; memmove(entries + 1, entries, - (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); + ((unsigned int)langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); ++langmap_mapga.ga_len; entries[0].from = from; entries[0].to = to; @@ -7566,10 +7581,8 @@ int langmap_adjust_mb(int c) static void langmap_init(void) { - int i; - - for (i = 0; i < 256; i++) - langmap_mapchar[i] = i; /* we init with a one-to-one map */ + for (int i = 0; i < 256; i++) + langmap_mapchar[i] = (char_u)i; /* we init with a one-to-one map */ ga_init(&langmap_mapga, sizeof(langmap_entry_T), 8); } @@ -7627,8 +7640,10 @@ static void langmap_set(void) if (from >= 256) langmap_set_entry(from, to); - else - langmap_mapchar[from & 255] = to; + else { + assert(to <= UCHAR_MAX); + langmap_mapchar[from & 255] = (char_u)to; + } /* Advance to next pair */ mb_ptr_adv(p); @@ -7867,20 +7882,19 @@ opt_strings_flags ( int list /* when TRUE: accept a list of values */ ) { - int i; - int len; - unsigned new_flags = 0; + unsigned int new_flags = 0; while (*val) { - for (i = 0;; ++i) { + for (unsigned int i = 0;; ++i) { if (values[i] == NULL) /* val not found in values[] */ return FAIL; - len = (int)STRLEN(values[i]); + size_t len = STRLEN(values[i]); if (STRNCMP(values[i], val, len) == 0 && ((list && val[len] == ',') || val[len] == NUL)) { val += len + (val[len] == ','); - new_flags |= (1 << i); + assert(i < sizeof(1U) * 8); + new_flags |= (1U << i); break; /* check next item in val list */ } } @@ -8104,7 +8118,7 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) static bool briopt_check(win_T *wp) { int bri_shift = 0; - long bri_min = 20; + int bri_min = 20; bool bri_sbr = false; char_u *p = wp->w_p_briopt; @@ -8119,7 +8133,7 @@ static bool briopt_check(win_T *wp) else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) { p += 4; - bri_min = getdigits_long(&p); + bri_min = getdigits_int(&p); } else if (STRNCMP(p, "sbr", 3) == 0) { diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index ca3ba052d7..d074ace884 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -4,7 +4,6 @@ #include "nvim/lib/klist.h" -#include "nvim/types.h" #include "nvim/ascii.h" #include "nvim/vim.h" #include "nvim/globals.h" diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index fafd99c046..4af09915d5 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1693,7 +1693,7 @@ static char_u *regpiece(int *flagp) if (lop == BEHIND || lop == NOBEHIND) { if (nr < 0) nr = 0; /* no limit is same as zero limit */ - reginsert_nr(lop, nr, ret); + reginsert_nr(lop, (uint32_t)nr, ret); } else reginsert(lop, ret); break; @@ -2122,14 +2122,14 @@ static char_u *regatom(int *flagp) default: if (VIM_ISDIGIT(c) || c == '<' || c == '>' || c == '\'') { - long_u n = 0; + uint32_t n = 0; int cmp; cmp = c; if (cmp == '<' || cmp == '>') c = getchr(); while (VIM_ISDIGIT(c)) { - n = n * 10 + (c - '0'); + n = n * 10 + (uint32_t)(c - '0'); c = getchr(); } if (c == '\'' && n == 0) { @@ -2155,7 +2155,7 @@ static char_u *regatom(int *flagp) else { /* put the number and the optional * comparator after the opcode */ - regcode = re_put_long(regcode, n); + regcode = re_put_uint32(regcode, n); *regcode++ = cmp; } break; @@ -2580,7 +2580,8 @@ static void reginsert_nr(int op, long val, char_u *opnd) *place++ = op; *place++ = NUL; *place++ = NUL; - re_put_long(place, (long_u)val); + assert(val >= 0 && (uintmax_t)val <= UINT32_MAX); + re_put_uint32(place, (uint32_t)val); } /* @@ -2609,15 +2610,17 @@ static void reginsert_limits(int op, long minval, long maxval, char_u *opnd) *place++ = op; *place++ = NUL; *place++ = NUL; - place = re_put_long(place, (long_u)minval); - place = re_put_long(place, (long_u)maxval); + assert(minval >= 0 && (uintmax_t)minval <= UINT32_MAX); + place = re_put_uint32(place, (uint32_t)minval); + assert(maxval >= 0 && (uintmax_t)maxval <= UINT32_MAX); + place = re_put_uint32(place, (uint32_t)maxval); regtail(opnd, place); } /* - * Write a long as four bytes at "p" and return pointer to the next char. + * Write a four bytes number at "p" and return pointer to the next char. */ -static char_u *re_put_long(char_u *p, long_u val) +static char_u *re_put_uint32(char_u *p, uint32_t val) { *p++ = (char_u) ((val >> 24) & 0377); *p++ = (char_u) ((val >> 16) & 0377); @@ -3643,7 +3646,6 @@ static int reg_match_visual(void) int mode; colnr_T start, end; colnr_T start2, end2; - colnr_T cols; /* Check if the buffer is the current buffer. */ if (reg_buf != curbuf || VIsual.lnum == 0) @@ -3686,7 +3688,10 @@ static int reg_match_visual(void) end = end2; if (top.col == MAXCOL || bot.col == MAXCOL) end = MAXCOL; - cols = win_linetabsize(wp, regline, (colnr_T)(reginput - regline)); + unsigned int cols_u = win_linetabsize(wp, regline, + (colnr_T)(reginput - regline)); + assert(cols_u <= MAXCOL); + colnr_T cols = (colnr_T)cols_u; if (cols < start || cols > end - (*p_sel == 'e')) return FALSE; } @@ -3862,20 +3867,25 @@ regmatch ( break; case RE_LNUM: - if (!REG_MULTI || !re_num_cmp((long_u)(reglnum + reg_firstlnum), - scan)) + assert(reglnum + reg_firstlnum >= 0 + && (uintmax_t)(reglnum + reg_firstlnum) <= UINT32_MAX); + if (!REG_MULTI || !re_num_cmp((uint32_t)(reglnum + reg_firstlnum), + scan)) status = RA_NOMATCH; break; case RE_COL: - if (!re_num_cmp((long_u)(reginput - regline) + 1, scan)) + assert(reginput - regline + 1 >= 0 + && (uintmax_t)(reginput - regline + 1) <= UINT32_MAX); + if (!re_num_cmp((uint32_t)(reginput - regline + 1), scan)) status = RA_NOMATCH; break; case RE_VCOL: - if (!re_num_cmp((long_u)win_linetabsize( - reg_win == NULL ? curwin : reg_win, - regline, (colnr_T)(reginput - regline)) + 1, scan)) + if (!re_num_cmp(win_linetabsize(reg_win == NULL ? curwin : reg_win, + regline, + (colnr_T)(reginput - regline)) + 1, + scan)) status = RA_NOMATCH; break; @@ -5599,9 +5609,9 @@ static void save_se_one(save_se_T *savep, char_u **pp) /* * Compare a number with the operand of RE_LNUM, RE_COL or RE_VCOL. */ -static int re_num_cmp(long_u val, char_u *scan) +static int re_num_cmp(uint32_t val, char_u *scan) { - long_u n = OPERAND_MIN(scan); + uint32_t n = (uint32_t)OPERAND_MIN(scan); if (OPERAND_CMP(scan) == '>') return val > n; diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index fc3e73c396..b082903282 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4,8 +4,10 @@ * This file is included in "regexp.c". */ +#include <assert.h> #include <inttypes.h> #include <stdbool.h> +#include <stdint.h> #include "nvim/ascii.h" #include "nvim/misc2.h" @@ -4403,7 +4405,7 @@ static void nfa_restore_listids(nfa_regprog_T *prog, int *list) } } -static int nfa_re_num_cmp(long_u val, int op, long_u pos) +static bool nfa_re_num_cmp(uintmax_t val, int op, uintmax_t pos) { if (op == 1) return pos > val; if (op == 2) return pos < val; @@ -5684,9 +5686,14 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm case NFA_LNUM: case NFA_LNUM_GT: case NFA_LNUM_LT: - result = (REG_MULTI && - nfa_re_num_cmp(t->state->val, t->state->c - NFA_LNUM, - (long_u)(reglnum + reg_firstlnum))); + assert(t->state->val >= 0 + && !((reg_firstlnum > 0 && reglnum > LONG_MAX - reg_firstlnum) + || (reg_firstlnum <0 && reglnum < LONG_MIN + reg_firstlnum)) + && reglnum + reg_firstlnum >= 0); + result = (REG_MULTI + && nfa_re_num_cmp((uintmax_t)t->state->val, + t->state->c - NFA_LNUM, + (uintmax_t)(reglnum + reg_firstlnum))); if (result) { add_here = TRUE; add_state = t->state->out; @@ -5696,8 +5703,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm case NFA_COL: case NFA_COL_GT: case NFA_COL_LT: - result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_COL, - (long_u)(reginput - regline) + 1); + assert(t->state->val >= 0 + && reginput >= regline + && (uintmax_t)(reginput - regline) <= UINTMAX_MAX - 1); + result = nfa_re_num_cmp((uintmax_t)t->state->val, + t->state->c - NFA_COL, + (uintmax_t)(reginput - regline + 1)); if (result) { add_here = TRUE; add_state = t->state->out; @@ -5707,13 +5718,18 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm case NFA_VCOL: case NFA_VCOL_GT: case NFA_VCOL_LT: - result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_VCOL, - (long_u)win_linetabsize( - reg_win == NULL ? curwin : reg_win, - regline, (colnr_T)(reginput - regline)) + 1); - if (result) { - add_here = TRUE; - add_state = t->state->out; + { + uintmax_t lts = win_linetabsize(reg_win == NULL ? curwin : reg_win, + regline, + (colnr_T)(reginput - regline)); + assert(t->state->val >= 0); + result = nfa_re_num_cmp((uintmax_t)t->state->val, + t->state->c - NFA_VCOL, + lts + 1); + if (result) { + add_here = TRUE; + add_state = t->state->out; + } } break; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 5e69a935ca..bb995fe3c2 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -289,6 +289,7 @@ #include <inttypes.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <stdlib.h> #include <wctype.h> @@ -6546,7 +6547,7 @@ node_compress ( n = np->wn_flags + (np->wn_region << 8) + (np->wn_affixID << 16); else // byte node: use the byte value and the child pointer - n = (unsigned)(np->wn_byte + ((long_u)np->wn_child << 8)); + n = (unsigned)(np->wn_byte + ((uintptr_t)np->wn_child << 8)); nr = nr * 101 + n; } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 3980a4d8e6..f24b2aa80a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3837,7 +3837,7 @@ static void add_keyword(char_u *name, } kp->next_list = copy_id_list(next_list); - long_u hash = hash_hash(kp->keyword); + hash_T hash = hash_hash(kp->keyword); hashtab_T *ht = (curwin->w_s->b_syn_ic) ? &curwin->w_s->b_keywtab_ic : &curwin->w_s->b_keywtab; hashitem_T *hi = hash_lookup(ht, kp->keyword, hash); diff --git a/src/nvim/types.h b/src/nvim/types.h index c18c6abb4b..a87122d24b 100644 --- a/src/nvim/types.h +++ b/src/nvim/types.h @@ -13,11 +13,6 @@ // dummy to pass an ACL to a function typedef void *vim_acl_T; -// According to the vanilla Vim docs, long_u needs to be big enough to hold -// a pointer for the platform. On C99, this is easy to do with the uintptr_t -// type in lieu of the platform-specific typedefs that existed before. -typedef uintptr_t long_u; - /* * Shorthand for unsigned variables. Many systems, but not all, have u_char * already defined, so we use char_u to avoid trouble. |