Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/less/opttbl.c
Show First 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | #endif | ||||
{ '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } } | { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } } | ||||
}; | }; | ||||
/* | /* | ||||
* Initialize each option to its default value. | * Initialize each option to its default value. | ||||
*/ | */ | ||||
public void | public void | ||||
init_option() | init_option(void) | ||||
{ | { | ||||
register struct loption *o; | struct loption *o; | ||||
char *p; | char *p; | ||||
p = lgetenv("LESS_IS_MORE"); | p = lgetenv("LESS_IS_MORE"); | ||||
if (p != NULL && *p != '\0') | if (p != NULL && *p != '\0') | ||||
less_is_more = 1; | less_is_more = 1; | ||||
for (o = option; o->oletter != '\0'; o++) | for (o = option; o->oletter != '\0'; o++) | ||||
{ | { | ||||
/* | /* | ||||
* Set each variable to its default. | * Set each variable to its default. | ||||
*/ | */ | ||||
if (o->ovar != NULL) | if (o->ovar != NULL) | ||||
*(o->ovar) = o->odefault; | *(o->ovar) = o->odefault; | ||||
if (o->otype & INIT_HANDLER) | if (o->otype & INIT_HANDLER) | ||||
(*(o->ofunc))(INIT, (char *) NULL); | (*(o->ofunc))(INIT, (char *) NULL); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Find an option in the option table, given its option letter. | * Find an option in the option table, given its option letter. | ||||
*/ | */ | ||||
public struct loption * | public struct loption * | ||||
findopt(c) | findopt(int c) | ||||
int c; | |||||
{ | { | ||||
register struct loption *o; | struct loption *o; | ||||
for (o = option; o->oletter != '\0'; o++) | for (o = option; o->oletter != '\0'; o++) | ||||
{ | { | ||||
if (o->oletter == c) | if (o->oletter == c) | ||||
return (o); | return (o); | ||||
if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c) | if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c) | ||||
return (o); | return (o); | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
/* | /* | ||||
* | * | ||||
*/ | */ | ||||
static int | static int | ||||
is_optchar(c) | is_optchar(char c) | ||||
char c; | |||||
{ | { | ||||
if (ASCII_IS_UPPER(c)) | if (ASCII_IS_UPPER(c)) | ||||
return 1; | return 1; | ||||
if (ASCII_IS_LOWER(c)) | if (ASCII_IS_LOWER(c)) | ||||
return 1; | return 1; | ||||
if (c == '-') | if (c == '-') | ||||
return 1; | return 1; | ||||
return 0; | return 0; | ||||
} | } | ||||
/* | /* | ||||
* Find an option in the option table, given its option name. | * Find an option in the option table, given its option name. | ||||
* p_optname is the (possibly partial) name to look for, and | * p_optname is the (possibly partial) name to look for, and | ||||
* is updated to point after the matched name. | * is updated to point after the matched name. | ||||
* p_oname if non-NULL is set to point to the full option name. | * p_oname if non-NULL is set to point to the full option name. | ||||
*/ | */ | ||||
public struct loption * | public struct loption * | ||||
findopt_name(p_optname, p_oname, p_err) | findopt_name(char **p_optname, char **p_oname, int *p_err) | ||||
char **p_optname; | |||||
char **p_oname; | |||||
int *p_err; | |||||
{ | { | ||||
char *optname = *p_optname; | char *optname = *p_optname; | ||||
register struct loption *o; | struct loption *o; | ||||
register struct optname *oname; | struct optname *oname; | ||||
register int len; | int len; | ||||
int uppercase; | int uppercase; | ||||
struct loption *maxo = NULL; | struct loption *maxo = NULL; | ||||
struct optname *maxoname = NULL; | struct optname *maxoname = NULL; | ||||
int maxlen = 0; | int maxlen = 0; | ||||
int ambig = 0; | int ambig = 0; | ||||
int exact = 0; | int exact = 0; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |