[Libguestfs] [PATCH] builder: fix EOF check with flex >= 2.6.1

Pino Toscano ptoscano at redhat.com
Wed Jul 27 12:45:44 UTC 2016


It looks like flex 2.6.1 changed [1] the return code for EOF in
yyinput.  Therefore, use the right value depending on the version of
flex which generates the lexer.

[1] https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff
---
 builder/index-scan.l | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/builder/index-scan.l b/builder/index-scan.l
index d4db826..bdb474b 100644
--- a/builder/index-scan.l
+++ b/builder/index-scan.l
@@ -45,6 +45,14 @@
 extern void scanner_init (yyscan_t *scanner, struct parse_context *context, FILE *in);
 extern void scanner_destroy (yyscan_t scanner);
 
+#if (YY_FLEX_MAJOR_VERSION > 2) \
+  || ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION > 6)) \
+  || ((YY_FLEX_MAJOR_VERSION == 2) && (YY_FLEX_MINOR_VERSION == 6) && (YY_FLEX_SUBMINOR_VERSION >= 1))
+#define IS_EOF 0
+#else
+#define IS_EOF EOF
+#endif
+
 %}
 
 %option nounput
@@ -104,7 +112,7 @@ extern void scanner_destroy (yyscan_t scanner);
   int c, prevnl = 0;
 
   /* Eat everything to the first blank line. */
-  while ((c = input (yyscanner)) != EOF) {
+  while ((c = input (yyscanner)) != IS_EOF) {
     if (c == '\n' && prevnl)
       break;
     prevnl = c == '\n';
@@ -116,7 +124,7 @@ extern void scanner_destroy (yyscan_t scanner);
  /* Hack to eat the PGP epilogue. */
 ^"-----BEGIN PGP SIGNATURE-----\n"  {
   /* Eat everything to the end of the file. */
-  while (input (yyscanner) != EOF)
+  while (input (yyscanner) != IS_EOF)
     ;
 
   return PGP_EPILOGUE;
-- 
2.7.4




More information about the Libguestfs mailing list