struct command_switch
{
char c; /* The switch character. */
+
enum /* Type of the value. */
{
flag, /* Turn int flag on. */
\f
/* The table of command switches. */
-static struct command_switch switches[] =
+static const struct command_switch switches[] =
{
{ 'b', ignore, 0, 0, 0, 0, 0, 0,
0, 0,
{ 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
"print-directory", 0,
"Print the current directory" },
- { -1, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
+ { 1, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
"no-print-directory", 0,
"Turn off -w, even if it was turned on implicitly" },
{ 'W', string, (char *) &new_files, 0, 0, 0, 0, 0,
long_options[i].name = (switches[i].long_name == 0 ? "" :
switches[i].long_name);
long_options[i].flag = 0;
- *p++ = long_options[i].val = switches[i].c;
+ long_options[i].val = switches[i].c;
+ if (isalnum (switches[i].c))
+ *p++ = switches[i].c;
switch (switches[i].type)
{
case flag:
case string:
case positive_int:
case floating:
- *p++ = ':';
+ if (isalnum (switches[i].c))
+ *p++ = ':';
if (switches[i].noarg_value != 0)
{
- *p++ = ':';
+ if (isalnum (switches[i].c))
+ *p++ = ':';
long_options[i].has_arg = optional_argument;
}
else
int env;
{
int bad = 0;
- register struct command_switch *cs;
+ register const struct command_switch *cs;
register struct stringlist *sl;
register int c;
p = buf;
- if (cs->c != -1)
+ if (isalnum (cs->c))
{
sprintf (buf, " -%c%s", cs->c, arg);
p += strlen (p);
{
unsigned int i;
sprintf (p, "%s--%s%s",
- cs->c == -1 ? " " : ", ",
+ !isalnum (cs->c) ? " " : ", ",
cs->long_name, arg);
p += strlen (p);
for (i = 0; i < (sizeof (long_option_aliases) /
}
}
{
- struct command_switch *ncs = cs;
+ const struct command_switch *ncs = cs;
while ((++ncs)->c != '\0')
if (ncs->description[0] == '-' &&
ncs->description[1] == cs->c)
define_makeflags (all, makefile)
int all, makefile;
{
- register struct command_switch *cs;
+ register const struct command_switch *cs;
char *flagstring;
/* We will construct a linked list of `struct flag's describing
struct flag
{
struct flag *next;
- struct command_switch *cs;
+ const struct command_switch *cs;
char *arg;
unsigned int arglen;
};
++flagslen; /* Just a single flag letter. */ \
else \
flagslen += 1 + 1 + 1 + 1 + new->arglen; /* " -x foo" */ \
- if (cs->c == -1) \
+ if (!isalnum (cs->c)) \
/* This switch has no single-letter version, so we use the long. */ \
flagslen += 2 + strlen (cs->long_name); \
} while (0)
do
{
/* Add the flag letter or name to the string. */
- if (flags->cs->c == -1)
+ if (!isalnum (flags->cs->c))
{
*p++ = '-';
strcpy (p, flags->cs->long_name);
if (flags->arglen > 0)
{
/* Add its argument too. */
- *p++ = flags->cs->c == -1 ? '=' : ' ';
+ *p++ = !isalnum (flags->cs->c) ? '=' : ' ';
bcopy (flags->arg, p, flags->arglen);
p += flags->arglen;
}
*p++ = ' ';
*p++ = '-';
}
- else if (flags->cs->c == -1)
+ else if (!isalnum (flags->cs->c))
{
/* Long options must each go in their own word,
so we write the following space and dash. */