Re: [PATCH] Revert 'Fix logic error in _AC_PROG_LEX_YYTEXT_DECL (#109320)'

Ross Burton <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Message-ID <CAAnfSTuom9ELaXOdEkXD7AVGYKst6hV_f1zEg_S5Airm3UUuZw@mail.gmail.com>
On Thu, 16 Jul 2020 at 15:10, Zack Weinberg <[email protected]> wrote:
> I presume that gdbm, flex, and gmp provide a definition of yywrap
> themselves, so they don't actually *need* lib{,f}l.a.

gmp calclex.l:
yywrap ()
{
  return 1;
}

flex scan.l:
int yywrap(void)
        {
        if ( --num_input_files > 0 )
                {
                set_input_file( *++input_files );
                return 0;
                }

        else
                return 1;
        }

bc scan.l:
yywrap(void)
{
  if (!open_new_file ()) return (1);    /* EOF on standard in. */
  return (0);                           /* We have more input. */
  yyunput(0,NULL);      /* Make sure the compiler think yyunput is used. */
}

Yes, they provide their own.

> Clearly we need to preserve compatibility with these existing autoconf
> scripts, and I would guess that programs that define yywrap themselves
> are much more common than those that use the fallback, which is not
> that useful (all it does is return 1, causing the scanner to stop).  I
> propose to make the following additional changes, instead of reverting
> the patch:
>
>  - Change the conftest.l used by _AC_PROG_LEX_YYTEXT_DECL so that it
> defines yywrap itself (it already defines main).  Thus, LEXLIB will
> only be set to -ll or -lfl if there's something in there *besides*
> yywrap and main that the generated scanner needs.  Document this.
>
>  - Add a new macro, tentatively AC_FUNC_YYWRAP([action-if-not-found]),
> that tries to find a definition of yywrap in libl and libfl, sets
> LEXLIB accordingly, and failing that executes action-if-not-found,
> which defaults to AC_LIBOBJ([yywrap]).

The first change seems entirely correct. Is the second actually needed?

Ross
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.