On 02/12/2012 03:59 PM, Stefano Lattarini wrote:
> I have cloned 'master' into a temporary branch 'yl-work-for-master',
> merged master in there, and pushed.
>
> I will merge the 'yl-work-for-master' branch back into master in 72
> hours or so if there is no objection by then.
> 
Also, to avoid some new spurious failures, I've applied the attached
follow-up patch.

Regards,
  Stefano


>From 0b34421dc2d78a163ce9eaca41348dd672c302ed Mon Sep 17 00:00:00 2001
Message-Id: <0b34421dc2d78a163ce9eaca41348dd672c302ed.1329061070.git.stefano.lattar...@gmail.com>
From: Stefano Lattarini <stefano.lattar...@gmail.com>
Date: Sun, 12 Feb 2012 16:37:44 +0100
Subject: [PATCH] tests: fix spurious failures due to missing 'yywrap()'
 function

The AC_PROG_LEX Autoconf macro does not diagnose a failure to find
the "lex library" expected to provide a 'yywrap' function (function
which is required to link most lex-generated programs).  On the
contrary, when all the link attempts (i.e., with '-ll' and '-lfl')
fail, configure declares that no lex library is needed, and simply
proceeds with the configuration process -- only for the build to
possibly fail later, at make time.

This behaviour is intended; the Autoconf manual reads:

  You are encouraged to use Flex in your sources, since it is
  both more pleasant to use than plain Lex and the C source it
  produces is portable.  In order to ensure portability, however,
  you must either provide a function 'yywrap' or, if you don't use
  it (e.g., your scanner has no '#include'-like feature), simply
  include a '%noyywrap' statement in the scanner's source.

This AC_PROG_LEX behaviour is causing some spurious failures of
the Automake testsuite in environments which lack a proper library
providing 'yywrap' (this happens for example on Fedora-based
systems).   The proper workaround is to simply provide a fall-back
implementation of 'yywrap' in our lexers.

See also similar commits 'v1.11-546-gca0ba5d' (24-10-2011),
'v1.11-1085-gb5c3968' (24-10-2011) and 'v1.11-871-geb147a1'
(25-05-2011).

* tests/lex-clean.test: Provide a dummy 'yywrap' function.
* tests/lex-line.test: Likewise.
* tests/lex-nodist.test: Likewise.
* tests/lex-depend.test: Likewise.
* tests/lex-clean-cxx.test: Move the dummy 'yywrap' function
from the main '.cc' file into the '.lxx' file, so that it won't
be subject to the namespace declaration in the '.cc' file (which
was causing a spurious link error in systems without a default
"lex library").
---
 tests/lex-clean-cxx.test |    9 +++++----
 tests/lex-clean.test     |    6 ++++++
 tests/lex-depend.test    |    5 +++++
 tests/lex-line.test      |    6 ++++++
 tests/lex-nodist.test    |    6 ++++++
 5 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/tests/lex-clean-cxx.test b/tests/lex-clean-cxx.test
index ba7e367..6ca8071 100755
--- a/tests/lex-clean-cxx.test
+++ b/tests/lex-clean-cxx.test
@@ -58,16 +58,17 @@ cat > parsefoo.lxx << 'END'
 %%
 "GOOD"   return EOF;
 .
+%%
+int yywrap (void)
+{
+  return 1;
+}
 END
 cp parsefoo.lxx parsebar.ll
 
 cat > mainfoo.cc << 'END'
 // This file should contain valid C++ but invalid C.
 using namespace std;
-int yywrap (void)
-{
-  return 1;
-}
 int main (int argc, char **argv)
 {
   extern int yylex (void);
diff --git a/tests/lex-clean.test b/tests/lex-clean.test
index 5bcb5c1..6f03887 100755
--- a/tests/lex-clean.test
+++ b/tests/lex-clean.test
@@ -64,6 +64,12 @@ int main (void)
 {
   return yylex ();
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 $ACLOCAL
diff --git a/tests/lex-depend.test b/tests/lex-depend.test
index 13d5554..2ef27da 100755
--- a/tests/lex-depend.test
+++ b/tests/lex-depend.test
@@ -55,6 +55,11 @@ int main (void)
   printf("%s\n", MESSAGE);
   return 0;
 }
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 cat > my-hdr.h <<'END'
diff --git a/tests/lex-line.test b/tests/lex-line.test
index 27958c8..a7e1640 100755
--- a/tests/lex-line.test
+++ b/tests/lex-line.test
@@ -70,6 +70,12 @@ int main ()
     ;
   return 0;
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 cp zardoz.l dir/quux.l
diff --git a/tests/lex-nodist.test b/tests/lex-nodist.test
index 5948400..092e089 100755
--- a/tests/lex-nodist.test
+++ b/tests/lex-nodist.test
@@ -65,6 +65,12 @@ int main ()
 {
   return yylex ();
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 $ACLOCAL
-- 
1.7.7.3

Reply via email to