[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



On Wed, Jul 27, 2016 at 02:45:44PM +0200, Pino Toscano wrote:
> 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

This sounds like a regression in flex, but ACK.

Rich.

>  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
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs redhat com
> https://www.redhat.com/mailman/listinfo/libguestfs

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]