Add declarations to flex, cleans up Clang 15 warnings.

This commit is contained in:
Andrew Johnson
2023-12-12 13:44:08 -06:00
parent 6a369acd0b
commit 56dbc949ff
8 changed files with 50 additions and 34 deletions

View File

@@ -19,7 +19,7 @@ parse_CPPFLAGS = -DDEFAULT_SKELETON_FILE=$(SKELETON_FILE)
INC += flex.skel.static
# flex.c is included in parse.c
# flex.c, scan.c and yylex.c are #included by parse.c
e_flex_SRCS += ccl.c
e_flex_SRCS += dfa.c
e_flex_SRCS += ecs.c

View File

@@ -132,7 +132,6 @@ void cclnegate(int cclp)
void list_character_set(FILE *file, int cset[])
{
int i;
char *readable_form();
putc( '[', file );

View File

@@ -188,7 +188,6 @@ int main(int argc, char *argv[])
void flexend(int status)
{
int tblsiz;
char *flex_gettime();
if ( skelfile != NULL )
{
@@ -382,7 +381,7 @@ void flexend(int status)
void flexinit(int argc, char **argv)
{
int i, sawcmpflag;
char *arg, *flex_gettime(), *mktemp();
char *arg;
printstats = syntaxerror = trace = spprdflt = interactive = caseins = false;
backtrack_report = performance_report = ddebug = fulltbl = fullspd = false;

View File

@@ -567,8 +567,8 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
extern int num_backtracking, bol_needed;
void *allocate_array(int size, int element_size);
void *reallocate_array(void *array, int size, int element_size);
extern void *allocate_array(int size, int element_size);
extern void *reallocate_array(void *array, int size, int element_size);
#define allocate_integer_array(size) \
(int *) allocate_array( size, sizeof( int ) )
@@ -677,10 +677,20 @@ extern int all_upper (Char *);
/* bubble sort an integer array */
extern void bubble (int [], int);
/* replace upper-case letter to lower-case */
extern Char clower(int c);
/* returns copy of a string */
extern char *copy_string(char *str);
/* returns copy of a (potentially) unsigned string */
extern Char *copy_unsigned_string(Char *str);
/* shell sort a character array */
extern void cshell (Char [], int, int);
extern void dataend (void); /* finish up a block of data declarations */
/* finish up a block of data declarations */
extern void dataend (void);
/* report an error message and terminate */
extern void flexerror (char[]) NORETURN;
@@ -688,6 +698,9 @@ extern void flexerror (char[]) NORETURN;
/* report a fatal error message and terminate */
extern void flexfatal (char[]);
/* return current time */
extern char *flex_gettime();
/* report an error message formatted with one integer argument */
extern void lerrif (char[], int);
@@ -700,11 +713,18 @@ extern void line_directive_out (FILE*);
/* generate a data statment for a two-dimensional array */
extern void mk2data (int);
extern void mkdata (int); /* generate a data statement */
/* generate a data statement */
extern void mkdata (int);
/* return the integer represented by a string of digits */
extern int myctoi (Char []);
/* return character corresponding to escape sequence */
extern Char myesc(Char *array);
/* return the the human-readable form of a character */
extern char *readable_form(int c);
/* write out one section of the skeleton file */
extern void skelout (void);
@@ -784,8 +804,14 @@ extern void cclinstal (Char [], int);
/* lookup the number associated with character class */
extern int ccllookup (Char []);
extern void ndinstal (char[], Char[]); /* install a name definition */
extern void scinstal (char[], int); /* make a start condition */
/* install a name definition */
extern void ndinstal (char[], Char[]);
/* lookup a name definition */
extern Char *ndlookup(char *nd);
/* make a start condition */
extern void scinstal (char[], int);
/* lookup the number associated with a start condition */
extern int sclookup (char[]);

View File

@@ -217,7 +217,6 @@ void genecs(void)
int i, j;
static char C_char_decl[] = "static const %s %s[%d] =\n { 0,\n";
int numrows;
Char clower();
if ( numecs < csize )
printf( C_char_decl, "YY_CHAR", "yy_ec", csize );
@@ -237,8 +236,6 @@ void genecs(void)
if ( trace )
{
char *readable_form();
fputs( "\n\nEquivalence Classes:\n\n", stderr );
numrows = csize / 8;

View File

@@ -34,11 +34,18 @@
int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
Char clower();
static int madeany = false; /* whether we've made the '.' character class */
int previous_continued_action; /* whether the previous rule's action was '|' */
/* forward declarations */
void build_eof_action( void );
void synerr( char str[] );
void format_pinpoint_message( char msg[], char arg[] );
void pinpoint_message( char str[] );
void yyerror( char msg[] );
%}
%%
@@ -626,7 +633,7 @@ string : string CHAR
* conditions
*/
void build_eof_action()
void build_eof_action( void )
{
int i;
@@ -652,8 +659,7 @@ void build_eof_action()
/* synerr - report a syntax error */
void synerr( str )
char str[];
void synerr( char str[] )
{
syntaxerror = true;
@@ -665,8 +671,7 @@ char str[];
* pinpointing its location
*/
void format_pinpoint_message( msg, arg )
char msg[], arg[];
void format_pinpoint_message( char msg[], char arg[] )
{
char errmsg[MAXLINE];
@@ -678,8 +683,7 @@ char msg[], arg[];
/* pinpoint_message - write out a message, pinpointing its location */
void pinpoint_message( str )
char str[];
void pinpoint_message( char str[] )
{
fprintf( stderr, "\"%s\", line %d: %s\n", infilename, linenum, str );
@@ -690,8 +694,7 @@ char str[];
* currently, messages are ignore
*/
void yyerror( msg )
char msg[];
void yyerror( char msg[] )
{
}

View File

@@ -953,6 +953,7 @@ void yy_load_buffer_state ( void );
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
void yy_delete_buffer ( YY_BUFFER_STATE b );
void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
void set_input_file( char *file );
#define yy_new_buffer yy_create_buffer
@@ -966,7 +967,7 @@ YY_DECL
static int bracelevel, didadef;
int i, indented_code = false, checking_used = false, new_xlation = false;
int doing_codeblock = false;
Char nmdef[MAXLINE], myesc();
Char nmdef[MAXLINE];
if ( yy_init )
@@ -1488,7 +1489,6 @@ case 65:
# line 333 "scan.l"
{
Char *nmdefptr;
Char *ndlookup();
(void) strcpy( nmstr, (char *) yytext );
nmstr[yyleng - 1] = '\0'; /* chop trailing brace */
@@ -2230,8 +2230,7 @@ int yywrap()
/* set_input_file - open the given file (if NULL, stdin) for scanning */
void set_input_file( file )
char *file;
void set_input_file( char *file )
{
if ( file )

View File

@@ -108,8 +108,6 @@ void cclinstal(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();
(void) addsym( (char *) copy_unsigned_string( ccltxt ), (char *) 0, cclnum,
ccltab, CCL_HASH_SIZE );
}
@@ -191,9 +189,6 @@ int hashfunct(char *str, int hash_size)
void ndinstal(char *nd, Char *def)
{
char *copy_string();
Char *copy_unsigned_string();
if ( addsym( copy_string( nd ), (char *) copy_unsigned_string( def ), 0,
ndtbl, NAME_TABLE_HASH_SIZE ) )
synerr( "name defined twice" );
@@ -227,8 +222,6 @@ Char *ndlookup(char *nd)
void scinstal(char *str, int xcluflg)
{
char *copy_string();
/* bit of a hack. We know how the default start-condition is
* declared, and don't put out a define for it, because it
* would come out as "#define 0 1"