From 830c5a1ffb0ee5f064b0ba0b07cb111aa7f85141 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 16 Apr 2020 10:12:30 +0200 Subject: intl: Allow building both with old bison and bison >= 3 [PR92008] bison 3 apparently made a backwards incompatible change, dropped YYLEX_PARAM/YYPARSE_PARAM support and instead needs %param or %lex-param and %parse-param. Furthermore, there is no easy way to conditionalize on bison version in the *.y files. While e.g. glibc bumped bison requirement and just has the bison 3 compatible version, Richi said there are still systems with older bison where we want to build gcc. So, this patch instead determines during configure bison version, and depending on that when building plural.c (if building it at all) tweaks what is passed over to bison if needed. Tested with both bison 3 and bison 1.35, in each case with reconfiguring intl and building with make all-yes (as in my setup intl isn't normally used). intl/ChangeLog 2020-04-16 Jakub Jelinek PR bootstrap/92008 * configure.ac: Add check for bison >= 3, AC_DEFINE HAVE_BISON3 and AC_SUBST BISON3_YES and BISON3_NO. * Makefile.in (.y.c): Prefix $(YACC) invocation with @BISON3_NO@, add @BISON3_YES@ prefixed rule to adjust the *.y source using sed and adjust output afterwards. * plural-exp.h (PLURAL_PARSE): If HAVE_BISON3 is defined, use struct parse_args * type for arg instead of void *. * plural.y: Add magic /* BISON3 ... */ comments with bison >= 3 directives. (YYLEX_PARAM, YYPARSE_PARAM): Don't define if HAVE_BISON3 is defined. (yylex, yyerror): Adjust prototypes and definitions if HAVE_BISON3 is defined. * plural.c: Regenerated. * config.h.in: Regenerated. * configure: Regenerated. --- intl/plural.y | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'intl/plural.y') diff --git a/intl/plural.y b/intl/plural.y index 3f75cf3..c97f09a 100644 --- a/intl/plural.y +++ b/intl/plural.y @@ -1,6 +1,6 @@ %{ /* Expression parsing for plural form selection. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000-2020 Free Software Foundation, Inc. Written by Ulrich Drepper , 2000. This program is free software; you can redistribute it and/or modify it @@ -40,10 +40,15 @@ # define __gettextparse PLURAL_PARSE #endif +#ifndef HAVE_BISON3 #define YYLEX_PARAM &((struct parse_args *) arg)->cp #define YYPARSE_PARAM arg +#endif %} %pure_parser +/* BISON3 %parse-param {struct parse_args *arg} */ +/* BISON3 %lex-param {struct parse_args *arg} */ +/* BISON3 %define api.pure full */ %expect 7 %union { @@ -66,8 +71,13 @@ static inline struct expression *new_exp_3 PARAMS ((enum operator op, struct expression *bexp, struct expression *tbranch, struct expression *fbranch)); +#ifdef HAVE_BISON3 +static int yylex PARAMS ((YYSTYPE *lval, struct parse_args *arg)); +static void yyerror PARAMS ((struct parse_args *arg, const char *str)); +#else static int yylex PARAMS ((YYSTYPE *lval, const char **pexp)); static void yyerror PARAMS ((const char *str)); +#endif /* Allocation of expressions. */ @@ -256,11 +266,20 @@ FREE_EXPRESSION (exp) } +#ifdef HAVE_BISON3 +static int +yylex (lval, arg) + YYSTYPE *lval; + struct parse_args *arg; +{ + const char **pexp = &arg->cp; +#else static int yylex (lval, pexp) YYSTYPE *lval; const char **pexp; { +#endif const char *exp = *pexp; int result; @@ -401,8 +420,14 @@ yylex (lval, pexp) } +#ifdef HAVE_BISON3 +static void +yyerror (arg, str) + struct parse_args *arg; +#else static void yyerror (str) +#endif const char *str; { /* Do nothing. We don't print error messages here. */ -- cgit v1.1