diff options
-rw-r--r-- | src/nvim/buffer.c | 8 | ||||
-rw-r--r-- | src/nvim/charset.c | 45 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 4 | ||||
-rw-r--r-- | src/nvim/diff.c | 12 | ||||
-rw-r--r-- | src/nvim/digraph.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 8 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 26 | ||||
-rw-r--r-- | src/nvim/hardcopy.c | 4 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 8 | ||||
-rw-r--r-- | src/nvim/mark.c | 4 | ||||
-rw-r--r-- | src/nvim/menu.c | 2 | ||||
-rw-r--r-- | src/nvim/misc1.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 14 | ||||
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/search.c | 2 | ||||
-rw-r--r-- | src/nvim/spell.c | 14 | ||||
-rw-r--r-- | src/nvim/syntax.c | 8 | ||||
-rw-r--r-- | src/nvim/term.c | 26 | ||||
-rw-r--r-- | src/nvim/ui.c | 4 | ||||
-rw-r--r-- | src/nvim/window.c | 2 |
23 files changed, 104 insertions, 105 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 4c40cd631e..5c1b01130d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -750,7 +750,7 @@ do_bufdel ( break; arg = p; } else - bnr = getdigits(&arg); + bnr = get_int_digits(&arg); } } if (!got_int && do_current && do_buffer(command, DOBUF_FIRST, @@ -2997,7 +2997,7 @@ build_stl_str_hl ( l = -1; } if (VIM_ISDIGIT(*s)) { - minwid = (int)getdigits(&s); + minwid = get_int_digits(&s); if (minwid < 0) /* overflow */ minwid = 0; } @@ -3033,7 +3033,7 @@ build_stl_str_hl ( if (*s == '.') { s++; if (VIM_ISDIGIT(*s)) { - maxwid = (int)getdigits(&s); + maxwid = get_int_digits(&s); if (maxwid <= 0) /* overflow */ maxwid = 50; } @@ -4077,7 +4077,7 @@ chk_modeline ( e = s + 4; else e = s + 3; - vers = getdigits(&e); + vers = get_int_digits(&e); if (*e == ':' && (s[0] != 'V' || STRNCMP(skipwhite(e + 1), "set", 3) == 0) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 32427cc3ba..91d8f221c9 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -177,7 +177,7 @@ int buf_init_chartab(buf_T *buf, int global) } if (VIM_ISDIGIT(*p)) { - c = getdigits(&p); + c = get_int_digits(&p); } else if (has_mbyte) { c = mb_ptr2char_adv(&p); } else { @@ -189,7 +189,7 @@ int buf_init_chartab(buf_T *buf, int global) ++p; if (VIM_ISDIGIT(*p)) { - c2 = getdigits(&p); + c2 = get_int_digits(&p); } else if (has_mbyte) { c2 = mb_ptr2char_adv(&p); } else { @@ -1676,26 +1676,37 @@ char_u* skiptowhite_esc(char_u *p) { return p; } -/// Getdigits: Get a number from a string and skip over it. +/// Get a number from a string and skip over it. /// -/// Note: the argument is a pointer to a char_u pointer! +/// @param[out] pp A pointer to a pointer to char_u. +/// It will be advanced past the read number. /// -/// @param pp +/// @return Number read from the string. +intmax_t get_digits(char_u **pp) +{ + intmax_t number = strtoimax((char *)*pp, (char **)pp, 10); + assert(errno != ERANGE); + return number; +} + +/// Get an int number from a string. /// -/// @return Number from the string. -long getdigits(char_u **pp) +/// A get_digits wrapper restricted to int values. +int get_int_digits(char_u **pp) { - char_u *p = *pp; - long retval = atol((char *)p); + intmax_t number = get_digits(pp); + assert(number >= INT_MIN && number <= INT_MAX); + return (int)number; +} - if (*p == '-') { - // skip negative sign - ++p; - } - // skip to next non-digit - p = skipdigits(p); - *pp = p; - return retval; +/// Get a long number from a string. +/// +/// A get_digits wrapper restricted to long values. +long get_long_digits(char_u **pp) +{ + intmax_t number = get_digits(pp); + assert(number >= LONG_MIN && number <= LONG_MAX); + return (long)number; } /// Return TRUE if "lbuf" is empty or only contains blanks. diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 87064b4ef3..3dab383dcd 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -135,9 +135,7 @@ char_u *parse_shape_opt(int what) p += len; if (!VIM_ISDIGIT(*p)) return (char_u *)N_("E548: digit expected"); - int64_t digits = getdigits(&p); - assert(digits <= INT_MAX); - int n = (int)digits; + int n = get_int_digits(&p); if (len == 3) { /* "ver" or "hor" */ if (n == 0) return (char_u *)N_("E549: Illegal percentage"); diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 7e31c3f216..307ccadf5f 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1221,11 +1221,11 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname) // {first}a{first}[,{last}] // {first}[,{last}]d{first} p = linebuf; - f1 = getdigits(&p); + f1 = get_long_digits(&p); if (*p == ',') { ++p; - l1 = getdigits(&p); + l1 = get_long_digits(&p); } else { l1 = f1; } @@ -1235,11 +1235,11 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname) continue; } difftype = *p++; - f2 = getdigits(&p); + f2 = get_long_digits(&p); if (*p == ',') { ++p; - l2 = getdigits(&p); + l2 = get_long_digits(&p); } else { l2 = f2; } @@ -1783,7 +1783,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_FILLER; } else if ((STRNCMP(p, "context:", 8) == 0) && VIM_ISDIGIT(p[8])) { p += 8; - diff_context_new = getdigits(&p); + diff_context_new = get_int_digits(&p); } else if (STRNCMP(p, "icase", 5) == 0) { p += 5; diff_flags_new |= DIFF_ICASE; @@ -1798,7 +1798,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_VERTICAL; } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && VIM_ISDIGIT(p[11])) { p += 11; - diff_foldcolumn_new = getdigits(&p); + diff_foldcolumn_new = get_int_digits(&p); } if ((*p != ',') && (*p != NUL)) { diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 2b5fdea2fe..7a24203594 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1611,9 +1611,7 @@ void putdigraph(char_u *str) EMSG(_(e_number_exp)); return; } - int64_t digits = getdigits(&str); - assert(digits <= INT_MAX); - int n = (int)digits; + int n = get_int_digits(&str); // If the digraph already exists, replace the result. dp = (digr_T *)user_digraphs.ga_data; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9974315d3f..e921f3a1a8 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2750,7 +2750,7 @@ void ex_lockvar(exarg_T *eap) if (eap->forceit) deep = -1; else if (vim_isdigit(*arg)) { - deep = getdigits(&arg); + deep = get_int_digits(&arg); arg = skipwhite(arg); } @@ -13370,7 +13370,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv) yank_type = MBLOCK; if (VIM_ISDIGIT(stropt[1])) { ++stropt; - block_len = getdigits(&stropt) - 1; + block_len = get_long_digits(&stropt) - 1; --stropt; } break; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3278de3561..6bd9da0c28 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -569,7 +569,7 @@ void ex_retab(exarg_T *eap) save_list = curwin->w_p_list; curwin->w_p_list = 0; /* don't want list mode here */ - new_ts = getdigits(&(eap->arg)); + new_ts = get_int_digits(&(eap->arg)); if (new_ts < 0) { EMSG(_(e_positive)); return; @@ -3674,7 +3674,7 @@ void do_sub(exarg_T *eap) */ cmd = skipwhite(cmd); if (VIM_ISDIGIT(*cmd)) { - i = getdigits(&cmd); + i = get_long_digits(&cmd); if (i <= 0 && !eap->skip && do_error) { EMSG(_(e_zerocount)); return; @@ -5920,7 +5920,7 @@ void ex_sign(exarg_T *eap) arg1 = arg; if (VIM_ISDIGIT(*arg)) { - id = getdigits(&arg); + id = get_int_digits(&arg); if (!vim_iswhite(*arg) && *arg != NUL) { id = -1; @@ -5985,7 +5985,7 @@ void ex_sign(exarg_T *eap) else if (STRNCMP(arg, "buffer=", 7) == 0) { arg += 7; - buf = buflist_findnr((int)getdigits(&arg)); + buf = buflist_findnr(get_int_digits(&arg)); if (*skipwhite(arg) != NUL) EMSG(_(e_trailing)); break; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 072972d24e..d4e5f138fc 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -471,7 +471,7 @@ dbg_parsearg ( else if ( gap != &prof_ga && VIM_ISDIGIT(*p)) { - bp->dbg_lnum = getdigits(&p); + bp->dbg_lnum = get_long_digits(&p); p = skipwhite(p); } else bp->dbg_lnum = 0; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ca79270fcc..abc205a1e8 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1733,7 +1733,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, if ((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg) && (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL || vim_iswhite(*p))) { - n = getdigits(&ea.arg); + n = get_long_digits(&ea.arg); ea.arg = skipwhite(ea.arg); if (n <= 0 && !ni && (ea.argt & ZEROR) == 0) { errormsg = (char_u *)_(e_zerocount); @@ -3250,7 +3250,7 @@ get_address ( default: if (VIM_ISDIGIT(*cmd)) /* absolute line number */ - lnum = getdigits(&cmd); + lnum = get_long_digits(&cmd); } for (;; ) { @@ -3267,7 +3267,7 @@ get_address ( if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */ n = 1; else - n = getdigits(&cmd); + n = get_long_digits(&cmd); if (i == '-') lnum -= n; else @@ -4439,7 +4439,7 @@ two_count: return FAIL; } - *def = getdigits(&p); + *def = get_long_digits(&p); *argt |= (ZEROR | NOTADR); if (p != val + vallen || vallen == 0) { @@ -4456,7 +4456,7 @@ invalid_count: if (*def >= 0) goto two_count; - *def = getdigits(&p); + *def = get_long_digits(&p); if (p != val + vallen) goto invalid_count; @@ -5819,7 +5819,7 @@ static void ex_tabmove(exarg_T *eap) return; } - tab_number = getdigits(&p); + tab_number = get_int_digits(&p); if (relative != 0) tab_number = tab_number * relative + tabpage_index(curtab) - 1; ; } else if (eap->addr_count != 0) @@ -6441,10 +6441,10 @@ static void ex_winsize(exarg_T *eap) char_u *arg = eap->arg; char_u *p; - w = getdigits(&arg); + w = get_int_digits(&arg); arg = skipwhite(arg); p = arg; - h = getdigits(&arg); + h = get_int_digits(&arg); if (*p != NUL && *arg == NUL) screen_resize(w, h, TRUE); else @@ -6494,10 +6494,10 @@ static void ex_winpos(exarg_T *eap) if (*arg == NUL) { EMSG(_("E188: Obtaining window position not implemented for this platform")); } else { - x = getdigits(&arg); + x = get_int_digits(&arg); arg = skipwhite(arg); p = arg; - y = getdigits(&arg); + y = get_int_digits(&arg); if (*p == NUL || *arg != NUL) { EMSG(_("E466: :winpos requires two number arguments")); return; @@ -6744,7 +6744,7 @@ static void ex_later(exarg_T *eap) if (*p == NUL) count = 1; else if (isdigit(*p)) { - count = getdigits(&p); + count = get_long_digits(&p); switch (*p) { case 's': ++p; sec = TRUE; break; case 'm': ++p; sec = TRUE; count *= 60; break; @@ -7354,7 +7354,7 @@ static void ex_findpat(exarg_T *eap) n = 1; if (vim_isdigit(*eap->arg)) { /* get count */ - n = getdigits(&eap->arg); + n = get_long_digits(&eap->arg); eap->arg = skipwhite(eap->arg); } if (*eap->arg == '/') { /* Match regexp, not just whole words */ @@ -7618,7 +7618,7 @@ eval_vars ( s = src + 1; if (*s == '<') /* "#<99" uses v:oldfiles */ ++s; - i = (int)getdigits(&s); + i = get_int_digits(&s); *usedlen = (int)(s - src); /* length of what we expand */ if (src[1] == '<') { diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 69285b3f32..1f0a0872a5 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -320,9 +320,7 @@ static char_u *parse_list_options(char_u *option_str, option_table_T *table, int if (!VIM_ISDIGIT(*p)) return (char_u *)N_("E552: digit expected"); - long digits = getdigits(&p); - assert(digits >= INT_MIN && digits >= INT_MAX); - table[idx].number = (int)digits; + table[idx].number = get_int_digits(&p); } table[idx].string = p; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 39ad512227..94d2a2ffff 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1463,9 +1463,7 @@ void parse_cino(buf_T *buf) if (*p == '-') ++p; char_u *digits_start = p; /* remember where the digits start */ - int64_t digits = getdigits(&p); - assert(digits <= INT_MAX); - int n = (int)digits; + int n = get_int_digits(&p); divider = 0; if (*p == '.') { /* ".5s" means a fraction */ fraction = atoi((char *)++p); @@ -1678,9 +1676,7 @@ int get_c_indent(void) else if (*p == COM_LEFT || *p == COM_RIGHT) align = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') { - int64_t digits = getdigits(&p); - assert(digits <= INT_MAX); - off = (int)digits; + off = get_int_digits(&p); } else ++p; diff --git a/src/nvim/mark.c b/src/nvim/mark.c index ef9f0ca408..abe05dfb30 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1226,9 +1226,9 @@ int read_viminfo_filemark(vir_T *virp, int force) } if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) { str = skipwhite(str + 1); - fm->fmark.mark.lnum = getdigits(&str); + fm->fmark.mark.lnum = get_long_digits(&str); str = skipwhite(str); - fm->fmark.mark.col = getdigits(&str); + fm->fmark.mark.col = get_int_digits(&str); fm->fmark.mark.coladd = 0; fm->fmark.fnum = 0; str = skipwhite(str); diff --git a/src/nvim/menu.c b/src/nvim/menu.c index b31b6c1cec..dffd1f41c5 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -120,7 +120,7 @@ ex_menu ( break; if (vim_iswhite(*p)) { for (i = 0; i < MENUDEPTH && !vim_iswhite(*arg); ++i) { - pri_tab[i] = getdigits(&arg); + pri_tab[i] = get_int_digits(&arg); if (pri_tab[i] == 0) pri_tab[i] = 500; if (*arg == '.') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 4f17f84e11..912babefb6 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -525,7 +525,7 @@ open_line ( if (*p == COM_RIGHT || *p == COM_LEFT) c = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') - off = getdigits(&p); + off = get_int_digits(&p); else ++p; } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3cefc9f623..d471453ffd 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4501,7 +4501,7 @@ int read_viminfo_register(vir_T *virp, int force) y_current->y_type = MLINE; /* get the block width; if it's missing we get a zero, which is OK */ str = skipwhite(skiptowhite(str)); - y_current->y_width = getdigits(&str); + y_current->y_width = get_int_digits(&str); } while (!(eof = viminfo_readline(virp)) diff --git a/src/nvim/option.c b/src/nvim/option.c index 20e983b253..2c9bd58d08 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2918,7 +2918,7 @@ do_set ( */ else if (varp == (char_u *)&p_bs && VIM_ISDIGIT(**(char_u **)varp)) { - i = getdigits((char_u **)varp); + i = get_int_digits((char_u **)varp); switch (i) { case 0: *(char_u **)varp = empty_option; @@ -2943,7 +2943,7 @@ do_set ( else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg)) { *errbuf = NUL; - i = getdigits(&arg); + i = get_int_digits(&arg); if (i & 1) STRCAT(errbuf, "b,"); if (i & 2) @@ -4359,7 +4359,7 @@ did_set_string_option ( /* set ru_wid if 'ruf' starts with "%99(" */ if (*++s == '-') /* ignore a '-' */ s++; - wid = getdigits(&s); + wid = get_int_digits(&s); if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) ru_wid = wid; else @@ -4664,14 +4664,14 @@ char_u *check_colorcolumn(win_T *wp) ++s; if (!VIM_ISDIGIT(*s)) return e_invarg; - col = col * getdigits(&s); + col = col * get_int_digits(&s); if (wp->w_buffer->b_p_tw == 0) goto skip; /* 'textwidth' not set, skip this item */ col += wp->w_buffer->b_p_tw; if (col < 0) goto skip; } else if (VIM_ISDIGIT(*s)) - col = getdigits(&s); + col = get_int_digits(&s); else return e_invarg; color_cols[count++] = col - 1; /* 1-based to 0-based */ @@ -8114,12 +8114,12 @@ static bool briopt_check(win_T *wp) && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6]))) { p += 6; - bri_shift = getdigits(&p); + bri_shift = get_int_digits(&p); } else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) { p += 4; - bri_min = getdigits(&p); + bri_min = get_long_digits(&p); } else if (STRNCMP(p, "sbr", 3) == 0) { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index dd7af63ce0..326640118b 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3082,10 +3082,10 @@ static int read_limits(long *minval, long *maxval) reverse = TRUE; } first_char = regparse; - *minval = getdigits(®parse); + *minval = get_long_digits(®parse); if (*regparse == ',') { /* There is a comma */ if (vim_isdigit(*++regparse)) - *maxval = getdigits(®parse); + *maxval = get_long_digits(®parse); else *maxval = MAX_LIMIT; } else if (VIM_ISDIGIT(*first_char)) diff --git a/src/nvim/search.c b/src/nvim/search.c index d3946a9b63..bd2a49c2d2 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -4611,7 +4611,7 @@ int read_viminfo_search_pattern(vir_T *virp, int force) if (lp[4] == 'E') off_end = SEARCH_END; lp += 5; - off = getdigits(&lp); + off = get_long_digits(&lp); } if (lp[0] == '~') { /* use this pattern for last-used pattern */ setlast = TRUE; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index b8713909b8..af020198d3 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -5162,7 +5162,7 @@ static unsigned get_affitem(int flagtype, char_u **pp) ++*pp; // always advance, avoid getting stuck return 0; } - res = getdigits(pp); + res = get_int_digits(pp); } else { res = mb_ptr2char_adv(pp); if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG @@ -5283,7 +5283,9 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) case AFT_NUM: for (p = afflist; *p != NUL; ) { - n = getdigits(&p); + int digits = get_int_digits(&p); + assert(digits >= 0); + n = (unsigned int)digits; if (n == flag) return true; if (*p != NUL) // skip over comma @@ -6357,19 +6359,19 @@ int spell_check_msm(void) if (!VIM_ISDIGIT(*p)) return FAIL; // block count = (value * 1024) / SBLOCKSIZE (but avoid overflow) - start = (getdigits(&p) * 10) / (SBLOCKSIZE / 102); + start = (get_long_digits(&p) * 10) / (SBLOCKSIZE / 102); if (*p != ',') return FAIL; ++p; if (!VIM_ISDIGIT(*p)) return FAIL; - incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10); + incr = (get_long_digits(&p) * 102) / (SBLOCKSIZE / 10); if (*p != ',') return FAIL; ++p; if (!VIM_ISDIGIT(*p)) return FAIL; - added = getdigits(&p) * 1024; + added = get_long_digits(&p) * 1024; if (*p != NUL) return FAIL; @@ -8355,7 +8357,7 @@ int spell_check_sps(void) f = 0; if (VIM_ISDIGIT(*buf)) { s = buf; - sps_limit = getdigits(&s); + sps_limit = get_int_digits(&s); if (*s != NUL && !VIM_ISDIGIT(*s)) f = -1; } else if (STRCMP(buf, "best") == 0) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f35da39bb3..6975932f2c 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4900,7 +4900,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) ci->sp_off_flags |= (1 << idx); if (idx == SPO_LC_OFF) { /* lc=99 */ end += 3; - *p = getdigits(&end); + *p = get_int_digits(&end); /* "lc=" offset automatically sets "ms=" offset */ if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) { @@ -4911,10 +4911,10 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) end += 4; if (*end == '+') { ++end; - *p = getdigits(&end); /* positive offset */ + *p = get_int_digits(&end); /* positive offset */ } else if (*end == '-') { ++end; - *p = -getdigits(&end); /* negative offset */ + *p = -get_int_digits(&end); /* negative offset */ } } if (*end != ',') @@ -4980,7 +4980,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) illegal = TRUE; break; } - n = getdigits(&arg_end); + n = get_long_digits(&arg_end); if (!eap->skip) { if (key[4] == 'B') curwin->w_s->b_syn_sync_linebreaks = n; diff --git a/src/nvim/term.c b/src/nvim/term.c index dfc42632c6..8e4efd69fb 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -3230,7 +3230,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) */ p = tp + slen; - mouse_code = getdigits(&p); + mouse_code = get_long_digits(&p); if (*p++ != ';') return -1; @@ -3238,15 +3238,11 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) if (key_name[0] == KS_SGR_MOUSE) mouse_code += 32; - long digits = getdigits(&p); - assert(digits >= INT_MIN && digits <= INT_MAX); - mouse_col = (int)digits - 1; + mouse_col = get_int_digits(&p); if (*p++ != ';') return -1; - digits = getdigits(&p); - assert(digits >= INT_MIN && digits <= INT_MAX); - mouse_row = (int)digits - 1; + mouse_row = get_int_digits(&p); if (key_name[0] == KS_SGR_MOUSE && *p == 'm') mouse_code |= MOUSE_RELEASE; else if (*p != 'M') @@ -3273,7 +3269,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) } } p += j; - if (cmd_complete && getdigits(&p) == mouse_code) { + if (cmd_complete && get_long_digits(&p) == mouse_code) { slen += j; /* skip the \033[ */ continue; } @@ -3319,10 +3315,10 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) * '6' is the row, 45 is the column */ p = tp + slen; - mr = getdigits(&p); + mr = get_long_digits(&p); if (*p++ != ',') return -1; - mc = getdigits(&p); + mc = get_long_digits(&p); if (*p++ != '\r') return -1; @@ -3389,27 +3385,27 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) p = tp + slen; /* get event status */ - Pe = getdigits(&p); + Pe = get_long_digits(&p); if (*p++ != ';') return -1; /* get button status */ - Pb = getdigits(&p); + Pb = get_long_digits(&p); if (*p++ != ';') return -1; /* get row status */ - Pr = getdigits(&p); + Pr = get_long_digits(&p); if (*p++ != ';') return -1; /* get column status */ - Pc = getdigits(&p); + Pc = get_long_digits(&p); /* the page parameter is optional */ if (*p == ';') { p++; - (void)getdigits(&p); + (void)get_long_digits(&p); } if (*p++ != '&') return -1; diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 9c58193e8c..a0b45c1077 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -344,14 +344,14 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) assert(p != end); if (VIM_ISDIGIT(*p)) { - arg1 = (int)getdigits(&p); + arg1 = get_int_digits(&p); if (p >= end) { break; } if (*p == ';') { p++; - arg2 = (int)getdigits(&p); + arg2 = get_int_digits(&p); if (p >= end) break; } diff --git a/src/nvim/window.c b/src/nvim/window.c index ed4a8d8e7a..cfe60c65f3 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4908,7 +4908,7 @@ file_name_in_line ( ++p; /* skip the separator */ p = skipwhite(p); if (isdigit(*p)) - *file_lnum = (int)getdigits(&p); + *file_lnum = get_long_digits(&p); } } |