2
0
mirror of git://git.sv.gnu.org/autoconf synced 2025-04-18 15:30:24 +08:00
autoconf/tests
Zack Weinberg dade4a8a31 Overhaul AC_PROG_LEX for precision and maintainability
AC_PROG_LEX has three different operating modes (“yywrap”, “noyywrap”,
and 2.69 compatibility mode) which were all tangled together and hard
to understand.  In addition, the way we were handling yywrap, in all
three modes, was imprecise to the point where I am unsure we were
actually testing the property people want to test.

Refactor AC_PROG_LEX into a set of smaller macros:

- AC_PROG_LEX and _AC_PROG_LEX_1 perform argument validation and
  normalization.  _AC_PROG_LEX_1 also ensures that repeated invocation
  of AC_PROG_LEX is harmless.

- _AC_PROG_LEX_2 is invoked with exactly one argument which is the
  name of one of the three _AC_PROG_LEX_LIBL_* macros (described below).
  It invokes, in sequence, AC_CHECK_PROGS([LEX]), _AC_PROG_LEX_OUTPUT_ROOT,
  the _AC_PROG_LEX_LIBL_ macro it was given as an argument, and
  finally _AC_PROG_LEX_YYTEXT_DECL.  If any of these sets LEX to ‘:’,
  further tests are skipped.  _AC_PROG_LEX_2 is also responsible for
  cleaning up conftest.l and lex.yy.c afterward.

- _AC_PROG_LEX_YYTEXT_DECL now *only* tests whether yytext is a
  pointer.  It reuses the conftest.l from previous tests.

- _AC_PROG_LEX_OUTPUT_ROOT just does the test for the name of the
  file produced by running ‘lex conftest.l’ with no further arguments.

- _AC_PROG_LEX_LIBL_YYWRAP, _AC_PROG_LEX_LIBL_NOYYWRAP, and
  _AC_PROG_LEX_LIBL_COMPAT determine whether a generated lexer needs
  to be linked with -ll or -lfl.  Each is dedicated to one of the
  three operating modes, and uses a conftest.l specialized for that mode.
  In compat mode we do *not* look for ‘yywrap’ using AC_SEARCH_LIBS;
  instead we actually try to link a generated lexer that uses yywrap.

- _AC_PROG_LEX_SEARCH_LIBL, _AC_PROG_LEX_TEST_COMMON,
  _AC_PROG_LEX_TEST_YYWRAP, and _AC_PROG_LEX_TEST_NOYYWRAP are
  subroutines of the _AC_PROG_LEX_LIBL_* macros.

TODO:

- Shrink and sharpen the test program used by _AC_PROG_LEX_YYTEXT_DECL and
  make it independent of previous operations.  Possibly smush it
  back together with _AC_PROG_LEX_OUTPUT_ROOT.
- Re-audit the “noyywrap” program, it might be better to declare
  “_static_ int yywrap(void)” in the %{ %} block instead of not
  declaring it at all.
- Re-audit the “yywrap” program, it might be better to rely on the
  skeleton to declare yywrap.

* lib/autoconf/programs.m4 (AC_PROG_LEX): Extensive refactor.
  Test for yywrap is now done by linking a generated lexer, not with
  AC_SEARCH_LIBS.
  (_AC_PROG_LEX_YYTEXT_DECL): Just test whether yytext is a pointer.
  (_AC_PROG_LEX): Removed.
  (_AC_PROG_LEX_1, _AC_PROG_LEX_2): New macros dividing up the labor
  formerly performed by _AC_PROG_LEX and the order of operations in
  the old _AC_PROG_LEX_YYTEXT_DECL.
  (_AC_PROG_LEX_OUTPUT_ROOT, _AC_PROG_LEX_SEARCH_LIBL)
  (_AC_PROG_LEX_LIBL_YYWRAP, _AC_PROG_LEX_LIBL_NOYYWRAP)
  (_AC_PROG_LEX_LIBL_COMPAT, _AC_PROG_LEX_TEST_COMMON)
  (_AC_PROG_LEX_TEST_YYWRAP, _AC_PROG_LEX_TEST_NOYYWRAP):
  New macros dividing up the rest of the labor formerly performed by
  _AC_PROG_LEX_YYTEXT_DECL.

* tests/semantics.at
  (AC_PROG_LEX with noyywrap): Rename “AC_PROG_LEX: noyywrap”.
  (AC_PROG_LEX with yywrap): Rename “AC_PROG_LEX: yywrap”.  No longer
  necessary to skip this test on OSes where there is no -ll nor -lfl.
  (AC_PROG_LEX in legacy mode): Rename “AC_PROG_LEX: compat mode.”
  Convert to AT_CHECK_MACRO test using -Wno-obsolete.
  (Invalid arguments to AC_PROG_LEX): Rename “AC_PROG_LEX: invalid
  arguments and warnings.”  Move the test for the warning
  “AC_PROG_LEX without either yywrap or noyywrap is obsolete” here.
  Adjust expected stack traces.
2023-12-03 12:09:37 -05:00
..
2023-01-21 00:58:47 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-21 00:58:47 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00
2023-01-21 00:58:47 -06:00
2023-01-20 23:41:13 -06:00
2023-01-20 23:41:13 -06:00