]> Savannah Git Hosting - gnulib.git/commitdiff
bison: rely on bison's %require to check a version requirement
authorAkim Demaille <akim.demaille@gmail.com>
Sun, 3 May 2020 06:54:58 +0000 (08:54 +0200)
committerAkim Demaille <akim.demaille@gmail.com>
Sun, 3 May 2020 09:39:36 +0000 (11:39 +0200)
See https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00021.html.

* m4/bison.m4 (gl_PROG_BISON): Let bison itself decide if it it recent
enough of not.
So far it is the only know Yacc tool that supports '%require'.
Other yaccs will actually even choke on seeing the -o option after the
input file name.
* m4/parse-datetime.m4: Simplify gl_PROG_BISON invocation.

ChangeLog
m4/bison.m4
m4/parse-datetime.m4

index 0bf6ca0dd8ffa91e73bd32cf88b7802c3c52581c..1ac3d104f2c38ff652f8c5d54f219beba4a3e070 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2020-05-03  Akim Demaille  <akim@lrde.epita.fr>
+
+       bison: rely on bison's %require to check a version requirement
+       See https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00021.html.
+       * m4/bison.m4 (gl_PROG_BISON): Let bison itself decide if it it recent
+       enough of not.
+       So far it is the only know Yacc tool that supports '%require'.
+       Other yaccs will actually even choke on seeing the -o option after the
+       input file name.
+       * m4/parse-datetime.m4: Simplify gl_PROG_BISON invocation.
+
+
 2020-05-02  Bruno Haible  <bruno@clisp.org>
 
        list: Add get_first, get_last, set_first, set_last operations.
index 5802a5ca51c86479c6d351300861ea437f3e240b..76b62baf809cc75ca7c50114331c27d91070879c 100644 (file)
@@ -1,4 +1,4 @@
-# serial 8
+# serial 9
 
 # Copyright (C) 2002-2006, 2008-2020 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -25,9 +25,9 @@
 #     - %define api.pure   requires bison 2.7 or newer,
 #     - %precedence        requires bison 3.0 or newer.
 #   For these, in the configure.ac you will need an invocation of
-#     gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION], [BISON_VERSIONS_TO_EXCLUDE])
+#     gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION])
 #   Example:
-#     gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*])
+#     gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4])
 #   With this preparation, in the Makefile.am there are two ways to formulate
 #   the invocation. Both are direct, without use of 'ylwrap'.
 #   (a) You can invoke
@@ -47,18 +47,23 @@ AC_DEFUN([gl_PROG_BISON],
   if test -z "$[$1]"; then
     ac_verc_fail=yes
   else
-    dnl Found it, now check the version.
-    AC_MSG_CHECKING([version of bison])
-changequote(<<,>>)dnl
-    ac_prog_version=`$<<$1>> --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
-    case $ac_prog_version in
-      '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
-      <<$3>>)
-         ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
-      *) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
-    esac
-changequote([,])dnl
+    cat >conftest.y <<_ACEOF
+%require "$2"
+%%
+exp:
+_ACEOF
+    AC_MSG_CHECKING([for bison $2 or newer])
+    ac_prog_version=`$$1 --version 2>&1 | sed -n 's/^.*GNU Bison.* \([[0-9]]*\.[[0-9.]]*\).*$/\1/p'`
+    : ${ac_prog_version:='v. ?.??'}
+    if $$1 conftest.y -o conftest.c 2>/dev/null; then
+      ac_prog_version="$ac_prog_version, ok"
+      ac_verc_fail=false
+    else
+      ac_prog_version="$ac_prog_version, bad"
+      ac_verc_fail=true
+    fi
     AC_MSG_RESULT([$ac_prog_version])
+    rm -f conftest.y conftest.c
   fi
   if test $ac_verc_fail = yes; then
     [$1]=:
index 0849b82036ec3db33547b159ec40268083ba3614..3bb487f9be5b15aed2a31e940cb28fe1b949609d 100644 (file)
@@ -35,7 +35,7 @@ AC_DEFUN([gl_PARSE_DATETIME],
   dnl the files or have a broken "make" program, hence the parse-datetime.c
   dnl rule will sometimes fire. To avoid an error, defines PARSE_DATETIME_BISON
   dnl to ":" if it is not present or too old.
-  gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*])
+  gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4])
 
   dnl Prerequisites of lib/parse-datetime.h.
   AC_REQUIRE([AM_STDBOOL_H])