When scanning for is*() function uses with signed chars, I found that
lex(1) uses an unecessary #define for unsigned char. The below diff
removes it and fixes an undefined is*() usage or two as well.
Index: ecs.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/ecs.c,v
retrieving revision 1.6
diff -u -p -r1.6 ecs.c
--- ecs.c 4 Jun 2003 17:34:44 -0000 1.6
+++ ecs.c 12 Oct 2015 14:13:36 -0000
@@ -107,9 +107,9 @@ int fwd[], bck[], num;
/* mkeccl - update equivalence classes based on character class xtions
*
* synopsis
- * Char ccls[];
+ * unsigned char ccls[];
* int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping;
- * void mkeccl( Char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz],
+ * void mkeccl( unsigned char ccls[], int lenccl, int fwd[llsiz], int
bck[llsiz],
* int llsiz, int NUL_mapping );
*
* ccls contains the elements of the character class, lenccl is the
@@ -120,7 +120,7 @@ int fwd[], bck[], num;
*/
void mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping )
-Char ccls[];
+unsigned char ccls[];
int lenccl, fwd[], bck[], llsiz, NUL_mapping;
{
int cclp, oldec, newec;
Index: flexdef.h
===================================================================
RCS file: /cvs/src/usr.bin/lex/flexdef.h,v
retrieving revision 1.8
diff -u -p -r1.8 flexdef.h
--- flexdef.h 10 Oct 2015 05:47:54 -0000 1.8
+++ flexdef.h 12 Oct 2015 14:13:36 -0000
@@ -81,7 +81,6 @@
/* Always be prepared to generate an 8-bit scanner. */
#define CSIZE 256
-#define Char unsigned char
/* Size of input alphabet - should be size of ASCII set. */
#ifndef DEFAULT_CSIZE
@@ -633,7 +632,7 @@ extern int end_of_buffer_state;
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
extern int current_maxccls, current_max_ccl_tbl_size;
-extern Char *ccltbl;
+extern unsigned char *ccltbl;
/* Variables for miscellaneous information:
@@ -701,10 +700,10 @@ void flex_free PROTO((void*));
(char *) reallocate_array( (void *) array, size, sizeof( char ) )
#define allocate_Character_array(size) \
- (Char *) allocate_array( size, sizeof( Char ) )
+ (unsigned char *) allocate_array( size, sizeof( unsigned char ) )
#define reallocate_Character_array(array,size) \
- (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
+ (unsigned char *) reallocate_array( (void *) array, size, sizeof(
unsigned char ) )
/* Used to communicate between scanner and parser. The type should really
@@ -755,7 +754,7 @@ extern void ccl2ecl PROTO((void));
extern int cre8ecs PROTO((int[], int[], int));
/* Update equivalence classes based on character class transitions. */
-extern void mkeccl PROTO((Char[], int, int[], int[], int, int));
+extern void mkeccl PROTO((unsigned char[], int, int[], int[], int, int));
/* Create equivalence class for single character. */
extern void mkechar PROTO((int, int[], int[]));
@@ -834,16 +833,16 @@ extern void bubble PROTO((int [], int));
extern void check_char PROTO((int c));
/* Replace upper-case letter to lower-case. */
-extern Char clower PROTO((int));
+extern unsigned char clower PROTO((int));
/* Returns a dynamically allocated copy of a string. */
extern char *copy_string PROTO((register const char *));
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */
-extern Char *copy_unsigned_string PROTO((register Char *));
+extern unsigned char *copy_unsigned_string PROTO((register unsigned char *));
/* Shell sort a character array. */
-extern void cshell PROTO((Char [], int, int));
+extern void cshell PROTO((unsigned char[], int, int));
/* Finish up a block of data declarations. */
extern void dataend PROTO((void));
@@ -858,7 +857,7 @@ extern void flexerror PROTO((const char[
extern void flexfatal PROTO((const char[]));
/* Convert a hexadecimal digit string to an integer value. */
-extern int htoi PROTO((Char[]));
+extern int htoi PROTO((unsigned char[]));
/* Report an error message formatted with one integer argument. */
extern void lerrif PROTO((const char[], int));
@@ -886,10 +885,10 @@ extern void mkdata PROTO((int)); /* gene
extern int myctoi PROTO((char []));
/* Return character corresponding to escape sequence. */
-extern Char myesc PROTO((Char[]));
+extern unsigned char myesc PROTO((unsigned char[]));
/* Convert an octal digit string to an integer value. */
-extern int otoi PROTO((Char [] ));
+extern int otoi PROTO((unsigned char[] ));
/* Output a (possibly-formatted) string to the generated scanner. */
extern void out PROTO((const char []));
@@ -1008,16 +1007,16 @@ extern int yywrap PROTO((void));
extern int addsym PROTO((register char[], char*, int, hash_table, int));
/* Save the text of a character class. */
-extern void cclinstal PROTO ((Char [], int));
+extern void cclinstal PROTO ((unsigned char[], int));
/* Lookup the number associated with character class. */
-extern int ccllookup PROTO((Char []));
+extern int ccllookup PROTO((unsigned char[]));
/* Find symbol in symbol table. */
extern struct hash_entry *findsym PROTO((register char[], hash_table, int ));
-extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
-extern Char *ndlookup PROTO((char[])); /* lookup a name definition */
+extern void ndinstal PROTO((char[], unsigned char[])); /* install a name
definition */
+extern unsigned char *ndlookup PROTO((char[])); /* lookup a name
definition */
/* Increase maximum number of SC's. */
extern void scextend PROTO((void));
Index: initscan.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/initscan.c,v
retrieving revision 1.14
diff -u -p -r1.14 initscan.c
--- initscan.c 4 Nov 2013 17:03:32 -0000 1.14
+++ initscan.c 12 Oct 2015 14:13:36 -0000
@@ -1498,7 +1498,7 @@ YY_DECL
int doing_codeblock = false;
int i;
- Char nmdef[MAXLINE], myesc();
+ unsigned char nmdef[MAXLINE], myesc();
#line 1498 "scan.c"
@@ -2268,7 +2268,7 @@ YY_RULE_SETUP
/* Check to see if we've already encountered this
* ccl.
*/
- if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
+ if ( (cclval = ccllookup( (unsigned char *) nmstr )) !=
0 )
{
if ( input() != ']' )
synerr( _( "bad character class" ) );
@@ -2282,7 +2282,7 @@ YY_RULE_SETUP
/* We fudge a bit. We know that this ccl will
* soon be numbered as lastccl + 1 by cclinit.
*/
- cclinstal( (Char *) nmstr, lastccl + 1 );
+ cclinstal( (unsigned char *) nmstr, lastccl + 1
);
/* Push back everything but the leading bracket
* so the ccl can be rescanned.
@@ -2298,8 +2298,8 @@ case 106:
YY_RULE_SETUP
#line 435 "scan.l"
{
- Char *nmdefptr;
- Char *ndlookup();
+ unsigned char *nmdefptr;
+ unsigned char *ndlookup();
strlcpy( nmstr, yytext + 1, sizeof nmstr );
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
@@ -2711,7 +2711,7 @@ case 162:
YY_RULE_SETUP
#line 633 "scan.l"
{
- yylval = myesc( (Char *) yytext );
+ yylval = myesc( (unsigned char *) yytext );
if ( YY_START == FIRSTCCL )
BEGIN(CCL);
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/main.c,v
retrieving revision 1.15
diff -u -p -r1.15 main.c
--- main.c 10 Oct 2015 05:47:54 -0000 1.15
+++ main.c 12 Oct 2015 14:13:36 -0000
@@ -94,7 +94,7 @@ int *accsiz, *dhash, numas;
int numsnpairs, jambase, jamstate;
int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
int current_maxccls, current_max_ccl_tbl_size;
-Char *ccltbl;
+unsigned char *ccltbl;
char nmstr[MAXLINE];
int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
Index: misc.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/misc.c,v
retrieving revision 1.13
diff -u -p -r1.13 misc.c
--- misc.c 27 Oct 2013 18:31:24 -0000 1.13
+++ misc.c 12 Oct 2015 14:13:36 -0000
@@ -109,7 +109,7 @@ char *str;
{
while ( *str )
{
- if ( ! isascii( (Char) *str ) || ! islower( *str ) )
+ if ( ! isascii( (unsigned char)*str ) || ! islower( (unsigned
char)*str ) )
return 0;
++str;
}
@@ -125,7 +125,7 @@ char *str;
{
while ( *str )
{
- if ( ! isascii( (Char) *str ) || ! isupper( *str ) )
+ if ( ! isascii( (unsigned char)*str ) || ! isupper( (unsigned
char)*str ) )
return 0;
++str;
}
@@ -187,10 +187,10 @@ int c;
/* clower - replace upper-case letter to lower-case */
-Char clower( c )
+unsigned char clower( c )
int c;
{
- return (Char) ((isascii( c ) && isupper( c )) ? tolower( c ) : c);
+ return (unsigned char) ((isascii( c ) && isupper( c )) ? tolower( c ) :
c);
}
@@ -225,11 +225,11 @@ const char *str;
* returns a dynamically allocated copy of a (potentially) unsigned string
*/
-Char *copy_unsigned_string( str )
-Char *str;
+unsigned char *copy_unsigned_string( str )
+unsigned char *str;
{
- Char *c;
- Char *copy;
+ unsigned char *c;
+ unsigned char *copy;
/* find length */
for ( c = str; *c; ++c )
@@ -248,7 +248,7 @@ Char *str;
*
* synopsis
*
- * Char v[n];
+ * unsigned char v[n];
* int n, special_case_0;
* cshell( v, n, special_case_0 );
*
@@ -263,11 +263,11 @@ Char *str;
*/
void cshell( v, n, special_case_0 )
-Char v[];
+unsigned char v[];
int n, special_case_0;
{
int gap, i, j, jg;
- Char k;
+ unsigned char k;
for ( gap = n / 2; gap > 0; gap = gap / 2 )
for ( i = gap; i < n; ++i )
@@ -353,7 +353,7 @@ const char msg[];
/* htoi - convert a hexadecimal digit string to an integer value */
int htoi( str )
-Char str[];
+unsigned char str[];
{
unsigned int result;
@@ -535,10 +535,10 @@ char array[];
/* myesc - return character corresponding to escape sequence */
-Char myesc( array )
-Char array[];
+unsigned char myesc( array )
+unsigned char array[];
{
- Char c, esc_char;
+ unsigned char c, esc_char;
switch ( array[1] )
{
@@ -590,7 +590,7 @@ Char array[];
int sptr = 2;
while ( isascii( array[sptr] ) &&
- isxdigit( (char) array[sptr] ) )
+ isxdigit( array[sptr] ) )
/* Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
@@ -616,7 +616,7 @@ Char array[];
/* otoi - convert an octal digit string to an integer value */
int otoi( str )
-Char str[];
+unsigned char str[];
{
unsigned int result;
Index: scan.l
===================================================================
RCS file: /cvs/src/usr.bin/lex/scan.l,v
retrieving revision 1.9
diff -u -p -r1.9 scan.l
--- scan.l 6 Dec 2006 05:03:29 -0000 1.9
+++ scan.l 12 Oct 2015 14:13:36 -0000
@@ -105,7 +105,7 @@ LEXOPT [aceknopr]
int doing_codeblock = false;
int i;
- Char nmdef[MAXLINE], myesc();
+ unsigned char nmdef[MAXLINE], myesc();
<INITIAL>{
@@ -414,7 +414,7 @@ LEXOPT [aceknopr]
/* Check to see if we've already encountered this
* ccl.
*/
- if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
+ if ( (cclval = ccllookup( (unsigned char *) nmstr )) !=
0 )
{
if ( input() != ']' )
synerr( _( "bad character class" ) );
@@ -428,7 +428,7 @@ LEXOPT [aceknopr]
/* We fudge a bit. We know that this ccl will
* soon be numbered as lastccl + 1 by cclinit.
*/
- cclinstal( (Char *) nmstr, lastccl + 1 );
+ cclinstal( (unsigned char *) nmstr, lastccl + 1
);
/* Push back everything but the leading bracket
* so the ccl can be rescanned.
@@ -441,8 +441,8 @@ LEXOPT [aceknopr]
}
"{"{NAME}"}" {
- register Char *nmdefptr;
- Char *ndlookup();
+ register unsigned char *nmdefptr;
+ unsigned char *ndlookup();
strlcpy( nmstr, yytext + 1, sizeof nmstr );
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
@@ -639,7 +639,7 @@ LEXOPT [aceknopr]
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
- yylval = myesc( (Char *) yytext );
+ yylval = myesc( (unsigned char *) yytext );
if ( YY_START == FIRSTCCL )
BEGIN(CCL);
Index: sym.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/sym.c,v
retrieving revision 1.6
diff -u -p -r1.6 sym.c
--- sym.c 4 Jun 2003 17:34:44 -0000 1.6
+++ sym.c 12 Oct 2015 14:13:36 -0000
@@ -106,13 +106,13 @@ int table_size;
/* cclinstal - save the text of a character class */
void cclinstal( ccltxt, cclnum )
-Char ccltxt[];
+unsigned char ccltxt[];
int cclnum;
{
/* We don't bother checking the return status because we are not
* called unless the symbol is new.
*/
- Char *copy_unsigned_string();
+ unsigned char *copy_unsigned_string();
(void) addsym( (char *) copy_unsigned_string( ccltxt ),
(char *) 0, cclnum,
@@ -126,7 +126,7 @@ int cclnum;
*/
int ccllookup( ccltxt )
-Char ccltxt[];
+unsigned char ccltxt[];
{
return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val;
}
@@ -184,10 +184,10 @@ int hash_size;
void ndinstal( name, definition )
char name[];
-Char definition[];
+unsigned char definition[];
{
char *copy_string();
- Char *copy_unsigned_string();
+ unsigned char *copy_unsigned_string();
if ( addsym( copy_string( name ),
(char *) copy_unsigned_string( definition ), 0,
@@ -201,10 +201,10 @@ Char definition[];
* Returns a nil pointer if the name definition does not exist.
*/
-Char *ndlookup( nd )
+unsigned char *ndlookup( nd )
char nd[];
{
- return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val;
+ return (unsigned char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE
)->str_val;
}
Index: tblcmp.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/tblcmp.c,v
retrieving revision 1.6
diff -u -p -r1.6 tblcmp.c
--- tblcmp.c 4 Jun 2003 17:34:44 -0000 1.6
+++ tblcmp.c 12 Oct 2015 14:13:36 -0000
@@ -719,7 +719,7 @@ void mktemplate( state, statenum, comsta
int state[], statenum, comstate;
{
int i, numdiff, tmpbase, tmp[CSIZE + 1];
- Char transset[CSIZE + 1];
+ unsigned char transset[CSIZE + 1];
int tsptr;
++numtemps;