mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #1794 from elmart/remove-long_u-cleanup
Some suggested cleanup after #1788.
This commit is contained in:
commit
7f30439d0f
@ -750,7 +750,7 @@ do_bufdel (
|
||||
break;
|
||||
arg = p;
|
||||
} else
|
||||
bnr = getdigits(&arg);
|
||||
bnr = getdigits_int(&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 = getdigits_int(&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 = getdigits_int(&s);
|
||||
if (maxwid <= 0) /* overflow */
|
||||
maxwid = 50;
|
||||
}
|
||||
@ -4077,7 +4077,7 @@ chk_modeline (
|
||||
e = s + 4;
|
||||
else
|
||||
e = s + 3;
|
||||
vers = getdigits(&e);
|
||||
vers = getdigits_int(&e);
|
||||
if (*e == ':'
|
||||
&& (s[0] != 'V'
|
||||
|| STRNCMP(skipwhite(e + 1), "set", 3) == 0)
|
||||
|
@ -177,7 +177,7 @@ int buf_init_chartab(buf_T *buf, int global)
|
||||
}
|
||||
|
||||
if (VIM_ISDIGIT(*p)) {
|
||||
c = getdigits(&p);
|
||||
c = getdigits_int(&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 = getdigits_int(&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 from the string.
|
||||
long getdigits(char_u **pp)
|
||||
/// @return Number read from the string.
|
||||
intmax_t getdigits(char_u **pp)
|
||||
{
|
||||
char_u *p = *pp;
|
||||
long retval = atol((char *)p);
|
||||
intmax_t number = strtoimax((char *)*pp, (char **)pp, 10);
|
||||
assert(errno != ERANGE);
|
||||
return number;
|
||||
}
|
||||
|
||||
if (*p == '-') {
|
||||
// skip negative sign
|
||||
++p;
|
||||
}
|
||||
// skip to next non-digit
|
||||
p = skipdigits(p);
|
||||
*pp = p;
|
||||
return retval;
|
||||
/// Get an int number from a string.
|
||||
///
|
||||
/// A getdigits wrapper restricted to int values.
|
||||
int getdigits_int(char_u **pp)
|
||||
{
|
||||
intmax_t number = getdigits(pp);
|
||||
assert(number >= INT_MIN && number <= INT_MAX);
|
||||
return (int)number;
|
||||
}
|
||||
|
||||
/// Get a long number from a string.
|
||||
///
|
||||
/// A getdigits wrapper restricted to long values.
|
||||
long getdigits_long(char_u **pp)
|
||||
{
|
||||
intmax_t number = getdigits(pp);
|
||||
assert(number >= LONG_MIN && number <= LONG_MAX);
|
||||
return (long)number;
|
||||
}
|
||||
|
||||
/// Return TRUE if "lbuf" is empty or only contains blanks.
|
||||
|
@ -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 = getdigits_int(&p);
|
||||
if (len == 3) { /* "ver" or "hor" */
|
||||
if (n == 0)
|
||||
return (char_u *)N_("E549: Illegal percentage");
|
||||
|
@ -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 = getdigits_long(&p);
|
||||
|
||||
if (*p == ',') {
|
||||
++p;
|
||||
l1 = getdigits(&p);
|
||||
l1 = getdigits_long(&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 = getdigits_long(&p);
|
||||
|
||||
if (*p == ',') {
|
||||
++p;
|
||||
l2 = getdigits(&p);
|
||||
l2 = getdigits_long(&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 = getdigits_int(&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 = getdigits_int(&p);
|
||||
}
|
||||
|
||||
if ((*p != ',') && (*p != NUL)) {
|
||||
|
@ -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 = getdigits_int(&str);
|
||||
|
||||
// If the digraph already exists, replace the result.
|
||||
dp = (digr_T *)user_digraphs.ga_data;
|
||||
|
@ -2750,7 +2750,7 @@ void ex_lockvar(exarg_T *eap)
|
||||
if (eap->forceit)
|
||||
deep = -1;
|
||||
else if (vim_isdigit(*arg)) {
|
||||
deep = getdigits(&arg);
|
||||
deep = getdigits_int(&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 = getdigits_long(&stropt) - 1;
|
||||
--stropt;
|
||||
}
|
||||
break;
|
||||
|
@ -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 = getdigits_int(&(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 = getdigits_long(&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 = getdigits_int(&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(getdigits_int(&arg));
|
||||
if (*skipwhite(arg) != NUL)
|
||||
EMSG(_(e_trailing));
|
||||
break;
|
||||
|
@ -471,7 +471,7 @@ dbg_parsearg (
|
||||
else if (
|
||||
gap != &prof_ga &&
|
||||
VIM_ISDIGIT(*p)) {
|
||||
bp->dbg_lnum = getdigits(&p);
|
||||
bp->dbg_lnum = getdigits_long(&p);
|
||||
p = skipwhite(p);
|
||||
} else
|
||||
bp->dbg_lnum = 0;
|
||||
|
@ -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 = getdigits_long(&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 = getdigits_long(&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 = getdigits_long(&cmd);
|
||||
if (i == '-')
|
||||
lnum -= n;
|
||||
else
|
||||
@ -4439,7 +4439,7 @@ two_count:
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*def = getdigits(&p);
|
||||
*def = getdigits_long(&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 = getdigits_long(&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 = getdigits_int(&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 = getdigits_int(&arg);
|
||||
arg = skipwhite(arg);
|
||||
p = arg;
|
||||
h = getdigits(&arg);
|
||||
h = getdigits_int(&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 = getdigits_int(&arg);
|
||||
arg = skipwhite(arg);
|
||||
p = arg;
|
||||
y = getdigits(&arg);
|
||||
y = getdigits_int(&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 = getdigits_long(&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 = getdigits_long(&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 = getdigits_int(&s);
|
||||
*usedlen = (int)(s - src); /* length of what we expand */
|
||||
|
||||
if (src[1] == '<') {
|
||||
|
@ -320,7 +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");
|
||||
|
||||
table[idx].number = getdigits(&p); /*advances p*/
|
||||
table[idx].number = getdigits_int(&p);
|
||||
}
|
||||
|
||||
table[idx].string = p;
|
||||
@ -358,7 +358,6 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
|
||||
{
|
||||
int colorindex;
|
||||
uint32_t fg_color;
|
||||
uint32_t bg_color;
|
||||
char *color;
|
||||
|
||||
pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL);
|
||||
@ -367,8 +366,6 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
|
||||
pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
|
||||
|
||||
{
|
||||
bg_color = PRCOLOR_WHITE;
|
||||
|
||||
color = (char *)highlight_color(hl_id, (char_u *)"fg", modec);
|
||||
if (color == NULL)
|
||||
colorindex = 0;
|
||||
@ -387,7 +384,7 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
|
||||
fg_color = darken_rgb(fg_color);
|
||||
|
||||
pattr->fg_color = fg_color;
|
||||
pattr->bg_color = bg_color;
|
||||
pattr->bg_color = PRCOLOR_WHITE;
|
||||
}
|
||||
|
||||
static void prt_set_fg(uint32_t fg)
|
||||
@ -455,9 +452,7 @@ static void prt_line_number(prt_settings_T *psettings, int page_line, linenr_T l
|
||||
int prt_header_height(void)
|
||||
{
|
||||
if (printer_opts[OPT_PRINT_HEADERHEIGHT].present) {
|
||||
assert(printer_opts[OPT_PRINT_HEADERHEIGHT].number >= INT_MIN
|
||||
&& printer_opts[OPT_PRINT_HEADERHEIGHT].number <= INT_MAX);
|
||||
return (int)printer_opts[OPT_PRINT_HEADERHEIGHT].number;
|
||||
return printer_opts[OPT_PRINT_HEADERHEIGHT].number;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
@ -731,7 +726,8 @@ void ex_hardcopy(exarg_T *eap)
|
||||
if (got_int || settings.user_abort)
|
||||
goto print_fail;
|
||||
|
||||
assert(prtpos.bytes_printed * 100 > prtpos.bytes_printed);
|
||||
assert(prtpos.bytes_printed == 0
|
||||
|| prtpos.bytes_printed * 100 > prtpos.bytes_printed);
|
||||
sprintf((char *)IObuff, _("Printing page %d (%zu%%)"),
|
||||
page_count + 1 + side,
|
||||
prtpos.bytes_printed * 100 / bytes_to_print);
|
||||
@ -1266,11 +1262,11 @@ static int prt_need_underline;
|
||||
static int prt_underline;
|
||||
static int prt_do_underline;
|
||||
static int prt_need_fgcol;
|
||||
static int prt_fgcol;
|
||||
static uint32_t prt_fgcol;
|
||||
static int prt_need_bgcol;
|
||||
static int prt_do_bgcol;
|
||||
static int prt_bgcol;
|
||||
static int prt_new_bgcol;
|
||||
static uint32_t prt_bgcol;
|
||||
static uint32_t prt_new_bgcol;
|
||||
static int prt_attribute_change;
|
||||
static double prt_text_run;
|
||||
static int prt_page_num;
|
||||
@ -1472,8 +1468,8 @@ static void prt_flush_buffer(void)
|
||||
prt_write_real(prt_line_height, 2);
|
||||
|
||||
/* Lastly add the color of the background */
|
||||
r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
|
||||
g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
|
||||
r = (prt_new_bgcol & 0xff0000) >> 16;
|
||||
g = (prt_new_bgcol & 0xff00) >> 8;
|
||||
b = prt_new_bgcol & 0xff;
|
||||
prt_write_real(r / 255.0, 3);
|
||||
prt_write_real(g / 255.0, 3);
|
||||
@ -1960,9 +1956,7 @@ static double to_device_units(int idx, double physsize, int def_number)
|
||||
u = PRT_UNIT_PERC;
|
||||
nr = def_number;
|
||||
} else {
|
||||
assert(printer_opts[idx].number >= INT_MIN
|
||||
&& printer_opts[idx].number <= INT_MAX);
|
||||
nr = (int)printer_opts[idx].number;
|
||||
nr = printer_opts[idx].number;
|
||||
}
|
||||
|
||||
switch (u) {
|
||||
@ -2959,8 +2953,8 @@ int mch_print_text_out(char_u *p, int len)
|
||||
}
|
||||
if (prt_need_fgcol) {
|
||||
unsigned int r, g, b;
|
||||
r = ((unsigned)prt_fgcol & 0xff0000) >> 16;
|
||||
g = ((unsigned)prt_fgcol & 0xff00) >> 8;
|
||||
r = (prt_fgcol & 0xff0000) >> 16;
|
||||
g = (prt_fgcol & 0xff00) >> 8;
|
||||
b = prt_fgcol & 0xff;
|
||||
|
||||
prt_write_real(r / 255.0, 3);
|
||||
@ -3081,17 +3075,15 @@ void mch_print_set_font(int iBold, int iItalic, int iUnderline)
|
||||
|
||||
void mch_print_set_bg(uint32_t bgcol)
|
||||
{
|
||||
assert(bgcol <= INT_MAX);
|
||||
prt_bgcol = (int)bgcol;
|
||||
prt_bgcol = bgcol;
|
||||
prt_attribute_change = TRUE;
|
||||
prt_need_bgcol = TRUE;
|
||||
}
|
||||
|
||||
void mch_print_set_fg(uint32_t fgcol)
|
||||
{
|
||||
assert(fgcol <= INT_MAX);
|
||||
if ((int)fgcol != prt_fgcol) {
|
||||
prt_fgcol = (int)fgcol;
|
||||
if (fgcol != prt_fgcol) {
|
||||
prt_fgcol = fgcol;
|
||||
prt_attribute_change = TRUE;
|
||||
prt_need_fgcol = TRUE;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int hasnum;
|
||||
long number;
|
||||
int number;
|
||||
char_u *string; /* points into option string */
|
||||
int strlen;
|
||||
int present;
|
||||
|
@ -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 = getdigits_int(&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 = getdigits_int(&p);
|
||||
}
|
||||
else
|
||||
++p;
|
||||
|
@ -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 = getdigits_long(&str);
|
||||
str = skipwhite(str);
|
||||
fm->fmark.mark.col = getdigits(&str);
|
||||
fm->fmark.mark.col = getdigits_int(&str);
|
||||
fm->fmark.mark.coladd = 0;
|
||||
fm->fmark.fnum = 0;
|
||||
str = skipwhite(str);
|
||||
|
@ -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] = getdigits_int(&arg);
|
||||
if (pri_tab[i] == 0)
|
||||
pri_tab[i] = 500;
|
||||
if (*arg == '.')
|
||||
|
@ -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 = getdigits_int(&p);
|
||||
else
|
||||
++p;
|
||||
}
|
||||
|
@ -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 = getdigits_int(&str);
|
||||
}
|
||||
|
||||
while (!(eof = viminfo_readline(virp))
|
||||
|
@ -2918,7 +2918,7 @@ do_set (
|
||||
*/
|
||||
else if (varp == (char_u *)&p_bs
|
||||
&& VIM_ISDIGIT(**(char_u **)varp)) {
|
||||
i = getdigits((char_u **)varp);
|
||||
i = getdigits_int((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 = getdigits_int(&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 = getdigits_int(&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 * 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;
|
||||
if (col < 0)
|
||||
goto skip;
|
||||
} else if (VIM_ISDIGIT(*s))
|
||||
col = getdigits(&s);
|
||||
col = getdigits_int(&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 = getdigits_int(&p);
|
||||
}
|
||||
else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
|
||||
{
|
||||
p += 4;
|
||||
bri_min = getdigits(&p);
|
||||
bri_min = getdigits_long(&p);
|
||||
}
|
||||
else if (STRNCMP(p, "sbr", 3) == 0)
|
||||
{
|
||||
|
@ -3082,10 +3082,10 @@ static int read_limits(long *minval, long *maxval)
|
||||
reverse = TRUE;
|
||||
}
|
||||
first_char = regparse;
|
||||
*minval = getdigits(®parse);
|
||||
*minval = getdigits_long(®parse);
|
||||
if (*regparse == ',') { /* There is a comma */
|
||||
if (vim_isdigit(*++regparse))
|
||||
*maxval = getdigits(®parse);
|
||||
*maxval = getdigits_long(®parse);
|
||||
else
|
||||
*maxval = MAX_LIMIT;
|
||||
} else if (VIM_ISDIGIT(*first_char))
|
||||
|
@ -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 = getdigits_long(&lp);
|
||||
}
|
||||
if (lp[0] == '~') { /* use this pattern for last-used pattern */
|
||||
setlast = TRUE;
|
||||
|
@ -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 = getdigits_int(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 = getdigits_int(&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 = (getdigits_long(&p) * 10) / (SBLOCKSIZE / 102);
|
||||
if (*p != ',')
|
||||
return FAIL;
|
||||
++p;
|
||||
if (!VIM_ISDIGIT(*p))
|
||||
return FAIL;
|
||||
incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10);
|
||||
incr = (getdigits_long(&p) * 102) / (SBLOCKSIZE / 10);
|
||||
if (*p != ',')
|
||||
return FAIL;
|
||||
++p;
|
||||
if (!VIM_ISDIGIT(*p))
|
||||
return FAIL;
|
||||
added = getdigits(&p) * 1024;
|
||||
added = getdigits_long(&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 = getdigits_int(&s);
|
||||
if (*s != NUL && !VIM_ISDIGIT(*s))
|
||||
f = -1;
|
||||
} else if (STRCMP(buf, "best") == 0)
|
||||
|
@ -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 = getdigits_int(&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 = getdigits_int(&end); /* positive offset */
|
||||
} else if (*end == '-') {
|
||||
++end;
|
||||
*p = -getdigits(&end); /* negative offset */
|
||||
*p = -getdigits_int(&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 = getdigits_long(&arg_end);
|
||||
if (!eap->skip) {
|
||||
if (key[4] == 'B')
|
||||
curwin->w_s->b_syn_sync_linebreaks = n;
|
||||
|
@ -2819,13 +2819,13 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
|
||||
char_u bytes[6];
|
||||
int num_bytes;
|
||||
# endif
|
||||
long mouse_code = 0; /* init for GCC */
|
||||
int mouse_code = 0; /* init for GCC */
|
||||
int is_click, is_drag;
|
||||
long wheel_code = 0;
|
||||
long current_button;
|
||||
static long held_button = MOUSE_RELEASE;
|
||||
int wheel_code = 0;
|
||||
int current_button;
|
||||
static int held_button = MOUSE_RELEASE;
|
||||
static int orig_num_clicks = 1;
|
||||
static long orig_mouse_code = 0x0;
|
||||
static int orig_mouse_code = 0x0;
|
||||
int cpo_koffset;
|
||||
|
||||
cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL);
|
||||
@ -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 = getdigits_int(&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 = getdigits_int(&p);
|
||||
if (*p++ != ';')
|
||||
return -1;
|
||||
|
||||
digits = getdigits(&p);
|
||||
assert(digits >= INT_MIN && digits <= INT_MAX);
|
||||
mouse_row = (int)digits - 1;
|
||||
mouse_row = getdigits_int(&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 && getdigits_int(&p) == mouse_code) {
|
||||
slen += j; /* skip the \033[ */
|
||||
continue;
|
||||
}
|
||||
@ -3312,24 +3308,22 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
|
||||
}
|
||||
# endif /* !UNIX || FEAT_MOUSE_XTERM */
|
||||
if (key_name[0] == (int)KS_NETTERM_MOUSE) {
|
||||
long mc, mr;
|
||||
int mc, mr;
|
||||
|
||||
/* expect a rather limited sequence like: balancing {
|
||||
* \033}6,45\r
|
||||
* '6' is the row, 45 is the column
|
||||
*/
|
||||
p = tp + slen;
|
||||
mr = getdigits(&p);
|
||||
mr = getdigits_int(&p);
|
||||
if (*p++ != ',')
|
||||
return -1;
|
||||
mc = getdigits(&p);
|
||||
mc = getdigits_int(&p);
|
||||
if (*p++ != '\r')
|
||||
return -1;
|
||||
|
||||
assert(mc - 1 >= INT_MIN && mc - 1 <= INT_MAX);
|
||||
mouse_col = (int)(mc - 1);
|
||||
assert(mr - 1 >= INT_MIN && mr - 1 <= INT_MAX);
|
||||
mouse_row = (int)(mr - 1);
|
||||
mouse_col = mc - 1;
|
||||
mouse_row = mr - 1;
|
||||
mouse_code = MOUSE_LEFT;
|
||||
slen += (int)(p - (tp + slen));
|
||||
}
|
||||
@ -3384,32 +3378,32 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
|
||||
* The page coordinate may be omitted if the locator is on
|
||||
* page one (the default). We ignore it anyway.
|
||||
*/
|
||||
long Pe, Pb, Pr, Pc;
|
||||
int Pe, Pb, Pr, Pc;
|
||||
|
||||
p = tp + slen;
|
||||
|
||||
/* get event status */
|
||||
Pe = getdigits(&p);
|
||||
Pe = getdigits_int(&p);
|
||||
if (*p++ != ';')
|
||||
return -1;
|
||||
|
||||
/* get button status */
|
||||
Pb = getdigits(&p);
|
||||
Pb = getdigits_int(&p);
|
||||
if (*p++ != ';')
|
||||
return -1;
|
||||
|
||||
/* get row status */
|
||||
Pr = getdigits(&p);
|
||||
Pr = getdigits_int(&p);
|
||||
if (*p++ != ';')
|
||||
return -1;
|
||||
|
||||
/* get column status */
|
||||
Pc = getdigits(&p);
|
||||
Pc = getdigits_int(&p);
|
||||
|
||||
/* the page parameter is optional */
|
||||
if (*p == ';') {
|
||||
p++;
|
||||
(void)getdigits(&p);
|
||||
(void)getdigits_int(&p);
|
||||
}
|
||||
if (*p++ != '&')
|
||||
return -1;
|
||||
@ -3453,10 +3447,8 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
|
||||
default: return -1; /* should never occur */
|
||||
}
|
||||
|
||||
assert(Pc - 1 >= INT_MIN && Pc - 1 <= INT_MAX);
|
||||
mouse_col = (int)(Pc - 1);
|
||||
assert(Pr - 1 >= INT_MIN && Pr - 1 <= INT_MAX);
|
||||
mouse_row = (int)(Pr - 1);
|
||||
mouse_col = Pc - 1;
|
||||
mouse_row = Pr - 1;
|
||||
|
||||
slen += (int)(p - (tp + slen));
|
||||
}
|
||||
@ -3544,8 +3536,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
|
||||
key_name[1] = (wheel_code & 1)
|
||||
? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN;
|
||||
} else {
|
||||
assert(current_button >= INT_MIN && current_button <= INT_MAX);
|
||||
key_name[1] = (char_u)get_pseudo_mouse_code((int)current_button,
|
||||
key_name[1] = (char_u)get_pseudo_mouse_code(current_button,
|
||||
is_click, is_drag);
|
||||
}
|
||||
}
|
||||
|
@ -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 = getdigits_int(&p);
|
||||
if (p >= end) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (*p == ';') {
|
||||
p++;
|
||||
arg2 = (int)getdigits(&p);
|
||||
arg2 = getdigits_int(&p);
|
||||
if (p >= end)
|
||||
break;
|
||||
}
|
||||
|
@ -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 = getdigits_long(&p);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user