Skip to content

Commit

Permalink
Add radix parameter to lstrtoXXX functions for future use.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Sep 24, 2022
1 parent fdabc7d commit 8c77e72
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions less.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ struct ansi_state;
void postoa LESSPARAMS ((POSITION, char*));
void linenumtoa LESSPARAMS ((LINENUM, char*));
void inttoa LESSPARAMS ((int, char*));
int lstrtoi LESSPARAMS ((char*, char**));
POSITION lstrtopos LESSPARAMS ((char*, char**));
int lstrtoi LESSPARAMS ((char*, char**, int));
POSITION lstrtopos LESSPARAMS ((char*, char**, int));
#if MSDOS_COMPILER==WIN32C
int pclose LESSPARAMS ((FILE*));
#endif
12 changes: 6 additions & 6 deletions lessecho.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ pr_error(s)
}

static long
lstrtol(s, radix, pend)
lstrtol(s, pend, radix)
char *s;
int radix;
char **pend;
int radix;
{
int v;
int neg = 0;
Expand Down Expand Up @@ -210,7 +210,7 @@ main(argc, argv)
closequote = *++arg;
break;
case 'd':
closequote = lstrtol(++arg, 0, &s);
closequote = lstrtol(++arg, &s, 0);
if (s == arg)
pr_error("Missing number after -d");
break;
Expand All @@ -221,7 +221,7 @@ main(argc, argv)
meta_escape = arg;
break;
case 'f':
meta_escape_buf[0] = lstrtol(++arg, 0, &s);
meta_escape_buf[0] = lstrtol(++arg, &s, 0);
meta_escape_buf[1] = '\0';
meta_escape = meta_escape_buf;
if (s == arg)
Expand All @@ -231,15 +231,15 @@ main(argc, argv)
openquote = *++arg;
break;
case 'p':
openquote = lstrtol(++arg, 0, &s);
openquote = lstrtol(++arg, &s, 0);
if (s == arg)
pr_error("Missing number after -p");
break;
case 'm':
add_metachar(*++arg);
break;
case 'n':
add_metachar(lstrtol(++arg, 0, &s));
add_metachar(lstrtol(++arg, &s, 0));
if (s == arg)
pr_error("Missing number after -n");
break;
Expand Down
5 changes: 3 additions & 2 deletions lesskey.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ lesskey_parse_error(s)
}

int
lstrtoi(buf, ebuf)
lstrtoi(buf, ebuf, radix)
char *buf;
char **ebuf;
int radix;
{
return (int) strtol(buf, ebuf, 10);
return (int) strtol(buf, ebuf, radix);
}

void *
Expand Down
6 changes: 3 additions & 3 deletions lesskey_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
extern void lesskey_parse_error(char *msg);
extern char *homefile(char *filename);
extern void *ecalloc(int count, unsigned int size);
extern int lstrtoi(char *str, char **end);
extern int lstrtoi(char *str, char **end, int radix);
extern char version[];

static int linenum;
Expand Down Expand Up @@ -439,7 +439,7 @@ version_line(s, tables)
return (NULL);
}
s = skipsp(s);
ver = lstrtoi(s, &e);
ver = lstrtoi(s, &e, 10);
if (e == s)
{
parse_error("non-numeric version number in #version line", "");
Expand Down Expand Up @@ -678,7 +678,7 @@ parse_lesskey(infile, tables)
errors = 0;
linenum = 0;
if (less_version == 0)
less_version = lstrtoi(version, NULL);
less_version = lstrtoi(version, NULL, 10);

/*
* Open the input file.
Expand Down
4 changes: 2 additions & 2 deletions mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ restore_mark(line)
if (m == NULL)
return;
skip_whitespace;
ln = lstrtoi(line, &line);
ln = lstrtoi(line, &line, 10);
if (ln < 1)
ln = 1;
if (ln > sc_height)
ln = sc_height;
skip_whitespace;
pos = lstrtopos(line, &line);
pos = lstrtopos(line, &line, 10);
skip_whitespace;
cmark(m, NULL_IFILE, pos, ln);
m->m_filename = save(line);
Expand Down
8 changes: 5 additions & 3 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,17 @@ TYPE_TO_A_FUNC(inttoa, int)
* Convert an string to an integral type.
*/
#define STR_TO_TYPE_FUNC(funcname, type) \
type funcname(buf, ebuf) \
type funcname(buf, ebuf, radix) \
char *buf; \
char **ebuf; \
int radix; \
{ \
type val = 0; \
for (;; buf++) { \
char c = *buf; \
if (c < '0' || c > '9') break; \
val = 10 * val + c - '0'; \
int digit = (c >= '0' && c <= '9') ? c - '0' : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : (c >= 'A' && c <= 'F') ? c - 'A' + 10 : -1; \
if (digit < 0 || digit >= radix) break; \
val = radix * val + digit; \
} \
if (ebuf != NULL) *ebuf = buf; \
return val; \
Expand Down
4 changes: 2 additions & 2 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ ltputs(str, affcnt, f_putc)
do_tputs(str2, affcnt, f_putc);
str += slen + 2;
/* Perform the delay. */
delay = lstrtoi(str, &str);
delay = lstrtoi(str, &str, 10);
if (*str == '*')
delay *= affcnt;
flush();
Expand Down Expand Up @@ -2469,7 +2469,7 @@ parse_color6(ps)
} else
{
char *ops = *ps;
int color = lstrtoi(ops, ps);
int color = lstrtoi(ops, ps, 10);
if (*ps == ops)
return CV_ERROR;
return color;
Expand Down

0 comments on commit 8c77e72

Please sign in to comment.