Explorar o código

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.

Brad King %!s(int64=19) %!d(string=hai) anos
pai
achega
a3836e09a2

+ 2 - 33
Source/cmCommandArgumentLexer.cxx

@@ -477,30 +477,9 @@ Modify cmCommandArgumentLexer.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
+#include "cmStandardLexer.h"
 
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmCommandArgumentParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  if defined( _MSC_VER )
-#    define isatty _isatty
-#  endif
-#  define YY_NO_UNISTD_H 1
-#endif
-
 /*--------------------------------------------------------------------------*/
 
 

+ 3 - 34
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,30 +38,9 @@ Modify cmCommandArgumentLexer.h:
 
 */
 
-#include "cmCommandArgumentParserHelper.h"
+#include "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 */
-#endif
-
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmCommandArgumentParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  if defined( _MSC_VER )
-#    define isatty _isatty
-#  endif
-#  define YY_NO_UNISTD_H 1
-#endif
-
 /*--------------------------------------------------------------------------*/
 %}
 

+ 2 - 31
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 <io.h>
-# 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"
 

+ 3 - 32
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 <io.h>
-# 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"
 

+ 3 - 33
Source/cmDependsJavaLexer.cxx

@@ -671,33 +671,13 @@ 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 "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
+#include "cmStandardLexer.h"
 
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmDependsJavaParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  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

+ 4 - 35
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,30 +38,9 @@ Modify cmDependsJavaLexer.h:
 
 */
 
-#include "cmDependsJavaParserHelper.h"
+#include "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 */
-#endif
-
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmDependsJavaParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  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

+ 3 - 35
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,30 +475,9 @@ Modify cmExprLexer.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
+#include "cmStandardLexer.h"
 
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmExprParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  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"
 

+ 3 - 34
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,30 +38,9 @@ Modify cmExprLexer.h:
 
 */
 
-#include "cmExprParserHelper.h"
+#include "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 */
-#endif
-
-/* Disable features we do not need. */
-#define YY_NEVER_INTERACTIVE 1
-#undef ECHO /* SGI termios defines this differently. */
-#define ECHO
+#include "cmExprParserHelper.h"
 
 /* Replace the lexer input function.  */
 #undef YY_INPUT
@@ -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 <io.h>
-#  if defined( _MSC_VER )
-#    define isatty _isatty
-#  endif
-#  define YY_NO_UNISTD_H 1
-#endif
-
 /*--------------------------------------------------------------------------*/
 %}
 

+ 2 - 20
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"
 
 /*--------------------------------------------------------------------------*/

+ 4 - 22
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"
 
 /*--------------------------------------------------------------------------*/

+ 67 - 0
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 <stdint.h>
+# endif
+#endif
+
+/* Define isatty on windows.  */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <io.h>
+# 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