From c94e5a36c643a93216d5d701989cdbaaa08fe91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Thu, 12 Jul 2012 10:28:58 +0000 Subject: [PATCH] Boost Jam code cleanup - minor stylistic changes. [SVN r79442] --- v2/engine/fileunix.c | 2 +- v2/engine/jam.c | 2 +- v2/engine/scan.c | 67 ++++++++++++++++++++------------------------ v2/engine/scan.h | 16 +++++++---- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/v2/engine/fileunix.c b/v2/engine/fileunix.c index 6f99b28b0..8cd6abaa6 100644 --- a/v2/engine/fileunix.c +++ b/v2/engine/fileunix.c @@ -336,7 +336,7 @@ static void file_archscan_small( int fd, char const * archive, scanback func, } } -/* Check for OS version which supports the big variant. */ +/* Check for OS versions supporting the big variant. */ #ifdef AR_HSZ_BIG static void file_archscan_big( int fd, char const * archive, scanback func, diff --git a/v2/engine/jam.c b/v2/engine/jam.c index 120ba2a45..71a190d67 100644 --- a/v2/engine/jam.c +++ b/v2/engine/jam.c @@ -439,7 +439,7 @@ int main( int argc, char * * argv, char * * arg_environ ) /* Load up variables set on command line. */ for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n ) { - char *symv[ 2 ]; + char * symv[ 2 ]; symv[ 0 ] = s; symv[ 1 ] = 0; var_defines( root_module(), symv, 1 ); diff --git a/v2/engine/scan.c b/v2/engine/scan.c index 915ec21f4..62adab617 100644 --- a/v2/engine/scan.c +++ b/v2/engine/scan.c @@ -4,28 +4,19 @@ * This file is part of Jam - see jam.c for Copyright information. */ -#include "jam.h" -#include "lists.h" -#include "parse.h" -#include "scan.h" -#include "jamgram.h" -#include "jambase.h" -#include "object.h" -#include "constants.h" - /* * scan.c - the jam yacc scanner * - * 12/26/93 (seiwald) - bump buf in yylex to 10240 - yuk. - * 09/16/94 (seiwald) - check for overflows, unmatched {}'s, etc. - * Also handle tokens abutting EOF by remembering - * to return EOF now matter how many times yylex() - * reinvokes yyline(). - * 02/11/95 (seiwald) - honor only punctuation keywords if SCAN_PUNCT. - * 07/27/95 (seiwald) - Include jamgram.h after scan.h, so that YYSTYPE is - * defined before Linux's yacc tries to redefine it. */ +#include "jam.h" +#include "scan.h" + +#include "constants.h" +#include "jambase.h" +#include "jamgram.h" + + struct keyword { char * word; @@ -36,18 +27,19 @@ struct keyword { 0, 0 } }; +typedef struct include include; struct include { - struct include * next; /* next serial include file */ - char * string; /* pointer into current line */ - char * * strings; /* for yyfparse() -- text to parse */ - FILE * file; /* for yyfparse() -- file being read */ - OBJECT * fname; /* for yyfparse() -- file name */ - int line; /* line counter for error messages */ - char buf[ 512 ]; /* for yyfparse() -- line buffer */ + include * next; /* next serial include file */ + char * string; /* pointer into current line */ + char * * strings; /* for yyfparse() -- text to parse */ + FILE * file; /* for yyfparse() -- file being read */ + OBJECT * fname; /* for yyfparse() -- file name */ + int line; /* line counter for error messages */ + char buf[ 512 ]; /* for yyfparse() -- line buffer */ }; -static struct include * incp = 0; /* current file; head of chain */ +static include * incp = 0; /* current file; head of chain */ static int scanmode = SCAN_NORMAL; static int anyerrors = 0; @@ -68,22 +60,23 @@ void yymode( int n ) } -void yyerror( const char * s ) +void yyerror( char const * s ) { /* We use yylval instead of incp to access the error location information as * the incp pointer will already be reset to 0 in case the error occurred at * EOF. * - * The two may differ only if we get an error while reading a lexical token - * spanning muliple lines, e.g. a multi-line string literal or action body, - * in which case yylval location information will hold the information about - * where this token started while incp will hold the information about where - * reading it broke. + * The two may differ only if ran into an unexpected EOF or we get an error + * while reading a lexical token spanning multiple lines, e.g. a multi-line + * string literal or action body, in which case yylval location information + * will hold the information about where the token started while incp will + * hold the information about where reading it broke. * * TODO: Test the theory about when yylval and incp location information are * the same and when they differ. */ - printf( "%s:%d: %s at %s\n", object_str( yylval.file ), yylval.line, s, symdump( &yylval ) ); + printf( "%s:%d: %s at %s\n", object_str( yylval.file ), yylval.line, s, + symdump( &yylval ) ); ++anyerrors; } @@ -96,7 +89,7 @@ int yyanyerrors() void yyfparse( OBJECT * s ) { - struct include * i = (struct include *)BJAM_MALLOC( sizeof( *i ) ); + include * i = (include *)BJAM_MALLOC( sizeof( *i ) ); /* Push this onto the incp chain. */ i->string = ""; @@ -122,7 +115,7 @@ void yyfparse( OBJECT * s ) int yyline() { - struct include * i = incp; + include * const i = incp; if ( !incp ) return EOF; @@ -265,7 +258,7 @@ int yylex() int notkeyword; /* Eat white space. */ - for ( ;; ) + for ( ; ; ) { /* Skip past white space. */ while ( ( c != EOF ) && isspace( c ) ) @@ -389,11 +382,11 @@ static char * symdump( YYSTYPE * s ) static char buf[ BIGGEST_TOKEN + 20 ]; switch ( s->type ) { - case EOF : sprintf( buf, "EOF" ); break; + case EOF : sprintf( buf, "EOF" ); break; case 0 : sprintf( buf, "unknown symbol %s", object_str( s->string ) ); break; case ARG : sprintf( buf, "argument %s" , object_str( s->string ) ); break; case STRING: sprintf( buf, "string \"%s\"" , object_str( s->string ) ); break; - default : sprintf( buf, "keyword %s" , s->keyword ); break; + default : sprintf( buf, "keyword %s" , s->keyword ); break; } return buf; } diff --git a/v2/engine/scan.h b/v2/engine/scan.h index b672d0026..51b0002dd 100644 --- a/v2/engine/scan.h +++ b/v2/engine/scan.h @@ -8,7 +8,6 @@ * scan.h - the jam yacc scanner * * External functions: - * * yyerror( char *s ) - print a parsing error message. * yyfparse( char *s ) - scan include file s. * yylex() - parse the next token, returning its type. @@ -23,6 +22,11 @@ * lists without quoting. */ +#include "lists.h" +#include "object.h" +#include "parse.h" + + /* * YYSTYPE - value of a lexical token */ @@ -38,13 +42,13 @@ typedef struct _YYSTYPE int number; OBJECT * file; int line; - const char * keyword; + char const * keyword; } YYSTYPE; extern YYSTYPE yylval; void yymode( int n ); -void yyerror( const char * s ); +void yyerror( char const * s ); int yyanyerrors(); void yyfparse( OBJECT * s ); int yyline(); @@ -52,6 +56,6 @@ int yylex(); int yyparse(); void yyinput_stream( OBJECT * * name, int * line ); -# define SCAN_NORMAL 0 /* normal parsing */ -# define SCAN_STRING 1 /* look only for matching } */ -# define SCAN_PUNCT 2 /* only punctuation keywords */ +#define SCAN_NORMAL 0 /* normal parsing */ +#define SCAN_STRING 1 /* look only for matching } */ +#define SCAN_PUNCT 2 /* only punctuation keywords */