is_optchar() could also take an int in order to be more compatible with
the ctype functions.
isupper() || islower() is equivalent to isalpha() in the C locale, but
not necessarily in others (see the isalpha(3) manpage).
We could use stdbool to make is_optchar() a one-liner, but I'll resist
the temptation.
ok?
Index: opttbl.c
===================================================================
RCS file: /cvs/src/usr.bin/less/opttbl.c,v
retrieving revision 1.15
diff -u -p -r1.15 opttbl.c
--- opttbl.c 6 Nov 2015 15:50:33 -0000 1.15
+++ opttbl.c 12 Nov 2015 00:22:20 -0000
@@ -458,7 +458,8 @@ findopt(int c)
for (o = option; o->oletter != '\0'; o++) {
if (o->oletter == c)
return (o);
- if ((o->otype & TRIPLE) && (toupper(o->oletter) == c))
+ if ((o->otype & TRIPLE) &&
+ (toupper((unsigned char)o->oletter) == c))
return (o);
}
return (NULL);
@@ -468,15 +469,12 @@ findopt(int c)
*
*/
static int
-is_optchar(char c)
+is_optchar(unsigned char c)
{
- if (isupper(c))
+ if (isupper(c) || islower(c) || c == '-')
return (1);
- if (islower(c))
- return (1);
- if (c == '-')
- return (1);
- return (0);
+ else
+ return (0);
}
/*