When using flex -P<prefix> instead of ylwrap all the yy symbols get #defined
authorChristos Zoulas <christos@zoulas.com>
Fri, 19 Sep 2008 21:32:38 +0000 (21:32 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 19 Sep 2008 21:32:38 +0000 (21:32 +0000)
to the prefixed ones in the begining of the c file. This breaks the #ifndef
yywrap test. We detect this by checking also yylex and if that is defined
too we declare and define yywrap.

amd/conf_tok.l
amd/sun_map_tok.l
fsinfo/fsi_lex.l

index dab571f8c20641c6143d2edf58478146f10854c5..6cf04de45bcd24817af237088aee3c9763713b9f 100644 (file)
@@ -86,9 +86,9 @@ int yylex(void);
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void);
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */
 
 #define TOK_DEBUG 0
 
@@ -184,9 +184,9 @@ NONQUOTE    [^\"]
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void)
 {
   return 1;
 }
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */
index 173f6bdaf4dccf2473c7addc27a2219c1c9ad074..6c56c97700641c91b71638c78cd36e91d9bf50f3 100644 (file)
@@ -75,6 +75,9 @@
 # endif /* not ECHO */
 #endif /* FLEX_SCANNER */
 
+int yylex(void);
+int yyerror(const char *);
+
 /*
  * We need to configure lex to parse from a string
  * instead of a file. Each version of lex has it's
@@ -124,9 +127,9 @@ int sun_map_input(char *buff, int maxsize);
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void);
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */
 
 /* no need to use yywrap() */
 #define YY_SKIP_YYWRAP
@@ -226,9 +229,9 @@ sun_map_tok_setbuff(const char* buff)
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void)
 {
   return 1;
 }
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */
index 044a102a2b8fca40aa30073d95010b3bc63d01c2..cc5d948dad4c396f8bbcb38bffcbd07cc330570b 100644 (file)
@@ -111,9 +111,9 @@ static int ayylineno;
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void);
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */
 
 int yyerror(const char *, ...);
 
@@ -268,9 +268,9 @@ current_location(void)
  * which automatically generates yywrap macros and symbols.  So I must
  * distinguish between them and when yywrap is actually needed.
  */
-#ifndef yywrap
+#if !defined(yywrap) || defined(yylex)
 int yywrap(void)
 {
   return 1;
 }
-#endif /* not yywrap */
+#endif /* not yywrap or yylex */