]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix logic error in _AC_PROG_LEX_YYTEXT_DECL (#109320)
authorTom <tom@ojodeagua.com>
Sun, 12 Jul 2020 14:44:11 +0000 (10:44 -0400)
committerZack Weinberg <zackw@panix.com>
Sun, 12 Jul 2020 14:52:26 +0000 (10:52 -0400)
The search for the appropriate value for @LEXLIB@ did not distinguish
correctly between success (‘break’ out of a shell for loop, having set
$ac_cv_lib_lex) and failure (normal termination of the loop, value in
$ac_cv_lib_lex is garbage).  Bug report and original patch by
Tom <tom@ojodeagua.com> with refinements by Zack Weinberg.

* lib/autoconf/programs.m4 (_AC_PROG_LEX_YYTEXT_DECL):
  Error out if we cannot find the library that (f)lex scanners
  need to be linked against, instead of continuing with @LEXLIB@
  set to the empty string.

lib/autoconf/programs.m4

index 006c0b666ae1784a3607aa2a40539617d0248bdd..9deb62e8a1b3612c998facf6195f25a2c059e964 100644 (file)
@@ -741,7 +741,7 @@ main (void)
 }
 ]_ACEOF
 _AC_DO_VAR(LEX conftest.l)
-AC_CACHE_CHECK([lex output file root], [ac_cv_prog_lex_root], [
+AC_CACHE_CHECK([for lex output file root], [ac_cv_prog_lex_root], [
 if test -f lex.yy.c; then
   ac_cv_prog_lex_root=lex.yy
 elif test -f lexyy.c; then
@@ -751,20 +751,25 @@ else
 fi])
 AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
 
-if ${LEXLIB+false} :; then
-  AC_CACHE_CHECK([lex library], [ac_cv_lib_lex], [
+AS_VAR_SET_IF([LEXLIB], [], [
+  AC_CACHE_CHECK([for lex library], [ac_cv_lib_lex], [
+    ac_cv_lib_lex='not found'
     ac_save_LIBS=$LIBS
-    ac_cv_lib_lex='none needed'
     for ac_lib in '' -lfl -ll; do
       LIBS="$ac_lib $ac_save_LIBS"
       AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED[`cat $LEX_OUTPUT_ROOT.c`]],
-       [ac_cv_lib_lex=$ac_lib])
-      test "$ac_cv_lib_lex" != 'none needed' && break
+       [ac_cv_lib_lex="${ac_lib:-none needed}"
+         break])
     done
     LIBS=$ac_save_LIBS
   ])
-  test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
-fi
+  AS_IF(
+     [test "$ac_cv_lib_lex" = 'not found'],
+       [AC_MSG_ERROR([required lex library not found])],
+     [test "$ac_cv_lib_lex" = 'none needed'],
+        [LEXLIB=''],
+       [LEXLIB=$ac_cv_lib_lex])
+])
 AC_SUBST(LEXLIB)
 
 AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,