From a3836e09a22790f9b4a12628e37dd164158880e3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 8 Aug 2006 14:00:28 -0400 Subject: [PATCH] COMP: Moved duplicate flex-generated lexer warning suppression and cross-platform support code to a single cmStandardLexer.h included by all lexer sources. Added fix for macro redefinitions on Borland 5.8 compiler. --- Source/cmCommandArgumentLexer.cxx | 35 +--------------- Source/cmCommandArgumentLexer.in.l | 37 ++--------------- Source/cmDependsFortranLexer.cxx | 33 +-------------- Source/cmDependsFortranLexer.in.l | 35 ++-------------- Source/cmDependsJavaLexer.cxx | 36 ++-------------- Source/cmDependsJavaLexer.in.l | 39 ++--------------- Source/cmExprLexer.cxx | 38 ++--------------- Source/cmExprLexer.in.l | 37 ++--------------- Source/cmListFileLexer.c | 22 +--------- Source/cmListFileLexer.in.l | 26 ++---------- Source/cmStandardLexer.h | 67 ++++++++++++++++++++++++++++++ 11 files changed, 96 insertions(+), 309 deletions(-) create mode 100644 Source/cmStandardLexer.h diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index 1f49ad10a..127ffe135 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -477,31 +477,10 @@ Modify cmCommandArgumentLexer.h: */ +#include "cmStandardLexer.h" + #include "cmCommandArgumentParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -510,16 +489,6 @@ Modify cmCommandArgumentLexer.h: /* Include the set of tokens from the parser. */ #include "cmCommandArgumentParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /*--------------------------------------------------------------------------*/ diff --git a/Source/cmCommandArgumentLexer.in.l b/Source/cmCommandArgumentLexer.in.l index 7aa90e64c..a4357b083 100644 --- a/Source/cmCommandArgumentLexer.in.l +++ b/Source/cmCommandArgumentLexer.in.l @@ -26,7 +26,7 @@ Run flex like this: Modify cmCommandArgumentLexer.cxx: - remove TABs - remove "yyscanner" argument from these methods: - yy_fatal_error, yyalloc, yyrealloc, yyfree + yy_fatal_error, cmCommandArgument_yyalloc, cmCommandArgument_yyrealloc, cmCommandArgument_yyfree - remove all YY_BREAK lines occurring right after return statements - change while ( 1 ) to for(;;) @@ -38,31 +38,10 @@ Modify cmCommandArgumentLexer.h: */ +#include "cmStandardLexer.h" + #include "cmCommandArgumentParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -71,16 +50,6 @@ Modify cmCommandArgumentLexer.h: /* Include the set of tokens from the parser. */ #include "cmCommandArgumentParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /*--------------------------------------------------------------------------*/ %} diff --git a/Source/cmDependsFortranLexer.cxx b/Source/cmDependsFortranLexer.cxx index b8feb1731..318443e51 100644 --- a/Source/cmDependsFortranLexer.cxx +++ b/Source/cmDependsFortranLexer.cxx @@ -640,45 +640,16 @@ Modify cmDependsFortranLexer.h: */ +#include "cmStandardLexer.h" + #define cmDependsFortranLexer_cxx #include "cmDependsFortranParser.h" /* Interface to parser object. */ -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ { result = cmDependsFortranParser_Input(yyextra, buf, max_size); } -/* Provide isatty on Windows. */ -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /* Include the set of tokens from the parser. */ #include "cmDependsFortranParserTokens.h" diff --git a/Source/cmDependsFortranLexer.in.l b/Source/cmDependsFortranLexer.in.l index f95ccdb76..8326eaeaa 100644 --- a/Source/cmDependsFortranLexer.in.l +++ b/Source/cmDependsFortranLexer.in.l @@ -36,7 +36,7 @@ Run flex like this: Modify cmDependsFortranLexer.cxx: - remove TABs - remove "yyscanner" argument from these methods: - yy_fatal_error, yyalloc, yyrealloc, yyfree + yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree - remove all YY_BREAK lines occurring right after return statements - change while ( 1 ) to for(;;) @@ -48,45 +48,16 @@ Modify cmDependsFortranLexer.h: */ +#include "cmStandardLexer.h" + #define cmDependsFortranLexer_cxx #include "cmDependsFortranParser.h" /* Interface to parser object. */ -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ { result = cmDependsFortranParser_Input(yyextra, buf, max_size); } -/* Provide isatty on Windows. */ -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /* Include the set of tokens from the parser. */ #include "cmDependsFortranParserTokens.h" diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index aa7b57183..361caa4c7 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -671,34 +671,14 @@ Modify cmDependsJavaLexer.h: - remove TABs - remove the yy_init_globals function - remove the block that includes unistd.h + - remove #line directives (avoids bogus warning on old Sun) */ +#include "cmStandardLexer.h" + #include "cmDependsJavaParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -707,16 +687,6 @@ Modify cmDependsJavaLexer.h: /* Include the set of tokens from the parser. */ #include "cmDependsJavaParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - #define KEYWORD yylvalp->str = 0 #define SYMBOL yylvalp->str = 0 #define PRIMITIVE yylvalp->str = 0 diff --git a/Source/cmDependsJavaLexer.in.l b/Source/cmDependsJavaLexer.in.l index 3ca61a399..f26aede29 100644 --- a/Source/cmDependsJavaLexer.in.l +++ b/Source/cmDependsJavaLexer.in.l @@ -23,10 +23,10 @@ Run flex like this: flex --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l -Modify cmDependsJavaLexer.cxx: +Modify cmDependsJavaLexer.c: - remove TABs - remove "yyscanner" argument from these methods: - yy_fatal_error, yyalloc, yyrealloc, yyfree + yy_fatal_error, cmDependsJava_yyalloc, cmDependsJava_yyrealloc, cmDependsJava_yyfree - remove all YY_BREAK lines occurring right after return statements - change while ( 1 ) to for(;;) @@ -38,31 +38,10 @@ Modify cmDependsJavaLexer.h: */ +#include "cmStandardLexer.h" + #include "cmDependsJavaParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -71,16 +50,6 @@ Modify cmDependsJavaLexer.h: /* Include the set of tokens from the parser. */ #include "cmDependsJavaParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - #define KEYWORD yylvalp->str = 0 #define SYMBOL yylvalp->str = 0 #define PRIMITIVE yylvalp->str = 0 diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index 045cf1186..5367be45b 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -458,8 +458,7 @@ This file must be translated to C and modified to build everywhere. Run flex like this: - flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx - cmExprLexer.in.l + flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l Modify cmExprLexer.cxx: - remove TABs @@ -476,31 +475,10 @@ Modify cmExprLexer.h: */ +#include "cmStandardLexer.h" + #include "cmExprParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -509,16 +487,6 @@ Modify cmExprLexer.h: /* Include the set of tokens from the parser. */ #include "cmExprParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /*--------------------------------------------------------------------------*/ #line 518 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" diff --git a/Source/cmExprLexer.in.l b/Source/cmExprLexer.in.l index bc2ec1c4f..fccc4f606 100644 --- a/Source/cmExprLexer.in.l +++ b/Source/cmExprLexer.in.l @@ -26,7 +26,7 @@ Run flex like this: Modify cmExprLexer.cxx: - remove TABs - remove "yyscanner" argument from these methods: - yy_fatal_error, yyalloc, yyrealloc, yyfree + yy_fatal_error, cmExpr_yyalloc, cmExpr_yyrealloc, cmExpr_yyfree - remove all YY_BREAK lines occurring right after return statements - change while ( 1 ) to for(;;) @@ -38,31 +38,10 @@ Modify cmExprLexer.h: */ +#include "cmStandardLexer.h" + #include "cmExprParserHelper.h" -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 -#undef ECHO /* SGI termios defines this differently. */ -#define ECHO - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, max_size) \ @@ -71,16 +50,6 @@ Modify cmExprLexer.h: /* Include the set of tokens from the parser. */ #include "cmExprParserTokens.h" - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -/* Handle Windows properly */ -# include -# if defined( _MSC_VER ) -# define isatty _isatty -# endif -# define YY_NO_UNISTD_H 1 -#endif - /*--------------------------------------------------------------------------*/ %} diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index 8f5def65f..d0159a53f 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -506,35 +506,17 @@ Modify cmListFileLexer.c: */ +#include "cmStandardLexer.h" + /* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 #define YY_NO_INPUT 1 #define YY_NO_UNPUT 1 #define YY_NO_UNISTD_H 1 -#define ECHO /* Setup the proper cmListFileLexer_yylex declaration. */ #define YY_EXTRA_TYPE cmListFileLexer* #define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer) -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - #include "cmListFileLexer.h" /*--------------------------------------------------------------------------*/ diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index 00b38be2f..e98fb3e71 100644 --- a/Source/cmListFileLexer.in.l +++ b/Source/cmListFileLexer.in.l @@ -27,40 +27,22 @@ Modify cmListFileLexer.c: - remove TABs - remove the yyunput function - add a statement "(void)yyscanner;" to the top of these methods: - yy_fatal_error, yyalloc, yyrealloc, yyfree + yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree - remove all YY_BREAK lines occurring right after return statements */ +#include "cmStandardLexer.h" + /* Disable features we do not need. */ -#define YY_NEVER_INTERACTIVE 1 #define YY_NO_INPUT 1 #define YY_NO_UNPUT 1 #define YY_NO_UNISTD_H 1 -#define ECHO -/* Setup the proper yylex declaration. */ +/* Setup the proper cmListFileLexer_yylex declaration. */ #define YY_EXTRA_TYPE cmListFileLexer* #define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer) -/* Disable some warnings. */ -#if defined(_MSC_VER) -# pragma warning ( disable : 4127 ) -# pragma warning ( disable : 4131 ) -# pragma warning ( disable : 4244 ) -# pragma warning ( disable : 4251 ) -# pragma warning ( disable : 4267 ) -# pragma warning ( disable : 4305 ) -# pragma warning ( disable : 4309 ) -# pragma warning ( disable : 4706 ) -# pragma warning ( disable : 4786 ) -#endif - -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - #include "cmListFileLexer.h" /*--------------------------------------------------------------------------*/ diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h new file mode 100644 index 000000000..7ee448eb5 --- /dev/null +++ b/Source/cmStandardLexer.h @@ -0,0 +1,67 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmStandardLexer_h +#define cmStandardLexer_h + +/* Disable some warnings. */ +#if defined(_MSC_VER) +# pragma warning ( disable : 4127 ) +# pragma warning ( disable : 4131 ) +# pragma warning ( disable : 4244 ) +# pragma warning ( disable : 4251 ) +# pragma warning ( disable : 4267 ) +# pragma warning ( disable : 4305 ) +# pragma warning ( disable : 4309 ) +# pragma warning ( disable : 4706 ) +# pragma warning ( disable : 4786 ) +#endif + +#if defined(__BORLANDC__) +# pragma warn -8008 /* condition always returns true */ +# pragma warn -8066 /* unreachable code */ +/* Borland system header defines these macros without first undef-ing them. */ +# if __BORLANDC__ >= 0x580 +# undef INT8_MIN +# undef INT16_MIN +# undef INT32_MIN +# undef INT8_MAX +# undef INT16_MAX +# undef INT32_MAX +# undef UINT8_MAX +# undef UINT16_MAX +# undef UINT32_MAX +# include +# endif +#endif + +/* Define isatty on windows. */ +#if defined(_WIN32) && !defined(__CYGWIN__) +# include +# if defined( _MSC_VER ) +# define isatty _isatty +# endif +# define YY_NO_UNISTD_H 1 +#endif + +/* Disable features we do not need. */ +#define YY_NEVER_INTERACTIVE 1 + +/* Avoid display of input matches to standard output. */ +#undef ECHO /* SGI termios defines this differently. */ +#define ECHO + +#endif