Skip to content

Commit

Permalink
Constify all the opt_* functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 7, 2023
1 parent f14f61d commit c6fb7d2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 53 deletions.
72 changes: 36 additions & 36 deletions optfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extern char *tags;
extern char ztags[];
#endif
#if LESSTEST
extern char *ttyin_name;
extern constant char *ttyin_name;
extern int is_tty;
#endif /*LESSTEST*/
#if MSDOS_COMPILER
Expand All @@ -99,7 +99,7 @@ extern int sgr_mode;
/*
* Handler for -o option.
*/
public void opt_o(int type, char *s)
public void opt_o(int type, constant char *s)
{
PARG parg;
char *filename;
Expand All @@ -125,7 +125,7 @@ public void opt_o(int type, char *s)
error("Log file is already in use", NULL_PARG);
return;
}
s = skipsp(s);
s = skipspc(s);
if (namelogfile != NULL)
free(namelogfile);
filename = lglob(s);
Expand All @@ -149,7 +149,7 @@ public void opt_o(int type, char *s)
/*
* Handler for -O option.
*/
public void opt__O(int type, char *s)
public void opt__O(int type, constant char *s)
{
force_logfile = TRUE;
opt_o(type, s);
Expand Down Expand Up @@ -213,7 +213,7 @@ static void query_fraction(int value, long fraction, char *int_msg, char *frac_m
/*
* Handlers for -j option.
*/
public void opt_j(int type, char *s)
public void opt_j(int type, constant char *s)
{
switch (type)
{
Expand All @@ -240,7 +240,7 @@ public void calc_jump_sline(void)
/*
* Handlers for -# option.
*/
public void opt_shift(int type, char *s)
public void opt_shift(int type, constant char *s)
{
switch (type)
{
Expand All @@ -264,7 +264,7 @@ public void calc_shift_count(void)
}

#if USERFILE
public void opt_k(int type, char *s)
public void opt_k(int type, constant char *s)
{
PARG parg;

Expand All @@ -281,7 +281,7 @@ public void opt_k(int type, char *s)
}

#if HAVE_LESSKEYSRC
public void opt_ks(int type, char *s)
public void opt_ks(int type, constant char *s)
{
PARG parg;

Expand All @@ -297,7 +297,7 @@ public void opt_ks(int type, char *s)
}
}

public void opt_kc(int type, char *s)
public void opt_kc(int type, constant char *s)
{
switch (type)
{
Expand All @@ -316,7 +316,7 @@ public void opt_kc(int type, char *s)
/*
* Handler for -S option.
*/
public void opt__S(int type, char *s)
public void opt__S(int type, constant char *s)
{
switch (type)
{
Expand All @@ -330,7 +330,7 @@ public void opt__S(int type, char *s)
/*
* Handler for -t option.
*/
public void opt_t(int type, char *s)
public void opt_t(int type, constant char *s)
{
IFILE save_ifile;
POSITION pos;
Expand All @@ -347,7 +347,7 @@ public void opt_t(int type, char *s)
error("tags support is not available", NULL_PARG);
break;
}
findtag(skipsp(s));
findtag(skipspc(s));
save_ifile = save_curr_ifile();
/*
* Try to open the file containing the tag
Expand All @@ -368,7 +368,7 @@ public void opt_t(int type, char *s)
/*
* Handler for -T option.
*/
public void opt__T(int type, char *s)
public void opt__T(int type, constant char *s)
{
PARG parg;
char *filename;
Expand All @@ -379,7 +379,7 @@ public void opt__T(int type, char *s)
tags = save(s);
break;
case TOGGLE:
s = skipsp(s);
s = skipspc(s);
if (tags != NULL && tags != ztags)
free(tags);
filename = lglob(s);
Expand All @@ -397,7 +397,7 @@ public void opt__T(int type, char *s)
/*
* Handler for -p option.
*/
public void opt_p(int type, char *s)
public void opt_p(int type, constant char *s)
{
switch (type)
{
Expand Down Expand Up @@ -430,7 +430,7 @@ public void opt_p(int type, char *s)
/*
* Handler for -P option.
*/
public void opt__P(int type, char *s)
public void opt__P(int type, constant char *s)
{
char **proto;
PARG parg;
Expand Down Expand Up @@ -466,7 +466,7 @@ public void opt__P(int type, char *s)
* Handler for the -b option.
*/
/*ARGSUSED*/
public void opt_b(int type, char *s)
public void opt_b(int type, constant char *s)
{
switch (type)
{
Expand All @@ -486,7 +486,7 @@ public void opt_b(int type, char *s)
* Handler for the -i option.
*/
/*ARGSUSED*/
public void opt_i(int type, char *s)
public void opt_i(int type, constant char *s)
{
switch (type)
{
Expand All @@ -503,7 +503,7 @@ public void opt_i(int type, char *s)
* Handler for the -V option.
*/
/*ARGSUSED*/
public void opt__V(int type, char *s)
public void opt__V(int type, constant char *s)
{
switch (type)
{
Expand Down Expand Up @@ -613,7 +613,7 @@ static int color_from_namechar(char namechar)
* Handler for the -D option.
*/
/*ARGSUSED*/
public void opt_D(int type, char *s)
public void opt_D(int type, constant char *s)
{
PARG p;
int attr;
Expand Down Expand Up @@ -720,7 +720,7 @@ public void set_tabs(constant char *s, int len)
/*
* Handler for the -x option.
*/
public void opt_x(int type, char *s)
public void opt_x(int type, constant char *s)
{
char msg[60+((INT_STRLEN_BOUND(int)+1)*TABSTOP_MAX)];
int i;
Expand Down Expand Up @@ -756,7 +756,7 @@ public void opt_x(int type, char *s)
/*
* Handler for the -" option.
*/
public void opt_quote(int type, char *s)
public void opt_quote(int type, constant char *s)
{
char buf[3];
PARG parg;
Expand Down Expand Up @@ -795,7 +795,7 @@ public void opt_quote(int type, char *s)
* Handler for the --rscroll option.
*/
/*ARGSUSED*/
public void opt_rscroll(int type, char *s)
public void opt_rscroll(int type, constant char *s)
{
PARG p;

Expand Down Expand Up @@ -827,7 +827,7 @@ public void opt_rscroll(int type, char *s)
* If from the command line, exit immediately.
*/
/*ARGSUSED*/
public void opt_query(int type, char *s)
public void opt_query(int type, constant char *s)
{
switch (type)
{
Expand All @@ -841,7 +841,7 @@ public void opt_query(int type, char *s)
}

/*ARGSUSED*/
public void opt_match_shift(int type, char *s)
public void opt_match_shift(int type, constant char *s)
{
switch (type)
{
Expand All @@ -868,7 +868,7 @@ public void calc_match_shift(void)
* Handler for the --mouse option.
*/
/*ARGSUSED*/
public void opt_mousecap(int type, char *s)
public void opt_mousecap(int type, constant char *s)
{
switch (type)
{
Expand All @@ -888,7 +888,7 @@ public void opt_mousecap(int type, char *s)
* Handler for the --wheel-lines option.
*/
/*ARGSUSED*/
public void opt_wheel_lines(int type, char *s)
public void opt_wheel_lines(int type, constant char *s)
{
switch (type)
{
Expand All @@ -906,7 +906,7 @@ public void opt_wheel_lines(int type, char *s)
* Handler for the --line-number-width option.
*/
/*ARGSUSED*/
public void opt_linenum_width(int type, char *s)
public void opt_linenum_width(int type, constant char *s)
{
PARG parg;

Expand All @@ -930,7 +930,7 @@ public void opt_linenum_width(int type, char *s)
* Handler for the --status-column-width option.
*/
/*ARGSUSED*/
public void opt_status_col_width(int type, char *s)
public void opt_status_col_width(int type, constant char *s)
{
PARG parg;

Expand All @@ -954,7 +954,7 @@ public void opt_status_col_width(int type, char *s)
* Handler for the --file-size option.
*/
/*ARGSUSED*/
public void opt_filesize(int type, char *s)
public void opt_filesize(int type, constant char *s)
{
switch (type)
{
Expand All @@ -972,7 +972,7 @@ public void opt_filesize(int type, char *s)
* Handler for the --intr option.
*/
/*ARGSUSED*/
public void opt_intr(int type, char *s)
public void opt_intr(int type, constant char *s)
{
PARG p;

Expand All @@ -995,7 +995,7 @@ public void opt_intr(int type, char *s)
* Handler for the --header option.
*/
/*ARGSUSED*/
public void opt_header(int type, char *s)
public void opt_header(int type, constant char *s)
{
int err;
int n;
Expand All @@ -1008,7 +1008,7 @@ public void opt_header(int type, char *s)
header_cols = 0;
if (*s != ',')
{
n = getnum(&s, "header", &err);
n = getnumc(&s, "header", &err);
if (err)
{
error("invalid number of lines", NULL_PARG);
Expand All @@ -1019,7 +1019,7 @@ public void opt_header(int type, char *s)
if (*s == ',')
{
++s;
n = getnum(&s, "header", &err);
n = getnumc(&s, "header", &err);
if (err)
error("invalid number of columns", NULL_PARG);
else
Expand All @@ -1045,7 +1045,7 @@ public void opt_header(int type, char *s)
* Handler for the --search-options option.
*/
/*ARGSUSED*/
public void opt_search_type(int type, char *s)
public void opt_search_type(int type, constant char *s)
{
int st;
PARG parg;
Expand Down Expand Up @@ -1108,7 +1108,7 @@ public void opt_search_type(int type, char *s)
* Handler for the --tty option.
*/
/*ARGSUSED*/
public void opt_ttyin_name(int type, char *s)
public void opt_ttyin_name(int type, constant char *s)
{
switch (type)
{
Expand Down
6 changes: 3 additions & 3 deletions option.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static struct loption *pendopt;
public int plusoption = FALSE;

static constant char *optstring(constant char *s, char **p_str, constant char *printopt, char *validchars);
static constant char *optstring(constant char *s, char **p_str, constant char *printopt, constant char *validchars);
static int flip_triple(int val, int lc);

extern int less_is_more;
Expand Down Expand Up @@ -508,7 +508,7 @@ public int opt_has_param(struct loption *o)
* Return the prompt to be used for a given option letter.
* Only string and number valued options have prompts.
*/
public char * opt_prompt(struct loption *o)
public constant char * opt_prompt(struct loption *o)
{
if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
return ("?");
Expand Down Expand Up @@ -571,7 +571,7 @@ public void nopendopt(void)
* "d" indicates a string of one or more digits (0-9)
* "," indicates a comma-separated list of digit strings is allowed
*/
static constant char * optstring(constant char *s, char **p_str, constant char *printopt, char *validchars)
static constant char * optstring(constant char *s, char **p_str, constant char *printopt, constant char *validchars)
{
constant char *p;
char *out;
Expand Down
6 changes: 3 additions & 3 deletions option.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

struct optname
{
char *oname; /* Long (GNU-style) option name */
constant char *oname; /* Long (GNU-style) option name */
struct optname *onext; /* List of synonymous option names */
};

Expand All @@ -61,7 +61,7 @@ struct loption
int otype; /* Type of the option */
int odefault; /* Default value */
int *ovar; /* Pointer to the associated variable */
void (*ofunc)(int, char*); /* Pointer to special handling function */
char *odesc[3]; /* Description of each value */
void (*ofunc)(int, constant char*); /* Pointer to special handling function */
constant char *odesc[3]; /* Description of each value */
};

5 changes: 1 addition & 4 deletions os.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ extern char intr_char;
#if !MSDOS_COMPILER
extern int tty;
#endif
#if LESSTEST
extern char *ttyin_name;
#endif /*LESSTEST*/

public void init_poll(void)
{
Expand Down Expand Up @@ -125,7 +122,7 @@ static int check_poll(int fd, int tty)
}
poll(poller, 2, timeout);
#if LESSTEST
if (ttyin_name == NULL) /* Check for ^X only on a real tty. */
if (!is_lesstest()) /* Check for ^X only on a real tty. */
#endif /*LESSTEST*/
{
if (poller[1].revents & POLLIN)
Expand Down
Loading

0 comments on commit c6fb7d2

Please sign in to comment.