diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-06-26 23:46:47 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-06-26 23:57:08 +0300 |
commit | ac037438ef5c581b0dc01829e7ba173d4b2a4d42 (patch) | |
tree | 567767475824d592c71612b198b47118923d68f5 /contrib/tools | |
parent | 10d8655dd385fe03395d60abfbb5903fcc87b2a4 (diff) | |
download | ydb-ac037438ef5c581b0dc01829e7ba173d4b2a4d42.tar.gz |
Update contrib/tools/bison to 3.1
3649391e5dae6eedaa45d736e3febbde1342c10a
Diffstat (limited to 'contrib/tools')
262 files changed, 11103 insertions, 8272 deletions
diff --git a/contrib/tools/bison/AUTHORS b/contrib/tools/bison/AUTHORS index fa4b1715a5..b0ddb15045 100644 --- a/contrib/tools/bison/AUTHORS +++ b/contrib/tools/bison/AUTHORS @@ -24,7 +24,7 @@ and nasty bugs. ----- -Copyright (C) 1998-2013 Free Software Foundation, Inc. +Copyright (C) 1998-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/NEWS b/contrib/tools/bison/NEWS index 991a308bec..6a7cd39dcd 100644 --- a/contrib/tools/bison/NEWS +++ b/contrib/tools/bison/NEWS @@ -1,5 +1,298 @@ GNU Bison NEWS +* Noteworthy changes in release 3.1 (2018-08-27) [stable] + +** Backward incompatible changes + + Compiling Bison now requires a C99 compiler---as announced during the + release of Bison 3.0, five years ago. Generated parsers do not require a + C99 compiler. + + Support for DJGPP, which have been unmaintained and untested for years, is + obsolete. Unless there is activity to revive it, the next release of Bison + will have it removed. + +** New features + +*** Typed midrule actions + + Because their type is unknown to Bison, the values of midrule actions are + not treated like the others: they don't have %printer and %destructor + support. It also prevents C++ (Bison) variants to handle them properly. + + Typed midrule actions address these issues. Instead of: + + exp: { $<ival>$ = 1; } { $<ival>$ = 2; } { $$ = $<ival>1 + $<ival>2; } + + write: + + exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; } { $$ = $1 + $2; } + +*** Reports include the type of the symbols + + The sections about terminal and nonterminal symbols of the '*.output' file + now specify their declared type. For instance, for: + + %token <ival> NUM + + the report now shows '<ival>': + + Terminals, with rules where they appear + + NUM <ival> (258) 5 + +*** Diagnostics about useless rules + + In the following grammar, the 'exp' nonterminal is trivially useless. So, + of course, its rules are useless too. + + %% + input: '0' | exp + exp: exp '+' exp | exp '-' exp | '(' exp ')' + + Previously all the useless rules were reported, including those whose + left-hand side is the 'exp' nonterminal: + + warning: 1 nonterminal useless in grammar [-Wother] + warning: 4 rules useless in grammar [-Wother] + 2.14-16: warning: nonterminal useless in grammar: exp [-Wother] + input: '0' | exp + ^^^ + 2.14-16: warning: rule useless in grammar [-Wother] + input: '0' | exp + ^^^ + 3.6-16: warning: rule useless in grammar [-Wother] + exp: exp '+' exp | exp '-' exp | '(' exp ')' + ^^^^^^^^^^^ + 3.20-30: warning: rule useless in grammar [-Wother] + exp: exp '+' exp | exp '-' exp | '(' exp ')' + ^^^^^^^^^^^ + 3.34-44: warning: rule useless in grammar [-Wother] + exp: exp '+' exp | exp '-' exp | '(' exp ')' + ^^^^^^^^^^^ + + Now, rules whose left-hand side symbol is useless are no longer reported + as useless. The locations of the errors have also been adjusted to point + to the first use of the nonterminal as a left-hand side of a rule: + + warning: 1 nonterminal useless in grammar [-Wother] + warning: 4 rules useless in grammar [-Wother] + 3.1-3: warning: nonterminal useless in grammar: exp [-Wother] + exp: exp '+' exp | exp '-' exp | '(' exp ')' + ^^^ + 2.14-16: warning: rule useless in grammar [-Wother] + input: '0' | exp + ^^^ + +*** C++: Generated parsers can be compiled with -fno-exceptions (lalr1.cc) + + When compiled with exceptions disabled, the generated parsers no longer + uses try/catch clauses. + + Currently only GCC and Clang are supported. + +** Documentation + +*** A demonstration of variants + + A new example was added (installed in .../share/doc/bison/examples), + 'variant.yy', which shows how to use (Bison) variants in C++. + + The other examples were made nicer to read. + +*** Some features are no longer 'experimental' + + The following features, mature enough, are no longer flagged as + experimental in the documentation: push parsers, default %printer and + %destructor (typed: <*> and untyped: <>), %define api.value.type union and + variant, Java parsers, XML output, LR family (lr, ielr, lalr), and + semantic predicates (%?). + +** Bug fixes + +*** GLR: Predicates support broken by #line directives + + Predicates (%?) in GLR such as + + widget: + %? {new_syntax} 'w' id new_args + | %?{!new_syntax} 'w' id old_args + + were issued with #lines in the middle of C code. + +*** Printer and destructor with broken #line directives + + The #line directives were not properly escaped when emitting the code for + %printer/%destructor, which resulted in compiler errors if there are + backslashes or double-quotes in the grammar file name. + +*** Portability on ICC + + The Intel compiler claims compatibility with GCC, yet rejects its _Pragma. + Generated parsers now work around this. + +*** Various + + There were several small fixes in the test suite and in the build system, + many warnings in bison and in the generated parsers were eliminated. The + documentation also received its share of minor improvements. + + Useless code was removed from C++ parsers, and some of the generated + constructors are more 'natural'. + +* Noteworthy changes in release 3.0.5 (2018-05-27) [stable] + +** Bug fixes + +*** C++: Fix support of 'syntax_error' + + One incorrect 'inline' resulted in linking errors about the constructor of + the syntax_error exception. + +*** C++: Fix warnings + + GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference + warnings about yyformat being possibly null. It also warned about the + deprecated implicit definition of copy constructors when there's a + user-defined (copy) assignment operator. + +*** Location of errors + + In C++ parsers, out-of-bounds errors can happen when a rule with an empty + ride-hand side raises a syntax error. The behavior of the default parser + (yacc.c) in such a condition was undefined. + + Now all the parsers match the behavior of glr.c: @$ is used as the + location of the error. This handles gracefully rules with and without + rhs. + +*** Portability fixes in the test suite + + On some platforms, some Java and/or C++ tests were failing. + +* Noteworthy changes in release 3.0.4 (2015-01-23) [stable] + +** Bug fixes + +*** C++ with Variants (lalr1.cc) + + Fix a compiler warning when no %destructor use $$. + +*** Test suites + + Several portability issues in tests were fixed. + +* Noteworthy changes in release 3.0.3 (2015-01-15) [stable] + +** Bug fixes + +*** C++ with Variants (lalr1.cc) + + Problems with %destructor and '%define parse.assert' have been fixed. + +*** Named %union support (yacc.c, glr.c) + + Bison 3.0 introduced a regression on named %union such as + + %union foo { int ival; }; + + The possibility to use a name was introduced "for Yacc compatibility". + It is however not required by POSIX Yacc, and its usefulness is not clear. + +*** %define api.value.type union with %defines (yacc.c, glr.c) + + The C parsers were broken when %defines was used together with "%define + api.value.type union". + +*** Redeclarations are reported in proper order + + On + + %token FOO "foo" + %printer {} "foo" + %printer {} FOO + + bison used to report: + + /tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO + %printer {} "foo" + ^^ + /tmp/foo.yy:3.10-11: previous declaration + %printer {} FOO + ^^ + + Now, the "previous" declaration is always the first one. + + +** Documentation + + Bison now installs various files in its docdir (which defaults to + '/usr/local/share/doc/bison'), including the three fully blown examples + extracted from the documentation: + + - rpcalc + Reverse Polish Calculator, a simple introductory example. + - mfcalc + Multi-function Calc, a calculator with memory and functions and located + error messages. + - calc++ + a calculator in C++ using variant support and token constructors. + +* Noteworthy changes in release 3.0.2 (2013-12-05) [stable] + +** Bug fixes + +*** Generated source files when errors are reported + + When warnings are issued and -Werror is set, bison would still generate + the source files (*.c, *.h...). As a consequence, some runs of "make" + could fail the first time, but not the second (as the files were generated + anyway). + + This is fixed: bison no longer generates this source files, but, of + course, still produces the various reports (*.output, *.xml, etc.). + +*** %empty is used in reports + + Empty right-hand sides are denoted by '%empty' in all the reports (text, + dot, XML and formats derived from it). + +*** YYERROR and variants + + When C++ variant support is enabled, an error triggered via YYERROR, but + not caught via error recovery, resulted in a double deletion. + +* Noteworthy changes in release 3.0.1 (2013-11-12) [stable] + +** Bug fixes + +*** Errors in caret diagnostics + + On some platforms, some errors could result in endless diagnostics. + +*** Fixes of the -Werror option + + Options such as "-Werror -Wno-error=foo" were still turning "foo" + diagnostics into errors instead of warnings. This is fixed. + + Actually, for consistency with GCC, "-Wno-error=foo -Werror" now also + leaves "foo" diagnostics as warnings. Similarly, with "-Werror=foo + -Wno-error", "foo" diagnostics are now errors. + +*** GLR Predicates + + As demonstrated in the documentation, one can now leave spaces between + "%?" and its "{". + +*** Installation + + The yacc.1 man page is no longer installed if --disable-yacc was + specified. + +*** Fixes in the test suite + + Bugs and portability issues. + * Noteworthy changes in release 3.0 (2013-07-25) [stable] ** WARNING: Future backward-incompatibilities! @@ -2625,7 +2918,7 @@ Output file does not redefine const for C++. ----- -Copyright (C) 1995-2013 Free Software Foundation, Inc. +Copyright (C) 1995-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Parser Generator. diff --git a/contrib/tools/bison/README b/contrib/tools/bison/README index ed393c2856..8689bab8ee 100644 --- a/contrib/tools/bison/README +++ b/contrib/tools/bison/README @@ -7,7 +7,7 @@ instructions. Bison requires GNU m4 1.4.6 or later. See: - ftp://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz + https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz ** Internationalization Bison supports two catalogues: one for Bison itself (i.e., for the @@ -37,14 +37,14 @@ test case in each bug report. For any copyright year range specified as YYYY-ZZZZ in this package, note that the range specifies every single year in that closed interval. +----- Local Variables: mode: outline +fill-column: 76 End: ------ - -Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2013 Free Software +Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/README-release b/contrib/tools/bison/README-release deleted file mode 100644 index 4d9423a9d9..0000000000 --- a/contrib/tools/bison/README-release +++ /dev/null @@ -1,100 +0,0 @@ -Here are most of the steps we (maintainers) follow when making a release. - -* Start from a clean, up-to-date git directory on "master": - - make -k maintainer-clean || { ./configure && make maintainer-clean; } - git checkout master - git pull origin master - -* Ensure that the latest stable versions of autoconf, automake, etc. - are in your PATH. See the buildreq list in bootstrap.conf for - the complete list of tools. - -* Ensure that you have no uncommitted diffs. This should produce no - output: - - git diff - -* Ensure that you've pushed all changes that belong in the release: - - git push origin master - -* Check that the NixOS/Hydra autobuilder is reporting all is well: - - http://hydra.nixos.org/jobset/gnu/bison-master - -* Run the following command to download any new translations: - - ./bootstrap && ./configure - -* Pre-release testing: ensure that the following command succeeds: - - make check syntax-check distcheck - -* To (i) set the date, version number, and release TYPE on line 3 of - NEWS, (ii) commit that, and (iii) tag the release, run - - # "TYPE" must be stable, beta or alpha - make release-commit RELEASE='X.Y TYPE' - -* Run the following to create release tarballs. Your choice selects the - corresponding upload-to destination in the emitted gnupload command. - The different destinations are specified in cfg.mk. See the definitions - of gnu_ftp_host-{alpha,beta,stable}. - - make release RELEASE='X.Y TYPE' - -* Test the tarball. Copy it to a few odd-ball systems and ensure that - it builds and passes all tests. - -* While that's happening, write the release announcement that you will - soon post. Start with the template, $HOME/announce-bison-X.Y - that was just created by that "make" command. - -Once all the builds and tests have passed, - -* Run the gnupload command that was suggested by your "make release" - run above, or run - - make upload RELEASE='X.Y TYPE' - -* Wait a few minutes (maybe up to 30?) and then use the release URLs to - download all tarball/signature pairs and use gpg --verify to ensure - that they're all valid. - -* Push the NEWS-updating changes and the new tag: - - v=$(cat .prev-version) - git push origin master tag v$v - -* Announce it on Savannah first, so you can include the savannah.org - announcement link in the email message. - - Go to the news-submission form: - - https://savannah.gnu.org/news/submit.php?group=bison - - If it does not work, then enable "News" for the project via this link: - - https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=bison - - Write something like the following: - - Subject: bison-X.Y released [stable] - +verbatim+ - ...paste the announcement here... - -verbatim- - - Then go here to approve it: - - https://savannah.gnu.org/news/approve.php?group=bison - -* Send the announcement email message. - -* After each non-alpha release, run - - make web-manual-update - - to update the on-line manual accessible at - - http://www.gnu.org/software/bison/manual/ diff --git a/contrib/tools/bison/data/README b/contrib/tools/bison/data/README index 842c004186..798750f7a9 100644 --- a/contrib/tools/bison/data/README +++ b/contrib/tools/bison/data/README @@ -1,5 +1,3 @@ --*- outline -*- - This directory contains data needed by Bison. * Skeletons @@ -52,7 +50,11 @@ into various formats. ----- -Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc. +Local Variables: +mode: outline +End: + +Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc. This file is part of GNU Bison. diff --git a/contrib/tools/bison/data/bison.m4 b/contrib/tools/bison/data/bison.m4 index ca27159c87..80e025c9b4 100644 --- a/contrib/tools/bison/data/bison.m4 +++ b/contrib/tools/bison/data/bison.m4 @@ -2,7 +2,7 @@ # Language-independent M4 Macros for Bison. -# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -437,7 +437,6 @@ m4_define([b4_symbol_action_location], # b4_symbol_action(SYMBOL-NUM, KIND) # ---------------------------------- # Run the action KIND (destructor or printer) for SYMBOL-NUM. -# Same as in C, but using references instead of pointers. m4_define([b4_symbol_action], [b4_symbol_if([$1], [has_$2], [b4_dollar_pushdef([(*yyvaluep)], @@ -445,7 +444,7 @@ m4_define([b4_symbol_action], [m4_dquote(b4_symbol([$1], [type]))]), [(*yylocationp)])dnl b4_symbol_case_([$1])[]dnl -b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"]) +b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) b4_symbol([$1], [$2]) b4_syncline([@oline@], [@ofile@]) break; @@ -1061,3 +1060,6 @@ b4_percent_define_ifdef([api.value.type], [['%s' and '%s' cannot be used together]], [%yacc], [%define api.value.type "union"])])])]) + +# api.value.union.name. +b4_percent_define_check_kind([api.value.union.name], [keyword]) diff --git a/contrib/tools/bison/data/c++-skel.m4 b/contrib/tools/bison/data/c++-skel.m4 index 06597a8bff..3cd56789f3 100644 --- a/contrib/tools/bison/data/c++-skel.m4 +++ b/contrib/tools/bison/data/c++-skel.m4 @@ -2,7 +2,8 @@ # C++ skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c++.m4 b/contrib/tools/bison/data/c++.m4 index be12c0a2fe..396d86132d 100644 --- a/contrib/tools/bison/data/c++.m4 +++ b/contrib/tools/bison/data/c++.m4 @@ -2,7 +2,7 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,6 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# Sanity checks, before defaults installed by c.m4. +b4_percent_define_ifdef([[api.value.union.name]], + [b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]), + [named %union is invalid in C++])]) + m4_include(b4_pkgdatadir/[c.m4]) # b4_comment(TEXT, [PREFIX]) @@ -25,6 +30,16 @@ m4_include(b4_pkgdatadir/[c.m4]) m4_define([b4_comment], [b4_comment_([$1], [$2// ], [$2// ])]) +# b4_inline(hh|cc) +# ---------------- +# Expand to `inline\n ` if $1 is hh. +m4_define([b4_inline], +[m4_case([$1], + [cc], [], + [hh], [[inline + ]], + [m4_fatal([$0: invalid argument: $1])])]) + ## -------- ## ## Checks. ## ## -------- ## @@ -169,9 +184,12 @@ m4_define([b4_public_types_declare], /// (External) token type, as returned by yylex. typedef token::yytokentype token_type; - /// Internal symbol number. + /// Symbol type: an internal symbol number. typedef int symbol_number_type; + /// The symbol type number to denote an empty symbol. + enum { empty_symbol = -2 }; + /// Internal symbol number for tokens (subsumed by symbol_number_type). typedef ]b4_int_type_for([b4_translate])[ token_number_type; @@ -204,8 +222,15 @@ m4_define([b4_public_types_declare], const semantic_type& v]b4_locations_if([, const location_type& l])[); + /// Destroy the symbol. ~basic_symbol (); + /// Destroy contents, and record that is empty. + void clear (); + + /// Whether empty. + bool empty () const; + /// Destructive move, \a s is emptied into this. void move (basic_symbol& s); @@ -235,21 +260,23 @@ m4_define([b4_public_types_declare], /// Constructor from (external) token numbers. by_type (kind_type t); + /// Record that this symbol is empty. + void clear (); + /// Steal the symbol type from \a that. void move (by_type& that); /// The (internal) type number (corresponding to \a type). - /// -1 when this symbol is empty. + /// \a empty when empty. symbol_number_type type_get () const; /// The token. token_type token () const; - enum { empty = 0 }; - /// The symbol type. - /// -1 when this symbol is empty. - token_number_type type; + /// \a empty_symbol when empty. + /// An int, not token_number_type, to be able to store empty_symbol. + int type; }; /// "External" symbols: returned by the scanner. @@ -258,38 +285,33 @@ m4_define([b4_public_types_declare], ]b4_symbol_constructor_declare]) -# b4_public_types_define -# ---------------------- +# b4_public_types_define(hh|cc) +# ----------------------------- # Provide the implementation needed by the public types. m4_define([b4_public_types_define], -[[ inline - ]b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) +[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) : std::runtime_error (m)]b4_locations_if([ , location (l)])[ {} // basic_symbol. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol () - : value () + : value ()]b4_locations_if([ + , location ()])[ {} template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other) : Base (other) - , value ()]b4_locations_if([ + , value (]b4_variant_if([], [other.value])[)]b4_locations_if([ , location (other.location)])[ - { - ]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy], - [other.value])], - [value = other.value;])[ + {]b4_variant_if([ + b4_symbol_variant([other.type_get ()], [value], [copy], + [other.value])])[ } - template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], [const semantic_type& v], @@ -306,7 +328,6 @@ m4_define([b4_public_types_define], ]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ /// Constructor for valueless symbols. template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], b4_locations_if([const location_type& l]))[) @@ -316,11 +337,19 @@ m4_define([b4_public_types_define], {}]])[ template <typename Base> - inline ]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol () + { + clear (); + } + + template <typename Base> + void + ]b4_parser_class_name[::basic_symbol<Base>::clear () {]b4_variant_if([[ // User destructor. symbol_number_type yytype = this->type_get (); + basic_symbol<Base>& yysym = *this; + (void) yysym; switch (yytype) { ]b4_symbol_foreach([b4_symbol_destructor])dnl @@ -330,14 +359,21 @@ m4_define([b4_public_types_define], // Type destructor. ]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[ + Base::clear (); + } + + template <typename Base> + bool + ]b4_parser_class_name[::basic_symbol<Base>::empty () const + { + return Base::type_get () == empty_symbol; } template <typename Base> - inline void ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s) { - super_type::move(s); + super_type::move (s); ]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move], [s.value])], [value = s.value;])[]b4_locations_if([ @@ -345,38 +381,38 @@ m4_define([b4_public_types_define], } // by_type. - inline - ]b4_parser_class_name[::by_type::by_type () - : type (empty) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type () + : type (empty_symbol) {} - inline - ]b4_parser_class_name[::by_type::by_type (const by_type& other) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other) : type (other.type) {} - inline - ]b4_parser_class_name[::by_type::by_type (token_type t) + ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t) : type (yytranslate_ (t)) {} - inline - void + ]b4_inline([$1])[void + ]b4_parser_class_name[::by_type::clear () + { + type = empty_symbol; + } + + ]b4_inline([$1])[void ]b4_parser_class_name[::by_type::move (by_type& that) { type = that.type; - that.type = empty; + that.clear (); } - inline - int + ]b4_inline([$1])[int ]b4_parser_class_name[::by_type::type_get () const { return type; } ]b4_token_ctor_if([[ - inline - ]b4_parser_class_name[::token_type + ]b4_inline([$1])b4_parser_class_name[::token_type ]b4_parser_class_name[::by_type::token () const { // YYTOKNUM[NUM] -- (External) token number corresponding to the @@ -402,14 +438,13 @@ m4_define([b4_symbol_constructor_declare], []) m4_define([b4_symbol_constructor_define], []) -# b4_yytranslate_define -# --------------------- -# Define yytranslate_. Sometimes used in the header file, +# b4_yytranslate_define(cc|hh) +# ---------------------------- +# Define yytranslate_. Sometimes used in the header file ($1=hh), # sometimes in the cc file. m4_define([b4_yytranslate_define], [[ // Symbol number corresponding to token number t. - inline - ]b4_parser_class_name[::token_number_type + ]b4_inline([$1])b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t) { @@ -419,12 +454,12 @@ m4_define([b4_yytranslate_define], { ]b4_translate[ }; - const unsigned int user_token_number_max_ = ]b4_user_token_number_max[; + const unsigned user_token_number_max_ = ]b4_user_token_number_max[; const token_number_type undef_token_ = ]b4_undef_token_number[; - if (static_cast<int>(t) <= yyeof_) + if (static_cast<int> (t) <= yyeof_) return yyeof_; - else if (static_cast<unsigned int> (t) <= user_token_number_max_) + else if (static_cast<unsigned> (t) <= user_token_number_max_) return translate_table[t]; else return undef_token_; diff --git a/contrib/tools/bison/data/c-like.m4 b/contrib/tools/bison/data/c-like.m4 index eb06de2a4d..26bab42eae 100644 --- a/contrib/tools/bison/data/c-like.m4 +++ b/contrib/tools/bison/data/c-like.m4 @@ -2,7 +2,7 @@ # Common code for C-like languages (C, C++, Java, etc.) -# Copyright (C) 2012-2013 Free Software Foundation, Inc. +# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c-skel.m4 b/contrib/tools/bison/data/c-skel.m4 index 36904aaf7b..cb9a7a21a9 100644 --- a/contrib/tools/bison/data/c-skel.m4 +++ b/contrib/tools/bison/data/c-skel.m4 @@ -2,7 +2,8 @@ # C skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/data/c.m4 b/contrib/tools/bison/data/c.m4 index b1b4394871..346b8fd30c 100644 --- a/contrib/tools/bison/data/c.m4 +++ b/contrib/tools/bison/data/c.m4 @@ -2,7 +2,7 @@ # C M4 Macros for Bison. -# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -97,7 +97,8 @@ m4_define([b4_api_PREFIX], m4_define_default([b4_prefix], [b4_api_prefix]) # If the %union is not named, its name is YYSTYPE. -m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE]) +b4_percent_define_default([[api.value.union.name]], + [b4_api_PREFIX[][STYPE]]) ## ------------------------ ## @@ -171,10 +172,10 @@ m4_define([b4_int_type], [m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], b4_ints_in($@, [-128], [127]), [1], [signed char], - b4_ints_in($@, [0], [65535]), [1], [unsigned short int], - b4_ints_in($@, [-32768], [32767]), [1], [short int], + b4_ints_in($@, [0], [65535]), [1], [unsigned short], + b4_ints_in($@, [-32768], [32767]), [1], [short], - m4_eval([0 <= $1]), [1], [unsigned int], + m4_eval([0 <= $1]), [1], [unsigned], [int])]) @@ -205,13 +206,32 @@ m4_define([b4_table_value_equals], # b4_attribute_define # ------------------- -# Provide portability for __attribute__. +# Provide portable compiler "attributes". m4_define([b4_attribute_define], -[#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +[#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif @@ -222,7 +242,7 @@ m4_define([b4_attribute_define], # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -250,14 +270,14 @@ m4_define([b4_attribute_define], # b4_null_define # -------------- -# Portability issues: define a YY_NULL appropriate for the current +# Portability issues: define a YY_NULLPTR appropriate for the current # language (C, C++98, or C++11). m4_define([b4_null_define], -[# ifndef YY_NULL +[# ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# define YY_NULLPTR nullptr # else -# define YY_NULL 0 +# define YY_NULLPTR 0 # endif # endif[]dnl ]) @@ -266,7 +286,7 @@ m4_define([b4_null_define], # b4_null # ------- # Return a null pointer constant. -m4_define([b4_null], [YY_NULL]) +m4_define([b4_null], [YY_NULLPTR]) # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT) # ------------------------------------------------------------- @@ -439,7 +459,8 @@ b4_syncline([@oline@], [@ofile@]) # ------------------------------------ m4_define([b4_predicate_case], [ case $1: - if (! ($2)) YYERROR; + if (! ( +$2)) YYERROR; b4_syncline([@oline@], [@ofile@]) break;]) @@ -541,15 +562,15 @@ b4_locations_if([, yylocationp])[]b4_user_args[); # b4_symbol_type_register(SYMBOL-NUM) # ----------------------------------- # Symbol SYMBOL-NUM has a type (for variant) instead of a type-tag. -# Extend the definition of %union's body with a field of that type, -# and extend the symbol's "type" field to point to the field name, -# instead of the type name. +# Extend the definition of %union's body (b4_union_members) with a +# field of that type, and extend the symbol's "type" field to point to +# the field name, instead of the type name. m4_define([b4_symbol_type_register], [m4_define([b4_symbol($1, type_tag)], [b4_symbol_if([$1], [has_id], [b4_symbol([$1], [id])], [yytype_[]b4_symbol([$1], [number])])])dnl -m4_append([b4_user_union_members], +m4_append([b4_union_members], m4_expand([ b4_symbol_tag_comment([$1])dnl b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);])) @@ -589,10 +610,9 @@ m4_copy_force([b4_symbol_value_union], [b4_symbol_value]) ]) -# ---------------- # -# api.value.type. # -# ---------------- # - +# -------------------------- # +# api.value.type = variant. # +# -------------------------- # # b4_value_type_setup_variant # --------------------------- @@ -667,11 +687,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE; [m4_bmatch(b4_percent_define_get([[api.value.type]]), [union\|union-directive], [[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED -typedef union ]b4_union_name[ ]b4_api_PREFIX[STYPE; -union ]b4_union_name[ +]b4_percent_define_get_syncline([[api.value.union.name]])[ +union ]b4_percent_define_get([[api.value.union.name]])[ { ]b4_user_union_members[ }; +]b4_percent_define_get_syncline([[api.value.union.name]])[ +typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE; # define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1 # define ]b4_api_PREFIX[STYPE_IS_DECLARED 1 #endif @@ -783,7 +805,7 @@ m4_define([b4_yy_location_print_define], /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ -__attribute__((__unused__)) +YY_ATTRIBUTE_UNUSED ]b4_function_define([yy_location_print_], [static unsigned], [[FILE *yyo], [yyo]], diff --git a/contrib/tools/bison/data/glr.cc b/contrib/tools/bison/data/glr.cc index e57308bd82..2ce14bc090 100644 --- a/contrib/tools/bison/data/glr.cc +++ b/contrib/tools/bison/data/glr.cc @@ -1,6 +1,6 @@ # C++ GLR skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -177,7 +177,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl | Print this symbol. | `--------------------*/ - inline void + void ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, const semantic_type* yyvaluep]b4_locations_if([[, const location_type* yylocationp]])[) @@ -329,7 +329,7 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]], b4_defines_if( [b4_output_begin([b4_spec_defines_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C++], - [2002-2013])[ + [2002-2015, 2018])[ // C++ GLR parser skeleton written by Akim Demaille. diff --git a/contrib/tools/bison/data/lalr1.cc b/contrib/tools/bison/data/lalr1.cc index 3294f59110..143f3d4b18 100644 --- a/contrib/tools/bison/data/lalr1.cc +++ b/contrib/tools/bison/data/lalr1.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -107,7 +107,7 @@ b4_dollar_pushdef([yysym.value], [m4_dquote(b4_symbol([$1], [type]))]), [yysym.location])dnl b4_symbol_case_([$1]) -b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"]) +b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) b4_symbol([$1], [$2]) b4_syncline([@oline@], [@ofile@]) break; @@ -131,7 +131,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])]) m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) @@ -142,21 +142,24 @@ b4_bison_locations_if([# Backward compatibility. m4_include(b4_pkgdatadir/[stack.hh]) b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) -# b4_shared_declarations -# ---------------------- -# Declaration that might either go into the header (if --defines) +# b4_shared_declarations(hh|cc) +# ----------------------------- +# Declaration that might either go into the header (if --defines, $1 = hh) # or open coded in the parser body. m4_define([b4_shared_declarations], [b4_percent_code_get([[requires]])[ ]b4_parse_assert_if([# include <cassert>])[ -# include <vector> +# include <cstdlib> // std::abort # include <iostream> # include <stdexcept> -# include <string>]b4_defines_if([[ +# include <string> +# include <vector>]b4_defines_if([[ # include "stack.hh" ]b4_bison_locations_if([[# include "location.hh"]])])[ ]b4_variant_if([b4_variant_includes])[ +]b4_attribute_define[ +]b4_null_define[ ]b4_YYDEBUG_define[ ]b4_namespace_open[ @@ -183,14 +186,14 @@ b4_location_define])])[ #if ]b4_api_PREFIX[DEBUG /// The current debugging stream. - std::ostream& debug_stream () const; + std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; /// Set the current debugging stream. void set_debug_stream (std::ostream &); /// Type for debugging levels. typedef int debug_level_type; /// The current debugging level. - debug_level_type debug_level () const; + debug_level_type debug_level () const YY_ATTRIBUTE_PURE; /// Set the current debugging level. void set_debug_level (debug_level_type l); #endif @@ -213,14 +216,14 @@ b4_location_define])])[ /// Generate an error message. /// \param yystate the state where the error occurred. - /// \param yytoken the lookahead token type, or yyempty_. + /// \param yyla the lookahead token. virtual std::string yysyntax_error_ (state_type yystate, - symbol_number_type yytoken) const; + const symbol_type& yyla) const; /// Compute post-reduction state. /// \param yystate the current state - /// \param yylhs the nonterminal to push on the stack - state_type yy_lr_goto_state_ (state_type yystate, int yylhs); + /// \param yysym the nonterminal to push on the stack + state_type yy_lr_goto_state_ (state_type yystate, int yysym); /// Whether the given \c yypact_ value indicates a defaulted state. /// \param yyvalue the value to check @@ -267,7 +270,7 @@ b4_location_define])])[ /// \brief Reclaim the memory associated to a symbol. /// \param yymsg Why this token is reclaimed. /// If null, print nothing. - /// \param s The symbol. + /// \param yysym The symbol. template <typename Base> void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const; @@ -287,16 +290,21 @@ b4_location_define])])[ /// Copy constructor. by_state (const by_state& other); + /// Record that this symbol is empty. + void clear (); + /// Steal the symbol type from \a that. void move (by_state& that); /// The (internal) type number (corresponding to \a state). - /// "empty" when empty. + /// \a empty_symbol when empty. symbol_number_type type_get () const; - enum { empty = 0 }; + /// The state number used to denote an empty symbol. + enum { empty_state = -1 }; /// The state. + /// \a empty when empty. state_type state; }; @@ -307,6 +315,8 @@ b4_location_define])])[ typedef basic_symbol<by_state> super_type; /// Construct an empty symbol. stack_symbol_type (); + /// Copy construct (for efficiency). + stack_symbol_type (const stack_symbol_type& that); /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, symbol_type& sym); /// Assignment, needed by push_back. @@ -335,26 +345,25 @@ b4_location_define])])[ void yypush_ (const char* m, state_type s, symbol_type& sym); /// Pop \a n symbols the three stacks. - void yypop_ (unsigned int n = 1); + void yypop_ (unsigned n = 1); - // Constants. + /// Constants. enum { yyeof_ = 0, - yylast_ = ]b4_last[, //< Last index in yytable_. - yynnts_ = ]b4_nterms_number[, //< Number of nonterminal symbols. - yyempty_ = -2, - yyfinal_ = ]b4_final_state_number[, //< Termination state number. + yylast_ = ]b4_last[, ///< Last index in yytable_. + yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols. + yyfinal_ = ]b4_final_state_number[, ///< Termination state number. yyterror_ = 1, yyerrcode_ = 256, - yyntokens_ = ]b4_tokens_number[ //< Number of tokens. + yyntokens_ = ]b4_tokens_number[ ///< Number of tokens. }; ]b4_parse_param_vars[ }; -]b4_token_ctor_if([b4_yytranslate_define -b4_public_types_define])[ +]b4_token_ctor_if([b4_yytranslate_define([$1])[ +]b4_public_types_define([$1])])[ ]b4_namespace_close[ ]b4_percent_define_flag_if([[global_tokens_and_yystype]], @@ -380,7 +389,7 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) // C++ LALR(1) parser skeleton written by Akim Demaille. ]b4_cpp_guard_open([b4_spec_defines_file])[ -]b4_shared_declarations[ +]b4_shared_declarations(hh)[ ]b4_cpp_guard_close([b4_spec_defines_file]) b4_output_end() ]) @@ -400,7 +409,7 @@ m4_if(b4_prefix, [yy], [], ]b4_null_define[ ]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], - [b4_shared_declarations])[ + [b4_shared_declarations([cc])])[ // User implementation prologue. ]b4_user_post_prologue[ @@ -418,6 +427,15 @@ m4_if(b4_prefix, [yy], [], # endif #endif +// Whether we are compiled with exception support. +#ifndef YY_EXCEPTIONS +# if defined __GNUC__ && !defined __EXCEPTIONS +# define YY_EXCEPTIONS 0 +# else +# define YY_EXCEPTIONS 1 +# endif +#endif + ]b4_locations_if([dnl [#define YYRHSLOC(Rhs, K) ((Rhs)[K].location) ]b4_yylloc_default_define])[ @@ -437,7 +455,7 @@ m4_if(b4_prefix, [yy], [], { \ *yycdebug_ << Title << ' '; \ yy_print_ (*yycdebug_, Symbol); \ - *yycdebug_ << std::endl; \ + *yycdebug_ << '\n'; \ } \ } while (false) @@ -456,14 +474,14 @@ m4_if(b4_prefix, [yy], [], #else // !]b4_api_PREFIX[DEBUG # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) -# define YY_REDUCE_PRINT(Rule) static_cast<void>(0) -# define YY_STACK_PRINT() static_cast<void>(0) +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE (Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast<void> (0) +# define YY_STACK_PRINT() static_cast<void> (0) #endif // !]b4_api_PREFIX[DEBUG #define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yyempty = true) +#define yyclearin (yyla.clear ()) #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -527,56 +545,63 @@ m4_if(b4_prefix, [yy], [], | Symbol types. | `---------------*/ -]b4_token_ctor_if([], [b4_public_types_define])[ +]b4_token_ctor_if([], [b4_public_types_define([cc])])[ // by_state. - inline ]b4_parser_class_name[::by_state::by_state () - : state (empty) + : state (empty_state) {} - inline ]b4_parser_class_name[::by_state::by_state (const by_state& other) : state (other.state) {} - inline + void + ]b4_parser_class_name[::by_state::clear () + { + state = empty_state; + } + void ]b4_parser_class_name[::by_state::move (by_state& that) { state = that.state; - that.state = empty; + that.clear (); } - inline ]b4_parser_class_name[::by_state::by_state (state_type s) : state (s) {} - inline ]b4_parser_class_name[::symbol_number_type ]b4_parser_class_name[::by_state::type_get () const { - return state == empty ? 0 : yystos_[state]; + if (state == empty_state) + return empty_symbol; + else + return yystos_[state]; } - inline ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () {} - - inline - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) - : super_type (s]b4_locations_if([, that.location])[) + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that) + : super_type (that.state]b4_locations_if([, that.location])[) { ]b4_variant_if([b4_symbol_variant([that.type_get ()], - [value], [move], [that.value])], + [value], [copy], [that.value])], [[value = that.value;]])[ + } + + ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) + : super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[) + {]b4_variant_if([ + b4_symbol_variant([that.type_get ()], + [value], [move], [that.value])])[ // that is emptied. - that.type = empty; + that.type = empty_symbol; } - inline ]b4_parser_class_name[::stack_symbol_type& ]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that) { @@ -590,7 +615,6 @@ m4_if(b4_prefix, [yy], [], template <typename Base> - inline void ]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const { @@ -610,6 +634,10 @@ m4_if(b4_prefix, [yy], [], std::ostream& yyoutput = yyo; YYUSE (yyoutput); symbol_number_type yytype = yysym.type_get (); + // Avoid a (spurious) G++ 4.8 warning about "array subscript is + // below array bounds". + if (yysym.empty ()) + std::abort (); yyo << (yytype < yyntokens_ ? "token" : "nterm") << ' ' << yytname_[yytype] << " ("]b4_locations_if([ << yysym.location << ": "])[; @@ -618,7 +646,6 @@ m4_if(b4_prefix, [yy], [], } #endif - inline void ]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym) { @@ -626,7 +653,6 @@ m4_if(b4_prefix, [yy], [], yypush_ (m, t); } - inline void ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s) { @@ -635,9 +661,8 @@ m4_if(b4_prefix, [yy], [], yystack_.push (s); } - inline void - ]b4_parser_class_name[::yypop_ (unsigned int n) + ]b4_parser_class_name[::yypop_ (unsigned n) { yystack_.pop (n); } @@ -669,23 +694,23 @@ m4_if(b4_prefix, [yy], [], } #endif // ]b4_api_PREFIX[DEBUG - inline ]b4_parser_class_name[::state_type - ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs) + ]b4_parser_class_name[::state_type + ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym) { - int yyr = yypgoto_[yylhs - yyntokens_] + yystate; + int yyr = yypgoto_[yysym - yyntokens_] + yystate; if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) return yytable_[yyr]; else - return yydefgoto_[yylhs - yyntokens_]; + return yydefgoto_[yysym - yyntokens_]; } - inline bool + bool ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) { return yyvalue == yypact_ninf_; } - inline bool + bool ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) { return yyvalue == yytable_ninf_; @@ -694,11 +719,9 @@ m4_if(b4_prefix, [yy], [], int ]b4_parser_class_name[::parse () { - /// Whether yyla contains a lookahead. - bool yyempty = true; - // State. int yyn; + /// Length of the RHS of the rule being reduced. int yylen = 0; // Error handling. @@ -711,17 +734,14 @@ m4_if(b4_prefix, [yy], [], /// The locations where the error started and ended. stack_symbol_type yyerror_range[3];]])[ - /// $$ and @@$. - stack_symbol_type yylhs; - /// The return value of parse (). int yyresult; - // FIXME: This shoud be completely indented. It is not yet to - // avoid gratuitous conflicts when merging into the master branch. +#if YY_EXCEPTIONS try +#endif // YY_EXCEPTIONS { - YYCDEBUG << "Starting parse" << std::endl; + YYCDEBUG << "Starting parse\n"; ]m4_ifdef([b4_initial_action], [ b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl @@ -734,11 +754,11 @@ b4_dollar_popdef])[]dnl location values to have been already stored, initialize these stacks with a primary value. */ yystack_.clear (); - yypush_ (YY_NULL, 0, yyla); + yypush_ (YY_NULLPTR, 0, yyla); // A new symbol was pushed on the stack. yynewstate: - YYCDEBUG << "Entering state " << yystack_[0].state << std::endl; + YYCDEBUG << "Entering state " << yystack_[0].state << '\n'; // Accept? if (yystack_[0].state == yyfinal_) @@ -748,28 +768,30 @@ b4_dollar_popdef])[]dnl // Backup. yybackup: - // Try to take a decision without lookahead. yyn = yypact_[yystack_[0].state]; if (yy_pact_value_is_default_ (yyn)) goto yydefault; // Read a lookahead token. - if (yyempty) + if (yyla.empty ()) { YYCDEBUG << "Reading a token: "; +#if YY_EXCEPTIONS try +#endif // YY_EXCEPTIONS {]b4_token_ctor_if([[ symbol_type yylookahead (]b4_lex[); yyla.move (yylookahead);]], [[ yyla.type = yytranslate_ (]b4_lex[);]])[ } +#if YY_EXCEPTIONS catch (const syntax_error& yyexc) { error (yyexc); goto yyerrlab1; } - yyempty = false; +#endif // YY_EXCEPTIONS } YY_SYMBOL_PRINT ("Next token is", yyla); @@ -789,9 +811,6 @@ b4_dollar_popdef])[]dnl goto yyreduce; } - // Discard the token being shifted. - yyempty = true; - // Count tokens shifted since error; after three, turn off error status. if (yyerrstatus_) --yyerrstatus_; @@ -814,52 +833,60 @@ b4_dollar_popdef])[]dnl `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; - yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ - /* Variants are always initialized to an empty instance of the - correct type. The default $$=$1 action is NOT applied when using - variants. */ - b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])],[ - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYLHS.VALUE to garbage. - This behavior is undocumented and Bison - users should not rely upon it. */ - if (yylen) - yylhs.value = yystack_@{yylen - 1@}.value; - else - yylhs.value = yystack_@{0@}.value;])[ + { + stack_symbol_type yylhs; + yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([ + /* Variants are always initialized to an empty instance of the + correct type. The default '$$ = $1' action is NOT applied + when using variants. */ + b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])], [ + /* If YYLEN is nonzero, implement the default value of the + action: '$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYLHS.VALUE to garbage. + This behavior is undocumented and Bison users should not rely + upon it. */ + if (yylen) + yylhs.value = yystack_@{yylen - 1@}.value; + else + yylhs.value = yystack_@{0@}.value;])[ ]b4_locations_if([dnl [ - // Compute the default @@$. - { - slice<stack_symbol_type, stack_type> slice (yystack_, yylen); - YYLLOC_DEFAULT (yylhs.location, slice, yylen); - }]])[ - - // Perform the reduction. - YY_REDUCE_PRINT (yyn); - try + // Default location. { - switch (yyn) - { + slice<stack_symbol_type, stack_type> slice (yystack_, yylen); + YYLLOC_DEFAULT (yylhs.location, slice, yylen); + yyerror_range[1].location = yylhs.location; + }]])[ + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); +#if YY_EXCEPTIONS + try +#endif // YY_EXCEPTIONS + { + switch (yyn) + { ]b4_user_actions[ - default: - break; - } - } - catch (const syntax_error& yyexc) - { - error (yyexc); - YYERROR; - } - YY_SYMBOL_PRINT ("-> $$ =", yylhs); - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - - // Shift the result of the reduction. - yypush_ (YY_NULL, yylhs); + default: + break; + } + } +#if YY_EXCEPTIONS + catch (const syntax_error& yyexc) + { + error (yyexc); + YYERROR; + } +#endif // YY_EXCEPTIONS + YY_SYMBOL_PRINT ("-> $$ =", yylhs); + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + // Shift the result of the reduction. + yypush_ (YY_NULLPTR, yylhs); + } goto yynewstate; /*--------------------------------------. @@ -871,8 +898,7 @@ b4_dollar_popdef])[]dnl { ++yynerrs_; error (]b4_join(b4_locations_if([yyla.location]), - [[yysyntax_error_ (yystack_[0].state, - yyempty ? yyempty_ : yyla.type_get ())]])[); + [[yysyntax_error_ (yystack_[0].state, yyla)]])[); } ]b4_locations_if([[ @@ -885,10 +911,10 @@ b4_dollar_popdef])[]dnl // Return failure if at end of input. if (yyla.type_get () == yyeof_) YYABORT; - else if (!yyempty) + else if (!yyla.empty ()) { yy_destroy_ ("Error: discarding", yyla); - yyempty = true; + yyla.clear (); } } @@ -905,11 +931,7 @@ b4_dollar_popdef])[]dnl YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) - goto yyerrorlab;]b4_locations_if([[ - yyerror_range[1].location = yystack_[yylen - 1].location;]])b4_variant_if([[ - /* $$ was initialized before running the user action. */ - YY_SYMBOL_PRINT ("Error: discarding", yylhs); - yylhs.~stack_symbol_type();]])[ + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ yypop_ (yylen); @@ -967,7 +989,7 @@ b4_dollar_popdef])[]dnl goto yyreturn; yyreturn: - if (!yyempty) + if (!yyla.empty ()) yy_destroy_ ("Cleanup: discarding lookahead", yyla); /* Do not reclaim the symbols of the rule whose action triggered @@ -981,38 +1003,38 @@ b4_dollar_popdef])[]dnl return yyresult; } +#if YY_EXCEPTIONS catch (...) { - YYCDEBUG << "Exception caught: cleaning lookahead and stack" - << std::endl; + YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; // Do not try to display the values of the reclaimed symbols, - // as their printer might throw an exception. - if (!yyempty) - yy_destroy_ (YY_NULL, yyla); + // as their printers might throw an exception. + if (!yyla.empty ()) + yy_destroy_ (YY_NULLPTR, yyla); while (1 < yystack_.size ()) { - yy_destroy_ (YY_NULL, yystack_[0]); + yy_destroy_ (YY_NULLPTR, yystack_[0]); yypop_ (); } throw; } +#endif // YY_EXCEPTIONS } void ]b4_parser_class_name[::error (const syntax_error& yyexc) { error (]b4_join(b4_locations_if([yyexc.location]), - [[yyexc.what()]])[); + [[yyexc.what ()]])[); } // Generate an error message. std::string ]b4_parser_class_name[::yysyntax_error_ (]dnl -b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], - [state_type, symbol_number_type])[) const +b4_error_verbose_if([state_type yystate, const symbol_type& yyla], + [state_type, const symbol_type&])[) const {]b4_error_verbose_if([[ - std::string yyres; // Number of reported tokens (one for the "unexpected", one per // "expected"). size_t yycount = 0; @@ -1026,7 +1048,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is + - The only way there can be no lookahead present (in yyla) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to @@ -1046,8 +1068,9 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], token that will not be accepted due to an error action in a later state. */ - if (yytoken != yyempty_) + if (!yyla.empty ()) { + int yytoken = yyla.type_get (); yyarg[yycount++] = yytname_[yytoken]; int yyn = yypact_[yystate]; if (!yy_pact_value_is_default_ (yyn)) @@ -1074,22 +1097,24 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], } } - char const* yyformat = YY_NULL; + char const* yyformat = YY_NULLPTR; switch (yycount) { #define YYCASE_(N, S) \ case N: \ yyformat = S; \ break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); + default: // Avoid compiler warnings. + YYCASE_ (0, YY_("syntax error")); + YYCASE_ (1, YY_("syntax error, unexpected %s")); + YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); #undef YYCASE_ } + std::string yyres; // Argument number. size_t yyi = 0; for (char const* yyp = yyformat; *yyp; ++yyp) @@ -1133,18 +1158,18 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], i_end = yystack_.end (); i != i_end; ++i) *yycdebug_ << ' ' << i->state; - *yycdebug_ << std::endl; + *yycdebug_ << '\n'; } // Report on the debug stream that the rule \a yyrule is going to be reduced. void ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) { - unsigned int yylno = yyrline_[yyrule]; + unsigned yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; // Print the symbols being reduced, and their result. *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):" << std::endl; + << " (line " << yylno << "):\n"; // The symbols being reduced. for (int yyi = 0; yyi < yynrhs; yyi++) YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", @@ -1152,7 +1177,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken], } #endif // ]b4_api_PREFIX[DEBUG -]b4_token_ctor_if([], [b4_yytranslate_define])[ +]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[ ]b4_namespace_close[ ]b4_epilogue[]dnl b4_output_end() diff --git a/contrib/tools/bison/data/location.cc b/contrib/tools/bison/data/location.cc index 9a60f2503f..07f1ca62fb 100644 --- a/contrib/tools/bison/data/location.cc +++ b/contrib/tools/bison/data/location.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) # b4_position_define # ------------------ @@ -27,20 +27,19 @@ m4_define([b4_position_define], { public:]m4_ifdef([b4_location_constructors], [[ /// Construct a position. - explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : filename (f) , line (l) , column (c) - { - } + {} ]])[ /// Initialization. - void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { filename = fn; line = l; @@ -69,21 +68,19 @@ m4_define([b4_position_define], /// File name to which this position refers. ]b4_percent_define_get([[filename_type]])[* filename; /// Current line number. - unsigned int line; + unsigned line; /// Current column number. - unsigned int column; + unsigned column; private: - /// Compute max(min, lhs+rhs) (provided min <= lhs). - static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min) + /// Compute max(min, lhs+rhs). + static unsigned add_ (unsigned lhs, int rhs, int min) { - return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs - ? rhs + lhs - : min); + return static_cast<unsigned>(std::max(min, static_cast<int>(lhs) + rhs)); } }; - /// Add and assign a position. + /// Add \a width columns, in place. inline position& operator+= (position& res, int width) { @@ -91,21 +88,21 @@ m4_define([b4_position_define], return res; } - /// Add two position objects. + /// Add \a width columns. inline position operator+ (position res, int width) { return res += width; } - /// Add and assign a position. + /// Subtract \a width columns, in place. inline position& operator-= (position& res, int width) { return res += -width; } - /// Add two position objects. + /// Subtract \a width columns. inline position operator- (position res, int width) { @@ -135,7 +132,7 @@ m4_define([b4_position_define], ** \param pos a reference to the position to redirect */ template <typename YYChar> - inline std::basic_ostream<YYChar>& + std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const position& pos) { if (pos.filename) @@ -157,30 +154,27 @@ m4_define([b4_location_define], location (const position& b, const position& e) : begin (b) , end (e) - { - } + {} /// Construct a 0-width location in \a p. explicit location (const position& p = position ()) : begin (p) , end (p) - { - } + {} /// Construct a 0-width location in \a f, \a l, \a c. explicit location (]b4_percent_define_get([[filename_type]])[* f, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) : begin (f, l, c) , end (f, l, c) - { - } + {} ])[ /// Initialization. - void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL, - unsigned int l = ]b4_location_initial_line[u, - unsigned int c = ]b4_location_initial_column[u) + void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, + unsigned l = ]b4_location_initial_line[u, + unsigned c = ]b4_location_initial_column[u) { begin.initialize (f, l, c); end = begin; @@ -216,36 +210,42 @@ m4_define([b4_location_define], position end; }; - /// Join two location objects to create a location. - inline location operator+ (location res, const location& end) + /// Join two locations, in place. + inline location& operator+= (location& res, const location& end) { res.end = end.end; return res; } - /// Change end position in place. + /// Join two locations. + inline location operator+ (location res, const location& end) + { + return res += end; + } + + /// Add \a width columns to the end position, in place. inline location& operator+= (location& res, int width) { res.columns (width); return res; } - /// Change end position. + /// Add \a width columns to the end position. inline location operator+ (location res, int width) { return res += width; } - /// Change end position in place. + /// Subtract \a width columns to the end position, in place. inline location& operator-= (location& res, int width) { return res += -width; } - /// Change end position. - inline location operator- (const location& begin, int width) + /// Subtract \a width columns to the end position. + inline location operator- (location res, int width) { - return begin + -width; + return res -= width; } ]b4_percent_define_flag_if([[define_location_comparison]], [[ /// Compare two location objects. @@ -269,12 +269,11 @@ m4_define([b4_location_define], ** Avoid duplicate information. */ template <typename YYChar> - inline std::basic_ostream<YYChar>& + std::basic_ostream<YYChar>& operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) { - unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; - ostr << loc.begin// << "(" << loc.end << ") " -; + unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; + ostr << loc.begin; if (loc.end.filename && (!loc.begin.filename || *loc.begin.filename != *loc.end.filename)) diff --git a/contrib/tools/bison/data/m4sugar/foreach.m4 b/contrib/tools/bison/data/m4sugar/foreach.m4 index f6a6394472..7093d0fcc4 100644 --- a/contrib/tools/bison/data/m4sugar/foreach.m4 +++ b/contrib/tools/bison/data/m4sugar/foreach.m4 @@ -4,7 +4,7 @@ # Speeds up GNU M4 1.4.x by avoiding quadratic $@ recursion, but penalizes # GNU M4 1.6 by requiring more memory and macro expansions. # -# Copyright (C) 2008-2013 Free Software Foundation, Inc. +# Copyright (C) 2008-2017 Free Software Foundation, Inc. # This file is part of Autoconf. This program is free # software; you can redistribute it and/or modify it under the @@ -24,7 +24,7 @@ # You should have received a copy of the GNU General Public License # and a copy of the Autoconf Configure Script Exception along with # this program; see the files COPYINGv3 and COPYING.EXCEPTION -# respectively. If not, see <http://www.gnu.org/licenses/>. +# respectively. If not, see <https://www.gnu.org/licenses/>. # Written by Eric Blake. diff --git a/contrib/tools/bison/data/m4sugar/m4sugar.m4 b/contrib/tools/bison/data/m4sugar/m4sugar.m4 index b732abc789..bbd695836a 100644 --- a/contrib/tools/bison/data/m4sugar/m4sugar.m4 +++ b/contrib/tools/bison/data/m4sugar/m4sugar.m4 @@ -3,7 +3,7 @@ divert(-1)# -*- Autoconf -*- # Base M4 layer. # Requires GNU M4. # -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # This file is part of Autoconf. This program is free # software; you can redistribute it and/or modify it under the @@ -23,7 +23,7 @@ divert(-1)# -*- Autoconf -*- # You should have received a copy of the GNU General Public License # and a copy of the Autoconf Configure Script Exception along with # this program; see the files COPYINGv3 and COPYING.EXCEPTION -# respectively. If not, see <http://www.gnu.org/licenses/>. +# respectively. If not, see <https://www.gnu.org/licenses/>. # Written by Akim Demaille. @@ -2000,7 +2000,7 @@ m4_define([_m4_defun_once], # m4_pattern_forbid(ERE, [WHY]) # ----------------------------- -# Declare that no token matching the forbidden extended regular +# Declare that no token matching the forbidden perl extended regular # expression ERE should be seen in the output unless... m4_define([m4_pattern_forbid], []) @@ -2008,7 +2008,7 @@ m4_define([m4_pattern_forbid], []) # m4_pattern_allow(ERE) # --------------------- # ... that token also matches the allowed extended regular expression ERE. -# Both used via traces. +# Both used via traces, by autom4te post-processing. m4_define([m4_pattern_allow], []) @@ -2107,7 +2107,7 @@ m4_define([_m4_require_check], [m4_if(_m4_defn([_m4_diverting]), [$2], [m4_ignore], m4_ifdef([_m4_diverting([$2])], [-]), [-], [m4_warn([syntax], [$3: `$1' was expanded before it was required -http://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required])_m4_require_call], +https://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required])_m4_require_call], [m4_ignore])]) @@ -3126,7 +3126,8 @@ m4_define([m4_set_empty], # guaranteed. This is faster than the corresponding m4_foreach([VAR], # m4_indir([m4_dquote]m4_set_listc([SET])), [ACTION]) m4_define([m4_set_foreach], -[m4_pushdef([$2])m4_set_map_sep([$1], [m4_define([$2],], [)$3])]) +[m4_pushdef([$2])m4_set_map_sep([$1], +[m4_define([$2],], [)$3])m4_popdef([$2])]) # m4_set_intersection(SET1, SET2) # ------------------------------- diff --git a/contrib/tools/bison/data/stack.hh b/contrib/tools/bison/data/stack.hh index aa64d63d84..f3ac21f949 100644 --- a/contrib/tools/bison/data/stack.hh +++ b/contrib/tools/bison/data/stack.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,39 +16,44 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2013]) + [2002-2015, 2018]) # b4_stack_define # --------------- m4_define([b4_stack_define], -[[ template <class T, class S = std::vector<T> > +[[ /// A stack with random access from its top. + template <class T, class S = std::vector<T> > class stack { public: // Hide our reversed order. typedef typename S::reverse_iterator iterator; typedef typename S::const_reverse_iterator const_iterator; + typedef typename S::size_type size_type; stack () - : seq_ () { + seq_.reserve (200); } - stack (unsigned int n) + stack (size_type n) : seq_ (n) - { - } + {} - inline + /// Random access. + /// + /// Index 0 returns the topmost element. T& - operator[] (unsigned int i) + operator[] (size_type i) { return seq_[seq_.size () - 1 - i]; } - inline + /// Random access. + /// + /// Index 0 returns the topmost element. const T& - operator[] (unsigned int i) const + operator[] (size_type i) const { return seq_[seq_.size () - 1 - i]; } @@ -56,7 +61,6 @@ m4_define([b4_stack_define], /// Steal the contents of \a t. /// /// Close to move-semantics. - inline void push (T& t) { @@ -64,9 +68,8 @@ m4_define([b4_stack_define], operator[](0).move (t); } - inline void - pop (unsigned int n = 1) + pop (size_type n = 1) { for (; n; --n) seq_.pop_back (); @@ -78,21 +81,18 @@ m4_define([b4_stack_define], seq_.clear (); } - inline - typename S::size_type + size_type size () const { return seq_.size (); } - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { @@ -111,22 +111,21 @@ m4_define([b4_stack_define], class slice { public: - slice (const S& stack, unsigned int range) + typedef typename S::size_type size_type; + slice (const S& stack, size_type range) : stack_ (stack) , range_ (range) - { - } + {} - inline const T& - operator [] (unsigned int i) const + operator[] (size_type i) const { return stack_[range_ - i]; } private: const S& stack_; - unsigned int range_; + size_type range_; }; ]]) diff --git a/contrib/tools/bison/data/variant.hh b/contrib/tools/bison/data/variant.hh index ac4f7a7850..8d0f06f6e3 100644 --- a/contrib/tools/bison/data/variant.hh +++ b/contrib/tools/bison/data/variant.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ m4_define([b4_symbol_variant], [m4_pushdef([b4_dollar_dollar], [$2.$3< $][3 > (m4_shift3($@))])dnl - switch ($1) +switch ($1) { b4_type_foreach([b4_type_action_])[]dnl default: @@ -94,14 +94,15 @@ m4_define([b4_variant_define], typedef variant<S> self_type; /// Empty construction. - variant ()]b4_parse_assert_if([ - : yytname_ (YY_NULL)])[ + variant () + : yybuffer_ ()]b4_parse_assert_if([ + , yytypeid_ (YY_NULLPTR)])[ {} /// Construct and fill. template <typename T> variant (const T& t)]b4_parse_assert_if([ - : yytname_ (typeid (T).name ())])[ + : yytypeid_ (&typeid (T))])[ { YYASSERT (sizeof (T) <= S); new (yyas_<T> ()) T (t); @@ -110,7 +111,7 @@ m4_define([b4_variant_define], /// Destruction, allowed only if empty. ~variant () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); ])[} /// Instantiate an empty \a T in here. @@ -118,10 +119,10 @@ m4_define([b4_variant_define], T& build () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ - return *new (yyas_<T> ()) T; + yytypeid_ = & typeid (T);])[ + return *new (yyas_<T> ()) T (); } /// Instantiate a \a T in here from \a t. @@ -129,9 +130,9 @@ m4_define([b4_variant_define], T& build (const T& t) {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ + yytypeid_ = & typeid (T);])[ return *new (yyas_<T> ()) T (t); } @@ -140,7 +141,8 @@ m4_define([b4_variant_define], T& as () {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_<T> (); } @@ -150,7 +152,8 @@ m4_define([b4_variant_define], const T& as () const {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_<T> (); } @@ -167,8 +170,8 @@ m4_define([b4_variant_define], void swap (self_type& other) {]b4_parse_assert_if([ - YYASSERT (yytname_); - YYASSERT (yytname_ == other.yytname_);])[ + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == *other.yytypeid_);])[ std::swap (as<T> (), other.as<T> ()); } @@ -178,8 +181,7 @@ m4_define([b4_variant_define], template <typename T> void move (self_type& other) - {]b4_parse_assert_if([ - YYASSERT (!yytname_);])[ + { build<T> (); swap<T> (other); other.destroy<T> (); @@ -199,7 +201,7 @@ m4_define([b4_variant_define], destroy () { as<T> ().~T ();]b4_parse_assert_if([ - yytname_ = YY_NULL;])[ + yytypeid_ = YY_NULLPTR;])[ } private: @@ -234,7 +236,7 @@ m4_define([b4_variant_define], } yybuffer_;]b4_parse_assert_if([ /// Whether the content is built: if defined, the name of the stored type. - const char *yytname_;])[ + const std::type_info *yytypeid_;])[ }; ]]) @@ -321,7 +323,6 @@ b4_join(b4_symbol_if([$1], [has_type], return symbol_type (b4_join([token::b4_symbol([$1], [id])], b4_symbol_if([$1], [has_type], [v]), b4_locations_if([l]))); - } ])])]) @@ -334,7 +335,7 @@ m4_define([b4_basic_symbol_constructor_declare], [[ basic_symbol (]b4_join( [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]), + b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]), b4_locations_if([const location_type& l]))[); ]]) @@ -346,10 +347,10 @@ m4_define([b4_basic_symbol_constructor_define], template <typename Base> ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[ v]), + b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]), b4_locations_if([const location_type& l]))[) - : Base (t) - , value (]b4_symbol_if([$1], [has_type], [v])[)]b4_locations_if([ + : Base (t)]b4_symbol_if([$1], [has_type], [ + , value (v)])[]b4_locations_if([ , location (l)])[ {} ]]) diff --git a/contrib/tools/bison/data/yacc.c b/contrib/tools/bison/data/yacc.c index 822656b8d8..e72b098b7a 100644 --- a/contrib/tools/bison/data/yacc.c +++ b/contrib/tools/bison/data/yacc.c @@ -1,11 +1,11 @@ -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, -# Inc. +# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software +# Foundation, Inc. m4_pushdef([b4_copyright_years], - [1984, 1989-1990, 2000-2013]) + [1984, 1989-1990, 2000-2015, 2018]) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -118,7 +118,7 @@ m4_define([b4_int_type], b4_ints_in($@, [0], [65535]), [1], [yytype_uint16], b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16], - m4_eval([0 <= $1]), [1], [unsigned int], + m4_eval([0 <= $1]), [1], [unsigned], [int])]) @@ -377,13 +377,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -395,7 +395,7 @@ typedef short int yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -571,7 +571,7 @@ union yyalloc #define YYMAXUTOK ]b4_user_token_number_max[ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ @@ -719,7 +719,7 @@ do { \ ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -827,7 +827,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]), [full], [[ YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix, - (unsigned long int) yyalloc, yydebug_suffix));]])[ + (unsigned long) yyalloc, yydebug_suffix));]])[ } return 0; } @@ -1108,11 +1108,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes, YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1187,7 +1187,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1207,6 +1207,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1271,7 +1272,7 @@ static char yypstate_allocated = 0;]])b4_pull_if([ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ { - return yypull_parse (YY_NULL]m4_ifset([b4_parse_param], + return yypull_parse (YY_NULLPTR]m4_ifset([b4_parse_param], [[, ]b4_args(b4_parse_param)])[); } @@ -1313,10 +1314,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ { yypstate *yyps;]b4_pure_if([], [[ if (yypstate_allocated) - return YY_NULL;]])[ + return YY_NULLPTR;]])[ yyps = (yypstate *) malloc (sizeof *yyps); if (!yyps) - return YY_NULL; + return YY_NULLPTR; yyps->yynew = 1;]b4_pure_if([], [[ yypstate_allocated = 1;]])[ return yyps; @@ -1325,16 +1326,19 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ ]b4_function_define([[yypstate_delete]], [[void]], [[[yypstate *yyps]], [[yyps]]])[ { + if (yyps) + { #ifndef yyoverflow - /* If the stack was reallocated but the parse did not complete, then the - stack still needs to be freed. */ - if (!yyps->yynew && yyps->yyss != yyps->yyssa) - YYSTACK_FREE (yyps->yyss); + /* If the stack was reallocated but the parse did not complete, then the + stack still needs to be freed. */ + if (!yyps->yynew && yyps->yyss != yyps->yyssa) + YYSTACK_FREE (yyps->yyss); #endif]b4_lac_if([[ - if (!yyps->yynew && yyps->yyes != yyps->yyesa) - YYSTACK_FREE (yyps->yyes);]])[ - free (yyps);]b4_pure_if([], [[ - yypstate_allocated = 0;]])[ + if (!yyps->yynew && yyps->yyes != yyps->yyesa) + YYSTACK_FREE (yyps->yyes);]])[ + free (yyps);]b4_pure_if([], [[ + yypstate_allocated = 0;]])[ + } } ]b4_pure_if([[ #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[ @@ -1509,7 +1513,7 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo yylsp = yyls + yysize - 1;])[ YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; @@ -1641,8 +1645,9 @@ yyreduce: yyval = yyvsp[1-yylen]; ]b4_locations_if( -[[ /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ +[[ /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc;]])[ YY_REDUCE_PRINT (yyn);]b4_lac_if([[ { int yychar_backup = yychar; @@ -1782,8 +1787,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; -]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen]; -]])[ /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; diff --git a/contrib/tools/bison/lib/abitset.c b/contrib/tools/bison/lib/abitset.c index f876996bcf..830fdefcfc 100644 --- a/contrib/tools/bison/lib/abitset.c +++ b/contrib/tools/bison/lib/abitset.c @@ -1,7 +1,7 @@ /* Array bitsets. - Copyright (C) 2002-2003, 2006, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002-2003, 2006, 2009-2015, 2018 Free Software + Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -146,7 +146,7 @@ abitset_list_reverse (bitset src, bitset_bindex *list, bitset_bindex rbitno; bitset_bindex count; bitset_windex windex; - unsigned int bitcnt; + unsigned bitcnt; bitset_bindex bitoff; bitset_word *srcp = ABITSET_WORDS (src); bitset_bindex n_bits = BITSET_SIZE_ (src); @@ -302,7 +302,7 @@ abitset_list (bitset src, bitset_bindex *list, static inline void abitset_unused_clear (bitset dst) { - unsigned int last_bit; + unsigned last_bit; last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS; if (last_bit) diff --git a/contrib/tools/bison/lib/abitset.h b/contrib/tools/bison/lib/abitset.h index f66122894a..65d4842751 100644 --- a/contrib/tools/bison/lib/abitset.h +++ b/contrib/tools/bison/lib/abitset.h @@ -1,6 +1,7 @@ /* Functions to support abitsets. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). diff --git a/contrib/tools/bison/lib/argmatch.c b/contrib/tools/bison/lib/argmatch.c index 9125e2af04..5c2202b4d2 100644 --- a/contrib/tools/bison/lib/argmatch.c +++ b/contrib/tools/bison/lib/argmatch.c @@ -1,6 +1,6 @@ /* argmatch.c -- find a match for a string in an array - Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2013 Free Software + Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by David MacKenzie <djm@ai.mit.edu> Modified by Akim Demaille <demaille@inf.enst.fr> */ @@ -35,6 +35,7 @@ #include "error.h" #include "quotearg.h" #include "quote.h" +#include "getprogname.h" #if USE_UNLOCKED_IO # include "unlocked-io.h" @@ -209,7 +210,6 @@ argmatch_to_argument (const char *value, /* * Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu> */ -char *program_name; /* When to make backup files. */ enum backup_type @@ -253,11 +253,9 @@ main (int argc, const char *const *argv) const char *cp; enum backup_type backup_type = no_backups; - program_name = (char *) argv[0]; - if (argc > 2) { - fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name); + fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ()); exit (1); } @@ -266,7 +264,7 @@ main (int argc, const char *const *argv) backup_args, backup_vals); if (argc == 2) - backup_type = XARGMATCH (program_name, argv[1], + backup_type = XARGMATCH (getprogname (), argv[1], backup_args, backup_vals); printf ("The version control is '%s'\n", diff --git a/contrib/tools/bison/lib/argmatch.h b/contrib/tools/bison/lib/argmatch.h index e4c8027144..e6b4c48f06 100644 --- a/contrib/tools/bison/lib/argmatch.h +++ b/contrib/tools/bison/lib/argmatch.h @@ -1,6 +1,6 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2013 Free Software + Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by David MacKenzie <djm@ai.mit.edu> Modified by Akim Demaille <demaille@inf.enst.fr> */ diff --git a/contrib/tools/bison/lib/asnprintf.c b/contrib/tools/bison/lib/asnprintf.c index 76e228d860..2298455b4a 100644 --- a/contrib/tools/bison/lib/asnprintf.c +++ b/contrib/tools/bison/lib/asnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/basename-lgpl.c b/contrib/tools/bison/lib/basename-lgpl.c index 9307e83142..33f9994f22 100644 --- a/contrib/tools/bison/lib/basename-lgpl.c +++ b/contrib/tools/bison/lib/basename-lgpl.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/basename.c b/contrib/tools/bison/lib/basename.c index d73fd41aa1..02adb8c3d1 100644 --- a/contrib/tools/bison/lib/basename.c +++ b/contrib/tools/bison/lib/basename.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/bbitset.h b/contrib/tools/bison/lib/bbitset.h index 443d2da2e8..d0e7c17c26 100644 --- a/contrib/tools/bison/lib/bbitset.h +++ b/contrib/tools/bison/lib/bbitset.h @@ -1,7 +1,7 @@ /* Base bitset stuff. - Copyright (C) 2002-2004, 2006, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software + Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -50,8 +50,8 @@ extern const char * const bitset_type_names[]; enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC}; /* Data type used to store a word of bits. */ -typedef unsigned long int bitset_word; -#define BITSET_WORD_BITS ((unsigned int) (CHAR_BIT * sizeof (bitset_word))) +typedef unsigned long bitset_word; +#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word))) /* Bit index. In theory we might need a type wider than size_t, but in practice we lose at most a factor of CHAR_BIT by going with diff --git a/contrib/tools/bison/lib/binary-io.c b/contrib/tools/bison/lib/binary-io.c index 8bbdb44d12..f9cc4dd2ec 100644 --- a/contrib/tools/bison/lib/binary-io.c +++ b/contrib/tools/bison/lib/binary-io.c @@ -1,3 +1,37 @@ +/* Binary mode I/O. + Copyright 2017-2018 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + #include <config.h> + #define BINARY_IO_INLINE _GL_EXTERN_INLINE #include "binary-io.h" + +#if defined __DJGPP__ || defined __EMX__ +# include <errno.h> +# include <unistd.h> + +int +__gl_setmode_check (int fd) +{ + if (isatty (fd)) + { + errno = EINVAL; + return -1; + } + else + return 0; +} +#endif diff --git a/contrib/tools/bison/lib/binary-io.h b/contrib/tools/bison/lib/binary-io.h index 7b4a4c0a1b..7d3c4dfbaa 100644 --- a/contrib/tools/bison/lib/binary-io.h +++ b/contrib/tools/bison/lib/binary-io.h @@ -1,5 +1,5 @@ /* Binary mode I/O. - Copyright (C) 2001, 2003, 2005, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _BINARY_H #define _BINARY_H @@ -33,20 +33,20 @@ #define O_TEXT 0 #endif +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif _GL_INLINE_HEADER_BEGIN #ifndef BINARY_IO_INLINE # define BINARY_IO_INLINE _GL_INLINE #endif -/* set_binary_mode (fd, mode) - sets the binary/text I/O mode of file descriptor fd to the given mode - (must be O_BINARY or O_TEXT) and returns the previous mode. */ #if O_BINARY # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ # include <io.h> /* declares setmode() */ -# define set_binary_mode setmode +# define __gl_setmode setmode # else -# define set_binary_mode _setmode +# define __gl_setmode _setmode # undef fileno # define fileno _fileno # endif @@ -55,26 +55,35 @@ _GL_INLINE_HEADER_BEGIN /* Use a function rather than a macro, to avoid gcc warnings "warning: statement with no effect". */ BINARY_IO_INLINE int -set_binary_mode (int fd, int mode) +__gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED) { - (void) fd; - (void) mode; return O_BINARY; } #endif -/* SET_BINARY (fd); - changes the file descriptor fd to perform binary I/O. */ -#ifdef __DJGPP__ -# include <unistd.h> /* declares isatty() */ - /* Avoid putting stdin/stdout in binary mode if it is connected to - the console, because that would make it impossible for the user - to interrupt the program through Ctrl-C or Ctrl-Break. */ -# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0)) +#if defined __DJGPP__ || defined __EMX__ +extern int __gl_setmode_check (int); #else -# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY)) +BINARY_IO_INLINE int +__gl_setmode_check (int fd _GL_UNUSED) { return 0; } #endif +/* Set FD's mode to MODE, which should be either O_TEXT or O_BINARY. + Return the old mode if successful, -1 (setting errno) on failure. + Ordinarily this function would be called 'setmode', since that is + its name on MS-Windows, but it is called 'set_binary_mode' here + to avoid colliding with a BSD function of another name. */ + +BINARY_IO_INLINE int +set_binary_mode (int fd, int mode) +{ + int r = __gl_setmode_check (fd); + return r != 0 ? r : __gl_setmode (fd, mode); +} + +/* This macro is obsolescent. */ +#define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY)) + _GL_INLINE_HEADER_END #endif /* _BINARY_H */ diff --git a/contrib/tools/bison/lib/bitrotate.h b/contrib/tools/bison/lib/bitrotate.h index 9e10a45f43..9eb6a6f42d 100644 --- a/contrib/tools/bison/lib/bitrotate.h +++ b/contrib/tools/bison/lib/bitrotate.h @@ -1,5 +1,5 @@ /* bitrotate.h - Rotate bits in integers - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Simon Josefsson <simon@josefsson.org>, 2008. */ @@ -23,6 +23,9 @@ #include <stdint.h> #include <sys/types.h> +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif _GL_INLINE_HEADER_BEGIN #ifndef BITROTATE_INLINE # define BITROTATE_INLINE _GL_INLINE diff --git a/contrib/tools/bison/lib/bitset.c b/contrib/tools/bison/lib/bitset.c index f7a9996afb..97a60ef4e3 100644 --- a/contrib/tools/bison/lib/bitset.c +++ b/contrib/tools/bison/lib/bitset.c @@ -1,6 +1,7 @@ /* General bitsets. - Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -100,7 +101,7 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) specified by ATTR. For variable size bitsets, N_BITS is only a hint and may be zero. */ enum bitset_type -bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned int attr) +bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr) { /* Check attributes. */ if (attr & BITSET_FIXED && attr & BITSET_VARIABLE) @@ -168,7 +169,7 @@ bitset_obstack_alloc (struct obstack *bobstack, /* Create a bitset of N_BITS and with attribute hints specified by ATTR. */ bitset -bitset_create (bitset_bindex n_bits, unsigned int attr) +bitset_create (bitset_bindex n_bits, unsigned attr) { enum bitset_type type; @@ -290,13 +291,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno) static void bitset_print (FILE *file, bitset bset, bool verbose) { - unsigned int pos; + unsigned pos; bitset_bindex i; bitset_iterator iter; if (verbose) fprintf (file, "n_bits = %lu, set = {", - (unsigned long int) bitset_size (bset)); + (unsigned long) bitset_size (bset)); pos = 30; BITSET_FOR_EACH (iter, bset, i, 0) @@ -307,7 +308,7 @@ bitset_print (FILE *file, bitset bset, bool verbose) pos = 0; } - fprintf (file, "%lu ", (unsigned long int) i); + fprintf (file, "%lu ", (unsigned long) i); pos += 1 + (i >= 10) + (i >= 100); }; diff --git a/contrib/tools/bison/lib/bitset.h b/contrib/tools/bison/lib/bitset.h index ef44ea4cf8..48bd2300b9 100644 --- a/contrib/tools/bison/lib/bitset.h +++ b/contrib/tools/bison/lib/bitset.h @@ -1,6 +1,7 @@ /* Generic bitsets. - Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -39,7 +40,7 @@ enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */ BITSET_FRUGAL = 16, /* Prefer most compact. */ BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */ -typedef unsigned int bitset_attrs; +typedef unsigned bitset_attrs; /* The contents of the union should be considered to be private. While I would like to make this union opaque, it needs to be @@ -309,7 +310,7 @@ extern void bitset_dump (FILE *, bitset); BITSET_FOR_EACH (iter, src, i, 0) { - printf ("%lu ", (unsigned long int) i); + printf ("%lu ", (unsigned long) i); }; */ #define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \ @@ -331,7 +332,7 @@ extern void bitset_dump (FILE *, bitset); BITSET_FOR_EACH_REVERSE (iter, src, i, 0) { - printf ("%lu ", (unsigned long int) i); + printf ("%lu ", (unsigned long) i); }; */ #define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \ diff --git a/contrib/tools/bison/lib/bitset_stats.c b/contrib/tools/bison/lib/bitset_stats.c index 8316302616..dc8aae50d7 100644 --- a/contrib/tools/bison/lib/bitset_stats.c +++ b/contrib/tools/bison/lib/bitset_stats.c @@ -1,6 +1,7 @@ /* Bitset statistics. - Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -76,23 +77,23 @@ struct bitset_type_info_struct { - unsigned int allocs; - unsigned int frees; - unsigned int lists; - unsigned int sets; - unsigned int cache_sets; - unsigned int resets; - unsigned int cache_resets; - unsigned int tests; - unsigned int cache_tests; - unsigned int list_counts[BITSET_LOG_COUNT_BINS]; - unsigned int list_sizes[BITSET_LOG_SIZE_BINS]; - unsigned int list_density[BITSET_DENSITY_BINS]; + unsigned allocs; + unsigned frees; + unsigned lists; + unsigned sets; + unsigned cache_sets; + unsigned resets; + unsigned cache_resets; + unsigned tests; + unsigned cache_tests; + unsigned list_counts[BITSET_LOG_COUNT_BINS]; + unsigned list_sizes[BITSET_LOG_SIZE_BINS]; + unsigned list_density[BITSET_DENSITY_BINS]; }; struct bitset_stats_info_struct { - unsigned int runs; + unsigned runs; struct bitset_type_info_struct types[BITSET_TYPE_NUM]; }; @@ -105,10 +106,10 @@ bool bitset_stats_enabled = false; /* Print a percentage histogram with message MSG to FILE. */ static void bitset_percent_histogram_print (FILE *file, const char *name, const char *msg, - unsigned int n_bins, unsigned int *bins) + unsigned n_bins, unsigned *bins) { - unsigned int i; - unsigned int total; + unsigned i; + unsigned total; total = 0; for (i = 0; i < n_bins; i++) @@ -129,11 +130,11 @@ bitset_percent_histogram_print (FILE *file, const char *name, const char *msg, /* Print a log histogram with message MSG to FILE. */ static void bitset_log_histogram_print (FILE *file, const char *name, const char *msg, - unsigned int n_bins, unsigned int *bins) + unsigned n_bins, unsigned *bins) { - unsigned int i; - unsigned int total; - unsigned int max_width; + unsigned i; + unsigned total; + unsigned max_width; total = 0; for (i = 0; i < n_bins; i++) @@ -148,7 +149,7 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg, n_bins = i; /* 2 * ceil (log10 (2) * (N - 1)) + 1. */ - max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1; + max_width = 2 * (unsigned) (0.30103 * (n_bins - 1) + 0.9999) + 1; fprintf (file, "%s %s", name, msg); for (i = 0; i < 2; i++) @@ -157,7 +158,7 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg, for (; i < n_bins; i++) fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n", - max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1), + max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1), 1UL << (i - 1), (1UL << i) - 1, bins[i], diff --git a/contrib/tools/bison/lib/bitset_stats.h b/contrib/tools/bison/lib/bitset_stats.h index d65fcad93c..f1e213f984 100644 --- a/contrib/tools/bison/lib/bitset_stats.h +++ b/contrib/tools/bison/lib/bitset_stats.h @@ -1,6 +1,7 @@ /* Functions to support bitset statistics. - Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). diff --git a/contrib/tools/bison/lib/bitsetv-print.c b/contrib/tools/bison/lib/bitsetv-print.c index dd544a9c9e..798a81acc3 100644 --- a/contrib/tools/bison/lib/bitsetv-print.c +++ b/contrib/tools/bison/lib/bitsetv-print.c @@ -1,6 +1,6 @@ /* Bitset vectors. - Copyright (C) 2001-2002, 2004, 2006, 2009-2013 Free Software + Copyright (C) 2001-2002, 2004, 2006, 2009-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -54,7 +54,7 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset) /* Contents. */ for (i = 0; bset[i]; ++i) { - fprintf (out, "%2lu|", (unsigned long int) i); + fprintf (out, "%2lu|", (unsigned long) i); for (j = 0; j < hsize; ++j) fputs (bitset_test (bset[i], j) ? "1" : " ", out); fputs ("|\n", out); diff --git a/contrib/tools/bison/lib/bitsetv-print.h b/contrib/tools/bison/lib/bitsetv-print.h index a7cc8bc106..f1ba11829a 100644 --- a/contrib/tools/bison/lib/bitsetv-print.h +++ b/contrib/tools/bison/lib/bitsetv-print.h @@ -1,6 +1,7 @@ /* Bitset vectors. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Akim Demaille (akim@freefriends.org). diff --git a/contrib/tools/bison/lib/bitsetv.c b/contrib/tools/bison/lib/bitsetv.c index 2bdf1bfa1a..1d3213bf38 100644 --- a/contrib/tools/bison/lib/bitsetv.c +++ b/contrib/tools/bison/lib/bitsetv.c @@ -1,6 +1,6 @@ /* Bitset vectors. - Copyright (C) 2001-2002, 2004-2006, 2009-2013 Free Software + Copyright (C) 2001-2002, 2004-2006, 2009-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -62,7 +62,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits, /* Create a vector of N_VECS bitsets, each of N_BITS, and with attribute hints specified by ATTR. */ bitset * -bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned int attr) +bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr) { enum bitset_type type; @@ -146,7 +146,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle, fprintf (file, "%s\n", title); for (i = 0; bsetv[i]; i++) { - fprintf (file, "%s %lu\n", subtitle, (unsigned long int) i); + fprintf (file, "%s %lu\n", subtitle, (unsigned long) i); bitset_dump (file, bsetv[i]); } @@ -161,7 +161,7 @@ debug_bitsetv (bitsetv bsetv) for (i = 0; bsetv[i]; i++) { - fprintf (stderr, "%lu: ", (unsigned long int) i); + fprintf (stderr, "%lu: ", (unsigned long) i); debug_bitset (bsetv[i]); } diff --git a/contrib/tools/bison/lib/bitsetv.h b/contrib/tools/bison/lib/bitsetv.h index 2472a82a5c..56e0de7dca 100644 --- a/contrib/tools/bison/lib/bitsetv.h +++ b/contrib/tools/bison/lib/bitsetv.h @@ -1,6 +1,7 @@ /* Bitset vectors. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -30,7 +31,7 @@ extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type); /* Create a vector of N_VECS bitsets, each of N_BITS, and with attribute hints specified by ATTR. */ -extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned int); +extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned); /* Free vector of bitsets. */ extern void bitsetv_free (bitsetv); diff --git a/contrib/tools/bison/lib/c-ctype.c b/contrib/tools/bison/lib/c-ctype.c index 752d2e32ae..5d9d4d87a6 100644 --- a/contrib/tools/bison/lib/c-ctype.c +++ b/contrib/tools/bison/lib/c-ctype.c @@ -1,395 +1,3 @@ -/* Character handling in C locale. - - Copyright 2000-2003, 2006, 2009-2013 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ -#define NO_C_CTYPE_MACROS +#define C_CTYPE_INLINE _GL_EXTERN_INLINE #include "c-ctype.h" - -/* The function isascii is not locale dependent. Its use in EBCDIC is - questionable. */ -bool -c_isascii (int c) -{ - return (c >= 0x00 && c <= 0x7f); -} - -bool -c_isalnum (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isalpha (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); -#else - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isblank (int c) -{ - return (c == ' ' || c == '\t'); -} - -bool -c_iscntrl (int c) -{ -#if C_CTYPE_ASCII - return ((c & ~0x1f) == 0 || c == 0x7f); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 0; - default: - return 1; - } -#endif -} - -bool -c_isdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS - return (c >= '0' && c <= '9'); -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - return 1; - default: - return 0; - } -#endif -} - -bool -c_islower (int c) -{ -#if C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z'); -#else - switch (c) - { - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isgraph (int c) -{ -#if C_CTYPE_ASCII - return (c >= '!' && c <= '~'); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isprint (int c) -{ -#if C_CTYPE_ASCII - return (c >= ' ' && c <= '~'); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_ispunct (int c) -{ -#if C_CTYPE_ASCII - return ((c >= '!' && c <= '~') - && !((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case '[': case '\\': case ']': case '^': case '_': case '`': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isspace (int c) -{ - return (c == ' ' || c == '\t' - || c == '\n' || c == '\v' || c == '\f' || c == '\r'); -} - -bool -c_isupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE - return (c >= 'A' && c <= 'Z'); -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isxdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'F') - || (c >= 'a' && c <= 'f')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - default: - return 0; - } -#endif -} - -int -c_tolower (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c); -#else - switch (c) - { - case 'A': return 'a'; - case 'B': return 'b'; - case 'C': return 'c'; - case 'D': return 'd'; - case 'E': return 'e'; - case 'F': return 'f'; - case 'G': return 'g'; - case 'H': return 'h'; - case 'I': return 'i'; - case 'J': return 'j'; - case 'K': return 'k'; - case 'L': return 'l'; - case 'M': return 'm'; - case 'N': return 'n'; - case 'O': return 'o'; - case 'P': return 'p'; - case 'Q': return 'q'; - case 'R': return 'r'; - case 'S': return 's'; - case 'T': return 't'; - case 'U': return 'u'; - case 'V': return 'v'; - case 'W': return 'w'; - case 'X': return 'x'; - case 'Y': return 'y'; - case 'Z': return 'z'; - default: return c; - } -#endif -} - -int -c_toupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); -#else - switch (c) - { - case 'a': return 'A'; - case 'b': return 'B'; - case 'c': return 'C'; - case 'd': return 'D'; - case 'e': return 'E'; - case 'f': return 'F'; - case 'g': return 'G'; - case 'h': return 'H'; - case 'i': return 'I'; - case 'j': return 'J'; - case 'k': return 'K'; - case 'l': return 'L'; - case 'm': return 'M'; - case 'n': return 'N'; - case 'o': return 'O'; - case 'p': return 'P'; - case 'q': return 'Q'; - case 'r': return 'R'; - case 's': return 'S'; - case 't': return 'T'; - case 'u': return 'U'; - case 'v': return 'V'; - case 'w': return 'W'; - case 'x': return 'X'; - case 'y': return 'Y'; - case 'z': return 'Z'; - default: return c; - } -#endif -} diff --git a/contrib/tools/bison/lib/c-ctype.h b/contrib/tools/bison/lib/c-ctype.h index ad589b5c20..d55d4f64e4 100644 --- a/contrib/tools/bison/lib/c-ctype.h +++ b/contrib/tools/bison/lib/c-ctype.h @@ -5,7 +5,7 @@ <ctype.h> functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +18,20 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, see <http://www.gnu.org/licenses/>. */ +along with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef C_CTYPE_H #define C_CTYPE_H #include <stdbool.h> +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef C_CTYPE_INLINE +# define C_CTYPE_INLINE _GL_INLINE +#endif #ifdef __cplusplus extern "C" { @@ -39,38 +46,6 @@ extern "C" { characters. */ -/* Check whether the ASCII optimizations apply. */ - -/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that - '0', '1', ..., '9' have consecutive integer values. */ -#define C_CTYPE_CONSECUTIVE_DIGITS 1 - -#if ('A' <= 'Z') \ - && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ - && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ - && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ - && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \ - && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \ - && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \ - && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ - && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ - && ('Y' + 1 == 'Z') -#define C_CTYPE_CONSECUTIVE_UPPERCASE 1 -#endif - -#if ('a' <= 'z') \ - && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ - && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ - && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ - && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \ - && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \ - && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \ - && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ - && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ - && ('y' + 1 == 'z') -#define C_CTYPE_CONSECUTIVE_LOWERCASE 1 -#endif - #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ @@ -96,11 +71,84 @@ extern "C" { && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* The character set is ASCII or one of its variants or extensions, not EBCDIC. Testing the value of '\n' and '\r' is not relevant. */ -#define C_CTYPE_ASCII 1 +# define C_CTYPE_ASCII 1 +#elif ! (' ' == '\x40' && '0' == '\xf0' \ + && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \ + && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2') +# error "Only ASCII and EBCDIC are supported" #endif +#if 'A' < 0 +# error "EBCDIC and char is signed -- not supported" +#endif + +/* Cases for control characters. */ + +#define _C_CTYPE_CNTRL \ + case '\a': case '\b': case '\f': case '\n': \ + case '\r': case '\t': case '\v': \ + _C_CTYPE_OTHER_CNTRL + +/* ASCII control characters other than those with \-letter escapes. */ + +#if C_CTYPE_ASCII +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x04': case '\x05': case '\x06': case '\x0e': \ + case '\x0f': case '\x10': case '\x11': case '\x12': \ + case '\x13': case '\x14': case '\x15': case '\x16': \ + case '\x17': case '\x18': case '\x19': case '\x1a': \ + case '\x1b': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x7f' +#else + /* Use EBCDIC code page 1047's assignments for ASCII control chars; + assume all EBCDIC code pages agree about these assignments. */ +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x07': case '\x0e': case '\x0f': case '\x10': \ + case '\x11': case '\x12': case '\x13': case '\x18': \ + case '\x19': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x26': case '\x27': case '\x2d': \ + case '\x2e': case '\x32': case '\x37': case '\x3c': \ + case '\x3d': case '\x3f' +#endif -/* Function declarations. */ +/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */ + +#define _C_CTYPE_LOWER_A_THRU_F_N(N) \ + case 'a' + (N): case 'b' + (N): case 'c' + (N): case 'd' + (N): \ + case 'e' + (N): case 'f' + (N) +#define _C_CTYPE_LOWER_N(N) \ + _C_CTYPE_LOWER_A_THRU_F_N(N): \ + case 'g' + (N): case 'h' + (N): case 'i' + (N): case 'j' + (N): \ + case 'k' + (N): case 'l' + (N): case 'm' + (N): case 'n' + (N): \ + case 'o' + (N): case 'p' + (N): case 'q' + (N): case 'r' + (N): \ + case 's' + (N): case 't' + (N): case 'u' + (N): case 'v' + (N): \ + case 'w' + (N): case 'x' + (N): case 'y' + (N): case 'z' + (N) + +/* Cases for hex letters, digits, lower, punct, and upper. */ + +#define _C_CTYPE_A_THRU_F \ + _C_CTYPE_LOWER_A_THRU_F_N (0): \ + _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a') +#define _C_CTYPE_DIGIT \ + case '0': case '1': case '2': case '3': \ + case '4': case '5': case '6': case '7': \ + case '8': case '9' +#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0) +#define _C_CTYPE_PUNCT \ + case '!': case '"': case '#': case '$': \ + case '%': case '&': case '\'': case '(': \ + case ')': case '*': case '+': case ',': \ + case '-': case '.': case '/': case ':': \ + case ';': case '<': case '=': case '>': \ + case '?': case '@': case '[': case '\\': \ + case ']': case '^': case '_': case '`': \ + case '{': case '|': case '}': case '~' +#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a') + + +/* Function definitions. */ /* Unlike the functions in <ctype.h>, which require an argument in the range of the 'unsigned char' type, the functions here operate on values that are @@ -117,179 +165,202 @@ extern "C" { if (c_isalpha (*s)) ... */ -extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */ - -extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST; -extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST; -extern bool c_islower (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST; -extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST; - -extern int c_tolower (int c) _GL_ATTRIBUTE_CONST; -extern int c_toupper (int c) _GL_ATTRIBUTE_CONST; - - -#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \ - && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS) - -/* ASCII optimizations. */ - -#undef c_isascii -#define c_isascii(c) \ - ({ int __c = (c); \ - (__c >= 0x00 && __c <= 0x7f); \ - }) +C_CTYPE_INLINE bool +c_isalnum (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isalnum -#define c_isalnum(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \ - }) -#else -#undef c_isalnum -#define c_isalnum(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || (__c >= 'A' && __c <= 'Z') \ - || (__c >= 'a' && __c <= 'z')); \ - }) -#endif -#endif +C_CTYPE_INLINE bool +c_isalpha (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isalpha -#define c_isalpha(c) \ - ({ int __c = (c); \ - ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ - }) -#else -#undef c_isalpha -#define c_isalpha(c) \ - ({ int __c = (c); \ - ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ - }) -#endif -#endif +/* The function isascii is not locale dependent. + Its use in EBCDIC is questionable. */ +C_CTYPE_INLINE bool +c_isascii (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_CNTRL: + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#undef c_isblank -#define c_isblank(c) \ - ({ int __c = (c); \ - (__c == ' ' || __c == '\t'); \ - }) +C_CTYPE_INLINE bool +c_isblank (int c) +{ + return c == ' ' || c == '\t'; +} -#if C_CTYPE_ASCII -#undef c_iscntrl -#define c_iscntrl(c) \ - ({ int __c = (c); \ - ((__c & ~0x1f) == 0 || __c == 0x7f); \ - }) -#endif +C_CTYPE_INLINE bool +c_iscntrl (int c) +{ + switch (c) + { + _C_CTYPE_CNTRL: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS -#undef c_isdigit -#define c_isdigit(c) \ - ({ int __c = (c); \ - (__c >= '0' && __c <= '9'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_LOWERCASE -#undef c_islower -#define c_islower(c) \ - ({ int __c = (c); \ - (__c >= 'a' && __c <= 'z'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isgraph (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_isgraph -#define c_isgraph(c) \ - ({ int __c = (c); \ - (__c >= '!' && __c <= '~'); \ - }) -#endif +C_CTYPE_INLINE bool +c_islower (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_isprint -#define c_isprint(c) \ - ({ int __c = (c); \ - (__c >= ' ' && __c <= '~'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isprint (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_ispunct -#define c_ispunct(c) \ - ({ int _c = (c); \ - (c_isgraph (_c) && ! c_isalnum (_c)); \ - }) -#endif +C_CTYPE_INLINE bool +c_ispunct (int c) +{ + switch (c) + { + _C_CTYPE_PUNCT: + return true; + default: + return false; + } +} -#undef c_isspace -#define c_isspace(c) \ - ({ int __c = (c); \ - (__c == ' ' || __c == '\t' \ - || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ - }) - -#if C_CTYPE_CONSECUTIVE_UPPERCASE -#undef c_isupper -#define c_isupper(c) \ - ({ int __c = (c); \ - (__c >= 'A' && __c <= 'Z'); \ - }) -#endif +C_CTYPE_INLINE bool +c_isspace (int c) +{ + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#undef c_isxdigit -#define c_isxdigit(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \ - }) -#else -#undef c_isxdigit -#define c_isxdigit(c) \ - ({ int __c = (c); \ - ((__c >= '0' && __c <= '9') \ - || (__c >= 'A' && __c <= 'F') \ - || (__c >= 'a' && __c <= 'f')); \ - }) -#endif -#endif +C_CTYPE_INLINE bool +c_isupper (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#undef c_tolower -#define c_tolower(c) \ - ({ int __c = (c); \ - (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \ - }) -#undef c_toupper -#define c_toupper(c) \ - ({ int __c = (c); \ - (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \ - }) -#endif +C_CTYPE_INLINE bool +c_isxdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_A_THRU_F: + return true; + default: + return false; + } +} -#endif /* optimizing for speed */ +C_CTYPE_INLINE int +c_tolower (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return c - 'A' + 'a'; + default: + return c; + } +} +C_CTYPE_INLINE int +c_toupper (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return c - 'a' + 'A'; + default: + return c; + } +} #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* C_CTYPE_H */ diff --git a/contrib/tools/bison/lib/c-strcase.h b/contrib/tools/bison/lib/c-strcase.h index 49e1bb03dd..41f439e8de 100644 --- a/contrib/tools/bison/lib/c-strcase.h +++ b/contrib/tools/bison/lib/c-strcase.h @@ -1,5 +1,5 @@ /* Case-insensitive string comparison functions in C locale. - Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2013 Free Software + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef C_STRCASE_H #define C_STRCASE_H diff --git a/contrib/tools/bison/lib/c-strcasecmp.c b/contrib/tools/bison/lib/c-strcasecmp.c index ef85f0e67d..2b1ac99bb6 100644 --- a/contrib/tools/bison/lib/c-strcasecmp.c +++ b/contrib/tools/bison/lib/c-strcasecmp.c @@ -1,5 +1,5 @@ /* c-strcasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/c-strcaseeq.h b/contrib/tools/bison/lib/c-strcaseeq.h index afdea26ba9..9bde9de6af 100644 --- a/contrib/tools/bison/lib/c-strcaseeq.h +++ b/contrib/tools/bison/lib/c-strcaseeq.h @@ -1,5 +1,5 @@ /* Optimized case-insensitive string comparison in C locale. - Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -12,7 +12,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>. */ @@ -33,9 +33,6 @@ # if C_CTYPE_ASCII # define CASEEQ(other,upper) \ (c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper)) -# elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -# define CASEEQ(other,upper) \ - (c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' : (other) == (upper)) # else # define CASEEQ(other,upper) \ (c_toupper (other) == (upper)) diff --git a/contrib/tools/bison/lib/c-strncasecmp.c b/contrib/tools/bison/lib/c-strncasecmp.c index 04404b00cd..8151c1a834 100644 --- a/contrib/tools/bison/lib/c-strncasecmp.c +++ b/contrib/tools/bison/lib/c-strncasecmp.c @@ -1,5 +1,5 @@ /* c-strncasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/cloexec.c b/contrib/tools/bison/lib/cloexec.c index e3e42d2855..238ab18886 100644 --- a/contrib/tools/bison/lib/cloexec.c +++ b/contrib/tools/bison/lib/cloexec.c @@ -1,6 +1,6 @@ -/* closexec.c - set or clear the close-on-exec descriptor flag +/* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 1991, 2004-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1991, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this program. If not, see <https://www.gnu.org/licenses/>. The code is taken from glibc/manual/llio.texi */ diff --git a/contrib/tools/bison/lib/cloexec.h b/contrib/tools/bison/lib/cloexec.h index 0c5935ba56..59028058e6 100644 --- a/contrib/tools/bison/lib/cloexec.h +++ b/contrib/tools/bison/lib/cloexec.h @@ -1,6 +1,6 @@ -/* closexec.c - set or clear the close-on-exec descriptor flag +/* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this program. If not, see <https://www.gnu.org/licenses/>. */ diff --git a/contrib/tools/bison/lib/close-stream.c b/contrib/tools/bison/lib/close-stream.c index d6a869287e..3d5a52ebd8 100644 --- a/contrib/tools/bison/lib/close-stream.c +++ b/contrib/tools/bison/lib/close-stream.c @@ -1,6 +1,6 @@ /* Close a stream, with nicer error checking than fclose's. - Copyright (C) 1998-2002, 2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2006-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/close.c b/contrib/tools/bison/lib/close.c index f620e54bba..01c326a28c 100644 --- a/contrib/tools/bison/lib/close.c +++ b/contrib/tools/bison/lib/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -22,7 +22,9 @@ #include <errno.h> #include "fd-hook.h" -#include "msvc-inval.h" +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif #undef close diff --git a/contrib/tools/bison/lib/closeout.c b/contrib/tools/bison/lib/closeout.c index d4d3edca4e..0672732b63 100644 --- a/contrib/tools/bison/lib/closeout.c +++ b/contrib/tools/bison/lib/closeout.c @@ -1,6 +1,6 @@ /* Close standard output and standard error, exiting with a diagnostic on error. - Copyright (C) 1998-2002, 2004, 2006, 2008-2013 Free Software Foundation, + Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -33,6 +33,16 @@ #include "exitfail.h" #include "quotearg.h" +#ifndef __has_feature +# define __has_feature(a) false +#endif + +#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) +enum { SANITIZE_ADDRESS = true }; +#else +enum { SANITIZE_ADDRESS = false }; +#endif + static const char *file_name; /* Set the file name to be reported in the event an error is detected @@ -119,6 +129,8 @@ close_stdout (void) _exit (exit_failure); } - if (close_stream (stderr) != 0) - _exit (exit_failure); + /* Close stderr only if not sanitizing, as sanitizers may report to + stderr after this function returns. */ + if (!SANITIZE_ADDRESS && close_stream (stderr) != 0) + _exit (exit_failure); } diff --git a/contrib/tools/bison/lib/closeout.h b/contrib/tools/bison/lib/closeout.h index 131fe864ec..6629d49934 100644 --- a/contrib/tools/bison/lib/closeout.h +++ b/contrib/tools/bison/lib/closeout.h @@ -1,6 +1,6 @@ /* Close standard output and standard error. - Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2013 Free Software + Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef CLOSEOUT_H # define CLOSEOUT_H 1 diff --git a/contrib/tools/bison/lib/concat-filename.c b/contrib/tools/bison/lib/concat-filename.c index 68168dcd53..578cb21fe3 100644 --- a/contrib/tools/bison/lib/concat-filename.c +++ b/contrib/tools/bison/lib/concat-filename.c @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <haible@clisp.cons.org>. */ diff --git a/contrib/tools/bison/lib/concat-filename.h b/contrib/tools/bison/lib/concat-filename.h index 898dcee2d6..cca9597d07 100644 --- a/contrib/tools/bison/lib/concat-filename.h +++ b/contrib/tools/bison/lib/concat-filename.h @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _CONCAT_FILENAME_H #define _CONCAT_FILENAME_H diff --git a/contrib/tools/bison/lib/config-linux.h b/contrib/tools/bison/lib/config-linux.h index 72ac3690de..5322cd67cf 100644 --- a/contrib/tools/bison/lib/config-linux.h +++ b/contrib/tools/bison/lib/config-linux.h @@ -1,6 +1,111 @@ /* lib/config.h. Generated from config.in.h by configure. */ /* lib/config.in.h. Generated from configure.ac by autoheader. */ +/* CPU and C ABI indicator */ +#ifndef __i386__ +/* #undef __i386__ */ +#endif +#ifndef __x86_64_x32__ +/* #undef __x86_64_x32__ */ +#endif +#ifndef __alpha__ +/* #undef __alpha__ */ +#endif +#ifndef __arm__ +/* #undef __arm__ */ +#endif +#ifndef __armhf__ +/* #undef __armhf__ */ +#endif +#ifndef __arm64_ilp32__ +/* #undef __arm64_ilp32__ */ +#endif +#ifndef __arm64__ +/* #undef __arm64__ */ +#endif +#ifndef __hppa__ +/* #undef __hppa__ */ +#endif +#ifndef __hppa64__ +/* #undef __hppa64__ */ +#endif +#ifndef __ia64_ilp32__ +/* #undef __ia64_ilp32__ */ +#endif +#ifndef __ia64__ +/* #undef __ia64__ */ +#endif +#ifndef __m68k__ +/* #undef __m68k__ */ +#endif +#ifndef __mips__ +/* #undef __mips__ */ +#endif +#ifndef __mipsn32__ +/* #undef __mipsn32__ */ +#endif +#ifndef __mips64__ +/* #undef __mips64__ */ +#endif +#ifndef __powerpc__ +/* #undef __powerpc__ */ +#endif +#ifndef __powerpc64__ +/* #undef __powerpc64__ */ +#endif +#ifndef __powerpc64_elfv2__ +/* #undef __powerpc64_elfv2__ */ +#endif +#ifndef __riscv32__ +/* #undef __riscv32__ */ +#endif +#ifndef __riscv64__ +/* #undef __riscv64__ */ +#endif +#ifndef __riscv32_ilp32__ +/* #undef __riscv32_ilp32__ */ +#endif +#ifndef __riscv32_ilp32f__ +/* #undef __riscv32_ilp32f__ */ +#endif +#ifndef __riscv32_ilp32d__ +/* #undef __riscv32_ilp32d__ */ +#endif +#ifndef __riscv64_ilp32__ +/* #undef __riscv64_ilp32__ */ +#endif +#ifndef __riscv64_ilp32f__ +/* #undef __riscv64_ilp32f__ */ +#endif +#ifndef __riscv64_ilp32d__ +/* #undef __riscv64_ilp32d__ */ +#endif +#ifndef __riscv64_lp64__ +/* #undef __riscv64_lp64__ */ +#endif +#ifndef __riscv64_lp64f__ +/* #undef __riscv64_lp64f__ */ +#endif +#ifndef __riscv64_lp64d__ +/* #undef __riscv64_lp64d__ */ +#endif +#ifndef __s390__ +/* #undef __s390__ */ +#endif +#ifndef __s390x__ +/* #undef __s390x__ */ +#endif +#ifndef __sh__ +/* #undef __sh__ */ +#endif +#ifndef __sparc__ +/* #undef __sparc__ */ +#endif +#ifndef __sparc64__ +/* #undef __sparc64__ */ +#endif + + /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ @@ -31,6 +136,9 @@ /* Define to 1 if using `alloca.c'. */ /* #undef C_ALLOCA */ +/* Define to 1 if the C locale may have encoding errors. */ +#define C_LOCALE_MAYBE_EILSEQ 1 + /* Define as the bit index in the word where to find bit 0 of the exponent of 'double'. */ #define DBL_EXPBIT0_BIT 20 @@ -99,9 +207,17 @@ #define GNULIB_MALLOC_GNU 1 /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module msvc-nothrow shall be considered present. */ +#define GNULIB_MSVC_NOTHROW 1 + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module pipe2-safer shall be considered present. */ #define GNULIB_PIPE2_SAFER 1 +/* Define to 1 if printf and friends should be labeled with attribute + "__gnu_printf__" instead of "__printf__" */ +/* #undef GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU */ + /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module scanf shall be considered present. */ #define GNULIB_SCANF 1 @@ -114,6 +230,10 @@ whether the gnulib module strerror shall be considered present. */ #define GNULIB_STRERROR 1 +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module strerror_r-posix shall be considered present. */ +#define GNULIB_STRERROR_R_POSIX 1 + /* Define to 1 when the gnulib module calloc-posix should be tested. */ #define GNULIB_TEST_CALLOC_POSIX 1 @@ -150,9 +270,6 @@ /* Define to 1 when the gnulib module getdtablesize should be tested. */ #define GNULIB_TEST_GETDTABLESIZE 1 -/* Define to 1 when the gnulib module getopt-gnu should be tested. */ -#define GNULIB_TEST_GETOPT_GNU 1 - /* Define to 1 when the gnulib module isnan should be tested. */ #define GNULIB_TEST_ISNAN 1 @@ -168,6 +285,9 @@ /* Define to 1 when the gnulib module ldexpl should be tested. */ #define GNULIB_TEST_LDEXPL 1 +/* Define to 1 when the gnulib module lstat should be tested. */ +#define GNULIB_TEST_LSTAT 1 + /* Define to 1 when the gnulib module malloc-posix should be tested. */ #define GNULIB_TEST_MALLOC_POSIX 1 @@ -285,6 +405,9 @@ /* Define to 1 when the gnulib module strverscmp should be tested. */ #define GNULIB_TEST_STRVERSCMP 1 +/* Define to 1 when the gnulib module unlink should be tested. */ +#define GNULIB_TEST_UNLINK 1 + /* Define to 1 when the gnulib module unsetenv should be tested. */ #define GNULIB_TEST_UNSETENV 1 @@ -346,6 +469,9 @@ libc. */ /* #undef HAVE_COPYSIGN_IN_LIBC */ +/* Define to 1 if you have the <crtdefs.h> header file. */ +/* #undef HAVE_CRTDEFS_H */ + /* Define if the GNU dcgettext() function is already present or preinstalled. */ /* #undef HAVE_DCGETTEXT */ @@ -414,9 +540,9 @@ don't. */ #define HAVE_DECL_GETC_UNLOCKED 1 -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 +/* Define to 1 if you have the declaration of `getdtablesize', and to 0 if you + don't. */ +#define HAVE_DECL_GETDTABLESIZE 1 /* Define to 1 if you have the declaration of `getrusage', and to 0 if you don't. */ @@ -502,6 +628,10 @@ don't. */ #define HAVE_DECL__SNPRINTF 0 +/* Define to 1 if you have the declaration of `__argv', and to 0 if you don't. + */ +#define HAVE_DECL___ARGV 0 + /* Define to 1 if you have the declaration of `__fpending', and to 0 if you don't. */ #define HAVE_DECL___FPENDING 1 @@ -527,12 +657,18 @@ /* Define to 1 if you have the `getdtablesize' function. */ #define HAVE_GETDTABLESIZE 1 +/* Define to 1 if you have the `getexecname' function. */ +/* #undef HAVE_GETEXECNAME */ + /* Define to 1 if you have the <getopt.h> header file. */ #define HAVE_GETOPT_H 1 /* Define to 1 if you have the `getopt_long_only' function. */ #define HAVE_GETOPT_LONG_ONLY 1 +/* Define to 1 if you have the `getprogname' function. */ +/* #undef HAVE_GETPROGNAME */ + /* Define if the GNU gettext() function is already present or preinstalled. */ /* #undef HAVE_GETTEXT */ @@ -559,7 +695,7 @@ #define HAVE_ISNANF_IN_LIBC 1 /* Define if the isnan(long double) function is available in libc. */ -/* #undef HAVE_ISNANL_IN_LIBC */ +#define HAVE_ISNANL_IN_LIBC 1 /* Define to 1 if you have the `iswcntrl' function. */ #define HAVE_ISWCNTRL 1 @@ -576,6 +712,9 @@ /* Define if the ldexp function is available in libc. */ #define HAVE_LDEXP_IN_LIBC 1 +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + /* Define to 1 if you have the <locale.h> header file. */ #define HAVE_LOCALE_H 1 @@ -611,6 +750,12 @@ /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 +/* Define to 1 if <limits.h> defines the MIN and MAX macros. */ +/* #undef HAVE_MINMAX_IN_LIMITS_H */ + +/* Define to 1 if <sys/param.h> defines the MIN and MAX macros. */ +#define HAVE_MINMAX_IN_SYS_PARAM_H 1 + /* Define to 1 if you have the `mprotect' function. */ #define HAVE_MPROTECT 1 @@ -621,8 +766,8 @@ /* Define to 1 if you have the `nl_langinfo' function. */ /* #undef HAVE_NL_LANGINFO */ -/* Define to 1 if libc includes obstacks. */ -#define HAVE_OBSTACK 1 +/* Define to 1 if the system has obstacks that work with any size object. */ +/* #undef HAVE_OBSTACK */ /* Define to 1 if you have the `obstack_printf' function. */ #define HAVE_OBSTACK_PRINTF 1 @@ -651,890 +796,16 @@ /* Define if the POSIX multithreading library has read/write locks. */ #define HAVE_PTHREAD_RWLOCK 1 +/* Define if the 'pthread_rwlock_rdlock' function prefers a writer to a + reader. */ +/* #undef HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER */ + /* Define to 1 if you have the `raise' function. */ #define HAVE_RAISE 1 /* Define to 1 if you have the `rawmemchr' function. */ #define HAVE_RAWMEMCHR 1 -/* Define to 1 if acosf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ACOSF 1 - -/* Define to 1 if acosl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ACOSL 1 - -/* Define to 1 if asinf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ASINF 1 - -/* Define to 1 if asinl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ASINL 1 - -/* Define to 1 if atanf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ATANF 1 - -/* Define to 1 if atanl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ATANL 1 - -/* Define to 1 if atoll is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ATOLL 1 - -/* Define to 1 if btowc is declared even after undefining macros. */ -#define HAVE_RAW_DECL_BTOWC 1 - -/* Define to 1 if canonicalize_file_name is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 1 - -/* Define to 1 if cbrt is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CBRT 1 - -/* Define to 1 if cbrtf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CBRTF 1 - -/* Define to 1 if cbrtl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CBRTL 1 - -/* Define to 1 if ceilf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CEILF 1 - -/* Define to 1 if ceill is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CEILL 1 - -/* Define to 1 if chdir is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CHDIR 1 - -/* Define to 1 if chown is declared even after undefining macros. */ -#define HAVE_RAW_DECL_CHOWN 1 - -/* Define to 1 if copysign is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COPYSIGN 1 - -/* Define to 1 if copysignf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COPYSIGNF 1 - -/* Define to 1 if copysignl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COPYSIGNL 1 - -/* Define to 1 if cosf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COSF 1 - -/* Define to 1 if coshf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COSHF 1 - -/* Define to 1 if cosl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_COSL 1 - -/* Define to 1 if dprintf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_DPRINTF 1 - -/* Define to 1 if dup is declared even after undefining macros. */ -#define HAVE_RAW_DECL_DUP 1 - -/* Define to 1 if dup2 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_DUP2 1 - -/* Define to 1 if dup3 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_DUP3 1 - -/* Define to 1 if endusershell is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ENDUSERSHELL 1 - -/* Define to 1 if environ is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ENVIRON 1 - -/* Define to 1 if euidaccess is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EUIDACCESS 1 - -/* Define to 1 if exp2 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXP2 1 - -/* Define to 1 if exp2f is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXP2F 1 - -/* Define to 1 if exp2l is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXP2L 1 - -/* Define to 1 if expf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXPF 1 - -/* Define to 1 if expl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXPL 1 - -/* Define to 1 if expm1 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXPM1 1 - -/* Define to 1 if expm1f is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXPM1F 1 - -/* Define to 1 if expm1l is declared even after undefining macros. */ -#define HAVE_RAW_DECL_EXPM1L 1 - -/* Define to 1 if fabsf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FABSF 1 - -/* Define to 1 if fabsl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FABSL 1 - -/* Define to 1 if faccessat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FACCESSAT 1 - -/* Define to 1 if fchdir is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FCHDIR 1 - -/* Define to 1 if fchmodat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FCHMODAT 1 - -/* Define to 1 if fchownat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FCHOWNAT 1 - -/* Define to 1 if fcntl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FCNTL 1 - -/* Define to 1 if fdatasync is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FDATASYNC 1 - -/* Define to 1 if ffsl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FFSL 1 - -/* Define to 1 if ffsll is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FFSLL 1 - -/* Define to 1 if floorf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FLOORF 1 - -/* Define to 1 if floorl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FLOORL 1 - -/* Define to 1 if fma is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMA 1 - -/* Define to 1 if fmaf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMAF 1 - -/* Define to 1 if fmal is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMAL 1 - -/* Define to 1 if fmod is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMOD 1 - -/* Define to 1 if fmodf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMODF 1 - -/* Define to 1 if fmodl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FMODL 1 - -/* Define to 1 if fpurge is declared even after undefining macros. */ -/* #undef HAVE_RAW_DECL_FPURGE */ - -/* Define to 1 if frexpf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FREXPF 1 - -/* Define to 1 if frexpl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FREXPL 1 - -/* Define to 1 if fseeko is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FSEEKO 1 - -/* Define to 1 if fstat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FSTAT 1 - -/* Define to 1 if fstatat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FSTATAT 1 - -/* Define to 1 if fsync is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FSYNC 1 - -/* Define to 1 if ftello is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FTELLO 1 - -/* Define to 1 if ftruncate is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FTRUNCATE 1 - -/* Define to 1 if futimens is declared even after undefining macros. */ -#define HAVE_RAW_DECL_FUTIMENS 1 - -/* Define to 1 if getcwd is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETCWD 1 - -/* Define to 1 if getdelim is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETDELIM 1 - -/* Define to 1 if getdomainname is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETDOMAINNAME 1 - -/* Define to 1 if getdtablesize is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETDTABLESIZE 1 - -/* Define to 1 if getgroups is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETGROUPS 1 - -/* Define to 1 if gethostname is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETHOSTNAME 1 - -/* Define to 1 if getline is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETLINE 1 - -/* Define to 1 if getloadavg is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETLOADAVG 1 - -/* Define to 1 if getlogin is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETLOGIN 1 - -/* Define to 1 if getlogin_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETLOGIN_R 1 - -/* Define to 1 if getpagesize is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETPAGESIZE 1 - -/* Define to 1 if gets is declared even after undefining macros. */ -/* #undef HAVE_RAW_DECL_GETS */ - -/* Define to 1 if getsubopt is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETSUBOPT 1 - -/* Define to 1 if getusershell is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GETUSERSHELL 1 - -/* Define to 1 if grantpt is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GRANTPT 1 - -/* Define to 1 if group_member is declared even after undefining macros. */ -#define HAVE_RAW_DECL_GROUP_MEMBER 1 - -/* Define to 1 if hypotf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_HYPOTF 1 - -/* Define to 1 if hypotl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_HYPOTL 1 - -/* Define to 1 if ilogb is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ILOGB 1 - -/* Define to 1 if ilogbf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ILOGBF 1 - -/* Define to 1 if ilogbl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ILOGBL 1 - -/* Define to 1 if imaxabs is declared even after undefining macros. */ -#define HAVE_RAW_DECL_IMAXABS 1 - -/* Define to 1 if imaxdiv is declared even after undefining macros. */ -#define HAVE_RAW_DECL_IMAXDIV 1 - -/* Define to 1 if initstate is declared even after undefining macros. */ -#define HAVE_RAW_DECL_INITSTATE 1 - -/* Define to 1 if initstate_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_INITSTATE_R 1 - -/* Define to 1 if isatty is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ISATTY 1 - -/* Define to 1 if iswctype is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ISWCTYPE 1 - -/* Define to 1 if lchmod is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LCHMOD 1 - -/* Define to 1 if lchown is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LCHOWN 1 - -/* Define to 1 if ldexpf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LDEXPF 1 - -/* Define to 1 if ldexpl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LDEXPL 1 - -/* Define to 1 if link is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LINK 1 - -/* Define to 1 if linkat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LINKAT 1 - -/* Define to 1 if log is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG 1 - -/* Define to 1 if log10 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG10 1 - -/* Define to 1 if log10f is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG10F 1 - -/* Define to 1 if log10l is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG10L 1 - -/* Define to 1 if log1p is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG1P 1 - -/* Define to 1 if log1pf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG1PF 1 - -/* Define to 1 if log1pl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG1PL 1 - -/* Define to 1 if log2 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG2 1 - -/* Define to 1 if log2f is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG2F 1 - -/* Define to 1 if log2l is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOG2L 1 - -/* Define to 1 if logb is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOGB 1 - -/* Define to 1 if logbf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOGBF 1 - -/* Define to 1 if logbl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOGBL 1 - -/* Define to 1 if logf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOGF 1 - -/* Define to 1 if logl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LOGL 1 - -/* Define to 1 if lseek is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LSEEK 1 - -/* Define to 1 if lstat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_LSTAT 1 - -/* Define to 1 if mbrlen is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MBRLEN 1 - -/* Define to 1 if mbrtowc is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MBRTOWC 1 - -/* Define to 1 if mbsinit is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MBSINIT 1 - -/* Define to 1 if mbsnrtowcs is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MBSNRTOWCS 1 - -/* Define to 1 if mbsrtowcs is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MBSRTOWCS 1 - -/* Define to 1 if memmem is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MEMMEM 1 - -/* Define to 1 if mempcpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MEMPCPY 1 - -/* Define to 1 if memrchr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MEMRCHR 1 - -/* Define to 1 if mkdirat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKDIRAT 1 - -/* Define to 1 if mkdtemp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKDTEMP 1 - -/* Define to 1 if mkfifo is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKFIFO 1 - -/* Define to 1 if mkfifoat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKFIFOAT 1 - -/* Define to 1 if mknod is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKNOD 1 - -/* Define to 1 if mknodat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKNODAT 1 - -/* Define to 1 if mkostemp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKOSTEMP 1 - -/* Define to 1 if mkostemps is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKOSTEMPS 1 - -/* Define to 1 if mkstemp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKSTEMP 1 - -/* Define to 1 if mkstemps is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MKSTEMPS 1 - -/* Define to 1 if modf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MODF 1 - -/* Define to 1 if modff is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MODFF 1 - -/* Define to 1 if modfl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_MODFL 1 - -/* Define to 1 if openat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_OPENAT 1 - -/* Define to 1 if pclose is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PCLOSE 1 - -/* Define to 1 if pipe is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PIPE 1 - -/* Define to 1 if pipe2 is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PIPE2 1 - -/* Define to 1 if popen is declared even after undefining macros. */ -#define HAVE_RAW_DECL_POPEN 1 - -/* Define to 1 if posix_openpt is declared even after undefining macros. */ -#define HAVE_RAW_DECL_POSIX_OPENPT 1 - -/* Define to 1 if posix_spawn is declared even after undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN 1 - -/* Define to 1 if posix_spawnattr_destroy is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY 1 - -/* Define to 1 if posix_spawnattr_getflags is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS 1 - -/* Define to 1 if posix_spawnattr_getpgroup is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP 1 - -/* Define to 1 if posix_spawnattr_getschedparam is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM 1 - -/* Define to 1 if posix_spawnattr_getschedpolicy is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY 1 - -/* Define to 1 if posix_spawnattr_getsigdefault is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT 1 - -/* Define to 1 if posix_spawnattr_getsigmask is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK 1 - -/* Define to 1 if posix_spawnattr_init is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT 1 - -/* Define to 1 if posix_spawnattr_setflags is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS 1 - -/* Define to 1 if posix_spawnattr_setpgroup is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP 1 - -/* Define to 1 if posix_spawnattr_setschedparam is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM 1 - -/* Define to 1 if posix_spawnattr_setschedpolicy is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY 1 - -/* Define to 1 if posix_spawnattr_setsigdefault is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT 1 - -/* Define to 1 if posix_spawnattr_setsigmask is declared even after undefining - macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK 1 - -/* Define to 1 if posix_spawnp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWNP 1 - -/* Define to 1 if posix_spawn_file_actions_addclose is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE 1 - -/* Define to 1 if posix_spawn_file_actions_adddup2 is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 1 - -/* Define to 1 if posix_spawn_file_actions_addopen is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 1 - -/* Define to 1 if posix_spawn_file_actions_destroy is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY 1 - -/* Define to 1 if posix_spawn_file_actions_init is declared even after - undefining macros. */ -#define HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT 1 - -/* Define to 1 if powf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_POWF 1 - -/* Define to 1 if pread is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PREAD 1 - -/* Define to 1 if pthread_sigmask is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PTHREAD_SIGMASK 1 - -/* Define to 1 if ptsname is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PTSNAME 1 - -/* Define to 1 if ptsname_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PTSNAME_R 1 - -/* Define to 1 if pwrite is declared even after undefining macros. */ -#define HAVE_RAW_DECL_PWRITE 1 - -/* Define to 1 if random is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RANDOM 1 - -/* Define to 1 if random_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RANDOM_R 1 - -/* Define to 1 if rawmemchr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RAWMEMCHR 1 - -/* Define to 1 if readlink is declared even after undefining macros. */ -#define HAVE_RAW_DECL_READLINK 1 - -/* Define to 1 if readlinkat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_READLINKAT 1 - -/* Define to 1 if realpath is declared even after undefining macros. */ -#define HAVE_RAW_DECL_REALPATH 1 - -/* Define to 1 if remainder is declared even after undefining macros. */ -#define HAVE_RAW_DECL_REMAINDER 1 - -/* Define to 1 if remainderf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_REMAINDERF 1 - -/* Define to 1 if remainderl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_REMAINDERL 1 - -/* Define to 1 if renameat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RENAMEAT 1 - -/* Define to 1 if rint is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RINT 1 - -/* Define to 1 if rintf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RINTF 1 - -/* Define to 1 if rintl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RINTL 1 - -/* Define to 1 if rmdir is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RMDIR 1 - -/* Define to 1 if round is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ROUND 1 - -/* Define to 1 if roundf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ROUNDF 1 - -/* Define to 1 if roundl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_ROUNDL 1 - -/* Define to 1 if rpmatch is declared even after undefining macros. */ -#define HAVE_RAW_DECL_RPMATCH 1 - -/* Define to 1 if secure_getenv is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SECURE_GETENV 1 - -/* Define to 1 if setenv is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SETENV 1 - -/* Define to 1 if sethostname is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SETHOSTNAME 1 - -/* Define to 1 if setstate is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SETSTATE 1 - -/* Define to 1 if setstate_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SETSTATE_R 1 - -/* Define to 1 if setusershell is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SETUSERSHELL 1 - -/* Define to 1 if sigaction is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGACTION 1 - -/* Define to 1 if sigaddset is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGADDSET 1 - -/* Define to 1 if sigdelset is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGDELSET 1 - -/* Define to 1 if sigemptyset is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGEMPTYSET 1 - -/* Define to 1 if sigfillset is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGFILLSET 1 - -/* Define to 1 if sigismember is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGISMEMBER 1 - -/* Define to 1 if sigpending is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGPENDING 1 - -/* Define to 1 if sigprocmask is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SIGPROCMASK 1 - -/* Define to 1 if sinf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SINF 1 - -/* Define to 1 if sinhf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SINHF 1 - -/* Define to 1 if sinl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SINL 1 - -/* Define to 1 if sleep is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SLEEP 1 - -/* Define to 1 if snprintf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SNPRINTF 1 - -/* Define to 1 if sqrtf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SQRTF 1 - -/* Define to 1 if sqrtl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SQRTL 1 - -/* Define to 1 if srandom is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SRANDOM 1 - -/* Define to 1 if srandom_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SRANDOM_R 1 - -/* Define to 1 if stat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STAT 1 - -/* Define to 1 if stpcpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STPCPY 1 - -/* Define to 1 if stpncpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STPNCPY 1 - -/* Define to 1 if strcasestr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRCASESTR 1 - -/* Define to 1 if strchrnul is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRCHRNUL 1 - -/* Define to 1 if strdup is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRDUP 1 - -/* Define to 1 if strerror_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRERROR_R 1 - -/* Define to 1 if strncat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRNCAT 1 - -/* Define to 1 if strndup is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRNDUP 1 - -/* Define to 1 if strnlen is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRNLEN 1 - -/* Define to 1 if strpbrk is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRPBRK 1 - -/* Define to 1 if strsep is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRSEP 1 - -/* Define to 1 if strsignal is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRSIGNAL 1 - -/* Define to 1 if strtod is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOD 1 - -/* Define to 1 if strtoimax is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOIMAX 1 - -/* Define to 1 if strtok_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOK_R 1 - -/* Define to 1 if strtoll is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOLL 1 - -/* Define to 1 if strtoull is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOULL 1 - -/* Define to 1 if strtoumax is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRTOUMAX 1 - -/* Define to 1 if strverscmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_STRVERSCMP 1 - -/* Define to 1 if symlink is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SYMLINK 1 - -/* Define to 1 if symlinkat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_SYMLINKAT 1 - -/* Define to 1 if tanf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TANF 1 - -/* Define to 1 if tanhf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TANHF 1 - -/* Define to 1 if tanl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TANL 1 - -/* Define to 1 if tmpfile is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TMPFILE 1 - -/* Define to 1 if towctrans is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TOWCTRANS 1 - -/* Define to 1 if trunc is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TRUNC 1 - -/* Define to 1 if truncf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TRUNCF 1 - -/* Define to 1 if truncl is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TRUNCL 1 - -/* Define to 1 if ttyname_r is declared even after undefining macros. */ -#define HAVE_RAW_DECL_TTYNAME_R 1 - -/* Define to 1 if unlink is declared even after undefining macros. */ -#define HAVE_RAW_DECL_UNLINK 1 - -/* Define to 1 if unlinkat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_UNLINKAT 1 - -/* Define to 1 if unlockpt is declared even after undefining macros. */ -#define HAVE_RAW_DECL_UNLOCKPT 1 - -/* Define to 1 if unsetenv is declared even after undefining macros. */ -#define HAVE_RAW_DECL_UNSETENV 1 - -/* Define to 1 if usleep is declared even after undefining macros. */ -#define HAVE_RAW_DECL_USLEEP 1 - -/* Define to 1 if utimensat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_UTIMENSAT 1 - -/* Define to 1 if vdprintf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_VDPRINTF 1 - -/* Define to 1 if vsnprintf is declared even after undefining macros. */ -#define HAVE_RAW_DECL_VSNPRINTF 1 - -/* Define to 1 if waitpid is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WAITPID 1 - -/* Define to 1 if wcpcpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCPCPY 1 - -/* Define to 1 if wcpncpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCPNCPY 1 - -/* Define to 1 if wcrtomb is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCRTOMB 1 - -/* Define to 1 if wcscasecmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCASECMP 1 - -/* Define to 1 if wcscat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCAT 1 - -/* Define to 1 if wcschr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCHR 1 - -/* Define to 1 if wcscmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCMP 1 - -/* Define to 1 if wcscoll is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCOLL 1 - -/* Define to 1 if wcscpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCPY 1 - -/* Define to 1 if wcscspn is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSCSPN 1 - -/* Define to 1 if wcsdup is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSDUP 1 - -/* Define to 1 if wcslen is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSLEN 1 - -/* Define to 1 if wcsncasecmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNCASECMP 1 - -/* Define to 1 if wcsncat is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNCAT 1 - -/* Define to 1 if wcsncmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNCMP 1 - -/* Define to 1 if wcsncpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNCPY 1 - -/* Define to 1 if wcsnlen is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNLEN 1 - -/* Define to 1 if wcsnrtombs is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSNRTOMBS 1 - -/* Define to 1 if wcspbrk is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSPBRK 1 - -/* Define to 1 if wcsrchr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSRCHR 1 - -/* Define to 1 if wcsrtombs is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSRTOMBS 1 - -/* Define to 1 if wcsspn is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSSPN 1 - -/* Define to 1 if wcsstr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSSTR 1 - -/* Define to 1 if wcstok is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSTOK 1 - -/* Define to 1 if wcswidth is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSWIDTH 1 - -/* Define to 1 if wcsxfrm is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCSXFRM 1 - -/* Define to 1 if wctob is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCTOB 1 - -/* Define to 1 if wctrans is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCTRANS 1 - -/* Define to 1 if wctype is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCTYPE 1 - -/* Define to 1 if wcwidth is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WCWIDTH 1 - -/* Define to 1 if wmemchr is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WMEMCHR 1 - -/* Define to 1 if wmemcmp is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WMEMCMP 1 - -/* Define to 1 if wmemcpy is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WMEMCPY 1 - -/* Define to 1 if wmemmove is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WMEMMOVE 1 - -/* Define to 1 if wmemset is declared even after undefining macros. */ -#define HAVE_RAW_DECL_WMEMSET 1 - -/* Define to 1 if _Exit is declared even after undefining macros. */ -#define HAVE_RAW_DECL__EXIT 1 - /* Define if the 'realloc' function is POSIX compliant. */ #define HAVE_REALLOC_POSIX 1 @@ -1542,7 +813,7 @@ /* #undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE */ /* Define to 1 if you have the <sched.h> header file. */ -#define HAVE_SCHED_H 1 +/* #undef HAVE_SCHED_H */ /* Define to 1 if you have the `sched_setparam' function. */ /* #undef HAVE_SCHED_SETPARAM */ @@ -1550,6 +821,9 @@ /* Define to 1 if you have the `sched_setscheduler' function. */ /* #undef HAVE_SCHED_SETSCHEDULER */ +/* Define to 1 if you have the `setdtablesize' function. */ +/* #undef HAVE_SETDTABLESIZE */ + /* Define to 1 if you have the `setegid' function. */ /* #undef HAVE_SETEGID */ @@ -1634,12 +908,30 @@ /* Define to 1 if you have the `strnlen' function. */ #define HAVE_STRNLEN 1 -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - /* Define to 1 if `sa_sigaction' is a member of `struct sigaction'. */ #define HAVE_STRUCT_SIGACTION_SA_SIGACTION 1 +/* Define to 1 if `st_atimensec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */ + +/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */ + +/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1 + +/* Define to 1 if `st_birthtimensec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC */ + +/* Define to 1 if `st_birthtimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_birthtim.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC */ + /* Define to 1 if the system has the type `struct tms'. */ #define HAVE_STRUCT_TMS 1 @@ -1652,6 +944,9 @@ /* Define to 1 if you have the <sys/bitypes.h> header file. */ /* #undef HAVE_SYS_BITYPES_H */ +/* Define to 1 if you have the <sys/cdefs.h> header file. */ +#define HAVE_SYS_CDEFS_H 1 + /* Define to 1 if you have the <sys/inttypes.h> header file. */ /* #undef HAVE_SYS_INTTYPES_H */ @@ -1697,6 +992,9 @@ /* Define to 1 if the system has the type 'unsigned long long int'. */ #define HAVE_UNSIGNED_LONG_LONG_INT 1 +/* Define if you have a global __progname variable */ +/* #undef HAVE_VAR___PROGNAME */ + /* Define to 1 if you have the `vasnprintf' function. */ /* #undef HAVE_VASNPRINTF */ @@ -1752,9 +1050,6 @@ /* Define to 1 if you have the `_set_invalid_parameter_handler' function. */ /* #undef HAVE__SET_INVALID_PARAMETER_HANDLER */ -/* Define to 1 if you have the `__fpending' function. */ -#define HAVE___FPENDING 1 - /* Define to 1 if you have the `__fseterr' function. */ /* #undef HAVE___FSETERR */ @@ -1775,15 +1070,26 @@ /* Define as the word index where to find the sign of 'long double'. */ /* #undef LDBL_SIGNBIT_WORD */ +/* Define to 1 if 'lstat' dereferences a symlink specified with a trailing + slash. */ +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 + /* Define to the GNU M4 executable name. */ #define M4 "/var/empty/gnum4-1.4.19/bin/m4" /* Define to "-g" if GNU M4 supports -g, otherwise to "". */ #define M4_GNU_OPTION "--gnu" +/* If malloc(0) is != NULL, define this to 1. Otherwise define this to 0. */ +#define MALLOC_0_IS_NONNULL 1 + /* Define to a substitute value for mmap()'s MAP_ANONYMOUS flag. */ /* #undef MAP_ANONYMOUS */ +/* Define if the mbrtowc function does not return (size_t) -2 for empty input. + */ +/* #undef MBRTOWC_EMPTY_INPUT_BUG */ + /* Define if the mbrtowc function has the NULL pwc argument bug. */ /* #undef MBRTOWC_NULL_ARG1_BUG */ @@ -1796,6 +1102,12 @@ /* Define if the mbrtowc function returns a wrong return value. */ /* #undef MBRTOWC_RETVAL_BUG */ +/* Use GNU style printf and scanf. */ +#ifndef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 1 +#endif + + /* Define to 1 if assertions should be disabled. */ /* #undef NDEBUG */ @@ -1837,7 +1149,7 @@ /* Define if the vasnprintf implementation needs special code for infinite 'long double' arguments. */ -#define NEED_PRINTF_INFINITE_LONG_DOUBLE 1 +/* #undef NEED_PRINTF_INFINITE_LONG_DOUBLE */ /* Define if the vasnprintf implementation needs special code for 'long double' arguments. */ @@ -1857,13 +1169,13 @@ #define PACKAGE_BUGREPORT "bug-bison@gnu.org" /* The copyright year for this package */ -#define PACKAGE_COPYRIGHT_YEAR 2013 +#define PACKAGE_COPYRIGHT_YEAR 2018 /* Define to the full name of this package. */ #define PACKAGE_NAME "GNU Bison" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 3.0" +#define PACKAGE_STRING "GNU Bison 3.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bison" @@ -1872,10 +1184,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/bison/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.0" - -/* the number of pending output bytes on stream 'fp' */ -/* #undef PENDING_OUTPUT_N_BYTES */ +#define PACKAGE_VERSION "3.1" /* Define if <inttypes.h> exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -1895,10 +1204,6 @@ */ #define REPLACE_FPRINTF_POSIX 1 -/* Define to 1 if stat needs help when passed a directory name with a trailing - slash */ -/* #undef REPLACE_FUNC_STAT_DIR */ - /* Define to 1 if stat needs help when passed a file name with a trailing slash */ /* #undef REPLACE_FUNC_STAT_FILE */ @@ -1948,6 +1253,13 @@ /* Define to 1 if strerror_r returns char *. */ #define STRERROR_R_CHAR_P 1 +/* Define to 1 if the type of the st_atim member of a struct stat is struct + timespec. */ +#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1 + +/* Define to 1 if unlink() on a parent directory may succeed */ +/* #undef UNLINK_PARENT_BUG */ + /* Define to the prefix of C symbols at the assembler and linker level, either an underscore or empty. */ #define USER_LABEL_PREFIX @@ -1977,7 +1289,7 @@ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif -/* Enable general extensions on OS X. */ +/* Enable general extensions on macOS. */ #ifndef _DARWIN_C_SOURCE # define _DARWIN_C_SOURCE 1 #endif @@ -1985,10 +1297,46 @@ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif +/* Enable NetBSD extensions on NetBSD. */ +#ifndef _NETBSD_SOURCE +# define _NETBSD_SOURCE 1 +#endif +/* Enable OpenBSD extensions on NetBSD. */ +#ifndef _OPENBSD_SOURCE +# define _OPENBSD_SOURCE 1 +#endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# define __STDC_WANT_LIB_EXT2__ 1 +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 @@ -1999,6 +1347,11 @@ #ifndef _XOPEN_SOURCE /* # undef _XOPEN_SOURCE */ #endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # define __EXTENSIONS__ 1 @@ -2014,7 +1367,7 @@ /* #undef USE_WINDOWS_THREADS */ /* Version number of package */ -#define VERSION "3.0" +#define VERSION "3.1" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ @@ -2055,10 +1408,6 @@ /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ -/* Define to 1 if Gnulib overrides 'struct stat' on Windows so that struct - stat.st_size becomes 64-bit. */ -/* #undef _GL_WINDOWS_64_BIT_ST_SIZE */ - /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ @@ -2066,7 +1415,7 @@ /* #undef _MINIX */ /* Define to 1 to make NetBSD features available. MINIX 3 needs this. */ -/* #undef _NETBSD_SOURCE */ +#define _NETBSD_SOURCE 1 /* The _Noreturn keyword of C11. */ #if ! (defined _Noreturn \ @@ -2089,14 +1438,23 @@ /* Define to 1 if you need to in order for 'stat' and other things to work. */ /* #undef _POSIX_SOURCE */ +/* For standard stat data types on VMS. */ +#define _USE_STD_STAT 1 + /* Define to rpl_ if the getopt replacement functions and variables should be used. */ /* #undef __GETOPT_PREFIX */ +/* Define to 1 if the system <stdint.h> predates C++11. */ +/* #undef __STDC_CONSTANT_MACROS */ + +/* Define to 1 if the system <stdint.h> predates C++11. */ +/* #undef __STDC_LIMIT_MACROS */ + /* Please see the Gnulib manual for how to use these macros. Suppress extern inline with HP-UX cc, as it appears to be broken; see - <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. + <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>. Suppress extern inline with Sun C in standards-conformance mode, as it mishandles inline functions that call each other. E.g., for 'inline void f @@ -2104,43 +1462,87 @@ 'reference to static identifier "f" in extern inline function'. This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. - Suppress the use of extern inline on Apple's platforms, as Libc at least - through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., - <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. - Perhaps Apple will fix this some day. */ + Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) + on configurations that mistakenly use 'static inline' to implement + functions or macros in standard C headers like <ctype.h>. For example, + if isdigit is mistakenly implemented via a static inline function, + a program containing an extern inline function that calls isdigit + may not work since the C standard prohibits extern inline functions + from calling static functions (ISO C 99 section 6.7.4.(3). + This bug is known to occur on: + + OS X 10.8 and earlier; see: + https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html + + DragonFly; see + http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log + + FreeBSD; see: + https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html + + OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and + for clang but remains for g++; see <https://trac.macports.org/ticket/41033>. + Assume DragonFly and FreeBSD will be similar. + + GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. It defines a macro + __GNUC_STDC_INLINE__ to indicate this situation or a macro + __GNUC_GNU_INLINE__ to indicate the opposite situation. + GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline + semantics but warns, unless -fgnu89-inline is used: + warning: C99 inline functions are not supported; using GNU89 + warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute + It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. + */ +#if (((defined __APPLE__ && defined __MACH__) \ + || defined __DragonFly__ || defined __FreeBSD__) \ + && (defined __header_inline \ + ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ + && ! defined __clang__) \ + : ((! defined _DONT_USE_CTYPE_INLINE_ \ + && (defined __GNUC__ || defined __cplusplus)) \ + || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ + && defined __GNUC__ && ! defined __cplusplus)))) +# define _GL_EXTERN_INLINE_STDHEADER_BUG +#endif #if ((__GNUC__ \ ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ : (199901L <= __STDC_VERSION__ \ && !defined __HP_cc \ + && !defined __PGI \ && !(defined __SUNPRO_C && __STDC__))) \ - && !defined __APPLE__) + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # define _GL_INLINE inline # define _GL_EXTERN_INLINE extern inline +# define _GL_EXTERN_INLINE_IN_USE #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ - && !defined __APPLE__) -# if __GNUC_GNU_INLINE__ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) # else # define _GL_INLINE extern inline # endif # define _GL_EXTERN_INLINE extern +# define _GL_EXTERN_INLINE_IN_USE #else # define _GL_INLINE static _GL_UNUSED # define _GL_EXTERN_INLINE static _GL_UNUSED #endif -#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +/* In GCC 4.6 (inclusive) to 5.1 (exclusive), + suppress bogus "no previous prototype for 'FOO'" + and "no previous declaration for 'FOO'" diagnostics, + when FOO is an inline function in the header; see + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */ +#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ # define _GL_INLINE_HEADER_CONST_PRAGMA # else # define _GL_INLINE_HEADER_CONST_PRAGMA \ _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") # endif - /* Suppress GCC's bogus "no previous prototype for 'FOO'" - and "no previous declaration for 'FOO'" diagnostics, - when FOO is an inline function in the header; see - <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */ # define _GL_INLINE_HEADER_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ @@ -2230,6 +1632,16 @@ is a misnomer outside of parameter lists. */ #define _UNUSED_PARAMETER_ _GL_UNUSED +/* gcc supports the "unused" attribute on possibly unused labels, and + g++ has since version 4.5. Note to support C++ as well as C, + _GL_UNUSED_LABEL should be used with a trailing ; */ +#if !defined __cplusplus || __GNUC__ > 4 \ + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define _GL_UNUSED_LABEL _GL_UNUSED +#else +# define _GL_UNUSED_LABEL +#endif + /* The __pure__ attribute was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) @@ -2244,3 +1656,11 @@ # define _GL_ATTRIBUTE_CONST /* empty */ #endif +/* The __malloc__ attribute was added in gcc 3. */ +#if 3 <= __GNUC__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC /* empty */ +#endif + +#define _GL_ATTRIBUTE_FORMAT_PRINTF(...) diff --git a/contrib/tools/bison/lib/config-osx.h b/contrib/tools/bison/lib/config-osx.h index 73cfff6950..651a271e22 100644 --- a/contrib/tools/bison/lib/config-osx.h +++ b/contrib/tools/bison/lib/config-osx.h @@ -11,6 +11,7 @@ #undef HAVE_DECL_PROGRAM_INVOCATION_NAME #undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME +#define HAVE_VAR___PROGNAME 1 #undef HAVE_OBSTACK #undef HAVE_OBSTACK_PRINTF @@ -30,4 +31,7 @@ #undef HAVE_DECL_PUTCHAR_UNLOCKED #undef HAVE_DECL_PUTC_UNLOCKED -#define PENDING_OUTPUT_N_BYTES 0 +#define _GL_ARG_NONNULL(...) + +#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC +#undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC diff --git a/contrib/tools/bison/lib/config-win.h b/contrib/tools/bison/lib/config-win.h index c1ca8e81a4..cb0268bf50 100644 --- a/contrib/tools/bison/lib/config-win.h +++ b/contrib/tools/bison/lib/config-win.h @@ -1226,7 +1226,7 @@ char *strsignal (int signum); /* #undef PACKAGE_PACKAGER_VERSION */ /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 3.0" +#define PACKAGE_STRING "GNU Bison 3.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "m4" @@ -1235,7 +1235,7 @@ char *strsignal (int signum); #define PACKAGE_URL "http://www.gnu.org/software/m4/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.0" +#define PACKAGE_VERSION "3.1" /* Define if <inttypes.h> exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -1398,7 +1398,7 @@ char *strsignal (int signum); /* #undef USE_WINDOWS_THREADS */ /* Version number of package */ -#define VERSION "3.0" +#define VERSION "3.1" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ @@ -1701,46 +1701,10 @@ char *strsignal (int signum); /* Define as a macro for copying va_list variables. */ #define va_copy gl_va_copy -// Since Windows SDK 10 FILE is an internal opaque structure with no backward compatibility. -// This code has been transplanted from Windows SDK -// corecrt_internal_stdio.h - -// __crt_stdio_stream_data -// -// These will be used in fseterr.c to set FILE into an error state. -typedef struct { - union { - void* _public_file; - char* _ptr; - }; - - char* _base; - int _cnt; - long _flags; - long _file; - int _charbuf; - int _bufsiz; - char* _tmpfname; - //CRITICAL_SECTION _lock; -} TWinSdk10File; - -enum EWinSdk10ModeBits { - WIN_SDK10_IOREAD = 0x0001, - WIN_SDK10_IOWRITE = 0x0002, - WIN_SDK10_IOUPDATE = 0x0004, - WIN_SDK10_IOEOF = 0x0008, - WIN_SDK10_IOERROR = 0x0010, - WIN_SDK10_IOCTRLZ = 0x0020, - WIN_SDK10_IOBUFFER_CRT = 0x0040, - WIN_SDK10_IOBUFFER_USER = 0x0080, - WIN_SDK10_IOBUFFER_SETVBUF = 0x0100, - WIN_SDK10_IOBUFFER_STBUF = 0x0200, - WIN_SDK10_IOBUFFER_NONE = 0x0400, - WIN_SDK10_IOCOMMIT = 0x0800, - WIN_SDK10_IOSTRING = 0x1000, - WIN_SDK10_IOALLOCATED = 0x2000, -}; - -#define PENDING_OUTPUT_N_BYTES (((TWinSdk10File*)fp)->_ptr - ((TWinSdk10File*)fp)->_base) #define M4_GNU_OPTION "--gnu" #define PACKAGE_COPYRIGHT_YEAR 2013 +#define _GL_ATTRIBUTE_MALLOC +#define HAVE_DECL___ARGV 1 +#define _GL_ATTRIBUTE_FORMAT_PRINTF(...) +#define HAVE_ISNANL_IN_LIBC 1 +#define HAVE_ISNAND_IN_LIBC 1 diff --git a/contrib/tools/bison/lib/configmake-linux.h b/contrib/tools/bison/lib/configmake-linux.h index c72947f530..bc0a0399a3 100644 --- a/contrib/tools/bison/lib/configmake-linux.h +++ b/contrib/tools/bison/lib/configmake-linux.h @@ -1,27 +1,28 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -#define PREFIX "/var/empty/bison-3.0" -#define EXEC_PREFIX "/var/empty/bison-3.0" -#define BINDIR "/var/empty/bison-3.0/bin" -#define SBINDIR "/var/empty/bison-3.0/sbin" -#define LIBEXECDIR "/var/empty/bison-3.0/libexec" -#define DATAROOTDIR "/var/empty/bison-3.0/share" -#define DATADIR "/var/empty/bison-3.0/share" -#define SYSCONFDIR "/var/empty/bison-3.0/etc" -#define SHAREDSTATEDIR "/var/empty/bison-3.0/com" -#define LOCALSTATEDIR "/var/empty/bison-3.0/var" -#define INCLUDEDIR "/var/empty/bison-3.0/include" +#define PREFIX "/var/empty/bison-3.1" +#define EXEC_PREFIX "/var/empty/bison-3.1" +#define BINDIR "/var/empty/bison-3.1/bin" +#define SBINDIR "/var/empty/bison-3.1/sbin" +#define LIBEXECDIR "/var/empty/bison-3.1/libexec" +#define DATAROOTDIR "/var/empty/bison-3.1/share" +#define DATADIR "/var/empty/bison-3.1/share" +#define SYSCONFDIR "/var/empty/bison-3.1/etc" +#define SHAREDSTATEDIR "/var/empty/bison-3.1/com" +#define LOCALSTATEDIR "/var/empty/bison-3.1/var" +#define RUNSTATEDIR "/var/empty/bison-3.1/var/run" +#define INCLUDEDIR "/var/empty/bison-3.1/include" #define OLDINCLUDEDIR "/usr/include" -#define DOCDIR "/var/empty/bison-3.0/share/doc/bison" -#define INFODIR "/var/empty/bison-3.0/share/info" -#define HTMLDIR "/var/empty/bison-3.0/share/doc/bison" -#define DVIDIR "/var/empty/bison-3.0/share/doc/bison" -#define PDFDIR "/var/empty/bison-3.0/share/doc/bison" -#define PSDIR "/var/empty/bison-3.0/share/doc/bison" -#define LIBDIR "/var/empty/bison-3.0/lib" -#define LISPDIR "/var/empty/bison-3.0/share/emacs/site-lisp" -#define LOCALEDIR "/var/empty/bison-3.0/share/locale" -#define MANDIR "/var/empty/bison-3.0/share/man" -#define PKGDATADIR "/var/empty/bison-3.0/share/bison" -#define PKGINCLUDEDIR "/var/empty/bison-3.0/include/bison" -#define PKGLIBDIR "/var/empty/bison-3.0/lib/bison" -#define PKGLIBEXECDIR "/var/empty/bison-3.0/libexec/bison" +#define DOCDIR "/var/empty/bison-3.1/share/doc/bison" +#define INFODIR "/var/empty/bison-3.1/share/info" +#define HTMLDIR "/var/empty/bison-3.1/share/doc/bison" +#define DVIDIR "/var/empty/bison-3.1/share/doc/bison" +#define PDFDIR "/var/empty/bison-3.1/share/doc/bison" +#define PSDIR "/var/empty/bison-3.1/share/doc/bison" +#define LIBDIR "/var/empty/bison-3.1/lib" +#define LISPDIR "/var/empty/bison-3.1/share/emacs/site-lisp" +#define LOCALEDIR "/var/empty/bison-3.1/share/locale" +#define MANDIR "/var/empty/bison-3.1/share/man" +#define PKGDATADIR "/var/empty/bison-3.1/share/bison" +#define PKGINCLUDEDIR "/var/empty/bison-3.1/include/bison" +#define PKGLIBDIR "/var/empty/bison-3.1/lib/bison" +#define PKGLIBEXECDIR "/var/empty/bison-3.1/libexec/bison" diff --git a/contrib/tools/bison/lib/dirname-lgpl.c b/contrib/tools/bison/lib/dirname-lgpl.c index 82f66301f2..a40f6a901f 100644 --- a/contrib/tools/bison/lib/dirname-lgpl.c +++ b/contrib/tools/bison/lib/dirname-lgpl.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/dirname.c b/contrib/tools/bison/lib/dirname.c index 1fb65888bb..766f862569 100644 --- a/contrib/tools/bison/lib/dirname.c +++ b/contrib/tools/bison/lib/dirname.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/dirname.h b/contrib/tools/bison/lib/dirname.h index 4ad0312008..8b5111168d 100644 --- a/contrib/tools/bison/lib/dirname.h +++ b/contrib/tools/bison/lib/dirname.h @@ -1,6 +1,6 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef DIRNAME_H_ # define DIRNAME_H_ 1 @@ -31,8 +31,12 @@ # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 # endif +#ifdef __cplusplus +extern "C" { +#endif + # if GNULIB_DIRNAME -char *base_name (char const *file); +char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC; char *dir_name (char const *file); # endif @@ -43,4 +47,8 @@ char *last_component (char const *file) _GL_ATTRIBUTE_PURE; bool strip_trailing_slashes (char *file); +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* not DIRNAME_H_ */ diff --git a/contrib/tools/bison/lib/dosname.h b/contrib/tools/bison/lib/dosname.h index ba63ce4bd3..fef3b6daa1 100644 --- a/contrib/tools/bison/lib/dosname.h +++ b/contrib/tools/bison/lib/dosname.h @@ -1,6 +1,6 @@ /* File names on MS-DOS/Windows systems. - Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,16 +13,15 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this program. If not, see <https://www.gnu.org/licenses/>. From Paul Eggert and Jim Meyering. */ #ifndef _DOSNAME_H #define _DOSNAME_H -#if (defined _WIN32 || defined __WIN32__ || \ - defined __MSDOS__ || defined __CYGWIN__ || \ - defined __EMX__ || defined __DJGPP__) +#if (defined _WIN32 || defined __CYGWIN__ \ + || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__) /* This internal macro assumes ASCII, but all hosts that support drive letters use ASCII. */ # define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ diff --git a/contrib/tools/bison/lib/dup-safer-flag.c b/contrib/tools/bison/lib/dup-safer-flag.c index 8a09821dc8..aa28194d53 100644 --- a/contrib/tools/bison/lib/dup-safer-flag.c +++ b/contrib/tools/bison/lib/dup-safer-flag.c @@ -1,7 +1,7 @@ /* Duplicate a file descriptor result, avoiding clobbering STD{IN,OUT,ERR}_FILENO, with specific flags. - Copyright (C) 2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert and Eric Blake. */ diff --git a/contrib/tools/bison/lib/dup-safer.c b/contrib/tools/bison/lib/dup-safer.c index c20310785a..1f1679ea18 100644 --- a/contrib/tools/bison/lib/dup-safer.c +++ b/contrib/tools/bison/lib/dup-safer.c @@ -1,6 +1,6 @@ /* Invoke dup, but avoid some glitches. - Copyright (C) 2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ diff --git a/contrib/tools/bison/lib/dup2.c b/contrib/tools/bison/lib/dup2.c index 9219eb3823..ba417823e9 100644 --- a/contrib/tools/bison/lib/dup2.c +++ b/contrib/tools/bison/lib/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* written by Paul Eggert */ @@ -29,16 +29,45 @@ # undef dup2 -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h> -# include "msvc-inval.h" +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif /* Get _get_osfhandle. */ -# include "msvc-nothrow.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +dup2_nothrow (int fd, int desired_fd) +{ + int result; + + TRY_MSVC_INVAL + { + result = dup2 (fd, desired_fd); + } + CATCH_MSVC_INVAL + { + errno = EBADF; + result = -1; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define dup2_nothrow dup2 +# endif static int ms_windows_dup2 (int fd, int desired_fd) @@ -59,23 +88,14 @@ ms_windows_dup2 (int fd, int desired_fd) } /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: - http://bugs.winehq.org/show_bug.cgi?id=21289 */ + https://bugs.winehq.org/show_bug.cgi?id=21289 */ if (desired_fd < 0) { errno = EBADF; return -1; } - TRY_MSVC_INVAL - { - result = dup2 (fd, desired_fd); - } - CATCH_MSVC_INVAL - { - errno = EBADF; - result = -1; - } - DONE_MSVC_INVAL; + result = dup2_nothrow (fd, desired_fd); if (result == 0) result = desired_fd; @@ -85,6 +105,57 @@ ms_windows_dup2 (int fd, int desired_fd) # define dup2 ms_windows_dup2 +# elif defined __KLIBC__ + +# error #include <InnoTekLIBC/backend.h> + +static int +klibc_dup2dirfd (int fd, int desired_fd) +{ + int tempfd; + int dupfd; + + tempfd = open ("NUL", O_RDONLY); + if (tempfd == -1) + return -1; + + if (tempfd == desired_fd) + { + close (tempfd); + + char path[_MAX_PATH]; + if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) + return -1; + + return open(path, O_RDONLY); + } + + dupfd = klibc_dup2dirfd (fd, desired_fd); + + close (tempfd); + + return dupfd; +} + +static int +klibc_dup2 (int fd, int desired_fd) +{ + int dupfd; + struct stat sbuf; + + dupfd = dup2 (fd, desired_fd); + if (dupfd == -1 && errno == ENOTSUP \ + && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) + { + close (desired_fd); + + return klibc_dup2dirfd (fd, desired_fd); + } + + return dupfd; +} + +# define dup2 klibc_dup2 # endif int @@ -96,7 +167,11 @@ rpl_dup2 (int fd, int desired_fd) /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. On Cygwin 1.5.x, dup2 (1, 1) returns 0. On Cygwin 1.7.17, dup2 (1, -1) dumps core. + On Cygwin 1.7.25, dup2 (1, 256) can dump core. On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ +# if HAVE_SETDTABLESIZE + setdtablesize (desired_fd + 1); +# endif if (desired_fd < 0) fd = desired_fd; if (fd == desired_fd) diff --git a/contrib/tools/bison/lib/ebitset.c b/contrib/tools/bison/lib/ebitset.c index e5d6c9239b..06da3cc6ce 100644 --- a/contrib/tools/bison/lib/ebitset.c +++ b/contrib/tools/bison/lib/ebitset.c @@ -1,6 +1,7 @@ /* Functions to support expandable bitsets. - Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -51,7 +52,7 @@ /* Number of bits stored in each element. */ #define EBITSET_ELT_BITS \ - ((unsigned int) (EBITSET_ELT_WORDS * BITSET_WORD_BITS)) + ((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS)) /* Ebitset element. We use an array of bits. */ typedef struct ebitset_elt_struct @@ -432,7 +433,7 @@ ebitset_equal_p (bitset dst, bitset src) for (j = 0; j < EBITSET_SIZE (src); j++) { - unsigned int i; + unsigned i; ebitset_elt *selt = selts[j]; ebitset_elt *delt = delts[j]; @@ -569,7 +570,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list, bitset_bindex n_bits; bitset_bindex bitno; bitset_bindex rbitno; - unsigned int bcount; + unsigned bcount; bitset_bindex boffset; bitset_windex windex; bitset_windex eindex; @@ -835,7 +836,7 @@ ebitset_list (bitset bset, bitset_bindex *list, static inline void ebitset_unused_clear (bitset dst) { - unsigned int last_bit; + unsigned last_bit; bitset_bindex n_bits; n_bits = BITSET_NBITS_ (dst); @@ -922,7 +923,7 @@ ebitset_empty_p (bitset dst) static void ebitset_not (bitset dst, bitset src) { - unsigned int i; + unsigned i; ebitset_elt *selt; ebitset_elt *delt; bitset_windex j; @@ -964,7 +965,7 @@ ebitset_subset_p (bitset dst, bitset src) for (j = 0; j < ssize; j++) { - unsigned int i; + unsigned i; ebitset_elt *selt; ebitset_elt *delt; @@ -1006,7 +1007,7 @@ ebitset_disjoint_p (bitset dst, bitset src) for (j = 0; j < ssize; j++) { - unsigned int i; + unsigned i; ebitset_elt *selt; ebitset_elt *delt; @@ -1039,7 +1040,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) bitset_word *srcp2; bitset_word *dstp; bool changed = false; - unsigned int i; + unsigned i; bitset_windex j; ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2))); diff --git a/contrib/tools/bison/lib/ebitset.h b/contrib/tools/bison/lib/ebitset.h index d31bda7d50..e8036cd45e 100644 --- a/contrib/tools/bison/lib/ebitset.h +++ b/contrib/tools/bison/lib/ebitset.h @@ -1,6 +1,7 @@ /* Functions to support ebitsets. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). diff --git a/contrib/tools/bison/lib/error.c b/contrib/tools/bison/lib/error.c index 865b29340b..adc873391c 100644 --- a/contrib/tools/bison/lib/error.c +++ b/contrib/tools/bison/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ @@ -39,6 +39,11 @@ # include <stdint.h> # include <wchar.h> # define mbsrtowcs __mbsrtowcs +# define USE_UNLOCKED_IO 0 +# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b) +# define _GL_ARG_NONNULL(a) +#else +# include "getprogname.h" #endif #if USE_UNLOCKED_IO @@ -72,14 +77,14 @@ extern void __error (int status, int errnum, const char *message, ...) extern void __error_at_line (int status, int errnum, const char *file_name, unsigned int line_number, const char *message, ...) - __attribute__ ((__format__ (__printf__, 5, 6)));; + __attribute__ ((__format__ (__printf__, 5, 6))); # define error __error # define error_at_line __error_at_line # include <libio/iolibio.h> -# define fflush(s) INTUSE(_IO_fflush) (s) +# define fflush(s) _IO_fflush (s) # undef putc -# define putc(c, fp) INTUSE(_IO_putc) (c, fp) +# define putc(c, fp) _IO_putc (c, fp) # include <bits/libc-lock.h> @@ -88,35 +93,37 @@ extern void __error_at_line (int status, int errnum, const char *file_name, # include <fcntl.h> # include <unistd.h> -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h> /* Get _get_osfhandle. */ -# include "msvc-nothrow.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif # endif /* The gnulib override of fcntl is not needed in this file. */ # undef fcntl -# if !HAVE_DECL_STRERROR_R +# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R) # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" # endif # if STRERROR_R_CHAR_P -char *strerror_r (); +char *strerror_r (int errnum, char *buf, size_t buflen); # else -int strerror_r (); +int strerror_r (int errnum, char *buf, size_t buflen); # endif # endif -/* The calling program should define program_name and set it to the - name of the executing program. */ -extern char *program_name; +#define program_name getprogname () -# if HAVE_STRERROR_R || defined strerror_r +# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r -# endif /* HAVE_STRERROR_R || defined strerror_r */ +# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */ #endif /* not _LIBC */ #if !_LIBC @@ -124,7 +131,7 @@ extern char *program_name; static int is_open (int fd) { -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ /* On native Windows: The initial state of unassigned standard file descriptors is that they are open but point to an INVALID_HANDLE_VALUE. There is no fcntl, and the gnulib replacement fcntl does not support @@ -169,9 +176,9 @@ print_errno_message (int errnum) { char const *s; -#if defined HAVE_STRERROR_R || _LIBC +#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R char errbuf[1024]; -# if STRERROR_R_CHAR_P || _LIBC +# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P) s = __strerror_r (errnum, errbuf, sizeof errbuf); # else if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) @@ -195,13 +202,12 @@ print_errno_message (int errnum) #endif } -static void +static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3)) error_tail (int status, int errnum, const char *message, va_list args) { #if _LIBC if (_IO_fwide (stderr, 0) > 0) { -# define ALLOCA_LIMIT 2000 size_t len = strlen (message) + 1; wchar_t *wmessage = NULL; mbstate_t st; @@ -237,7 +243,7 @@ error_tail (int status, int errnum, const char *message, va_list args) if (res != len) break; - if (__builtin_expect (len >= SIZE_MAX / 2, 0)) + if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0)) { /* This really should not happen if everything is fine. */ res = (size_t) -1; @@ -266,7 +272,6 @@ error_tail (int status, int errnum, const char *message, va_list args) else #endif vfprintf (stderr, message, args); - va_end (args); ++error_message_count; if (errnum) @@ -316,6 +321,7 @@ error (int status, int errnum, const char *message, ...) va_start (args, message); error_tail (status, errnum, message, args); + va_end (args); #ifdef _LIBC _IO_funlockfile (stderr); @@ -342,7 +348,10 @@ error_at_line (int status, int errnum, const char *file_name, if (old_line_number == line_number && (file_name == old_file_name - || strcmp (old_file_name, file_name) == 0)) + || (old_file_name != NULL + && file_name != NULL + && strcmp (old_file_name, file_name) == 0))) + /* Simply return and print nothing. */ return; @@ -374,15 +383,16 @@ error_at_line (int status, int errnum, const char *file_name, } #if _LIBC - __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", + __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ", file_name, line_number); #else - fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", + fprintf (stderr, file_name != NULL ? "%s:%u: " : " ", file_name, line_number); #endif va_start (args, message); error_tail (status, errnum, message, args); + va_end (args); #ifdef _LIBC _IO_funlockfile (stderr); diff --git a/contrib/tools/bison/lib/error.h b/contrib/tools/bison/lib/error.h index afcb0e10c8..36401e1aa3 100644 --- a/contrib/tools/bison/lib/error.h +++ b/contrib/tools/bison/lib/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation, + Copyright (C) 1995-1997, 2003, 2006, 2008-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _ERROR_H #define _ERROR_H 1 @@ -31,6 +31,16 @@ # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif +/* On mingw, the flavor of printf depends on whether the extensions module + * is in use; the check for <stdio.h> determines the witness macro. */ +#ifndef _GL_ATTRIBUTE_SPEC_PRINTF +# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU +# define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__ +# else +# define _GL_ATTRIBUTE_SPEC_PRINTF __printf__ +# endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -40,11 +50,11 @@ extern "C" { If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ extern void error (int __status, int __errnum, const char *__format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4)); extern void error_at_line (int __status, int __errnum, const char *__fname, unsigned int __lineno, const char *__format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6)); /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this diff --git a/contrib/tools/bison/lib/exitfail.c b/contrib/tools/bison/lib/exitfail.c index b0b4ebe45a..19c5cba049 100644 --- a/contrib/tools/bison/lib/exitfail.c +++ b/contrib/tools/bison/lib/exitfail.c @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/exitfail.h b/contrib/tools/bison/lib/exitfail.h index e54333bdd2..a42057b11a 100644 --- a/contrib/tools/bison/lib/exitfail.h +++ b/contrib/tools/bison/lib/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,6 +13,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ extern int volatile exit_failure; diff --git a/contrib/tools/bison/lib/fatal-signal.c b/contrib/tools/bison/lib/fatal-signal.c index 8f7cb8ea3b..9d795f746d 100644 --- a/contrib/tools/bison/lib/fatal-signal.c +++ b/contrib/tools/bison/lib/fatal-signal.c @@ -1,5 +1,5 @@ /* Emergency actions in case of a fatal signal. - Copyright (C) 2003-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/fatal-signal.h b/contrib/tools/bison/lib/fatal-signal.h index f5df78a048..41b4af7392 100644 --- a/contrib/tools/bison/lib/fatal-signal.h +++ b/contrib/tools/bison/lib/fatal-signal.h @@ -1,5 +1,5 @@ /* Emergency actions in case of a fatal signal. - Copyright (C) 2003-2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2009-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifdef __cplusplus diff --git a/contrib/tools/bison/lib/fcntl.c b/contrib/tools/bison/lib/fcntl.c index 735fa66f4d..d09e6b180c 100644 --- a/contrib/tools/bison/lib/fcntl.c +++ b/contrib/tools/bison/lib/fcntl.c @@ -1,6 +1,6 @@ /* Provide file descriptor control. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Eric Blake <ebb9@byu.net>. */ @@ -32,13 +32,17 @@ #endif #undef fcntl -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h> /* Get _get_osfhandle. */ -# include "msvc-nothrow.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif /* Upper bound on getdtablesize(). See lib/getdtablesize.c. */ # define OPEN_MAX_MAX 0x10000 @@ -89,8 +93,25 @@ dupfd (int oldfd, int newfd, int flags) inherit, /* InheritHandle */ DUPLICATE_SAME_ACCESS)) /* Options */ { - /* TODO: Translate GetLastError () into errno. */ - errno = EMFILE; + switch (GetLastError ()) + { + case ERROR_TOO_MANY_OPEN_FILES: + errno = EMFILE; + break; + case ERROR_INVALID_HANDLE: + case ERROR_INVALID_TARGET_HANDLE: + case ERROR_DIRECT_ACCESS_HANDLE: + errno = EBADF; + break; + case ERROR_INVALID_PARAMETER: + case ERROR_INVALID_FUNCTION: + case ERROR_INVALID_ACCESS: + errno = EINVAL; + break; + default: + errno = EACCES; + break; + } result = -1; break; } @@ -98,7 +119,6 @@ dupfd (int oldfd, int newfd, int flags) if (duplicated_fd < 0) { CloseHandle (new_handle); - errno = EMFILE; result = -1; break; } @@ -146,6 +166,93 @@ dupfd (int oldfd, int newfd, int flags) } #endif /* W32 */ +#ifdef __KLIBC__ + +# define INCL_DOS +# error #include <os2.h> + +static int +klibc_fcntl (int fd, int action, /* arg */...) +{ + va_list arg_ptr; + int arg; + struct stat sbuf; + int result = -1; + + va_start (arg_ptr, action); + arg = va_arg (arg_ptr, int); + result = fcntl (fd, action, arg); + /* EPERM for F_DUPFD, ENOTSUP for others */ + if (result == -1 && (errno == EPERM || errno == ENOTSUP) + && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) + { + ULONG ulMode; + + switch (action) + { + case F_DUPFD: + /* Find available fd */ + while (fcntl (arg, F_GETFL) != -1 || errno != EBADF) + arg++; + + result = dup2 (fd, arg); + break; + + /* Using underlying APIs is right ? */ + case F_GETFD: + if (DosQueryFHState (fd, &ulMode)) + break; + + result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0; + break; + + case F_SETFD: + if (arg & ~FD_CLOEXEC) + break; + + if (DosQueryFHState (fd, &ulMode)) + break; + + if (arg & FD_CLOEXEC) + ulMode |= OPEN_FLAGS_NOINHERIT; + else + ulMode &= ~OPEN_FLAGS_NOINHERIT; + + /* Filter supported flags. */ + ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR + | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT); + + if (DosSetFHState (fd, ulMode)) + break; + + result = 0; + break; + + case F_GETFL: + result = 0; + break; + + case F_SETFL: + if (arg != 0) + break; + + result = 0; + break; + + default : + errno = EINVAL; + break; + } + } + + va_end (arg_ptr); + + return result; +} + +# define fcntl klibc_fcntl +#endif + /* Perform the specified ACTION on the file descriptor FD, possibly using the argument ARG further described below. This replacement handles the following actions, and forwards all others on to the @@ -269,7 +376,7 @@ rpl_fcntl (int fd, int action, /* arg */...) #if !HAVE_FCNTL case F_GETFD: { -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ HANDLE handle = (HANDLE) _get_osfhandle (fd); DWORD flags; if (handle == INVALID_HANDLE_VALUE diff --git a/contrib/tools/bison/lib/fd-hook.c b/contrib/tools/bison/lib/fd-hook.c index e158a52aa3..95a0662bc0 100644 --- a/contrib/tools/bison/lib/fd-hook.c +++ b/contrib/tools/bison/lib/fd-hook.c @@ -1,5 +1,5 @@ -/* Hook for making making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2013 Free Software Foundation, Inc. +/* Hook for making file descriptor functions close(), ioctl() extensible. + Copyright (C) 2009-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it @@ -13,7 +13,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/fd-hook.h b/contrib/tools/bison/lib/fd-hook.h index d15b577114..dbc5b67a81 100644 --- a/contrib/tools/bison/lib/fd-hook.h +++ b/contrib/tools/bison/lib/fd-hook.h @@ -1,5 +1,5 @@ -/* Hook for making making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2013 Free Software Foundation, Inc. +/* Hook for making file descriptor functions close(), ioctl() extensible. + Copyright (C) 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -12,7 +12,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef FD_HOOK_H diff --git a/contrib/tools/bison/lib/fd-safer-flag.c b/contrib/tools/bison/lib/fd-safer-flag.c index 8bc14bda2c..b7574848d7 100644 --- a/contrib/tools/bison/lib/fd-safer-flag.c +++ b/contrib/tools/bison/lib/fd-safer-flag.c @@ -1,7 +1,7 @@ /* Adjust a file descriptor result so that it avoids clobbering STD{IN,OUT,ERR}_FILENO, with specific flags. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert and Eric Blake. */ diff --git a/contrib/tools/bison/lib/fd-safer.c b/contrib/tools/bison/lib/fd-safer.c index 8ded8886a5..1ea9a4981d 100644 --- a/contrib/tools/bison/lib/fd-safer.c +++ b/contrib/tools/bison/lib/fd-safer.c @@ -1,6 +1,6 @@ /* Return a safer copy of a file descriptor. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ diff --git a/contrib/tools/bison/lib/filename.h b/contrib/tools/bison/lib/filename.h index b82a0ac389..a7ad7e7e0c 100644 --- a/contrib/tools/bison/lib/filename.h +++ b/contrib/tools/bison/lib/filename.h @@ -1,5 +1,5 @@ /* Basic filename support macros. - Copyright (C) 2001-2004, 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _FILENAME_H #define _FILENAME_H @@ -28,7 +28,7 @@ extern "C" { it may be concatenated to a directory pathname. IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. */ -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ +#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Native Windows, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') # define HAS_DEVICE(P) \ diff --git a/contrib/tools/bison/lib/float+.h b/contrib/tools/bison/lib/float+.h index 32fb790bb5..2cb858f6a8 100644 --- a/contrib/tools/bison/lib/float+.h +++ b/contrib/tools/bison/lib/float+.h @@ -1,5 +1,5 @@ /* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _FLOATPLUS_H #define _FLOATPLUS_H diff --git a/contrib/tools/bison/lib/fopen-safer.c b/contrib/tools/bison/lib/fopen-safer.c index 917920d904..faf7b66426 100644 --- a/contrib/tools/bison/lib/fopen-safer.c +++ b/contrib/tools/bison/lib/fopen-safer.c @@ -1,6 +1,6 @@ /* Invoke fopen, but avoid some glitches. - Copyright (C) 2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ diff --git a/contrib/tools/bison/lib/fpending.c b/contrib/tools/bison/lib/fpending.c index e917f4f15f..de370d4b10 100644 --- a/contrib/tools/bison/lib/fpending.c +++ b/contrib/tools/bison/lib/fpending.c @@ -1,5 +1,5 @@ /* fpending.c -- return the number of pending output bytes on a stream - Copyright (C) 2000, 2004, 2006-2007, 2009-2013 Free Software Foundation, + Copyright (C) 2000, 2004, 2006-2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -13,18 +13,50 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Jim Meyering. */ #include <config.h> +/* Specification. */ #include "fpending.h" +#include "stdio-impl.h" + +/* This file is not used on systems that already have the __fpending function, + namely glibc >= 2.2, Solaris >= 7, Android API >= 23. */ + /* Return the number of pending (aka buffered, unflushed) bytes on the stream, FP, that is open for writing. */ size_t __fpending (FILE *fp) { - return PENDING_OUTPUT_N_BYTES; + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ + return fp->_IO_write_ptr - fp->_IO_write_base; +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ + return fp->_p - fp->_bf._base; +#elif defined __EMX__ /* emx+gcc */ + return fp->_ptr - fp->_buffer; +#elif defined __minix /* Minix */ + return fp_->_ptr - fp_->_buf; +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */ + return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0); +#elif defined __UCLIBC__ /* uClibc */ + return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0); +#elif defined __QNX__ /* QNX */ + return (fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + return fp->__bufp - fp->__buffer; +#elif defined EPLAN9 /* Plan9 */ + return fp->wp - fp->buf; +#else +# error "Please port gnulib fpending.c to your platform!" + return 1; +#endif } diff --git a/contrib/tools/bison/lib/fpending.h b/contrib/tools/bison/lib/fpending.h index bf40d3732e..2ff26bc6af 100644 --- a/contrib/tools/bison/lib/fpending.h +++ b/contrib/tools/bison/lib/fpending.h @@ -1,6 +1,6 @@ /* Declare __fpending. - Copyright (C) 2000, 2003, 2005-2006, 2009-2013 Free Software Foundation, + Copyright (C) 2000, 2003, 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,17 +14,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this program. If not, see <https://www.gnu.org/licenses/>. Written by Jim Meyering. */ #include <stddef.h> #include <stdio.h> +#if HAVE_STDIO_EXT_H +# include <stdio_ext.h> +#endif -#if HAVE_DECL___FPENDING -# if HAVE_STDIO_EXT_H -# include <stdio_ext.h> -# endif -#else -size_t __fpending (FILE *); +#if !HAVE_DECL___FPENDING +size_t __fpending (FILE *) _GL_ATTRIBUTE_PURE; #endif diff --git a/contrib/tools/bison/lib/fpucw.h b/contrib/tools/bison/lib/fpucw.h index 0b7f5284a1..0c04800885 100644 --- a/contrib/tools/bison/lib/fpucw.h +++ b/contrib/tools/bison/lib/fpucw.h @@ -1,5 +1,5 @@ -/* Manipulating the FPU control word. - Copyright (C) 2007-2013 Free Software Foundation, Inc. +/* Manipulating the FPU control word. -*- coding: utf-8 -*- + Copyright (C) 2007-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _FPUCW_H #define _FPUCW_H @@ -35,13 +35,13 @@ The FPU control word is under control of the application, i.e. it is not required to be set either way by the ABI. (In fact, the i386 ABI - http://refspecs.freestandards.org/elf/abi386-4.pdf page 3-12 = page 38 + https://www.linux-mips.org/pub/linux/mips/doc/ABI/abi386-4.pdf page 3-12 = page 38 is not clear about it. But in any case, gcc treats the control word like a "preserved" register: it emits code that assumes that the control word is preserved across calls, and it restores the control word at the end of functions that modify it.) - See Vincent Lefèvre's page http://www.vinc17.org/research/extended.en.html + See Vincent Lefèvre's page https://www.vinc17.net/research/extended.en.html for a good explanation. See http://www.uwsg.iu.edu/hypermail/linux/kernel/0103.0/0453.html for some argumentation which setting should be the default. */ diff --git a/contrib/tools/bison/lib/fseterr.c b/contrib/tools/bison/lib/fseterr.c index 7eeaf9ff70..81f51edade 100644 --- a/contrib/tools/bison/lib/fseterr.c +++ b/contrib/tools/bison/lib/fseterr.c @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -23,24 +23,27 @@ #include "stdio-impl.h" +/* This file is not used on systems that have the __fseterr function, + namely musl libc. */ + void fseterr (FILE *fp) { /* Most systems provide FILE as a struct and the necessary bitmask in <stdio.h>, because they need it for implementing getc() and putc() as fast macros. */ -#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 + /* GNU libc, BeOS, Haiku, Linux libc5 */ fp->_flags |= _IO_ERR_SEEN; -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ fp_->_flags |= __SERR; #elif defined __EMX__ /* emx+gcc */ fp->_flags |= _IOERR; #elif defined __minix /* Minix */ fp->_flags |= _IOERR; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */ fp_->_flag |= _IOERR; -#elif _MSC_VER - ((TWinSdk10File*)fp)->_flags |= WIN_SDK10_IOERROR; #elif defined __UCLIBC__ /* uClibc */ fp->__modeflags |= __FLAG_ERROR; #elif defined __QNX__ /* QNX */ diff --git a/contrib/tools/bison/lib/fseterr.h b/contrib/tools/bison/lib/fseterr.h index 630fa8647f..d61643313a 100644 --- a/contrib/tools/bison/lib/fseterr.h +++ b/contrib/tools/bison/lib/fseterr.h @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _FSETERR_H #define _FSETERR_H diff --git a/contrib/tools/bison/lib/get-errno.c b/contrib/tools/bison/lib/get-errno.c index 7865212cc7..fdce06586a 100644 --- a/contrib/tools/bison/lib/get-errno.c +++ b/contrib/tools/bison/lib/get-errno.c @@ -1,6 +1,7 @@ /* get-errno.c - get and set errno. - Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2015, 2018 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/lib/get-errno.h b/contrib/tools/bison/lib/get-errno.h index 04b3d4c8de..39c9c8a1f7 100644 --- a/contrib/tools/bison/lib/get-errno.h +++ b/contrib/tools/bison/lib/get-errno.h @@ -1,6 +1,6 @@ /* get-errno.h - get and set errno. - Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/lib/getdtablesize.c b/contrib/tools/bison/lib/getdtablesize.c index 212b3c0f96..ac05bc483c 100644 --- a/contrib/tools/bison/lib/getdtablesize.c +++ b/contrib/tools/bison/lib/getdtablesize.c @@ -1,5 +1,5 @@ -/* getdtablesize() function for platforms that don't have it. - Copyright (C) 2008-2013 Free Software Foundation, Inc. +/* getdtablesize() function: Return maximum possible file descriptor value + 1. + Copyright (C) 2008-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify @@ -13,20 +13,22 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #include <unistd.h> -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ -#include <stdio.h> +# include <stdio.h> -#include "msvc-inval.h" +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int _setmaxstdio_nothrow (int newmax) { @@ -44,10 +46,12 @@ _setmaxstdio_nothrow (int newmax) return result; } -# define _setmaxstdio _setmaxstdio_nothrow -#endif +# else +# define _setmaxstdio_nothrow _setmaxstdio +# endif -/* Cache for the previous getdtablesize () result. */ +/* Cache for the previous getdtablesize () result. Safe to cache because + Windows also lacks setrlimit. */ static int dtablesize; int @@ -73,18 +77,48 @@ getdtablesize (void) FILE objects. The sanity check in _setmaxstdio reveals the maximum number of file descriptors. This too allocates memory, but it is freed when we call _setmaxstdio with the original value. */ -#if !defined(_WIN32) && !defined(_WIN64) int orig_max_stdio = _getmaxstdio (); unsigned int bound; - for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2) + for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2) ; - _setmaxstdio (orig_max_stdio); + _setmaxstdio_nothrow (orig_max_stdio); dtablesize = bound; -#else - dtablesize = _getmaxstdio(); -#endif } return dtablesize; } +#else + +# include <limits.h> +# include <sys/resource.h> + +# ifndef RLIM_SAVED_CUR +# define RLIM_SAVED_CUR RLIM_INFINITY +# endif +# ifndef RLIM_SAVED_MAX +# define RLIM_SAVED_MAX RLIM_INFINITY +# endif + +# ifdef __CYGWIN__ + /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it + hits the compile-time constant hard limit of 3200. We might as + well just report the hard limit. */ +# define rlim_cur rlim_max +# endif + +int +getdtablesize (void) +{ + struct rlimit lim; + + if (getrlimit (RLIMIT_NOFILE, &lim) == 0 + && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX + && lim.rlim_cur != RLIM_INFINITY + && lim.rlim_cur != RLIM_SAVED_CUR + && lim.rlim_cur != RLIM_SAVED_MAX) + return lim.rlim_cur; + + return INT_MAX; +} + #endif diff --git a/contrib/tools/bison/lib/getopt.c b/contrib/tools/bison/lib/getopt.c index ef0f4ceec7..11e36eef81 100644 --- a/contrib/tools/bison/lib/getopt.c +++ b/contrib/tools/bison/lib/getopt.c @@ -1,23 +1,21 @@ /* Getopt for GNU. - NOTE: getopt is part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + Copyright (C) 1987-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ #ifndef _LIBC # include <config.h> @@ -31,30 +29,54 @@ #include <unistd.h> #ifdef _LIBC +/* When used as part of glibc, error printing must be done differently + for standards compliance. getopt is not a cancellation point, so + it must not call functions that are, and it is specified by an + older standard than stdio locking, so it must not refer to + functions in the "user namespace" related to stdio locking. + Finally, it must use glibc's internal message translation so that + the messages are looked up in the proper text domain. */ # include <libintl.h> +# define fprintf __fxprintf_nocancel +# define flockfile(fp) _IO_flockfile (fp) +# define funlockfile(fp) _IO_funlockfile (fp) #else # include "gettext.h" # define _(msgid) gettext (msgid) +/* When used standalone, flockfile and funlockfile might not be + available. */ +# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \ + || (defined _WIN32 && ! defined __CYGWIN__)) +# define flockfile(fp) /* nop */ +# define funlockfile(fp) /* nop */ +# endif +/* When used standalone, do not attempt to use alloca. */ +# define __libc_use_alloca(size) 0 +# undef alloca +# define alloca(size) (abort (), (void *)0) #endif -#if defined _LIBC && defined USE_IN_LIBIO -# include <wchar.h> -#endif - -/* This version of 'getopt' appears to the caller like standard Unix 'getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As 'getopt_long' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Using 'getopt' or setting the environment variable POSIXLY_CORRECT +/* This implementation of 'getopt' has three modes for handling + options interspersed with non-option arguments. It can stop + scanning for options at the first non-option argument encountered, + as POSIX specifies. It can continue scanning for options after the + first non-option argument, but permute 'argv' as it goes so that, + after 'getopt' is done, all the options precede all the non-option + arguments and 'optind' points to the first non-option argument. + Or, it can report non-option arguments as if they were arguments to + the option character '\x01'. + + The default behavior of 'getopt_long' is to permute the argument list. + When this implementation is used standalone, the default behavior of + 'getopt' is to stop at the first non-option argument, but when it is + used as part of GNU libc it also permutes the argument list. In both + cases, setting the environment variable POSIXLY_CORRECT to any value disables permutation. - Then the behavior is completely standard. - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ + If the first character of the OPTSTRING argument to 'getopt' or + 'getopt_long' is '+', both functions will stop at the first + non-option argument. If it is '-', both functions will report + non-option arguments as arguments to the option character '\x01'. */ #include "getopt_int.h" @@ -95,42 +117,7 @@ int optopt = '?'; /* Keep a global copy of all internal members of getopt_data. */ static struct _getopt_data getopt_data; - - -#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV -extern char *getenv (); -#endif -#ifdef _LIBC -/* Stored original parameters. - XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ -extern int __libc_argc; -extern char **__libc_argv; - -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -# ifdef USE_NONOPTION_FLAGS -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; -# endif - -# ifdef USE_NONOPTION_FLAGS -# define SWAP_FLAGS(ch1, ch2) \ - if (d->__nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -# else -# define SWAP_FLAGS(ch1, ch2) -# endif -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. @@ -153,64 +140,40 @@ exchange (char **argv, struct _getopt_data *d) It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ -#if defined _LIBC && defined USE_NONOPTION_FLAGS - /* First make sure the handling of the '__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - d->__nonoption_flags_max_len), - '\0', top + 1 - d->__nonoption_flags_max_len); - d->__nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - while (top > middle && middle > bottom) { if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } + { + /* Top segment is the short one. */ + int len = top - middle; + int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } } /* Update records for the slots the non-options now occupy. */ @@ -219,25 +182,216 @@ exchange (char **argv, struct _getopt_data *d) d->__last_nonopt = d->optind; } -/* Initialize the internal data when the first call is made. */ +/* Process the argument starting with d->__nextchar as a long option. + d->optind should *not* have been advanced over this argument. + + If the value returned is -1, it was not actually a long option, the + state is unchanged, and the argument should be processed as a set + of short options (this can only happen when long_only is true). + Otherwise, the option (and its argument, if any) have been consumed + and the return value is the value to return from _getopt_internal_r. */ +static int +process_long_option (int argc, char **argv, const char *optstring, + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, + int print_errors, const char *prefix) +{ + char *nameend; + size_t namelen; + const struct option *p; + const struct option *pfound = NULL; + int n_options; + int option_index; + + for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + namelen = nameend - d->__nextchar; + + /* First look for an exact match, counting the options as a side + effect. */ + for (p = longopts, n_options = 0; p->name; p++, n_options++) + if (!strncmp (p->name, d->__nextchar, namelen) + && namelen == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + option_index = n_options; + break; + } + + if (pfound == NULL) + { + /* Didn't find an exact match, so look for abbreviations. */ + unsigned char *ambig_set = NULL; + int ambig_malloced = 0; + int ambig_fallback = 0; + int indfound = -1; + + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, d->__nextchar, namelen)) + { + if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + { + /* Second or later nonexact match found. */ + if (!ambig_fallback) + { + if (!print_errors) + /* Don't waste effort tracking the ambig set if + we're not going to print it anyway. */ + ambig_fallback = 1; + else if (!ambig_set) + { + if (__libc_use_alloca (n_options)) + ambig_set = alloca (n_options); + else if ((ambig_set = malloc (n_options)) == NULL) + /* Fall back to simpler error message. */ + ambig_fallback = 1; + else + ambig_malloced = 1; + + if (ambig_set) + { + memset (ambig_set, 0, n_options); + ambig_set[indfound] = 1; + } + } + if (ambig_set) + ambig_set[option_index] = 1; + } + } + } + + if (ambig_set || ambig_fallback) + { + if (print_errors) + { + if (ambig_fallback) + fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"), + argv[0], prefix, d->__nextchar); + else + { + flockfile (stderr); + fprintf (stderr, + _("%s: option '%s%s' is ambiguous; possibilities:"), + argv[0], prefix, d->__nextchar); + + for (option_index = 0; option_index < n_options; option_index++) + if (ambig_set[option_index]) + fprintf (stderr, " '%s%s'", + prefix, longopts[option_index].name); + + /* This must use 'fprintf' even though it's only + printing a single character, so that it goes through + __fxprintf_nocancel when compiled as part of glibc. */ + fprintf (stderr, "\n"); + funlockfile (stderr); + } + } + if (ambig_malloced) + free (ambig_set); + d->__nextchar += strlen (d->__nextchar); + d->optind++; + d->optopt = 0; + return '?'; + } + + option_index = indfound; + } + + if (pfound == NULL) + { + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short option, + then it's an error. */ + if (!long_only || argv[d->optind][1] == '-' + || strchr (optstring, *d->__nextchar) == NULL) + { + if (print_errors) + fprintf (stderr, _("%s: unrecognized option '%s%s'\n"), + argv[0], prefix, d->__nextchar); + + d->__nextchar = NULL; + d->optind++; + d->optopt = 0; + return '?'; + } + + /* Otherwise interpret it as a short option. */ + return -1; + } + + /* We have found a matching long option. Consume it. */ + d->optind++; + d->__nextchar = NULL; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option '%s%s' doesn't allow an argument\n"), + argv[0], prefix, pfound->name); + + d->optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option '%s%s' requires an argument\n"), + argv[0], prefix, pfound->name); + + d->optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; +} + +/* Initialize internal data upon the first call to getopt. */ static const char * _getopt_initialize (int argc _GL_UNUSED, - char **argv _GL_UNUSED, const char *optstring, - struct _getopt_data *d, int posixly_correct) + char **argv _GL_UNUSED, const char *optstring, + struct _getopt_data *d, int posixly_correct) { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ + if (d->optind == 0) + d->optind = 1; d->__first_nonopt = d->__last_nonopt = d->optind; - d->__nextchar = NULL; - d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); - /* Determine how to handle the ordering of options and nonoptions. */ - if (optstring[0] == '-') { d->__ordering = RETURN_IN_ORDER; @@ -248,41 +402,12 @@ _getopt_initialize (int argc _GL_UNUSED, d->__ordering = REQUIRE_ORDER; ++optstring; } - else if (d->__posixly_correct) + else if (posixly_correct || !!getenv ("POSIXLY_CORRECT")) d->__ordering = REQUIRE_ORDER; else d->__ordering = PERMUTE; -#if defined _LIBC && defined USE_NONOPTION_FLAGS - if (!d->__posixly_correct - && argc == __libc_argc && argv == __libc_argv) - { - if (d->__nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - d->__nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = d->__nonoption_flags_max_len = strlen (orig_str); - if (d->__nonoption_flags_max_len < argc) - d->__nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (d->__nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - d->__nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', d->__nonoption_flags_max_len - len); - } - } - d->__nonoption_flags_len = d->__nonoption_flags_max_len; - } - else - d->__nonoption_flags_len = 0; -#endif - + d->__initialized = 1; return optstring; } @@ -344,8 +469,8 @@ _getopt_initialize (int argc _GL_UNUSED, int _getopt_internal_r (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, - int long_only, struct _getopt_data *d, int posixly_correct) + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, int posixly_correct) { int print_errors = d->opterr; @@ -355,431 +480,129 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, d->optarg = NULL; if (d->optind == 0 || !d->__initialized) - { - if (d->optind == 0) - d->optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring, d, - posixly_correct); - d->__initialized = 1; - } + optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct); else if (optstring[0] == '-' || optstring[0] == '+') optstring++; + if (optstring[0] == ':') print_errors = 0; - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#if defined _LIBC && defined USE_NONOPTION_FLAGS -# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ - || (d->optind < d->__nonoption_flags_len \ - && __getopt_nonoption_flags[d->optind] == '1')) -#else -# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') -#endif + /* Test whether ARGV[optind] points to a non-option argument. */ +#define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') if (d->__nextchar == NULL || *d->__nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ + moved back by the user (who may also have changed the arguments). */ if (d->__last_nonopt > d->optind) - d->__last_nonopt = d->optind; + d->__last_nonopt = d->optind; if (d->__first_nonopt > d->optind) - d->__first_nonopt = d->optind; + d->__first_nonopt = d->optind; if (d->__ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__last_nonopt != d->optind) - d->__first_nonopt = d->optind; + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange (argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ - while (d->optind < argc && NONOPTION_P) - d->optind++; - d->__last_nonopt = d->optind; - } + while (d->optind < argc && NONOPTION_P) + d->optind++; + d->__last_nonopt = d->optind; + } /* The special ARGV-element '--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ if (d->optind != argc && !strcmp (argv[d->optind], "--")) - { - d->optind++; + { + d->optind++; - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__first_nonopt == d->__last_nonopt) - d->__first_nonopt = d->optind; - d->__last_nonopt = argc; + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange (argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; - d->optind = argc; - } + d->optind = argc; + } /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ + and back over any non-options that we skipped and permuted. */ if (d->optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (d->__first_nonopt != d->__last_nonopt) - d->optind = d->__first_nonopt; - return -1; - } + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ + either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) - { - if (d->__ordering == REQUIRE_ORDER) - return -1; - d->optarg = argv[d->optind++]; - return 1; - } + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - d->__nextchar = (argv[d->optind] + 1 - + (longopts != NULL && argv[d->optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[d->optind][1] == '-' - || (long_only && (argv[d->optind][2] - || !strchr (optstring, argv[d->optind][1]))))) - { - char *nameend; - unsigned int namelen; - const struct option *p; - const struct option *pfound = NULL; - struct option_list - { - const struct option *p; - struct option_list *next; - } *ambig_list = NULL; - int exact = 0; - int indfound = -1; - int option_index; - - for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - namelen = nameend - d->__nextchar; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, namelen)) - { - if (namelen == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - { - /* Second or later nonexact match found. */ - struct option_list *newp = malloc (sizeof (*newp)); - newp->p = p; - newp->next = ambig_list; - ambig_list = newp; - } - } - - if (ambig_list != NULL && !exact) - { - if (print_errors) - { - struct option_list first; - first.p = pfound; - first.next = ambig_list; - ambig_list = &first; - -#if defined _LIBC && defined USE_IN_LIBIO - char *buf = NULL; - size_t buflen = 0; - - FILE *fp = open_memstream (&buf, &buflen); - if (fp != NULL) - { - fprintf (fp, - _("%s: option '%s' is ambiguous; possibilities:"), - argv[0], argv[d->optind]); - - do - { - fprintf (fp, " '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - - fputc_unlocked ('\n', fp); - - if (__builtin_expect (fclose (fp) != EOF, 1)) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } - } -#else - fprintf (stderr, - _("%s: option '%s' is ambiguous; possibilities:"), - argv[0], argv[d->optind]); - do - { - fprintf (stderr, " '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - - fputc ('\n', stderr); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - d->optopt = 0; - return '?'; - } - - while (ambig_list != NULL) - { - struct option_list *pn = ambig_list->next; - free (ambig_list); - ambig_list = pn; - } - - if (pfound != NULL) - { - option_index = indfound; - d->optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[d->optind - 1][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option '--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#else - fprintf (stderr, _("\ -%s: option '--%s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option '%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); -#else - fprintf (stderr, _("\ -%s: option '%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - - d->__nextchar += strlen (d->__nextchar); - - d->optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '--%s' requires an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option '--%s' requires an argument\n"), - argv[0], pfound->name); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[d->optind][1] == '-' - || strchr (optstring, *d->__nextchar) == NULL) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - - if (argv[d->optind][1] == '-') - { - /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), - argv[0], d->__nextchar); -#else - fprintf (stderr, _("%s: unrecognized option '--%s'\n"), - argv[0], d->__nextchar); -#endif - } - else - { - /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); -#else - fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); -#endif - } - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - d->__nextchar = (char *) ""; - d->optind++; - d->optopt = 0; - return '?'; - } + Check whether it might be a long option. */ + if (longopts) + { + if (argv[d->optind][1] == '-') + { + /* "--foo" is always a long option. The special option + "--" was handled above. */ + d->__nextchar = argv[d->optind] + 2; + return process_long_option (argc, argv, optstring, longopts, + longind, long_only, d, + print_errors, "--"); + } + + /* If long_only and the ARGV-element has the form "-f", + where f is a valid short option, don't consider it an + abbreviated form of a long option that starts with f. + Otherwise there would be no way to give the -f short + option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an + abbreviation of the long option, just like "--fu", and + not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + if (long_only && (argv[d->optind][2] + || !strchr (optstring, argv[d->optind][1]))) + { + int code; + d->__nextchar = argv[d->optind] + 1; + code = process_long_option (argc, argv, optstring, longopts, + longind, long_only, d, + print_errors, "-"); + if (code != -1) + return code; + } + } + + /* It is not a long option. Skip the initial punctuation. */ + d->__nextchar = argv[d->optind] + 1; } /* Look at and handle the next short option-character. */ @@ -794,331 +617,83 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (temp == NULL || c == ':' || c == ';') { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; -#endif - -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), - argv[0], c); -#else - fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); -#endif - -#if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#endif - } - d->optopt = c; - return '?'; + if (print_errors) + fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); + d->optopt = c; + return '?'; } + /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') + if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL) { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - if (longopts == NULL) - goto no_longs; - - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c); -#endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented 'd->optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; - nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), - argv[0], d->optarg) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), - argv[0], d->optarg); -#endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '-W %s' doesn't allow an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("\ -%s: option '-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); -#endif - } - - d->__nextchar += strlen (d->__nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option '-W %s' requires an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, _("\ -%s: option '-W %s' requires an argument\n"), - argv[0], pfound->name); -#endif - } - d->__nextchar += strlen (d->__nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - else - d->optarg = NULL; - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - no_longs: - d->__nextchar = NULL; - return 'W'; /* Let the application handle it. */ + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + d->optarg = d->__nextchar; + else if (d->optind == argc) + { + if (print_errors) + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); + + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + d->optarg = argv[d->optind]; + + d->__nextchar = d->optarg; + d->optarg = NULL; + return process_long_option (argc, argv, optstring, longopts, longind, + 0 /* long_only */, d, print_errors, "-W "); } if (temp[1] == ':') { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else - d->optarg = NULL; - d->__nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { -#if defined _LIBC && defined USE_IN_LIBIO - char *buf; - - if (__asprintf (&buf, _("\ -%s: option requires an argument -- '%c'\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); - - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - - __fxprintf (NULL, "%s", buf); - - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); - - free (buf); - } -#else - fprintf (stderr, - _("%s: option requires an argument -- '%c'\n"), - argv[0], c); -#endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented 'optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; - d->__nextchar = NULL; - } + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); + + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented 'optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } } return c; } @@ -1126,8 +701,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int _getopt_internal (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, int long_only, - int posixly_correct) + const struct option *longopts, int *longind, int long_only, + int posixly_correct) { int result; @@ -1135,8 +710,8 @@ _getopt_internal (int argc, char **argv, const char *optstring, getopt_data.opterr = opterr; result = _getopt_internal_r (argc, argv, optstring, longopts, - longind, long_only, &getopt_data, - posixly_correct); + longind, long_only, &getopt_data, + posixly_correct); optind = getopt_data.optind; optarg = getopt_data.optarg; @@ -1145,32 +720,23 @@ _getopt_internal (int argc, char **argv, const char *optstring, return result; } -/* glibc gets a LSB-compliant getopt. - Standalone applications get a POSIX-compliant getopt. */ -#if _LIBC -enum { POSIXLY_CORRECT = 0 }; -#else -enum { POSIXLY_CORRECT = 1 }; -#endif - -int -getopt (int argc, char *const *argv, const char *optstring) -{ - return _getopt_internal (argc, (char **) argv, optstring, - (const struct option *) 0, - (int *) 0, - 0, POSIXLY_CORRECT); -} +/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt. + Standalone applications just get a POSIX-compliant getopt. + POSIX and LSB both require these functions to take 'char *const *argv' + even though this is incorrect (because of the permutation). */ +#define GETOPT_ENTRY(NAME, POSIXLY_CORRECT) \ + int \ + NAME (int argc, char *const *argv, const char *optstring) \ + { \ + return _getopt_internal (argc, (char **)argv, optstring, \ + 0, 0, 0, POSIXLY_CORRECT); \ + } #ifdef _LIBC -int -__posix_getopt (int argc, char *const *argv, const char *optstring) -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0, 1); -} +GETOPT_ENTRY(getopt, 0) +GETOPT_ENTRY(__posix_getopt, 1) +#else +GETOPT_ENTRY(getopt, 1) #endif @@ -1191,51 +757,51 @@ main (int argc, char **argv) c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) - break; + break; switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value '%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) - printf ("%s ", argv[optind++]); + printf ("%s ", argv[optind++]); printf ("\n"); } diff --git a/contrib/tools/bison/lib/getopt1.c b/contrib/tools/bison/lib/getopt1.c index 55a6b4eae4..9c7fff4c73 100644 --- a/contrib/tools/bison/lib/getopt1.c +++ b/contrib/tools/bison/lib/getopt1.c @@ -1,56 +1,44 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1987-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ -#ifdef _LIBC -# include <getopt.h> -#else +#ifndef _LIBC # include <config.h> -# include "getopt.h" #endif -#include "getopt_int.h" - -#include <stdio.h> -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include <stdlib.h> -#endif - -#ifndef NULL -#define NULL 0 -#endif +#include "getopt.h" +#include "getopt_int.h" int getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, - const struct option *long_options, int *opt_index) + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 0, 0); + opt_index, 0, 0); } int _getopt_long_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 0, d, 0); + 0, d, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -60,26 +48,27 @@ _getopt_long_r (int argc, char **argv, const char *options, int getopt_long_only (int argc, char *__getopt_argv_const *argv, - const char *options, - const struct option *long_options, int *opt_index) + const char *options, + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 1, 0); + opt_index, 1, 0); } int _getopt_long_only_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 1, d, 0); + 1, d, 0); } #ifdef TEST #include <stdio.h> +#include <stdlib.h> int main (int argc, char **argv) @@ -93,74 +82,74 @@ main (int argc, char **argv) int option_index = 0; static const struct option long_options[] = { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); + long_options, &option_index); if (c == -1) - break; + break; switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value '%s'\n", optarg); - break; - - case 'd': - printf ("option d with value '%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case 'd': + printf ("option d with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) - printf ("%s ", argv[optind++]); + printf ("%s ", argv[optind++]); printf ("\n"); } diff --git a/contrib/tools/bison/lib/getopt_int.h b/contrib/tools/bison/lib/getopt_int.h index a6e4b9ea71..b0e9a6d012 100644 --- a/contrib/tools/bison/lib/getopt_int.h +++ b/contrib/tools/bison/lib/getopt_int.h @@ -1,30 +1,31 @@ /* Internal declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1989-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ #ifndef _GETOPT_INT_H -#define _GETOPT_INT_H 1 +#define _GETOPT_INT_H 1 #include <getopt.h> extern int _getopt_internal (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, int __posixly_correct); + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int __posixly_correct); /* Reentrant versions which can handle parsing multiple argument @@ -32,28 +33,20 @@ extern int _getopt_internal (int ___argc, char **___argv, /* Describe how to deal with options that follow non-option ARGV-elements. - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. + REQUIRE_ORDER means don't recognize them as options; stop option + processing when the first non-option is seen. This is what POSIX + specifies should happen. - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using '+' as the first character - of the list of option characters, or by calling getopt. - - PERMUTE is the default. We permute the contents of ARGV as we - scan, so that eventually all the non-options are at the end. - This allows options to be given in any order, even with programs - that were not written to expect this. + PERMUTE means permute the contents of ARGV as we scan, so that + eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written + to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option - with character code 1. Using '-' as the first character of the - list of option characters selects this mode of operation. + with character code 1. The special argument '--' forces an end of option-scanning regardless of the value of 'ordering'. In the case of RETURN_IN_ORDER, only @@ -91,11 +84,6 @@ struct _getopt_data /* See __ord above. */ enum __ord __ordering; - /* If the POSIXLY_CORRECT environment variable is set - or getopt was called. */ - int __posixly_correct; - - /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have @@ -104,32 +92,27 @@ struct _getopt_data int __first_nonopt; int __last_nonopt; - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - int __nonoption_flags_max_len; - int __nonoption_flags_len; -#endif }; /* The initializer is necessary to set OPTIND and OPTERR to their default values and to clear the initialization flag. */ -#define _GETOPT_DATA_INITIALIZER { 1, 1 } +#define _GETOPT_DATA_INITIALIZER { 1, 1 } extern int _getopt_internal_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, struct _getopt_data *__data, - int __posixly_correct); + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, struct _getopt_data *__data, + int __posixly_correct); extern int _getopt_long_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - struct _getopt_data *__data); + const char *__shortopts, + const struct option *__longopts, int *__longind, + struct _getopt_data *__data); extern int _getopt_long_only_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, - int *__longind, - struct _getopt_data *__data); + const char *__shortopts, + const struct option *__longopts, + int *__longind, + struct _getopt_data *__data); #endif /* getopt_int.h */ diff --git a/contrib/tools/bison/lib/getprogname.c b/contrib/tools/bison/lib/getprogname.c new file mode 100644 index 0000000000..43f37505ea --- /dev/null +++ b/contrib/tools/bison/lib/getprogname.c @@ -0,0 +1,191 @@ +/* Program name management. + Copyright (C) 2016-2018 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include "getprogname.h" + +#include <errno.h> /* get program_invocation_name declaration */ +#include <stdlib.h> /* get __argv declaration */ + +#ifdef _AIX +# include <unistd.h> +# include <procinfo.h> +# include <string.h> +#endif + +#ifdef __MVS__ +# ifndef _OPEN_SYS +# define _OPEN_SYS +# endif +# include <string.h> +# error #include <sys/ps.h> +#endif + +#ifdef __hpux +# include <unistd.h> +# include <sys/param.h> +# include <sys/pstat.h> +# include <string.h> +#endif + +#ifdef __sgi +# include <string.h> +# include <unistd.h> +# include <stdio.h> +# include <fcntl.h> +# include <sys/procfs.h> +#endif + +#include "dirname.h" + +#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ +char const * +getprogname (void) +{ +# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */ + /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */ + return program_invocation_short_name; +# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */ + /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */ + return last_component (program_invocation_name); +# elif HAVE_GETEXECNAME /* Solaris */ + /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */ + const char *p = getexecname (); + if (!p) + p = "?"; + return last_component (p); +# elif HAVE_DECL___ARGV /* mingw, MSVC */ + /* https://msdn.microsoft.com/en-us/library/dn727674.aspx */ + const char *p = __argv && __argv[0] ? __argv[0] : "?"; + return last_component (p); +# elif HAVE_VAR___PROGNAME /* OpenBSD, QNX */ + /* https://man.openbsd.org/style.9 */ + /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */ + /* Be careful to declare this only when we absolutely need it + (OpenBSD 5.1), rather than when it's available. Otherwise, + its mere declaration makes program_invocation_short_name + malfunction (have zero length) with Fedora 25's glibc. */ + extern char *__progname; + const char *p = __progname; + return p && p[0] ? p : "?"; +# elif _AIX /* AIX */ + /* Idea by Bastien ROUCARIÈS, + https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html + Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm + */ + static char *p; + static int first = 1; + if (first) + { + first = 0; + pid_t pid = getpid (); + struct procentry64 procs; + p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1) + ? strdup (procs.pi_comm) + : NULL); + if (!p) + p = "?"; + } + return p; +# elif defined __hpux + static char *p; + static int first = 1; + if (first) + { + first = 0; + pid_t pid = getpid (); + struct pst_status status; + p = (0 < pstat_getproc (&status, sizeof status, 0, pid) + ? strdup (status.pst_ucomm) + : NULL); + if (!p) + p = "?"; + } + return p; +# elif __MVS__ /* z/OS */ + /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */ + static char *p = "?"; + static int first = 1; + if (first) + { + pid_t pid = getpid (); + int token; + W_PSPROC buf; + first = 0; + memset (&buf, 0, sizeof(buf)); + buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG); + buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN); + buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN); + if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr) + { + for (token = 0; token >= 0; + token = w_getpsent (token, &buf, sizeof(buf))) + { + if (token > 0 && buf.ps_pid == pid) + { + char *s = strdup (last_component (buf.ps_pathptr)); + if (s) + p = s; + break; + } + } + } + free (buf.ps_cmdptr); + free (buf.ps_conttyptr); + free (buf.ps_pathptr); + } + return p; +# elif defined __sgi /* IRIX */ + char filename[50]; + int fd; + + sprintf (filename, "/proc/pinfo/%d", (int) getpid ()); + fd = open (filename, O_RDONLY); + if (0 <= fd) + { + prpsinfo_t buf; + int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf); + close (fd); + if (ioctl_ok) + { + char *name = buf.pr_fname; + size_t namesize = sizeof buf.pr_fname; + char *namenul = memchr (name, '\0', namesize); + size_t namelen = namenul ? namenul - name : namesize; + char *namecopy = malloc (namelen + 1); + if (namecopy) + { + namecopy[namelen] = 0; + return memcpy (namecopy, name, namelen); + } + } + } + return NULL; +# else +# error "getprogname module not ported to this OS" +# endif +} + +#endif + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/contrib/tools/bison/lib/getprogname.h b/contrib/tools/bison/lib/getprogname.h new file mode 100644 index 0000000000..ee6688fc2a --- /dev/null +++ b/contrib/tools/bison/lib/getprogname.h @@ -0,0 +1,40 @@ +/* Program name management. + Copyright (C) 2016-2018 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#ifndef _GL_GETPROGNAME_H +#define _GL_GETPROGNAME_H + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return the base name of the executing program. + On native Windows this will usually end in ".exe" or ".EXE". */ +#ifndef HAVE_GETPROGNAME +extern char const *getprogname (void) +# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME + _GL_ATTRIBUTE_PURE +# endif + ; +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/tools/bison/lib/gettext.h b/contrib/tools/bison/lib/gettext.h index d0215715a9..f2d7458f4a 100644 --- a/contrib/tools/bison/lib/gettext.h +++ b/contrib/tools/bison/lib/gettext.h @@ -1,5 +1,5 @@ /* Convenience header for conditional use of GNU <libintl.h>. - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -13,13 +13,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS +/* NLS can be disabled through the configure --disable-nls option + or through "#define ENABLE NLS 0" before including this file. */ +#if defined ENABLE_NLS && ENABLE_NLS /* Get declarations of GNU message catalog functions. */ # include <libintl.h> @@ -184,7 +185,8 @@ npgettext_aux (const char *domain, #include <string.h> #if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ >= 199901L */ ) + /* || __STDC_VERSION__ == 199901L + || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ) # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 #else # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 @@ -225,15 +227,17 @@ dcpgettext_expr (const char *domain, if (msg_ctxt_id != NULL) #endif { + int found_translation; memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); translation = dcgettext (domain, msg_ctxt_id, category); + found_translation = (translation != msg_ctxt_id); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) free (msg_ctxt_id); #endif - if (translation != msg_ctxt_id) + if (found_translation) return translation; } return msgid; @@ -271,15 +275,17 @@ dcnpgettext_expr (const char *domain, if (msg_ctxt_id != NULL) #endif { + int found_translation; memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + found_translation = !(translation == msg_ctxt_id || translation == msgid_plural); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) free (msg_ctxt_id); #endif - if (!(translation == msg_ctxt_id || translation == msgid_plural)) + if (found_translation) return translation; } return (n == 1 ? msgid : msgid_plural); diff --git a/contrib/tools/bison/lib/glthread/lock.c b/contrib/tools/bison/lib/glthread/lock.c index f62aa301fe..f166d7ca8c 100644 --- a/contrib/tools/bison/lib/glthread/lock.c +++ b/contrib/tools/bison/lib/glthread/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>, 2005. Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, @@ -30,9 +30,38 @@ /* ------------------------- gl_rwlock_t datatype ------------------------- */ -# if HAVE_PTHREAD_RWLOCK +# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) -# if !defined PTHREAD_RWLOCK_INITIALIZER +# ifdef PTHREAD_RWLOCK_INITIALIZER + +# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ + +int +glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock) +{ + pthread_rwlockattr_t attributes; + int err; + + err = pthread_rwlockattr_init (&attributes); + if (err != 0) + return err; + /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that + causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not + do this; see + http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ + err = pthread_rwlockattr_setkind_np (&attributes, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + if (err == 0) + err = pthread_rwlock_init(lock, &attributes); + /* pthread_rwlockattr_destroy always returns 0. It cannot influence the + return value. */ + pthread_rwlockattr_destroy (&attributes); + return err; +} + +# endif +# else int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) @@ -152,11 +181,9 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) if (err != 0) return err; /* Test whether only readers are currently running, and whether the runcount - field will not overflow. */ - /* POSIX says: "It is implementation-defined whether the calling thread - acquires the lock when a writer does not hold the lock and there are - writers blocked on the lock." Let's say, no: give the writers a higher - priority. */ + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) { /* This thread has to wait for a while. Enqueue it among the @@ -481,6 +508,141 @@ glthread_once_singlethreaded (pthread_once_t *once_control) /* ------------------------- gl_rwlock_t datatype ------------------------- */ +# if !HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER + +int +glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) +{ + if (!pth_mutex_init (&lock->lock)) + return errno; + if (!pth_cond_init (&lock->waiting_readers)) + return errno; + if (!pth_cond_init (&lock->waiting_writers)) + return errno; + lock->waiting_writers_count = 0; + lock->runcount = 0; + lock->initialized = 1; + return 0; +} + +int +glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + glthread_rwlock_init_multithreaded (lock); + if (!pth_mutex_acquire (&lock->lock, 0, NULL)) + return errno; + /* Test whether only readers are currently running, and whether the runcount + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ + while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + if (!pth_cond_await (&lock->waiting_readers, &lock->lock, NULL)) + { + int err = errno; + pth_mutex_release (&lock->lock); + return err; + } + } + lock->runcount++; + return (!pth_mutex_release (&lock->lock) ? errno : 0); +} + +int +glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + glthread_rwlock_init_multithreaded (lock); + if (!pth_mutex_acquire (&lock->lock, 0, NULL)) + return errno; + /* Test whether no readers or writers are currently running. */ + while (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + lock->waiting_writers_count++; + if (!pth_cond_await (&lock->waiting_writers, &lock->lock, NULL)) + { + int err = errno; + lock->waiting_writers_count--; + pth_mutex_release (&lock->lock); + return err; + } + lock->waiting_writers_count--; + } + lock->runcount--; /* runcount becomes -1 */ + return (!pth_mutex_release (&lock->lock) ? errno : 0); +} + +int +glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + if (!lock->initialized) + return EINVAL; + if (!pth_mutex_acquire (&lock->lock, 0, NULL)) + return errno; + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + { + pth_mutex_release (&lock->lock); + return EINVAL; + } + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + pth_mutex_release (&lock->lock); + return EINVAL; + } + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers_count > 0) + { + /* Wake up one of the waiting writers. */ + if (!pth_cond_notify (&lock->waiting_writers, FALSE)) + { + int err = errno; + pth_mutex_release (&lock->lock); + return err; + } + } + else + { + /* Wake up all waiting readers. */ + if (!pth_cond_notify (&lock->waiting_readers, TRUE)) + { + int err = errno; + pth_mutex_release (&lock->lock); + return err; + } + } + } + return (!pth_mutex_release (&lock->lock) ? errno : 0); +} + +int +glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) +{ + lock->initialized = 0; + return 0; +} + +# endif + /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* -------------------------- gl_once_t datatype -------------------------- */ @@ -796,8 +958,10 @@ glthread_rwlock_rdlock_func (gl_rwlock_t *lock) } EnterCriticalSection (&lock->lock); /* Test whether only readers are currently running, and whether the runcount - field will not overflow. */ - if (!(lock->runcount + 1 > 0)) + field will not overflow, and whether no writer is waiting. The latter + condition is because POSIX recommends that "write locks shall take + precedence over read locks", to avoid "writer starvation". */ + if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) { /* This thread has to wait for a while. Enqueue it among the waiting_readers. */ diff --git a/contrib/tools/bison/lib/glthread/lock.h b/contrib/tools/bison/lib/glthread/lock.h index 42228df80f..9c9e2f6840 100644 --- a/contrib/tools/bison/lib/glthread/lock.h +++ b/contrib/tools/bison/lib/glthread/lock.h @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>, 2005. Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, @@ -139,13 +139,24 @@ extern int glthread_in_use (void); # pragma weak pthread_mutexattr_init # pragma weak pthread_mutexattr_settype # pragma weak pthread_mutexattr_destroy +# pragma weak pthread_rwlockattr_init +# if __GNU_LIBRARY__ > 1 +# pragma weak pthread_rwlockattr_setkind_np +# endif +# pragma weak pthread_rwlockattr_destroy # ifndef pthread_self # pragma weak pthread_self # endif # if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) + /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols + can be used to determine whether libpthread is in use. These are: + pthread_mutexattr_gettype + pthread_rwlockattr_destroy + pthread_rwlockattr_init + */ +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() (pthread_mutexattr_gettype != NULL) # endif # else @@ -176,7 +187,7 @@ typedef pthread_mutex_t gl_lock_t; /* ------------------------- gl_rwlock_t datatype ------------------------- */ -# if HAVE_PTHREAD_RWLOCK +# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) # ifdef PTHREAD_RWLOCK_INITIALIZER @@ -185,10 +196,18 @@ typedef pthread_rwlock_t gl_rwlock_t; STORAGECLASS pthread_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - PTHREAD_RWLOCK_INITIALIZER -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) +# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) +# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0) +extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock); +# endif # define glthread_rwlock_rdlock(LOCK) \ (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) # define glthread_rwlock_wrlock(LOCK) \ @@ -427,6 +446,9 @@ typedef pth_mutex_t gl_lock_t; /* ------------------------- gl_rwlock_t datatype ------------------------- */ +/* Pth pth_rwlock_acquire always prefers readers. No autoconf test so far. */ +# if HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER + typedef pth_rwlock_t gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS pth_rwlock_t NAME; @@ -445,6 +467,42 @@ typedef pth_rwlock_t gl_rwlock_t; # define glthread_rwlock_destroy(LOCK) \ ((void)(LOCK), 0) +# else + +typedef struct + { + int initialized; + pth_mutex_t lock; /* protects the remaining fields */ + pth_cond_t waiting_readers; /* waiting readers */ + pth_cond_t waiting_writers; /* waiting writers */ + unsigned int waiting_writers_count; /* number of waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { 0 } +# define glthread_rwlock_init(LOCK) \ + (pth_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pth_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pth_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pth_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pth_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) +extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); + +# endif + /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* In Pth, mutexes are recursive by default. */ diff --git a/contrib/tools/bison/lib/glthread/threadlib.c b/contrib/tools/bison/lib/glthread/threadlib.c index b447657302..e8b484a05c 100644 --- a/contrib/tools/bison/lib/glthread/threadlib.c +++ b/contrib/tools/bison/lib/glthread/threadlib.c @@ -1,5 +1,5 @@ /* Multithreading primitives. - Copyright (C) 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>, 2005. */ diff --git a/contrib/tools/bison/lib/hard-locale.c b/contrib/tools/bison/lib/hard-locale.c new file mode 100644 index 0000000000..49bc6caff4 --- /dev/null +++ b/contrib/tools/bison/lib/hard-locale.c @@ -0,0 +1,72 @@ +/* hard-locale.c -- Determine whether a locale is hard. + + Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2018 Free Software + Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "hard-locale.h" + +#include <locale.h> +#include <stdlib.h> +#include <string.h> + +#ifdef __GLIBC__ +# define GLIBC_VERSION __GLIBC__ +#elif defined __UCLIBC__ +# define GLIBC_VERSION 2 +#else +# define GLIBC_VERSION 0 +#endif + +/* Return true if the current CATEGORY locale is hard, i.e. if you + can't get away with assuming traditional C or POSIX behavior. */ +bool +hard_locale (int category) +{ + bool hard = true; + char const *p = setlocale (category, NULL); + + if (p) + { + if (2 <= GLIBC_VERSION) + { + if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) + hard = false; + } + else + { + char *locale = strdup (p); + if (locale) + { + /* Temporarily set the locale to the "C" and "POSIX" locales + to find their names, so that we can determine whether one + or the other is the caller's locale. */ + if (((p = setlocale (category, "C")) + && strcmp (p, locale) == 0) + || ((p = setlocale (category, "POSIX")) + && strcmp (p, locale) == 0)) + hard = false; + + /* Restore the caller's locale. */ + setlocale (category, locale); + free (locale); + } + } + } + + return hard; +} diff --git a/contrib/tools/bison/lib/isnanl.c b/contrib/tools/bison/lib/hard-locale.h index 9d9d84b974..22eecc5ed8 100644 --- a/contrib/tools/bison/lib/isnanl.c +++ b/contrib/tools/bison/lib/hard-locale.h @@ -1,5 +1,6 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. +/* Determine whether a locale is hard. + + Copyright (C) 1999, 2003-2004, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,9 +13,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#ifndef HARD_LOCALE_H_ +# define HARD_LOCALE_H_ 1 + +# include <stdbool.h> -/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +bool hard_locale (int); -#define USE_LONG_DOUBLE -#include "isnan.c" +#endif /* HARD_LOCALE_H_ */ diff --git a/contrib/tools/bison/lib/hash.c b/contrib/tools/bison/lib/hash.c index 685928ec0c..98a8ea3d3c 100644 --- a/contrib/tools/bison/lib/hash.c +++ b/contrib/tools/bison/lib/hash.c @@ -1,6 +1,6 @@ /* hash - hashing table processing. - Copyright (C) 1998-2004, 2006-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1998-2004, 2006-2007, 2009-2018 Free Software Foundation, Inc. Written by Jim Meyering, 1992. @@ -15,7 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* A generic hash table package. */ @@ -1116,14 +1116,6 @@ hash_insert_if_absent (Hash_table *table, void const *entry, return 1; } -/* hash_insert0 is the deprecated name for hash_insert_if_absent. - . */ -int -hash_insert0 (Hash_table *table, void const *entry, void const **matched_ent) -{ - return hash_insert_if_absent (table, entry, matched_ent); -} - /* If ENTRY matches an entry already in the hash table, return the pointer to the entry from the table. Otherwise, insert ENTRY and return ENTRY. Return NULL if the storage required for insertion cannot be allocated. diff --git a/contrib/tools/bison/lib/hash.h b/contrib/tools/bison/lib/hash.h index bcd0d1d96b..562f5e6796 100644 --- a/contrib/tools/bison/lib/hash.h +++ b/contrib/tools/bison/lib/hash.h @@ -1,5 +1,5 @@ /* hash - hashing table processing. - Copyright (C) 1998-1999, 2001, 2003, 2009-2013 Free Software Foundation, + Copyright (C) 1998-1999, 2001, 2003, 2009-2018 Free Software Foundation, Inc. Written by Jim Meyering <meyering@ascend.com>, 1998. @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* A generic hash table package. */ @@ -96,10 +96,6 @@ void hash_free (Hash_table *); bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR; void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR; -/* Deprecate this interface. It has been renamed to hash_insert_if_absent. */ -int hash_insert0 (Hash_table *table, /* FIXME: remove in 2013 */ - const void *entry, - const void **matched_ent) _GL_ATTRIBUTE_DEPRECATED; int hash_insert_if_absent (Hash_table *table, const void *entry, const void **matched_ent); void *hash_delete (Hash_table *, const void *); diff --git a/contrib/tools/bison/lib/intprops.h b/contrib/tools/bison/lib/intprops.h new file mode 100644 index 0000000000..15e470cbc6 --- /dev/null +++ b/contrib/tools/bison/lib/intprops.h @@ -0,0 +1,453 @@ +/* intprops.h -- properties of integer types + + Copyright (C) 2001-2018 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +#ifndef _GL_INTPROPS_H +#define _GL_INTPROPS_H + +#include <limits.h> + +/* Return a value with the common real type of E and V and the value of V. */ +#define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) + +/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see + <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */ +#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the arithmetic type T is an integer type. bool counts as + an integer. */ +#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) + +/* True if the real type T is signed. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* Return 1 if the real expression E, after promotion, has a + signed or floating type. */ +#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) + + +/* Minimum and maximum values for integer types and expressions. */ + +/* The width in bits of the integer type or expression T. + Padding bits are not supported; this is checked at compile-time below. */ +#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) + +/* The maximum and minimum values for the integer type T. */ +#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) + +/* The maximum and minimum values for the type of the expression E, + after integer promotion. E should not have side effects. */ +#define _GL_INT_MINIMUM(e) \ + (EXPR_SIGNED (e) \ + ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_CONVERT (e, 0)) +#define _GL_INT_MAXIMUM(e) \ + (EXPR_SIGNED (e) \ + ? _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_NEGATE_CONVERT (e, 1)) +#define _GL_SIGNED_INT_MAXIMUM(e) \ + (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1) + +/* Work around OpenVMS incompatibility with C99. */ +#if !defined LLONG_MAX && defined __INT64_MAX +# define LLONG_MAX __INT64_MAX +# define LLONG_MIN __INT64_MIN +#endif + +/* This include file assumes that signed types are two's complement without + padding bits; the above macros have undefined behavior otherwise. + If this is a problem for you, please let us know how to fix it for your host. + This assumption is tested by the intprops-tests module. */ + +/* Does the __typeof__ keyword work? This could be done by + 'configure', but for now it's easier to do it by hand. */ +#if (2 <= __GNUC__ \ + || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ + || (0x5110 <= __SUNPRO_C && !__STDC__)) +# define _GL_HAVE___TYPEOF__ 1 +#else +# define _GL_HAVE___TYPEOF__ 0 +#endif + +/* Return 1 if the integer type or expression T might be signed. Return 0 + if it is definitely unsigned. This macro does not evaluate its argument, + and expands to an integer constant expression. */ +#if _GL_HAVE___TYPEOF__ +# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) +#else +# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 +#endif + +/* Bound on length of the string representing an unsigned integer + value representable in B bits. log10 (2.0) < 146/485. The + smallest value of B where this bound is not tight is 2621. */ +#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) + +/* Bound on length of the string representing an integer type or expression T. + Subtract 1 for the sign bit if T is signed, and then add 1 more for + a minus sign if needed. + + Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is + signed, this macro may overestimate the true bound by one byte when + applied to unsigned types of size 2, 4, 16, ... bytes. */ +#define INT_STRLEN_BOUND(t) \ + (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \ + + _GL_SIGNED_TYPE_OR_EXPR (t)) + +/* Bound on buffer size needed to represent an integer type or expression T, + including the terminating null. */ +#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) + + +/* Range overflow checks. + + The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C + operators might not yield numerically correct answers due to + arithmetic overflow. They do not rely on undefined or + implementation-defined behavior. Their implementations are simple + and straightforward, but they are a bit harder to use than the + INT_<op>_OVERFLOW macros described below. + + Example usage: + + long int i = ...; + long int j = ...; + if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) + printf ("multiply would overflow"); + else + printf ("product is %ld", i * j); + + Restrictions on *_RANGE_OVERFLOW macros: + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, + so the arguments should not have side effects. The arithmetic + arguments (including the MIN and MAX arguments) must be of the same + integer type after the usual arithmetic conversions, and the type + must have minimum value MIN and maximum MAX. Unsigned types should + use a zero MIN of the proper type. + + These macros are tuned for constant MIN and MAX. For commutative + operations such as A + B, they are also tuned for constant B. */ + +/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (a) < (min) - (b) \ + : (max) - (b) < (a)) + +/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (max) + (b) < (a) \ + : (a) < (min) + (b)) + +/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ + ((min) < 0 \ + ? (a) < - (max) \ + : 0 < (a)) + +/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Avoid && and || as they tickle + bugs in Sun C 5.11 2010/08/13 and other compilers; see + <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */ +#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? ((a) < 0 \ + ? (a) < (max) / (b) \ + : (b) == -1 \ + ? 0 \ + : (min) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (a) < (min) / (b) \ + : (max) / (b) < (a))) + +/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. */ +#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ + ((min) < 0 && (b) == -1 && (a) < - (max)) + +/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. + Mathematically, % should never overflow, but on x86-like hosts + INT_MIN % -1 traps, and the C standard permits this, so treat this + as an overflow too. */ +#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ + INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) + +/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Here, MIN and MAX are for A only, and B need + not be of the same type as the other arguments. The C standard says that + behavior is undefined for shifts unless 0 <= B < wordwidth, and that when + A is negative then A << B has undefined behavior and A >> B has + implementation-defined behavior, but do not check these other + restrictions. */ +#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ + ((a) < 0 \ + ? (a) < (min) >> (b) \ + : (max) >> (b) < (a)) + +/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ +#if 5 <= __GNUC__ && !defined __ICC +# define _GL_HAS_BUILTIN_OVERFLOW 1 +#else +# define _GL_HAS_BUILTIN_OVERFLOW 0 +#endif + +/* True if __builtin_add_overflow_p (A, B, C) works. */ +#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) + +/* The _GL*_OVERFLOW macros have the same restrictions as the + *_RANGE_OVERFLOW macros, except that they do not assume that operands + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume + that the result (e.g., A + B) has that type. */ +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define _GL_ADD_OVERFLOW(a, b, min, max) \ + __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) +#else +# define _GL_ADD_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? (b) <= (a) + (b) \ + : (b) < 0 ? (a) <= (a) + (b) \ + : (a) + (b) < (b)) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? 1 \ + : (b) < 0 ? (a) - (b) <= (a) \ + : (a) < (b)) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ + || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) +#endif +#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (b) <= (a) + (b) - 1 \ + : (b) < 0 && (a) + (b) <= (a)) +#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ + : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) + +/* Return a nonzero value if A is a mathematical multiple of B, where + A is unsigned, B is negative, and MAX is the maximum value of A's + type. A's type must be the same as (A % B)'s type. Normally (A % + -B == 0) suffices, but things get tricky if -B would overflow. */ +#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ + (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ + ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ + ? (a) \ + : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ + : (a) % - (b)) \ + == 0) + +/* Check for integer overflow, and report low order bits of answer. + + The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators + might not yield numerically correct answers due to arithmetic overflow. + The INT_<op>_WRAPV macros also store the low-order bits of the answer. + These macros work correctly on all known practical hosts, and do not rely + on undefined behavior due to signed arithmetic overflow. + + Example usage, assuming A and B are long int: + + if (INT_MULTIPLY_OVERFLOW (a, b)) + printf ("result would overflow\n"); + else + printf ("result is %ld (no overflow)\n", a * b); + + Example usage with WRAPV flavor: + + long int result; + bool overflow = INT_MULTIPLY_WRAPV (a, b, &result); + printf ("result is %ld (%s)\n", result, + overflow ? "after overflow" : "no overflow"); + + Restrictions on these macros: + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, so the + arguments should not have side effects. + + The WRAPV macros are not constant expressions. They support only + +, binary -, and *. The result type must be signed. + + These macros are tuned for their last argument being a constant. + + Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, + A % B, and A << B would overflow, respectively. */ + +#define INT_ADD_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) +#define INT_SUBTRACT_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) +#else +# define INT_NEGATE_OVERFLOW(a) \ + INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) +#endif +#define INT_MULTIPLY_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) +#define INT_DIVIDE_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) +#define INT_REMAINDER_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) +#define INT_LEFT_SHIFT_OVERFLOW(a, b) \ + INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ + _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) + +/* Return 1 if the expression A <op> B would overflow, + where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, + assuming MIN and MAX are the minimum and maximum for the result type. + Arguments should be free of side effects. */ +#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ + op_result_overflow (a, b, \ + _GL_INT_MINIMUM (0 * (b) + (a)), \ + _GL_INT_MAXIMUM (0 * (b) + (a))) + +/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. + Return 1 if the result overflows. See above for restrictions. */ +#define INT_ADD_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW) +#define INT_SUBTRACT_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW) +#define INT_MULTIPLY_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) + +/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 + https://llvm.org/bugs/show_bug.cgi?id=25390 + For now, assume all versions of GCC-like compilers generate bogus + warnings for _Generic. This matters only for older compilers that + lack __builtin_add_overflow. */ +#if __GNUC__ +# define _GL__GENERIC_BOGUS 1 +#else +# define _GL__GENERIC_BOGUS 0 +#endif + +/* Store the low-order bits of A <op> B into *R, where OP specifies + the operation. BUILTIN is the builtin operation, and OVERFLOW the + overflow predicate. Return 1 if the result overflows. See above + for restrictions. */ +#if _GL_HAS_BUILTIN_OVERFLOW +# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) +#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS +# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ + (_Generic \ + (*(r), \ + signed char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + signed char, SCHAR_MIN, SCHAR_MAX), \ + short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + short int, SHRT_MIN, SHRT_MAX), \ + int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX), \ + long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX), \ + long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX))) +#else +# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ + (sizeof *(r) == sizeof (signed char) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + signed char, SCHAR_MIN, SCHAR_MAX) \ + : sizeof *(r) == sizeof (short int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + short int, SHRT_MIN, SHRT_MAX) \ + : sizeof *(r) == sizeof (int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX) \ + : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) +# ifdef LLONG_MAX +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (long int) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX)) +# else +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) +# endif +#endif + +/* Store the low-order bits of A <op> B into *R, where the operation + is given by OP. Use the unsigned type UT for calculation to avoid + overflow problems. *R's type is T, with extrema TMIN and TMAX. + T must be a signed integer type. Return 1 if the result overflows. */ +#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \ + (sizeof ((a) op (b)) < sizeof (t) \ + ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \ + : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax)) +#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \ + ((overflow (a, b) \ + || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \ + || (tmax) < ((a) op (b))) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0)) + +/* Return the low-order bits of A <op> B, where the operation is given + by OP. Use the unsigned type UT for calculation to avoid undefined + behavior on signed integer overflow, and convert the result to type T. + UT is at least as wide as T and is no narrower than unsigned int, + T is two's complement, and there is no padding or trap representations. + Assume that converting UT to T yields the low-order bits, as is + done in all known two's-complement C compilers. E.g., see: + https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html + + According to the C standard, converting UT to T yields an + implementation-defined result or signal for values outside T's + range. However, code that works around this theoretical problem + runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: + https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html + As the compiler bug is real, don't try to work around the + theoretical problem. */ + +#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \ + ((t) ((ut) (a) op (ut) (b))) + +#endif /* _GL_INTPROPS_H */ diff --git a/contrib/tools/bison/lib/isnan.c b/contrib/tools/bison/lib/isnan.c deleted file mode 100644 index d95e4bac77..0000000000 --- a/contrib/tools/bison/lib/isnan.c +++ /dev/null @@ -1,177 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2007-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ - -#include <config.h> - -/* Specification. */ -#ifdef USE_LONG_DOUBLE -/* Specification found in math.h or isnanl-nolibm.h. */ -extern int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; -#elif ! defined USE_FLOAT -/* Specification found in math.h or isnand-nolibm.h. */ -extern int rpl_isnand (double x); -#else /* defined USE_FLOAT */ -/* Specification found in math.h or isnanf-nolibm.h. */ -extern int rpl_isnanf (float x); -#endif - -#include <float.h> -#include <string.h> - -#include "float+.h" - -#ifdef USE_LONG_DOUBLE -# define FUNC rpl_isnanl -# define DOUBLE long double -# define MAX_EXP LDBL_MAX_EXP -# define MIN_EXP LDBL_MIN_EXP -# if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT -# define KNOWN_EXPBIT0_LOCATION -# define EXPBIT0_WORD LDBL_EXPBIT0_WORD -# define EXPBIT0_BIT LDBL_EXPBIT0_BIT -# endif -# define SIZE SIZEOF_LDBL -# define L_(literal) literal##L -#elif ! defined USE_FLOAT -# define FUNC rpl_isnand -# define DOUBLE double -# define MAX_EXP DBL_MAX_EXP -# define MIN_EXP DBL_MIN_EXP -# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT -# define KNOWN_EXPBIT0_LOCATION -# define EXPBIT0_WORD DBL_EXPBIT0_WORD -# define EXPBIT0_BIT DBL_EXPBIT0_BIT -# endif -# define SIZE SIZEOF_DBL -# define L_(literal) literal -#else /* defined USE_FLOAT */ -# define FUNC rpl_isnanf -# define DOUBLE float -# define MAX_EXP FLT_MAX_EXP -# define MIN_EXP FLT_MIN_EXP -# if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT -# define KNOWN_EXPBIT0_LOCATION -# define EXPBIT0_WORD FLT_EXPBIT0_WORD -# define EXPBIT0_BIT FLT_EXPBIT0_BIT -# endif -# define SIZE SIZEOF_FLT -# define L_(literal) literal##f -#endif - -#define EXP_MASK ((MAX_EXP - MIN_EXP) | 7) - -#define NWORDS \ - ((sizeof (DOUBLE) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) -typedef union { DOUBLE value; unsigned int word[NWORDS]; } memory_double; - -int -FUNC (DOUBLE x) -{ -#ifdef KNOWN_EXPBIT0_LOCATION -# if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE - /* Special CPU dependent code is needed to treat bit patterns outside the - IEEE 754 specification (such as Pseudo-NaNs, Pseudo-Infinities, - Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals) as NaNs. - These bit patterns are: - - exponent = 0x0001..0x7FFF, mantissa bit 63 = 0, - - exponent = 0x0000, mantissa bit 63 = 1. - The NaN bit pattern is: - - exponent = 0x7FFF, mantissa >= 0x8000000000000001. */ - memory_double m; - unsigned int exponent; - - m.value = x; - exponent = (m.word[EXPBIT0_WORD] >> EXPBIT0_BIT) & EXP_MASK; -# ifdef WORDS_BIGENDIAN - /* Big endian: EXPBIT0_WORD = 0, EXPBIT0_BIT = 16. */ - if (exponent == 0) - return 1 & (m.word[0] >> 15); - else if (exponent == EXP_MASK) - return (((m.word[0] ^ 0x8000U) << 16) | m.word[1] | (m.word[2] >> 16)) != 0; - else - return 1 & ~(m.word[0] >> 15); -# else - /* Little endian: EXPBIT0_WORD = 2, EXPBIT0_BIT = 0. */ - if (exponent == 0) - return (m.word[1] >> 31); - else if (exponent == EXP_MASK) - return ((m.word[1] ^ 0x80000000U) | m.word[0]) != 0; - else - return (m.word[1] >> 31) ^ 1; -# endif -# else - /* Be careful to not do any floating-point operation on x, such as x == x, - because x may be a signaling NaN. */ -# if defined __SUNPRO_C || defined __ICC || defined _MSC_VER \ - || defined __DECC || defined __TINYC__ \ - || (defined __sgi && !defined __GNUC__) - /* The Sun C 5.0, Intel ICC 10.0, Microsoft Visual C/C++ 9.0, Compaq (ex-DEC) - 6.4, and TinyCC compilers don't recognize the initializers as constant - expressions. The Compaq compiler also fails when constant-folding - 0.0 / 0.0 even when constant-folding is not required. The Microsoft - Visual C/C++ compiler also fails when constant-folding 1.0 / 0.0 even - when constant-folding is not required. The SGI MIPSpro C compiler - complains about "floating-point operation result is out of range". */ - static DOUBLE zero = L_(0.0); - memory_double nan; - DOUBLE plus_inf = L_(1.0) / zero; - DOUBLE minus_inf = -L_(1.0) / zero; - nan.value = zero / zero; -# else - static memory_double nan = { L_(0.0) / L_(0.0) }; - static DOUBLE plus_inf = L_(1.0) / L_(0.0); - static DOUBLE minus_inf = -L_(1.0) / L_(0.0); -# endif - { - memory_double m; - - /* A NaN can be recognized through its exponent. But exclude +Infinity and - -Infinity, which have the same exponent. */ - m.value = x; - if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) - & (EXP_MASK << EXPBIT0_BIT)) - == 0) - return (memcmp (&m.value, &plus_inf, SIZE) != 0 - && memcmp (&m.value, &minus_inf, SIZE) != 0); - else - return 0; - } -# endif -#else - /* The configuration did not find sufficient information. Give up about - the signaling NaNs, handle only the quiet NaNs. */ - if (x == x) - { -# if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE - /* Detect any special bit patterns that pass ==; see comment above. */ - memory_double m1; - memory_double m2; - - memset (&m1.value, 0, SIZE); - memset (&m2.value, 0, SIZE); - m1.value = x; - m2.value = x + (x ? 0.0L : -0.0L); - if (memcmp (&m1.value, &m2.value, SIZE) != 0) - return 1; -# endif - return 0; - } - else - return 1; -#endif -} diff --git a/contrib/tools/bison/lib/isnand-nolibm.h b/contrib/tools/bison/lib/isnand-nolibm.h index 8a84ff8140..7be4573955 100644 --- a/contrib/tools/bison/lib/isnand-nolibm.h +++ b/contrib/tools/bison/lib/isnand-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #if HAVE_ISNAND_IN_LIBC /* Get declaration of isnan macro. */ diff --git a/contrib/tools/bison/lib/isnand.c b/contrib/tools/bison/lib/isnand.c deleted file mode 100644 index cbad17b583..0000000000 --- a/contrib/tools/bison/lib/isnand.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ - -#include "isnan.c" diff --git a/contrib/tools/bison/lib/isnanf.c b/contrib/tools/bison/lib/isnanf.c deleted file mode 100644 index 946cb69ce0..0000000000 --- a/contrib/tools/bison/lib/isnanf.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ - -#define USE_FLOAT -#include "isnan.c" diff --git a/contrib/tools/bison/lib/isnanl-nolibm.h b/contrib/tools/bison/lib/isnanl-nolibm.h index 18eb803714..ddd12f0d24 100644 --- a/contrib/tools/bison/lib/isnanl-nolibm.h +++ b/contrib/tools/bison/lib/isnanl-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #if HAVE_ISNANL_IN_LIBC /* Get declaration of isnan macro or (older) isnanl function. */ diff --git a/contrib/tools/bison/lib/lbitset.c b/contrib/tools/bison/lib/lbitset.c index 7a638c6f9b..2ad6957d8b 100644 --- a/contrib/tools/bison/lib/lbitset.c +++ b/contrib/tools/bison/lib/lbitset.c @@ -1,7 +1,7 @@ /* Functions to support link list bitsets. - Copyright (C) 2002-2004, 2006, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software + Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -54,7 +54,7 @@ typedef bitset_word lbitset_word; /* Number of bits stored in each element. */ #define LBITSET_ELT_BITS \ - ((unsigned int) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS)) + ((unsigned) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS)) /* Lbitset element. We use an array of bits for each element. These are linked together in a doubly-linked list. */ @@ -571,7 +571,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list, { bitset_bindex rbitno; bitset_bindex bitno; - unsigned int bcount; + unsigned bcount; bitset_bindex boffset; bitset_windex windex; bitset_bindex count; @@ -883,7 +883,7 @@ lbitset_empty_p (bitset dst) static inline void lbitset_unused_clear (bitset dst) { - unsigned int last_bit; + unsigned last_bit; bitset_bindex n_bits; n_bits = BITSET_SIZE_ (dst); @@ -939,7 +939,7 @@ lbitset_not (bitset dst, bitset src) lbitset_elt *selt; lbitset_elt *delt; bitset_windex i; - unsigned int j; + unsigned j; bitset_windex windex; windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS; @@ -966,7 +966,7 @@ lbitset_subset_p (bitset dst, bitset src) { lbitset_elt *selt; lbitset_elt *delt; - unsigned int j; + unsigned j; for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst); selt || delt; selt = selt->next, delt = delt->next) @@ -1003,7 +1003,7 @@ lbitset_disjoint_p (bitset dst, bitset src) { lbitset_elt *selt; lbitset_elt *delt; - unsigned int j; + unsigned j; for (selt = LBITSET_HEAD (src), delt = LBITSET_HEAD (dst); selt && delt; selt = selt->next, delt = delt->next) @@ -1049,7 +1049,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) bitset_word *srcp2; bitset_word *dstp; bool changed = false; - unsigned int i; + unsigned i; LBITSET_HEAD (dst) = 0; dst->b.csize = 0; @@ -1376,17 +1376,17 @@ void debug_lbitset (bitset bset) { lbitset_elt *elt; - unsigned int i; + unsigned i; if (!bset) return; for (elt = LBITSET_HEAD (bset); elt; elt = elt->next) { - fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index); + fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index); for (i = 0; i < LBITSET_ELT_WORDS; i++) { - unsigned int j; + unsigned j; bitset_word word; word = elt->words[i]; diff --git a/contrib/tools/bison/lib/lbitset.h b/contrib/tools/bison/lib/lbitset.h index 8ccaca74da..4aced06d65 100644 --- a/contrib/tools/bison/lib/lbitset.h +++ b/contrib/tools/bison/lib/lbitset.h @@ -1,6 +1,7 @@ /* Functions to support lbitsets. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). diff --git a/contrib/tools/bison/lib/libiberty.h b/contrib/tools/bison/lib/libiberty.h index ec1467c59b..7628fc1298 100644 --- a/contrib/tools/bison/lib/libiberty.h +++ b/contrib/tools/bison/lib/libiberty.h @@ -1,6 +1,7 @@ /* Fake libiberty.h for Bison. - Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/lib/localcharset.c b/contrib/tools/bison/lib/localcharset.c index 2c31399da5..bfa5531778 100644 --- a/contrib/tools/bison/lib/localcharset.c +++ b/contrib/tools/bison/lib/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>. */ @@ -22,7 +22,6 @@ /* Specification. */ #include "localcharset.h" -#include <fcntl.h> #include <stddef.h> #include <stdio.h> #include <string.h> @@ -32,8 +31,9 @@ # define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ #endif -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 && !defined __CYGWIN__ # define WINDOWS_NATIVE +# include <locale.h> #endif #if defined __EMX__ @@ -44,11 +44,10 @@ #endif #if !defined WINDOWS_NATIVE -# include <unistd.h> # if HAVE_LANGINFO_CODESET # include <langinfo.h> # else -# if 0 /* see comment below */ +# if 0 /* see comment regarding use of setlocale(), below */ # include <locale.h> # endif # endif @@ -70,287 +69,613 @@ # include <xlocale.h> #endif -#if ENABLE_RELOCATABLE -# include "relocatable.h" -#else -# define relocate(pathname) (pathname) -#endif -/* Get LIBDIR. */ -#ifndef LIBDIR -# include "configmake.h" -#endif +#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2 -/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */ -#ifndef O_NOFOLLOW -# define O_NOFOLLOW 0 -#endif +/* On these platforms, we use a mapping from non-canonical encoding name + to GNU canonical encoding name. */ -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Native Windows, Cygwin, OS/2, DOS */ -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -#endif - -#ifndef DIRECTORY_SEPARATOR -# define DIRECTORY_SEPARATOR '/' -#endif - -#ifndef ISSLASH -# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) -#endif +/* With glibc-2.1 or newer, we don't need any canonicalization, + because glibc has iconv and both glibc and libiconv support all + GNU canonical names directly. */ +# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__) -#if HAVE_DECL_GETC_UNLOCKED -# undef getc -# define getc getc_unlocked -#endif - -/* The following static variable is declared 'volatile' to avoid a - possible multithread problem in the function get_charset_aliases. If we - are running in a threaded environment, and if two threads initialize - 'charset_aliases' simultaneously, both will produce the same value, - and everything will be ok if the two assignments to 'charset_aliases' - are atomic. But I don't know what will happen if the two assignments mix. */ -#if __STDC__ != 1 -# define volatile /* empty */ -#endif -/* Pointer to the contents of the charset.alias file, if it has already been - read, else NULL. Its format is: - ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ -static const char * volatile charset_aliases; - -/* Return a pointer to the contents of the charset.alias file. */ -static const char * -get_charset_aliases (void) +struct table_entry { - const char *cp; - - cp = charset_aliases; - if (cp == NULL) - { -#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__) - const char *dir; - const char *base = "charset.alias"; - char *file_name; - - /* Make it possible to override the charset.alias location. This is - necessary for running the testsuite before "make install". */ - dir = getenv ("CHARSETALIASDIR"); - if (dir == NULL || dir[0] == '\0') - dir = relocate (LIBDIR); - - /* Concatenate dir and base into freshly allocated file_name. */ - { - size_t dir_len = strlen (dir); - size_t base_len = strlen (base); - int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); - file_name = (char *) malloc (dir_len + add_slash + base_len + 1); - if (file_name != NULL) - { - memcpy (file_name, dir, dir_len); - if (add_slash) - file_name[dir_len] = DIRECTORY_SEPARATOR; - memcpy (file_name + dir_len + add_slash, base, base_len + 1); - } - } - - if (file_name == NULL) - /* Out of memory. Treat the file as empty. */ - cp = ""; - else - { - int fd; - - /* Open the file. Reject symbolic links on platforms that support - O_NOFOLLOW. This is a security feature. Without it, an attacker - could retrieve parts of the contents (namely, the tail of the - first line that starts with "* ") of an arbitrary file by placing - a symbolic link to that file under the name "charset.alias" in - some writable directory and defining the environment variable - CHARSETALIASDIR to point to that directory. */ - fd = open (file_name, - O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); - if (fd < 0) - /* File not found. Treat it as empty. */ - cp = ""; - else - { - FILE *fp; - - fp = fdopen (fd, "r"); - if (fp == NULL) - { - /* Out of memory. Treat the file as empty. */ - close (fd); - cp = ""; - } - else - { - /* Parse the file's contents. */ - char *res_ptr = NULL; - size_t res_size = 0; - - for (;;) - { - int c; - char buf1[50+1]; - char buf2[50+1]; - size_t l1, l2; - char *old_res_ptr; - - c = getc (fp); - if (c == EOF) - break; - if (c == '\n' || c == ' ' || c == '\t') - continue; - if (c == '#') - { - /* Skip comment, to end of line. */ - do - c = getc (fp); - while (!(c == EOF || c == '\n')); - if (c == EOF) - break; - continue; - } - ungetc (c, fp); - if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) - break; - l1 = strlen (buf1); - l2 = strlen (buf2); - old_res_ptr = res_ptr; - if (res_size == 0) - { - res_size = l1 + 1 + l2 + 1; - res_ptr = (char *) malloc (res_size + 1); - } - else - { - res_size += l1 + 1 + l2 + 1; - res_ptr = (char *) realloc (res_ptr, res_size + 1); - } - if (res_ptr == NULL) - { - /* Out of memory. */ - res_size = 0; - free (old_res_ptr); - break; - } - strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); - strcpy (res_ptr + res_size - (l2 + 1), buf2); - } - fclose (fp); - if (res_size == 0) - cp = ""; - else - { - *(res_ptr + res_size) = '\0'; - cp = res_ptr; - } - } - } + const char alias[11+1]; + const char canonical[11+1]; +}; + +/* Table of platform-dependent mappings, sorted in ascending order. */ +static const struct table_entry alias_table[] = + { +# if defined __FreeBSD__ /* FreeBSD */ + /*{ "ARMSCII-8", "ARMSCII-8" },*/ + { "Big5", "BIG5" }, + { "C", "ASCII" }, + /*{ "CP1131", "CP1131" },*/ + /*{ "CP1251", "CP1251" },*/ + /*{ "CP866", "CP866" },*/ + /*{ "GB18030", "GB18030" },*/ + /*{ "GB2312", "GB2312" },*/ + /*{ "GBK", "GBK" },*/ + /*{ "ISCII-DEV", "?" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + /*{ "KOI8-R", "KOI8-R" },*/ + /*{ "KOI8-U", "KOI8-U" },*/ + { "SJIS", "SHIFT_JIS" }, + { "US-ASCII", "ASCII" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" } +# define alias_table_defined +# endif +# if defined __NetBSD__ /* NetBSD */ + { "646", "ASCII" }, + /*{ "ARMSCII-8", "ARMSCII-8" },*/ + /*{ "BIG5", "BIG5" },*/ + { "Big5-HKSCS", "BIG5-HKSCS" }, + /*{ "CP1251", "CP1251" },*/ + /*{ "CP866", "CP866" },*/ + /*{ "GB18030", "GB18030" },*/ + /*{ "GB2312", "GB2312" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + /*{ "KOI8-R", "KOI8-R" },*/ + /*{ "KOI8-U", "KOI8-U" },*/ + /*{ "PT154", "PT154" },*/ + { "SJIS", "SHIFT_JIS" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# if defined __OpenBSD__ /* OpenBSD */ + { "646", "ASCII" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" } +# define alias_table_defined +# endif +# if defined __APPLE__ && defined __MACH__ /* Mac OS X */ + /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is + useless: + - It returns the empty string when LANG is set to a locale of the + form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 + LC_CTYPE file. + - The environment variables LANG, LC_CTYPE, LC_ALL are not set by + the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. + - The documentation says: + "... all code that calls BSD system routines should ensure + that the const *char parameters of these routines are in UTF-8 + encoding. All BSD system functions expect their string + parameters to be in UTF-8 encoding and nothing else." + It also says + "An additional caveat is that string parameters for files, + paths, and other file-system entities must be in canonical + UTF-8. In a canonical UTF-8 Unicode string, all decomposable + characters are decomposed ..." + but this is not true: You can pass non-decomposed UTF-8 strings + to file system functions, and it is the OS which will convert + them to decomposed UTF-8 before accessing the file system. + - The Apple Terminal application displays UTF-8 by default. + - However, other applications are free to use different encodings: + - xterm uses ISO-8859-1 by default. + - TextEdit uses MacRoman by default. + We prefer UTF-8 over decomposed UTF-8-MAC because one should + minimize the use of decomposed Unicode. Unfortunately, through the + Darwin file system, decomposed UTF-8 strings are leaked into user + space nevertheless. + Then there are also the locales with encodings other than US-ASCII + and UTF-8. These locales can be occasionally useful to users (e.g. + when grepping through ISO-8859-1 encoded text files), when all their + file names are in US-ASCII. + */ + { "ARMSCII-8", "ARMSCII-8" }, + { "Big5", "BIG5" }, + { "Big5HKSCS", "BIG5-HKSCS" }, + { "CP1131", "CP1131" }, + { "CP1251", "CP1251" }, + { "CP866", "CP866" }, + { "CP949", "CP949" }, + { "GB18030", "GB18030" }, + { "GB2312", "GB2312" }, + { "GBK", "GBK" }, + /*{ "ISCII-DEV", "?" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + { "KOI8-R", "KOI8-R" }, + { "KOI8-U", "KOI8-U" }, + { "PT154", "PT154" }, + { "SJIS", "SHIFT_JIS" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" } +# define alias_table_defined +# endif +# if defined _AIX /* AIX */ + /*{ "GBK", "GBK" },*/ + { "IBM-1046", "CP1046" }, + { "IBM-1124", "CP1124" }, + { "IBM-1129", "CP1129" }, + { "IBM-1252", "CP1252" }, + { "IBM-850", "CP850" }, + { "IBM-856", "CP856" }, + { "IBM-921", "ISO-8859-13" }, + { "IBM-922", "CP922" }, + { "IBM-932", "CP932" }, + { "IBM-943", "CP943" }, + { "IBM-eucCN", "GB2312" }, + { "IBM-eucJP", "EUC-JP" }, + { "IBM-eucKR", "EUC-KR" }, + { "IBM-eucTW", "EUC-TW" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-6", "ISO-8859-6" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "TIS-620", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "big5", "BIG5" } +# define alias_table_defined +# endif +# if defined __hpux /* HP-UX */ + { "SJIS", "SHIFT_JIS" }, + { "arabic8", "HP-ARABIC8" }, + { "big5", "BIG5" }, + { "cp1251", "CP1251" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" }, + { "gb18030", "GB18030" }, + { "greek8", "HP-GREEK8" }, + { "hebrew8", "HP-HEBREW8" }, + { "hkbig5", "BIG5-HKSCS" }, + { "hp15CN", "GB2312" }, + { "iso88591", "ISO-8859-1" }, + { "iso885913", "ISO-8859-13" }, + { "iso885915", "ISO-8859-15" }, + { "iso88592", "ISO-8859-2" }, + { "iso88594", "ISO-8859-4" }, + { "iso88595", "ISO-8859-5" }, + { "iso88596", "ISO-8859-6" }, + { "iso88597", "ISO-8859-7" }, + { "iso88598", "ISO-8859-8" }, + { "iso88599", "ISO-8859-9" }, + { "kana8", "HP-KANA8" }, + { "koi8r", "KOI8-R" }, + { "roman8", "HP-ROMAN8" }, + { "tis620", "TIS-620" }, + { "turkish8", "HP-TURKISH8" }, + { "utf8", "UTF-8" } +# define alias_table_defined +# endif +# if defined __sgi /* IRIX */ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# if defined __osf__ /* OSF/1 */ + /*{ "GBK", "GBK" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "KSC5601", "CP949" }, + { "SJIS", "SHIFT_JIS" }, + { "TACTIS", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "big5", "BIG5" }, + { "cp850", "CP850" }, + { "dechanyu", "DEC-HANYU" }, + { "dechanzi", "GB2312" }, + { "deckanji", "DEC-KANJI" }, + { "deckorean", "EUC-KR" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" }, + { "sdeckanji", "EUC-JP" } +# define alias_table_defined +# endif +# if defined __sun /* Solaris */ + { "5601", "EUC-KR" }, + { "646", "ASCII" }, + /*{ "BIG5", "BIG5" },*/ + { "Big5-HKSCS", "BIG5-HKSCS" }, + { "GB18030", "GB18030" }, + /*{ "GBK", "GBK" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-11", "TIS-620" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-3", "ISO-8859-3" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-6", "ISO-8859-6" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "PCK", "SHIFT_JIS" }, + { "TIS620.2533", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "ansi-1251", "CP1251" }, + { "cns11643", "EUC-TW" }, + { "eucJP", "EUC-JP" }, + { "gb2312", "GB2312" }, + { "koi8-r", "KOI8-R" } +# define alias_table_defined +# endif +# if defined __minix /* Minix */ + { "646", "ASCII" } +# define alias_table_defined +# endif +# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */ + { "CP1361", "JOHAB" }, + { "CP20127", "ASCII" }, + { "CP20866", "KOI8-R" }, + { "CP20936", "GB2312" }, + { "CP21866", "KOI8-RU" }, + { "CP28591", "ISO-8859-1" }, + { "CP28592", "ISO-8859-2" }, + { "CP28593", "ISO-8859-3" }, + { "CP28594", "ISO-8859-4" }, + { "CP28595", "ISO-8859-5" }, + { "CP28596", "ISO-8859-6" }, + { "CP28597", "ISO-8859-7" }, + { "CP28598", "ISO-8859-8" }, + { "CP28599", "ISO-8859-9" }, + { "CP28605", "ISO-8859-15" }, + { "CP38598", "ISO-8859-8" }, + { "CP51932", "EUC-JP" }, + { "CP51936", "GB2312" }, + { "CP51949", "EUC-KR" }, + { "CP51950", "EUC-TW" }, + { "CP54936", "GB18030" }, + { "CP65001", "UTF-8" }, + { "CP936", "GBK" } +# define alias_table_defined +# endif +# if defined OS2 /* OS/2 */ + /* The list of encodings is taken from "List of OS/2 Codepages" + by Alex Taylor: + <http://altsan.org/os2/toolkits/uls/index.html#codepages>. + See also "IBM Globalization - Code page identifiers": + <https://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */ + { "CP1089", "ISO-8859-6" }, + { "CP1208", "UTF-8" }, + { "CP1381", "GB2312" }, + { "CP1386", "GBK" }, + { "CP3372", "EUC-JP" }, + { "CP813", "ISO-8859-7" }, + { "CP819", "ISO-8859-1" }, + { "CP878", "KOI8-R" }, + { "CP912", "ISO-8859-2" }, + { "CP913", "ISO-8859-3" }, + { "CP914", "ISO-8859-4" }, + { "CP915", "ISO-8859-5" }, + { "CP916", "ISO-8859-8" }, + { "CP920", "ISO-8859-9" }, + { "CP921", "ISO-8859-13" }, + { "CP923", "ISO-8859-15" }, + { "CP954", "EUC-JP" }, + { "CP964", "EUC-TW" }, + { "CP970", "EUC-KR" } +# define alias_table_defined +# endif +# if defined VMS /* OpenVMS */ + /* The list of encodings is taken from the OpenVMS 7.3-1 documentation + "Compaq C Run-Time Library Reference Manual for OpenVMS systems" + section 10.7 "Handling Different Character Sets". */ + { "DECHANYU", "DEC-HANYU" }, + { "DECHANZI", "GB2312" }, + { "DECKANJI", "DEC-KANJI" }, + { "DECKOREAN", "EUC-KR" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "SDECKANJI", "EUC-JP" }, + { "SJIS", "SHIFT_JIS" }, + { "eucJP", "EUC-JP" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# ifndef alias_table_defined + /* Just a dummy entry, to avoid a C syntax error. */ + { "", "" } +# endif + }; - free (file_name); - } +# endif #else -# if defined DARWIN7 - /* To avoid the trouble of installing a file that is shared by many - GNU packages -- many packaging systems have problems with this --, - simply inline the aliases here. */ - cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-4" "\0" "ISO-8859-4" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - "ISO8859-13" "\0" "ISO-8859-13" "\0" - "ISO8859-15" "\0" "ISO-8859-15" "\0" - "KOI8-R" "\0" "KOI8-R" "\0" - "KOI8-U" "\0" "KOI8-U" "\0" - "CP866" "\0" "CP866" "\0" - "CP949" "\0" "CP949" "\0" - "CP1131" "\0" "CP1131" "\0" - "CP1251" "\0" "CP1251" "\0" - "eucCN" "\0" "GB2312" "\0" - "GB2312" "\0" "GB2312" "\0" - "eucJP" "\0" "EUC-JP" "\0" - "eucKR" "\0" "EUC-KR" "\0" - "Big5" "\0" "BIG5" "\0" - "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" - "GBK" "\0" "GBK" "\0" - "GB18030" "\0" "GB18030" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "ARMSCII-8" "\0" "ARMSCII-8" "\0" - "PT154" "\0" "PT154" "\0" - /*"ISCII-DEV" "\0" "?" "\0"*/ - "*" "\0" "UTF-8" "\0"; -# endif +/* On these platforms, we use a mapping from locale name to GNU canonical + encoding name. */ -# if defined VMS - /* To avoid the troubles of an extra file charset.alias_vms in the - sources of many GNU packages, simply inline the aliases here. */ - /* The list of encodings is taken from the OpenVMS 7.3-1 documentation - "Compaq C Run-Time Library Reference Manual for OpenVMS systems" - section 10.7 "Handling Different Character Sets". */ - cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-8" "\0" "ISO-8859-8" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - /* Japanese */ - "eucJP" "\0" "EUC-JP" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "DECKANJI" "\0" "DEC-KANJI" "\0" - "SDECKANJI" "\0" "EUC-JP" "\0" - /* Chinese */ - "eucTW" "\0" "EUC-TW" "\0" - "DECHANYU" "\0" "DEC-HANYU" "\0" - "DECHANZI" "\0" "GB2312" "\0" - /* Korean */ - "DECKOREAN" "\0" "EUC-KR" "\0"; +struct table_entry +{ + const char locale[17+1]; + const char canonical[11+1]; +}; + +/* Table of platform-dependent mappings, sorted in ascending order. */ +static const struct table_entry locale_table[] = + { +# if defined __FreeBSD__ /* FreeBSD 4.2 */ + { "cs_CZ.ISO_8859-2", "ISO-8859-2" }, + { "da_DK.DIS_8859-15", "ISO-8859-15" }, + { "da_DK.ISO_8859-1", "ISO-8859-1" }, + { "de_AT.DIS_8859-15", "ISO-8859-15" }, + { "de_AT.ISO_8859-1", "ISO-8859-1" }, + { "de_CH.DIS_8859-15", "ISO-8859-15" }, + { "de_CH.ISO_8859-1", "ISO-8859-1" }, + { "de_DE.DIS_8859-15", "ISO-8859-15" }, + { "de_DE.ISO_8859-1", "ISO-8859-1" }, + { "en_AU.DIS_8859-15", "ISO-8859-15" }, + { "en_AU.ISO_8859-1", "ISO-8859-1" }, + { "en_CA.DIS_8859-15", "ISO-8859-15" }, + { "en_CA.ISO_8859-1", "ISO-8859-1" }, + { "en_GB.DIS_8859-15", "ISO-8859-15" }, + { "en_GB.ISO_8859-1", "ISO-8859-1" }, + { "en_US.DIS_8859-15", "ISO-8859-15" }, + { "en_US.ISO_8859-1", "ISO-8859-1" }, + { "es_ES.DIS_8859-15", "ISO-8859-15" }, + { "es_ES.ISO_8859-1", "ISO-8859-1" }, + { "fi_FI.DIS_8859-15", "ISO-8859-15" }, + { "fi_FI.ISO_8859-1", "ISO-8859-1" }, + { "fr_BE.DIS_8859-15", "ISO-8859-15" }, + { "fr_BE.ISO_8859-1", "ISO-8859-1" }, + { "fr_CA.DIS_8859-15", "ISO-8859-15" }, + { "fr_CA.ISO_8859-1", "ISO-8859-1" }, + { "fr_CH.DIS_8859-15", "ISO-8859-15" }, + { "fr_CH.ISO_8859-1", "ISO-8859-1" }, + { "fr_FR.DIS_8859-15", "ISO-8859-15" }, + { "fr_FR.ISO_8859-1", "ISO-8859-1" }, + { "hr_HR.ISO_8859-2", "ISO-8859-2" }, + { "hu_HU.ISO_8859-2", "ISO-8859-2" }, + { "is_IS.DIS_8859-15", "ISO-8859-15" }, + { "is_IS.ISO_8859-1", "ISO-8859-1" }, + { "it_CH.DIS_8859-15", "ISO-8859-15" }, + { "it_CH.ISO_8859-1", "ISO-8859-1" }, + { "it_IT.DIS_8859-15", "ISO-8859-15" }, + { "it_IT.ISO_8859-1", "ISO-8859-1" }, + { "ja_JP.EUC", "EUC-JP" }, + { "ja_JP.SJIS", "SHIFT_JIS" }, + { "ja_JP.Shift_JIS", "SHIFT_JIS" }, + { "ko_KR.EUC", "EUC-KR" }, + { "la_LN.ASCII", "ASCII" }, + { "la_LN.DIS_8859-15", "ISO-8859-15" }, + { "la_LN.ISO_8859-1", "ISO-8859-1" }, + { "la_LN.ISO_8859-2", "ISO-8859-2" }, + { "la_LN.ISO_8859-4", "ISO-8859-4" }, + { "lt_LN.ASCII", "ASCII" }, + { "lt_LN.DIS_8859-15", "ISO-8859-15" }, + { "lt_LN.ISO_8859-1", "ISO-8859-1" }, + { "lt_LN.ISO_8859-2", "ISO-8859-2" }, + { "lt_LT.ISO_8859-4", "ISO-8859-4" }, + { "nl_BE.DIS_8859-15", "ISO-8859-15" }, + { "nl_BE.ISO_8859-1", "ISO-8859-1" }, + { "nl_NL.DIS_8859-15", "ISO-8859-15" }, + { "nl_NL.ISO_8859-1", "ISO-8859-1" }, + { "no_NO.DIS_8859-15", "ISO-8859-15" }, + { "no_NO.ISO_8859-1", "ISO-8859-1" }, + { "pl_PL.ISO_8859-2", "ISO-8859-2" }, + { "pt_PT.DIS_8859-15", "ISO-8859-15" }, + { "pt_PT.ISO_8859-1", "ISO-8859-1" }, + { "ru_RU.CP866", "CP866" }, + { "ru_RU.ISO_8859-5", "ISO-8859-5" }, + { "ru_RU.KOI8-R", "KOI8-R" }, + { "ru_SU.CP866", "CP866" }, + { "ru_SU.ISO_8859-5", "ISO-8859-5" }, + { "ru_SU.KOI8-R", "KOI8-R" }, + { "sl_SI.ISO_8859-2", "ISO-8859-2" }, + { "sv_SE.DIS_8859-15", "ISO-8859-15" }, + { "sv_SE.ISO_8859-1", "ISO-8859-1" }, + { "uk_UA.KOI8-U", "KOI8-U" }, + { "zh_CN.EUC", "GB2312" }, + { "zh_TW.BIG5", "BIG5" }, + { "zh_TW.Big5", "BIG5" } +# define locale_table_defined # endif - -# if defined WINDOWS_NATIVE || defined __CYGWIN__ - /* To avoid the troubles of installing a separate file in the same - directory as the DLL and of retrieving the DLL's directory at - runtime, simply inline the aliases here. */ - - cp = "CP936" "\0" "GBK" "\0" - "CP1361" "\0" "JOHAB" "\0" - "CP20127" "\0" "ASCII" "\0" - "CP20866" "\0" "KOI8-R" "\0" - "CP20936" "\0" "GB2312" "\0" - "CP21866" "\0" "KOI8-RU" "\0" - "CP28591" "\0" "ISO-8859-1" "\0" - "CP28592" "\0" "ISO-8859-2" "\0" - "CP28593" "\0" "ISO-8859-3" "\0" - "CP28594" "\0" "ISO-8859-4" "\0" - "CP28595" "\0" "ISO-8859-5" "\0" - "CP28596" "\0" "ISO-8859-6" "\0" - "CP28597" "\0" "ISO-8859-7" "\0" - "CP28598" "\0" "ISO-8859-8" "\0" - "CP28599" "\0" "ISO-8859-9" "\0" - "CP28605" "\0" "ISO-8859-15" "\0" - "CP38598" "\0" "ISO-8859-8" "\0" - "CP51932" "\0" "EUC-JP" "\0" - "CP51936" "\0" "GB2312" "\0" - "CP51949" "\0" "EUC-KR" "\0" - "CP51950" "\0" "EUC-TW" "\0" - "CP54936" "\0" "GB18030" "\0" - "CP65001" "\0" "UTF-8" "\0"; +# if defined __DJGPP__ /* DOS / DJGPP 2.03 */ + /* The encodings given here may not all be correct. + If you find that the encoding given for your language and + country is not the one your DOS machine actually uses, just + correct it in this file, and send a mail to + Juan Manuel Guerrero <juan.guerrero@gmx.de> + and <bug-gnulib@gnu.org>. */ + { "C", "ASCII" }, + { "ar", "CP864" }, + { "ar_AE", "CP864" }, + { "ar_DZ", "CP864" }, + { "ar_EG", "CP864" }, + { "ar_IQ", "CP864" }, + { "ar_IR", "CP864" }, + { "ar_JO", "CP864" }, + { "ar_KW", "CP864" }, + { "ar_MA", "CP864" }, + { "ar_OM", "CP864" }, + { "ar_QA", "CP864" }, + { "ar_SA", "CP864" }, + { "ar_SY", "CP864" }, + { "be", "CP866" }, + { "be_BE", "CP866" }, + { "bg", "CP866" }, /* not CP855 ?? */ + { "bg_BG", "CP866" }, /* not CP855 ?? */ + { "ca", "CP850" }, + { "ca_ES", "CP850" }, + { "cs", "CP852" }, + { "cs_CZ", "CP852" }, + { "da", "CP865" }, /* not CP850 ?? */ + { "da_DK", "CP865" }, /* not CP850 ?? */ + { "de", "CP850" }, + { "de_AT", "CP850" }, + { "de_CH", "CP850" }, + { "de_DE", "CP850" }, + { "el", "CP869" }, + { "el_GR", "CP869" }, + { "en", "CP850" }, + { "en_AU", "CP850" }, /* not CP437 ?? */ + { "en_CA", "CP850" }, + { "en_GB", "CP850" }, + { "en_NZ", "CP437" }, + { "en_US", "CP437" }, + { "en_ZA", "CP850" }, /* not CP437 ?? */ + { "eo", "CP850" }, + { "eo_EO", "CP850" }, + { "es", "CP850" }, + { "es_AR", "CP850" }, + { "es_BO", "CP850" }, + { "es_CL", "CP850" }, + { "es_CO", "CP850" }, + { "es_CR", "CP850" }, + { "es_CU", "CP850" }, + { "es_DO", "CP850" }, + { "es_EC", "CP850" }, + { "es_ES", "CP850" }, + { "es_GT", "CP850" }, + { "es_HN", "CP850" }, + { "es_MX", "CP850" }, + { "es_NI", "CP850" }, + { "es_PA", "CP850" }, + { "es_PE", "CP850" }, + { "es_PY", "CP850" }, + { "es_SV", "CP850" }, + { "es_UY", "CP850" }, + { "es_VE", "CP850" }, + { "et", "CP850" }, + { "et_EE", "CP850" }, + { "eu", "CP850" }, + { "eu_ES", "CP850" }, + { "fi", "CP850" }, + { "fi_FI", "CP850" }, + { "fr", "CP850" }, + { "fr_BE", "CP850" }, + { "fr_CA", "CP850" }, + { "fr_CH", "CP850" }, + { "fr_FR", "CP850" }, + { "ga", "CP850" }, + { "ga_IE", "CP850" }, + { "gd", "CP850" }, + { "gd_GB", "CP850" }, + { "gl", "CP850" }, + { "gl_ES", "CP850" }, + { "he", "CP862" }, + { "he_IL", "CP862" }, + { "hr", "CP852" }, + { "hr_HR", "CP852" }, + { "hu", "CP852" }, + { "hu_HU", "CP852" }, + { "id", "CP850" }, /* not CP437 ?? */ + { "id_ID", "CP850" }, /* not CP437 ?? */ + { "is", "CP861" }, /* not CP850 ?? */ + { "is_IS", "CP861" }, /* not CP850 ?? */ + { "it", "CP850" }, + { "it_CH", "CP850" }, + { "it_IT", "CP850" }, + { "ja", "CP932" }, + { "ja_JP", "CP932" }, + { "kr", "CP949" }, /* not CP934 ?? */ + { "kr_KR", "CP949" }, /* not CP934 ?? */ + { "lt", "CP775" }, + { "lt_LT", "CP775" }, + { "lv", "CP775" }, + { "lv_LV", "CP775" }, + { "mk", "CP866" }, /* not CP855 ?? */ + { "mk_MK", "CP866" }, /* not CP855 ?? */ + { "mt", "CP850" }, + { "mt_MT", "CP850" }, + { "nb", "CP865" }, /* not CP850 ?? */ + { "nb_NO", "CP865" }, /* not CP850 ?? */ + { "nl", "CP850" }, + { "nl_BE", "CP850" }, + { "nl_NL", "CP850" }, + { "nn", "CP865" }, /* not CP850 ?? */ + { "nn_NO", "CP865" }, /* not CP850 ?? */ + { "no", "CP865" }, /* not CP850 ?? */ + { "no_NO", "CP865" }, /* not CP850 ?? */ + { "pl", "CP852" }, + { "pl_PL", "CP852" }, + { "pt", "CP850" }, + { "pt_BR", "CP850" }, + { "pt_PT", "CP850" }, + { "ro", "CP852" }, + { "ro_RO", "CP852" }, + { "ru", "CP866" }, + { "ru_RU", "CP866" }, + { "sk", "CP852" }, + { "sk_SK", "CP852" }, + { "sl", "CP852" }, + { "sl_SI", "CP852" }, + { "sq", "CP852" }, + { "sq_AL", "CP852" }, + { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sv", "CP850" }, + { "sv_SE", "CP850" }, + { "th", "CP874" }, + { "th_TH", "CP874" }, + { "tr", "CP857" }, + { "tr_TR", "CP857" }, + { "uk", "CP1125" }, + { "uk_UA", "CP1125" }, + { "zh_CN", "GBK" }, + { "zh_TW", "CP950" } /* not CP938 ?? */ +# define locale_table_defined # endif +# ifndef locale_table_defined + /* Just a dummy entry, to avoid a C syntax error. */ + { "", "" } +# endif + }; + #endif - charset_aliases = cp; - } - - return cp; -} /* Determine the current locale's character encoding, and canonicalize it - into one of the canonical names listed in config.charset. + into one of the canonical names listed in localcharset.h. The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical name. */ @@ -362,9 +687,8 @@ const char * locale_charset (void) { const char *codeset; - const char *aliases; -#if !(defined WINDOWS_NATIVE || defined OS2) +#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2 # if HAVE_LANGINFO_CODESET @@ -427,57 +751,53 @@ locale_charset (void) } # endif -# else - - /* On old systems which lack it, use setlocale or getenv. */ - const char *locale = NULL; - - /* But most old systems don't have a complete set of locales. Some - (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't - use setlocale here; it would return "C" when it doesn't support the - locale name the user has set. */ -# if 0 - locale = setlocale (LC_CTYPE, NULL); -# endif - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_ALL"); - if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } - } - - /* On some old systems, one used to set locale = "iso8859_1". On others, - you set it to "language_COUNTRY.charset". In any case, we resolve it - through the charset.alias file. */ - codeset = locale; + if (codeset == NULL) + /* The canonical name cannot be determined. */ + codeset = ""; -# endif - -#elif defined WINDOWS_NATIVE +# elif defined WINDOWS_NATIVE static char buf[2 + 10 + 1]; - /* The Windows API has a function returning the locale's codepage as a - number: GetACP(). - When the output goes to a console window, it needs to be provided in - GetOEMCP() encoding if the console is using a raster font, or in - GetConsoleOutputCP() encoding if it is using a TrueType font. - But in GUI programs and for output sent to files and pipes, GetACP() - encoding is the best bet. */ - sprintf (buf, "CP%u", GetACP ()); + /* The Windows API has a function returning the locale's codepage as + a number, but the value doesn't change according to what the + 'setlocale' call specified. So we use it as a last resort, in + case the string returned by 'setlocale' doesn't specify the + codepage. */ + char *current_locale = setlocale (LC_ALL, NULL); + char *pdot; + + /* If they set different locales for different categories, + 'setlocale' will return a semi-colon separated list of locale + values. To make sure we use the correct one, we choose LC_CTYPE. */ + if (strchr (current_locale, ';')) + current_locale = setlocale (LC_CTYPE, NULL); + + pdot = strrchr (current_locale, '.'); + if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf)) + sprintf (buf, "CP%s", pdot + 1); + else + { + /* The Windows API has a function returning the locale's codepage as a + number: GetACP(). + When the output goes to a console window, it needs to be provided in + GetOEMCP() encoding if the console is using a raster font, or in + GetConsoleOutputCP() encoding if it is using a TrueType font. + But in GUI programs and for output sent to files and pipes, GetACP() + encoding is the best bet. */ + sprintf (buf, "CP%u", GetACP ()); + } codeset = buf; -#elif defined OS2 +# elif defined OS2 const char *locale; static char buf[2 + 10 + 1]; ULONG cp[3]; ULONG cplen; + codeset = NULL; + /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); @@ -509,10 +829,12 @@ locale_charset (void) } } - /* Resolve through the charset.alias file. */ - codeset = locale; + /* For the POSIX locale, don't use the system's codepage. */ + if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) + codeset = ""; } - else + + if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) @@ -524,28 +846,144 @@ locale_charset (void) } } -#endif +# else - if (codeset == NULL) - /* The canonical name cannot be determined. */ - codeset = ""; +# error "Add code for other platforms here." + +# endif + + /* Resolve alias. */ + { +# ifdef alias_table_defined + /* On some platforms, UTF-8 locales are the most frequently used ones. + Speed up the common case and slow down the less common cases by + testing for this case first. */ +# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__ + if (strcmp (codeset, "UTF-8") == 0) + goto done_table_lookup; + else +# endif + { + const struct table_entry * const table = alias_table; + size_t const table_size = + sizeof (alias_table) / sizeof (struct table_entry); + /* The table is sorted. Perform a binary search. */ + size_t hi = table_size; + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, strcmp (table[i].alias, codeset) < 0, + for i >= hi, strcmp (table[i].alias, codeset) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = strcmp (table[mid].alias, codeset); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + strcmp (table[i].alias, codeset) == 0. */ + codeset = table[mid].canonical; + goto done_table_lookup; + } + } + } + if (0) + done_table_lookup: ; + else +# endif + { + /* Did not find it in the table. */ + /* On Mac OS X, all modern locales use the UTF-8 encoding. + BeOS and Haiku have a single locale, and it has UTF-8 encoding. */ +# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__ + codeset = "UTF-8"; +# else + /* Don't return an empty string. GNU libc and GNU libiconv interpret + the empty string as denoting "the locale's character encoding", + thus GNU libiconv would call this function a second time. */ + if (codeset[0] == '\0') + codeset = "ASCII"; +# endif + } + } - /* Resolve alias. */ - for (aliases = get_charset_aliases (); - *aliases != '\0'; - aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) - if (strcmp (codeset, aliases) == 0 - || (aliases[0] == '*' && aliases[1] == '\0')) +#else + + /* On old systems which lack it, use setlocale or getenv. */ + const char *locale = NULL; + + /* But most old systems don't have a complete set of locales. Some + (like DJGPP) have only the C locale. Therefore we don't use setlocale + here; it would return "C" when it doesn't support the locale name the + user has set. */ +# if 0 + locale = setlocale (LC_CTYPE, NULL); +# endif + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_ALL"); + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + if (locale == NULL) + locale = ""; + } + } + + /* Map locale name to canonical encoding name. */ + { +# ifdef locale_table_defined + const struct table_entry * const table = locale_table; + size_t const table_size = + sizeof (locale_table) / sizeof (struct table_entry); + /* The table is sorted. Perform a binary search. */ + size_t hi = table_size; + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, strcmp (table[i].locale, locale) < 0, + for i >= hi, strcmp (table[i].locale, locale) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = strcmp (table[mid].locale, locale); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + strcmp (table[i].locale, locale) == 0. */ + codeset = table[mid].canonical; + goto done_table_lookup; + } + } + if (0) + done_table_lookup: ; + else +# endif { - codeset = aliases + strlen (aliases) + 1; - break; + /* Did not find it in the table. */ + /* On Mac OS X, all modern locales use the UTF-8 encoding. + BeOS and Haiku have a single locale, and it has UTF-8 encoding. */ +# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__ + codeset = "UTF-8"; +# else + /* The canonical name cannot be determined. */ + /* Don't return an empty string. GNU libc and GNU libiconv interpret + the empty string as denoting "the locale's character encoding", + thus GNU libiconv would call this function a second time. */ + codeset = "ASCII"; +# endif } + } - /* Don't return an empty string. GNU libc and GNU libiconv interpret - the empty string as denoting "the locale's character encoding", - thus GNU libiconv would call this function a second time. */ - if (codeset[0] == '\0') - codeset = "ASCII"; +#endif #ifdef DARWIN7 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" diff --git a/contrib/tools/bison/lib/localcharset.h b/contrib/tools/bison/lib/localcharset.h index c209829867..e4ba2960ba 100644 --- a/contrib/tools/bison/lib/localcharset.h +++ b/contrib/tools/bison/lib/localcharset.h @@ -1,5 +1,5 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2018 Free Software Foundation, Inc. This file is part of the GNU CHARSET Library. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _LOCALCHARSET_H #define _LOCALCHARSET_H @@ -25,12 +25,106 @@ extern "C" { /* Determine the current locale's character encoding, and canonicalize it - into one of the canonical names listed in config.charset. + into one of the canonical names listed below. The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical name. */ extern const char * locale_charset (void); +/* About GNU canonical names for character encodings: + + Every canonical name must be supported by GNU libiconv. Support by GNU libc + is also desirable. + + The name is case insensitive. Usually an upper case MIME charset name is + preferred. + + The current list of these GNU canonical names is: + + name MIME? used by which systems + (darwin = Mac OS X, windows = native Windows) + + ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin + ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin + ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin + ISO-8859-3 Y glibc solaris cygwin + ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin + ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin + ISO-8859-6 Y glibc aix hpux solaris cygwin + ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin + ISO-8859-8 Y glibc aix hpux osf solaris cygwin + ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin + ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin + ISO-8859-14 glibc cygwin + ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin + KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin + KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin + KOI8-T glibc + CP437 dos + CP775 dos + CP850 aix osf dos + CP852 dos + CP855 dos + CP856 aix + CP857 dos + CP861 dos + CP862 dos + CP864 dos + CP865 dos + CP866 freebsd netbsd openbsd darwin dos + CP869 dos + CP874 windows dos + CP922 aix + CP932 aix cygwin windows dos + CP943 aix + CP949 osf darwin windows dos + CP950 windows dos + CP1046 aix + CP1124 aix + CP1125 dos + CP1129 aix + CP1131 freebsd darwin + CP1250 windows + CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows + CP1252 aix windows + CP1253 windows + CP1254 windows + CP1255 glibc windows + CP1256 windows + CP1257 windows + GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin + EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin + EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin + EUC-TW glibc aix hpux irix osf solaris netbsd + BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin + BIG5-HKSCS glibc hpux solaris netbsd darwin + GBK glibc aix osf solaris freebsd darwin cygwin windows dos + GB18030 glibc hpux solaris freebsd netbsd darwin + SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin + JOHAB glibc solaris windows + TIS-620 glibc aix hpux osf solaris cygwin + VISCII Y glibc + TCVN5712-1 glibc + ARMSCII-8 glibc freebsd netbsd darwin + GEORGIAN-PS glibc cygwin + PT154 glibc netbsd cygwin + HP-ROMAN8 hpux + HP-ARABIC8 hpux + HP-GREEK8 hpux + HP-HEBREW8 hpux + HP-TURKISH8 hpux + HP-KANA8 hpux + DEC-KANJI osf + DEC-HANYU osf + UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin + + Note: Names which are not marked as being a MIME name should not be used in + Internet protocols for information interchange (mail, news, etc.). + + Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications + must understand both names and treat them as equivalent. + */ + #ifdef __cplusplus } diff --git a/contrib/tools/bison/lib/malloca.c b/contrib/tools/bison/lib/malloca.c new file mode 100644 index 0000000000..c54e1e0f9b --- /dev/null +++ b/contrib/tools/bison/lib/malloca.c @@ -0,0 +1,105 @@ +/* Safe automatic memory allocation. + Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2003, 2018. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <https://www.gnu.org/licenses/>. */ + +#define _GL_USE_STDLIB_ALLOC 1 +#include <config.h> + +/* Specification. */ +#include "malloca.h" + +#include "verify.h" + +/* The speed critical point in this file is freea() applied to an alloca() + result: it must be fast, to match the speed of alloca(). The speed of + mmalloca() and freea() in the other case are not critical, because they + are only invoked for big memory sizes. + Here we use a bit in the address as an indicator, an idea by OndÅ™ej BÃlka. + malloca() can return three types of pointers: + - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation. + - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap + allocation. + - NULL comes from a failed heap allocation. */ + +/* Type for holding very small pointer differences. */ +typedef unsigned char small_t; +/* Verify that it is wide enough. */ +verify (2 * sa_alignment_max - 1 <= (small_t) -1); + +void * +mmalloca (size_t n) +{ +#if HAVE_ALLOCA + /* Allocate one more word, used to determine the address to pass to freea(), + and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */ + size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1; + + if (nplus >= n) + { + char *mem = (char *) malloc (nplus); + + if (mem != NULL) + { + char *p = + (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1) + & ~(uintptr_t)(2 * sa_alignment_max - 1)) + + sa_alignment_max); + /* Here p >= mem + sizeof (small_t), + and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 + hence p + n <= mem + nplus. + So, the memory range [p, p+n) lies in the allocated memory range + [mem, mem + nplus). */ + ((small_t *) p)[-1] = p - mem; + /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ + return p; + } + } + /* Out of memory. */ + return NULL; +#else +# if !MALLOC_0_IS_NONNULL + if (n == 0) + n = 1; +# endif + return malloc (n); +#endif +} + +#if HAVE_ALLOCA +void +freea (void *p) +{ + /* Check argument. */ + if ((uintptr_t) p & (sa_alignment_max - 1)) + { + /* p was not the result of a malloca() call. Invalid argument. */ + abort (); + } + /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ + if ((uintptr_t) p & sa_alignment_max) + { + void *mem = (char *) p - ((small_t *) p)[-1]; + free (mem); + } +} +#endif + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/contrib/tools/bison/lib/malloca.h b/contrib/tools/bison/lib/malloca.h new file mode 100644 index 0000000000..1e47813ff4 --- /dev/null +++ b/contrib/tools/bison/lib/malloca.h @@ -0,0 +1,127 @@ +/* Safe automatic memory allocation. + Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2003. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <https://www.gnu.org/licenses/>. */ + +#ifndef _MALLOCA_H +#define _MALLOCA_H + +#include <alloca.h> +#include <stddef.h> +#include <stdlib.h> +#include <stdint.h> + +#include "xalloc-oversized.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call + alloca(N); otherwise it returns NULL. It either returns N bytes of + memory allocated on the stack, that lasts until the function returns, + or NULL. + Use of safe_alloca should be avoided: + - inside arguments of function calls - undefined behaviour, + - in inline functions - the allocation may actually last until the + calling function returns. +*/ +#if HAVE_ALLOCA +/* The OS usually guarantees only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + allocate anything larger than 4096 bytes. Also care for the possibility + of a few compiler-allocated temporary stack slots. + This must be a macro, not a function. */ +# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) +#else +# define safe_alloca(N) ((void) (N), NULL) +#endif + +/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of + memory allocated on the stack, that must be freed using freea() before + the function returns. Upon failure, it returns NULL. */ +#if HAVE_ALLOCA +# define malloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ + : mmalloca (N)) +#else +# define malloca(N) \ + mmalloca (N) +#endif +extern void * mmalloca (size_t n); + +/* Free a block of memory allocated through malloca(). */ +#if HAVE_ALLOCA +extern void freea (void *p); +#else +# define freea free +#endif + +/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). + It allocates an array of N objects, each with S bytes of memory, + on the stack. S must be positive and N must be nonnegative. + The array must be freed using freea() before the function returns. */ +#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s))) + + +#ifdef __cplusplus +} +#endif + + +/* ------------------- Auxiliary, non-public definitions ------------------- */ + +/* Determine the alignment of a type at compile time. */ +#if defined __GNUC__ || defined __IBM__ALIGNOF__ +# define sa_alignof __alignof__ +#elif defined __cplusplus + template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; +# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2) +#elif defined __hpux + /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof + values. */ +# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#elif defined _AIX + /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof + values. */ +# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#else +# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) +#endif + +enum +{ +/* The desired alignment of memory allocations is the maximum alignment + among all elementary types. */ + sa_alignment_long = sa_alignof (long), + sa_alignment_double = sa_alignof (double), +#if HAVE_LONG_LONG_INT + sa_alignment_longlong = sa_alignof (long long), +#endif + sa_alignment_longdouble = sa_alignof (long double), + sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) +#if HAVE_LONG_LONG_INT + | (sa_alignment_longlong - 1) +#endif + | (sa_alignment_longdouble - 1) + ) + 1 +}; + +#endif /* _MALLOCA_H */ diff --git a/contrib/tools/bison/lib/math.c b/contrib/tools/bison/lib/math.c index ddb2ded530..ba2a6abd62 100644 --- a/contrib/tools/bison/lib/math.c +++ b/contrib/tools/bison/lib/math.c @@ -1,3 +1,4 @@ #include <config.h> #define _GL_MATH_INLINE _GL_EXTERN_INLINE #include "math.h" +typedef int dummy; diff --git a/contrib/tools/bison/lib/mbrtowc.c b/contrib/tools/bison/lib/mbrtowc.c new file mode 100644 index 0000000000..2f6df287a5 --- /dev/null +++ b/contrib/tools/bison/lib/mbrtowc.c @@ -0,0 +1,458 @@ +/* Convert multibyte character to wide character. + Copyright (C) 1999-2002, 2005-2018 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2008. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <wchar.h> + +#if C_LOCALE_MAYBE_EILSEQ +# include "hard-locale.h" +# include <locale.h> +#endif + +#if GNULIB_defined_mbstate_t +/* Implement mbrtowc() on top of mbtowc(). */ + +# include <errno.h> +# include <stdlib.h> + +# include "localcharset.h" +# include "streq.h" +# include "verify.h" + +# ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +# endif + +/* Returns a classification of special values of the encoding of the current + locale. */ +typedef enum { + enc_other, /* other */ + enc_utf8, /* UTF-8 */ + enc_eucjp, /* EUC-JP */ + enc_94, /* EUC-KR, GB2312, BIG5 */ + enc_euctw, /* EUC-TW */ + enc_gb18030, /* GB18030 */ + enc_sjis /* SJIS */ +} enc_t; +static inline enc_t +locale_enc (void) +{ + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + return enc_utf8; + if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) + return enc_eucjp; + if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) + || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) + || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) + return enc_94; + if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) + return enc_euctw; + if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) + return enc_gb18030; + if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) + return enc_sjis; + return enc_other; +} + +#if GNULIB_WCHAR_SINGLE +/* When we know that the locale does not change, provide a speedup by + caching the value of locale_enc. */ +static int cached_locale_enc = -1; +static inline enc_t +locale_enc_cached (void) +{ + if (cached_locale_enc < 0) + cached_locale_enc = locale_enc (); + return cached_locale_enc; +} +#else +/* By default, don't make assumptions, hence no caching. */ +# define locale_enc_cached locale_enc +#endif + +verify (sizeof (mbstate_t) >= 4); + +static char internal_state[4]; + +size_t +mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ + char *pstate = (char *)ps; + + if (s == NULL) + { + pwc = NULL; + s = ""; + n = 1; + } + + if (n == 0) + return (size_t)(-2); + + /* Here n > 0. */ + + if (pstate == NULL) + pstate = internal_state; + + { + size_t nstate = pstate[0]; + char buf[4]; + const char *p; + size_t m; + + switch (nstate) + { + case 0: + p = s; + m = n; + break; + case 3: + buf[2] = pstate[3]; + FALLTHROUGH; + case 2: + buf[1] = pstate[2]; + FALLTHROUGH; + case 1: + buf[0] = pstate[1]; + p = buf; + m = nstate; + buf[m++] = s[0]; + if (n >= 2 && m < 4) + { + buf[m++] = s[1]; + if (n >= 3 && m < 4) + buf[m++] = s[2]; + } + break; + default: + errno = EINVAL; + return (size_t)(-1); + } + + /* Here m > 0. */ + +# if __GLIBC__ || defined __UCLIBC__ + /* Work around bug <https://sourceware.org/bugzilla/show_bug.cgi?id=9674> */ + mbtowc (NULL, NULL, 0); +# endif + { + int res = mbtowc (pwc, p, m); + + if (res >= 0) + { + if (pwc != NULL && ((*pwc == 0) != (res == 0))) + abort (); + if (nstate >= (res > 0 ? res : 1)) + abort (); + res -= nstate; + pstate[0] = 0; + return res; + } + + /* mbtowc does not distinguish between invalid and incomplete multibyte + sequences. But mbrtowc needs to make this distinction. + There are two possible approaches: + - Use iconv() and its return value. + - Use built-in knowledge about the possible encodings. + Given the low quality of implementation of iconv() on the systems that + lack mbrtowc(), we use the second approach. + The possible encodings are: + - 8-bit encodings, + - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, + - UTF-8. + Use specialized code for each. */ + if (m >= 4 || m >= MB_CUR_MAX) + goto invalid; + /* Here MB_CUR_MAX > 1 and 0 < m < 4. */ + switch (locale_enc_cached ()) + { + case enc_utf8: /* UTF-8 */ + { + /* Cf. unistr/u8-mblen.c. */ + unsigned char c = (unsigned char) p[0]; + + if (c >= 0xc2) + { + if (c < 0xe0) + { + if (m == 1) + goto incomplete; + } + else if (c < 0xf0) + { + if (m == 1) + goto incomplete; + if (m == 2) + { + unsigned char c2 = (unsigned char) p[1]; + + if ((c2 ^ 0x80) < 0x40 + && (c >= 0xe1 || c2 >= 0xa0) + && (c != 0xed || c2 < 0xa0)) + goto incomplete; + } + } + else if (c <= 0xf4) + { + if (m == 1) + goto incomplete; + else /* m == 2 || m == 3 */ + { + unsigned char c2 = (unsigned char) p[1]; + + if ((c2 ^ 0x80) < 0x40 + && (c >= 0xf1 || c2 >= 0x90) + && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) + { + if (m == 2) + goto incomplete; + else /* m == 3 */ + { + unsigned char c3 = (unsigned char) p[2]; + + if ((c3 ^ 0x80) < 0x40) + goto incomplete; + } + } + } + } + } + goto invalid; + } + + /* As a reference for this code, you can use the GNU libiconv + implementation. Look for uses of the RET_TOOFEW macro. */ + + case enc_eucjp: /* EUC-JP */ + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; + + if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) + goto incomplete; + } + if (m == 2) + { + unsigned char c = (unsigned char) p[0]; + + if (c == 0x8f) + { + unsigned char c2 = (unsigned char) p[1]; + + if (c2 >= 0xa1 && c2 < 0xff) + goto incomplete; + } + } + goto invalid; + } + + case enc_94: /* EUC-KR, GB2312, BIG5 */ + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; + + if (c >= 0xa1 && c < 0xff) + goto incomplete; + } + goto invalid; + } + + case enc_euctw: /* EUC-TW */ + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; + + if ((c >= 0xa1 && c < 0xff) || c == 0x8e) + goto incomplete; + } + else /* m == 2 || m == 3 */ + { + unsigned char c = (unsigned char) p[0]; + + if (c == 0x8e) + goto incomplete; + } + goto invalid; + } + + case enc_gb18030: /* GB18030 */ + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; + + if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) + goto incomplete; + } + else /* m == 2 || m == 3 */ + { + unsigned char c = (unsigned char) p[0]; + + if (c >= 0x90 && c <= 0xe3) + { + unsigned char c2 = (unsigned char) p[1]; + + if (c2 >= 0x30 && c2 <= 0x39) + { + if (m == 2) + goto incomplete; + else /* m == 3 */ + { + unsigned char c3 = (unsigned char) p[2]; + + if (c3 >= 0x81 && c3 <= 0xfe) + goto incomplete; + } + } + } + } + goto invalid; + } + + case enc_sjis: /* SJIS */ + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; + + if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) + || (c >= 0xf0 && c <= 0xf9)) + goto incomplete; + } + goto invalid; + } + + default: + /* An unknown multibyte encoding. */ + goto incomplete; + } + + incomplete: + { + size_t k = nstate; + /* Here 0 <= k < m < 4. */ + pstate[++k] = s[0]; + if (k < m) + { + pstate[++k] = s[1]; + if (k < m) + pstate[++k] = s[2]; + } + if (k != m) + abort (); + } + pstate[0] = m; + return (size_t)(-2); + + invalid: + errno = EILSEQ; + /* The conversion state is undefined, says POSIX. */ + return (size_t)(-1); + } + } +} + +#else +/* Override the system's mbrtowc() function. */ + +# undef mbrtowc + +size_t +rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ + size_t ret; + wchar_t wc; + +# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG + if (s == NULL) + { + pwc = NULL; + s = ""; + n = 1; + } +# endif + +# if MBRTOWC_EMPTY_INPUT_BUG + if (n == 0) + return (size_t) -2; +# endif + + if (! pwc) + pwc = &wc; + +# if MBRTOWC_RETVAL_BUG + { + static mbstate_t internal_state; + + /* Override mbrtowc's internal state. We cannot call mbsinit() on the + hidden internal state, but we can call it on our variable. */ + if (ps == NULL) + ps = &internal_state; + + if (!mbsinit (ps)) + { + /* Parse the rest of the multibyte character byte for byte. */ + size_t count = 0; + for (; n > 0; s++, n--) + { + ret = mbrtowc (&wc, s, 1, ps); + + if (ret == (size_t)(-1)) + return (size_t)(-1); + count++; + if (ret != (size_t)(-2)) + { + /* The multibyte character has been completed. */ + *pwc = wc; + return (wc == 0 ? 0 : count); + } + } + return (size_t)(-2); + } + } +# endif + + ret = mbrtowc (pwc, s, n, ps); + +# if MBRTOWC_NUL_RETVAL_BUG + if (ret < (size_t) -2 && !*pwc) + return 0; +# endif + +# if C_LOCALE_MAYBE_EILSEQ + if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE)) + { + unsigned char uc = *s; + *pwc = uc; + return 1; + } +# endif + + return ret; +} + +#endif diff --git a/contrib/tools/bison/lib/mbswidth.c b/contrib/tools/bison/lib/mbswidth.c index 7c2dfce886..7ef404794c 100644 --- a/contrib/tools/bison/lib/mbswidth.c +++ b/contrib/tools/bison/lib/mbswidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <haible@clisp.cons.org>. */ diff --git a/contrib/tools/bison/lib/mbswidth.h b/contrib/tools/bison/lib/mbswidth.h index e9c0b03938..0f22ca572d 100644 --- a/contrib/tools/bison/lib/mbswidth.h +++ b/contrib/tools/bison/lib/mbswidth.h @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2004, 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <stddef.h> diff --git a/contrib/tools/bison/lib/minmax.h b/contrib/tools/bison/lib/minmax.h new file mode 100644 index 0000000000..33a5305f42 --- /dev/null +++ b/contrib/tools/bison/lib/minmax.h @@ -0,0 +1,60 @@ +/* MIN, MAX macros. + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2018 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <https://www.gnu.org/licenses/>. */ + +#ifndef _MINMAX_H +#define _MINMAX_H + +/* Note: MIN, MAX are also defined in <sys/param.h> on some systems + (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about + MIN, MAX macro redefinitions on some systems; the workaround is to + #include this file as the last one among the #include list. */ + +/* Before we define the following symbols we get the <limits.h> file + since otherwise we get redefinitions on some systems if <limits.h> is + included after this file. Likewise for <sys/param.h>. + If more than one of these system headers define MIN and MAX, pick just + one of the headers (because the definitions most likely are the same). */ +#if HAVE_MINMAX_IN_LIMITS_H +# include <limits.h> +#elif HAVE_MINMAX_IN_SYS_PARAM_H +# include <sys/param.h> +#endif + +/* Note: MIN and MAX should be used with two arguments of the + same type. They might not return the minimum and maximum of their two + arguments, if the arguments have different types or have unusual + floating-point values. For example, on a typical host with 32-bit 'int', + 64-bit 'long long', and 64-bit IEEE 754 'double' types: + + MAX (-1, 2147483648) returns 4294967295. + MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0. + MAX (NaN, 0.0) returns 0.0. + MAX (+0.0, -0.0) returns -0.0. + + and in each case the answer is in some sense bogus. */ + +/* MAX(a,b) returns the maximum of A and B. */ +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +/* MIN(a,b) returns the minimum of A and B. */ +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#endif /* _MINMAX_H */ diff --git a/contrib/tools/bison/lib/msvc-inval.c b/contrib/tools/bison/lib/msvc-inval.c index 396031e4c2..0f19a09aee 100644 --- a/contrib/tools/bison/lib/msvc-inval.c +++ b/contrib/tools/bison/lib/msvc-inval.c @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/msvc-inval.h b/contrib/tools/bison/lib/msvc-inval.h index dcb0353dcd..8e7ff303a7 100644 --- a/contrib/tools/bison/lib/msvc-inval.h +++ b/contrib/tools/bison/lib/msvc-inval.h @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _MSVC_INVAL_H #define _MSVC_INVAL_H @@ -95,7 +95,7 @@ extern void gl_msvc_inval_ensure_handler (void); /* Gnulib can define its own status codes, as described in the page "Raising Software Exceptions" on microsoft.com - <http://msdn.microsoft.com/en-us/library/het71c37.aspx>. + <https://msdn.microsoft.com/en-us/library/het71c37.aspx>. Our status codes are composed of - 0xE0000000, mandatory for all user-defined status codes, - 0x474E550, a API identifier ("GNU"), @@ -106,7 +106,7 @@ extern void gl_msvc_inval_ensure_handler (void); # if defined _MSC_VER /* A compiler that supports __try/__except, as described in the page "try-except statement" on microsoft.com - <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>. + <https://msdn.microsoft.com/en-us/library/s58ftw19.aspx>. With __try/__except, we can use the multithread-safe exception handling. */ # ifdef __cplusplus diff --git a/contrib/tools/bison/lib/msvc-nothrow.c b/contrib/tools/bison/lib/msvc-nothrow.c index 8d65472a82..785733e439 100644 --- a/contrib/tools/bison/lib/msvc-nothrow.c +++ b/contrib/tools/bison/lib/msvc-nothrow.c @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -24,7 +24,9 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> -#include "msvc-inval.h" +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif #undef _get_osfhandle diff --git a/contrib/tools/bison/lib/msvc-nothrow.h b/contrib/tools/bison/lib/msvc-nothrow.h index 5f521813df..a9671c3b64 100644 --- a/contrib/tools/bison/lib/msvc-nothrow.h +++ b/contrib/tools/bison/lib/msvc-nothrow.h @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _MSVC_NOTHROW_H #define _MSVC_NOTHROW_H @@ -25,7 +25,7 @@ This file defines wrappers that turn such an invalid parameter notification into an error code. */ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* Get original declaration of _get_osfhandle. */ # include <io.h> diff --git a/contrib/tools/bison/lib/obstack.c b/contrib/tools/bison/lib/obstack.c index d915449def..16d1770882 100644 --- a/contrib/tools/bison/lib/obstack.c +++ b/contrib/tools/bison/lib/obstack.c @@ -1,32 +1,32 @@ /* obstack.c - subroutines used implicitly by object stack macros + Copyright (C) 1988-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. - Copyright (C) 1988-1994, 1996-2006, 2009-2013 Free Software Foundation, Inc. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef _LIBC # include <obstack.h> -# include <shlib-compat.h> #else # include <config.h> # include "obstack.h" #endif -/* NOTE BEFORE MODIFYING THIS FILE: This version number must be - incremented whenever callers compiled using an old obstack.h can no - longer properly call the functions in this obstack.c. */ -#define OBSTACK_INTERFACE_VERSION 1 +/* NOTE BEFORE MODIFYING THIS FILE: _OBSTACK_INTERFACE_VERSION in + obstack.h must be incremented whenever callers compiled using an old + obstack.h can no longer properly call the functions in this file. */ /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself, and the installed library @@ -36,114 +36,76 @@ (especially if it is a shared library). Rather than having every GNU program understand 'configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ - -#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */ #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 # include <gnu-versions.h> -# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION -# define ELIDE_CODE +# if (_GNU_OBSTACK_INTERFACE_VERSION == _OBSTACK_INTERFACE_VERSION \ + || (_GNU_OBSTACK_INTERFACE_VERSION == 1 \ + && _OBSTACK_INTERFACE_VERSION == 2 \ + && defined SIZEOF_INT && defined SIZEOF_SIZE_T \ + && SIZEOF_INT == SIZEOF_SIZE_T)) +# define _OBSTACK_ELIDE_CODE # endif #endif -#include <stddef.h> - -#ifndef ELIDE_CODE - +#ifndef _OBSTACK_ELIDE_CODE +/* If GCC, or if an oddball (testing?) host that #defines __alignof__, + use the already-supplied __alignof__. Otherwise, this must be Gnulib + (as glibc assumes GCC); defer to Gnulib's alignof_type. */ +# include <stdlib.h> # include <stdint.h> -/* Determine default alignment. */ -union fooround -{ - uintmax_t i; - long double d; - void *p; -}; -struct fooalign -{ - char c; - union fooround u; -}; -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -enum - { - DEFAULT_ALIGNMENT = offsetof (struct fooalign, u), - DEFAULT_ROUNDING = sizeof (union fooround) - }; - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to 'long' (if that works) - or 'char' as a last resort. */ -# ifndef COPYING_UNIT -# define COPYING_UNIT int +# ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) # endif +/* Determine default alignment. */ -/* The functions allocating more room by calling 'obstack_chunk_alloc' - jump to the handler pointed to by 'obstack_alloc_failed_handler'. - This can be set to a user defined function which should either - abort gracefully or use longjump - but shouldn't return. This - variable by default points to the internal function - 'print_and_abort'. */ -static _Noreturn void print_and_abort (void); -void (*obstack_alloc_failed_handler) (void) = print_and_abort; +/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. + But in fact it might be less smart and round addresses to as much as + DEFAULT_ROUNDING. So we prepare for it to do that. + + DEFAULT_ALIGNMENT cannot be an enum constant; see gnulib's alignof.h. */ +#define DEFAULT_ALIGNMENT MAX (__alignof__ (long double), \ + MAX (__alignof__ (uintmax_t), \ + __alignof__ (void *))) +#define DEFAULT_ROUNDING MAX (sizeof (long double), \ + MAX (sizeof (uintmax_t), \ + sizeof (void *))) + +/* Call functions with either the traditional malloc/free calling + interface, or the mmalloc/mfree interface (that adds an extra first + argument), based on the value of use_extra_arg. */ + +static void * +call_chunkfun (struct obstack *h, size_t size) +{ + if (h->use_extra_arg) + return h->chunkfun.extra (h->extra_arg, size); + else + return h->chunkfun.plain (size); +} -/* Exit value used when 'print_and_abort' is used. */ -# include <stdlib.h> -# ifdef _LIBC -int obstack_exit_failure = EXIT_FAILURE; -# else -# include "exitfail.h" -# define obstack_exit_failure exit_failure -# endif +static void +call_freefun (struct obstack *h, void *old_chunk) +{ + if (h->use_extra_arg) + h->freefun.extra (h->extra_arg, old_chunk); + else + h->freefun.plain (old_chunk); +} -# ifdef _LIBC -# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) -/* A looong time ago (before 1994, anyway; we're not sure) this global variable - was used by non-GNU-C macros to avoid multiple evaluation. The GNU C - library still exports it because somebody might use it. */ -struct obstack *_obstack_compat; -compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0); -# endif -# endif -/* Define a macro that either calls functions with the traditional malloc/free - calling interface, or calls functions with the mmalloc/mfree interface - (that adds an extra first argument), based on the state of use_extra_arg. - For free, do not use ?:, since some compilers, like the MIPS compilers, - do not allow (expr) ? void : void. */ - -# define CALL_CHUNKFUN(h, size) \ - (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size))) - -# define CALL_FREEFUN(h, old_chunk) \ - do { \ - if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ - else \ - (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ - } while (0) - - /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. Return nonzero if successful, calls obstack_alloc_failed_handler if allocation fails. */ -int -_obstack_begin (struct obstack *h, - int size, int alignment, - void *(*chunkfun) (long), - void (*freefun) (void *)) +static int +_obstack_begin_worker (struct obstack *h, + _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment) { - register struct _obstack_chunk *chunk; /* points to new chunk */ + struct _obstack_chunk *chunk; /* points to new chunk */ if (alignment == 0) alignment = DEFAULT_ALIGNMENT; @@ -164,19 +126,15 @@ _obstack_begin (struct obstack *h, size = 4096 - extra; } - h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; h->chunk_size = size; h->alignment_mask = alignment - 1; - h->use_extra_arg = 0; - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + chunk = h->chunk = call_chunkfun (h, h->chunk_size); if (!chunk) (*obstack_alloc_failed_handler) (); h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents, alignment - 1); - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; + h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; @@ -185,51 +143,29 @@ _obstack_begin (struct obstack *h, } int -_obstack_begin_1 (struct obstack *h, int size, int alignment, - void *(*chunkfun) (void *, long), +_obstack_begin (struct obstack *h, + _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, + void *(*chunkfun) (size_t), + void (*freefun) (void *)) +{ + h->chunkfun.plain = chunkfun; + h->freefun.plain = freefun; + h->use_extra_arg = 0; + return _obstack_begin_worker (h, size, alignment); +} + +int +_obstack_begin_1 (struct obstack *h, + _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, + void *(*chunkfun) (void *, size_t), void (*freefun) (void *, void *), void *arg) { - register struct _obstack_chunk *chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - - h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; - h->chunk_size = size; - h->alignment_mask = alignment - 1; + h->chunkfun.extra = chunkfun; + h->freefun.extra = freefun; h->extra_arg = arg; h->use_extra_arg = 1; - - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); - if (!chunk) - (*obstack_alloc_failed_handler) (); - h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents, - alignment - 1); - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; - /* The initial chunk now contains no empty object. */ - h->maybe_empty_object = 0; - h->alloc_failed = 0; - return 1; + return _obstack_begin_worker (h, size, alignment); } /* Allocate a new current chunk for the obstack *H @@ -239,25 +175,27 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment, to the beginning of the new one. */ void -_obstack_newchunk (struct obstack *h, int length) +_obstack_newchunk (struct obstack *h, _OBSTACK_SIZE_T length) { - register struct _obstack_chunk *old_chunk = h->chunk; - register struct _obstack_chunk *new_chunk; - register long new_size; - register long obj_size = h->next_free - h->object_base; - register long i; - long already; + struct _obstack_chunk *old_chunk = h->chunk; + struct _obstack_chunk *new_chunk = 0; + size_t obj_size = h->next_free - h->object_base; char *object_base; /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100; + size_t sum1 = obj_size + length; + size_t sum2 = sum1 + h->alignment_mask; + size_t new_size = sum2 + (obj_size >> 3) + 100; + if (new_size < sum2) + new_size = sum2; if (new_size < h->chunk_size) new_size = h->chunk_size; /* Allocate and initialize the new chunk. */ - new_chunk = CALL_CHUNKFUN (h, new_size); + if (obj_size <= sum1 && sum1 <= sum2) + new_chunk = call_chunkfun (h, new_size); if (!new_chunk) - (*obstack_alloc_failed_handler) (); + (*obstack_alloc_failed_handler)(); h->chunk = new_chunk; new_chunk->prev = old_chunk; new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; @@ -266,36 +204,19 @@ _obstack_newchunk (struct obstack *h, int length) object_base = __PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask); - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)object_base)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - object_base[i] = h->object_base[i]; + /* Move the existing object to the new chunk. */ + memcpy (object_base, h->object_base, obj_size); /* If the object just copied was the only data in OLD_CHUNK, free that chunk and remove it from the chain. But not if that chunk might contain an empty object. */ - if (! h->maybe_empty_object + if (!h->maybe_empty_object && (h->object_base == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents, h->alignment_mask))) { new_chunk->prev = old_chunk->prev; - CALL_FREEFUN (h, old_chunk); + call_freefun (h, old_chunk); } h->object_base = object_base; @@ -303,9 +224,6 @@ _obstack_newchunk (struct obstack *h, int length) /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0; } -# ifdef _LIBC -libc_hidden_def (_obstack_newchunk) -# endif /* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. @@ -313,13 +231,13 @@ libc_hidden_def (_obstack_newchunk) /* Suppress -Wmissing-prototypes warning. We don't want to declare this in obstack.h because it is just for debugging. */ -int _obstack_allocated_p (struct obstack *h, void *obj); +int _obstack_allocated_p (struct obstack *h, void *obj) __attribute_pure__; int _obstack_allocated_p (struct obstack *h, void *obj) { - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ + struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at @@ -332,17 +250,15 @@ _obstack_allocated_p (struct obstack *h, void *obj) } return lp != 0; } - + /* Free objects in obstack H, including OBJ and everything allocate more recently than OBJ. If OBJ is zero, free everything in H. */ -# undef obstack_free - void -__obstack_free (struct obstack *h, void *obj) +_obstack_free (struct obstack *h, void *obj) { - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ + struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. @@ -351,7 +267,7 @@ __obstack_free (struct obstack *h, void *obj) while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj)) { plp = lp->prev; - CALL_FREEFUN (h, lp); + call_freefun (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ @@ -368,17 +284,11 @@ __obstack_free (struct obstack *h, void *obj) abort (); } -# ifdef _LIBC -/* Older versions of libc used a function _obstack_free intended to be - called by non-GCC compilers. */ -strong_alias (obstack_free, _obstack_free) -# endif - -int +_OBSTACK_SIZE_T _obstack_memory_used (struct obstack *h) { - register struct _obstack_chunk* lp; - register int nbytes = 0; + struct _obstack_chunk *lp; + _OBSTACK_SIZE_T nbytes = 0; for (lp = h->chunk; lp != 0; lp = lp->prev) { @@ -386,20 +296,31 @@ _obstack_memory_used (struct obstack *h) } return nbytes; } - + +# ifndef _OBSTACK_NO_ERROR_HANDLER /* Define the error handler. */ -# ifdef _LIBC -# include <libintl.h> -# else -# include "gettext.h" -# endif -# ifndef _ -# define _(msgid) gettext (msgid) -# endif +# include <stdio.h> -# ifdef _LIBC -# include <libio/iolibio.h> -# endif +/* Exit value used when 'print_and_abort' is used. */ +# ifdef _LIBC +int obstack_exit_failure = EXIT_FAILURE; +# else +# include "exitfail.h" +# define obstack_exit_failure exit_failure +# endif + +# ifdef _LIBC +# include <libintl.h> +# else +# include "gettext.h" +# endif +# ifndef _ +# define _(msgid) gettext (msgid) +# endif + +# ifdef _LIBC +# include <libio/iolibio.h> +# endif static _Noreturn void print_and_abort (void) @@ -409,12 +330,21 @@ print_and_abort (void) happen because the "memory exhausted" message appears in other places like this and the translation should be reused instead of creating a very similar string which requires a separate translation. */ -# ifdef _LIBC +# ifdef _LIBC (void) __fxprintf (NULL, "%s\n", _("memory exhausted")); -# else +# else fprintf (stderr, "%s\n", _("memory exhausted")); -# endif +# endif exit (obstack_exit_failure); } -#endif /* !ELIDE_CODE */ +/* The functions allocating more room by calling 'obstack_chunk_alloc' + jump to the handler pointed to by 'obstack_alloc_failed_handler'. + This can be set to a user defined function which should either + abort gracefully or use longjump - but shouldn't return. This + variable by default points to the internal function + 'print_and_abort'. */ +__attribute_noreturn__ void (*obstack_alloc_failed_handler) (void) + = print_and_abort; +# endif /* !_OBSTACK_NO_ERROR_HANDLER */ +#endif /* !_OBSTACK_ELIDE_CODE */ diff --git a/contrib/tools/bison/lib/obstack.h b/contrib/tools/bison/lib/obstack.h index 046fc58546..4355fc55c8 100644 --- a/contrib/tools/bison/lib/obstack.h +++ b/contrib/tools/bison/lib/obstack.h @@ -1,90 +1,90 @@ /* obstack.h - object stack macros - Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1988-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ /* Summary: -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called 'obstack_chunk_alloc'. On occasion, they free chunks, -by calling 'obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a 'struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" ---Gosper's immortal quote from HAKMEM item 154, out of context--you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: + All the apparent functions defined here are macros. The idea + is that you would use these pre-tested macros to solve a + very specific set of problems, and they would run fast. + Caution: no side-effects in arguments please!! They may be + evaluated MANY times!! + + These macros operate a stack of objects. Each object starts life + small, and may grow to maturity. (Consider building a word syllable + by syllable.) An object can move while it is growing. Once it has + been "finished" it never changes address again. So the "top of the + stack" is typically an immature growing object, while the rest of the + stack is of mature, fixed size and fixed address objects. + + These routines grab large chunks of memory, using a function you + supply, called 'obstack_chunk_alloc'. On occasion, they free chunks, + by calling 'obstack_chunk_free'. You must define them and declare + them before using any obstack macros. + + Each independent stack is represented by a 'struct obstack'. + Each of the obstack macros expects a pointer to such a structure + as the first argument. + + One motivation for this package is the problem of growing char strings + in symbol tables. Unless you are "fascist pig with a read-only mind" + --Gosper's immortal quote from HAKMEM item 154, out of context--you + would not like to put any arbitrary upper limit on the length of your + symbols. + + In practice this often means you will build many short symbols and a + few long symbols. At the time you are reading a symbol you don't know + how long it is. One traditional method is to read a symbol into a + buffer, realloc()ating the buffer every time you try to read a symbol + that is longer than the buffer. This is beaut, but you still will + want to copy the symbol from the buffer to a more permanent + symbol-table entry say about half the time. + + With obstacks, you can work differently. Use one obstack for all symbol + names. As you read a symbol, grow the name in the obstack gradually. + When the name is complete, finalize it. Then, if the symbol exists already, + free the newly read name. + + The way we do this is to take a large chunk, allocating memory from + low addresses. When you want to build a symbol in the chunk you just + add chars above the current "high water mark" in the chunk. When you + have finished adding chars, because you got to the end of the symbol, + you know how long the chars are, and you can create a new object. + Mostly the chars will not burst over the highest address of the chunk, + because you would typically expect a chunk to be (say) 100 times as + long as an average object. + + In case that isn't clear, when we have enough chars to make up + the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) + so we just point to it where it lies. No moving of chars is + needed and this is the second win: potentially long strings need + never be explicitly shuffled. Once an object is formed, it does not + change its address during its lifetime. + + When the chars burst over a chunk boundary, we allocate a larger + chunk, and then copy the partly formed object from the end of the old + chunk to the beginning of the new larger chunk. We then carry on + accreting characters to the end of the object as we normally would. + + A special macro is provided to add a single char at a time to a + growing object. This allows the use of register variables, which + break the ordinary 'growth' macro. + + Summary: We allocate large chunks. We carve out one object at a time from the current chunk. Once carved, an object never moves. @@ -96,24 +96,38 @@ Summary: Because of the way we do it, you can "unwind" an obstack back to a previous state. (You may remove objects much as you would with a stack.) -*/ + */ /* Don't do the contents of this file more than once. */ #ifndef _OBSTACK_H #define _OBSTACK_H 1 - -/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is - defined, as with GNU C, use that; that way we don't pollute the - namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h> - and use ptrdiff_t. */ - -#ifdef __PTRDIFF_TYPE__ -# define PTR_INT_TYPE __PTRDIFF_TYPE__ + +#ifndef _OBSTACK_INTERFACE_VERSION +# define _OBSTACK_INTERFACE_VERSION 2 +#endif + +#include <stddef.h> /* For size_t and ptrdiff_t. */ +#include <string.h> /* For __GNU_LIBRARY__, and memcpy. */ + +#if __STDC_VERSION__ < 199901L +# define __FLEXIBLE_ARRAY_MEMBER 1 #else -# include <stddef.h> -# define PTR_INT_TYPE ptrdiff_t +# define __FLEXIBLE_ARRAY_MEMBER +#endif + +#if _OBSTACK_INTERFACE_VERSION == 1 +/* For binary compatibility with obstack version 1, which used "int" + and "long" for these two types. */ +# define _OBSTACK_SIZE_T unsigned int +# define _CHUNK_SIZE_T unsigned long +# define _OBSTACK_CAST(type, expr) ((type) (expr)) +#else +/* Version 2 with sane types, especially for 64-bit hosts. */ +# define _OBSTACK_SIZE_T size_t +# define _CHUNK_SIZE_T size_t +# define _OBSTACK_CAST(type, expr) (expr) #endif /* If B is the base of an object addressed by P, return the result of @@ -122,18 +136,29 @@ Summary: #define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A))) -/* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case +/* Similar to __BPTR_ALIGN (B, P, A), except optimize the common case where pointers can be converted to integers, aligned as integers, - and converted back again. If PTR_INT_TYPE is narrower than a + and converted back again. If ptrdiff_t is narrower than a pointer (e.g., the AS/400), play it safe and compute the alignment relative to B. Otherwise, use the faster strategy of computing the alignment relative to 0. */ -#define __PTR_ALIGN(B, P, A) \ - __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \ +#define __PTR_ALIGN(B, P, A) \ + __BPTR_ALIGN (sizeof (ptrdiff_t) < sizeof (void *) ? (B) : (char *) 0, \ P, A) -#include <string.h> +#ifndef __attribute_pure__ +# define __attribute_pure__ _GL_ATTRIBUTE_PURE +#endif + +/* Not the same as _Noreturn, since it also works with function pointers. */ +#ifndef __attribute_noreturn__ +# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define __attribute_noreturn__ __attribute__ ((__noreturn__)) +# else +# define __attribute_noreturn__ +# endif +#endif #ifdef __cplusplus extern "C" { @@ -141,67 +166,72 @@ extern "C" { struct _obstack_chunk /* Lives at front of each chunk. */ { - char *limit; /* 1 past end of this chunk */ + char *limit; /* 1 past end of this chunk */ struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ + char contents[__FLEXIBLE_ARRAY_MEMBER]; /* objects begin here */ }; struct obstack /* control current object in current chunk */ { - long chunk_size; /* preferred size to allocate chunks in */ + _CHUNK_SIZE_T chunk_size; /* preferred size to allocate chunks in */ struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ union { - PTR_INT_TYPE tempint; - void *tempptr; + _OBSTACK_SIZE_T i; + void *p; } temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - /* These prototypes vary based on 'use_extra_arg', and we use - casts to the prototypeless function type in all assignments, - but having prototypes here quiets -Wstrict-prototypes. */ - struct _obstack_chunk *(*chunkfun) (void *, long); - void (*freefun) (void *, struct _obstack_chunk *); + _OBSTACK_SIZE_T alignment_mask; /* Mask of alignment for each object. */ + + /* These prototypes vary based on 'use_extra_arg'. */ + union + { + void *(*plain) (size_t); + void *(*extra) (void *, size_t); + } chunkfun; + union + { + void (*plain) (void *); + void (*extra) (void *, void *); + } freefun; + void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ - unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ - unsigned maybe_empty_object:1;/* There is a possibility that the current - chunk contains a zero-length object. This - prevents freeing the chunk if we allocate - a bigger chunk to replace it. */ - unsigned alloc_failed:1; /* No longer used, as we now call the failed - handler on error, but retained for binary - compatibility. */ + unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */ + unsigned maybe_empty_object : 1; /* There is a possibility that the current + chunk contains a zero-length object. This + prevents freeing the chunk if we allocate + a bigger chunk to replace it. */ + unsigned alloc_failed : 1; /* No longer used, as we now call the failed + handler on error, but retained for binary + compatibility. */ }; /* Declare the external functions we use; they are in obstack.c. */ -extern void _obstack_newchunk (struct obstack *, int); -extern int _obstack_begin (struct obstack *, int, int, - void *(*) (long), void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (void *, long), +extern void _obstack_newchunk (struct obstack *, _OBSTACK_SIZE_T); +extern void _obstack_free (struct obstack *, void *); +extern int _obstack_begin (struct obstack *, + _OBSTACK_SIZE_T, _OBSTACK_SIZE_T, + void *(*) (size_t), void (*) (void *)); +extern int _obstack_begin_1 (struct obstack *, + _OBSTACK_SIZE_T, _OBSTACK_SIZE_T, + void *(*) (void *, size_t), void (*) (void *, void *), void *); -extern int _obstack_memory_used (struct obstack *); +extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *) + __attribute_pure__; -/* The default name of the function for freeing a chunk is 'obstack_free', - but gnulib users can override this by defining '__obstack_free'. */ -#ifndef __obstack_free -# define __obstack_free obstack_free -#endif -extern void __obstack_free (struct obstack *obstack, void *block); - /* Error handler called when 'obstack_chunk_alloc' failed to allocate more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ -extern void (*obstack_alloc_failed_handler) (void); +extern __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void); /* Exit value used when 'print_and_abort' is used. */ extern int obstack_exit_failure; - + /* Pointer to beginning of object being allocated or to be allocated next. Note that this might not be the final address of the object because a new chunk might be needed to hold the final size. */ @@ -214,50 +244,47 @@ extern int obstack_exit_failure; /* Pointer to next byte not yet allocated in current chunk. */ -#define obstack_next_free(h) ((h)->next_free) +#define obstack_next_free(h) ((void *) (h)->next_free) /* Mask specifying low bits that should be clear in address of an object. */ #define obstack_alignment_mask(h) ((h)->alignment_mask) /* To prevent prototype warnings provide complete argument list. */ -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ - (void (*) (void *)) obstack_chunk_free) +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \ + _OBSTACK_CAST (void (*) (void *), obstack_chunk_free)) -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ - (void (*) (void *)) obstack_chunk_free) +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \ + _OBSTACK_CAST (void (*) (void *), obstack_chunk_free)) -#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) (long)) (chunkfun), \ - (void (*) (void *)) (freefun)) +#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + _OBSTACK_CAST (void *(*) (size_t), chunkfun), \ + _OBSTACK_CAST (void (*) (void *), freefun)) #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) (void *, long)) (chunkfun), \ - (void (*) (void *, void *)) (freefun), (arg)) + _obstack_begin_1 ((h), (size), (alignment), \ + _OBSTACK_CAST (void *(*) (void *, size_t), chunkfun), \ + _OBSTACK_CAST (void (*) (void *, void *), freefun), arg) -#define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) +#define obstack_chunkfun(h, newchunkfun) \ + ((void) ((h)->chunkfun.extra = (void *(*) (void *, size_t)) (newchunkfun))) -#define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) +#define obstack_freefun(h, newfreefun) \ + ((void) ((h)->freefun.extra = (void *(*) (void *, void *)) (newfreefun))) -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) +#define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar))) -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) +#define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n))) #define obstack_memory_used(h) _obstack_memory_used (h) - + #if defined __GNUC__ -/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and - does not implement __extension__. But that compiler doesn't define - __GNUC_MINOR__. */ -# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) +# if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008 # define __extension__ # endif @@ -266,160 +293,161 @@ extern int obstack_exit_failure; without using a global variable. Also, we can avoid using the 'temp' slot, to make faster code. */ -# define obstack_object_size(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -# define obstack_room(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -# define obstack_make_room(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - (void) 0; }) - -# define obstack_empty_p(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ - (__o->chunk->prev == 0 \ - && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ - __o->chunk->contents, \ - __o->alignment_mask)); }) - -# define obstack_grow(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len > __o->chunk_limit) \ - _obstack_newchunk (__o, __len); \ - memcpy (__o->next_free, where, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -# define obstack_grow0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, __len + 1); \ - memcpy (__o->next_free, where, __len); \ - __o->next_free += __len; \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -# define obstack_1grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, 1); \ - obstack_1grow_fast (__o, datum); \ - (void) 0; }) +# define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o = (OBSTACK); \ + (_OBSTACK_SIZE_T) (__o->next_free - __o->object_base); }) + +/* The local variable is named __o1 to avoid a shadowed variable + warning when invoked from other obstack macros. */ +# define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o1 = (OBSTACK); \ + (_OBSTACK_SIZE_T) (__o1->chunk_limit - __o1->next_free); }) + +# define obstack_make_room(OBSTACK, length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + _OBSTACK_SIZE_T __len = (length); \ + if (obstack_room (__o) < __len) \ + _obstack_newchunk (__o, __len); \ + (void) 0; }) + +# define obstack_empty_p(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o = (OBSTACK); \ + (__o->chunk->prev == 0 \ + && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ + __o->chunk->contents, \ + __o->alignment_mask)); }) + +# define obstack_grow(OBSTACK, where, length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + _OBSTACK_SIZE_T __len = (length); \ + if (obstack_room (__o) < __len) \ + _obstack_newchunk (__o, __len); \ + memcpy (__o->next_free, where, __len); \ + __o->next_free += __len; \ + (void) 0; }) + +# define obstack_grow0(OBSTACK, where, length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + _OBSTACK_SIZE_T __len = (length); \ + if (obstack_room (__o) < __len + 1) \ + _obstack_newchunk (__o, __len + 1); \ + memcpy (__o->next_free, where, __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ + (void) 0; }) + +# define obstack_1grow(OBSTACK, datum) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + if (obstack_room (__o) < 1) \ + _obstack_newchunk (__o, 1); \ + obstack_1grow_fast (__o, datum); }) /* These assume that the obstack alignment is good enough for pointers or ints, and that the data added so far to the current object shares that much alignment. */ -# define obstack_ptr_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (void *)); \ - obstack_ptr_grow_fast (__o, datum); }) \ - -# define obstack_int_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (int) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (int)); \ - obstack_int_grow_fast (__o, datum); }) - -# define obstack_ptr_grow_fast(OBSTACK,aptr) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *__p1 = __o1->next_free; \ - *(const void **) __p1 = (aptr); \ - __o1->next_free += sizeof (const void *); \ - (void) 0; }) - -# define obstack_int_grow_fast(OBSTACK,aint) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *__p1 = __o1->next_free; \ - *(int *) __p1 = (aint); \ - __o1->next_free += sizeof (int); \ - (void) 0; }) - -# define obstack_blank(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - obstack_blank_fast (__o, __len); \ - (void) 0; }) - -# define obstack_alloc(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -# define obstack_copy(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -# define obstack_copy0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -/* The local variable is named __o1 to avoid a name conflict - when obstack_blank is called. */ -# define obstack_finish(OBSTACK) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *__value = (void *) __o1->object_base; \ - if (__o1->next_free == __value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ - __o1->alignment_mask); \ - if (__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - __o1->next_free = __o1->chunk_limit; \ - __o1->object_base = __o1->next_free; \ - __value; }) - -# define obstack_free(OBSTACK, OBJ) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = (char *)__obj; \ - else (__obstack_free) (__o, __obj); }) - +# define obstack_ptr_grow(OBSTACK, datum) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + if (obstack_room (__o) < sizeof (void *)) \ + _obstack_newchunk (__o, sizeof (void *)); \ + obstack_ptr_grow_fast (__o, datum); }) + +# define obstack_int_grow(OBSTACK, datum) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + if (obstack_room (__o) < sizeof (int)) \ + _obstack_newchunk (__o, sizeof (int)); \ + obstack_int_grow_fast (__o, datum); }) + +# define obstack_ptr_grow_fast(OBSTACK, aptr) \ + __extension__ \ + ({ struct obstack *__o1 = (OBSTACK); \ + void *__p1 = __o1->next_free; \ + *(const void **) __p1 = (aptr); \ + __o1->next_free += sizeof (const void *); \ + (void) 0; }) + +# define obstack_int_grow_fast(OBSTACK, aint) \ + __extension__ \ + ({ struct obstack *__o1 = (OBSTACK); \ + void *__p1 = __o1->next_free; \ + *(int *) __p1 = (aint); \ + __o1->next_free += sizeof (int); \ + (void) 0; }) + +# define obstack_blank(OBSTACK, length) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + _OBSTACK_SIZE_T __len = (length); \ + if (obstack_room (__o) < __len) \ + _obstack_newchunk (__o, __len); \ + obstack_blank_fast (__o, __len); }) + +# define obstack_alloc(OBSTACK, length) \ + __extension__ \ + ({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +# define obstack_copy(OBSTACK, where, length) \ + __extension__ \ + ({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +# define obstack_copy0(OBSTACK, where, length) \ + __extension__ \ + ({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +/* The local variable is named __o1 to avoid a shadowed variable + warning when invoked from other obstack macros, typically obstack_free. */ +# define obstack_finish(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o1 = (OBSTACK); \ + void *__value = (void *) __o1->object_base; \ + if (__o1->next_free == __value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ + __o1->alignment_mask); \ + if ((size_t) (__o1->next_free - (char *) __o1->chunk) \ + > (size_t) (__o1->chunk_limit - (char *) __o1->chunk)) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ + __value; }) + +# define obstack_free(OBSTACK, OBJ) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + void *__obj = (void *) (OBJ); \ + if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \ + __o->next_free = __o->object_base = (char *) __obj; \ + else \ + _obstack_free (__o, __obj); }) + #else /* not __GNUC__ */ -# define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) +# define obstack_object_size(h) \ + ((_OBSTACK_SIZE_T) ((h)->next_free - (h)->object_base)) -# define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) +# define obstack_room(h) \ + ((_OBSTACK_SIZE_T) ((h)->chunk_limit - (h)->next_free)) -# define obstack_empty_p(h) \ - ((h)->chunk->prev == 0 \ - && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ - (h)->chunk->contents, \ - (h)->alignment_mask)) +# define obstack_empty_p(h) \ + ((h)->chunk->prev == 0 \ + && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ + (h)->chunk->contents, \ + (h)->alignment_mask)) /* Note that the call to _obstack_newchunk is enclosed in (..., 0) so that we can avoid having void expressions @@ -427,83 +455,87 @@ __extension__ \ Casting the third operand to void was tried before, but some compilers won't accept it. */ -# define obstack_make_room(h,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0)) - -# define obstack_grow(h,where,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ - memcpy ((h)->next_free, where, (h)->temp.tempint), \ - (h)->next_free += (h)->temp.tempint) - -# define obstack_grow0(h,where,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \ - memcpy ((h)->next_free, where, (h)->temp.tempint), \ - (h)->next_free += (h)->temp.tempint, \ - *((h)->next_free)++ = 0) - -# define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), 1), 0) : 0), \ - obstack_1grow_fast (h, datum)) - -# define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ - obstack_ptr_grow_fast (h, datum)) - -# define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ - obstack_int_grow_fast (h, datum)) - -# define obstack_ptr_grow_fast(h,aptr) \ - (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) - -# define obstack_int_grow_fast(h,aint) \ - (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) - -# define obstack_blank(h,length) \ -( (h)->temp.tempint = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ - obstack_blank_fast (h, (h)->temp.tempint)) - -# define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -# define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_finish(h) \ -( ((h)->next_free == (h)->object_base \ - ? (((h)->maybe_empty_object = 1), 0) \ - : 0), \ - (h)->temp.tempptr = (h)->object_base, \ - (h)->next_free \ - = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ - (h)->alignment_mask), \ - (((h)->next_free - (char *) (h)->chunk \ - > (h)->chunk_limit - (char *) (h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - (h)->temp.tempptr) - -# define obstack_free(h,obj) \ -( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ - ((((h)->temp.tempint > 0 \ - && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp.tempint + (char *) (h)->chunk) \ - : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) +# define obstack_make_room(h, length) \ + ((h)->temp.i = (length), \ + ((obstack_room (h) < (h)->temp.i) \ + ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0), \ + (void) 0) + +# define obstack_grow(h, where, length) \ + ((h)->temp.i = (length), \ + ((obstack_room (h) < (h)->temp.i) \ + ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp.i), \ + (h)->next_free += (h)->temp.i, \ + (void) 0) + +# define obstack_grow0(h, where, length) \ + ((h)->temp.i = (length), \ + ((obstack_room (h) < (h)->temp.i + 1) \ + ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp.i), \ + (h)->next_free += (h)->temp.i, \ + *((h)->next_free)++ = 0, \ + (void) 0) + +# define obstack_1grow(h, datum) \ + (((obstack_room (h) < 1) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ + obstack_1grow_fast (h, datum)) + +# define obstack_ptr_grow(h, datum) \ + (((obstack_room (h) < sizeof (char *)) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ + obstack_ptr_grow_fast (h, datum)) + +# define obstack_int_grow(h, datum) \ + (((obstack_room (h) < sizeof (int)) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ + obstack_int_grow_fast (h, datum)) + +# define obstack_ptr_grow_fast(h, aptr) \ + (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr), \ + (void) 0) + +# define obstack_int_grow_fast(h, aint) \ + (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint), \ + (void) 0) + +# define obstack_blank(h, length) \ + ((h)->temp.i = (length), \ + ((obstack_room (h) < (h)->temp.i) \ + ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ + obstack_blank_fast (h, (h)->temp.i)) + +# define obstack_alloc(h, length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +# define obstack_copy(h, where, length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_copy0(h, where, length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_finish(h) \ + (((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp.p = (h)->object_base, \ + (h)->next_free \ + = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ + (h)->alignment_mask), \ + (((size_t) ((h)->next_free - (char *) (h)->chunk) \ + > (size_t) ((h)->chunk_limit - (char *) (h)->chunk)) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + (h)->temp.p) + +# define obstack_free(h, obj) \ + ((h)->temp.p = (void *) (obj), \ + (((h)->temp.p > (void *) (h)->chunk \ + && (h)->temp.p < (void *) (h)->chunk_limit) \ + ? (void) ((h)->next_free = (h)->object_base = (char *) (h)->temp.p) \ + : _obstack_free ((h), (h)->temp.p))) #endif /* not __GNUC__ */ @@ -515,4 +547,4 @@ __extension__ \ int obstack_printf(struct obstack *obs, const char *format, ...); #endif -#endif /* obstack.h */ +#endif /* _OBSTACK_H */ diff --git a/contrib/tools/bison/lib/obstack_printf.c b/contrib/tools/bison/lib/obstack_printf.c index 291dcd52a4..705b4c0e7d 100644 --- a/contrib/tools/bison/lib/obstack_printf.c +++ b/contrib/tools/bison/lib/obstack_printf.c @@ -1,5 +1,5 @@ /* Formatted output to obstacks. - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/open.c b/contrib/tools/bison/lib/open.c index a0c43eadf9..792e258ba0 100644 --- a/contrib/tools/bison/lib/open.c +++ b/contrib/tools/bison/lib/open.c @@ -1,5 +1,5 @@ /* Open a descriptor to a file. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ @@ -38,6 +38,8 @@ orig_open (const char *filename, int flags, mode_t mode) this include because of the preliminary #include <fcntl.h> above. */ #include "fcntl.h" +#include "cloexec.h" + #include <errno.h> #include <stdarg.h> #include <string.h> @@ -52,6 +54,13 @@ orig_open (const char *filename, int flags, mode_t mode) int open (const char *filename, int flags, ...) { + /* 0 = unknown, 1 = yes, -1 = no. */ +#if GNULIB_defined_O_CLOEXEC + int have_cloexec = -1; +#else + static int have_cloexec; +#endif + mode_t mode; int fd; @@ -77,7 +86,7 @@ open (const char *filename, int flags, ...) flags &= ~O_NONBLOCK; #endif -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ if (strcmp (filename, "/dev/null") == 0) filename = "NUL"; #endif @@ -115,7 +124,25 @@ open (const char *filename, int flags, ...) } #endif - fd = orig_open (filename, flags, mode); + fd = orig_open (filename, + flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode); + + if (flags & O_CLOEXEC) + { + if (! have_cloexec) + { + if (0 <= fd) + have_cloexec = 1; + else if (errno == EINVAL) + { + fd = orig_open (filename, flags & ~O_CLOEXEC, mode); + have_cloexec = -1; + } + } + if (have_cloexec < 0 && 0 <= fd) + set_cloexec_flag (fd, true); + } + #if REPLACE_FCHDIR /* Implementing fchdir and fdopendir requires the ability to open a diff --git a/contrib/tools/bison/lib/pipe-safer.c b/contrib/tools/bison/lib/pipe-safer.c index f2e0ad6fb0..1669d90934 100644 --- a/contrib/tools/bison/lib/pipe-safer.c +++ b/contrib/tools/bison/lib/pipe-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe, but avoid some glitches. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Jim Meyering. */ diff --git a/contrib/tools/bison/lib/pipe2-safer.c b/contrib/tools/bison/lib/pipe2-safer.c index e831d0c6c1..71fef9ec8e 100644 --- a/contrib/tools/bison/lib/pipe2-safer.c +++ b/contrib/tools/bison/lib/pipe2-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe2, but avoid some glitches. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Eric Blake. */ diff --git a/contrib/tools/bison/lib/pipe2.c b/contrib/tools/bison/lib/pipe2.c index 211d75545c..c16d9351ec 100644 --- a/contrib/tools/bison/lib/pipe2.c +++ b/contrib/tools/bison/lib/pipe2.c @@ -1,5 +1,5 @@ /* Create a pipe, with specific opening flags. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -29,7 +29,7 @@ # include "nonblocking.h" #endif -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* Native Windows API. */ # include <io.h> @@ -73,7 +73,7 @@ pipe2 (int fd[2], int flags) return -1; } -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* Native Windows API. */ if (_pipe (fd, 4096, flags & ~O_NONBLOCK) < 0) @@ -152,8 +152,7 @@ pipe2 (int fd[2], int flags) #endif -#if GNULIB_defined_O_NONBLOCK || \ - !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) +#if GNULIB_defined_O_NONBLOCK || !(defined _WIN32 && ! defined __CYGWIN__) fail: { int saved_errno = errno; diff --git a/contrib/tools/bison/lib/printf-args.c b/contrib/tools/bison/lib/printf-args.c index c27e6bc6b7..1079e0a9a6 100644 --- a/contrib/tools/bison/lib/printf-args.c +++ b/contrib/tools/bison/lib/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ /* This file can be parametrized with the following macros: ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. diff --git a/contrib/tools/bison/lib/printf-args.h b/contrib/tools/bison/lib/printf-args.h index 2a9c2a3f87..111e8a5605 100644 --- a/contrib/tools/bison/lib/printf-args.h +++ b/contrib/tools/bison/lib/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _PRINTF_ARGS_H #define _PRINTF_ARGS_H diff --git a/contrib/tools/bison/lib/printf-frexp.c b/contrib/tools/bison/lib/printf-frexp.c index 1a7b0c438e..c704090b9e 100644 --- a/contrib/tools/bison/lib/printf-frexp.c +++ b/contrib/tools/bison/lib/printf-frexp.c @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #if ! defined USE_LONG_DOUBLE # include <config.h> diff --git a/contrib/tools/bison/lib/printf-frexp.h b/contrib/tools/bison/lib/printf-frexp.h index 3976b73686..814229f9c0 100644 --- a/contrib/tools/bison/lib/printf-frexp.h +++ b/contrib/tools/bison/lib/printf-frexp.h @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Write a finite, positive number x as x = mantissa * 2^exp diff --git a/contrib/tools/bison/lib/printf-frexpl.c b/contrib/tools/bison/lib/printf-frexpl.c index 26987a7bd1..cc8db67e33 100644 --- a/contrib/tools/bison/lib/printf-frexpl.c +++ b/contrib/tools/bison/lib/printf-frexpl.c @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/printf-frexpl.h b/contrib/tools/bison/lib/printf-frexpl.h index 3768b0915e..c48c70cd3a 100644 --- a/contrib/tools/bison/lib/printf-frexpl.h +++ b/contrib/tools/bison/lib/printf-frexpl.h @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Write a finite, positive number x as x = mantissa * 2^exp diff --git a/contrib/tools/bison/lib/printf-parse.c b/contrib/tools/bison/lib/printf-parse.c index 23cacc1dab..e6251458fd 100644 --- a/contrib/tools/bison/lib/printf-parse.c +++ b/contrib/tools/bison/lib/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ /* This file can be parametrized with the following macros: CHAR_T The element type of the format string. @@ -419,7 +419,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) cp++; } #endif -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* On native Windows, PRIdMAX is defined as "I64d". We cannot change it to "lld" because PRIdMAX must also be understood by the system's printf routines. */ diff --git a/contrib/tools/bison/lib/printf-parse.h b/contrib/tools/bison/lib/printf-parse.h index d8474bee15..16d817ec02 100644 --- a/contrib/tools/bison/lib/printf-parse.h +++ b/contrib/tools/bison/lib/printf-parse.h @@ -1,5 +1,5 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _PRINTF_PARSE_H #define _PRINTF_PARSE_H diff --git a/contrib/tools/bison/lib/progname.c b/contrib/tools/bison/lib/progname.c index 0c195e521a..382f5031d5 100644 --- a/contrib/tools/bison/lib/progname.c +++ b/contrib/tools/bison/lib/progname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/progname.h b/contrib/tools/bison/lib/progname.h index b4f3c2778a..adc6b01d23 100644 --- a/contrib/tools/bison/lib/progname.h +++ b/contrib/tools/bison/lib/progname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2004, 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _PROGNAME_H #define _PROGNAME_H diff --git a/contrib/tools/bison/lib/quote.h b/contrib/tools/bison/lib/quote.h index 1679796763..eedc283e08 100644 --- a/contrib/tools/bison/lib/quote.h +++ b/contrib/tools/bison/lib/quote.h @@ -1,6 +1,6 @@ /* quote.h - prototypes for quote.c - Copyright (C) 1998-2001, 2003, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1998-2001, 2003, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef QUOTE_H_ # define QUOTE_H_ 1 diff --git a/contrib/tools/bison/lib/quotearg.c b/contrib/tools/bison/lib/quotearg.c index 40114d7fbd..fe68dca313 100644 --- a/contrib/tools/bison/lib/quotearg.c +++ b/contrib/tools/bison/lib/quotearg.c @@ -1,6 +1,6 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998-2002, 2004-2013 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert <eggert@twinsun.com> */ @@ -29,6 +29,7 @@ #include "quotearg.h" #include "quote.h" +#include "minmax.h" #include "xalloc.h" #include "c-strcaseeq.h" #include "localcharset.h" @@ -37,6 +38,7 @@ #include <errno.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <wchar.h> @@ -52,6 +54,14 @@ #define INT_BITS (sizeof (int) * CHAR_BIT) +#ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +#endif + struct quoting_options { /* Basic quoting style. */ @@ -77,6 +87,8 @@ char const *const quoting_style_args[] = "literal", "shell", "shell-always", + "shell-escape", + "shell-escape-always", "c", "c-maybe", "escape", @@ -91,6 +103,8 @@ enum quoting_style const quoting_style_vals[] = literal_quoting_style, shell_quoting_style, shell_always_quoting_style, + shell_escape_quoting_style, + shell_escape_always_quoting_style, c_quoting_style, c_maybe_quoting_style, escape_quoting_style, @@ -116,7 +130,7 @@ clone_quoting_options (struct quoting_options *o) /* Get the value of O's quoting style. If O is null, use the default. */ enum quoting_style -get_quoting_style (struct quoting_options *o) +get_quoting_style (struct quoting_options const *o) { return (o ? o : &default_quoting_options)->style; } @@ -178,7 +192,7 @@ set_custom_quoting (struct quoting_options *o, static struct quoting_options /* NOT PURE!! */ quoting_options_from_style (enum quoting_style style) { - struct quoting_options o = { 0, 0, { 0 }, NULL, NULL }; + struct quoting_options o = { literal_quoting_style, 0, { 0 }, NULL, NULL }; if (style == custom_quoting_style) abort (); o.style = style; @@ -248,11 +262,15 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { size_t i; size_t len = 0; + size_t orig_buffersize = 0; char const *quote_string = 0; size_t quote_string_len = 0; bool backslash_escapes = false; bool unibyte_locale = MB_CUR_MAX == 1; bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0; + bool pending_shell_escape_end = false; + bool encountered_single_quote = false; + bool all_c_and_shell_quote_compat = true; #define STORE(c) \ do \ @@ -263,12 +281,44 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } \ while (0) +#define START_ESC() \ + do \ + { \ + if (elide_outer_quotes) \ + goto force_outer_quoting_style; \ + escaping = true; \ + if (quoting_style == shell_always_quoting_style \ + && ! pending_shell_escape_end) \ + { \ + STORE ('\''); \ + STORE ('$'); \ + STORE ('\''); \ + pending_shell_escape_end = true; \ + } \ + STORE ('\\'); \ + } \ + while (0) + +#define END_ESC() \ + do \ + { \ + if (pending_shell_escape_end && ! escaping) \ + { \ + STORE ('\''); \ + STORE ('\''); \ + pending_shell_escape_end = false; \ + } \ + } \ + while (0) + + process_input: + switch (quoting_style) { case c_maybe_quoting_style: quoting_style = c_quoting_style; elide_outer_quotes = true; - /* Fall through. */ + FALLTHROUGH; case c_quoting_style: if (!elide_outer_quotes) STORE ('"'); @@ -307,7 +357,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, for your locale. If you don't know what to put here, please see - <http://en.wikipedia.org/wiki/Quotation_marks_in_other_languages> + <https://en.wikipedia.org/wiki/Quotation_marks_in_other_languages> and use glyphs suitable for your language. */ left_quote = gettext_quote (N_("`"), quoting_style); right_quote = gettext_quote (N_("'"), quoting_style); @@ -321,11 +371,18 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } break; + case shell_escape_quoting_style: + backslash_escapes = true; + FALLTHROUGH; case shell_quoting_style: - quoting_style = shell_always_quoting_style; elide_outer_quotes = true; - /* Fall through. */ + FALLTHROUGH; + case shell_escape_always_quoting_style: + if (!elide_outer_quotes) + backslash_escapes = true; + FALLTHROUGH; case shell_always_quoting_style: + quoting_style = shell_always_quoting_style; if (!elide_outer_quotes) STORE ('\''); quote_string = "'"; @@ -345,8 +402,11 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, unsigned char c; unsigned char esc; bool is_right_quote = false; + bool escaping = false; + bool c_and_shell_quote_compat = false; if (backslash_escapes + && quoting_style != shell_always_quoting_style && quote_string_len && (i + quote_string_len <= (argsize == SIZE_MAX && 1 < quote_string_len @@ -367,15 +427,15 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '\0': if (backslash_escapes) { - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\\'); + START_ESC (); /* If quote_string were to begin with digits, we'd need to test for the end of the arg as well. However, it's hard to imagine any locale that would use digits in quotes, and set_custom_quoting is documented not to - accept them. */ - if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') + accept them. Use only a single \0 with shell-escape + as currently digits are not printed within $'...' */ + if (quoting_style != shell_always_quoting_style + && i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') { STORE ('0'); STORE ('0'); @@ -436,6 +496,14 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '\t': esc = 't'; goto c_and_shell_escape; case '\v': esc = 'v'; goto c_escape; case '\\': esc = c; + /* Never need to escape '\' in shell case. */ + if (quoting_style == shell_always_quoting_style) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + goto store_c; + } + /* No need to escape the escape if we are trying to elide outer quotes and nothing else is problematic. */ if (backslash_escapes && elide_outer_quotes && quote_string_len) @@ -445,7 +513,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, if (quoting_style == shell_always_quoting_style && elide_outer_quotes) goto force_outer_quoting_style; - /* Fall through. */ + /* fall through */ c_escape: if (backslash_escapes) { @@ -457,12 +525,14 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '{': case '}': /* sometimes special if isolated */ if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) break; - /* Fall through. */ + FALLTHROUGH; case '#': case '~': if (i != 0) break; - /* Fall through. */ + FALLTHROUGH; case ' ': + c_and_shell_quote_compat = true; + FALLTHROUGH; case '!': /* special in bash */ case '"': case '$': case '&': case '(': case ')': case '*': case ';': @@ -481,13 +551,26 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, break; case '\'': + encountered_single_quote = true; + c_and_shell_quote_compat = true; if (quoting_style == shell_always_quoting_style) { if (elide_outer_quotes) goto force_outer_quoting_style; + + if (buffersize && ! orig_buffersize) + { + /* Just scan string to see if supports a more concise + representation, rather than writing a longer string + but returning the length of the more concise form. */ + orig_buffersize = buffersize; + buffersize = 0; + } + STORE ('\''); STORE ('\\'); STORE ('\''); + pending_shell_escape_end = false; } break; @@ -513,6 +596,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, them. Also, a digit or a special letter would cause trouble if it appeared in quote_these_too, but that's also documented as not accepting them. */ + c_and_shell_quote_compat = true; break; default: @@ -591,6 +675,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, while (! mbsinit (&mbstate)); } + c_and_shell_quote_compat = printable; + if (1 < m || (backslash_escapes && ! printable)) { /* Output a multibyte sequence, or an escaped @@ -601,9 +687,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { if (backslash_escapes && ! printable) { - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\\'); + START_ESC (); STORE ('0' + (c >> 6)); STORE ('0' + ((c >> 3) & 7)); c = '0' + (c & 7); @@ -615,6 +699,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } if (ilim <= i + 1) break; + END_ESC (); STORE (c); c = arg[++i]; } @@ -624,25 +709,49 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } } - if (! ((backslash_escapes || elide_outer_quotes) + if (! (((backslash_escapes && quoting_style != shell_always_quoting_style) + || elide_outer_quotes) && quote_these_too - && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))) + && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1) && !is_right_quote) goto store_c; store_escape: - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\\'); + START_ESC (); store_c: + END_ESC (); STORE (c); + + if (! c_and_shell_quote_compat) + all_c_and_shell_quote_compat = false; } if (len == 0 && quoting_style == shell_always_quoting_style && elide_outer_quotes) goto force_outer_quoting_style; + /* Single shell quotes (') are commonly enough used as an apostrophe, + that we attempt to minimize the quoting in this case. Note itʼs + better to use the apostrophe modifier "\u02BC" if possible, as that + renders better and works with the word match regex \W+ etc. */ + if (quoting_style == shell_always_quoting_style && ! elide_outer_quotes + && encountered_single_quote) + { + if (all_c_and_shell_quote_compat) + return quotearg_buffer_restyled (buffer, orig_buffersize, arg, argsize, + c_quoting_style, + flags, quote_these_too, + left_quote, right_quote); + else if (! buffersize && orig_buffersize) + { + /* Disable read-only scan, and reprocess to write quoted string. */ + buffersize = orig_buffersize; + len = 0; + goto process_input; + } + } + if (quote_string && !elide_outer_quotes) for (; *quote_string; quote_string++) STORE (*quote_string); @@ -654,6 +763,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, force_outer_quoting_style: /* Don't reuse quote_these_too, since the addition of outer quotes sufficiently quotes the specified characters. */ + if (quoting_style == shell_always_quoting_style && backslash_escapes) + quoting_style = shell_escape_always_quoting_style; return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, quoting_style, flags & ~QA_ELIDE_OUTER_QUOTES, NULL, @@ -729,7 +840,7 @@ struct slotvec /* Preallocate a slot 0 buffer, so that the caller can always quote one small component of a "memory exhausted" message in slot 0. */ static char slot0[256]; -static unsigned int nslots = 1; +static int nslots = 1; static struct slotvec slotvec0 = {sizeof slot0, slot0}; static struct slotvec *slotvec = &slotvec0; @@ -737,7 +848,7 @@ void quotearg_free (void) { struct slotvec *sv = slotvec; - unsigned int i; + int i; for (i = 1; i < nslots; i++) free (sv[i].val); if (sv[0].val != slot0) @@ -768,30 +879,24 @@ quotearg_n_options (int n, char const *arg, size_t argsize, { int e = errno; - unsigned int n0 = n; struct slotvec *sv = slotvec; if (n < 0) abort (); - if (nslots <= n0) + if (nslots <= n) { - /* FIXME: technically, the type of n1 should be 'unsigned int', - but that evokes an unsuppressible warning from gcc-4.0.1 and - older. If gcc ever provides an option to suppress that warning, - revert to the original type, so that the test in xalloc_oversized - is once again performed only at compile time. */ - size_t n1 = n0 + 1; bool preallocated = (sv == &slotvec0); + int nmax = MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) - 1; - if (xalloc_oversized (n1, sizeof *sv)) + if (nmax < n) xalloc_die (); - slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv); + slotvec = sv = xrealloc (preallocated ? NULL : sv, (n + 1) * sizeof *sv); if (preallocated) *sv = slotvec0; - memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv); - nslots = n1; + memset (sv + nslots, 0, (n + 1 - nslots) * sizeof *sv); + nslots = n + 1; } { @@ -901,6 +1006,15 @@ quotearg_colon_mem (char const *arg, size_t argsize) } char * +quotearg_n_style_colon (int n, enum quoting_style s, char const *arg) +{ + struct quoting_options options; + options = quoting_options_from_style (s); + set_char_quoting (&options, ':', 1); + return quotearg_n_options (n, arg, SIZE_MAX, &options); +} + +char * quotearg_n_custom (int n, char const *left_quote, char const *right_quote, char const *arg) { @@ -966,3 +1080,10 @@ quote (char const *arg) { return quote_n (0, arg); } + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/contrib/tools/bison/lib/quotearg.h b/contrib/tools/bison/lib/quotearg.h index 58ee3f6089..0584c56a2b 100644 --- a/contrib/tools/bison/lib/quotearg.h +++ b/contrib/tools/bison/lib/quotearg.h @@ -1,6 +1,6 @@ /* quotearg.h - quote arguments for output - Copyright (C) 1998-2002, 2004, 2006, 2008-2013 Free Software Foundation, + Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert <eggert@twinsun.com> */ @@ -73,6 +73,37 @@ enum quoting_style */ shell_always_quoting_style, + /* Quote names for the shell if they contain shell metacharacters + or other problematic characters (ls --quoting-style=shell-escape). + Non printable characters are quoted using the $'...' syntax, + which originated in ksh93 and is widely supported by most shells, + and proposed for inclusion in POSIX. + + quotearg_buffer: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b" + quotearg: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b" + quotearg_colon: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "'a:b'" + */ + shell_escape_quoting_style, + + /* Quote names for the shell even if they would normally not + require quoting (ls --quoting-style=shell-escape). + Non printable characters are quoted using the $'...' syntax, + which originated in ksh93 and is widely supported by most shells, + and proposed for inclusion in POSIX. Behaves like + shell_escape_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect. + + quotearg_buffer: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b" + quotearg: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b" + quotearg_colon: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "'a:b'" + */ + shell_escape_always_quoting_style, + /* Quote names as for a C language string (ls --quoting-style=c). Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect. Split into consecutive strings if @@ -247,7 +278,7 @@ struct quoting_options; struct quoting_options *clone_quoting_options (struct quoting_options *o); /* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style get_quoting_style (struct quoting_options *o); +enum quoting_style get_quoting_style (struct quoting_options const *o); /* In O (or in the default if O is null), set the value of the quoting style to S. */ @@ -362,6 +393,9 @@ char *quotearg_colon (char const *arg); /* Like quotearg_colon (ARG), except it can quote null bytes. */ char *quotearg_colon_mem (char const *arg, size_t argsize); +/* Like quotearg_n_style, except with ':' quoting enabled. */ +char *quotearg_n_style_colon (int n, enum quoting_style s, char const *arg); + /* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See set_custom_quoting for a description of acceptable LEFT_QUOTE and diff --git a/contrib/tools/bison/lib/raise.c b/contrib/tools/bison/lib/raise.c index 5b546d2b8d..3a29339a66 100644 --- a/contrib/tools/bison/lib/raise.c +++ b/contrib/tools/bison/lib/raise.c @@ -1,6 +1,6 @@ /* Provide a non-threads replacement for the POSIX raise function. - Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* written by Jim Meyering and Bruno Haible */ @@ -27,7 +27,9 @@ # include <errno.h> -# include "msvc-inval.h" +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif # undef raise diff --git a/contrib/tools/bison/lib/sig-handler.h b/contrib/tools/bison/lib/sig-handler.h index ca9f979c41..9ea339453f 100644 --- a/contrib/tools/bison/lib/sig-handler.h +++ b/contrib/tools/bison/lib/sig-handler.h @@ -1,6 +1,6 @@ /* Convenience declarations when working with <signal.h>. - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,13 +13,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _GL_SIG_HANDLER_H #define _GL_SIG_HANDLER_H #include <signal.h> +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif _GL_INLINE_HEADER_BEGIN #ifndef SIG_HANDLER_INLINE # define SIG_HANDLER_INLINE _GL_INLINE @@ -31,18 +34,15 @@ typedef void (*sa_handler_t) (int); /* Return the handler of a signal, as a sa_handler_t value regardless of its true type. The resulting function can be compared to special values like SIG_IGN but it is not portable to call it. */ -SIG_HANDLER_INLINE sa_handler_t +SIG_HANDLER_INLINE sa_handler_t _GL_ATTRIBUTE_PURE get_handler (struct sigaction const *a) { -#ifdef SA_SIGINFO /* POSIX says that special values like SIG_IGN can only occur when action.sa_flags does not contain SA_SIGINFO. But in Linux 2.4, for example, sa_sigaction and sa_handler are aliases and a signal - is ignored if sa_sigaction (after casting) equals SIG_IGN. So - use (and cast) sa_sigaction in that case. */ - if (a->sa_flags & SA_SIGINFO) - return (sa_handler_t) a->sa_sigaction; -#endif + is ignored if sa_sigaction (after casting) equals SIG_IGN. In + this case, this implementation relies on the fact that the two + are aliases, and simply returns sa_handler. */ return a->sa_handler; } diff --git a/contrib/tools/bison/lib/sigaction.c b/contrib/tools/bison/lib/sigaction.c index 97eb76d92e..7e4af5fe55 100644 --- a/contrib/tools/bison/lib/sigaction.c +++ b/contrib/tools/bison/lib/sigaction.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. Written by Eric Blake <ebb9@byu.net>, 2008. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -67,7 +67,7 @@ /* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias for the signal SIGABRT. Only one signal handler is stored for both SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ # undef SIGABRT_COMPAT # define SIGABRT_COMPAT 6 #endif diff --git a/contrib/tools/bison/lib/sigprocmask.c b/contrib/tools/bison/lib/sigprocmask.c index 8de3777db3..7a49bcd115 100644 --- a/contrib/tools/bison/lib/sigprocmask.c +++ b/contrib/tools/bison/lib/sigprocmask.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2006. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -50,7 +50,7 @@ /* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias for the signal SIGABRT. Only one signal handler is stored for both SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ # undef SIGABRT_COMPAT # define SIGABRT_COMPAT 6 #endif diff --git a/contrib/tools/bison/lib/spawn-pipe.c b/contrib/tools/bison/lib/spawn-pipe.c index 57a891aac0..1324f9008c 100644 --- a/contrib/tools/bison/lib/spawn-pipe.c +++ b/contrib/tools/bison/lib/spawn-pipe.c @@ -1,5 +1,5 @@ /* Creation of subprocesses, communicating via pipes. - Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,9 +13,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ +/* Tell clang not to warn about the 'child' variable, below. */ +#if defined __clang__ +# pragma clang diagnostic ignored "-Wconditional-uninitialized" +#endif + #include <config.h> /* Specification. */ @@ -35,7 +40,7 @@ #define _(str) gettext (str) -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if (defined _WIN32 && ! defined __CYGWIN__) || defined __KLIBC__ /* Native Windows API. */ # include <process.h> @@ -48,11 +53,6 @@ #endif -/* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close - #if defined(__FreeBSD__) || defined(__MACH__) extern char** environ; #endif @@ -74,9 +74,10 @@ nonintr_close (int fd) return retval; } +#undef close /* avoid warning related to gnulib module unistd */ #define close nonintr_close -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ static int nonintr_open (const char *pathname, int oflag, mode_t mode) { @@ -117,7 +118,7 @@ create_pipe (const char *progname, bool slave_process, bool exit_on_error, int fd[2]) { -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if (defined _WIN32 && ! defined __CYGWIN__) || defined __KLIBC__ /* Native Windows API. This uses _pipe(), dup2(), and spawnv(). It could also be implemented diff --git a/contrib/tools/bison/lib/spawn-pipe.h b/contrib/tools/bison/lib/spawn-pipe.h index ea8284f268..52576d00b8 100644 --- a/contrib/tools/bison/lib/spawn-pipe.h +++ b/contrib/tools/bison/lib/spawn-pipe.h @@ -1,5 +1,5 @@ /* Creation of subprocesses, communicating via pipes. - Copyright (C) 2001-2003, 2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _SPAWN_PIPE_H #define _SPAWN_PIPE_H @@ -130,7 +130,7 @@ extern pid_t create_pipe_bidi (const char *progname, int fd[2]); /* The name of the "always silent" device. */ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ /* Native Windows API. */ # define DEV_NULL "NUL" #else diff --git a/contrib/tools/bison/lib/stat-time.c b/contrib/tools/bison/lib/stat-time.c new file mode 100644 index 0000000000..81b83ddb4f --- /dev/null +++ b/contrib/tools/bison/lib/stat-time.c @@ -0,0 +1,3 @@ +#include <config.h> +#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE +#include "stat-time.h" diff --git a/contrib/tools/bison/lib/stat-time.h b/contrib/tools/bison/lib/stat-time.h new file mode 100644 index 0000000000..8e787bd3b2 --- /dev/null +++ b/contrib/tools/bison/lib/stat-time.h @@ -0,0 +1,252 @@ +/* stat-related time functions. + + Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +#ifndef STAT_TIME_H +#define STAT_TIME_H 1 + +#include "intprops.h" + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <time.h> + +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_STAT_TIME_INLINE +# define _GL_STAT_TIME_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type + struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, + ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, + if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim + for access, status change, data modification, or birth (creation) + time respectively. + + These macros are private to stat-time.h. */ +#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC +# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC +# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) +# else +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) +# endif +#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC +# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) +#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) +#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec) +#endif + +/* Return the nanosecond component of *ST's access time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_atime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_atim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_atim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's status change time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_ctime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_ctim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_ctim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's data modification time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_mtime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_mtim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_mtim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's birth time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_birthtime_ns (struct stat const *st _GL_UNUSED) +{ +# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC + return STAT_TIMESPEC (st, st_birthtim).tv_nsec; +# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC + return STAT_TIMESPEC_NS (st, st_birthtim); +# else + return 0; +# endif +} + +/* Return *ST's access time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_atime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_atim); +#else + struct timespec t; + t.tv_sec = st->st_atime; + t.tv_nsec = get_stat_atime_ns (st); + return t; +#endif +} + +/* Return *ST's status change time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_ctime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_ctim); +#else + struct timespec t; + t.tv_sec = st->st_ctime; + t.tv_nsec = get_stat_ctime_ns (st); + return t; +#endif +} + +/* Return *ST's data modification time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_mtime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_mtim); +#else + struct timespec t; + t.tv_sec = st->st_mtime; + t.tv_nsec = get_stat_mtime_ns (st); + return t; +#endif +} + +/* Return *ST's birth time, if available; otherwise return a value + with tv_sec and tv_nsec both equal to -1. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_birthtime (struct stat const *st _GL_UNUSED) +{ + struct timespec t; + +#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) + t = STAT_TIMESPEC (st, st_birthtim); +#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC + t.tv_sec = st->st_birthtime; + t.tv_nsec = st->st_birthtimensec; +#elif defined _WIN32 && ! defined __CYGWIN__ + /* Native Windows platforms (but not Cygwin) put the "file creation + time" in st_ctime (!). See + <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>. */ +# if _GL_WINDOWS_STAT_TIMESPEC + t = st->st_ctim; +# else + t.tv_sec = st->st_ctime; + t.tv_nsec = 0; +# endif +#else + /* Birth time is not supported. */ + t.tv_sec = -1; + t.tv_nsec = -1; +#endif + +#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC) + /* FreeBSD and NetBSD sometimes signal the absence of knowledge by + using zero. Attempt to work around this problem. Alas, this can + report failure even for valid timestamps. Also, NetBSD + sometimes returns junk in the birth time fields; work around this + bug if it is detected. */ + if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) + { + t.tv_sec = -1; + t.tv_nsec = -1; + } +#endif + + return t; +} + +/* If a stat-like function returned RESULT, normalize the timestamps + in *ST, in case this platform suffers from the Solaris 11 bug where + tv_nsec might be negative. Return the adjusted RESULT, setting + errno to EOVERFLOW if normalization overflowed. This function + is intended to be private to this .h file. */ +_GL_STAT_TIME_INLINE int +stat_time_normalize (int result, struct stat *st _GL_UNUSED) +{ +#if defined __sun && defined STAT_TIMESPEC + if (result == 0) + { + long int timespec_resolution = 1000000000; + short int const ts_off[] = { offsetof (struct stat, st_atim), + offsetof (struct stat, st_mtim), + offsetof (struct stat, st_ctim) }; + int i; + for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) + { + struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); + long int q = ts->tv_nsec / timespec_resolution; + long int r = ts->tv_nsec % timespec_resolution; + if (r < 0) + { + r += timespec_resolution; + q--; + } + ts->tv_nsec = r; + /* Overflow is possible, as Solaris 11 stat can yield + tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. + INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */ + if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec)) + { + errno = EOVERFLOW; + return -1; + } + } + } +#endif + return result; +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif diff --git a/contrib/tools/bison/lib/stdio-impl.h b/contrib/tools/bison/lib/stdio-impl.h index 18575555a0..393ef0cf58 100644 --- a/contrib/tools/bison/lib/stdio-impl.h +++ b/contrib/tools/bison/lib/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Many stdio implementations have the same logic and therefore can share the same implementation of stdio extension API, except that some fields @@ -34,10 +34,11 @@ #include <errno.h> /* For detecting Plan9. */ -#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ +#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ # if defined __DragonFly__ /* DragonFly */ - /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */ + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */ # define fp_ ((struct { struct __FILE_public pub; \ struct { unsigned char *_base; int _size; } _bf; \ void *cookie; \ @@ -54,30 +55,84 @@ fpos_t _offset; \ /* More fields, not relevant here. */ \ } *) fp) - /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */ + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */ # define _p pub._p # define _flags pub._flags # define _r pub._r # define _w pub._w +# elif defined __ANDROID__ /* Android */ + /* Up to this commit from 2015-10-12 + <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a> + the innards of FILE were public, and fp_ub could be defined like for OpenBSD, + see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h> + and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>. + After this commit, the innards of FILE are hidden. */ +# define fp_ ((struct { unsigned char *_p; \ + int _r; \ + int _w; \ + int _flags; \ + int _file; \ + struct { unsigned char *_base; size_t _size; } _bf; \ + int _lbfsize; \ + void *_cookie; \ + void *_close; \ + void *_read; \ + void *_seek; \ + void *_write; \ + struct { unsigned char *_base; size_t _size; } _ext; \ + unsigned char *_up; \ + int _ur; \ + unsigned char _ubuf[3]; \ + unsigned char _nbuf[1]; \ + struct { unsigned char *_base; size_t _size; } _lb; \ + int _blksize; \ + fpos_t _offset; \ + /* More fields, not relevant here. */ \ + } *) fp) # else # define fp_ fp # endif -# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ /* NetBSD >= 1.5ZA, OpenBSD */ +# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> - and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */ + and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> + and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */ struct __sfileext { struct __sbuf _ub; /* ungetc buffer */ /* More fields, not relevant here. */ }; # define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub +# elif defined __ANDROID__ /* Android */ + struct __sfileext + { + struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */ + /* More fields, not relevant here. */ + }; +# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub # else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */ # define fp_ub fp_->_ub # endif # define HASUB(fp) (fp_ub._base != NULL) +# if defined __ANDROID__ /* Android */ + /* Needed after this commit from 2016-01-25 + <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */ +# ifndef __SEOF +# define __SLBF 1 +# define __SNBF 2 +# define __SRD 4 +# define __SWR 8 +# define __SRW 0x10 +# define __SEOF 0x20 +# define __SERR 0x40 +# endif +# ifndef __SOFF +# define __SOFF 0x1000 +# endif +# endif + #endif @@ -86,7 +141,7 @@ #ifdef __TANDEM /* NonStop Kernel */ # ifndef _IOERR /* These values were determined by the program 'stdioext-flags' at - <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ # define _IOERR 0x40 # define _IOREAD 0x80 # define _IOWRT 0x4 @@ -104,6 +159,8 @@ int _file; \ unsigned int _flag; \ } *) fp) +# elif defined __VMS /* OpenVMS */ +# define fp_ ((struct _iobuf *) fp) # else # define fp_ fp # endif @@ -115,4 +172,31 @@ # define _flag __flag # endif +#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */ + +/* <stdio.h> does not define the innards of FILE any more. */ +# define WINDOWS_OPAQUE_FILE + +struct _gl_real_FILE +{ + /* Note: Compared to older Windows and to mingw, it has the fields + _base and _cnt swapped. */ + unsigned char *_ptr; + unsigned char *_base; + int _cnt; + int _flag; + int _file; + int _charbuf; + int _bufsiz; +}; +# define fp_ ((struct _gl_real_FILE *) fp) + +/* These values were determined by a program similar to the one at + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ +# define _IOREAD 0x1 +# define _IOWRT 0x2 +# define _IORW 0x4 +# define _IOEOF 0x8 +# define _IOERR 0x10 + #endif diff --git a/contrib/tools/bison/lib/stdio-safer.h b/contrib/tools/bison/lib/stdio-safer.h index 7b67ae059d..17d4dd282a 100644 --- a/contrib/tools/bison/lib/stdio-safer.h +++ b/contrib/tools/bison/lib/stdio-safer.h @@ -1,6 +1,6 @@ /* Invoke stdio functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ diff --git a/contrib/tools/bison/lib/stpcpy.c b/contrib/tools/bison/lib/stpcpy.c index 8d7dfb07a9..61239e9f1d 100644 --- a/contrib/tools/bison/lib/stpcpy.c +++ b/contrib/tools/bison/lib/stpcpy.c @@ -1,5 +1,5 @@ /* stpcpy.c -- copy a string and return pointer to end of new string - Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2013 Free Software + Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2018 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. @@ -16,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/streq.h b/contrib/tools/bison/lib/streq.h index 12c1867c83..bde1b9562f 100644 --- a/contrib/tools/bison/lib/streq.h +++ b/contrib/tools/bison/lib/streq.h @@ -1,5 +1,5 @@ /* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -12,7 +12,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>. */ diff --git a/contrib/tools/bison/lib/stripslash.c b/contrib/tools/bison/lib/stripslash.c index 0e452a95ef..60c6781ca1 100644 --- a/contrib/tools/bison/lib/stripslash.c +++ b/contrib/tools/bison/lib/stripslash.c @@ -1,6 +1,6 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation, + Copyright (C) 1990, 2001, 2003-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/strndup.c b/contrib/tools/bison/lib/strndup.c index e60268b86e..b5c18dda66 100644 --- a/contrib/tools/bison/lib/strndup.c +++ b/contrib/tools/bison/lib/strndup.c @@ -1,6 +1,6 @@ /* A replacement function, for systems that lack strndup. - Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2013 Free Software + Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/strverscmp.c b/contrib/tools/bison/lib/strverscmp.c index db4f1edc70..4eac791584 100644 --- a/contrib/tools/bison/lib/strverscmp.c +++ b/contrib/tools/bison/lib/strverscmp.c @@ -1,21 +1,21 @@ /* Compare strings while treating digits characters numerically. - Copyright (C) 1997, 2000, 2002, 2004, 2006, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ #if !_LIBC # include <config.h> @@ -26,27 +26,14 @@ /* states: S_N: normal, S_I: comparing integral part, S_F: comparing fractional parts, S_Z: idem but with leading Zeroes only */ -#define S_N 0x0 -#define S_I 0x4 -#define S_F 0x8 -#define S_Z 0xC +#define S_N 0x0 +#define S_I 0x3 +#define S_F 0x6 +#define S_Z 0x9 /* result_type: CMP: return diff; LEN: compare using len_diff/diff */ -#define CMP 2 -#define LEN 3 - - -/* ISDIGIT differs from isdigit, as follows: - - Its arg may be any int or unsigned int; it need not be an unsigned char - or EOF. - - It's typically faster. - POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to - isdigit unless it's important to use the locale's definition - of "digit" even when the host does not conform to POSIX. */ -#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) - -#undef __strverscmp -#undef strverscmp +#define CMP 2 +#define LEN 3 #ifndef weak_alias # define __strverscmp strverscmp @@ -66,30 +53,25 @@ __strverscmp (const char *s1, const char *s2) int state; int diff; - /* Symbol(s) 0 [1-9] others (padding) - Transition (10) 0 (01) d (00) x (11) - */ - static const unsigned int next_state[] = + /* Symbol(s) 0 [1-9] others + Transition (10) 0 (01) d (00) x */ + static const unsigned char next_state[] = { - /* state x d 0 - */ - /* S_N */ S_N, S_I, S_Z, S_N, - /* S_I */ S_N, S_I, S_I, S_I, - /* S_F */ S_N, S_F, S_F, S_F, - /* S_Z */ S_N, S_F, S_Z, S_Z + /* state x d 0 */ + /* S_N */ S_N, S_I, S_Z, + /* S_I */ S_N, S_I, S_I, + /* S_F */ S_N, S_F, S_F, + /* S_Z */ S_N, S_F, S_Z }; - static const int result_type[] = + static const signed char result_type[] = { - /* state x/x x/d x/0 x/- d/x d/d d/0 d/- - 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */ - - /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, - CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP, - 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, - /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, - CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP, - -1, CMP, CMP, CMP + /* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */ + + /* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP, + /* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN, + /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, + /* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP }; if (p1 == p2) @@ -98,17 +80,20 @@ __strverscmp (const char *s1, const char *s2) c1 = *p1++; c2 = *p2++; /* Hint: '0' is a digit too. */ - state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0)); + state = S_N + ((c1 == '0') + (isdigit (c1) != 0)); - while ((diff = c1 - c2) == 0 && c1 != '\0') + while ((diff = c1 - c2) == 0) { + if (c1 == '\0') + return diff; + state = next_state[state]; c1 = *p1++; c2 = *p2++; - state |= (c1 == '0') + (ISDIGIT (c1) != 0); + state += (c1 == '0') + (isdigit (c1) != 0); } - state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))]; + state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))]; switch (state) { @@ -116,16 +101,17 @@ __strverscmp (const char *s1, const char *s2) return diff; case LEN: - while (ISDIGIT (*p1++)) - if (!ISDIGIT (*p2++)) + while (isdigit (*p1++)) + if (!isdigit (*p2++)) return 1; - return ISDIGIT (*p2) ? -1 : diff; + return isdigit (*p2) ? -1 : diff; default: return state; } } #ifdef weak_alias +libc_hidden_def (__strverscmp) weak_alias (__strverscmp, strverscmp) #endif diff --git a/contrib/tools/bison/lib/timevar.c b/contrib/tools/bison/lib/timevar.c index 59a649885a..e780c303fc 100644 --- a/contrib/tools/bison/lib/timevar.c +++ b/contrib/tools/bison/lib/timevar.c @@ -1,6 +1,6 @@ /* Timing variables for measuring compiler performance. - Copyright (C) 2000, 2002, 2004, 2006, 2009-2013 Free Software + Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018 Free Software Foundation, Inc. Contributed by Alex Samuel <samuel@codesourcery.com> @@ -448,7 +448,7 @@ timevar_print (fp) { /* Only print stuff if we have some sort of time information. */ #if defined HAVE_USER_TIME || defined HAVE_SYS_TIME || defined HAVE_WALL_TIME - unsigned int /* timevar_id_t */ id; + unsigned /* timevar_id_t */ id; struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed; struct timevar_time_def now; @@ -473,7 +473,7 @@ timevar_print (fp) start_time = now; fputs (_("\nExecution times (seconds)\n"), fp); - for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id) + for (id = 0; id < (unsigned) TIMEVAR_LAST; ++id) { struct timevar_def *tv = &timevars[(timevar_id_t) id]; const float tiny = 5e-3; diff --git a/contrib/tools/bison/lib/timevar.def b/contrib/tools/bison/lib/timevar.def index 484fe35f7b..01eaba7076 100644 --- a/contrib/tools/bison/lib/timevar.def +++ b/contrib/tools/bison/lib/timevar.def @@ -1,7 +1,8 @@ /* This file contains the definitions for timing variables used to -*- C -*- measure run-time performance of the compiler. - Copyright (C) 2002, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2007, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Akim Demaille <akim@freefriends.org>. diff --git a/contrib/tools/bison/lib/timevar.h b/contrib/tools/bison/lib/timevar.h index d397bd7ff0..14366c9628 100644 --- a/contrib/tools/bison/lib/timevar.h +++ b/contrib/tools/bison/lib/timevar.h @@ -1,7 +1,7 @@ /* Timing variables for measuring compiler performance. - Copyright (C) 2000, 2002, 2004, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software + Foundation, Inc. Contributed by Alex Samuel <samuel@codesourcery.com> diff --git a/contrib/tools/bison/lib/unistd-safer.h b/contrib/tools/bison/lib/unistd-safer.h index 5c2b55ae2f..5baf339a08 100644 --- a/contrib/tools/bison/lib/unistd-safer.h +++ b/contrib/tools/bison/lib/unistd-safer.h @@ -1,6 +1,6 @@ /* Invoke unistd-like functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2005, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert and Eric Blake. */ diff --git a/contrib/tools/bison/lib/unistd.c b/contrib/tools/bison/lib/unistd.c index 6c6a8e268c..72bad1c052 100644 --- a/contrib/tools/bison/lib/unistd.c +++ b/contrib/tools/bison/lib/unistd.c @@ -1,3 +1,4 @@ #include <config.h> #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE #include "unistd.h" +typedef int dummy; diff --git a/contrib/tools/bison/lib/unitypes.h b/contrib/tools/bison/lib/unitypes.h index 3d7db7510d..e45ff8052a 100644 --- a/contrib/tools/bison/lib/unitypes.h +++ b/contrib/tools/bison/lib/unitypes.h @@ -1,6 +1,6 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Elementary types and macros for the GNU UniString library. - Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -13,7 +13,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _UNITYPES_H #define _UNITYPES_H diff --git a/contrib/tools/bison/lib/uniwidth.h b/contrib/tools/bison/lib/uniwidth.h index 2ad29275a5..65445fa519 100644 --- a/contrib/tools/bison/lib/uniwidth.h +++ b/contrib/tools/bison/lib/uniwidth.h @@ -1,6 +1,6 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Display width functions. - Copyright (C) 2001-2002, 2005, 2007, 2009-2013 Free Software Foundation, + Copyright (C) 2001-2002, 2005, 2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it @@ -14,7 +14,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _UNIWIDTH_H #define _UNIWIDTH_H diff --git a/contrib/tools/bison/lib/uniwidth/cjk.h b/contrib/tools/bison/lib/uniwidth/cjk.h index 11b14dfec5..f7f822ca68 100644 --- a/contrib/tools/bison/lib/uniwidth/cjk.h +++ b/contrib/tools/bison/lib/uniwidth/cjk.h @@ -1,5 +1,5 @@ /* Test for CJK encoding. - Copyright (C) 2001-2002, 2005-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2007, 2009-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -13,7 +13,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include "streq.h" diff --git a/contrib/tools/bison/lib/uniwidth/width.c b/contrib/tools/bison/lib/uniwidth/width.c index 173d0872c7..cd27d61b8d 100644 --- a/contrib/tools/bison/lib/uniwidth/width.c +++ b/contrib/tools/bison/lib/uniwidth/width.c @@ -1,5 +1,5 @@ /* Determine display width of Unicode character. - Copyright (C) 2001-2002, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -13,7 +13,7 @@ General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -32,7 +32,7 @@ * - Zero width characters; generated from * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt" */ -static const unsigned char nonspacing_table_data[27*64] = { +static const unsigned char nonspacing_table_data[38*64] = { /* 0x0000-0x01ff */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */ @@ -61,7 +61,7 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */ 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */ /* 0x0600-0x07ff */ - 0x0f, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ + 0x3f, 0x00, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */ 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ @@ -73,7 +73,7 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08c0-0x08ff */ + 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x08c0-0x08ff */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */ 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */ @@ -88,11 +88,11 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */ 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */ /* 0x0c00-0x0dff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */ 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */ 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */ 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */ @@ -133,35 +133,35 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */ 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */ /* 0x1800-0x19ff */ - 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */ + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */ 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */ /* 0x1a00-0x1bff */ - 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ + 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1a80-0x1abf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, /* 0x1a80-0x1abf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */ 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */ - 0x03, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, /* 0x1b80-0x1bbf */ + 0x03, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0x00, 0x00, /* 0x1b80-0x1bbf */ 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */ /* 0x1c00-0x1dff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */ - 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x00, 0x00, /* 0x1cc0-0x1cff */ + 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x10, 0x03, /* 0x1cc0-0x1cff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */ - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, /* 0x1dc0-0x1dff */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, /* 0x1dc0-0x1dff */ /* 0x2000-0x21ff */ 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */ - 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, /* 0x2040-0x207f */ + 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x00, 0x00, /* 0x2040-0x207f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */ @@ -178,7 +178,7 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */ /* 0x3000-0x31ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, /* 0x3000-0x303f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x3000-0x303f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */ @@ -188,8 +188,8 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */ /* 0xa600-0xa7ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x30, /* 0xa640-0xa67f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x3f, /* 0xa640-0xa67f */ + 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */ @@ -199,16 +199,16 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */ - 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */ + 0x30, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */ 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ /* 0xaa00-0xabff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */ - 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaa40-0xaa7f */ + 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0xaa40-0xaa7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaac0-0xaaff */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, /* 0xaac0-0xaaff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */ @@ -223,7 +223,7 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */ /* 0xfe00-0xffff */ - 0xff, 0xff, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, /* 0xfe00-0xfe3f */ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, /* 0xfe00-0xfe3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */ @@ -240,24 +240,96 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */ + /* 0x10200-0x103ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10200-0x1023f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10240-0x1027f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10280-0x102bf */ + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x102c0-0x102ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10300-0x1033f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x10340-0x1037f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10380-0x103bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x103c0-0x103ff */ /* 0x10a00-0x10bff */ 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */ + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */ /* 0x11000-0x111ff */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */ - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11040-0x1107f */ + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x11040-0x1107f */ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11100-0x1113f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11140-0x1117f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11180-0x111bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ + 0x07, 0x00, 0x00, 0x00, 0x80, 0xef, 0x1f, 0x00, /* 0x11100-0x1113f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x11140-0x1117f */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, /* 0x11180-0x111bf */ + 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ + /* 0x11200-0x113ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd3, 0x40, /* 0x11200-0x1123f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11240-0x1127f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11280-0x112bf */ + 0x00, 0x00, 0x00, 0x80, 0xf8, 0x07, 0x00, 0x00, /* 0x112c0-0x112ff */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x11300-0x1133f */ + 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x1f, 0x00, /* 0x11340-0x1137f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11380-0x113bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x113c0-0x113ff */ + /* 0x11400-0x115ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11400-0x1143f */ + 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11440-0x1147f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x85, /* 0x11480-0x114bf */ + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x114c0-0x114ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11500-0x1153f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11540-0x1157f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xb0, /* 0x11580-0x115bf */ + 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, /* 0x115c0-0x115ff */ + /* 0x11600-0x117ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xa7, /* 0x11600-0x1163f */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11640-0x1167f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xbf, 0x00, /* 0x11680-0x116bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x116c0-0x116ff */ + 0x00, 0x00, 0x00, 0xe0, 0xbc, 0x0f, 0x00, 0x00, /* 0x11700-0x1173f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11740-0x1177f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11780-0x117bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x117c0-0x117ff */ + /* 0x11c00-0x11dff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x3f, /* 0x11c00-0x11c3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c40-0x11c7f */ + 0x00, 0x00, 0xfc, 0xff, 0xff, 0xfc, 0x6d, 0x00, /* 0x11c80-0x11cbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11cc0-0x11cff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d00-0x11d3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d40-0x11d7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d80-0x11dbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11dc0-0x11dff */ + /* 0x16a00-0x16bff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a00-0x16a3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a40-0x16a7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a80-0x16abf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, /* 0x16ac0-0x16aff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x16b00-0x16b3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b40-0x16b7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b80-0x16bbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16bc0-0x16bff */ + /* 0x16e00-0x16fff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e00-0x16e3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e40-0x16e7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e80-0x16ebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16ec0-0x16eff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f00-0x16f3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f40-0x16f7f */ + 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f80-0x16fbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16fc0-0x16fff */ + /* 0x1bc00-0x1bdff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc00-0x1bc3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc40-0x1bc7f */ + 0x00, 0x00, 0x00, 0x60, 0x0f, 0x00, 0x00, 0x00, /* 0x1bc80-0x1bcbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bcc0-0x1bcff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd00-0x1bd3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd40-0x1bd7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd80-0x1bdbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bdc0-0x1bdff */ /* 0x1d000-0x1d1ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */ @@ -275,9 +347,36 @@ static const unsigned char nonspacing_table_data[27*64] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1d3c0-0x1d3ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d3c0-0x1d3ff */ + /* 0x1da00-0x1dbff */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, /* 0x1da00-0x1da3f */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x20, 0x00, /* 0x1da40-0x1da7f */ + 0x10, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x00, 0x00, /* 0x1da80-0x1dabf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dac0-0x1daff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db00-0x1db3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db40-0x1db7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db80-0x1dbbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dbc0-0x1dbff */ + /* 0x1e000-0x1e1ff */ + 0x7f, 0xff, 0xff, 0xf9, 0xdb, 0x07, 0x00, 0x00, /* 0x1e000-0x1e03f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e040-0x1e07f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e080-0x1e0bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e0c0-0x1e0ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e100-0x1e13f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e140-0x1e17f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e180-0x1e1bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e1c0-0x1e1ff */ + /* 0x1e800-0x1e9ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e800-0x1e83f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e840-0x1e87f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e880-0x1e8bf */ + 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e8c0-0x1e8ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e900-0x1e93f */ + 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e940-0x1e97f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e980-0x1e9bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1e9c0-0x1e9ff */ }; -static const signed char nonspacing_table_ind[240] = { +static const signed char nonspacing_table_ind[248] = { 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */ 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */ 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */ @@ -294,20 +393,21 @@ static const signed char nonspacing_table_ind[240] = { -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */ -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */ - 22, -1, -1, -1, -1, 23, -1, -1, /* 0x10000-0x10fff */ - 24, -1, -1, -1, -1, -1, -1, -1, /* 0x11000-0x11fff */ + 22, 23, -1, -1, -1, 24, -1, -1, /* 0x10000-0x10fff */ + 25, 26, 27, 28, -1, -1, 29, -1, /* 0x11000-0x11fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x16000-0x16fff */ + -1, -1, -1, -1, -1, 30, -1, 31, /* 0x16000-0x16fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1b000-0x1bfff */ + -1, -1, -1, -1, -1, -1, 32, -1, /* 0x1b000-0x1bfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */ - 25, 26, -1, -1, -1, -1, -1, -1 /* 0x1d000-0x1dfff */ + 33, 34, -1, -1, -1, 35, -1, -1, /* 0x1d000-0x1dfff */ + 36, -1, -1, -1, 37, -1, -1, -1 /* 0x1e000-0x1efff */ }; /* Determine number of column positions required for UC. */ @@ -315,7 +415,7 @@ int uc_width (ucs4_t uc, const char *encoding) { /* Test for non-spacing or control character. */ - if ((uc >> 9) < 240) + if ((uc >> 9) < 248) { int ind = nonspacing_table_ind[uc >> 9]; if (ind >= 0) diff --git a/contrib/tools/bison/lib/unlocked-io.h b/contrib/tools/bison/lib/unlocked-io.h index df3e13911e..e3f0fcfed4 100644 --- a/contrib/tools/bison/lib/unlocked-io.h +++ b/contrib/tools/bison/lib/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001-2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Jim Meyering. */ diff --git a/contrib/tools/bison/lib/vasnprintf.c b/contrib/tools/bison/lib/vasnprintf.c index 184937d6f1..3b441d03b7 100644 --- a/contrib/tools/bison/lib/vasnprintf.c +++ b/contrib/tools/bison/lib/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ /* This file can be parametrized with the following macros: VASNPRINTF The name of the function being defined. @@ -118,6 +118,14 @@ # include "fpucw.h" #endif +#ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +#endif + /* Default parameters. */ #ifndef VASNPRINTF # if WIDE_CHAR_VERSION @@ -156,6 +164,7 @@ # define SNPRINTF snwprintf # else # define SNPRINTF _snwprintf +# define USE_MSVC__SNPRINTF 1 # endif # else /* Unix. */ @@ -181,7 +190,9 @@ /* Here we need to call the native snprintf, not rpl_snprintf. */ # undef snprintf # else + /* MSVC versions < 14 did not have snprintf, only _snprintf. */ # define SNPRINTF _snprintf +# define USE_MSVC__SNPRINTF 1 # endif # else /* Unix. */ @@ -195,7 +206,7 @@ /* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" warnings in this file. Use -Dlint to suppress them. */ -#ifdef lint +#if defined GCC_LINT || defined lint # define IF_LINT(Code) Code #else # define IF_LINT(Code) /* empty */ @@ -208,7 +219,7 @@ #undef remainder #define remainder rem -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION # if (HAVE_STRNLEN && !defined _AIX) # define local_strnlen strnlen # else @@ -224,7 +235,7 @@ local_strnlen (const char *string, size_t maxlen) # endif #endif -#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T +#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T # if HAVE_WCSLEN # define local_wcslen wcslen # else @@ -247,7 +258,7 @@ local_wcslen (const wchar_t *s) # endif #endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION # if HAVE_WCSNLEN # define local_wcsnlen wcsnlen # else @@ -1517,7 +1528,7 @@ is_borderline (const char *digits, size_t precision) #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF /* Use a different function name, to make it possible that the 'wchar_t' parametrization and the 'char' parametrization get compiled in the same @@ -1886,7 +1897,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, else { do - result[length++] = (unsigned char) *cp++; + result[length++] = *cp++; while (--n > 0); } } @@ -1957,15 +1968,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; - width = (unsigned int) (-arg); + width = -width; } - else - width = arg; } else { @@ -2073,8 +2083,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2127,8 +2136,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) + if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2201,8 +2209,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2255,8 +2262,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) + if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2329,8 +2335,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2383,8 +2388,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) + if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2399,7 +2403,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } #endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T else if (dp->conversion == 's' # if WIDE_CHAR_VERSION && a.arg[dp->arg_index].type != TYPE_WIDE_STRING @@ -2435,15 +2439,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; - width = (unsigned int) (-arg); + width = -width; } - else - width = arg; } else { @@ -2573,8 +2576,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2635,8 +2637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) + if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2827,8 +2828,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* w doesn't matter. */ w = 0; - if (has_width && width > w - && !(dp->flags & FLAG_LEFT)) + if (w < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -2911,8 +2911,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += tmpdst_len; # endif - if (has_width && width > w - && (dp->flags & FLAG_LEFT)) + if (w < width && (dp->flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); @@ -2939,17 +2938,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; - int has_width; size_t width; int has_precision; size_t precision; size_t tmp_length; + size_t count; DCHAR_T tmpbuf[700]; DCHAR_T *tmp; DCHAR_T *pad_ptr; DCHAR_T *p; - has_width = 0; width = 0; if (dp->width_start != dp->width_end) { @@ -2960,15 +2958,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; - width = (unsigned int) (-arg); + width = -width; } - else - width = arg; } else { @@ -2978,7 +2975,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } - has_width = 1; } has_precision = 0; @@ -3354,11 +3350,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, abort (); # endif } + /* The generated string now extends from tmp to p, with the zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) + count = p - tmp; + + if (count < width) { - size_t pad = width - (p - tmp); + size_t pad = width - count; DCHAR_T *end = p + pad; if (flags & FLAG_LEFT) @@ -3391,28 +3390,26 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, p = end; } - { - size_t count = p - tmp; + count = p - tmp; - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); - ENSURE_ALLOCATION (n); - } + ENSURE_ALLOCATION (n); + } - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; } #endif #if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL @@ -3446,8 +3443,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, arg_type type = a.arg[dp->arg_index].type; # endif int flags = dp->flags; - int has_width; size_t width; + size_t count; int has_precision; size_t precision; size_t tmp_length; @@ -3456,7 +3453,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, DCHAR_T *pad_ptr; DCHAR_T *p; - has_width = 0; width = 0; if (dp->width_start != dp->width_end) { @@ -3467,15 +3463,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; - width = (unsigned int) (-arg); + width = -width; } - else - width = arg; } else { @@ -3485,7 +3480,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } - has_width = 1; } has_precision = 0; @@ -3925,9 +3919,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, digits without trailing zeroes. */ if (exponent >= 0) { - size_t count = exponent + 1; + size_t ecount = exponent + 1; /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) + for (; ecount > 0; ecount--) *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { @@ -3941,10 +3935,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } else { - size_t count = -exponent - 1; + size_t ecount = -exponent - 1; *p++ = '0'; *p++ = decimal_point_char (); - for (; count > 0; count--) + for (; ecount > 0; ecount--) *p++ = '0'; while (ndigits > nzeroes) { @@ -4249,7 +4243,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, static const wchar_t decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ { '%', '+', '.', '3', 'd', '\0' }; # else { '%', '+', '.', '2', 'd', '\0' }; @@ -4263,7 +4257,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, static const char decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ "%+.3d"; # else "%+.2d"; @@ -4395,9 +4389,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, digits without trailing zeroes. */ if (exponent >= 0) { - size_t count = exponent + 1; - /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) + size_t ecount = exponent + 1; + /* Note: ecount <= precision = ndigits. */ + for (; ecount > 0; ecount--) *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { @@ -4411,10 +4405,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } else { - size_t count = -exponent - 1; + size_t ecount = -exponent - 1; *p++ = '0'; *p++ = decimal_point_char (); - for (; count > 0; count--) + for (; ecount > 0; ecount--) *p++ = '0'; while (ndigits > nzeroes) { @@ -4442,7 +4436,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, static const wchar_t decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ { '%', '+', '.', '3', 'd', '\0' }; # else { '%', '+', '.', '2', 'd', '\0' }; @@ -4456,7 +4450,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, static const char decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ "%+.3d"; # else "%+.2d"; @@ -4514,7 +4508,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, *p++ = '+'; /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ *p++ = '0'; # endif *p++ = '0'; @@ -4542,9 +4536,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* The generated string now extends from tmp to p, with the zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) + count = p - tmp; + + if (count < width) { - size_t pad = width - (p - tmp); + size_t pad = width - count; DCHAR_T *end = p + pad; if (flags & FLAG_LEFT) @@ -4577,39 +4573,39 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, p = end; } - { - size_t count = p - tmp; + count = p - tmp; - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); - ENSURE_ALLOCATION (n); - } + ENSURE_ALLOCATION (n); + } - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; } #endif else { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int has_width; +#endif +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION size_t width; #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION int has_precision; size_t precision; #endif @@ -4635,8 +4631,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, TCHAR_T *tmp; #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 0; +#endif +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION width = 0; if (dp->width_start != dp->width_end) { @@ -4647,15 +4645,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; - width = (unsigned int) (-arg); + width = -width; } - else - width = arg; } else { @@ -4665,11 +4662,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } +#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 1; +#endif } #endif -#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION has_precision = 0; precision = 6; if (dp->precision_start != dp->precision_end) @@ -4805,7 +4804,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { const FCHAR_T *mp = dp->width_start; do - *fbp++ = (unsigned char) *mp++; + *fbp++ = *mp++; while (--n > 0); } } @@ -4826,7 +4825,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { const FCHAR_T *mp = dp->precision_start; do - *fbp++ = (unsigned char) *mp++; + *fbp++ = *mp++; while (--n > 0); } } @@ -4837,16 +4836,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: case TYPE_ULONGLONGINT: -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if defined _WIN32 && ! defined __CYGWIN__ *fbp++ = 'I'; *fbp++ = '6'; *fbp++ = '4'; break; # else *fbp++ = 'l'; - /*FALLTHROUGH*/ # endif #endif + FALLTHROUGH; case TYPE_LONGINT: case TYPE_ULONGINT: #if HAVE_WINT_T @@ -4870,7 +4869,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif *fbp = dp->conversion; #if USE_SNPRINTF -# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) +# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ + && !defined __UCLIBC__) \ + || (defined __APPLE__ && defined __MACH__) \ + || (defined _WIN32 && ! defined __CYGWIN__)) fbp[1] = '%'; fbp[2] = 'n'; fbp[3] = '\0'; @@ -4884,6 +4886,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, in format strings in writable memory may crash the program (if compiled with _FORTIFY_SOURCE=2), so we should avoid it in this situation. */ + /* On Mac OS X 10.3 or newer, we know that snprintf's return + value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 + and gl_SNPRINTF_TRUNCATION_C99 pass. + Therefore we can avoid using %n in this situation. + On Mac OS X 10.13 or newer, the use of %n in format strings + in writable memory by default crashes the program, so we + should avoid it in this situation. */ /* On native Windows systems (such as mingw), we can avoid using %n because: - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, @@ -4896,8 +4905,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, On native Windows systems (such as mingw) where the OS is Windows Vista, the use of %n in format strings by default crashes the program. See - <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and - <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx> + <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and + <https://msdn.microsoft.com/en-us/library/ms175782.aspx> So we should avoid %n in this situation. */ fbp[1] = '\0'; # endif @@ -5139,7 +5148,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Look at the snprintf() return value. */ if (retcount < 0) { -# if !HAVE_SNPRINTF_RETVAL_C99 +# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF /* HP-UX 10.20 snprintf() is doubly deficient: It doesn't understand the '%n' directive, *and* it returns -1 (rather than the length @@ -5153,7 +5162,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, size_t tmp_length = MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, flags, - has_width ? width : 0, + width, has_precision, precision, pad_ourselves); @@ -5191,18 +5200,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* SNPRINTF or sprintf failed. Save and use the errno that it has set, if any. */ int saved_errno = errno; + if (saved_errno == 0) + { + if (dp->conversion == 'c' || dp->conversion == 's') + saved_errno = EILSEQ; + else + saved_errno = EINVAL; + } if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); - errno = - (saved_errno != 0 - ? saved_errno - : (dp->conversion == 'c' || dp->conversion == 's' - ? EILSEQ - : EINVAL)); + + errno = saved_errno; return NULL; } @@ -5391,7 +5403,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, tmpsrc += count; tmpdst += count; for (n = count; n > 0; n--) - *--tmpdst = (unsigned char) *--tmpsrc; + *--tmpdst = *--tmpsrc; } } #endif diff --git a/contrib/tools/bison/lib/vasnprintf.h b/contrib/tools/bison/lib/vasnprintf.h index 7658f505e5..3eaaa7e537 100644 --- a/contrib/tools/bison/lib/vasnprintf.h +++ b/contrib/tools/bison/lib/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ + with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _VASNPRINTF_H #define _VASNPRINTF_H diff --git a/contrib/tools/bison/lib/vbitset.c b/contrib/tools/bison/lib/vbitset.c index e7200cdaa5..69d1b76231 100644 --- a/contrib/tools/bison/lib/vbitset.c +++ b/contrib/tools/bison/lib/vbitset.c @@ -1,6 +1,7 @@ /* Variable array bitsets. - Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -169,7 +170,7 @@ vbitset_list_reverse (src, list, num, next) bitset_bindex rbitno; bitset_bindex count; bitset_windex windex; - unsigned int bitcnt; + unsigned bitcnt; bitset_bindex bitoff; bitset_word *srcp = VBITSET_WORDS (src); bitset_bindex n_bits = BITSET_SIZE_ (src); @@ -329,7 +330,7 @@ static inline void vbitset_unused_clear (dst) bitset dst; { - unsigned int last_bit; + unsigned last_bit; last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS; if (last_bit) @@ -342,7 +343,7 @@ static void vbitset_ones (bitset dst) { bitset_word *dstp = VBITSET_WORDS (dst); - unsigned int bytes; + unsigned bytes; bytes = sizeof (bitset_word) * VBITSET_SIZE (dst); @@ -355,7 +356,7 @@ static void vbitset_zero (bitset dst) { bitset_word *dstp = VBITSET_WORDS (dst); - unsigned int bytes; + unsigned bytes; bytes = sizeof (bitset_word) * VBITSET_SIZE (dst); @@ -366,7 +367,7 @@ vbitset_zero (bitset dst) static bool vbitset_empty_p (bitset dst) { - unsigned int i; + unsigned i; bitset_word *dstp = VBITSET_WORDS (dst); for (i = 0; i < VBITSET_SIZE (dst); i++) @@ -405,7 +406,7 @@ vbitset_copy1 (bitset dst, bitset src) static void vbitset_not (bitset dst, bitset src) { - unsigned int i; + unsigned i; bitset_word *srcp; bitset_word *dstp; bitset_windex ssize; @@ -430,7 +431,7 @@ vbitset_not (bitset dst, bitset src) static bool vbitset_equal_p (bitset dst, bitset src) { - unsigned int i; + unsigned i; bitset_word *srcp = VBITSET_WORDS (src); bitset_word *dstp = VBITSET_WORDS (dst); bitset_windex ssize = VBITSET_SIZE (src); @@ -460,7 +461,7 @@ vbitset_equal_p (bitset dst, bitset src) static bool vbitset_subset_p (bitset dst, bitset src) { - unsigned int i; + unsigned i; bitset_word *srcp = VBITSET_WORDS (src); bitset_word *dstp = VBITSET_WORDS (dst); bitset_windex ssize = VBITSET_SIZE (src); @@ -484,7 +485,7 @@ vbitset_subset_p (bitset dst, bitset src) static bool vbitset_disjoint_p (bitset dst, bitset src) { - unsigned int i; + unsigned i; bitset_word *srcp = VBITSET_WORDS (src); bitset_word *dstp = VBITSET_WORDS (dst); bitset_windex ssize = VBITSET_SIZE (src); @@ -501,7 +502,7 @@ vbitset_disjoint_p (bitset dst, bitset src) static void vbitset_and (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *dstp; @@ -528,7 +529,7 @@ vbitset_and (bitset dst, bitset src1, bitset src2) static bool vbitset_and_cmp (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -581,7 +582,7 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2) static void vbitset_andn (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *dstp; @@ -621,7 +622,7 @@ vbitset_andn (bitset dst, bitset src1, bitset src2) static bool vbitset_andn_cmp (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -686,7 +687,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2) static void vbitset_or (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *dstp; @@ -722,7 +723,7 @@ vbitset_or (bitset dst, bitset src1, bitset src2) static bool vbitset_or_cmp (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -777,7 +778,7 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2) static void vbitset_xor (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *dstp; @@ -813,7 +814,7 @@ vbitset_xor (bitset dst, bitset src1, bitset src2) static bool vbitset_xor_cmp (bitset dst, bitset src1, bitset src2) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -871,7 +872,7 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2) static void vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *src3p; @@ -901,7 +902,7 @@ vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3) static bool vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -938,7 +939,7 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) static void vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *src3p; @@ -968,7 +969,7 @@ vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3) static bool vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; @@ -1005,7 +1006,7 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) static void vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; bitset_word *src1p; bitset_word *src2p; bitset_word *src3p; @@ -1035,7 +1036,7 @@ vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3) static bool vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) { - unsigned int i; + unsigned i; int changed = 0; bitset_word *src1p; bitset_word *src2p; diff --git a/contrib/tools/bison/lib/vbitset.h b/contrib/tools/bison/lib/vbitset.h index b91019bcb1..6f7d7137d3 100644 --- a/contrib/tools/bison/lib/vbitset.h +++ b/contrib/tools/bison/lib/vbitset.h @@ -1,6 +1,7 @@ /* Functions to support vbitsets. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). diff --git a/contrib/tools/bison/lib/verify.h b/contrib/tools/bison/lib/verify.h index d42d0750ee..3b57ddee0a 100644 --- a/contrib/tools/bison/lib/verify.h +++ b/contrib/tools/bison/lib/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ @@ -248,7 +248,37 @@ template <int w> /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ -#define verify(R) _GL_VERIFY (R, "verify (" #R ")") +#ifdef __GNUC__ +# define verify(R) _GL_VERIFY (R, "verify (" #R ")") +#else +/* PGI barfs if R is long. Play it safe. */ +# define verify(R) _GL_VERIFY (R, "verify (...)") +#endif + +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +/* Assume that R always holds. This lets the compiler optimize + accordingly. R should not have side-effects; it may or may not be + evaluated. Behavior is undefined if R is false. */ + +#if (__has_builtin (__builtin_unreachable) \ + || 4 < __GNUC__ + (5 <= __GNUC_MINOR__)) +# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) +#elif 1200 <= _MSC_VER +# define assume(R) __assume (R) +#elif ((defined GCC_LINT || defined lint) \ + && (__has_builtin (__builtin_trap) \ + || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)))) + /* Doing it this way helps various packages when configured with + --enable-gcc-warnings, which compiles with -Dlint. It's nicer + when 'assume' silences warnings even with older GCCs. */ +# define assume(R) ((R) ? (void) 0 : __builtin_trap ()) +#else + /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */ +# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) +#endif /* @assert.h omit end@ */ diff --git a/contrib/tools/bison/lib/w32spawn.h b/contrib/tools/bison/lib/w32spawn.h index 3b5c08afcd..3f675ebc44 100644 --- a/contrib/tools/bison/lib/w32spawn.h +++ b/contrib/tools/bison/lib/w32spawn.h @@ -1,5 +1,5 @@ /* Auxiliary functions for the creation of subprocesses. Native Windows API. - Copyright (C) 2001, 2003-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2018 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify @@ -13,11 +13,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#ifndef __KLIBC__ /* Get declarations of the native Windows API functions. */ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +#endif /* Get _open_osfhandle(). */ #include <io.h> @@ -28,7 +30,11 @@ #include <errno.h> /* Get _get_osfhandle(). */ -#include "msvc-nothrow.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include <io.h> +# endif #include "cloexec.h" #include "xalloc.h" @@ -123,8 +129,13 @@ undup_safer_noinherit (int tempfd, int origfd) - mingw programs that have a global variable 'int _CRT_glob = 0;', - Cygwin programs, when invoked from a Cygwin program. */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037*?" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#ifndef __KLIBC__ +# define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037*?" +# define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#else +# define SHELL_SPECIAL_CHARS "" +# define SHELL_SPACE_CHARS "" +#endif static char ** prepare_spawn (char **argv) { diff --git a/contrib/tools/bison/lib/wait-process.c b/contrib/tools/bison/lib/wait-process.c index 17a2430f91..9e59c08dd8 100644 --- a/contrib/tools/bison/lib/wait-process.c +++ b/contrib/tools/bison/lib/wait-process.c @@ -1,5 +1,5 @@ /* Waiting for a subprocess to finish. - Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -39,14 +39,14 @@ #define SIZEOF(a) (sizeof(a) / sizeof(a[0])) -#if defined _MSC_VER || defined __MINGW32__ +#if defined _WIN32 && ! defined __CYGWIN__ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +# define WIN32_LEAN_AND_MEAN +# include <windows.h> /* The return value of spawnvp() is really a process handle as returned by CreateProcess(). Therefore we can kill it using TerminateProcess. */ -#define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig) +# define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig) #endif diff --git a/contrib/tools/bison/lib/wait-process.h b/contrib/tools/bison/lib/wait-process.h index 6d8f0d2b94..0e73e710de 100644 --- a/contrib/tools/bison/lib/wait-process.h +++ b/contrib/tools/bison/lib/wait-process.h @@ -1,5 +1,5 @@ /* Waiting for a subprocess to finish. - Copyright (C) 2001-2003, 2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _WAIT_PROCESS_H #define _WAIT_PROCESS_H diff --git a/contrib/tools/bison/lib/waitpid.c b/contrib/tools/bison/lib/waitpid.c index d28a70b3ea..b2e346a475 100644 --- a/contrib/tools/bison/lib/waitpid.c +++ b/contrib/tools/bison/lib/waitpid.c @@ -1,5 +1,5 @@ /* Wait for process state change. - Copyright (C) 2001-2003, 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/wcwidth.c b/contrib/tools/bison/lib/wcwidth.c index 253fcaa656..d33b6a9a55 100644 --- a/contrib/tools/bison/lib/wcwidth.c +++ b/contrib/tools/bison/lib/wcwidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a character. - Copyright (C) 2006-2007, 2010-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2010-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -26,17 +26,40 @@ #include "streq.h" #include "uniwidth.h" +/* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise. */ +static inline int +is_locale_utf8 (void) +{ + const char *encoding = locale_charset (); + return STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0); +} + +#if GNULIB_WCHAR_SINGLE +/* When we know that the locale does not change, provide a speedup by + caching the value of is_locale_utf8. */ +static int cached_is_locale_utf8 = -1; +static inline int +is_locale_utf8_cached (void) +{ + if (cached_is_locale_utf8 < 0) + cached_is_locale_utf8 = is_locale_utf8 (); + return cached_is_locale_utf8; +} +#else +/* By default, don't make assumptions, hence no caching. */ +# define is_locale_utf8_cached is_locale_utf8 +#endif + int wcwidth (wchar_t wc) #undef wcwidth { /* In UTF-8 locales, use a Unicode aware width function. */ - const char *encoding = locale_charset (); - if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0)) + if (is_locale_utf8_cached ()) { /* We assume that in a UTF-8 locale, a wide character is the same as a Unicode character. */ - return uc_width (wc, encoding); + return uc_width (wc, "UTF-8"); } else { diff --git a/contrib/tools/bison/lib/xalloc-die.c b/contrib/tools/bison/lib/xalloc-die.c index daa403b9c8..bfe610990e 100644 --- a/contrib/tools/bison/lib/xalloc-die.c +++ b/contrib/tools/bison/lib/xalloc-die.c @@ -1,6 +1,6 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2013 Free Software + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/xalloc-oversized.h b/contrib/tools/bison/lib/xalloc-oversized.h index a971c78ad3..3426e10f4d 100644 --- a/contrib/tools/bison/lib/xalloc-oversized.h +++ b/contrib/tools/bison/lib/xalloc-oversized.h @@ -1,6 +1,6 @@ /* xalloc-oversized.h -- memory allocation size checking - Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,26 +13,48 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef XALLOC_OVERSIZED_H_ -# define XALLOC_OVERSIZED_H_ +#define XALLOC_OVERSIZED_H_ -# include <stddef.h> - -/* Return 1 if an array of N objects, each of size S, cannot exist due - to size arithmetic overflow. S must be positive and N must be - nonnegative. This is a macro, not a function, so that it - works correctly even when SIZE_MAX < N. +#include <stddef.h> +#include <stdint.h> +/* True if N * S would overflow in a size_t calculation, + or would generate a value larger than PTRDIFF_MAX. + This expands to a constant expression if N and S are both constants. By gnulib convention, SIZE_MAX represents overflow in size - calculations, so the conservative dividend to use here is - SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. - However, malloc (SIZE_MAX) fails on all known hosts where - sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for - exactly-SIZE_MAX allocations on such hosts; this avoids a test and - branch when S is known to be 1. */ + calculations, so the conservative size_t-based dividend to use here + is SIZE_MAX - 1. */ +#define __xalloc_oversized(n, s) \ + ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n)) + +#if PTRDIFF_MAX < SIZE_MAX +typedef ptrdiff_t __xalloc_count_type; +#else +typedef size_t __xalloc_count_type; +#endif + +/* Return 1 if an array of N objects, each of size S, cannot exist + reliably due to size or ptrdiff_t arithmetic overflow. S must be + positive and N must be nonnegative. This is a macro, not a + function, so that it works correctly even when SIZE_MAX < N. */ + +#if 7 <= __GNUC__ +# define xalloc_oversized(n, s) \ + __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1) +#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ # define xalloc_oversized(n, s) \ - ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) + (__builtin_constant_p (n) && __builtin_constant_p (s) \ + ? __xalloc_oversized (n, s) \ + : ({ __xalloc_count_type __xalloc_count; \ + __builtin_mul_overflow (n, s, &__xalloc_count); })) + +/* Other compilers use integer division; this may be slower but is + more portable. */ +#else +# define xalloc_oversized(n, s) __xalloc_oversized (n, s) +#endif #endif /* !XALLOC_OVERSIZED_H_ */ diff --git a/contrib/tools/bison/lib/xalloc.h b/contrib/tools/bison/lib/xalloc.h index da7c4b6bb3..c419a2de6c 100644 --- a/contrib/tools/bison/lib/xalloc.h +++ b/contrib/tools/bison/lib/xalloc.h @@ -1,6 +1,6 @@ /* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,15 +13,19 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef XALLOC_H_ #define XALLOC_H_ #include <stddef.h> +#include <stdint.h> #include "xalloc-oversized.h" +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif _GL_INLINE_HEADER_BEGIN #ifndef XALLOC_INLINE # define XALLOC_INLINE _GL_INLINE @@ -32,13 +36,8 @@ extern "C" { #endif -#if __GNUC__ >= 3 -# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -#else -# define _GL_ATTRIBUTE_MALLOC -#endif - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if ! defined __clang__ && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) #else # define _GL_ATTRIBUTE_ALLOC_SIZE(args) @@ -61,7 +60,7 @@ void *xrealloc (void *p, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2)); void *x2realloc (void *p, size_t *pn); void *xmemdup (void const *p, size_t s) - _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2)); + _GL_ATTRIBUTE_ALLOC_SIZE ((2)); char *xstrdup (char const *str) _GL_ATTRIBUTE_MALLOC; @@ -119,10 +118,9 @@ xnrealloc (void *p, size_t n, size_t s) /* If P is null, allocate a block of at least *PN such objects; otherwise, reallocate P so that it contains more than *PN objects - each of S bytes. *PN must be nonzero unless P is null, and S must - be nonzero. Set *PN to the new number of objects, and return the - pointer to the new block. *PN is never set to zero, and the - returned pointer is never null. + each of S bytes. S must be nonzero. Set *PN to the new number of + objects, and return the pointer to the new block. *PN is never set + to zero, and the returned pointer is never null. Repeated reallocations are guaranteed to make progress, either by allocating an initial block with a nonzero size, or by allocating a @@ -190,16 +188,19 @@ x2nrealloc (void *p, size_t *pn, size_t s) n = DEFAULT_MXFAST / s; n += !n; } + if (xalloc_oversized (n, s)) + xalloc_die (); } else { - /* Set N = ceil (1.5 * N) so that progress is made if N == 1. - Check for overflow, so that N * S stays in size_t range. - The check is slightly conservative, but an exact check isn't - worth the trouble. */ - if ((size_t) -1 / 3 * 2 / s <= n) + /* Set N = floor (1.5 * N) + 1 so that progress is made even if N == 0. + Check for overflow, so that N * S stays in both ptrdiff_t and + size_t range. The check may be slightly conservative, but an + exact check isn't worth the trouble. */ + if ((PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX) / 3 * 2 / s + <= n) xalloc_die (); - n += (n + 1) / 2; + n += n / 2 + 1; } *pn = n; @@ -256,5 +257,6 @@ xmemdup (T const *p, size_t s) #endif +_GL_INLINE_HEADER_END #endif /* !XALLOC_H_ */ diff --git a/contrib/tools/bison/lib/xconcat-filename.c b/contrib/tools/bison/lib/xconcat-filename.c index eb2f8a9fb1..d44ca7d5ea 100644 --- a/contrib/tools/bison/lib/xconcat-filename.c +++ b/contrib/tools/bison/lib/xconcat-filename.c @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -12,7 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <haible@clisp.cons.org>. */ diff --git a/contrib/tools/bison/lib/xmalloc.c b/contrib/tools/bison/lib/xmalloc.c index 57e34b7cdb..9a30d67b9f 100644 --- a/contrib/tools/bison/lib/xmalloc.c +++ b/contrib/tools/bison/lib/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> @@ -93,11 +93,11 @@ void * xcalloc (size_t n, size_t s) { void *p; - /* Test for overflow, since some calloc implementations don't have - proper overflow checks. But omit overflow and size-zero tests if - HAVE_GNU_CALLOC, since GNU calloc catches overflow and never - returns NULL if successful. */ - if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s)) + /* Test for overflow, since objects with size greater than + PTRDIFF_MAX cause pointer subtraction to go awry. Omit size-zero + tests if HAVE_GNU_CALLOC, since GNU calloc never returns NULL if + successful. */ + if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0))) xalloc_die (); return p; diff --git a/contrib/tools/bison/lib/xmemdup0.c b/contrib/tools/bison/lib/xmemdup0.c index c070fa6343..1b53d11757 100644 --- a/contrib/tools/bison/lib/xmemdup0.c +++ b/contrib/tools/bison/lib/xmemdup0.c @@ -1,6 +1,6 @@ /* xmemdup0.c -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/xmemdup0.h b/contrib/tools/bison/lib/xmemdup0.h index 9ec827107a..d1820288d6 100644 --- a/contrib/tools/bison/lib/xmemdup0.h +++ b/contrib/tools/bison/lib/xmemdup0.h @@ -1,6 +1,6 @@ /* xmemdup0.h -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2008-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef XMEMDUP_H_ # define XMEMDUP_H_ diff --git a/contrib/tools/bison/lib/xsize.h b/contrib/tools/bison/lib/xsize.h index 2922f35305..8aeb3b7a68 100644 --- a/contrib/tools/bison/lib/xsize.h +++ b/contrib/tools/bison/lib/xsize.h @@ -1,6 +1,6 @@ /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2003, 2008-2018 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _XSIZE_H #define _XSIZE_H @@ -27,6 +27,9 @@ # include <stdint.h> #endif +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif _GL_INLINE_HEADER_BEGIN #ifndef XSIZE_INLINE # define XSIZE_INLINE _GL_INLINE diff --git a/contrib/tools/bison/lib/xstrndup.c b/contrib/tools/bison/lib/xstrndup.c index eae92d039d..3b1700a627 100644 --- a/contrib/tools/bison/lib/xstrndup.c +++ b/contrib/tools/bison/lib/xstrndup.c @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/contrib/tools/bison/lib/xstrndup.h b/contrib/tools/bison/lib/xstrndup.h index 59673b0489..54b0967f15 100644 --- a/contrib/tools/bison/lib/xstrndup.h +++ b/contrib/tools/bison/lib/xstrndup.h @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,11 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <stddef.h> /* Return a newly allocated copy of at most N bytes of STRING. In other words, return a copy of the initial segment of length N of STRING. */ -extern char *xstrndup (const char *string, size_t n); +extern char *xstrndup (const char *string, size_t n) _GL_ATTRIBUTE_MALLOC; diff --git a/contrib/tools/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make index 34dcfae080..2bb7d5a261 100644 --- a/contrib/tools/bison/lib/ya.make +++ b/contrib/tools/bison/lib/ya.make @@ -47,15 +47,16 @@ SRCS( fopen-safer.c fseterr.c get-errno.c + getprogname.c glthread/lock.c glthread/threadlib.c + hard-locale.c hash.c - isnand.c - isnanf.c - isnanl.c lbitset.c localcharset.c + malloca.c math.c + mbrtowc.c mbswidth.c pipe-safer.c pipe2-safer.c @@ -68,6 +69,7 @@ SRCS( quotearg.c sig-handler.c spawn-pipe.c + stat-time.c stripslash.c timevar.c unistd.c diff --git a/contrib/tools/bison/src/AnnotationList.c b/contrib/tools/bison/src/AnnotationList.c index b14c675b8f..a78deb8ac9 100644 --- a/contrib/tools/bison/src/AnnotationList.c +++ b/contrib/tools/bison/src/AnnotationList.c @@ -1,6 +1,6 @@ /* IELR's inadequacy annotation list. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -242,7 +242,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s, { symbol_number contribution_token = InadequacyList__getContributionToken (self->inadequacyNode, ci) - ->number; + ->content->number; if (AnnotationList__isContributionAlways (self, ci)) { annotation_node->contributions[ci] = NULL; @@ -275,7 +275,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s, - 2])) { Sbitset items; - unsigned int rulei; + unsigned rulei; for (rulei = s->items[self_item]; !item_number_is_rule_number (ritem[rulei]); ++rulei) @@ -541,15 +541,19 @@ AnnotationList__compute_from_inadequacies ( { InadequacyList__prependTo (conflict_node, &inadequacy_lists[s->number]); - aver (AnnotationList__insertInto ( - annotation_node, &annotation_lists[s->number], - s->nitems)); + { + bool b = + AnnotationList__insertInto (annotation_node, + &annotation_lists[s->number], + s->nitems); + aver (b); (void) b; + } /* This aver makes sure the AnnotationList__computeDominantContribution check above does discard annotations in the simplest case of a S/R conflict with no token precedence. */ aver (!bitset_test (shift_tokens, conflicted_token) - || symbols[conflicted_token]->prec); + || symbols[conflicted_token]->content->prec); ++annotation_counts[s->number]; if (contribution_count > *max_contributionsp) *max_contributionsp = contribution_count; @@ -595,7 +599,7 @@ AnnotationList__debug (AnnotationList const *self, size_t nitems, int spaces) { symbol_number token = InadequacyList__getContributionToken (a->inadequacyNode, ci) - ->number; + ->content->number; { int j; for (j = 0; j < spaces+2; ++j) @@ -644,7 +648,7 @@ AnnotationList__computeLookaheadFilter (AnnotationList const *self, Sbitset biter; symbol_number token = InadequacyList__getContributionToken (self->inadequacyNode, ci) - ->number; + ->content->number; SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item) bitset_set (lookahead_filter[item], token); } @@ -679,7 +683,8 @@ AnnotationList__stateMakesContribution (AnnotationList const *self, return false; { symbol_number token = - InadequacyList__getContributionToken (self->inadequacyNode, ci)->number; + InadequacyList__getContributionToken (self->inadequacyNode, ci) + ->content->number; Sbitset__Index item; Sbitset biter; SBITSET__FOR_EACH (self->contributions[ci], nitems, biter, item) @@ -709,7 +714,7 @@ AnnotationList__computeDominantContribution (AnnotationList const *self, ContributionIndex ci; int actioni; ContributionIndex ci_rr_dominator = ContributionIndex__none; - int shift_precedence = token->prec; + int shift_precedence = token->content->prec; /* If the token has no precedence set, shift is always chosen. */ if (!shift_precedence) @@ -739,7 +744,7 @@ AnnotationList__computeDominantContribution (AnnotationList const *self, if (reduce_precedence && (reduce_precedence < shift_precedence || (reduce_precedence == shift_precedence - && token->assoc == right_assoc))) + && token->content->assoc == right_assoc))) continue; if (!AnnotationList__stateMakesContribution (self, nitems, ci, lookaheads)) @@ -747,7 +752,7 @@ AnnotationList__computeDominantContribution (AnnotationList const *self, /* This uneliminated reduction contributes, so see if it can cause an error action. */ if (reduce_precedence == shift_precedence - && token->assoc == non_assoc) + && token->content->assoc == non_assoc) { /* It's not possible to find split-stable domination over shift after a potential %nonassoc. */ diff --git a/contrib/tools/bison/src/AnnotationList.h b/contrib/tools/bison/src/AnnotationList.h index 5abaa2e79b..f770f6f0aa 100644 --- a/contrib/tools/bison/src/AnnotationList.h +++ b/contrib/tools/bison/src/AnnotationList.h @@ -1,6 +1,6 @@ /* IELR's inadequacy annotation list. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -25,7 +25,7 @@ # include "InadequacyList.h" # include "state.h" -typedef unsigned int AnnotationIndex; +typedef unsigned AnnotationIndex; /** * A node in a list of annotations on a particular LR(0) state. Each diff --git a/contrib/tools/bison/src/InadequacyList.c b/contrib/tools/bison/src/InadequacyList.c index 9510b40d91..4d36533f93 100644 --- a/contrib/tools/bison/src/InadequacyList.c +++ b/contrib/tools/bison/src/InadequacyList.c @@ -1,6 +1,6 @@ /* IELR's inadequacy list. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -66,7 +66,7 @@ symbol * InadequacyList__getContributionToken (InadequacyList const *self, ContributionIndex i) { - aver (0 <= i && i < self->contributionCount); + aver (0 <= i && i < self->contributionCount); (void) i; return self->inadequacy.conflict.token; } diff --git a/contrib/tools/bison/src/InadequacyList.h b/contrib/tools/bison/src/InadequacyList.h index d293b9b6c6..a05b99da84 100644 --- a/contrib/tools/bison/src/InadequacyList.h +++ b/contrib/tools/bison/src/InadequacyList.h @@ -1,6 +1,6 @@ /* IELR's inadequacy list. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -31,7 +31,7 @@ * This must remain unsigned so that the overflow check in * \c InadequacyList__new_conflict works properly. */ -typedef unsigned long long int InadequacyListNodeCount; +typedef unsigned long long InadequacyListNodeCount; /** * For a conflict, each rule in the grammar can have at most one contributing diff --git a/contrib/tools/bison/src/LR0.c b/contrib/tools/bison/src/LR0.c index f6a9537e4c..35eaf563ee 100644 --- a/contrib/tools/bison/src/LR0.c +++ b/contrib/tools/bison/src/LR0.c @@ -1,7 +1,7 @@ /* Generate the LR(0) parser states for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/LR0.h b/contrib/tools/bison/src/LR0.h index 976bcb26ee..f7f6b63af9 100644 --- a/contrib/tools/bison/src/LR0.h +++ b/contrib/tools/bison/src/LR0.h @@ -1,7 +1,7 @@ /* Generate the LR(0) parser states for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2002, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2000-2002, 2009-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/Sbitset.c b/contrib/tools/bison/src/Sbitset.c index bb278b55db..b6ba379de6 100644 --- a/contrib/tools/bison/src/Sbitset.c +++ b/contrib/tools/bison/src/Sbitset.c @@ -1,6 +1,6 @@ /* A simple, memory-efficient bitset implementation. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/Sbitset.h b/contrib/tools/bison/src/Sbitset.h index bcb329ad39..82acdc5204 100644 --- a/contrib/tools/bison/src/Sbitset.h +++ b/contrib/tools/bison/src/Sbitset.h @@ -1,6 +1,6 @@ /* A simple, memory-efficient bitset implementation. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/assoc.c b/contrib/tools/bison/src/assoc.c index d2eec31574..38d24e3498 100644 --- a/contrib/tools/bison/src/assoc.c +++ b/contrib/tools/bison/src/assoc.c @@ -1,7 +1,7 @@ /* Associativity information. - Copyright (C) 2002, 2005-2006, 2008-2013 Free Software Foundation, - Inc. + Copyright (C) 2002, 2005-2006, 2008-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/assoc.h b/contrib/tools/bison/src/assoc.h index b9475b5d12..661e1e541c 100644 --- a/contrib/tools/bison/src/assoc.h +++ b/contrib/tools/bison/src/assoc.h @@ -1,6 +1,7 @@ /* Associativity information. - Copyright (C) 2002, 2006, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2008-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/closure.c b/contrib/tools/bison/src/closure.c index 45e8311022..6729d702ec 100644 --- a/contrib/tools/bison/src/closure.c +++ b/contrib/tools/bison/src/closure.c @@ -1,7 +1,7 @@ /* Closures for Bison - Copyright (C) 1984, 1989, 2000-2002, 2004-2005, 2007, 2009-2013 Free - Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2004-2005, 2007, 2009-2015, 2018 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -54,12 +54,11 @@ static bitsetv firsts = NULL; static void print_closure (char const *title, item_number const *array, size_t size) { - size_t i; fprintf (stderr, "Closure: %s\n", title); - for (i = 0; i < size; ++i) + for (size_t i = 0; i < size; ++i) { - item_number *rp; fprintf (stderr, " %2d: .", array[i]); + item_number *rp; for (rp = &ritem[array[i]]; *rp >= 0; ++rp) fprintf (stderr, " %s", symbols[*rp]->tag); fprintf (stderr, " (rule %d)\n", -*rp - 1); @@ -71,13 +70,12 @@ print_closure (char const *title, item_number const *array, size_t size) static void print_firsts (void) { - symbol_number i, j; - fprintf (stderr, "FIRSTS\n"); - for (i = ntokens; i < nsyms; i++) + for (symbol_number i = ntokens; i < nsyms; ++i) { - bitset_iterator iter; fprintf (stderr, " %s firsts\n", symbols[i]->tag); + bitset_iterator iter; + symbol_number j; BITSET_FOR_EACH (iter, FIRSTS (i), j, 0) fprintf (stderr, " %s\n", symbols[j + ntokens]->tag); } @@ -88,14 +86,12 @@ print_firsts (void) static void print_fderives (void) { - int i; - rule_number r; - fprintf (stderr, "FDERIVES\n"); - for (i = ntokens; i < nsyms; i++) + for (symbol_number i = ntokens; i < nsyms; ++i) { - bitset_iterator iter; fprintf (stderr, " %s derives\n", symbols[i]->tag); + bitset_iterator iter; + rule_number r; BITSET_FOR_EACH (iter, FDERIVES (i), r, 0) { fprintf (stderr, " %3d ", r); @@ -120,12 +116,10 @@ print_fderives (void) static void set_firsts (void) { - symbol_number i, j; - firsts = bitsetv_create (nvars, nvars, BITSET_FIXED); - for (i = ntokens; i < nsyms; i++) - for (j = 0; derives[i - ntokens][j]; ++j) + for (symbol_number i = ntokens; i < nsyms; ++i) + for (symbol_number j = 0; derives[i - ntokens][j]; ++j) { item_number sym = derives[i - ntokens][j]->rhs[0]; if (ISVAR (sym)) @@ -155,17 +149,14 @@ set_firsts (void) static void set_fderives (void) { - symbol_number i, j; - rule_number k; - fderives = bitsetv_create (nvars, nrules, BITSET_FIXED); set_firsts (); - for (i = ntokens; i < nsyms; ++i) - for (j = ntokens; j < nsyms; ++j) + for (symbol_number i = ntokens; i < nsyms; ++i) + for (symbol_number j = ntokens; j < nsyms; ++j) if (bitset_test (FIRSTS (i), j - ntokens)) - for (k = 0; derives[j - ntokens][k]; ++k) + for (rule_number k = 0; derives[j - ntokens][k]; ++k) bitset_set (FDERIVES (i), derives[j - ntokens][k]->number); if (trace_flag & trace_sets) @@ -177,7 +168,7 @@ set_fderives (void) void -new_closure (unsigned int n) +new_closure (unsigned n) { itemset = xnmalloc (n, sizeof *itemset); @@ -191,27 +182,23 @@ new_closure (unsigned int n) void closure (item_number const *core, size_t n) { - /* Index over CORE. */ - size_t c; - - /* A bit index over RULESET. */ - rule_number ruleno; - - bitset_iterator iter; - if (trace_flag & trace_sets) print_closure ("input", core, n); bitset_zero (ruleset); - for (c = 0; c < n; ++c) + for (size_t c = 0; c < n; ++c) if (ISVAR (ritem[core[c]])) bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]])); /* core is sorted on item index in ritem, which is sorted on rule number. Compute itemset with the same sort. */ + /* A bit index over RULESET. */ + rule_number ruleno; + bitset_iterator iter; + nitemset = 0; - c = 0; + size_t c = 0; BITSET_FOR_EACH (iter, ruleset, ruleno, 0) { item_number itemno = rules[ruleno].rhs - ritem; diff --git a/contrib/tools/bison/src/closure.h b/contrib/tools/bison/src/closure.h index ad4a3ba96b..1d728984fd 100644 --- a/contrib/tools/bison/src/closure.h +++ b/contrib/tools/bison/src/closure.h @@ -1,7 +1,7 @@ /* Subroutines for bison - Copyright (C) 1984, 1989, 2000-2002, 2007, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2007, 2009-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -27,7 +27,7 @@ data so that closure can be called. n is the number of elements to allocate for itemset. */ -void new_closure (unsigned int n); +void new_closure (unsigned n); /* Given the kernel (aka core) of a state (a sorted vector of item numbers diff --git a/contrib/tools/bison/src/complain.c b/contrib/tools/bison/src/complain.c index fdc4b5426b..e39626a3f3 100644 --- a/contrib/tools/bison/src/complain.c +++ b/contrib/tools/bison/src/complain.c @@ -1,6 +1,6 @@ /* Declaration for error-reporting function for Bison. - Copyright (C) 2000-2002, 2004-2006, 2009-2013 Free Software + Copyright (C) 2000-2002, 2004-2006, 2009-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -35,14 +35,25 @@ err_status complaint_status = status_none; bool warnings_are_errors = false; +/** Whether -Werror/-Wno-error was applied to a warning. */ +typedef enum + { + errority_unset = 0, /** No explict status. */ + errority_disabled = 1, /** Explictly disabled with -Wno-error=foo. */ + errority_enabled = 2 /** Explictly enabled with -Werror=foo. */ + } errority; + +/** For each warning type, its errority. */ +static errority errority_flag[warnings_size]; + /** Diagnostics severity. */ typedef enum { - severity_disabled = 0, - severity_unset = 1, - severity_warning = 2, - severity_error = 3, - severity_fatal = 4 + severity_disabled = 0, /**< Explicitly disabled via -Wno-foo. */ + severity_unset = 1, /**< Unspecified status. */ + severity_warning = 2, /**< A warning. */ + severity_error = 3, /**< An error (continue, but die soon). */ + severity_fatal = 4 /**< Fatal error (die now). */ } severity; @@ -103,32 +114,26 @@ warning_argmatch (char const *arg, size_t no, size_t err) no = !no; } - if (no) - { - size_t b; - for (b = 0; b < warnings_size; ++b) - if (value & 1 << b) + size_t b; + for (b = 0; b < warnings_size; ++b) + if (value & 1 << b) + { + if (err && no) + /* -Wno-error=foo. */ + errority_flag[b] = errority_disabled; + else if (err && !no) { - if (err) - { - /* -Wno-error=foo: if foo enabled as an error, - make it a warning. */ - if (warnings_flag[b] == severity_error) - warnings_flag[b] = severity_warning; - } - else - /* -Wno-foo. */ - warnings_flag[b] = severity_disabled; + /* -Werror=foo: enables -Wfoo. */ + errority_flag[b] = errority_enabled; + warnings_flag[b] = severity_warning; } - } - else - { - size_t b; - for (b = 0; b < warnings_size; ++b) - if (value & 1 << b) - /* -Wfoo and -Werror=foo. */ - warnings_flag[b] = err ? severity_error : severity_warning; - } + else if (no) + /* -Wno-foo. */ + warnings_flag[b] = severity_disabled; + else + /* -Wfoo. */ + warnings_flag[b] = severity_warning; + } } /** Decode a comma-separated list of arguments from -W. @@ -145,13 +150,13 @@ warnings_argmatch (char *args) if (STREQ (args, "error")) warnings_are_errors = true; else if (STREQ (args, "no-error")) - { - warnings_are_errors = false; - warning_argmatch ("no-error=everything", 3, 6); - } + warnings_are_errors = false; else { + /* The length of the possible 'no-' prefix: 3, or 0. */ size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0; + /* The length of the possible 'error=' (possibly after + 'no-') prefix: 6, or 0. */ size_t err = STRPREFIX_LIT ("error=", args + no) ? 6 : 0; warning_argmatch (args, no, err); @@ -173,27 +178,46 @@ complain_init (void) size_t b; for (b = 0; b < warnings_size; ++b) - warnings_flag[b] = (1 << b & warnings_default - ? severity_warning - : severity_unset); + { + warnings_flag[b] = (1 << b & warnings_default + ? severity_warning + : severity_unset); + errority_flag[b] = errority_unset; + } } + +/* A diagnostic with FLAGS is about to be issued. With what severity? + (severity_fatal, severity_error, severity_disabled, or + severity_warning.) */ + static severity warning_severity (warnings flags) { if (flags & fatal) + /* Diagnostics about fatal errors. */ return severity_fatal; else if (flags & complaint) + /* Diagnostics about errors. */ return severity_error; else { + /* Diagnostics about warnings. */ severity res = severity_disabled; size_t b; for (b = 0; b < warnings_size; ++b) if (flags & 1 << b) - res = res < warnings_flag[b] ? warnings_flag[b] : res; - if (res == severity_warning && warnings_are_errors) - res = severity_error; + { + res = res < warnings_flag[b] ? warnings_flag[b] : res; + /* If the diagnostic is enabled, and -Werror is enabled, + and -Wno-error=foo was not explicitly requested, this + is an error. */ + if (res == severity_warning + && (errority_flag[b] == errority_enabled + || (warnings_are_errors + && errority_flag[b] != errority_disabled))) + res = severity_error; + } return res; } } diff --git a/contrib/tools/bison/src/complain.h b/contrib/tools/bison/src/complain.h index 0d81503df7..599afb97c7 100644 --- a/contrib/tools/bison/src/complain.h +++ b/contrib/tools/bison/src/complain.h @@ -1,7 +1,7 @@ /* Declaration for error-reporting function for Bison. - Copyright (C) 2000-2002, 2006, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2000-2002, 2006, 2009-2015, 2018 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,14 +128,14 @@ void deprecated_directive (location const *loc, void duplicate_directive (char const *directive, location first, location second); -/** Warnings treated as errors shouldn't stop the execution as regular errors - should (because due to their nature, it is safe to go on). Thus, there are - three possible execution statuses. */ +/** Warnings treated as errors shouldn't stop the execution as regular + errors should (because due to their nature, it is safe to go + on). Thus, there are three possible execution statuses. */ typedef enum { - status_none, - status_warning_as_error, - status_complaint + status_none, /**< No diagnostic issued so far. */ + status_warning_as_error, /**< A warning was issued (but no error). */ + status_complaint /**< An error was issued. */ } err_status; /** Whether an error was reported. */ diff --git a/contrib/tools/bison/src/conflicts.c b/contrib/tools/bison/src/conflicts.c index 1840473620..6a6f88d90f 100644 --- a/contrib/tools/bison/src/conflicts.c +++ b/contrib/tools/bison/src/conflicts.c @@ -1,7 +1,7 @@ /* Find and resolve or report lookahead conflicts for bison, - Copyright (C) 1984, 1989, 1992, 2000-2013 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989, 1992, 2000-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -104,7 +104,7 @@ log_resolution (rule *r, symbol_number token, case shift_resolution: obstack_printf (&solved_conflicts_obstack, " (%s < %s)", - r->prec->tag, + r->prec->symbol->tag, symbols[token]->tag); break; @@ -112,7 +112,7 @@ log_resolution (rule *r, symbol_number token, obstack_printf (&solved_conflicts_obstack, " (%s < %s)", symbols[token]->tag, - r->prec->tag); + r->prec->symbol->tag); break; case left_resolution: @@ -176,7 +176,7 @@ log_resolution (rule *r, symbol_number token, case shift_resolution: obstack_printf (&solved_conflicts_xml_obstack, "%s < %s", - xml_escape_n (0, r->prec->tag), + xml_escape_n (0, r->prec->symbol->tag), xml_escape_n (1, symbols[token]->tag)); break; @@ -184,7 +184,7 @@ log_resolution (rule *r, symbol_number token, obstack_printf (&solved_conflicts_xml_obstack, "%s < %s", xml_escape_n (0, symbols[token]->tag), - xml_escape_n (1, r->prec->tag)); + xml_escape_n (1, r->prec->symbol->tag)); break; case left_resolution: @@ -221,10 +221,9 @@ static void flush_shift (state *s, int token) { transitions *trans = s->transitions; - int i; bitset_reset (lookahead_set, token); - for (i = 0; i < trans->num; i++) + for (int i = 0; i < trans->num; ++i) if (!TRANSITION_IS_DISABLED (trans, i) && TRANSITION_SYMBOL (trans, i) == token) TRANSITION_DISABLE (trans, i); @@ -259,28 +258,27 @@ flush_reduce (bitset lookahead_tokens, int token) static void resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs) { - symbol_number i; reductions *reds = s->reductions; /* Find the rule to reduce by to get precedence of reduction. */ rule *redrule = reds->rules[ruleno]; int redprec = redrule->prec->prec; bitset lookahead_tokens = reds->lookahead_tokens[ruleno]; - for (i = 0; i < ntokens; i++) + for (symbol_number i = 0; i < ntokens; ++i) if (bitset_test (lookahead_tokens, i) && bitset_test (lookahead_set, i) - && symbols[i]->prec) + && symbols[i]->content->prec) { /* Shift-reduce conflict occurs for token number i and it has a precedence. The precedence of shifting is that of token i. */ - if (symbols[i]->prec < redprec) + if (symbols[i]->content->prec < redprec) { register_precedence (redrule->prec->number, i); log_resolution (redrule, i, reduce_resolution); flush_shift (s, i); } - else if (symbols[i]->prec > redprec) + else if (symbols[i]->content->prec > redprec) { register_precedence (i, redrule->prec->number); log_resolution (redrule, i, shift_resolution); @@ -294,7 +292,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs) For right associativity, keep only the shift. For nonassociativity, keep neither. */ - switch (symbols[i]->assoc) + switch (symbols[i]->content->assoc) { case undef_assoc: abort (); @@ -337,33 +335,34 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs) static void set_conflicts (state *s, symbol **errors) { - int i; - transitions *trans = s->transitions; - reductions *reds = s->reductions; - int nerrs = 0; - if (s->consistent) return; + reductions *reds = s->reductions; + int nerrs = 0; + bitset_zero (lookahead_set); - FOR_EACH_SHIFT (trans, i) - bitset_set (lookahead_set, TRANSITION_SYMBOL (trans, i)); + { + transitions *trans = s->transitions; + int i; + FOR_EACH_SHIFT (trans, i) + bitset_set (lookahead_set, TRANSITION_SYMBOL (trans, i)); + } /* Loop over all rules which require lookahead in this state. First check for shift-reduce conflict, and try to resolve using precedence. */ - for (i = 0; i < reds->num; ++i) + for (int i = 0; i < reds->num; ++i) if (reds->rules[i]->prec && reds->rules[i]->prec->prec && !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set)) resolve_sr_conflict (s, i, errors, &nerrs); if (nerrs) - { - /* Some tokens have been explicitly made errors. Allocate a - permanent errs structure for this state, to record them. */ - state_errs_set (s, nerrs, errors); - } + /* Some tokens have been explicitly made errors. Allocate a + permanent errs structure for this state, to record them. */ + state_errs_set (s, nerrs, errors); + if (obstack_object_size (&solved_conflicts_obstack)) s->solved_conflicts = obstack_finish0 (&solved_conflicts_obstack); if (obstack_object_size (&solved_conflicts_xml_obstack)) @@ -371,7 +370,7 @@ set_conflicts (state *s, symbol **errors) /* Loop over all rules which require lookahead in this state. Check for conflicts not resolved above. */ - for (i = 0; i < reds->num; ++i) + for (int i = 0; i < reds->num; ++i) { if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set)) conflicts[s->number] = 1; @@ -388,7 +387,6 @@ set_conflicts (state *s, symbol **errors) void conflicts_solve (void) { - state_number i; /* List of lookahead tokens on which we explicitly raise a syntax error. */ symbol **errors = xnmalloc (ntokens + 1, sizeof *errors); @@ -398,7 +396,7 @@ conflicts_solve (void) obstack_init (&solved_conflicts_obstack); obstack_init (&solved_conflicts_xml_obstack); - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) { set_conflicts (states[i], errors); @@ -416,8 +414,7 @@ void conflicts_update_state_numbers (state_number old_to_new[], state_number nstates_old) { - state_number i; - for (i = 0; i < nstates_old; ++i) + for (state_number i = 0; i < nstates_old; ++i) if (old_to_new[i] != nstates_old) conflicts[old_to_new[i]] = conflicts[i]; } @@ -430,7 +427,6 @@ conflicts_update_state_numbers (state_number old_to_new[], static size_t count_state_sr_conflicts (state *s) { - int i; transitions *trans = s->transitions; reductions *reds = s->reductions; @@ -440,10 +436,13 @@ count_state_sr_conflicts (state *s) bitset_zero (lookahead_set); bitset_zero (shift_set); - FOR_EACH_SHIFT (trans, i) - bitset_set (shift_set, TRANSITION_SYMBOL (trans, i)); + { + int i; + FOR_EACH_SHIFT (trans, i) + bitset_set (shift_set, TRANSITION_SYMBOL (trans, i)); + } - for (i = 0; i < reds->num; ++i) + for (int i = 0; i < reds->num; ++i) bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]); bitset_and (lookahead_set, lookahead_set, shift_set); @@ -459,10 +458,8 @@ static size_t count_sr_conflicts (void) { size_t res = 0; - state_number i; - /* Conflicts by state. */ - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) if (conflicts[i]) res += count_state_sr_conflicts (states[i]); return res; @@ -480,15 +477,13 @@ count_sr_conflicts (void) static size_t count_state_rr_conflicts (state *s, bool one_per_token) { - int i; reductions *reds = s->reductions; size_t res = 0; - for (i = 0; i < ntokens; i++) + for (symbol_number i = 0; i < ntokens; ++i) { int count = 0; - int j; - for (j = 0; j < reds->num; ++j) + for (int j = 0; j < reds->num; ++j) count += bitset_test (reds->lookahead_tokens[j], i); if (count >= 2) res += one_per_token ? 1 : count-1; @@ -501,10 +496,8 @@ static size_t count_rr_conflicts (bool one_per_token) { size_t res = 0; - state_number i; - /* Conflicts by state. */ - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) if (conflicts[i]) res += count_state_rr_conflicts (states[i], one_per_token); return res; @@ -519,8 +512,7 @@ void conflicts_output (FILE *out) { bool printed_sth = false; - state_number i; - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) { state *s = states[i]; if (conflicts[i]) diff --git a/contrib/tools/bison/src/conflicts.h b/contrib/tools/bison/src/conflicts.h index 5df5787162..22a177cbe4 100644 --- a/contrib/tools/bison/src/conflicts.h +++ b/contrib/tools/bison/src/conflicts.h @@ -1,6 +1,6 @@ /* Find and resolve or report lookahead conflicts for bison, - Copyright (C) 2000-2002, 2004, 2007, 2009-2013 Free Software + Copyright (C) 2000-2002, 2004, 2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/derives.c b/contrib/tools/bison/src/derives.c index c834f0b0d0..7564b41153 100644 --- a/contrib/tools/bison/src/derives.c +++ b/contrib/tools/bison/src/derives.c @@ -1,7 +1,7 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000-2003, 2005, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2003, 2005, 2009-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/derives.h b/contrib/tools/bison/src/derives.h index ea8dff7231..c4a701c034 100644 --- a/contrib/tools/bison/src/derives.h +++ b/contrib/tools/bison/src/derives.h @@ -1,6 +1,6 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000-2002, 2009-2013 Free Software + Copyright (C) 1984, 1989, 2000-2002, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/files.c b/contrib/tools/bison/src/files.c index d0e61df611..e2920b41d7 100644 --- a/contrib/tools/bison/src/files.c +++ b/contrib/tools/bison/src/files.c @@ -1,6 +1,6 @@ /* Open and close files for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2013 Free Software + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -51,8 +51,17 @@ char *spec_defines_file = NULL; /* for --defines. */ char *parser_file_name; /* All computed output file names. */ -static char **file_names = NULL; -static int file_names_count = 0; +typedef struct generated_file +{ + /** File name. */ + char *name; + /** Whether is a generated source file (e.g., *.c, *.java...), as + opposed to the report file (e.g., *.output). When late errors + are detected, generated source files are removed. */ + bool is_source; +} generated_file; +static generated_file *generated_files = NULL; +static int generated_files_size = 0; uniqstr grammar_file = NULL; uniqstr current_file = NULL; @@ -342,21 +351,21 @@ compute_output_file_names (void) { if (! spec_graph_file) spec_graph_file = concat2 (all_but_tab_ext, ".dot"); - output_file_name_check (&spec_graph_file); + output_file_name_check (&spec_graph_file, false); } if (xml_flag) { if (! spec_xml_file) spec_xml_file = concat2 (all_but_tab_ext, ".xml"); - output_file_name_check (&spec_xml_file); + output_file_name_check (&spec_xml_file, false); } if (report_flag) { if (!spec_verbose_file) spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT); - output_file_name_check (&spec_verbose_file); + output_file_name_check (&spec_verbose_file, false); } free (all_but_tab_ext); @@ -365,7 +374,7 @@ compute_output_file_names (void) } void -output_file_name_check (char **file_name) +output_file_name_check (char **file_name, bool source) { bool conflict = false; if (STREQ (*file_name, grammar_file)) @@ -377,11 +386,11 @@ output_file_name_check (char **file_name) else { int i; - for (i = 0; i < file_names_count; i++) - if (STREQ (file_names[i], *file_name)) + for (i = 0; i < generated_files_size; i++) + if (STREQ (generated_files[i].name, *file_name)) { complain (NULL, Wother, _("conflicting outputs to file %s"), - quote (*file_name)); + quote (generated_files[i].name)); conflict = true; } } @@ -392,13 +401,24 @@ output_file_name_check (char **file_name) } else { - file_names = xnrealloc (file_names, ++file_names_count, - sizeof *file_names); - file_names[file_names_count-1] = xstrdup (*file_name); + generated_files = xnrealloc (generated_files, ++generated_files_size, + sizeof *generated_files); + generated_files[generated_files_size-1].name = xstrdup (*file_name); + generated_files[generated_files_size-1].is_source = source; } } void +unlink_generated_sources (void) +{ + int i; + for (i = 0; i < generated_files_size; i++) + if (generated_files[i].is_source) + /* Ignore errors. The file might not even exist. */ + unlink (generated_files[i].name); +} + +void output_file_names_free (void) { free (all_but_ext); @@ -410,8 +430,8 @@ output_file_names_free (void) free (dir_prefix); { int i; - for (i = 0; i < file_names_count; i++) - free (file_names[i]); + for (i = 0; i < generated_files_size; i++) + free (generated_files[i].name); } - free (file_names); + free (generated_files); } diff --git a/contrib/tools/bison/src/files.h b/contrib/tools/bison/src/files.h index ebe5037c7a..9970e88b66 100644 --- a/contrib/tools/bison/src/files.h +++ b/contrib/tools/bison/src/files.h @@ -1,6 +1,6 @@ /* File names and variables for bison, - Copyright (C) 1984, 1989, 2000-2002, 2006-2007, 2009-2013 Free + Copyright (C) 1984, 1989, 2000-2002, 2006-2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -63,7 +63,17 @@ extern char *all_but_ext; void compute_output_file_names (void); void output_file_names_free (void); -void output_file_name_check (char **file_name); + +/** Record that we generate a file. + * + * \param file_name the name of file being generated. + * \param source whether this is a source file (*c, *.java...) + * as opposed to a report (*.output, *.dot...). + */ +void output_file_name_check (char **file_name, bool source); + +/** Remove all the generated source files. */ +void unlink_generated_sources (void); FILE *xfopen (const char *name, char const *mode); void xfclose (FILE *ptr); diff --git a/contrib/tools/bison/src/flex-scanner.h b/contrib/tools/bison/src/flex-scanner.h index d72986e812..e09a1c04fa 100644 --- a/contrib/tools/bison/src/flex-scanner.h +++ b/contrib/tools/bison/src/flex-scanner.h @@ -1,6 +1,6 @@ /* Common parts between scan-code.l, scan-gram.l, and scan-skel.l. - Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -44,6 +44,20 @@ int FLEX_PREFIX (lex_destroy) (void); #define last_string FLEX_PREFIX (last_string) +// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC +// 7.3.0). +// +// ./src/scan-skel.c: In function 'skel_restart': +// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference] +// b->yy_fill_buffer = 1; +// ~~~~~~~~~~~~~~~~~~^~~ +// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference] +// b->yy_input_file = file; +// ~~~~~~~~~~~~~~~~~^~~~~~ +#if defined __GNUC__ && 7 <= __GNUC__ +# pragma GCC diagnostic ignored "-Wnull-dereference" +#endif + /* It seems to be a nice "feature" of Flex that one cannot use yytext, yyleng etc. when a prefix is given, since there is no longer a #define, but rather the token is actually changed in the output. diff --git a/contrib/tools/bison/src/getargs.c b/contrib/tools/bison/src/getargs.c index 0edbbd1ed8..9bca42fd60 100644 --- a/contrib/tools/bison/src/getargs.c +++ b/contrib/tools/bison/src/getargs.c @@ -1,6 +1,6 @@ /* Parse command line arguments for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2013 Free Software + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -66,7 +66,7 @@ const char* m4_path = NULL; /** Decode an option's key. * - * \param option option being decoded. + * \param opt option being decoded. * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param all the all value. @@ -81,11 +81,11 @@ const char* m4_path = NULL; * flags from \c all. Thus no-none = all and no-all = none. */ static void -flag_argmatch (const char *option, - const char * const keys[], const int values[], +flag_argmatch (const char *opt, + const char *const keys[], const int values[], int all, int *flags, char *arg, size_t no) { - int value = XARGMATCH (option, arg + no, keys, values); + int value = XARGMATCH (opt, arg + no, keys, values); /* -rnone == -rno-all, and -rno-none == -rall. */ if (!value) @@ -102,7 +102,7 @@ flag_argmatch (const char *option, /** Decode an option's set of keys. * - * \param option option being decoded. + * \param opt option being decoded (e.g., --report). * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param all the all value. @@ -111,7 +111,7 @@ flag_argmatch (const char *option, * If 0, then activate all the flags. */ static void -flags_argmatch (const char *option, +flags_argmatch (const char *opt, const char * const keys[], const int values[], int all, int *flags, char *args) { @@ -119,7 +119,7 @@ flags_argmatch (const char *option, for (args = strtok (args, ","); args; args = strtok (NULL, ",")) { size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0; - flag_argmatch (option, keys, + flag_argmatch (opt, keys, values, all, flags, args, no); } else diff --git a/contrib/tools/bison/src/getargs.h b/contrib/tools/bison/src/getargs.h index 2bf103fcfe..4e127d4a59 100644 --- a/contrib/tools/bison/src/getargs.h +++ b/contrib/tools/bison/src/getargs.h @@ -1,6 +1,6 @@ /* Parse command line arguments for bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2013 Free Software + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/gram.c b/contrib/tools/bison/src/gram.c index f6cc3c5d87..1dbe88e779 100644 --- a/contrib/tools/bison/src/gram.c +++ b/contrib/tools/bison/src/gram.c @@ -1,7 +1,7 @@ /* Allocate input grammar variables for Bison. - Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -32,7 +32,7 @@ /* Comments for these variables are in gram.h. */ item_number *ritem = NULL; -unsigned int nritems = 0; +unsigned nritems = 0; rule *rules = NULL; rule_number nrules = 0; @@ -65,19 +65,19 @@ rule_useless_in_parser_p (rule const *r) } void -rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out) +rule_lhs_print (rule const *r, sym_content const *previous_lhs, FILE *out) { fprintf (out, " %3d ", r->number); if (previous_lhs != r->lhs) - fprintf (out, "%s:", r->lhs->tag); + fprintf (out, "%s:", r->lhs->symbol->tag); else - fprintf (out, "%*s|", (int) strlen (previous_lhs->tag), ""); + fprintf (out, "%*s|", (int) strlen (previous_lhs->symbol->tag), ""); } void rule_lhs_print_xml (rule const *r, FILE *out, int level) { - xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag); + xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->symbol->tag); } size_t @@ -126,7 +126,7 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level) void ritem_print (FILE *out) { - unsigned int i; + unsigned i; fputs ("RITEM\n", out); for (i = 0; i < nritems; ++i) if (ritem[i] >= 0) @@ -158,7 +158,7 @@ grammar_rules_partial_print (FILE *out, const char *title, { rule_number r; bool first = true; - symbol *previous_lhs = NULL; + sym_content *previous_lhs = NULL; /* rule # : LHS -> RHS */ for (r = 0; r < nrules + nuseless_productions; r++) @@ -209,7 +209,7 @@ grammar_rules_print_xml (FILE *out, int level) rules[r].number, usefulness); if (rules[r].precsym) fprintf (out, " percent_prec=\"%s\"", - xml_escape (rules[r].precsym->tag)); + xml_escape (rules[r].precsym->symbol->tag)); fputs (">\n", out); } rule_lhs_print_xml (&rules[r], out, level + 3); @@ -239,7 +239,7 @@ grammar_dump (FILE *out, const char *title) for (i = ntokens; i < nsyms; i++) fprintf (out, "%5d %5d %5d %s\n", i, - symbols[i]->prec, symbols[i]->assoc, + symbols[i]->content->prec, symbols[i]->content->assoc, symbols[i]->tag); fprintf (out, "\n\n"); } @@ -254,8 +254,8 @@ grammar_dump (FILE *out, const char *title) { rule const *rule_i = &rules[i]; item_number *rp = NULL; - unsigned int rhs_itemno = rule_i->rhs - ritem; - unsigned int rhs_count = 0; + unsigned rhs_itemno = rule_i->rhs - ritem; + unsigned rhs_count = 0; /* Find the last RHS index in ritems. */ for (rp = rule_i->rhs; *rp >= 0; ++rp) ++rhs_count; @@ -280,7 +280,7 @@ grammar_dump (FILE *out, const char *title) rule_number r; for (r = 0; r < nrules + nuseless_productions; r++) { - fprintf (out, "%-5d %s:", r, rules[r].lhs->tag); + fprintf (out, "%-5d %s:", r, rules[r].lhs->symbol->tag); rule_rhs_print (&rules[r], out); fprintf (out, "\n"); } @@ -293,7 +293,10 @@ grammar_rules_useless_report (const char *message) { rule_number r; for (r = 0; r < nrules ; ++r) - if (!rules[r].useful) + /* Don't complain about rules whose LHS is useless, we already + complained about it. */ + if (!reduce_nonterminal_useless_in_grammar (rules[r].lhs) + && !rules[r].useful) complain (&rules[r].location, Wother, "%s", message); } diff --git a/contrib/tools/bison/src/gram.h b/contrib/tools/bison/src/gram.h index c1dd9a648a..bbae54b48a 100644 --- a/contrib/tools/bison/src/gram.h +++ b/contrib/tools/bison/src/gram.h @@ -1,6 +1,6 @@ /* Data definitions for internal representation of Bison's input. - Copyright (C) 1984, 1986, 1989, 1992, 2001-2007, 2009-2013 Free + Copyright (C) 1984, 1986, 1989, 1992, 2001-2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -115,7 +115,7 @@ extern int nvars; typedef int item_number; # define ITEM_NUMBER_MAX INT_MAX extern item_number *ritem; -extern unsigned int nritems; +extern unsigned nritems; /* There is weird relationship between OT1H item_number and OTOH symbol_number and rule_number: we store the latter in @@ -180,17 +180,17 @@ typedef struct except if some rules are useless. */ rule_number number; - symbol *lhs; + sym_content *lhs; item_number *rhs; /* This symbol provides both the associativity, and the precedence. */ - symbol *prec; + sym_content *prec; int dprec; int merger; /* This symbol was attached to the rule via %prec. */ - symbol *precsym; + sym_content *precsym; location location; bool useful; @@ -220,7 +220,8 @@ bool rule_useless_in_parser_p (rule const *r); /* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was already displayed (by a previous call for another rule), avoid useless repetitions. */ -void rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out); +void rule_lhs_print (rule const *r, sym_content const *previous_lhs, + FILE *out); void rule_lhs_print_xml (rule const *r, FILE *out, int level); /* Return the length of the RHS. */ diff --git a/contrib/tools/bison/src/graphviz.c b/contrib/tools/bison/src/graphviz.c index 5ee41e73f3..d85b23de15 100644 --- a/contrib/tools/bison/src/graphviz.c +++ b/contrib/tools/bison/src/graphviz.c @@ -1,6 +1,7 @@ /* Output Graphviz specification of a state machine generated by Bison. - Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -93,7 +94,7 @@ no_reduce_bitset_init (state const *s, bitset *no_reduce_set) bitset_set (*no_reduce_set, TRANSITION_SYMBOL (s->transitions, n)); for (n = 0; n < s->errs->num; ++n) if (s->errs->symbols[n]) - bitset_set (*no_reduce_set, s->errs->symbols[n]->number); + bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number); } static void @@ -113,8 +114,8 @@ conclude_red (struct obstack *out, int source, rule_number ruleno, with n the source state and m the rule number. This is because we don't want all the reductions bearing a same rule number to point to the same state, since that is not the desired format. */ - fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [", - source, ruleno, ed); + fprintf (fout, " %d -> \"%dR%d%s\" [", + source, source, ruleno, ed); /* (The lookahead tokens have been added to the beginning of the obstack, in the caller function.) */ diff --git a/contrib/tools/bison/src/graphviz.h b/contrib/tools/bison/src/graphviz.h index 0254ef748b..f2aaa91feb 100644 --- a/contrib/tools/bison/src/graphviz.h +++ b/contrib/tools/bison/src/graphviz.h @@ -1,6 +1,6 @@ /* Output Graphviz specification of a state machine generated by Bison. - Copyright (C) 2006, 2010-2013 Free Software Foundation, Inc. + Copyright (C) 2006, 2010-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/ielr.c b/contrib/tools/bison/src/ielr.c index 5500523170..437635674b 100644 --- a/contrib/tools/bison/src/ielr.c +++ b/contrib/tools/bison/src/ielr.c @@ -1,6 +1,6 @@ /* IELR main implementation. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -49,7 +49,7 @@ static bitset ielr_compute_ritem_sees_lookahead_set (void) { bitset result = bitset_create (nritems, BITSET_FIXED); - unsigned int i = nritems-1; + unsigned i = nritems-1; while (i>0) { --i; @@ -101,16 +101,14 @@ ielr_compute_internal_follow_edges (bitset ritem_sees_lookahead_set, *edge_countsp = xnmalloc (ngotos, sizeof **edge_countsp); { bitset sources = bitset_create (ngotos, BITSET_FIXED); - goto_number i; - for (i = 0; i < ngotos; ++i) + for (goto_number i = 0; i < ngotos; ++i) (*edge_countsp)[i] = 0; - for (i = 0; i < ngotos; ++i) + for (goto_number i = 0; i < ngotos; ++i) { int nsources = 0; { - rule **rulep; - for (rulep = derives[states[to_state[i]]->accessing_symbol - - ntokens]; + for (rule **rulep = derives[states[to_state[i]]->accessing_symbol + - ntokens]; *rulep; ++rulep) { @@ -198,30 +196,26 @@ ielr_compute_follow_kernel_items (bitset ritem_sees_lookahead_set, { { size_t max_nitems = 0; - state_number i; - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) if (states[i]->nitems > max_nitems) max_nitems = states[i]->nitems; *follow_kernel_itemsp = bitsetv_create (ngotos, max_nitems, BITSET_FIXED); } - { - goto_number i; - for (i = 0; i < ngotos; ++i) - { - size_t nitems = states[from_state[i]]->nitems; - item_number *items = states[from_state[i]]->items; - size_t j; - for (j = 0; j < nitems; ++j) - /* If this item has this goto and if all subsequent symbols in this - RHS (if any) are nullable nonterminals, then record this item as - one whose lookahead set is included in this goto's follows. */ - if (item_number_is_symbol_number (ritem[items[j]]) - && item_number_as_symbol_number (ritem[items[j]]) - == states[to_state[i]]->accessing_symbol - && bitset_test (ritem_sees_lookahead_set, items[j])) - bitset_set ((*follow_kernel_itemsp)[i], j); - } - } + for (goto_number i = 0; i < ngotos; ++i) + { + size_t nitems = states[from_state[i]]->nitems; + item_number *items = states[from_state[i]]->items; + size_t j; + for (j = 0; j < nitems; ++j) + /* If this item has this goto and if all subsequent symbols in this + RHS (if any) are nullable nonterminals, then record this item as + one whose lookahead set is included in this goto's follows. */ + if (item_number_is_symbol_number (ritem[items[j]]) + && item_number_as_symbol_number (ritem[items[j]]) + == states[to_state[i]]->accessing_symbol + && bitset_test (ritem_sees_lookahead_set, items[j])) + bitset_set ((*follow_kernel_itemsp)[i], j); + } relation_digraph (internal_follow_edges, ngotos, follow_kernel_itemsp); if (trace_flag & trace_ielr) @@ -252,8 +246,7 @@ ielr_compute_always_follows (goto_number ***edgesp, *always_followsp = bitsetv_create (ngotos, ntokens, BITSET_FIXED); { goto_number *edge_array = xnmalloc (ngotos, sizeof *edge_array); - goto_number i; - for (i = 0; i < ngotos; ++i) + for (goto_number i = 0; i < ngotos; ++i) { goto_number nedges = edge_counts[i]; { @@ -300,32 +293,28 @@ ielr_compute_always_follows (goto_number ***edgesp, static state *** ielr_compute_predecessors (void) { - state_number i; int *predecessor_counts = xnmalloc (nstates, sizeof *predecessor_counts); state ***result = xnmalloc (nstates, sizeof *result); - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) predecessor_counts[i] = 0; - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { int j; for (j = 0; j < states[i]->transitions->num; ++j) ++predecessor_counts[states[i]->transitions->states[j]->number]; } - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { result[i] = xnmalloc (predecessor_counts[i]+1, sizeof *result[i]); result[i][predecessor_counts[i]] = NULL; predecessor_counts[i] = 0; } - for (i = 0; i < nstates; ++i) - { - int j; - for (j = 0; j < states[i]->transitions->num; ++j) - { - state_number k = states[i]->transitions->states[j]->number; - result[k][predecessor_counts[k]++] = states[i]; - } - } + for (state_number i = 0; i < nstates; ++i) + for (int j = 0; j < states[i]->transitions->num; ++j) + { + state_number k = states[i]->transitions->states[j]->number; + result[k][predecessor_counts[k]++] = states[i]; + } free (predecessor_counts); return result; } @@ -354,11 +343,8 @@ ielr_compute_auxiliary_tables (bitsetv *follow_kernel_itemsp, bitset_free (ritem_sees_lookahead_set); } ielr_compute_always_follows (&edges, edge_counts, always_followsp); - { - int i; - for (i = 0; i < ngotos; ++i) - free (edges[i]); - } + for (int i = 0; i < ngotos; ++i) + free (edges[i]); free (edges); free (edge_counts); if (predecessorsp) @@ -381,10 +367,9 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item, { if (!item_lookahead_sets[s->number]) { - size_t i; item_lookahead_sets[s->number] = xnmalloc (s->nitems, sizeof item_lookahead_sets[s->number][0]); - for (i = 0; i < s->nitems; ++i) + for (size_t i = 0; i < s->nitems; ++i) item_lookahead_sets[s->number][i] = NULL; } if (!item_lookahead_sets[s->number][item]) @@ -412,20 +397,19 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item, top-level invocation), go get it. */ if (!lhs) { - unsigned int i; + unsigned i; for (i = s->items[item]; !item_number_is_rule_number (ritem[i]); ++i) - ; + continue; lhs = rules[item_number_as_rule_number (ritem[i])].lhs->number; } /* If this kernel item is next to the beginning of the RHS, then check all predecessors' goto follows for the LHS. */ if (item_number_is_rule_number (ritem[s->items[item] - 2])) { - state **predecessor; - aver (lhs != accept->number); - for (predecessor = predecessors[s->number]; + aver (lhs != accept->content->number); + for (state **predecessor = predecessors[s->number]; *predecessor; ++predecessor) bitset_or (item_lookahead_sets[s->number][item], @@ -437,8 +421,7 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item, predecessor items' lookahead sets. */ else { - state **predecessor; - for (predecessor = predecessors[s->number]; + for (state **predecessor = predecessors[s->number]; *predecessor; ++predecessor) { @@ -492,12 +475,11 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, AnnotationIndex *annotation_counts = xnmalloc (nstates, sizeof *annotation_counts); ContributionIndex max_contributions = 0; - unsigned int total_annotations = 0; - state_number i; + unsigned total_annotations = 0; *inadequacy_listsp = xnmalloc (nstates, sizeof **inadequacy_listsp); *annotation_listsp = xnmalloc (nstates, sizeof **annotation_listsp); - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { item_lookahead_sets[i] = NULL; (*inadequacy_listsp)[i] = NULL; @@ -506,7 +488,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, } { InadequacyListNodeCount inadequacy_list_node_count = 0; - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) AnnotationList__compute_from_inadequacies ( states[i], follow_kernel_items, always_follows, predecessors, item_lookahead_sets, *inadequacy_listsp, *annotation_listsp, @@ -514,7 +496,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, &inadequacy_list_node_count); } *max_annotationsp = 0; - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { if (annotation_counts[i] > *max_annotationsp) *max_annotationsp = annotation_counts[i]; @@ -522,7 +504,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, } if (trace_flag & trace_ielr) { - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { fprintf (stderr, "Inadequacy annotations for state %d:\n", i); AnnotationList__debug ((*annotation_listsp)[i], @@ -536,11 +518,10 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, fprintf (stderr, "Max number of contributions per annotation: %d\n", max_contributions); } - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) if (item_lookahead_sets[i]) { - size_t j; - for (j = 0; j < states[i]->nitems; ++j) + for (size_t j = 0; j < states[i]->nitems; ++j) if (item_lookahead_sets[i][j]) bitset_free (item_lookahead_sets[i][j]); free (item_lookahead_sets[i]); @@ -580,7 +561,7 @@ typedef struct state_list { static void ielr_compute_goto_follow_set (bitsetv follow_kernel_items, bitsetv always_follows, state_list *s, - symbol *n, bitset follow_set) + sym_content *n, bitset follow_set) { goto_number n_goto = map_goto (s->lr0Isocore->state->number, n->number); bitset_copy (follow_set, always_follows[n_goto]); @@ -615,9 +596,8 @@ ielr_compute_lookaheads (bitsetv follow_kernel_items, bitsetv always_follows, bitsetv lookaheads) { size_t s_item = 0; - size_t t_item; bitsetv_zero (lookaheads); - for (t_item = 0; t_item < t->nitems; ++t_item) + for (size_t t_item = 0; t_item < t->nitems; ++t_item) { /* If this kernel item is the beginning of a RHS, it must be the kernel item in the start state, but t is supposed to be a successor @@ -631,7 +611,7 @@ ielr_compute_lookaheads (bitsetv follow_kernel_items, bitsetv always_follows, { if (item_number_is_rule_number (ritem[t->items[t_item] - 2])) { - unsigned int rule_item; + unsigned rule_item; for (rule_item = t->items[t_item]; !item_number_is_rule_number (ritem[rule_item]); ++rule_item) @@ -771,15 +751,12 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows, } has_lookaheads = false; - { - size_t i; - for (i = 0; i < lr0_isocore->state->nitems; ++i) - if (!bitset_empty_p (lookaheads[i])) - { - has_lookaheads = true; - break; - } - } + for (size_t i = 0; i < lr0_isocore->state->nitems; ++i) + if (!bitset_empty_p (lookaheads[i])) + { + has_lookaheads = true; + break; + } /* Merge with an existing isocore. */ if (this_isocorep == &t->state_list || *this_isocorep != t->state_list) @@ -822,11 +799,10 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows, (*this_isocorep)->recomputedAsSuccessor = true; else if (new_lookaheads) { - int i; /* When merging demands identical lookahead sets, it is impossible to merge new lookaheads. */ aver (annotation_lists); - for (i = 0; i < (*tp)->transitions->num; ++i) + for (int i = 0; i < (*tp)->transitions->num; ++i) { state *t2 = (*tp)->transitions->states[i]; /* At any time, there's at most one state for which we have so @@ -969,9 +945,8 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows, /* Set up state list and some reusable bitsets. */ { size_t max_nitems = 0; - state_number i; state_list **nodep = &first_state; - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { *nodep = states[i]->state_list = last_state = xmalloc (sizeof **nodep); (*nodep)->state = states[i]; @@ -993,12 +968,12 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows, /* Recompute states. */ { ContributionIndex *work = xnmalloc (max_annotations, sizeof *work); - state_list *this_state; - for (this_state = first_state; this_state; this_state = this_state->next) + for (state_list *this_state = first_state; + this_state; + this_state = this_state->next) { state *s = this_state->state; - int i; - for (i = 0; i < s->transitions->num; ++i) + for (int i = 0; i < s->transitions->num; ++i) { state *t = s->transitions->states[i]; if (annotation_lists) @@ -1022,11 +997,8 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows, /* Store states back in the states array. */ states = xnrealloc (states, nstates, sizeof *states); - { - state_list *node; - for (node = first_state; node; node = node->next) - states[node->state->number] = node->state; - } + for (state_list *node = first_state; node; node = node->next) + states[node->state->number] = node->state; /* In the case of canonical LR(1), copy item lookahead sets to reduction lookahead sets. */ @@ -1034,14 +1006,12 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows, { timevar_push (TV_IELR_PHASE4); initialize_LA (); - state_list *node; - for (node = first_state; node; node = node->next) + for (state_list *node = first_state; node; node = node->next) if (!node->state->consistent) { size_t i = 0; item_number *itemset = node->state->items; - size_t r; - for (r = 0; r < node->state->reductions->num; ++r) + for (size_t r = 0; r < node->state->reductions->num; ++r) { rule *this_rule = node->state->reductions->rules[r]; bitset lookahead_set = @@ -1102,7 +1072,10 @@ ielr (void) else if (STREQ (type, "canonical-lr")) lr_type = LR_TYPE__CANONICAL_LR; else - aver (false); + { + aver (false); + abort (); + } free (type); } @@ -1146,11 +1119,8 @@ ielr (void) predecessors, &max_annotations, &inadequacy_lists, &annotation_lists, &annotations_obstack); - { - state_number i; - for (i = 0; i < nstates; ++i) - free (predecessors[i]); - } + for (state_number i = 0; i < nstates; ++i) + free (predecessors[i]); free (predecessors); bitsetv_free (goto_follows); lalr_free (); @@ -1165,11 +1135,8 @@ ielr (void) ielr_split_states (follow_kernel_items, always_follows, annotation_lists, max_annotations); if (inadequacy_lists) - { - state_number i; - for (i = 0; i < nstates_lr0; ++i) - InadequacyList__delete (inadequacy_lists[i]); - } + for (state_number i = 0; i < nstates_lr0; ++i) + InadequacyList__delete (inadequacy_lists[i]); } free (inadequacy_lists); if (annotation_lists) diff --git a/contrib/tools/bison/src/ielr.h b/contrib/tools/bison/src/ielr.h index b60ae36348..c080fdf0d3 100644 --- a/contrib/tools/bison/src/ielr.h +++ b/contrib/tools/bison/src/ielr.h @@ -1,6 +1,6 @@ /* IELR main implementation. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/lalr.c b/contrib/tools/bison/src/lalr.c index d99f960fbf..109aa0f4d9 100644 --- a/contrib/tools/bison/src/lalr.c +++ b/contrib/tools/bison/src/lalr.c @@ -1,7 +1,7 @@ /* Compute lookahead criteria for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2013 Free Software Foundation, - Inc. + Copyright (C) 1984, 1986, 1989, 2000-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -67,17 +67,13 @@ static goto_number **includes; static goto_list **lookback; - - void set_goto_map (void) { state_number s; - goto_number *temp_map; + goto_number *temp_map = xnmalloc (nvars + 1, sizeof *temp_map); goto_map = xcalloc (nvars + 1, sizeof *goto_map); - temp_map = xnmalloc (nvars + 1, sizeof *temp_map); - ngotos = 0; for (s = 0; s < nstates; ++s) { @@ -132,16 +128,13 @@ set_goto_map (void) goto_number map_goto (state_number s0, symbol_number sym) { - goto_number high; - goto_number low; - goto_number middle; - state_number s; - - low = goto_map[sym - ntokens]; - high = goto_map[sym - ntokens + 1] - 1; + goto_number low = goto_map[sym - ntokens]; + goto_number high = goto_map[sym - ntokens + 1] - 1; for (;;) { + goto_number middle; + state_number s; aver (low <= high); middle = (low + high) / 2; s = from_state[middle]; @@ -412,7 +405,6 @@ static void lookahead_tokens_print (FILE *out) { state_number i; - int j, k; fprintf (out, "Lookahead tokens: BEGIN\n"); for (i = 0; i < nstates; ++i) { @@ -421,21 +413,25 @@ lookahead_tokens_print (FILE *out) int n_lookahead_tokens = 0; if (reds->lookahead_tokens) - for (k = 0; k < reds->num; ++k) - if (reds->lookahead_tokens[k]) - ++n_lookahead_tokens; + { + int j; + for (j = 0; j < reds->num; ++j) + if (reds->lookahead_tokens[j]) + ++n_lookahead_tokens; + } fprintf (out, "State %d: %d lookahead tokens\n", i, n_lookahead_tokens); if (reds->lookahead_tokens) - for (j = 0; j < reds->num; ++j) - BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0) - { - fprintf (out, " on %d (%s) -> rule %d\n", - k, symbols[k]->tag, - reds->rules[j]->number); - }; + { + int j, k; + for (j = 0; j < reds->num; ++j) + BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0) + fprintf (out, " on %d (%s) -> rule %d\n", + k, symbols[k]->tag, + reds->rules[j]->number); + } } fprintf (out, "Lookahead tokens: END\n"); } diff --git a/contrib/tools/bison/src/lalr.h b/contrib/tools/bison/src/lalr.h index f483315747..898053f5c9 100644 --- a/contrib/tools/bison/src/lalr.h +++ b/contrib/tools/bison/src/lalr.h @@ -1,7 +1,7 @@ /* Compute lookahead criteria for bison, Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006-2007, - 2009-2013 Free Software Foundation, Inc. + 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/location.c b/contrib/tools/bison/src/location.c index 662b2a12a0..5962ef0c41 100644 --- a/contrib/tools/bison/src/location.c +++ b/contrib/tools/bison/src/location.c @@ -1,6 +1,6 @@ /* Locations for Bison - Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -37,7 +37,7 @@ static inline int add_column_width (int column, char const *buf, size_t bufsize) { size_t width; - unsigned int remaining_columns = INT_MAX - column; + unsigned remaining_columns = INT_MAX - column; if (buf) { @@ -188,7 +188,7 @@ location_caret (location loc, FILE *out) /* Read the actual line. Don't update the offset, so that we keep a pointer to the start of the line. */ { - char c = getc (caret_info.source); + int c = getc (caret_info.source); if (c != EOF) { /* Quote the file, indent by a single column. */ diff --git a/contrib/tools/bison/src/location.h b/contrib/tools/bison/src/location.h index 9c6e53c190..25a9aa4917 100644 --- a/contrib/tools/bison/src/location.h +++ b/contrib/tools/bison/src/location.h @@ -1,6 +1,6 @@ /* Locations for Bison - Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/main.c b/contrib/tools/bison/src/main.c index c5200fa937..a5ff83a07f 100644 --- a/contrib/tools/bison/src/main.c +++ b/contrib/tools/bison/src/main.c @@ -1,7 +1,7 @@ /* Top level entry point of Bison. - Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2002, 2004-2013 Free - Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2002, 2004-2015, + 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/muscle-tab.c b/contrib/tools/bison/src/muscle-tab.c index cc5d01dffa..c14273f60a 100644 --- a/contrib/tools/bison/src/muscle-tab.c +++ b/contrib/tools/bison/src/muscle-tab.c @@ -1,6 +1,6 @@ /* Muscle table manager for Bison. - Copyright (C) 2001-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -37,7 +37,7 @@ muscle_kind_new (char const *k) return muscle_keyword; else if (STREQ (k, "string")) return muscle_string; - aver (0); + abort (); } char const * @@ -49,7 +49,7 @@ muscle_kind_string (muscle_kind k) case muscle_keyword: return "keyword"; case muscle_string: return "string"; } - aver (0); + abort (); } @@ -299,8 +299,9 @@ muscle_location_grow (char const *key, location loc) #define COMMON_DECODE(Value) \ case '$': \ - aver (*++(Value) == ']'); \ - aver (*++(Value) == '['); \ + ++(Value); aver (*(Value) == '['); \ + ++(Value); aver (*(Value) == ']'); \ + ++(Value); aver (*(Value) == '['); \ obstack_sgrow (&muscle_obstack, "$"); \ break; \ case '@': \ @@ -349,7 +350,7 @@ location_decode (char const *value) location loc; aver (value); aver (*value == '['); - aver (*++value == '['); + ++value; aver (*value == '['); while (*++value) switch (*value) { @@ -360,16 +361,16 @@ location_decode (char const *value) case ']': { char *boundary_str; - aver (*++value == ']'); + ++value; aver (*value == ']'); boundary_str = obstack_finish0 (&muscle_obstack); switch (*++value) { case ',': boundary_set_from_string (&loc.start, boundary_str); obstack_free (&muscle_obstack, boundary_str); - aver (*++value == ' '); - aver (*++value == '['); - aver (*++value == '['); + ++value; aver (*value == ' '); + ++value; aver (*value == '['); + ++value; aver (*value == '['); break; case '\0': boundary_set_from_string (&loc.end, boundary_str); diff --git a/contrib/tools/bison/src/muscle-tab.h b/contrib/tools/bison/src/muscle-tab.h index 0993f74ed7..4ec1ae1b27 100644 --- a/contrib/tools/bison/src/muscle-tab.h +++ b/contrib/tools/bison/src/muscle-tab.h @@ -1,6 +1,7 @@ /* Muscle table manager for Bison, - Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/named-ref.c b/contrib/tools/bison/src/named-ref.c index 1693767918..ac5af1c8e9 100644 --- a/contrib/tools/bison/src/named-ref.c +++ b/contrib/tools/bison/src/named-ref.c @@ -1,6 +1,6 @@ /* Named symbol references for Bison - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/named-ref.h b/contrib/tools/bison/src/named-ref.h index 84d02d7adb..f42036facb 100644 --- a/contrib/tools/bison/src/named-ref.h +++ b/contrib/tools/bison/src/named-ref.h @@ -1,6 +1,6 @@ /* Named symbol references for Bison - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/nullable.c b/contrib/tools/bison/src/nullable.c index a150f5f5c7..0dffd575b0 100644 --- a/contrib/tools/bison/src/nullable.c +++ b/contrib/tools/bison/src/nullable.c @@ -1,6 +1,6 @@ /* Calculate which nonterminals can expand into the null string for Bison. - Copyright (C) 1984, 1989, 2000-2006, 2009-2013 Free Software + Copyright (C) 1984, 1989, 2000-2006, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/nullable.h b/contrib/tools/bison/src/nullable.h index 63a8ae3f14..8b6cfddd23 100644 --- a/contrib/tools/bison/src/nullable.h +++ b/contrib/tools/bison/src/nullable.h @@ -1,6 +1,7 @@ /* Part of the bison parser generator, - Copyright (C) 2000, 2002, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/output.c b/contrib/tools/bison/src/output.c index ede96799b5..a4f7910bca 100644 --- a/contrib/tools/bison/src/output.c +++ b/contrib/tools/bison/src/output.c @@ -1,6 +1,6 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2013 Free Software + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -85,13 +85,10 @@ Name (char const *name, \ { \ Type min = first; \ Type max = first; \ - long int lmin; \ - long int lmax; \ - int i; \ int j = 1; \ \ obstack_printf (&format_obstack, "%6d", first); \ - for (i = begin; i < end; ++i) \ + for (int i = begin; i < end; ++i) \ { \ obstack_1grow (&format_obstack, ','); \ if (j >= 10) \ @@ -109,8 +106,8 @@ Name (char const *name, \ } \ muscle_insert (name, obstack_finish0 (&format_obstack)); \ \ - lmin = min; \ - lmax = max; \ + long lmin = min; \ + long lmax = max; \ /* Build 'NAME_min' and 'NAME_max' in the obstack. */ \ obstack_printf (&format_obstack, "%s_min", name); \ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmin); \ @@ -118,7 +115,7 @@ Name (char const *name, \ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \ } -GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_int_table, unsigned int) +GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_int_table, unsigned) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_int_table, int) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_base_table, base_number) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_rule_number_table, rule_number) @@ -170,7 +167,7 @@ prepare_symbols (void) MUSCLE_INSERT_INT ("tokens_number", ntokens); MUSCLE_INSERT_INT ("nterms_number", nvars); MUSCLE_INSERT_INT ("symbols_number", nsyms); - MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number); + MUSCLE_INSERT_INT ("undef_token_number", undeftoken->content->number); MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number); muscle_insert_symbol_number_table ("translate", @@ -180,13 +177,12 @@ prepare_symbols (void) /* tname -- token names. */ { - int i; /* We assume that the table will be output starting at column 2. */ int j = 2; struct quoting_options *qo = clone_quoting_options (0); set_quoting_style (qo, c_quoting_style); set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS); - for (i = 0; i < nsyms; i++) + for (int i = 0; i < nsyms; i++) { char *cp = quotearg_alloc (symbols[i]->tag, -1, qo); /* Width of the next token, including the two quotes, the @@ -215,10 +211,9 @@ prepare_symbols (void) /* Output YYTOKNUM. */ { - int i; int *values = xnmalloc (ntokens, sizeof *values); - for (i = 0; i < ntokens; ++i) - values[i] = symbols[i]->user_token_number; + for (int i = 0; i < ntokens; ++i) + values[i] = symbols[i]->content->user_token_number; muscle_insert_int_table ("toknum", values, values[0], 1, ntokens); free (values); @@ -234,15 +229,14 @@ prepare_symbols (void) static void prepare_rules (void) { - unsigned int *rline = xnmalloc (nrules, sizeof *rline); + unsigned *rline = xnmalloc (nrules, sizeof *rline); symbol_number *r1 = xnmalloc (nrules, sizeof *r1); - unsigned int *r2 = xnmalloc (nrules, sizeof *r2); + unsigned *r2 = xnmalloc (nrules, sizeof *r2); int *dprec = xnmalloc (nrules, sizeof *dprec); int *merger = xnmalloc (nrules, sizeof *merger); int *immediate = xnmalloc (nrules, sizeof *immediate); - rule_number r; - for (r = 0; r < nrules; ++r) + for (rule_number r = 0; r < nrules; ++r) { /* LHS of the rule R. */ r1[r] = rules[r].lhs->number; @@ -283,9 +277,8 @@ prepare_rules (void) static void prepare_states (void) { - state_number i; symbol_number *values = xnmalloc (nstates, sizeof *values); - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) values[i] = states[i]->accessing_symbol; muscle_insert_symbol_number_table ("stos", values, 0, 1, nstates); @@ -304,9 +297,9 @@ prepare_states (void) static int symbol_type_name_cmp (const symbol **lhs, const symbol **rhs) { - int res = uniqstr_cmp ((*lhs)->type_name, (*rhs)->type_name); + int res = uniqstr_cmp ((*lhs)->content->type_name, (*rhs)->content->type_name); if (!res) - res = (*lhs)->number - (*rhs)->number; + res = (*lhs)->content->number - (*rhs)->content->number; return res; } @@ -333,16 +326,16 @@ symbols_by_type_name (void) static void type_names_output (FILE *out) { - int i; symbol **syms = symbols_by_type_name (); fputs ("m4_define([b4_type_names],\n[", out); - for (i = 0; i < nsyms; /* nothing */) + for (int i = 0; i < nsyms; /* nothing */) { /* The index of the first symbol of the current type-name. */ int i0 = i; fputs (i ? ",\n[" : "[", out); - for (; i < nsyms && syms[i]->type_name == syms[i0]->type_name; ++i) - fprintf (out, "%s%d", i != i0 ? ", " : "", syms[i]->number); + for (; i < nsyms + && syms[i]->content->type_name == syms[i0]->content->type_name; ++i) + fprintf (out, "%s%d", i != i0 ? ", " : "", syms[i]->content->number); fputs ("]", out); } fputs ("])\n\n", out); @@ -357,9 +350,8 @@ type_names_output (FILE *out) static void symbol_numbers_output (FILE *out) { - int i; fputs ("m4_define([b4_symbol_numbers],\n[", out); - for (i = 0; i < nsyms; ++i) + for (int i = 0; i < nsyms; ++i) fprintf (out, "%s[%d]", i ? ", " : "", i); fputs ("])\n\n", out); } @@ -372,14 +364,12 @@ symbol_numbers_output (FILE *out) static void user_actions_output (FILE *out) { - rule_number r; - fputs ("m4_define([b4_actions], \n[", out); - for (r = 0; r < nrules; ++r) + for (rule_number r = 0; r < nrules; ++r) if (rules[r].action) { - fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ", - rules[r].is_predicate ? "predicate_" : "", + fprintf (out, "%s(%d, [b4_syncline(%d, ", + rules[r].is_predicate ? "b4_predicate_case" : "b4_case", r + 1, rules[r].action_location.start.line); string_output (out, rules[r].action_location.start.file); fprintf (out, ")\n[ %s]])\n\n", rules[r].action); @@ -394,10 +384,9 @@ user_actions_output (FILE *out) static void merger_output (FILE *out) { + fputs ("m4_define([b4_mergers], \n[[", out); int n; merger_list* p; - - fputs ("m4_define([b4_mergers], \n[[", out); for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next) { if (p->type[0] == '\0') @@ -418,12 +407,10 @@ merger_output (FILE *out) static void prepare_symbol_definitions (void) { - int i; - for (i = 0; i < nsyms; ++i) + for (int i = 0; i < nsyms; ++i) { symbol *sym = symbols[i]; const char *key; - const char *value; #define SET_KEY(Entry) \ obstack_printf (&format_obstack, "symbol(%d, %s)", \ @@ -436,7 +423,7 @@ prepare_symbol_definitions (void) key = obstack_finish0 (&format_obstack); /* Whether the symbol has an identifier. */ - value = symbol_id_get (sym); + const char *value = symbol_id_get (sym); SET_KEY ("has_id"); MUSCLE_INSERT_INT (key, !!value); @@ -449,44 +436,42 @@ prepare_symbol_definitions (void) MUSCLE_INSERT_STRING (key, sym->tag); SET_KEY ("user_number"); - MUSCLE_INSERT_INT (key, sym->user_token_number); + MUSCLE_INSERT_INT (key, sym->content->user_token_number); SET_KEY ("is_token"); MUSCLE_INSERT_INT (key, i < ntokens && sym != errtoken && sym != undeftoken); SET_KEY ("number"); - MUSCLE_INSERT_INT (key, sym->number); + MUSCLE_INSERT_INT (key, sym->content->number); SET_KEY ("has_type"); - MUSCLE_INSERT_INT (key, !!sym->type_name); + MUSCLE_INSERT_INT (key, !!sym->content->type_name); SET_KEY ("type"); - MUSCLE_INSERT_STRING (key, sym->type_name ? sym->type_name : ""); - - { - int j; - for (j = 0; j < CODE_PROPS_SIZE; ++j) - { - /* "printer", not "%printer". */ - char const *pname = code_props_type_string (j) + 1; - code_props const *p = symbol_code_props_get (sym, j); - SET_KEY2 ("has", pname); - MUSCLE_INSERT_INT (key, !!p->code); - - if (p->code) - { - SET_KEY2 (pname, "file"); - MUSCLE_INSERT_STRING (key, p->location.start.file); - - SET_KEY2 (pname, "line"); - MUSCLE_INSERT_INT (key, p->location.start.line); - - SET_KEY (pname); - MUSCLE_INSERT_STRING_RAW (key, p->code); - } - } - } + MUSCLE_INSERT_STRING (key, sym->content->type_name + ? sym->content->type_name : ""); + + for (int j = 0; j < CODE_PROPS_SIZE; ++j) + { + /* "printer", not "%printer". */ + char const *pname = code_props_type_string (j) + 1; + code_props const *p = symbol_code_props_get (sym, j); + SET_KEY2 ("has", pname); + MUSCLE_INSERT_INT (key, !!p->code); + + if (p->code) + { + SET_KEY2 (pname, "file"); + MUSCLE_INSERT_C_STRING (key, p->location.start.file); + + SET_KEY2 (pname, "line"); + MUSCLE_INSERT_INT (key, p->location.start.line); + + SET_KEY (pname); + MUSCLE_INSERT_STRING_RAW (key, p->code); + } + } #undef SET_KEY2 #undef SET_KEY } @@ -564,9 +549,6 @@ muscles_output (FILE *out) static void output_skeleton (void) { - int filter_fd[2]; - pid_t pid; - /* Compute the names of the package data dir and skeleton files. */ char const *m4 = (m4 = getenv ("M4")) ? m4 : M4; char const *datadir = pkgdatadir (); @@ -594,6 +576,8 @@ output_skeleton (void) See the thread starting at <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html> for details. */ + int filter_fd[2]; + pid_t pid; { char const *argv[10]; int i = 0; @@ -725,6 +709,11 @@ output (void) /* Process the selected skeleton file. */ output_skeleton (); + /* If late errors were generated, destroy the generated source + files. */ + if (complaint_status) + unlink_generated_sources (); + obstack_free (&format_obstack, NULL); } diff --git a/contrib/tools/bison/src/output.h b/contrib/tools/bison/src/output.h index 63a0ca803a..ba47a89c4d 100644 --- a/contrib/tools/bison/src/output.h +++ b/contrib/tools/bison/src/output.h @@ -1,6 +1,6 @@ /* Output the generated parsing program for bison, - Copyright (C) 2000-2003, 2006-2007, 2009-2013 Free Software + Copyright (C) 2000-2003, 2006-2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/parse-gram.c b/contrib/tools/bison/src/parse-gram.c index b48ed6ffc6..bf9ade4734 100644 --- a/contrib/tools/bison/src/parse-gram.c +++ b/contrib/tools/bison/src/parse-gram.c @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0. */ +/* A Bison parser, made by GNU Bison 3.0.5.75-d835. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0" +#define YYBISON_VERSION "3.0.5.75-d835" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -80,11 +80,11 @@ #line 82 "src/parse-gram.c" /* yacc.c:339 */ -# ifndef YY_NULL +# ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# define YY_NULLPTR nullptr # else -# define YY_NULL 0 +# define YY_NULLPTR 0 # endif # endif @@ -129,7 +129,7 @@ extern int gram_debug; param_parse = 1 << 1, param_both = param_lex | param_parse } param_type; -#line 645 "src/parse-gram.y" /* yacc.c:355 */ +#line 644 "src/parse-gram.y" /* yacc.c:355 */ #include "muscle-tab.h" #line 136 "src/parse-gram.c" /* yacc.c:355 */ @@ -200,7 +200,7 @@ extern int gram_debug; /* Value type. */ #if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED -typedef union GRAM_STYPE GRAM_STYPE; + union GRAM_STYPE { #line 182 "src/parse-gram.y" /* yacc.c:355 */ @@ -221,9 +221,9 @@ symbol_list *list; named_ref *named_ref; #line 241 "src/parse-gram.y" /* yacc.c:355 */ param_type param; -#line 409 "src/parse-gram.y" /* yacc.c:355 */ +#line 408 "src/parse-gram.y" /* yacc.c:355 */ code_props_type code_type; -#line 647 "src/parse-gram.y" /* yacc.c:355 */ +#line 646 "src/parse-gram.y" /* yacc.c:355 */ struct { @@ -233,6 +233,8 @@ code_props_type code_type; #line 235 "src/parse-gram.c" /* yacc.c:355 */ }; + +typedef union GRAM_STYPE GRAM_STYPE; # define GRAM_STYPE_IS_TRIVIAL 1 # define GRAM_STYPE_IS_DECLARED 1 #endif @@ -259,7 +261,7 @@ int gram_parse (void); /* Copy the second part of user declarations. */ -#line 263 "src/parse-gram.c" /* yacc.c:358 */ +#line 265 "src/parse-gram.c" /* yacc.c:358 */ /* Unqualified %code blocks. */ #line 33 "src/parse-gram.y" /* yacc.c:359 */ @@ -335,7 +337,7 @@ int gram_parse (void); static void add_param (param_type type, char *decl, location loc); static param_type current_param = param_none; -#line 339 "src/parse-gram.c" /* yacc.c:359 */ +#line 341 "src/parse-gram.c" /* yacc.c:359 */ #ifdef short # undef short @@ -356,13 +358,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -374,7 +376,7 @@ typedef short int yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -392,11 +394,30 @@ typedef short int yytype_int16; # endif #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif @@ -546,7 +567,7 @@ union yyalloc /* YYNRULES -- Number of rules. */ #define YYNRULES 110 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 144 +#define YYNSTATES 145 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ @@ -554,7 +575,7 @@ union yyalloc #define YYMAXUTOK 312 #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ @@ -601,15 +622,15 @@ static const yytype_uint16 yyrline[] = 0, 264, 264, 273, 274, 278, 279, 285, 289, 294, 295, 300, 306, 307, 308, 309, 314, 319, 320, 321, 322, 323, 324, 324, 325, 326, 350, 351, 352, 353, - 357, 358, 367, 368, 369, 373, 385, 389, 393, 401, - 412, 413, 423, 424, 428, 440, 440, 445, 445, 450, - 461, 476, 477, 478, 479, 483, 484, 489, 491, 496, - 501, 511, 513, 518, 519, 523, 524, 528, 529, 530, - 535, 540, 545, 551, 557, 568, 569, 578, 579, 585, - 586, 587, 594, 594, 602, 603, 604, 609, 612, 614, - 616, 618, 620, 622, 624, 629, 630, 640, 641, 666, - 667, 668, 669, 681, 683, 692, 697, 698, 703, 711, - 712 + 357, 358, 367, 368, 369, 373, 384, 388, 392, 400, + 411, 412, 422, 423, 429, 441, 441, 446, 446, 451, + 461, 475, 476, 477, 478, 482, 483, 488, 490, 495, + 500, 510, 512, 517, 518, 522, 523, 527, 528, 529, + 534, 539, 544, 550, 556, 567, 568, 577, 578, 584, + 585, 586, 593, 593, 601, 602, 603, 608, 611, 613, + 615, 617, 619, 621, 623, 628, 629, 639, 640, 665, + 666, 667, 668, 680, 682, 691, 696, 697, 702, 710, + 711 }; #endif @@ -639,7 +660,7 @@ static const char *const yytname[] = "symbols.1", "generic_symlist", "generic_symlist_item", "tag", "symbol_def", "symbol_defs.1", "grammar", "rules_or_grammar_declaration", "rules", "$@4", "rhses.1", "rhs", "named_ref.opt", "variable", "value", - "id", "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULL + "id", "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULLPTR }; #endif @@ -657,10 +678,10 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -113 +#define YYPACT_NINF -116 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-113))) + (!!((Yystate) == (-116))) #define YYTABLE_NINF -110 @@ -671,21 +692,21 @@ static const yytype_uint16 yytoknum[] = STATE-NUM. */ static const yytype_int8 yypact[] = { - -113, 16, 108, -113, -113, -113, -27, -113, -113, -113, - -113, -113, -113, -24, -113, 23, 24, -113, -21, -15, - -113, 29, -113, 3, 38, 42, -113, -113, -113, 44, - 47, 71, 31, -113, -113, -113, 55, -113, -113, -113, - 30, -113, -113, 39, -113, -113, 26, -22, -22, 31, - -113, 48, -113, -113, 1, -113, -113, -113, -113, -113, - -113, -113, -113, -113, -113, -113, -113, -113, -113, -113, - -113, 45, -113, 50, 2, -113, -113, 57, 49, -113, - 52, 41, -113, 31, -113, -113, -22, -2, -22, 31, - -113, -113, -113, -113, -113, -113, -113, -113, 46, -113, - -113, -113, -113, -113, 63, -113, -113, -113, -113, 41, - -113, -113, -113, 31, -113, 51, -113, 100, -113, -113, - -113, -113, -113, -113, -113, -113, -113, -20, 40, -113, - -113, 31, 53, 58, 57, -113, -113, 57, 40, -113, - -113, -113, -113, -113 + -116, 16, 108, -116, -116, -116, -27, -116, -116, -116, + -116, -116, -116, -24, -116, 23, 29, -116, -29, -21, + -116, 36, -116, 3, 38, 42, -116, -116, -116, 44, + 47, 71, 31, -116, -116, -116, 55, -116, -116, -116, + 30, -116, -116, 39, -116, -116, 26, -22, -22, 31, + -116, 48, -116, -116, 1, -116, -116, -116, -116, -116, + -116, -116, -116, -116, -116, -116, -116, -116, -116, -116, + -116, 45, -116, 50, 2, -116, -116, 57, 49, -116, + 63, 41, -116, 31, -116, -116, -22, -2, -22, 31, + -116, -116, -116, -116, -116, -116, -116, -116, 46, -116, + -116, -116, -116, -116, 64, -116, -116, -116, -116, 41, + -116, -116, -116, 31, -116, 51, -116, 101, -116, -116, + -116, -116, -116, -116, -116, -116, -116, -20, 40, -116, + -116, 31, 53, 58, -116, -116, 82, 57, 40, -116, + -116, -116, 57, -116, -116 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -706,24 +727,24 @@ static const yytype_uint8 yydefact[] = 2, 96, 82, 31, 23, 44, 67, 68, 69, 35, 63, 66, 65, 50, 57, 59, 76, 72, 73, 62, 110, 87, 30, 64, 58, 60, 74, 83, 84, 87, - 86, 0, 0, 0, 95, 90, 91, 95, 85, 92, - 93, 94, 89, 88 + 86, 0, 0, 0, 90, 91, 0, 95, 85, 92, + 93, 94, 95, 88, 89 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -113, -113, -113, -113, -113, -113, 102, -113, -113, -113, - -113, -113, -113, -113, -113, -113, 8, -113, -113, 13, - -113, -50, 75, -113, 73, -113, -113, -113, 19, -112, - -113, -113, 22, -113, -32, -82, -113 + -116, -116, -116, -116, -116, -116, 120, -116, -116, -116, + -116, -116, -116, -116, 77, -116, 34, -116, -116, 43, + -116, -50, 100, -116, 75, -116, -116, -116, 21, -115, + -116, -116, 22, -116, -32, -82, -116 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 1, 2, 41, 78, 104, 73, 43, 80, 44, - 48, 47, 45, 46, 83, 113, 114, 89, 109, 110, + 48, 47, 45, 46, 136, 113, 114, 89, 109, 110, 111, 85, 86, 74, 75, 76, 121, 127, 128, 102, 54, 95, 68, 77, 112, 70, 100 }; @@ -735,20 +756,20 @@ static const yytype_int16 yytable[] = { 69, 65, -109, 71, 92, 118, 4, 5, 6, 7, 8, 9, 10, 11, 12, 50, 3, 90, 13, 14, - 66, 51, 142, 67, 49, 143, 52, 55, 129, 84, - 130, 26, 58, 56, 65, 126, 116, 32, 116, 57, + 66, 51, 143, 67, 49, 56, 52, 144, 129, 84, + 130, 26, 55, 57, 65, 126, 116, 32, 116, 58, 93, 60, 59, 65, 65, 61, 94, 62, 72, 98, 63, 115, 117, 131, 132, 133, 71, 119, 40, 4, 5, 6, 7, 8, 9, 10, 11, 12, 53, 87, - 87, 13, 14, 66, 64, 79, 67, 82, 81, 134, - 135, 115, 66, 66, 26, 67, 67, 91, 103, 120, - 32, 105, 106, 107, 108, 96, 137, 136, 101, 139, - 97, 72, 122, 65, 42, 125, 137, 140, 87, 141, + 87, 13, 14, 66, 64, 79, 67, 82, 81, -55, + 134, 115, 66, 66, 26, 67, 67, 91, 103, 120, + 32, 82, 106, 107, 108, 96, 137, 135, 101, 139, + 97, 72, 105, 122, 65, 125, 137, 140, 87, 141, 87, 40, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 124, 123, 88, 13, 14, 15, 16, 17, 18, + 12, 142, 42, 83, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 99, 138, 0, - 0, 0, 0, 0, 0, 36, 0, 37, 38, 0, + 29, 30, 31, 32, 33, 34, 35, 124, 88, 99, + 138, 0, 123, 0, 0, 36, 0, 37, 38, 0, 0, 0, 0, 39, 40 }; @@ -756,20 +777,20 @@ static const yytype_int16 yycheck[] = { 32, 3, 0, 1, 3, 87, 4, 5, 6, 7, 8, 9, 10, 11, 12, 39, 0, 49, 16, 17, - 42, 45, 134, 45, 51, 137, 3, 3, 48, 51, - 50, 29, 3, 54, 3, 117, 86, 35, 88, 54, + 42, 45, 137, 45, 51, 54, 3, 142, 48, 51, + 50, 29, 3, 54, 3, 117, 86, 35, 88, 3, 39, 3, 39, 3, 3, 3, 45, 3, 46, 47, 3, 83, 54, 13, 14, 15, 1, 89, 56, 4, 5, 6, 7, 8, 9, 10, 11, 12, 45, 47, 48, 16, 17, 42, 3, 45, 45, 51, 39, 39, 40, 113, 42, 42, 29, 45, 45, 39, 39, 43, - 35, 39, 51, 52, 53, 50, 128, 57, 41, 131, - 50, 46, 39, 3, 2, 54, 138, 54, 86, 51, + 35, 51, 51, 52, 53, 50, 128, 57, 41, 131, + 50, 46, 39, 39, 3, 54, 138, 54, 86, 51, 88, 56, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 113, 109, 48, 16, 17, 18, 19, 20, 21, + 12, 39, 2, 46, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 74, 129, -1, - -1, -1, -1, -1, -1, 47, -1, 49, 50, -1, + 32, 33, 34, 35, 36, 37, 38, 113, 48, 74, + 129, -1, 109, -1, -1, 47, -1, 49, 50, -1, -1, -1, -1, 55, 56 }; @@ -790,8 +811,8 @@ static const yytype_uint8 yystos[] = 94, 41, 87, 39, 63, 39, 51, 52, 53, 76, 77, 78, 92, 73, 74, 92, 79, 54, 93, 92, 43, 84, 39, 77, 74, 54, 93, 85, 86, 48, - 50, 13, 14, 15, 39, 40, 57, 92, 86, 92, - 54, 51, 87, 87 + 50, 13, 14, 15, 40, 57, 72, 92, 86, 92, + 54, 51, 39, 87, 87 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ @@ -822,7 +843,7 @@ static const yytype_uint8 yyr2[] = 3, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 1, 2, 1, 2, 1, - 2, 2, 0, 4, 1, 3, 2, 0, 3, 3, + 2, 2, 0, 4, 1, 3, 2, 0, 3, 4, 2, 2, 3, 3, 3, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2 @@ -915,7 +936,7 @@ do { \ /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ -__attribute__((__unused__)) +YY_ATTRIBUTE_UNUSED static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { @@ -983,73 +1004,73 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue case 3: /* "string" */ #line 188 "src/parse-gram.y" /* yacc.c:684 */ { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).code)), yyo); } -#line 987 "src/parse-gram.c" /* yacc.c:684 */ +#line 1008 "src/parse-gram.c" /* yacc.c:684 */ break; case 23: /* "%<flag>" */ #line 196 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%%%s", ((*yyvaluep).uniqstr)); } -#line 993 "src/parse-gram.c" /* yacc.c:684 */ +#line 1014 "src/parse-gram.c" /* yacc.c:684 */ break; case 39: /* "{...}" */ #line 189 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 999 "src/parse-gram.c" /* yacc.c:684 */ +#line 1020 "src/parse-gram.c" /* yacc.c:684 */ break; case 40: /* "%?{...}" */ #line 189 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1005 "src/parse-gram.c" /* yacc.c:684 */ +#line 1026 "src/parse-gram.c" /* yacc.c:684 */ break; case 41: /* "[identifier]" */ #line 194 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "[%s]", ((*yyvaluep).uniqstr)); } -#line 1011 "src/parse-gram.c" /* yacc.c:684 */ +#line 1032 "src/parse-gram.c" /* yacc.c:684 */ break; case 42: /* "char" */ #line 184 "src/parse-gram.y" /* yacc.c:684 */ { fputs (char_name (((*yyvaluep).character)), yyo); } -#line 1017 "src/parse-gram.c" /* yacc.c:684 */ +#line 1038 "src/parse-gram.c" /* yacc.c:684 */ break; case 43: /* "epilogue" */ #line 189 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1023 "src/parse-gram.c" /* yacc.c:684 */ +#line 1044 "src/parse-gram.c" /* yacc.c:684 */ break; case 45: /* "identifier" */ #line 193 "src/parse-gram.y" /* yacc.c:684 */ { fputs (((*yyvaluep).uniqstr), yyo); } -#line 1029 "src/parse-gram.c" /* yacc.c:684 */ +#line 1050 "src/parse-gram.c" /* yacc.c:684 */ break; case 46: /* "identifier:" */ #line 195 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s:", ((*yyvaluep).uniqstr)); } -#line 1035 "src/parse-gram.c" /* yacc.c:684 */ +#line 1056 "src/parse-gram.c" /* yacc.c:684 */ break; case 49: /* "%{...%}" */ #line 189 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1041 "src/parse-gram.c" /* yacc.c:684 */ +#line 1062 "src/parse-gram.c" /* yacc.c:684 */ break; case 51: /* "<tag>" */ #line 197 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); } -#line 1047 "src/parse-gram.c" /* yacc.c:684 */ +#line 1068 "src/parse-gram.c" /* yacc.c:684 */ break; case 54: /* "integer" */ #line 201 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%d", ((*yyvaluep).integer)); } -#line 1053 "src/parse-gram.c" /* yacc.c:684 */ +#line 1074 "src/parse-gram.c" /* yacc.c:684 */ break; case 55: /* "%param" */ @@ -1066,35 +1087,35 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue case param_none: aver (false); break; } } -#line 1070 "src/parse-gram.c" /* yacc.c:684 */ +#line 1091 "src/parse-gram.c" /* yacc.c:684 */ break; case 65: /* code_props_type */ -#line 410 "src/parse-gram.y" /* yacc.c:684 */ +#line 409 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_type))); } -#line 1076 "src/parse-gram.c" /* yacc.c:684 */ +#line 1097 "src/parse-gram.c" /* yacc.c:684 */ break; case 74: /* symbol.prec */ #line 205 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1082 "src/parse-gram.c" /* yacc.c:684 */ +#line 1103 "src/parse-gram.c" /* yacc.c:684 */ break; case 78: /* tag */ #line 197 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); } -#line 1088 "src/parse-gram.c" /* yacc.c:684 */ +#line 1109 "src/parse-gram.c" /* yacc.c:684 */ break; case 88: /* variable */ #line 193 "src/parse-gram.y" /* yacc.c:684 */ { fputs (((*yyvaluep).uniqstr), yyo); } -#line 1094 "src/parse-gram.c" /* yacc.c:684 */ +#line 1115 "src/parse-gram.c" /* yacc.c:684 */ break; case 89: /* value */ -#line 656 "src/parse-gram.y" /* yacc.c:684 */ +#line 655 "src/parse-gram.y" /* yacc.c:684 */ { switch (((*yyvaluep).value).kind) { @@ -1103,31 +1124,31 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue case muscle_string: fprintf (yyo, "\"%s\"", ((*yyvaluep).value).chars); break; } } -#line 1107 "src/parse-gram.c" /* yacc.c:684 */ +#line 1128 "src/parse-gram.c" /* yacc.c:684 */ break; case 90: /* id */ #line 205 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1113 "src/parse-gram.c" /* yacc.c:684 */ +#line 1134 "src/parse-gram.c" /* yacc.c:684 */ break; case 91: /* id_colon */ #line 206 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s:", ((*yyvaluep).symbol)->tag); } -#line 1119 "src/parse-gram.c" /* yacc.c:684 */ +#line 1140 "src/parse-gram.c" /* yacc.c:684 */ break; case 92: /* symbol */ #line 205 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1125 "src/parse-gram.c" /* yacc.c:684 */ +#line 1146 "src/parse-gram.c" /* yacc.c:684 */ break; case 93: /* string_as_id */ #line 205 "src/parse-gram.y" /* yacc.c:684 */ { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1131 "src/parse-gram.c" /* yacc.c:684 */ +#line 1152 "src/parse-gram.c" /* yacc.c:684 */ break; @@ -1184,7 +1205,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -1569,11 +1590,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyesa, yytype_int16 **yyes, YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1628,7 +1649,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1648,6 +1669,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1821,7 +1843,7 @@ YYLTYPE yylloc = yyloc_default; yychar = YYEMPTY; /* Cause a token to be read. */ /* User initialization code. */ -#line 108 "src/parse-gram.y" /* yacc.c:1429 */ +#line 108 "src/parse-gram.y" /* yacc.c:1433 */ { /* Bison's grammar can initial empty locations, hence a default location is needed. */ @@ -1829,7 +1851,7 @@ YYLTYPE yylloc = yyloc_default; boundary_set (&yylloc.end, current_file, 1, 1); } -#line 1833 "src/parse-gram.c" /* yacc.c:1429 */ +#line 1855 "src/parse-gram.c" /* yacc.c:1433 */ yylsp[0] = yylloc; goto yysetstate; @@ -1904,7 +1926,7 @@ YYLTYPE yylloc = yyloc_default; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; @@ -2015,151 +2037,152 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; - /* Default location. */ + /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc; YY_REDUCE_PRINT (yyn); { int yychar_backup = yychar; switch (yyn) { case 6: -#line 280 "src/parse-gram.y" /* yacc.c:1646 */ +#line 280 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_code_grow (union_seen ? "post_prologue" : "pre_prologue", translate_code ((yyvsp[0].code), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2033 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2056 "src/parse-gram.c" /* yacc.c:1651 */ break; case 7: -#line 286 "src/parse-gram.y" /* yacc.c:1646 */ +#line 286 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_percent_define_ensure ((yyvsp[0].uniqstr), (yylsp[0]), true); } -#line 2041 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2064 "src/parse-gram.c" /* yacc.c:1651 */ break; case 8: -#line 290 "src/parse-gram.y" /* yacc.c:1646 */ +#line 290 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_percent_define_insert ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].value).kind, (yyvsp[0].value).chars, MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2050 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2073 "src/parse-gram.c" /* yacc.c:1651 */ break; case 9: -#line 294 "src/parse-gram.y" /* yacc.c:1646 */ +#line 294 "src/parse-gram.y" /* yacc.c:1651 */ { defines_flag = true; } -#line 2056 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2079 "src/parse-gram.c" /* yacc.c:1651 */ break; case 10: -#line 296 "src/parse-gram.y" /* yacc.c:1646 */ +#line 296 "src/parse-gram.y" /* yacc.c:1651 */ { defines_flag = true; spec_defines_file = xstrdup ((yyvsp[0].code)); } -#line 2065 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2088 "src/parse-gram.c" /* yacc.c:1651 */ break; case 11: -#line 301 "src/parse-gram.y" /* yacc.c:1646 */ +#line 301 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_percent_define_insert ("parse.error", (yylsp[0]), muscle_keyword, "verbose", MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2075 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2098 "src/parse-gram.c" /* yacc.c:1651 */ break; case 12: -#line 306 "src/parse-gram.y" /* yacc.c:1646 */ +#line 306 "src/parse-gram.y" /* yacc.c:1651 */ { expected_sr_conflicts = (yyvsp[0].integer); } -#line 2081 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2104 "src/parse-gram.c" /* yacc.c:1651 */ break; case 13: -#line 307 "src/parse-gram.y" /* yacc.c:1646 */ +#line 307 "src/parse-gram.y" /* yacc.c:1651 */ { expected_rr_conflicts = (yyvsp[0].integer); } -#line 2087 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2110 "src/parse-gram.c" /* yacc.c:1651 */ break; case 14: -#line 308 "src/parse-gram.y" /* yacc.c:1646 */ +#line 308 "src/parse-gram.y" /* yacc.c:1651 */ { spec_file_prefix = (yyvsp[0].code); } -#line 2093 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2116 "src/parse-gram.c" /* yacc.c:1651 */ break; case 15: -#line 310 "src/parse-gram.y" /* yacc.c:1646 */ +#line 310 "src/parse-gram.y" /* yacc.c:1651 */ { nondeterministic_parser = true; glr_parser = true; } -#line 2102 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2125 "src/parse-gram.c" /* yacc.c:1651 */ break; case 16: -#line 315 "src/parse-gram.y" /* yacc.c:1646 */ +#line 315 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_code_grow ("initial_action", translate_code ((yyvsp[0].code), (yylsp[0]), false), (yylsp[0])); code_scanner_last_string_free (); } -#line 2111 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2134 "src/parse-gram.c" /* yacc.c:1651 */ break; case 17: -#line 319 "src/parse-gram.y" /* yacc.c:1646 */ +#line 319 "src/parse-gram.y" /* yacc.c:1651 */ { language_argmatch ((yyvsp[0].code), grammar_prio, (yylsp[-1])); } -#line 2117 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2140 "src/parse-gram.c" /* yacc.c:1651 */ break; case 18: -#line 320 "src/parse-gram.y" /* yacc.c:1646 */ +#line 320 "src/parse-gram.y" /* yacc.c:1651 */ { spec_name_prefix = (yyvsp[0].code); } -#line 2123 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2146 "src/parse-gram.c" /* yacc.c:1651 */ break; case 19: -#line 321 "src/parse-gram.y" /* yacc.c:1646 */ +#line 321 "src/parse-gram.y" /* yacc.c:1651 */ { no_lines_flag = true; } -#line 2129 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2152 "src/parse-gram.c" /* yacc.c:1651 */ break; case 20: -#line 322 "src/parse-gram.y" /* yacc.c:1646 */ +#line 322 "src/parse-gram.y" /* yacc.c:1651 */ { nondeterministic_parser = true; } -#line 2135 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2158 "src/parse-gram.c" /* yacc.c:1651 */ break; case 21: -#line 323 "src/parse-gram.y" /* yacc.c:1646 */ +#line 323 "src/parse-gram.y" /* yacc.c:1651 */ { spec_outfile = (yyvsp[0].code); } -#line 2141 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2164 "src/parse-gram.c" /* yacc.c:1651 */ break; case 22: -#line 324 "src/parse-gram.y" /* yacc.c:1646 */ +#line 324 "src/parse-gram.y" /* yacc.c:1651 */ { current_param = (yyvsp[0].param); } -#line 2147 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2170 "src/parse-gram.c" /* yacc.c:1651 */ break; case 23: -#line 324 "src/parse-gram.y" /* yacc.c:1646 */ +#line 324 "src/parse-gram.y" /* yacc.c:1651 */ { current_param = param_none; } -#line 2153 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2176 "src/parse-gram.c" /* yacc.c:1651 */ break; case 24: -#line 325 "src/parse-gram.y" /* yacc.c:1646 */ +#line 325 "src/parse-gram.y" /* yacc.c:1651 */ { version_check (&(yylsp[0]), (yyvsp[0].code)); } -#line 2159 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2182 "src/parse-gram.c" /* yacc.c:1651 */ break; case 25: -#line 327 "src/parse-gram.y" /* yacc.c:1646 */ +#line 327 "src/parse-gram.y" /* yacc.c:1651 */ { char const *skeleton_user = (yyvsp[0].code); if (strchr (skeleton_user, '/')) @@ -2183,81 +2206,80 @@ yyreduce: } skeleton_arg (skeleton_user, grammar_prio, (yylsp[-1])); } -#line 2187 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2210 "src/parse-gram.c" /* yacc.c:1651 */ break; case 26: -#line 350 "src/parse-gram.y" /* yacc.c:1646 */ +#line 350 "src/parse-gram.y" /* yacc.c:1651 */ { token_table_flag = true; } -#line 2193 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2216 "src/parse-gram.c" /* yacc.c:1651 */ break; case 27: -#line 351 "src/parse-gram.y" /* yacc.c:1646 */ +#line 351 "src/parse-gram.y" /* yacc.c:1651 */ { report_flag |= report_states; } -#line 2199 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2222 "src/parse-gram.c" /* yacc.c:1651 */ break; case 28: -#line 352 "src/parse-gram.y" /* yacc.c:1646 */ +#line 352 "src/parse-gram.y" /* yacc.c:1651 */ { yacc_flag = true; } -#line 2205 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2228 "src/parse-gram.c" /* yacc.c:1651 */ break; case 30: -#line 357 "src/parse-gram.y" /* yacc.c:1646 */ +#line 357 "src/parse-gram.y" /* yacc.c:1651 */ { add_param (current_param, (yyvsp[0].code), (yylsp[0])); } -#line 2211 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2234 "src/parse-gram.c" /* yacc.c:1651 */ break; case 31: -#line 358 "src/parse-gram.y" /* yacc.c:1646 */ +#line 358 "src/parse-gram.y" /* yacc.c:1651 */ { add_param (current_param, (yyvsp[0].code), (yylsp[0])); } -#line 2217 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2240 "src/parse-gram.c" /* yacc.c:1651 */ break; case 34: -#line 370 "src/parse-gram.y" /* yacc.c:1646 */ +#line 370 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2225 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2248 "src/parse-gram.c" /* yacc.c:1651 */ break; case 35: -#line 374 "src/parse-gram.y" /* yacc.c:1646 */ +#line 374 "src/parse-gram.y" /* yacc.c:1651 */ { code_props code; code_props_symbol_action_init (&code, (yyvsp[-1].code), (yylsp[-1])); code_props_translate_code (&code); { - symbol_list *list; - for (list = (yyvsp[0].list); list; list = list->next) + for (symbol_list *list = (yyvsp[0].list); list; list = list->next) symbol_list_code_props_set (list, (yyvsp[-2].code_type), &code); symbol_list_free ((yyvsp[0].list)); } } -#line 2241 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2263 "src/parse-gram.c" /* yacc.c:1651 */ break; case 36: -#line 386 "src/parse-gram.y" /* yacc.c:1646 */ +#line 385 "src/parse-gram.y" /* yacc.c:1651 */ { default_prec = true; } -#line 2249 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2271 "src/parse-gram.c" /* yacc.c:1651 */ break; case 37: -#line 390 "src/parse-gram.y" /* yacc.c:1646 */ +#line 389 "src/parse-gram.y" /* yacc.c:1651 */ { default_prec = false; } -#line 2257 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2279 "src/parse-gram.c" /* yacc.c:1651 */ break; case 38: -#line 394 "src/parse-gram.y" /* yacc.c:1646 */ +#line 393 "src/parse-gram.y" /* yacc.c:1651 */ { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ @@ -2265,100 +2287,100 @@ yyreduce: translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2269 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2291 "src/parse-gram.c" /* yacc.c:1651 */ break; case 39: -#line 402 "src/parse-gram.y" /* yacc.c:1646 */ +#line 401 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_percent_code_grow ((yyvsp[-1].uniqstr), (yylsp[-1]), translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2278 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2300 "src/parse-gram.c" /* yacc.c:1651 */ break; case 40: -#line 412 "src/parse-gram.y" /* yacc.c:1646 */ +#line 411 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.code_type) = destructor; } -#line 2284 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2306 "src/parse-gram.c" /* yacc.c:1651 */ break; case 41: -#line 413 "src/parse-gram.y" /* yacc.c:1646 */ +#line 412 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.code_type) = printer; } -#line 2290 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2312 "src/parse-gram.c" /* yacc.c:1651 */ break; case 42: -#line 423 "src/parse-gram.y" /* yacc.c:1646 */ +#line 422 "src/parse-gram.y" /* yacc.c:1651 */ {} -#line 2296 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2318 "src/parse-gram.c" /* yacc.c:1651 */ break; case 43: -#line 424 "src/parse-gram.y" /* yacc.c:1646 */ - { muscle_code_grow ("union_name", (yyvsp[0].uniqstr), (yylsp[0])); } -#line 2302 "src/parse-gram.c" /* yacc.c:1646 */ +#line 423 "src/parse-gram.y" /* yacc.c:1651 */ + { muscle_percent_define_insert ("api.value.union.name", + (yylsp[0]), muscle_keyword, (yyvsp[0].uniqstr), + MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } +#line 2326 "src/parse-gram.c" /* yacc.c:1651 */ break; case 44: -#line 429 "src/parse-gram.y" /* yacc.c:1646 */ +#line 430 "src/parse-gram.y" /* yacc.c:1651 */ { union_seen = true; muscle_code_grow ("union_members", translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2312 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2336 "src/parse-gram.c" /* yacc.c:1651 */ break; case 45: -#line 440 "src/parse-gram.y" /* yacc.c:1646 */ +#line 441 "src/parse-gram.y" /* yacc.c:1651 */ { current_class = nterm_sym; } -#line 2318 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2342 "src/parse-gram.c" /* yacc.c:1651 */ break; case 46: -#line 441 "src/parse-gram.y" /* yacc.c:1646 */ +#line 442 "src/parse-gram.y" /* yacc.c:1651 */ { current_class = unknown_sym; current_type = NULL; } -#line 2327 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2351 "src/parse-gram.c" /* yacc.c:1651 */ break; case 47: -#line 445 "src/parse-gram.y" /* yacc.c:1646 */ +#line 446 "src/parse-gram.y" /* yacc.c:1651 */ { current_class = token_sym; } -#line 2333 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2357 "src/parse-gram.c" /* yacc.c:1651 */ break; case 48: -#line 446 "src/parse-gram.y" /* yacc.c:1646 */ +#line 447 "src/parse-gram.y" /* yacc.c:1651 */ { current_class = unknown_sym; current_type = NULL; } -#line 2342 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2366 "src/parse-gram.c" /* yacc.c:1651 */ break; case 49: -#line 451 "src/parse-gram.y" /* yacc.c:1646 */ +#line 452 "src/parse-gram.y" /* yacc.c:1651 */ { - symbol_list *list; tag_seen = true; - for (list = (yyvsp[0].list); list; list = list->next) + for (symbol_list *list = (yyvsp[0].list); list; list = list->next) symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1])); symbol_list_free ((yyvsp[0].list)); } -#line 2354 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2377 "src/parse-gram.c" /* yacc.c:1651 */ break; case 50: -#line 462 "src/parse-gram.y" /* yacc.c:1646 */ +#line 462 "src/parse-gram.y" /* yacc.c:1651 */ { - symbol_list *list; ++current_prec; - for (list = (yyvsp[0].list); list; list = list->next) + for (symbol_list *list = (yyvsp[0].list); list; list = list->next) { symbol_type_set (list->content.sym, current_type, (yylsp[-1])); symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2])); @@ -2366,341 +2388,341 @@ yyreduce: symbol_list_free ((yyvsp[0].list)); current_type = NULL; } -#line 2370 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2392 "src/parse-gram.c" /* yacc.c:1651 */ break; case 51: -#line 476 "src/parse-gram.y" /* yacc.c:1646 */ +#line 475 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.assoc) = left_assoc; } -#line 2376 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2398 "src/parse-gram.c" /* yacc.c:1651 */ break; case 52: -#line 477 "src/parse-gram.y" /* yacc.c:1646 */ +#line 476 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.assoc) = right_assoc; } -#line 2382 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2404 "src/parse-gram.c" /* yacc.c:1651 */ break; case 53: -#line 478 "src/parse-gram.y" /* yacc.c:1646 */ +#line 477 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.assoc) = non_assoc; } -#line 2388 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2410 "src/parse-gram.c" /* yacc.c:1651 */ break; case 54: -#line 479 "src/parse-gram.y" /* yacc.c:1646 */ +#line 478 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.assoc) = precedence_assoc; } -#line 2394 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2416 "src/parse-gram.c" /* yacc.c:1651 */ break; case 55: -#line 483 "src/parse-gram.y" /* yacc.c:1646 */ +#line 482 "src/parse-gram.y" /* yacc.c:1651 */ { current_type = NULL; } -#line 2400 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2422 "src/parse-gram.c" /* yacc.c:1651 */ break; case 56: -#line 484 "src/parse-gram.y" /* yacc.c:1646 */ +#line 483 "src/parse-gram.y" /* yacc.c:1651 */ { current_type = (yyvsp[0].uniqstr); tag_seen = true; } -#line 2406 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2428 "src/parse-gram.c" /* yacc.c:1651 */ break; case 57: -#line 490 "src/parse-gram.y" /* yacc.c:1646 */ +#line 489 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2412 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2434 "src/parse-gram.c" /* yacc.c:1651 */ break; case 58: -#line 492 "src/parse-gram.y" /* yacc.c:1646 */ +#line 491 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_append ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } -#line 2418 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2440 "src/parse-gram.c" /* yacc.c:1651 */ break; case 59: -#line 497 "src/parse-gram.y" /* yacc.c:1646 */ +#line 496 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = (yyvsp[0].symbol); symbol_class_set ((yyvsp[0].symbol), token_sym, (yylsp[0]), false); } -#line 2427 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2449 "src/parse-gram.c" /* yacc.c:1651 */ break; case 60: -#line 502 "src/parse-gram.y" /* yacc.c:1646 */ +#line 501 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = (yyvsp[-1].symbol); symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); symbol_class_set ((yyvsp[-1].symbol), token_sym, (yylsp[-1]), false); } -#line 2437 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2459 "src/parse-gram.c" /* yacc.c:1651 */ break; case 61: -#line 512 "src/parse-gram.y" /* yacc.c:1646 */ +#line 511 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2443 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2465 "src/parse-gram.c" /* yacc.c:1651 */ break; case 62: -#line 514 "src/parse-gram.y" /* yacc.c:1646 */ +#line 513 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_append ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } -#line 2449 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2471 "src/parse-gram.c" /* yacc.c:1651 */ break; case 63: -#line 518 "src/parse-gram.y" /* yacc.c:1646 */ +#line 517 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = (yyvsp[0].list); } -#line 2455 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2477 "src/parse-gram.c" /* yacc.c:1651 */ break; case 64: -#line 519 "src/parse-gram.y" /* yacc.c:1646 */ +#line 518 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_append ((yyvsp[-1].list), (yyvsp[0].list)); } -#line 2461 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2483 "src/parse-gram.c" /* yacc.c:1651 */ break; case 65: -#line 523 "src/parse-gram.y" /* yacc.c:1646 */ +#line 522 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2467 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2489 "src/parse-gram.c" /* yacc.c:1651 */ break; case 66: -#line 524 "src/parse-gram.y" /* yacc.c:1646 */ +#line 523 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.list) = symbol_list_type_new ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2473 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2495 "src/parse-gram.c" /* yacc.c:1651 */ break; case 68: -#line 529 "src/parse-gram.y" /* yacc.c:1646 */ +#line 528 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.uniqstr) = uniqstr_new ("*"); } -#line 2479 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2501 "src/parse-gram.c" /* yacc.c:1651 */ break; case 69: -#line 530 "src/parse-gram.y" /* yacc.c:1646 */ +#line 529 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.uniqstr) = uniqstr_new (""); } -#line 2485 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2507 "src/parse-gram.c" /* yacc.c:1651 */ break; case 70: -#line 536 "src/parse-gram.y" /* yacc.c:1646 */ +#line 535 "src/parse-gram.y" /* yacc.c:1651 */ { current_type = (yyvsp[0].uniqstr); tag_seen = true; } -#line 2494 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2516 "src/parse-gram.c" /* yacc.c:1651 */ break; case 71: -#line 541 "src/parse-gram.y" /* yacc.c:1646 */ +#line 540 "src/parse-gram.y" /* yacc.c:1651 */ { symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0]), true); symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0])); } -#line 2503 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2525 "src/parse-gram.c" /* yacc.c:1651 */ break; case 72: -#line 546 "src/parse-gram.y" /* yacc.c:1646 */ +#line 545 "src/parse-gram.y" /* yacc.c:1651 */ { symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true); symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); } -#line 2513 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2535 "src/parse-gram.c" /* yacc.c:1651 */ break; case 73: -#line 552 "src/parse-gram.y" /* yacc.c:1646 */ +#line 551 "src/parse-gram.y" /* yacc.c:1651 */ { symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true); symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc)); } -#line 2523 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2545 "src/parse-gram.c" /* yacc.c:1651 */ break; case 74: -#line 558 "src/parse-gram.y" /* yacc.c:1646 */ +#line 557 "src/parse-gram.y" /* yacc.c:1651 */ { symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2]), true); symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2])); symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1])); symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc)); } -#line 2534 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2556 "src/parse-gram.c" /* yacc.c:1651 */ break; case 81: -#line 588 "src/parse-gram.y" /* yacc.c:1646 */ +#line 587 "src/parse-gram.y" /* yacc.c:1651 */ { yyerrok; } -#line 2542 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2564 "src/parse-gram.c" /* yacc.c:1651 */ break; case 82: -#line 594 "src/parse-gram.y" /* yacc.c:1646 */ +#line 593 "src/parse-gram.y" /* yacc.c:1651 */ { current_lhs ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); } -#line 2548 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2570 "src/parse-gram.c" /* yacc.c:1651 */ break; case 83: -#line 595 "src/parse-gram.y" /* yacc.c:1646 */ +#line 594 "src/parse-gram.y" /* yacc.c:1651 */ { /* Free the current lhs. */ current_lhs (0, (yylsp[-3]), 0); } -#line 2557 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2579 "src/parse-gram.c" /* yacc.c:1651 */ break; case 84: -#line 602 "src/parse-gram.y" /* yacc.c:1646 */ +#line 601 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_end ((yylsp[0])); } -#line 2563 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2585 "src/parse-gram.c" /* yacc.c:1651 */ break; case 85: -#line 603 "src/parse-gram.y" /* yacc.c:1646 */ +#line 602 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_end ((yylsp[0])); } -#line 2569 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2591 "src/parse-gram.c" /* yacc.c:1651 */ break; case 87: -#line 610 "src/parse-gram.y" /* yacc.c:1646 */ +#line 609 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } -#line 2576 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2598 "src/parse-gram.c" /* yacc.c:1651 */ break; case 88: -#line 613 "src/parse-gram.y" /* yacc.c:1646 */ +#line 612 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); } -#line 2582 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2604 "src/parse-gram.c" /* yacc.c:1651 */ break; case 89: -#line 615 "src/parse-gram.y" /* yacc.c:1646 */ - { grammar_current_rule_action_append ((yyvsp[-1].code), (yylsp[-1]), (yyvsp[0].named_ref), false); } -#line 2588 "src/parse-gram.c" /* yacc.c:1646 */ +#line 614 "src/parse-gram.y" /* yacc.c:1651 */ + { grammar_current_rule_action_append ((yyvsp[-1].code), (yylsp[-1]), (yyvsp[0].named_ref), current_type); } +#line 2610 "src/parse-gram.c" /* yacc.c:1651 */ break; case 90: -#line 617 "src/parse-gram.y" /* yacc.c:1646 */ - { grammar_current_rule_action_append ((yyvsp[0].code), (yylsp[0]), NULL, true); } -#line 2594 "src/parse-gram.c" /* yacc.c:1646 */ +#line 616 "src/parse-gram.y" /* yacc.c:1651 */ + { grammar_current_rule_predicate_append ((yyvsp[0].code), (yylsp[0])); } +#line 2616 "src/parse-gram.c" /* yacc.c:1651 */ break; case 91: -#line 619 "src/parse-gram.y" /* yacc.c:1646 */ +#line 618 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_empty_set ((yylsp[0])); } -#line 2600 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2622 "src/parse-gram.c" /* yacc.c:1651 */ break; case 92: -#line 621 "src/parse-gram.y" /* yacc.c:1646 */ +#line 620 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2606 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2628 "src/parse-gram.c" /* yacc.c:1651 */ break; case 93: -#line 623 "src/parse-gram.y" /* yacc.c:1646 */ +#line 622 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); } -#line 2612 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2634 "src/parse-gram.c" /* yacc.c:1651 */ break; case 94: -#line 625 "src/parse-gram.y" /* yacc.c:1646 */ +#line 624 "src/parse-gram.y" /* yacc.c:1651 */ { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2618 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2640 "src/parse-gram.c" /* yacc.c:1651 */ break; case 95: -#line 629 "src/parse-gram.y" /* yacc.c:1646 */ +#line 628 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.named_ref) = 0; } -#line 2624 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2646 "src/parse-gram.c" /* yacc.c:1651 */ break; case 96: -#line 630 "src/parse-gram.y" /* yacc.c:1646 */ +#line 629 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.named_ref) = named_ref_new ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2630 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2652 "src/parse-gram.c" /* yacc.c:1651 */ break; case 98: -#line 641 "src/parse-gram.y" /* yacc.c:1646 */ +#line 640 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.uniqstr) = uniqstr_new ((yyvsp[0].code)); } -#line 2636 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2658 "src/parse-gram.c" /* yacc.c:1651 */ break; case 99: -#line 666 "src/parse-gram.y" /* yacc.c:1646 */ +#line 665 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.value).kind = muscle_keyword; (yyval.value).chars = ""; } -#line 2642 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2664 "src/parse-gram.c" /* yacc.c:1651 */ break; case 100: -#line 667 "src/parse-gram.y" /* yacc.c:1646 */ +#line 666 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.value).kind = muscle_keyword; (yyval.value).chars = (yyvsp[0].uniqstr); } -#line 2648 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2670 "src/parse-gram.c" /* yacc.c:1651 */ break; case 101: -#line 668 "src/parse-gram.y" /* yacc.c:1646 */ +#line 667 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.value).kind = muscle_string; (yyval.value).chars = (yyvsp[0].code); } -#line 2654 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2676 "src/parse-gram.c" /* yacc.c:1651 */ break; case 102: -#line 669 "src/parse-gram.y" /* yacc.c:1646 */ +#line 668 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.value).kind = muscle_code; (yyval.value).chars = strip_braces ((yyvsp[0].code)); } -#line 2660 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2682 "src/parse-gram.c" /* yacc.c:1651 */ break; case 103: -#line 682 "src/parse-gram.y" /* yacc.c:1646 */ +#line 681 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2666 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2688 "src/parse-gram.c" /* yacc.c:1651 */ break; case 104: -#line 684 "src/parse-gram.y" /* yacc.c:1646 */ +#line 683 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = symbol_get (char_name ((yyvsp[0].character)), (yylsp[0])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false); symbol_user_token_number_set ((yyval.symbol), (yyvsp[0].character), (yylsp[0])); } -#line 2676 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2698 "src/parse-gram.c" /* yacc.c:1651 */ break; case 105: -#line 692 "src/parse-gram.y" /* yacc.c:1646 */ +#line 691 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2682 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2704 "src/parse-gram.c" /* yacc.c:1651 */ break; case 108: -#line 704 "src/parse-gram.y" /* yacc.c:1646 */ +#line 703 "src/parse-gram.y" /* yacc.c:1651 */ { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].code)), (yylsp[0])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false); } -#line 2691 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2713 "src/parse-gram.c" /* yacc.c:1651 */ break; case 110: -#line 713 "src/parse-gram.y" /* yacc.c:1646 */ +#line 712 "src/parse-gram.y" /* yacc.c:1651 */ { muscle_code_grow ("epilogue", translate_code ((yyvsp[0].code), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2700 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2722 "src/parse-gram.c" /* yacc.c:1651 */ break; -#line 2704 "src/parse-gram.c" /* yacc.c:1646 */ +#line 2726 "src/parse-gram.c" /* yacc.c:1651 */ default: break; } if (yychar_backup != yychar) @@ -2829,7 +2851,6 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2947,7 +2968,7 @@ yyreturn: #endif return yyresult; } -#line 719 "src/parse-gram.y" /* yacc.c:1906 */ +#line 718 "src/parse-gram.y" /* yacc.c:1910 */ /* Return the location of the left-hand side of a rule whose @@ -2958,7 +2979,6 @@ yyreturn: static YYLTYPE lloc_default (YYLTYPE const *rhs, int n) { - int i; YYLTYPE loc; /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;". @@ -2969,7 +2989,7 @@ lloc_default (YYLTYPE const *rhs, int n) /* Ignore empty nonterminals the start of the right-hand side. Do not bother to ignore them at the end of the right-hand side, since empty nonterminals have the same end as their predecessors. */ - for (i = 1; i <= n; i++) + for (int i = 1; i <= n; i++) if (! equal_boundaries (rhs[i].start, rhs[i].end)) { loc.start = rhs[i].start; @@ -3010,7 +3030,7 @@ translate_code_braceless (char *code, location loc) static void add_param (param_type type, char *decl, location loc) { - static char const alphanum[26 + 26 + 1 + 10] = + static char const alphanum[26 + 26 + 1 + 10 + 1] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_" @@ -3022,18 +3042,18 @@ add_param (param_type type, char *decl, location loc) /* Stop on last actual character. */ for (p = decl; p[1]; p++) if ((p == decl - || ! memchr (alphanum, p[-1], sizeof alphanum)) - && memchr (alphanum, p[0], sizeof alphanum - 10)) + || ! memchr (alphanum, p[-1], sizeof alphanum - 1)) + && memchr (alphanum, p[0], sizeof alphanum - 10 - 1)) name_start = p; /* Strip the surrounding '{' and '}', and any blanks just inside the braces. */ --p; - while (c_isspace ((unsigned char) *p)) + while (c_isspace ((unsigned char) *p)) --p; p[1] = '\0'; ++decl; - while (c_isspace ((unsigned char) *decl)) + while (c_isspace ((unsigned char) *decl)) ++decl; } @@ -3095,6 +3115,8 @@ current_lhs (symbol *sym, location loc, named_ref *ref) { current_lhs_symbol = sym; current_lhs_location = loc; + if (sym) + symbol_location_as_lhs_set (sym, loc); /* In order to simplify memory management, named references for lhs are always assigned by deep copy into the current symbol_list node. This is because a single named-ref in the grammar may diff --git a/contrib/tools/bison/src/parse-gram.h b/contrib/tools/bison/src/parse-gram.h index 09358961d3..8766525cf8 100644 --- a/contrib/tools/bison/src/parse-gram.h +++ b/contrib/tools/bison/src/parse-gram.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0. */ +/* A Bison parser, made by GNU Bison 3.0.5.75-d835. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,11 +48,11 @@ extern int gram_debug; #endif /* "%code requires" blocks. */ -#line 21 "src/parse-gram.y" /* yacc.c:1909 */ +#line 21 "src/parse-gram.y" /* yacc.c:1913 */ #include "symlist.h" #include "symtab.h" -#line 221 "src/parse-gram.y" /* yacc.c:1909 */ +#line 221 "src/parse-gram.y" /* yacc.c:1913 */ typedef enum { @@ -61,10 +61,10 @@ extern int gram_debug; param_parse = 1 << 1, param_both = param_lex | param_parse } param_type; -#line 645 "src/parse-gram.y" /* yacc.c:1909 */ +#line 644 "src/parse-gram.y" /* yacc.c:1913 */ #include "muscle-tab.h" -#line 68 "src/parse-gram.h" /* yacc.c:1909 */ +#line 68 "src/parse-gram.h" /* yacc.c:1913 */ /* Token type. */ #ifndef GRAM_TOKENTYPE @@ -132,30 +132,30 @@ extern int gram_debug; /* Value type. */ #if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED -typedef union GRAM_STYPE GRAM_STYPE; + union GRAM_STYPE { -#line 182 "src/parse-gram.y" /* yacc.c:1909 */ +#line 182 "src/parse-gram.y" /* yacc.c:1913 */ unsigned char character; -#line 186 "src/parse-gram.y" /* yacc.c:1909 */ +#line 186 "src/parse-gram.y" /* yacc.c:1913 */ char *code; -#line 191 "src/parse-gram.y" /* yacc.c:1909 */ +#line 191 "src/parse-gram.y" /* yacc.c:1913 */ uniqstr uniqstr; -#line 199 "src/parse-gram.y" /* yacc.c:1909 */ +#line 199 "src/parse-gram.y" /* yacc.c:1913 */ int integer; -#line 203 "src/parse-gram.y" /* yacc.c:1909 */ +#line 203 "src/parse-gram.y" /* yacc.c:1913 */ symbol *symbol; -#line 208 "src/parse-gram.y" /* yacc.c:1909 */ +#line 208 "src/parse-gram.y" /* yacc.c:1913 */ assoc assoc; -#line 211 "src/parse-gram.y" /* yacc.c:1909 */ +#line 211 "src/parse-gram.y" /* yacc.c:1913 */ symbol_list *list; -#line 214 "src/parse-gram.y" /* yacc.c:1909 */ +#line 214 "src/parse-gram.y" /* yacc.c:1913 */ named_ref *named_ref; -#line 241 "src/parse-gram.y" /* yacc.c:1909 */ +#line 241 "src/parse-gram.y" /* yacc.c:1913 */ param_type param; -#line 409 "src/parse-gram.y" /* yacc.c:1909 */ +#line 408 "src/parse-gram.y" /* yacc.c:1913 */ code_props_type code_type; -#line 647 "src/parse-gram.y" /* yacc.c:1909 */ +#line 646 "src/parse-gram.y" /* yacc.c:1913 */ struct { @@ -163,8 +163,10 @@ code_props_type code_type; muscle_kind kind; } value; -#line 167 "src/parse-gram.h" /* yacc.c:1909 */ +#line 167 "src/parse-gram.h" /* yacc.c:1913 */ }; + +typedef union GRAM_STYPE GRAM_STYPE; # define GRAM_STYPE_IS_TRIVIAL 1 # define GRAM_STYPE_IS_DECLARED 1 #endif diff --git a/contrib/tools/bison/src/print-xml.c b/contrib/tools/bison/src/print-xml.c index e5c25c544f..3f4bc5be87 100644 --- a/contrib/tools/bison/src/print-xml.c +++ b/contrib/tools/bison/src/print-xml.c @@ -1,6 +1,6 @@ /* Print an xml on generated parser, for Bison, - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -65,40 +65,39 @@ print_core (FILE *out, int level, state *s) sitems = itemset; snritems = nitemset; - if (!snritems) { - xml_puts (out, level, "<itemset/>"); - return; - } + if (!snritems) + { + xml_puts (out, level, "<itemset/>"); + return; + } xml_puts (out, level, "<itemset>"); for (i = 0; i < snritems; i++) { bool printed = false; - item_number *sp; - item_number *sp1; - rule_number r; - - sp1 = sp = ritem + sitems[i]; + item_number *sp1 = ritem + sitems[i]; + item_number *sp = sp1; + rule *r; - while (*sp >= 0) + while (0 <= *sp) sp++; - r = item_number_as_rule_number (*sp); - sp = rules[r].rhs; + r = &rules[item_number_as_rule_number (*sp)]; + sp = r->rhs; /* Display the lookahead tokens? */ if (item_number_is_rule_number (*sp1)) { reductions *reds = s->reductions; - int red = state_reduction_find (s, &rules[r]); + int red = state_reduction_find (s, r); /* Print item with lookaheads if there are. */ if (reds->lookahead_tokens && red != -1) { xml_printf (out, level + 1, "<item rule-number=\"%d\" point=\"%d\">", - rules[r].number, sp1 - sp); - state_rule_lookahead_tokens_print_xml (s, &rules[r], + r->number, sp1 - sp); + state_rule_lookahead_tokens_print_xml (s, r, out, level + 2); xml_puts (out, level + 1, "</item>"); printed = true; @@ -106,12 +105,10 @@ print_core (FILE *out, int level, state *s) } if (!printed) - { - xml_printf (out, level + 1, - "<item rule-number=\"%d\" point=\"%d\"/>", - rules[r].number, - sp1 - sp); - } + xml_printf (out, level + 1, + "<item rule-number=\"%d\" point=\"%d\"/>", + r->number, + sp1 - sp); } xml_puts (out, level, "</itemset>"); } @@ -136,10 +133,11 @@ print_transitions (state *s, FILE *out, int level) } /* Nothing to report. */ - if (!n) { - xml_puts (out, level, "<transitions/>"); - return; - } + if (!n) + { + xml_puts (out, level, "<transitions/>"); + return; + } /* Report lookahead tokens and shifts. */ xml_puts (out, level, "<transitions>"); @@ -190,10 +188,11 @@ print_errs (FILE *out, int level, state *s) count = true; /* Nothing to report. */ - if (!count) { - xml_puts (out, level, "<errors/>"); - return; - } + if (!count) + { + xml_puts (out, level, "<errors/>"); + return; + } /* Report lookahead tokens and errors. */ xml_puts (out, level, "<errors>"); @@ -260,7 +259,7 @@ print_reductions (FILE *out, int level, state *s) bitset_set (no_reduce_set, TRANSITION_SYMBOL (trans, i)); for (i = 0; i < s->errs->num; ++i) if (s->errs->symbols[i]) - bitset_set (no_reduce_set, s->errs->symbols[i]->number); + bitset_set (no_reduce_set, s->errs->symbols[i]->content->number); if (default_reduction) report = true; @@ -287,10 +286,11 @@ print_reductions (FILE *out, int level, state *s) } /* Nothing to report. */ - if (!report) { - xml_puts (out, level, "<reductions/>"); - return; - } + if (!report) + { + xml_puts (out, level, "<reductions/>"); + return; + } xml_puts (out, level, "<reductions>"); @@ -388,11 +388,11 @@ print_grammar (FILE *out, int level) /* Terminals */ xml_puts (out, level + 1, "<terminals>"); for (i = 0; i < max_user_token_number + 1; i++) - if (token_translations[i] != undeftoken->number) + if (token_translations[i] != undeftoken->content->number) { char const *tag = symbols[token_translations[i]]->tag; - int precedence = symbols[token_translations[i]]->prec; - assoc associativity = symbols[token_translations[i]]->assoc; + int precedence = symbols[token_translations[i]]->content->prec; + assoc associativity = symbols[token_translations[i]]->content->assoc; xml_indent (out, level + 2); fprintf (out, "<terminal symbol-number=\"%d\" token-number=\"%d\"" @@ -417,7 +417,7 @@ print_grammar (FILE *out, int level) "<nonterminal symbol-number=\"%d\" name=\"%s\"" " usefulness=\"%s\"/>", i, xml_escape (tag), - reduce_nonterminal_useless_in_grammar (i) + reduce_nonterminal_useless_in_grammar (symbols[i]->content) ? "useless-in-grammar" : "useful"); } xml_puts (out, level + 1, "</nonterminals>"); diff --git a/contrib/tools/bison/src/print-xml.h b/contrib/tools/bison/src/print-xml.h index 251c2033b9..abdb76355e 100644 --- a/contrib/tools/bison/src/print-xml.h +++ b/contrib/tools/bison/src/print-xml.h @@ -1,6 +1,6 @@ /* Output an xml of the generated parser, for Bison. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print.c b/contrib/tools/bison/src/print.c index 824bb4ae82..36ad9d34a8 100644 --- a/contrib/tools/bison/src/print.c +++ b/contrib/tools/bison/src/print.c @@ -1,6 +1,6 @@ /* Print information on generated parser, for bison, - Copyright (C) 1984, 1986, 1989, 2000-2005, 2007, 2009-2013 Free + Copyright (C) 1984, 1986, 1989, 2000-2005, 2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -40,14 +40,6 @@ static bitset no_reduce_set; -#if 0 -static void -print_token (int extnum, int token) -{ - fprintf (out, _(" type %d is %s\n"), extnum, tags[token]); -} -#endif - /*---------------------------------------. @@ -72,7 +64,7 @@ print_core (FILE *out, state *s) size_t i; item_number *sitems = s->items; size_t snritems = s->nitems; - symbol *previous_lhs = NULL; + sym_content *previous_lhs = NULL; /* Output all the items of a state, not only its kernel. */ if (report_flag & report_itemsets) @@ -106,8 +98,11 @@ print_core (FILE *out, state *s) for (sp = rules[r].rhs; sp < sp1; sp++) fprintf (out, " %s", symbols[*sp]->tag); fputs (" .", out); - for (/* Nothing */; *sp >= 0; ++sp) - fprintf (out, " %s", symbols[*sp]->tag); + if (0 <= *rules[r].rhs) + for (/* Nothing */; 0 <= *sp; ++sp) + fprintf (out, " %s", symbols[*sp]->tag); + else + fprintf (out, " %%empty"); /* Display the lookahead tokens? */ if (report_flag & report_lookahead_tokens @@ -223,7 +218,8 @@ print_reduction (FILE *out, size_t width, if (!enabled) fputc ('[', out); if (r->number) - fprintf (out, _("reduce using rule %d (%s)"), r->number, r->lhs->tag); + fprintf (out, _("reduce using rule %d (%s)"), r->number, + r->lhs->symbol->tag); else fprintf (out, _("accept")); if (!enabled) @@ -257,7 +253,7 @@ print_reductions (FILE *out, state *s) bitset_set (no_reduce_set, TRANSITION_SYMBOL (trans, i)); for (i = 0; i < s->errs->num; ++i) if (s->errs->symbols[i]) - bitset_set (no_reduce_set, s->errs->symbols[i]->number); + bitset_set (no_reduce_set, s->errs->symbols[i]->content->number); /* Compute the width of the lookahead token column. */ if (default_reduction) @@ -340,6 +336,7 @@ print_reductions (FILE *out, state *s) || (STREQ (default_reductions, "consistent") && default_reduction_only) || (reds->num == 1 && reds->rules[0]->number == 0)); + (void) default_reduction_only; free (default_reductions); } } @@ -397,27 +394,30 @@ print_state (FILE *out, state *s) static void -print_grammar (FILE *out) +print_terminal_symbols (FILE *out) { symbol_number i; - char buffer[90]; - int column = 0; - - grammar_rules_print (out); /* TERMINAL (type #) : rule #s terminal is on RHS */ fprintf (out, "%s\n\n", _("Terminals, with rules where they appear")); for (i = 0; i < max_user_token_number + 1; i++) - if (token_translations[i] != undeftoken->number) + if (token_translations[i] != undeftoken->content->number) { const char *tag = symbols[token_translations[i]]->tag; + int column = strlen (tag); + char buffer[90]; rule_number r; item_number *rhsp; buffer[0] = 0; - column = strlen (tag); fputs (tag, out); END_TEST (65); + if (symbols[token_translations[i]]->content->type_name) + { + column += fprintf (out, " <%s>", + symbols[token_translations[i]]->content->type_name); + END_TEST (65); + } sprintf (buffer, " (%d)", i); for (r = 0; r < nrules; r++) @@ -431,14 +431,23 @@ print_grammar (FILE *out) fprintf (out, "%s\n", buffer); } fputs ("\n\n", out); +} + +static void +print_nonterminal_symbols (FILE *out) +{ + symbol_number i; fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear")); for (i = ntokens; i < nsyms; i++) { + const char *tag = symbols[i]->tag; + int column = strlen (tag); int left_count = 0, right_count = 0; rule_number r; - const char *tag = symbols[i]->tag; + char buffer[90]; + buffer[0] = 0; for (r = 0; r < nrules; r++) { @@ -453,9 +462,10 @@ print_grammar (FILE *out) } } - buffer[0] = 0; fputs (tag, out); - column = strlen (tag); + if (symbols[i]->content->type_name) + column += fprintf (out, " <%s>", + symbols[i]->content->type_name); sprintf (buffer, " (%d)", i); END_TEST (0); @@ -499,8 +509,6 @@ print_grammar (FILE *out) void print_results (void) { - state_number i; - /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but that conflicts with Posix. */ FILE *out = xfopen (spec_verbose_file, "w"); @@ -511,7 +519,9 @@ print_results (void) rule_useless_in_parser_p); conflicts_output (out); - print_grammar (out); + grammar_rules_print (out); + print_terminal_symbols (out); + print_nonterminal_symbols (out); /* If the whole state item sets, not only the kernels, are wanted, 'closure' will be run, which needs memory allocation/deallocation. */ @@ -519,8 +529,11 @@ print_results (void) new_closure (nritems); /* Storage for print_reductions. */ no_reduce_set = bitset_create (ntokens, BITSET_FIXED); - for (i = 0; i < nstates; i++) - print_state (out, states[i]); + { + state_number i; + for (i = 0; i < nstates; i++) + print_state (out, states[i]); + } bitset_free (no_reduce_set); if (report_flag & report_itemsets) free_closure (); diff --git a/contrib/tools/bison/src/print.h b/contrib/tools/bison/src/print.h index e1e254a9bc..61bc20552f 100644 --- a/contrib/tools/bison/src/print.h +++ b/contrib/tools/bison/src/print.h @@ -1,6 +1,6 @@ /* Print information on generated parser, for bison, - Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print_graph.c b/contrib/tools/bison/src/print_graph.c index 7e429dbd10..15d6dd572e 100644 --- a/contrib/tools/bison/src/print_graph.c +++ b/contrib/tools/bison/src/print_graph.c @@ -1,6 +1,7 @@ /* Output a graph of the generated parser, for Bison. - Copyright (C) 2001-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -46,7 +47,7 @@ static void print_core (struct obstack *oout, state *s) { item_number const *sitems = s->items; - symbol *previous_lhs = NULL; + sym_content *previous_lhs = NULL; size_t i; size_t snritems = s->nitems; @@ -72,11 +73,12 @@ print_core (struct obstack *oout, state *s) r = &rules[item_number_as_rule_number (*sp)]; obstack_printf (oout, "%3d ", r->number); - if (previous_lhs && UNIQSTR_EQ (previous_lhs->tag, r->lhs->tag)) + if (previous_lhs && UNIQSTR_EQ (previous_lhs->symbol->tag, + r->lhs->symbol->tag)) obstack_printf (oout, "%*s| ", - (int) strlen (previous_lhs->tag), ""); + (int) strlen (previous_lhs->symbol->tag), ""); else - obstack_printf (oout, "%s: ", escape (r->lhs->tag)); + obstack_printf (oout, "%s: ", escape (r->lhs->symbol->tag)); previous_lhs = r->lhs; for (sp = r->rhs; sp < sp1; sp++) @@ -84,8 +86,11 @@ print_core (struct obstack *oout, state *s) obstack_1grow (oout, '.'); - for (/* Nothing */; *sp >= 0; ++sp) - obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); + if (0 <= *r->rhs) + for (/* Nothing */; *sp >= 0; ++sp) + obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); + else + obstack_printf (oout, " %%empty"); /* Experimental feature: display the lookahead tokens. */ if (report_flag & report_lookahead_tokens diff --git a/contrib/tools/bison/src/print_graph.h b/contrib/tools/bison/src/print_graph.h index 073ae988b6..4081b63d86 100644 --- a/contrib/tools/bison/src/print_graph.h +++ b/contrib/tools/bison/src/print_graph.h @@ -1,6 +1,7 @@ /* Output a graph of the generated parser, for Bison. - Copyright (C) 2000, 2006, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000, 2006, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/reader.c b/contrib/tools/bison/src/reader.c index 95c595ed4e..664dea7101 100644 --- a/contrib/tools/bison/src/reader.c +++ b/contrib/tools/bison/src/reader.c @@ -1,7 +1,7 @@ /* Input parser for Bison Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000-2003, 2005-2007, - 2009-2013 Free Software Foundation, Inc. + 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -78,13 +78,13 @@ grammar_start_symbol_set (symbol *sym, location loc) static int get_merge_function (uniqstr name) { + if (! glr_parser) + return 0; + merger_list *syms; merger_list head; int n; - if (! glr_parser) - return 0; - head.next = merge_functions; for (syms = &head, n = 1; syms->next; syms = syms->next, n += 1) if (UNIQSTR_EQ (name, syms->next->name)) @@ -111,12 +111,12 @@ get_merge_function (uniqstr name) static void record_merge_function_type (int merger, uniqstr type, location declaration_loc) { - int merger_find; - merger_list *merge_function; - if (merger <= 0) return; + int merger_find; + merger_list *merge_function; + if (type == NULL) type = uniqstr_new (""); @@ -227,26 +227,24 @@ void grammar_current_rule_begin (symbol *lhs, location loc, named_ref *lhs_name) { - symbol_list* p; - /* Start a new rule and record its lhs. */ ++nrules; previous_rule_end = grammar_end; - p = grammar_symbol_append (lhs, loc); + symbol_list *p = grammar_symbol_append (lhs, loc); if (lhs_name) assign_named_ref (p, named_ref_copy (lhs_name)); current_rule = grammar_end; /* Mark the rule's lhs as a nonterminal if not already so. */ - if (lhs->class == unknown_sym) + if (lhs->content->class == unknown_sym) { - lhs->class = nterm_sym; - lhs->number = nvars; + lhs->content->class = nterm_sym; + lhs->content->number = nvars; ++nvars; } - else if (lhs->class == token_sym) + else if (lhs->content->class == token_sym) complain (&loc, complaint, _("rule given for %s, which is a token"), lhs->tag); } @@ -292,15 +290,15 @@ grammar_rule_check (const symbol_list *r) Don't worry about the default action if $$ is untyped, since $$'s value can't be used. */ - if (!r->action_props.code && r->content.sym->type_name) + if (!r->action_props.code && r->content.sym->content->type_name) { symbol *first_rhs = r->next->content.sym; /* If $$ is being set in default way, report if any type mismatch. */ if (first_rhs) { - char const *lhs_type = r->content.sym->type_name; + char const *lhs_type = r->content.sym->content->type_name; const char *rhs_type = - first_rhs->type_name ? first_rhs->type_name : ""; + first_rhs->content->type_name ? first_rhs->content->type_name : ""; if (!UNIQSTR_EQ (lhs_type, rhs_type)) complain (&r->location, Wother, _("type clash on default action: <%s> != <%s>"), @@ -314,9 +312,8 @@ grammar_rule_check (const symbol_list *r) /* Check that symbol values that should be used are in fact used. */ { - symbol_list const *l = r; int n = 0; - for (; l && l->content.sym; l = l->next, ++n) + for (symbol_list const *l = r; l && l->content.sym; l = l->next, ++n) { bool midrule_warning = false; if (!l->action_props.is_value_used @@ -350,9 +347,15 @@ grammar_rule_check (const symbol_list *r) it for char literals and strings, which are always tokens. */ if (r->ruleprec && r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"' - && r->ruleprec->status != declared && !r->ruleprec->prec) + && r->ruleprec->content->status != declared + && !r->ruleprec->content->prec) complain (&r->location, Wother, _("token for %%prec is not defined: %s"), r->ruleprec->tag); + + /* Check that the (main) action was not typed. */ + if (r->action_props.type) + complain (&r->location, Wother, + _("only midrule actions can be typed: %s"), r->action_props.type); } @@ -370,7 +373,7 @@ grammar_current_rule_end (location loc) /*-------------------------------------------------------------------. -| The previous action turns out the be a mid-rule action. Attach it | +| The previous action turns out to be a mid-rule action. Attach it | | to the current rule, i.e., create a dummy symbol, attach it this | | mid-rule action, and append this dummy nonterminal to the current | | rule. | @@ -387,6 +390,8 @@ grammar_midrule_action (void) action. Create the MIDRULE. */ location dummy_location = current_rule->action_props.location; symbol *dummy = dummy_symbol_get (dummy_location); + symbol_type_set(dummy, + current_rule->action_props.type, current_rule->action_props.location); symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location); /* Remember named_ref of previous action. */ @@ -401,7 +406,9 @@ grammar_midrule_action (void) code_props_rule_action_init (&midrule->action_props, current_rule->action_props.code, current_rule->action_props.location, - midrule, 0, + midrule, + /* name_ref */ NULL, + /* type */ NULL, current_rule->action_props.is_predicate); code_props_none_init (¤t_rule->action_props); @@ -511,28 +518,41 @@ void grammar_current_rule_symbol_append (symbol *sym, location loc, named_ref *name) { - symbol_list *p; if (current_rule->action_props.code) grammar_midrule_action (); - p = grammar_symbol_append (sym, loc); + symbol_list *p = grammar_symbol_append (sym, loc); if (name) assign_named_ref (p, name); - if (sym->status == undeclared || sym->status == used) - sym->status = needed; + if (sym->content->status == undeclared || sym->content->status == used) + sym->content->status = needed; } -/* Attach an ACTION to the current rule. */ - void grammar_current_rule_action_append (const char *action, location loc, - named_ref *name, bool is_predicate) + named_ref *name, uniqstr type) { if (current_rule->action_props.code) grammar_midrule_action (); + if (type) + complain (&loc, Wyacc, + _("POSIX Yacc does not support typed midrule actions")); /* After all symbol declarations have been parsed, packgram invokes code_props_translate_code. */ code_props_rule_action_init (¤t_rule->action_props, action, loc, - current_rule, name, is_predicate); + current_rule, + name, type, + /* is_predicate */ false); +} + +void +grammar_current_rule_predicate_append (const char *pred, location loc) +{ + if (current_rule->action_props.code) + grammar_midrule_action (); + code_props_rule_action_init (¤t_rule->action_props, pred, loc, + current_rule, + NULL, NULL, + /* is_predicate */ true); } @@ -544,9 +564,8 @@ grammar_current_rule_action_append (const char *action, location loc, static void packgram (void) { - unsigned int itemno = 0; + unsigned itemno = 0; rule_number ruleno = 0; - symbol_list *p; ritem = xnmalloc (nritems + 1, sizeof *ritem); @@ -555,14 +574,14 @@ packgram (void) rules = xnmalloc (nrules, sizeof *rules); - for (p = grammar; p; p = p->next) + for (symbol_list *p = grammar; p; p = p->next) { symbol *ruleprec = p->ruleprec; - record_merge_function_type (p->merger, p->content.sym->type_name, + record_merge_function_type (p->merger, p->content.sym->content->type_name, p->merger_declaration_location); rules[ruleno].user_number = ruleno; rules[ruleno].number = ruleno; - rules[ruleno].lhs = p->content.sym; + rules[ruleno].lhs = p->content.sym->content; rules[ruleno].rhs = ritem + itemno; rules[ruleno].prec = NULL; rules[ruleno].dprec = p->dprec; @@ -604,11 +623,11 @@ packgram (void) /* item_number = symbol_number. But the former needs to contain more: negative rule numbers. */ ritem[itemno++] = - symbol_number_as_item_number (p->content.sym->number); + symbol_number_as_item_number (p->content.sym->content->number); /* A rule gets by default the precedence and associativity of its last token. */ - if (p->content.sym->class == token_sym && default_prec) - rules[ruleno].prec = p->content.sym; + if (p->content.sym->content->class == token_sym && default_prec) + rules[ruleno].prec = p->content.sym->content; } } @@ -616,8 +635,8 @@ packgram (void) the specified symbol's precedence replaces the default. */ if (ruleprec) { - rules[ruleno].precsym = ruleprec; - rules[ruleno].prec = ruleprec; + rules[ruleno].precsym = ruleprec->content; + rules[ruleno].prec = ruleprec->content; } /* An item ends by the rule number (negated). */ ritem[itemno++] = rule_number_as_item_number (ruleno); @@ -647,19 +666,19 @@ reader (void) /* Construct the accept symbol. */ accept = symbol_get ("$accept", empty_location); - accept->class = nterm_sym; - accept->number = nvars++; + accept->content->class = nterm_sym; + accept->content->number = nvars++; /* Construct the error token */ errtoken = symbol_get ("error", empty_location); - errtoken->class = token_sym; - errtoken->number = ntokens++; + errtoken->content->class = token_sym; + errtoken->content->number = ntokens++; /* Construct a token that represents all undefined literal tokens. It is always token number 2. */ undeftoken = symbol_get ("$undefined", empty_location); - undeftoken->class = token_sym; - undeftoken->number = ntokens++; + undeftoken->content->class = token_sym; + undeftoken->content->number = ntokens++; gram_in = xfopen (grammar_file, "r"); @@ -704,6 +723,20 @@ prepare_percent_define_front_end_variables (void) } } +/* Find the first LHS which is not a dummy. */ + +static symbol * +find_start_symbol (void) +{ + symbol_list *res = grammar; + /* Skip all the possible dummy rules of the first rule. */ + for (; symbol_is_dummy (res->content.sym); res = res->next) + /* Skip the LHS, and then all the RHS of the dummy rule. */ + for (res = res->next; res->content.sym; res = res->next) + continue; + return res->content.sym; +} + /*-------------------------------------------------------------. | Check the grammar that has just been read, and convert it to | @@ -721,10 +754,10 @@ check_and_convert_grammar (void) if (!endtoken) { endtoken = symbol_get ("$end", empty_location); - endtoken->class = token_sym; - endtoken->number = 0; + endtoken->content->class = token_sym; + endtoken->content->number = 0; /* Value specified by POSIX. */ - endtoken->user_token_number = 0; + endtoken->content->user_token_number = 0; } /* Report any undefined symbols and consider them nonterminals. */ @@ -733,19 +766,8 @@ check_and_convert_grammar (void) /* Find the start symbol if no %start. */ if (!start_flag) { - symbol_list *node; - for (node = grammar; - node != NULL && symbol_is_dummy (node->content.sym); - node = node->next) - { - for (node = node->next; - node != NULL && node->content.sym != NULL; - node = node->next) - ; - } - aver (node != NULL); - grammar_start_symbol_set (node->content.sym, - node->content.sym->location); + symbol *start = find_start_symbol (); + grammar_start_symbol_set (start, start->location); } /* Insert the initial rule, whose line is that of the first rule @@ -782,11 +804,8 @@ check_and_convert_grammar (void) rule. For the same reason, all the 'used' flags must be set before checking whether to remove '$' from any midrule symbol name (also in packgram). */ - { - symbol_list *sym; - for (sym = grammar; sym; sym = sym->next) - code_props_translate_code (&sym->action_props); - } + for (symbol_list *sym = grammar; sym; sym = sym->next) + code_props_translate_code (&sym->action_props); /* Convert the grammar into the format described in gram.h. */ packgram (); diff --git a/contrib/tools/bison/src/reader.h b/contrib/tools/bison/src/reader.h index ba6ffe6edc..70128be09d 100644 --- a/contrib/tools/bison/src/reader.h +++ b/contrib/tools/bison/src/reader.h @@ -1,6 +1,6 @@ /* Input parser for Bison - Copyright (C) 2000-2003, 2005-2007, 2009-2013 Free Software + Copyright (C) 2000-2003, 2005-2007, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -54,8 +54,11 @@ void grammar_current_rule_dprec_set (int dprec, location loc); void grammar_current_rule_merge_set (uniqstr name, location loc); void grammar_current_rule_symbol_append (symbol *sym, location loc, named_ref *nref); +/* Attach an ACTION to the current rule. */ void grammar_current_rule_action_append (const char *action, location loc, - named_ref *nref, bool); + named_ref *nref, uniqstr tag); +/* Attach a PREDICATE to the current rule. */ +void grammar_current_rule_predicate_append (const char *predicate, location loc); void reader (void); void free_merger_functions (void); diff --git a/contrib/tools/bison/src/reduce.c b/contrib/tools/bison/src/reduce.c index eea11b1e20..c5013a9e05 100644 --- a/contrib/tools/bison/src/reduce.c +++ b/contrib/tools/bison/src/reduce.c @@ -1,6 +1,6 @@ /* Grammar reduction for Bison. - Copyright (C) 1988-1989, 2000-2003, 2005-2013 Free Software + Copyright (C) 1988-1989, 2000-2003, 2005-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -39,7 +39,7 @@ #include "reduce.h" #include "symtab.h" -/* Set of all nonterminals which are not useless. */ +/* Set of all nonterminals whose language is not empty. */ static bitset N; /* Set of all rules which have no useless nonterminals in their RHS. */ @@ -52,11 +52,18 @@ static bitset V; 'useless', but no warning should be issued). */ static bitset V1; -static rule_number nuseful_productions; -rule_number nuseless_productions; -static int nuseful_nonterminals; -symbol_number nuseless_nonterminals; +static unsigned nuseful_productions; +unsigned nuseless_productions; +static unsigned nuseful_nonterminals; +unsigned nuseless_nonterminals; +#define bitset_swap(Lhs, Rhs) \ + do { \ + bitset lhs__ = Lhs; \ + Lhs = Rhs; \ + Rhs = lhs__; \ + } while (0) + /*-------------------------------------------------------------------. | Another way to do this would be with a set for each production and | | then do subset tests against N0, but even for the C grammar the | @@ -71,7 +78,7 @@ useful_production (rule_number r, bitset N0) /* A production is useful if all of the nonterminals in its appear in the set of useful nonterminals. */ - for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp) + for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) if (ISVAR (*rhsp) && !bitset_test (N0, *rhsp - ntokens)) return false; return true; @@ -85,14 +92,10 @@ useful_production (rule_number r, bitset N0) static void useless_nonterminals (void) { - bitset Np, Ns; - rule_number r; - /* N is set as built. Np is set being built this iteration. P is set of all productions which have a RHS all in N. */ - Np = bitset_create (nvars, BITSET_FIXED); - + bitset Np = bitset_create (nvars, BITSET_FIXED); /* The set being computed is a set of nonterminals which can derive the empty string or strings consisting of all terminals. At each @@ -112,8 +115,9 @@ useless_nonterminals (void) while (1) { + rule_number r; bitset_copy (Np, N); - for (r = 0; r < nrules; r++) + for (r = 0; r < nrules; ++r) if (!bitset_test (P, r) && useful_production (r, N)) { @@ -122,9 +126,7 @@ useless_nonterminals (void) } if (bitset_equal_p (N, Np)) break; - Ns = Np; - Np = N; - N = Ns; + bitset_swap (N, Np); } bitset_free (N); N = Np; @@ -134,8 +136,6 @@ useless_nonterminals (void) static void inaccessable_symbols (void) { - bitset Vp, Vs, Pp; - /* Find out which productions are reachable and which symbols are used. Starting with an empty set of productions and a set of symbols which only has the start symbol in it, iterate over all @@ -159,46 +159,43 @@ inaccessable_symbols (void) terminals are printed (if running in verbose mode) so that the user can know. */ - Vp = bitset_create (nsyms, BITSET_FIXED); - Pp = bitset_create (nrules, BITSET_FIXED); + bitset Vp = bitset_create (nsyms, BITSET_FIXED); + bitset Pp = bitset_create (nrules, BITSET_FIXED); /* If the start symbol isn't useful, then nothing will be useful. */ - if (bitset_test (N, accept->number - ntokens)) + if (bitset_test (N, accept->content->number - ntokens)) { - bitset_set (V, accept->number); + bitset_set (V, accept->content->number); while (1) { rule_number r; bitset_copy (Vp, V); - for (r = 0; r < nrules; r++) - { - if (!bitset_test (Pp, r) - && bitset_test (P, r) - && bitset_test (V, rules[r].lhs->number)) - { - item_number *rhsp; - for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++) - if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens)) - bitset_set (Vp, *rhsp); - bitset_set (Pp, r); - } - } + for (r = 0; r < nrules; ++r) + if (!bitset_test (Pp, r) + && bitset_test (P, r) + && bitset_test (V, rules[r].lhs->number)) + { + item_number *rhsp; + for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) + if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens)) + bitset_set (Vp, *rhsp); + bitset_set (Pp, r); + } if (bitset_equal_p (V, Vp)) break; - Vs = Vp; - Vp = V; - V = Vs; + bitset_swap (V, Vp); } } bitset_free (V); V = Vp; - /* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */ - bitset_set (V, endtoken->number); /* end-of-input token */ - bitset_set (V, errtoken->number); /* error token */ - bitset_set (V, undeftoken->number); /* some undefined token */ + /* These tokens (numbered 0, 1, and 2) are internal to Bison. + Consider them useful. */ + bitset_set (V, endtoken->content->number); /* end-of-input token */ + bitset_set (V, errtoken->content->number); /* error token */ + bitset_set (V, undeftoken->content->number); /* some undefined token */ bitset_free (P); P = Pp; @@ -209,9 +206,8 @@ inaccessable_symbols (void) nuseful_nonterminals = 0; { symbol_number i; - for (i = ntokens; i < nsyms; i++) - if (bitset_test (V, i)) - nuseful_nonterminals++; + for (i = ntokens; i < nsyms; ++i) + nuseful_nonterminals += bitset_test (V, i); } nuseless_nonterminals = nvars - nuseful_nonterminals; @@ -236,7 +232,7 @@ reduce_grammar_tables (void) /* Report and flag useless productions. */ { rule_number r; - for (r = 0; r < nrules; r++) + for (r = 0; r < nrules; ++r) rules[r].useful = bitset_test (P, r); grammar_rules_useless_report (_("rule useless in grammar")); } @@ -257,8 +253,8 @@ reduce_grammar_tables (void) for (r = 0; r < nrules; ++r) { item_number *rhsp = rules[r].rhs; - for (/* Nothing. */; *rhsp >= 0; ++rhsp) - /* Nothing. */; + for (/* Nothing. */; 0 <= *rhsp; ++rhsp) + continue; *rhsp = rule_number_as_item_number (r); rules[r].number = r; } @@ -289,31 +285,33 @@ nonterminals_reduce (void) afterwards. Kept for later report. */ symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap); - symbol_number n = ntokens; - symbol_number i; - for (i = ntokens; i < nsyms; i++) - if (bitset_test (V, i)) - nontermmap[i - ntokens] = n++; - for (i = ntokens; i < nsyms; i++) - if (!bitset_test (V, i)) - { + { + symbol_number n = ntokens; + symbol_number i; + for (i = ntokens; i < nsyms; ++i) + if (bitset_test (V, i)) nontermmap[i - ntokens] = n++; - if (symbols[i]->status != used) - complain (&symbols[i]->location, Wother, - _("nonterminal useless in grammar: %s"), - symbols[i]->tag); - } + for (i = ntokens; i < nsyms; ++i) + if (!bitset_test (V, i)) + { + nontermmap[i - ntokens] = n++; + if (symbols[i]->content->status != used) + complain (&symbols[i]->location, Wother, + _("nonterminal useless in grammar: %s"), + symbols[i]->tag); + } + } /* Shuffle elements of tables indexed by symbol number. */ { symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted); - - for (i = ntokens; i < nsyms; i++) - symbols[i]->number = nontermmap[i - ntokens]; - for (i = ntokens; i < nsyms; i++) + symbol_number i; + for (i = ntokens; i < nsyms; ++i) + symbols[i]->content->number = nontermmap[i - ntokens]; + for (i = ntokens; i < nsyms; ++i) symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i]; - for (i = ntokens; i < nsyms; i++) + for (i = ntokens; i < nsyms; ++i) symbols[i] = symbols_sorted[i - ntokens]; free (symbols_sorted); } @@ -323,12 +321,12 @@ nonterminals_reduce (void) for (r = 0; r < nrules; ++r) { item_number *rhsp; - for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp) + for (rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) if (ISVAR (*rhsp)) *rhsp = symbol_number_as_item_number (nontermmap[*rhsp - ntokens]); } - accept->number = nontermmap[accept->number - ntokens]; + accept->content->number = nontermmap[accept->content->number - ntokens]; } nsyms -= nuseless_nonterminals; @@ -345,7 +343,7 @@ nonterminals_reduce (void) void reduce_output (FILE *out) { - if (nuseless_nonterminals > 0) + if (nuseless_nonterminals) { int i; fprintf (out, "%s\n\n", _("Nonterminals useless in grammar")); @@ -357,7 +355,7 @@ reduce_output (FILE *out) { bool b = false; int i; - for (i = 0; i < ntokens; i++) + for (i = 0; i < ntokens; ++i) if (reduce_token_unused_in_grammar (i)) { if (!b) @@ -369,7 +367,7 @@ reduce_output (FILE *out) fputs ("\n\n", out); } - if (nuseless_productions > 0) + if (nuseless_productions) grammar_rules_partial_print (out, _("Rules useless in grammar"), rule_useless_in_grammar_p); } @@ -382,12 +380,12 @@ reduce_output (FILE *out) static void reduce_print (void) { - if (nuseless_nonterminals > 0) + if (nuseless_nonterminals) complain (NULL, Wother, ngettext ("%d nonterminal useless in grammar", "%d nonterminals useless in grammar", nuseless_nonterminals), nuseless_nonterminals); - if (nuseless_productions > 0) + if (nuseless_productions) complain (NULL, Wother, ngettext ("%d rule useless in grammar", "%d rules useless in grammar", nuseless_productions), @@ -397,8 +395,6 @@ reduce_print (void) void reduce_grammar (void) { - bool reduced; - /* Allocate the global sets used to compute the reduced grammar */ N = bitset_create (nvars, BITSET_FIXED); @@ -409,13 +405,13 @@ reduce_grammar (void) useless_nonterminals (); inaccessable_symbols (); - reduced = (nuseless_nonterminals + nuseless_productions > 0); - if (!reduced) + /* Did we reduce something? */ + if (!nuseless_nonterminals && !nuseless_productions) return; reduce_print (); - if (!bitset_test (N, accept->number - ntokens)) + if (!bitset_test (N, accept->content->number - ntokens)) complain (&startsymbol_location, fatal, _("start symbol %s does not derive any sentence"), startsymbol->tag); @@ -423,9 +419,9 @@ reduce_grammar (void) /* First reduce the nonterminals, as they renumber themselves in the whole grammar. If you change the order, nonterms would be renumbered only in the reduced grammar. */ - if (nuseless_nonterminals > 0) + if (nuseless_nonterminals) nonterminals_reduce (); - if (nuseless_productions > 0) + if (nuseless_productions) reduce_grammar_tables (); if (trace_flag & trace_grammar) @@ -446,10 +442,11 @@ reduce_token_unused_in_grammar (symbol_number i) } bool -reduce_nonterminal_useless_in_grammar (symbol_number i) +reduce_nonterminal_useless_in_grammar (const sym_content *sym) { - aver (ntokens <= i && i < nsyms + nuseless_nonterminals); - return nsyms <= i; + symbol_number n = sym->number; + aver (ntokens <= n && n < nsyms + nuseless_nonterminals); + return nsyms <= n; } /*-----------------------------------------------------------. diff --git a/contrib/tools/bison/src/reduce.h b/contrib/tools/bison/src/reduce.h index bc12ed0e50..b1baa892bf 100644 --- a/contrib/tools/bison/src/reduce.h +++ b/contrib/tools/bison/src/reduce.h @@ -1,7 +1,7 @@ /* Grammar reduction for Bison. - Copyright (C) 2000-2002, 2007, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2000-2002, 2007, 2009-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -24,9 +24,14 @@ void reduce_grammar (void); void reduce_output (FILE *out); bool reduce_token_unused_in_grammar (symbol_number i); -bool reduce_nonterminal_useless_in_grammar (symbol_number i); + +/** Whether symbol \a i is useless in the grammar. + * \pre reduce_grammar was called before. + */ +bool reduce_nonterminal_useless_in_grammar (const sym_content *sym); + void reduce_free (void); -extern symbol_number nuseless_nonterminals; -extern rule_number nuseless_productions; +extern unsigned nuseless_nonterminals; +extern unsigned nuseless_productions; #endif /* !REDUCE_H_ */ diff --git a/contrib/tools/bison/src/relation.c b/contrib/tools/bison/src/relation.c index 5746eca704..148f55400c 100644 --- a/contrib/tools/bison/src/relation.c +++ b/contrib/tools/bison/src/relation.c @@ -1,7 +1,7 @@ /* Binary relations. - Copyright (C) 2002, 2004-2005, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002, 2004-2005, 2009-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -34,10 +34,10 @@ relation_print (relation r, relation_node size, FILE *out) for (i = 0; i < size; ++i) { - fprintf (out, "%3lu: ", (unsigned long int) i); + fprintf (out, "%3lu: ", (unsigned long) i); if (r[i]) for (j = 0; r[i][j] != END_NODE; ++j) - fprintf (out, "%3lu ", (unsigned long int) r[i][j]); + fprintf (out, "%3lu ", (unsigned long) r[i][j]); fputc ('\n', out); } fputc ('\n', out); diff --git a/contrib/tools/bison/src/relation.h b/contrib/tools/bison/src/relation.h index b44e1a7f98..cc940f93e4 100644 --- a/contrib/tools/bison/src/relation.h +++ b/contrib/tools/bison/src/relation.h @@ -1,6 +1,7 @@ /* Binary relations. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/scan-code.c b/contrib/tools/bison/src/scan-code.c index 971f30241f..14e7366d89 100644 --- a/contrib/tools/bison/src/scan-code.c +++ b/contrib/tools/bison/src/scan-code.c @@ -1,22 +1,27 @@ -#line 2 "src/scan-code.c" +#line 1 "src/scan-code.c" -#line 4 "src/scan-code.c" +#line 3 "src/scan-code.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ /* %not-for-header */ - /* %if-c-only */ /* %if-not-reentrant */ #define yy_create_buffer code__create_buffer #define yy_delete_buffer code__delete_buffer -#define yy_flex_debug code__flex_debug +#define yy_scan_buffer code__scan_buffer +#define yy_scan_string code__scan_string +#define yy_scan_bytes code__scan_bytes #define yy_init_buffer code__init_buffer #define yy_flush_buffer code__flush_buffer #define yy_load_buffer_state code__load_buffer_state #define yy_switch_to_buffer code__switch_to_buffer +#define yypush_buffer_state code_push_buffer_state +#define yypop_buffer_state code_pop_buffer_state +#define yyensure_buffer_stack code_ensure_buffer_stack +#define yy_flex_debug code__flex_debug #define yyin code_in #define yyleng code_leng #define yylex code_lex @@ -35,8 +40,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -45,11 +50,244 @@ /* %endif */ /* %if-c-only */ - +#ifdef yy_create_buffer +#define code__create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer code__create_buffer +#endif + +#ifdef yy_delete_buffer +#define code__delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer code__delete_buffer +#endif + +#ifdef yy_scan_buffer +#define code__scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer code__scan_buffer +#endif + +#ifdef yy_scan_string +#define code__scan_string_ALREADY_DEFINED +#else +#define yy_scan_string code__scan_string +#endif + +#ifdef yy_scan_bytes +#define code__scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes code__scan_bytes +#endif + +#ifdef yy_init_buffer +#define code__init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer code__init_buffer +#endif + +#ifdef yy_flush_buffer +#define code__flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer code__flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define code__load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state code__load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define code__switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer code__switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define code_push_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state code_push_buffer_state +#endif + +#ifdef yypop_buffer_state +#define code_pop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state code_pop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define code_ensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack code_ensure_buffer_stack +#endif + +#ifdef yylex +#define code_lex_ALREADY_DEFINED +#else +#define yylex code_lex +#endif + +#ifdef yyrestart +#define code_restart_ALREADY_DEFINED +#else +#define yyrestart code_restart +#endif + +#ifdef yylex_init +#define code_lex_init_ALREADY_DEFINED +#else +#define yylex_init code_lex_init +#endif + +#ifdef yylex_init_extra +#define code_lex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra code_lex_init_extra +#endif + +#ifdef yylex_destroy +#define code_lex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy code_lex_destroy +#endif + +#ifdef yyget_debug +#define code_get_debug_ALREADY_DEFINED +#else +#define yyget_debug code_get_debug +#endif + +#ifdef yyset_debug +#define code_set_debug_ALREADY_DEFINED +#else +#define yyset_debug code_set_debug +#endif + +#ifdef yyget_extra +#define code_get_extra_ALREADY_DEFINED +#else +#define yyget_extra code_get_extra +#endif + +#ifdef yyset_extra +#define code_set_extra_ALREADY_DEFINED +#else +#define yyset_extra code_set_extra +#endif + +#ifdef yyget_in +#define code_get_in_ALREADY_DEFINED +#else +#define yyget_in code_get_in +#endif + +#ifdef yyset_in +#define code_set_in_ALREADY_DEFINED +#else +#define yyset_in code_set_in +#endif + +#ifdef yyget_out +#define code_get_out_ALREADY_DEFINED +#else +#define yyget_out code_get_out +#endif + +#ifdef yyset_out +#define code_set_out_ALREADY_DEFINED +#else +#define yyset_out code_set_out +#endif + +#ifdef yyget_leng +#define code_get_leng_ALREADY_DEFINED +#else +#define yyget_leng code_get_leng +#endif + +#ifdef yyget_text +#define code_get_text_ALREADY_DEFINED +#else +#define yyget_text code_get_text +#endif + +#ifdef yyget_lineno +#define code_get_lineno_ALREADY_DEFINED +#else +#define yyget_lineno code_get_lineno +#endif + +#ifdef yyset_lineno +#define code_set_lineno_ALREADY_DEFINED +#else +#define yyset_lineno code_set_lineno +#endif + +#ifdef yywrap +#define code_wrap_ALREADY_DEFINED +#else +#define yywrap code_wrap +#endif + /* %endif */ +#ifdef yyalloc +#define code_alloc_ALREADY_DEFINED +#else +#define yyalloc code_alloc +#endif + +#ifdef yyrealloc +#define code_realloc_ALREADY_DEFINED +#else +#define yyrealloc code_realloc +#endif + +#ifdef yyfree +#define code_free_ALREADY_DEFINED +#else +#define yyfree code_free +#endif + /* %if-c-only */ +#ifdef yytext +#define code_text_ALREADY_DEFINED +#else +#define yytext code_text +#endif + +#ifdef yyleng +#define code_leng_ALREADY_DEFINED +#else +#define yyleng code_leng +#endif + +#ifdef yyin +#define code_in_ALREADY_DEFINED +#else +#define yyin code_in +#endif + +#ifdef yyout +#define code_out_ALREADY_DEFINED +#else +#define yyout code_out +#endif + +#ifdef yy_flex_debug +#define code__flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug code__flex_debug +#endif + +#ifdef yylineno +#define code_lineno_ALREADY_DEFINED +#else +#define yylineno code_lineno +#endif + /* %endif */ /* First, we deal with platform-specific or compiler-specific issues. */ @@ -127,50 +365,39 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* %endif */ +/* begin standard C++ headers. */ /* %if-c++-only */ /* %endif */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* %not-for-header */ - /* Returned upon end-of-file. */ #define YY_NULL 0 /* %ok-for-header */ /* %not-for-header */ - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* %ok-for-header */ /* %if-reentrant */ @@ -185,25 +412,29 @@ typedef unsigned int flex_uint32_t; * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE code_restart(code_in ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -221,35 +452,35 @@ typedef size_t yy_size_t; #endif /* %if-not-reentrant */ -extern yy_size_t code_leng; +extern int yyleng; /* %endif */ /* %if-c-only */ /* %if-not-reentrant */ -extern FILE *code_in, *code_out; +extern FILE *yyin, *yyout; /* %endif */ /* %endif */ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ - /* Undo effects of setting up code_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up code_text again */ \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -269,12 +500,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -297,7 +528,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -314,8 +545,8 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via code_restart()), so that the user can continue scanning by - * just pointing code_in at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -324,13 +555,12 @@ struct yy_buffer_state /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - /* %if-not-reentrant */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* %endif */ /* %ok-for-header */ @@ -345,7 +575,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -355,115 +584,112 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* %if-not-reentrant */ /* %not-for-header */ - -/* yy_hold_char holds the character lost when code_text is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t code_leng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow code_wrap()'s to do buffer switches - * instead of setting up a fresh code_in. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; /* %ok-for-header */ /* %endif */ -void code_restart (FILE *input_file ); -void code__switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE code__create_buffer (FILE *file,int size ); -void code__delete_buffer (YY_BUFFER_STATE b ); -void code__flush_buffer (YY_BUFFER_STATE b ); -void code_push_buffer_state (YY_BUFFER_STATE new_buffer ); -void code_pop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -static void code_ensure_buffer_stack (void ); -static void code__load_buffer_state (void ); -static void code__init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -#define YY_FLUSH_BUFFER code__flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE code__scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE code__scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE code__scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); /* %endif */ -void *code_alloc (yy_size_t ); -void *code_realloc (void *,yy_size_t ); -void code_free (void * ); - -#define yy_new_buffer code__create_buffer +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - code_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - code__create_buffer(code_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - code_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - code__create_buffer(code_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -/* %% [1.0] code_text/code_in/code_out/yy_state_type/code_lineno etc. def's & init go here */ +/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ -#define code_wrap() 1 +#define code_wrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP #define FLEX_DEBUG +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *code_in = (FILE *) 0, *code_out = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; -extern int code_lineno; +extern int yylineno; +int yylineno = 1; -int code_lineno = 1; +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext -extern char *code_text; -#define yytext_ptr code_text +/* %% [1.5] DFA */ /* %if-c-only Standard (non-C++) definition */ -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* %endif */ /* Done after the current pattern has been matched and before the - * corresponding action - sets up code_text. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ -/* %% [2.0] code to fiddle code_text and code_leng for yymore() goes here \ */\ - code_leng = (size_t) (yy_cp - yy_bp); \ +/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to code_text[] goes here, if %array \ */\ +/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; - /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 18 #define YY_END_OF_BUFFER 19 @@ -474,7 +700,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[91] = +static const flex_int16_t yy_accept[91] = { 0, 0, 0, 0, 0, 3, 3, 4, 4, 4, 4, 0, 0, 0, 0, 19, 17, 16, 17, 2, 17, @@ -487,7 +713,7 @@ static yyconst flex_int16_t yy_accept[91] = 12, 12, 0, 14, 12, 12, 0, 0, 0, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, @@ -519,13 +745,13 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[19] = +static const YY_CHAR yy_meta[19] = { 0, 1, 1, 2, 1, 1, 1, 1, 3, 3, 1, 3, 1, 2, 1, 1, 1, 1, 2 } ; -static yyconst flex_int16_t yy_base[97] = +static const flex_int16_t yy_base[97] = { 0, 0, 13, 121, 120, 0, 3, 4, 5, 6, 7, 27, 0, 20, 21, 125, 178, 178, 26, 178, 8, @@ -540,7 +766,7 @@ static yyconst flex_int16_t yy_base[97] = } ; -static yyconst flex_int16_t yy_def[97] = +static const flex_int16_t yy_def[97] = { 0, 91, 91, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, 11, 11, 90, 90, 90, 90, 90, 90, @@ -555,7 +781,7 @@ static yyconst flex_int16_t yy_def[97] = } ; -static yyconst flex_int16_t yy_nxt[197] = +static const flex_int16_t yy_nxt[197] = { 0, 90, 90, 19, 69, 17, 19, 63, 21, 21, 33, 34, 23, 23, 17, 17, 20, 17, 17, 20, 22, @@ -581,7 +807,7 @@ static yyconst flex_int16_t yy_nxt[197] = } ; -static yyconst flex_int16_t yy_chk[197] = +static const flex_int16_t yy_chk[197] = { 0, 0, 0, 5, 95, 1, 6, 93, 7, 8, 20, 20, 9, 10, 1, 1, 5, 1, 2, 6, 7, @@ -610,13 +836,13 @@ static yyconst flex_int16_t yy_chk[197] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int code__flex_debug; -int code__flex_debug = 1; +extern int yy_flex_debug; +int yy_flex_debug = 1; -static yyconst flex_int16_t yy_rule_linenum[18] = +static const flex_int16_t yy_rule_linenum[18] = { 0, - 114, 124, 125, 135, 140, 145, 151, 152, 153, 154, - 156, 164, 170, 180, 188, 198, 201 + 115, 125, 126, 136, 141, 146, 152, 153, 154, 155, + 157, 165, 171, 181, 189, 199, 202 } ; /* The intent behind this definition is that it'll catch @@ -626,11 +852,11 @@ static yyconst flex_int16_t yy_rule_linenum[18] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *code_text; -#line 1 "../../src/scan-code.l" +char *yytext; +#line 1 "/Users/akim/src/gnu/bison/src/scan-code.l" /* Bison Action Scanner -*- C -*- - Copyright (C) 2006-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -647,7 +873,7 @@ char *code_text; You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 -#line 24 "../../src/scan-code.l" +#line 24 "/Users/akim/src/gnu/bison/src/scan-code.l" /* Work around a bug in flex 2.5.31. See Debian bug 333231 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ #undef code_wrap @@ -672,7 +898,7 @@ char *code_text; # define YY_DECL static char *code_lex (code_props *self, int sc_context) YY_DECL; -#define YY_USER_ACTION location_compute (loc, &loc->end, code_text, code_leng); +#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng); static char *fetch_type_name (char *cp, char const **type_name, location dollar_loc); @@ -693,12 +919,14 @@ static char *last_string; /* True if an untyped $$ or $n was seen. */ static bool untyped_var_seen; -/* C and C++ comments in code. */ +#line 922 "src/scan-code.c" +#line 71 "/Users/akim/src/gnu/bison/src/scan-code.l" + /* C and C++ comments in code. */ -/* Strings and characters in code. */ + /* Strings and characters in code. */ -/* Whether in a rule or symbol action. Specifies the translation -of $ and @. */ + /* Whether in a rule or symbol action. Specifies the translation + of $ and @. */ /* POSIX says that a tag must be both an id and a C union member, but historically almost any character is allowed in a tag. We disallow @@ -709,7 +937,7 @@ of $ and @. */ /* C style identifier. Must start with letter. Will be used for named symbol references. Shall be kept synchronized with scan-gram.l "letter" and "id". */ -#line 713 "src/scan-code.c" +#line 940 "src/scan-code.c" #define INITIAL 0 #define SC_COMMENT 1 @@ -739,7 +967,7 @@ of $ and @. */ /* %if-reentrant */ /* %if-c-only */ -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* %endif */ /* %if-reentrant */ @@ -749,31 +977,31 @@ static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int code_lex_destroy (void ); +int yylex_destroy ( void ); -int code_get_debug (void ); +int yyget_debug ( void ); -void code_set_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE code_get_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void code_set_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *code_get_in (void ); +FILE *yyget_in ( void ); -void code_set_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *code_get_out (void ); +FILE *yyget_out ( void ); -void code_set_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t code_get_leng (void ); + int yyget_leng ( void ); -char *code_get_text (void ); +char *yyget_text ( void ); -int code_get_lineno (void ); +int yyget_lineno ( void ); -void code_set_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* %if-bison-bridge */ /* %endif */ @@ -784,34 +1012,35 @@ void code_set_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int code_wrap (void ); +extern "C" int yywrap ( void ); #else -extern int code_wrap (void ); +extern int yywrap ( void ); #endif #endif /* %not-for-header */ - +#ifndef YY_NO_UNPUT + +#endif /* %ok-for-header */ /* %endif */ #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif /* %ok-for-header */ @@ -824,7 +1053,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -833,7 +1067,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( code_text, code_leng, 1, code_out )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ @@ -848,20 +1082,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ - (c = getc( code_in )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( code_in ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, code_in))==0 && ferror(code_in)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -869,7 +1103,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(code_in); \ + clearerr(yyin); \ } \ }\ \ @@ -902,11 +1136,9 @@ static int input (void ); /* %if-tables-serialization structures and prototypes */ /* %not-for-header */ - /* %ok-for-header */ /* %not-for-header */ - /* %tables-yydmap generated elements */ /* %endif */ /* end tables serialization structures and prototypes */ @@ -920,15 +1152,15 @@ static int input (void ); #define YY_DECL_IS_OURS 1 /* %if-c-only Standard (non-C++) definition */ -extern int code_lex (void); +extern int yylex (void); -#define YY_DECL int code_lex (void) +#define YY_DECL int yylex (void) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after code_text and code_leng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -937,7 +1169,7 @@ extern int code_lex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif /* %% [6.0] YY_RULE_SETUP definition goes here */ @@ -945,35 +1177,14 @@ extern int code_lex (void); YY_USER_ACTION /* %not-for-header */ - /** The main scanner function which does all the work. */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; -/* %% [7.0] user's declarations go here */ -#line 96 "../../src/scan-code.l" - - - - /* This scanner is special: it is invoked only once, henceforth - is expected to return only once. This initialization is - therefore done once per action to translate. */ - aver (sc_context == SC_SYMBOL_ACTION - || sc_context == SC_RULE_ACTION - || sc_context == INITIAL); - BEGIN sc_context; - - - /*------------------------------------------------------------. - | Scanning a C comment. The initial '/ *' is already eaten. | - `------------------------------------------------------------*/ - -#line 976 "src/scan-code.c" - if ( !(yy_init) ) { (yy_init) = 1; @@ -985,35 +1196,56 @@ YY_DECL if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ - if ( ! code_in ) + if ( ! yyin ) /* %if-c-only */ - code_in = stdin; + yyin = stdin; /* %endif */ /* %if-c++-only */ /* %endif */ - if ( ! code_out ) + if ( ! yyout ) /* %if-c-only */ - code_out = stdout; + yyout = stdout; /* %endif */ /* %if-c++-only */ /* %endif */ if ( ! YY_CURRENT_BUFFER ) { - code_ensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - code__create_buffer(code_in,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - code__load_buffer_state( ); + yy_load_buffer_state( ); } - while ( 1 ) /* loops until end-of-file is reached */ + { +/* %% [7.0] user's declarations go here */ +#line 97 "/Users/akim/src/gnu/bison/src/scan-code.l" + + + + /* This scanner is special: it is invoked only once, henceforth + is expected to return only once. This initialization is + therefore done once per action to translate. */ + aver (sc_context == SC_SYMBOL_ACTION + || sc_context == SC_RULE_ACTION + || sc_context == INITIAL); + BEGIN sc_context; + + + /*------------------------------------------------------------. + | Scanning a C comment. The initial '/ *' is already eaten. | + `------------------------------------------------------------*/ + +#line 1241 "src/scan-code.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { /* %% [8.0] yymore()-related code goes here */ yy_cp = (yy_c_buf_p); - /* Support of code_text. */ + /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of @@ -1026,7 +1258,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1036,9 +1268,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 91 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_current_state != 90 ); @@ -1051,21 +1283,21 @@ yy_find_action: YY_DO_BEFORE_ACTION; -/* %% [11.0] code for code_lineno update goes here */ +/* %% [11.0] code for yylineno update goes here */ do_action: /* This label is used only to access EOF actions. */ /* %% [12.0] debug code goes here */ - if ( code__flex_debug ) + if ( yy_flex_debug ) { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); else if ( yy_act < 18 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], code_text ); + (long)yy_rule_linenum[yy_act], yytext ); else if ( yy_act == 18 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", - code_text ); + yytext ); else if ( yy_act == 19 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else @@ -1085,7 +1317,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 114 "../../src/scan-code.l" +#line 115 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN sc_context; YY_BREAK @@ -1097,13 +1329,13 @@ STRING_GROW; BEGIN sc_context; case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 124 "../../src/scan-code.l" +#line 125 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN sc_context; YY_BREAK case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 125 "../../src/scan-code.l" +#line 126 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; YY_BREAK @@ -1115,7 +1347,7 @@ STRING_GROW; case 4: /* rule 4 can match eol */ YY_RULE_SETUP -#line 135 "../../src/scan-code.l" +#line 136 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; YY_BREAK @@ -1123,7 +1355,7 @@ STRING_GROW; case 5: YY_RULE_SETUP -#line 140 "../../src/scan-code.l" +#line 141 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN sc_context; YY_BREAK @@ -1131,7 +1363,7 @@ STRING_GROW; BEGIN sc_context; case 6: YY_RULE_SETUP -#line 145 "../../src/scan-code.l" +#line 146 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN sc_context; YY_BREAK @@ -1139,32 +1371,32 @@ STRING_GROW; BEGIN sc_context; case 7: YY_RULE_SETUP -#line 151 "../../src/scan-code.l" +#line 152 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN SC_CHARACTER; YY_BREAK case 8: YY_RULE_SETUP -#line 152 "../../src/scan-code.l" +#line 153 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN SC_STRING; YY_BREAK case 9: /* rule 9 can match eol */ YY_RULE_SETUP -#line 153 "../../src/scan-code.l" +#line 154 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN SC_COMMENT; YY_BREAK case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 154 "../../src/scan-code.l" +#line 155 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; BEGIN SC_LINE_COMMENT; YY_BREAK case 11: YY_RULE_SETUP -#line 156 "../../src/scan-code.l" +#line 157 "/Users/akim/src/gnu/bison/src/scan-code.l" { - complain (loc, Wother, _("stray '%s'"), code_text); - obstack_escape (&obstack_for_string, code_text); + complain (loc, Wother, _("stray '%s'"), yytext); + obstack_escape (&obstack_for_string, yytext); } YY_BREAK @@ -1172,20 +1404,20 @@ YY_RULE_SETUP case 12: YY_RULE_SETUP -#line 164 "../../src/scan-code.l" +#line 165 "/Users/akim/src/gnu/bison/src/scan-code.l" { ref_tail_fields = NULL; - handle_action_dollar (self->rule, code_text, *loc); + handle_action_dollar (self->rule, yytext, *loc); if (ref_tail_fields) obstack_sgrow (&obstack_for_string, ref_tail_fields); } YY_BREAK case 13: YY_RULE_SETUP -#line 170 "../../src/scan-code.l" +#line 171 "/Users/akim/src/gnu/bison/src/scan-code.l" { ref_tail_fields = NULL; - handle_action_at (self->rule, code_text, *loc); + handle_action_at (self->rule, yytext, *loc); if (ref_tail_fields) obstack_sgrow (&obstack_for_string, ref_tail_fields); } @@ -1195,10 +1427,10 @@ YY_RULE_SETUP case 14: YY_RULE_SETUP -#line 180 "../../src/scan-code.l" +#line 181 "/Users/akim/src/gnu/bison/src/scan-code.l" { const char *type_name = NULL; - fetch_type_name (code_text + 1, &type_name, *loc)[-1] = 0; + fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0; obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar("); obstack_quote (&obstack_for_string, type_name); obstack_sgrow (&obstack_for_string, ")["); @@ -1207,7 +1439,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 188 "../../src/scan-code.l" +#line 189 "/Users/akim/src/gnu/bison/src/scan-code.l" { obstack_sgrow (&obstack_for_string, "]b4_at_dollar["); muscle_percent_define_ensure("locations", the_location, true); @@ -1219,14 +1451,14 @@ YY_RULE_SETUP /* Escape M4 quoting characters in C code. */ case 16: YY_RULE_SETUP -#line 198 "../../src/scan-code.l" -obstack_escape (&obstack_for_string, code_text); +#line 199 "/Users/akim/src/gnu/bison/src/scan-code.l" +obstack_escape (&obstack_for_string, yytext); YY_BREAK /* By default, grow the string obstack with the input. */ case 17: /* rule 17 can match eol */ YY_RULE_SETUP -#line 201 "../../src/scan-code.l" +#line 202 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_GROW; YY_BREAK /* End of processing. */ @@ -1237,16 +1469,16 @@ case YY_STATE_EOF(SC_STRING): case YY_STATE_EOF(SC_CHARACTER): case YY_STATE_EOF(SC_RULE_ACTION): case YY_STATE_EOF(SC_SYMBOL_ACTION): -#line 204 "../../src/scan-code.l" +#line 205 "/Users/akim/src/gnu/bison/src/scan-code.l" STRING_FINISH; return last_string; YY_BREAK case 18: YY_RULE_SETUP -#line 207 "../../src/scan-code.l" +#line 208 "/Users/akim/src/gnu/bison/src/scan-code.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1250 "src/scan-code.c" +#line 1481 "src/scan-code.c" case YY_END_OF_BUFFER: { @@ -1261,15 +1493,19 @@ YY_FATAL_ERROR( "flex scanner jammed" ); { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed code_in at a new source and called - * code_lex(). If so, then we have to assure + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = code_in; +/* %if-c-only */ + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; +/* %endif */ +/* %if-c++-only */ +/* %endif */ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1324,11 +1560,11 @@ YY_FATAL_ERROR( "flex scanner jammed" ); { (yy_did_buffer_switch_on_eof) = 0; - if ( code_wrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * code_text, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the @@ -1377,12 +1613,12 @@ YY_FATAL_ERROR( "flex scanner jammed" ); "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -} /* end of code_lex */ + } /* end of user's declarations */ +} /* end of yylex */ /* %ok-for-header */ /* %if-c++-only */ /* %not-for-header */ - /* %ok-for-header */ /* %endif */ @@ -1400,9 +1636,9 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1431,7 +1667,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1444,7 +1680,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1458,7 +1694,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1467,11 +1703,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - code_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1499,7 +1736,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - code_restart(code_in ); + yyrestart( yyin ); } else @@ -1513,12 +1750,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) code_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1534,14 +1774,13 @@ static int yy_get_next_buffer (void) /* %if-c-only */ /* %not-for-header */ - static yy_state_type yy_get_previous_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; /* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = (yy_start); @@ -1549,7 +1788,7 @@ static int yy_get_next_buffer (void) for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 18); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 18); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1559,9 +1798,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 91 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1578,11 +1817,11 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register int yy_is_jam; + int yy_is_jam; /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ - register char *yy_cp = (yy_c_buf_p); + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 18; + YY_CHAR yy_c = 18; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1592,17 +1831,19 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 91 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 90); return yy_is_jam ? 0 : yy_current_state; } +#ifndef YY_NO_UNPUT /* %if-c-only */ /* %endif */ +#endif /* %if-c-only */ #ifndef YY_NO_INPUT @@ -1632,7 +1873,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1649,14 +1890,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - code_restart(code_in ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( code_wrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1675,10 +1916,10 @@ static int yy_get_next_buffer (void) } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve code_text */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); -/* %% [19.0] update BOL and code_lineno */ +/* %% [19.0] update BOL and yylineno */ return c; } @@ -1692,28 +1933,31 @@ static int yy_get_next_buffer (void) * @note This function does not reset the start condition to @c INITIAL . */ /* %if-c-only */ - void code_restart (FILE * input_file ) + void yyrestart (FILE * input_file ) /* %endif */ /* %if-c++-only */ /* %endif */ { if ( ! YY_CURRENT_BUFFER ){ - code_ensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - code__create_buffer(code_in,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - code__init_buffer(YY_CURRENT_BUFFER,input_file ); - code__load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } +/* %if-c++-only */ +/* %endif */ + /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ /* %if-c-only */ - void code__switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1721,10 +1965,10 @@ static int yy_get_next_buffer (void) /* TODO. We should be able to replace this entire function body * with - * code_pop_buffer_state(); - * code_push_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - code_ensure_buffer_stack (); + yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1737,25 +1981,29 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - code__load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during - * EOF (code_wrap()) processing, but the only time this flag - * is looked at is after code_wrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } /* %if-c-only */ -static void code__load_buffer_state (void) +static void yy_load_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - code_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %if-c-only */ + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ (yy_hold_char) = *(yy_c_buf_p); } @@ -1766,39 +2014,42 @@ static void code__load_buffer_state (void) * @return the allocated buffer state. */ /* %if-c-only */ - YY_BUFFER_STATE code__create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) /* %endif */ /* %if-c++-only */ /* %endif */ { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) code_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in code__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) code_alloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in code__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - code__init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } +/* %if-c++-only */ +/* %endif */ + /** Destroy the buffer. - * @param b a buffer created with code__create_buffer() + * @param b a buffer created with yy_create_buffer() * */ /* %if-c-only */ - void code__delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1811,17 +2062,17 @@ static void code__load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - code_free((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - code_free((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a code_restart() or at EOF. + * such as during a yyrestart() or at EOF. */ /* %if-c-only */ - static void code__init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1829,13 +2080,17 @@ static void code__load_buffer_state (void) { int oerrno = errno; - code__flush_buffer(b ); + yy_flush_buffer( b ); +/* %if-c-only */ b->yy_input_file = file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ b->yy_fill_buffer = 1; - /* If b is the current buffer, then code__init_buffer was _probably_ - * called from code_restart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1858,7 +2113,7 @@ static void code__load_buffer_state (void) * */ /* %if-c-only */ - void code__flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1881,7 +2136,7 @@ static void code__load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - code__load_buffer_state( ); + yy_load_buffer_state( ); } /* %if-c-or-c++ */ @@ -1892,7 +2147,7 @@ static void code__load_buffer_state (void) * */ /* %if-c-only */ -void code_push_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1900,9 +2155,9 @@ void code_push_buffer_state (YY_BUFFER_STATE new_buffer ) if (new_buffer == NULL) return; - code_ensure_buffer_stack(); + yyensure_buffer_stack(); - /* This block is copied from code__switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1916,8 +2171,8 @@ void code_push_buffer_state (YY_BUFFER_STATE new_buffer ) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from code__switch_to_buffer. */ - code__load_buffer_state( ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /* %endif */ @@ -1928,7 +2183,7 @@ void code_push_buffer_state (YY_BUFFER_STATE new_buffer ) * */ /* %if-c-only */ -void code_pop_buffer_state (void) +void yypop_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1936,13 +2191,13 @@ void code_pop_buffer_state (void) if (!YY_CURRENT_BUFFER) return; - code__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - code__load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1953,7 +2208,7 @@ void code_pop_buffer_state (void) * Guarantees space for at least one push. */ /* %if-c-only */ -static void code_ensure_buffer_stack (void) +static void yyensure_buffer_stack (void) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1966,15 +2221,15 @@ static void code_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)code_alloc + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in code_ensure_buffer_stack()" ); - + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1983,15 +2238,15 @@ static void code_ensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)code_realloc + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in code_ensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2005,9 +2260,9 @@ static void code_ensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE code__scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; @@ -2015,53 +2270,53 @@ YY_BUFFER_STATE code__scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) code_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in code__scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - code__switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan a string. The next call to code_lex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * code__scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE code__scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return code__scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan the given bytes. The next call to code_lex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE code__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -2069,19 +2324,19 @@ YY_BUFFER_STATE code__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_l int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) code_alloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in code__scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = code__scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in code__scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2097,9 +2352,9 @@ YY_BUFFER_STATE code__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_l #endif /* %if-c-only */ -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* %endif */ @@ -2112,14 +2367,14 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up code_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - code_text[code_leng] = (yy_hold_char); \ - (yy_c_buf_p) = code_text + yyless_macro_arg; \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ - code_leng = yyless_macro_arg; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) @@ -2132,82 +2387,82 @@ static void yy_fatal_error (yyconst char* msg ) /** Get the current line number. * */ -int code_get_lineno (void) +int yyget_lineno (void) { - - return code_lineno; + + return yylineno; } /** Get the input stream. * */ -FILE *code_get_in (void) +FILE *yyget_in (void) { - return code_in; + return yyin; } /** Get the output stream. * */ -FILE *code_get_out (void) +FILE *yyget_out (void) { - return code_out; + return yyout; } /** Get the length of the current token. * */ -yy_size_t code_get_leng (void) +int yyget_leng (void) { - return code_leng; + return yyleng; } /** Get the current token. * */ -char *code_get_text (void) +char *yyget_text (void) { - return code_text; + return yytext; } /* %if-reentrant */ /* %endif */ /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void code_set_lineno (int line_number ) +void yyset_lineno (int _line_number ) { - code_lineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * - * @see code__switch_to_buffer + * @see yy_switch_to_buffer */ -void code_set_in (FILE * in_str ) +void yyset_in (FILE * _in_str ) { - code_in = in_str ; + yyin = _in_str ; } -void code_set_out (FILE * out_str ) +void yyset_out (FILE * _out_str ) { - code_out = out_str ; + yyout = _out_str ; } -int code_get_debug (void) +int yyget_debug (void) { - return code__flex_debug; + return yy_flex_debug; } -void code_set_debug (int bdebug ) +void yyset_debug (int _bdebug ) { - code__flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } /* %endif */ @@ -2221,50 +2476,50 @@ void code_set_debug (int bdebug ) static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. - * This function is called from code_lex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT - code_in = stdin; - code_out = stdout; + yyin = stdin; + yyout = stdout; #else - code_in = (FILE *) 0; - code_out = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * code_lex_init() + * yylex_init() */ return 0; } /* %endif */ /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ -/* code_lex_destroy is for both reentrant and non-reentrant scanners. */ -int code_lex_destroy (void) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - code__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; - code_pop_buffer_state(); + yypop_buffer_state(); } /* Destroy the stack itself. */ - code_free((yy_buffer_stack) ); + yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * code_lex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( ); /* %if-reentrant */ @@ -2278,18 +2533,19 @@ int code_lex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -2297,13 +2553,14 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *code_alloc (yy_size_t size ) +void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } -void *code_realloc (void * ptr, yy_size_t size ) +void *yyrealloc (void * ptr, yy_size_t size ) { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -2311,12 +2568,12 @@ void *code_realloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void code_free (void * ptr ) +void yyfree (void * ptr ) { - free( (char *) ptr ); /* see code_realloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } /* %if-tables-serialization definitions */ @@ -2326,8 +2583,7 @@ void code_free (void * ptr ) /* %ok-for-header */ -#line 207 "../../src/scan-code.l" - +#line 208 "/Users/akim/src/gnu/bison/src/scan-code.l" static inline bool @@ -2420,9 +2676,7 @@ static variant * variant_add (uniqstr id, location id_loc, unsigned symbol_index, char *cp, char *cp_end, bool explicit_bracketing) { - char *prefix_end; - - prefix_end = find_prefix_end (id, cp, cp_end); + char *prefix_end = find_prefix_end (id, cp, cp_end); if (prefix_end && (prefix_end == cp_end || (!explicit_bracketing && is_dot_or_dash (*prefix_end)))) @@ -2464,12 +2718,24 @@ show_sub_message (warnings warning, var->id, at_spec); else { - static struct obstack msg_buf; + const char *id; + location id_loc; + + if (var->hidden_by) + { + id = var->hidden_by->id; + id_loc = var->hidden_by->loc; + } + else + { + id = var->id; + id_loc = var->loc; + } + const char *tail = explicit_bracketing ? "" : cp + strlen (var->id); - const char *id = var->hidden_by ? var->hidden_by->id : var->id; - location id_loc = var->hidden_by ? var->hidden_by->loc : var->loc; /* Create the explanation message. */ + static struct obstack msg_buf; obstack_init (&msg_buf); obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at); @@ -2508,9 +2774,7 @@ show_sub_messages (warnings warning, int midrule_rhs_index, char dollar_or_at, unsigned indent) { - unsigned i; - - for (i = 0; i < variant_count; ++i) + for (unsigned i = 0; i < variant_count; ++i) show_sub_message (warning | silent, cp, explicit_bracketing, midrule_rhs_index, dollar_or_at, @@ -2528,24 +2792,17 @@ show_sub_messages (warnings warning, /* Parse named or positional reference. In case of positional references, can return negative values for $-n "deep" stack accesses. */ -static long int +static long parse_ref (char *cp, symbol_list *rule, int rule_length, int midrule_rhs_index, char *text, location text_loc, char dollar_or_at) { - symbol_list *l; - char *cp_end; - bool explicit_bracketing; - unsigned i; - unsigned valid_variants = 0; - unsigned valid_variant_index = 0; - if ('$' == *cp) return LHS_REF; if (c_isdigit (*cp) || (*cp == '-' && c_isdigit (* (cp + 1)))) { - long int num = strtol (cp, &cp, 10); + long num = strtol (cp, &cp, 10); if (1 - INT_MAX + rule_length <= num && num <= rule_length) return num; else @@ -2556,6 +2813,9 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, } } + char *cp_end; + bool explicit_bracketing; + if ('[' == *cp) { /* Ignore the brackets. */ @@ -2586,16 +2846,17 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, /* Add all relevant variants. */ { unsigned symbol_index; + symbol_list *l; variant_count = 0; for (symbol_index = 0, l = rule; !symbol_list_null (l); ++symbol_index, l = l->next) { - variant *var; if (l->content_type != SYMLIST_SYMBOL) continue; - var = variant_add (l->content.sym->tag, l->sym_loc, - symbol_index, cp, cp_end, explicit_bracketing); + variant *var + = variant_add (l->content.sym->tag, l->sym_loc, + symbol_index, cp, cp_end, explicit_bracketing); if (var && l->named_ref) var->hidden_by = l->named_ref; @@ -2606,7 +2867,9 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, } /* Check errors. */ - for (i = 0; i < variant_count; ++i) + unsigned valid_variants = 0; + unsigned valid_variant_index = 0; + for (unsigned i = 0; i < variant_count; ++i) { variant *var = &variant_table[i]; unsigned symbol_index = var->symbol_index; @@ -2697,9 +2960,6 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, return INVALID_REF; } } - - /* Not reachable. */ - return INVALID_REF; } /* Keeps track of the maximum number of semantic values to the left of @@ -2746,11 +3006,8 @@ fetch_type_name (char *cp, char const **type_name, static void handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) { - char const *type_name = NULL; - char *cp = text + 1; symbol_list *effective_rule; int effective_rule_length; - int n; if (rule->midrule_parent_rule) { @@ -2764,10 +3021,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) } /* Get the type name if explicit. */ - cp = fetch_type_name (cp, &type_name, dollar_loc); + char const *type_name = NULL; + char *cp = fetch_type_name (text + 1, &type_name, dollar_loc); - n = parse_ref (cp, effective_rule, effective_rule_length, - rule->midrule_parent_rhs_index, text, dollar_loc, '$'); + int n = parse_ref (cp, effective_rule, effective_rule_length, + rule->midrule_parent_rhs_index, text, dollar_loc, '$'); /* End type_name. */ if (type_name) @@ -2780,7 +3038,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) case LHS_REF: if (!type_name) - type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0); + type_name = symbol_list_n_type_name_get (rule, 0); if (!type_name) { @@ -2811,8 +3069,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) if (max_left_semantic_context < 1 - n) max_left_semantic_context = 1 - n; if (!type_name && 0 < n) - type_name = - symbol_list_n_type_name_get (effective_rule, dollar_loc, n); + type_name = symbol_list_n_type_name_get (effective_rule, n); if (!type_name) { if (union_seen | tag_seen) @@ -2827,7 +3084,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) "]b4_rhs_value(%d, %d, ", effective_rule_length, n); obstack_quote (&obstack_for_string, type_name); obstack_sgrow (&obstack_for_string, ")["); - if (n > 0) + if (0 < n) symbol_list_n_get (effective_rule, n)->action_props.is_value_used = true; break; @@ -2843,10 +3100,8 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) static void handle_action_at (symbol_list *rule, char *text, location at_loc) { - char *cp = text + 1; symbol_list *effective_rule; int effective_rule_length; - int n; if (rule->midrule_parent_rule) { @@ -2861,8 +3116,8 @@ handle_action_at (symbol_list *rule, char *text, location at_loc) muscle_percent_define_ensure("locations", at_loc, true); - n = parse_ref (cp, effective_rule, effective_rule_length, - rule->midrule_parent_rhs_index, text, at_loc, '@'); + int n = parse_ref (text + 1, effective_rule, effective_rule_length, + rule->midrule_parent_rhs_index, text, at_loc, '@'); switch (n) { case INVALID_REF: @@ -2890,19 +3145,18 @@ handle_action_at (symbol_list *rule, char *text, location at_loc) static char const * translate_action (code_props *self, int sc_context) { - char *res; static bool initialized = false; if (!initialized) { obstack_init (&obstack_for_string); - code__flex_debug = 0; + yy_flex_debug = 0; initialized = true; } loc->start = loc->end = self->location.start; - code__switch_to_buffer (code__scan_string (self->code)); - res = code_lex (self, sc_context); - code__delete_buffer (YY_CURRENT_BUFFER); + yy_switch_to_buffer (yy_scan_string (self->code)); + char *res = code_lex (self, sc_context); + yy_delete_buffer (YY_CURRENT_BUFFER); return res; } @@ -2942,7 +3196,8 @@ code_props_symbol_action_init (code_props *self, char const *code, void code_props_rule_action_init (code_props *self, char const *code, location code_loc, symbol_list *rule, - named_ref *name, bool is_predicate) + named_ref *name, uniqstr type, + bool is_predicate) { code_props_none_init (self); self->kind = CODE_PROPS_RULE_ACTION; @@ -2950,6 +3205,7 @@ code_props_rule_action_init (code_props *self, char const *code, self->location = code_loc; self->rule = rule; self->named_ref = name; + self->type = type; self->is_predicate = is_predicate; } @@ -2985,6 +3241,6 @@ code_scanner_free (void) variant_table_free (); /* Reclaim Flex's buffers. */ - code_lex_destroy (); + yylex_destroy (); } diff --git a/contrib/tools/bison/src/scan-code.h b/contrib/tools/bison/src/scan-code.h index d5a15c1a1c..fb8b4a272e 100644 --- a/contrib/tools/bison/src/scan-code.h +++ b/contrib/tools/bison/src/scan-code.h @@ -1,6 +1,7 @@ /* Bison code properties structure and scanner. - Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -22,6 +23,7 @@ # include "location.h" # include "named-ref.h" +# include "uniqstr.h" struct symbol_list; @@ -80,8 +82,11 @@ typedef struct code_props { /** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */ struct symbol_list *rule; - /* Named reference. */ + /** Named reference. */ named_ref *named_ref; + + /** Type, for mid-rule actions. */ + uniqstr type; } code_props; /** @@ -102,7 +107,8 @@ void code_props_none_init (code_props *self); /* .is_predicate = */ false, \ /* .is_used = */ false, \ /* .rule = */ NULL, \ - /* .named_ref = */ NULL \ + /* .named_ref = */ NULL, \ + /* .type = */ NULL, \ } /** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */ @@ -157,7 +163,8 @@ void code_props_symbol_action_init (code_props *self, char const *code, */ void code_props_rule_action_init (code_props *self, char const *code, location code_loc, struct symbol_list *rule, - named_ref *name, bool is_predicate); + named_ref *name, uniqstr type, + bool is_predicate); /** * \pre diff --git a/contrib/tools/bison/src/scan-gram.c b/contrib/tools/bison/src/scan-gram.c index 6c215ea7a7..ff9094eeba 100644 --- a/contrib/tools/bison/src/scan-gram.c +++ b/contrib/tools/bison/src/scan-gram.c @@ -1,22 +1,27 @@ -#line 2 "src/scan-gram.c" +#line 1 "src/scan-gram.c" -#line 4 "src/scan-gram.c" +#line 3 "src/scan-gram.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ /* %not-for-header */ - /* %if-c-only */ /* %if-not-reentrant */ #define yy_create_buffer gram__create_buffer #define yy_delete_buffer gram__delete_buffer -#define yy_flex_debug gram__flex_debug +#define yy_scan_buffer gram__scan_buffer +#define yy_scan_string gram__scan_string +#define yy_scan_bytes gram__scan_bytes #define yy_init_buffer gram__init_buffer #define yy_flush_buffer gram__flush_buffer #define yy_load_buffer_state gram__load_buffer_state #define yy_switch_to_buffer gram__switch_to_buffer +#define yypush_buffer_state gram_push_buffer_state +#define yypop_buffer_state gram_pop_buffer_state +#define yyensure_buffer_stack gram_ensure_buffer_stack +#define yy_flex_debug gram__flex_debug #define yyin gram_in #define yyleng gram_leng #define yylex gram_lex @@ -35,8 +40,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -45,11 +50,244 @@ /* %endif */ /* %if-c-only */ - +#ifdef yy_create_buffer +#define gram__create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer gram__create_buffer +#endif + +#ifdef yy_delete_buffer +#define gram__delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer gram__delete_buffer +#endif + +#ifdef yy_scan_buffer +#define gram__scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer gram__scan_buffer +#endif + +#ifdef yy_scan_string +#define gram__scan_string_ALREADY_DEFINED +#else +#define yy_scan_string gram__scan_string +#endif + +#ifdef yy_scan_bytes +#define gram__scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes gram__scan_bytes +#endif + +#ifdef yy_init_buffer +#define gram__init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer gram__init_buffer +#endif + +#ifdef yy_flush_buffer +#define gram__flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer gram__flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define gram__load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state gram__load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define gram__switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer gram__switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define gram_push_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state gram_push_buffer_state +#endif + +#ifdef yypop_buffer_state +#define gram_pop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state gram_pop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define gram_ensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack gram_ensure_buffer_stack +#endif + +#ifdef yylex +#define gram_lex_ALREADY_DEFINED +#else +#define yylex gram_lex +#endif + +#ifdef yyrestart +#define gram_restart_ALREADY_DEFINED +#else +#define yyrestart gram_restart +#endif + +#ifdef yylex_init +#define gram_lex_init_ALREADY_DEFINED +#else +#define yylex_init gram_lex_init +#endif + +#ifdef yylex_init_extra +#define gram_lex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra gram_lex_init_extra +#endif + +#ifdef yylex_destroy +#define gram_lex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy gram_lex_destroy +#endif + +#ifdef yyget_debug +#define gram_get_debug_ALREADY_DEFINED +#else +#define yyget_debug gram_get_debug +#endif + +#ifdef yyset_debug +#define gram_set_debug_ALREADY_DEFINED +#else +#define yyset_debug gram_set_debug +#endif + +#ifdef yyget_extra +#define gram_get_extra_ALREADY_DEFINED +#else +#define yyget_extra gram_get_extra +#endif + +#ifdef yyset_extra +#define gram_set_extra_ALREADY_DEFINED +#else +#define yyset_extra gram_set_extra +#endif + +#ifdef yyget_in +#define gram_get_in_ALREADY_DEFINED +#else +#define yyget_in gram_get_in +#endif + +#ifdef yyset_in +#define gram_set_in_ALREADY_DEFINED +#else +#define yyset_in gram_set_in +#endif + +#ifdef yyget_out +#define gram_get_out_ALREADY_DEFINED +#else +#define yyget_out gram_get_out +#endif + +#ifdef yyset_out +#define gram_set_out_ALREADY_DEFINED +#else +#define yyset_out gram_set_out +#endif + +#ifdef yyget_leng +#define gram_get_leng_ALREADY_DEFINED +#else +#define yyget_leng gram_get_leng +#endif + +#ifdef yyget_text +#define gram_get_text_ALREADY_DEFINED +#else +#define yyget_text gram_get_text +#endif + +#ifdef yyget_lineno +#define gram_get_lineno_ALREADY_DEFINED +#else +#define yyget_lineno gram_get_lineno +#endif + +#ifdef yyset_lineno +#define gram_set_lineno_ALREADY_DEFINED +#else +#define yyset_lineno gram_set_lineno +#endif + +#ifdef yywrap +#define gram_wrap_ALREADY_DEFINED +#else +#define yywrap gram_wrap +#endif + /* %endif */ +#ifdef yyalloc +#define gram_alloc_ALREADY_DEFINED +#else +#define yyalloc gram_alloc +#endif + +#ifdef yyrealloc +#define gram_realloc_ALREADY_DEFINED +#else +#define yyrealloc gram_realloc +#endif + +#ifdef yyfree +#define gram_free_ALREADY_DEFINED +#else +#define yyfree gram_free +#endif + /* %if-c-only */ +#ifdef yytext +#define gram_text_ALREADY_DEFINED +#else +#define yytext gram_text +#endif + +#ifdef yyleng +#define gram_leng_ALREADY_DEFINED +#else +#define yyleng gram_leng +#endif + +#ifdef yyin +#define gram_in_ALREADY_DEFINED +#else +#define yyin gram_in +#endif + +#ifdef yyout +#define gram_out_ALREADY_DEFINED +#else +#define yyout gram_out +#endif + +#ifdef yy_flex_debug +#define gram__flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug gram__flex_debug +#endif + +#ifdef yylineno +#define gram_lineno_ALREADY_DEFINED +#else +#define yylineno gram_lineno +#endif + /* %endif */ /* First, we deal with platform-specific or compiler-specific issues. */ @@ -127,50 +365,39 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* %endif */ +/* begin standard C++ headers. */ /* %if-c++-only */ /* %endif */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* %not-for-header */ - /* Returned upon end-of-file. */ #define YY_NULL 0 /* %ok-for-header */ /* %not-for-header */ - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* %ok-for-header */ /* %if-reentrant */ @@ -185,25 +412,29 @@ typedef unsigned int flex_uint32_t; * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE gram_restart(gram_in ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -221,35 +452,35 @@ typedef size_t yy_size_t; #endif /* %if-not-reentrant */ -extern yy_size_t gram_leng; +extern int yyleng; /* %endif */ /* %if-c-only */ /* %if-not-reentrant */ -extern FILE *gram_in, *gram_out; +extern FILE *yyin, *yyout; /* %endif */ /* %endif */ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ - /* Undo effects of setting up gram_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up gram_text again */ \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -269,12 +500,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -297,7 +528,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -314,8 +545,8 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via gram_restart()), so that the user can continue scanning by - * just pointing gram_in at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -324,13 +555,12 @@ struct yy_buffer_state /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - /* %if-not-reentrant */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* %endif */ /* %ok-for-header */ @@ -345,7 +575,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -355,115 +584,112 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* %if-not-reentrant */ /* %not-for-header */ - -/* yy_hold_char holds the character lost when gram_text is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t gram_leng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow gram_wrap()'s to do buffer switches - * instead of setting up a fresh gram_in. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; /* %ok-for-header */ /* %endif */ -void gram_restart (FILE *input_file ); -void gram__switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE gram__create_buffer (FILE *file,int size ); -void gram__delete_buffer (YY_BUFFER_STATE b ); -void gram__flush_buffer (YY_BUFFER_STATE b ); -void gram_push_buffer_state (YY_BUFFER_STATE new_buffer ); -void gram_pop_buffer_state (void ); - -static void gram_ensure_buffer_stack (void ); -static void gram__load_buffer_state (void ); -static void gram__init_buffer (YY_BUFFER_STATE b,FILE *file ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -#define YY_FLUSH_BUFFER gram__flush_buffer(YY_CURRENT_BUFFER ) +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -YY_BUFFER_STATE gram__scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE gram__scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE gram__scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); /* %endif */ -void *gram_alloc (yy_size_t ); -void *gram_realloc (void *,yy_size_t ); -void gram_free (void * ); - -#define yy_new_buffer gram__create_buffer +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - gram_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - gram__create_buffer(gram_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - gram_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - gram__create_buffer(gram_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -/* %% [1.0] gram_text/gram_in/gram_out/yy_state_type/gram_lineno etc. def's & init go here */ +/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ -#define gram_wrap() 1 +#define gram_wrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP #define FLEX_DEBUG +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *gram_in = (FILE *) 0, *gram_out = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; -extern int gram_lineno; +extern int yylineno; +int yylineno = 1; -int gram_lineno = 1; +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext -extern char *gram_text; -#define yytext_ptr gram_text +/* %% [1.5] DFA */ /* %if-c-only Standard (non-C++) definition */ -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* %endif */ /* Done after the current pattern has been matched and before the - * corresponding action - sets up gram_text. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ -/* %% [2.0] code to fiddle gram_text and gram_leng for yymore() goes here \ */\ - gram_leng = (size_t) (yy_cp - yy_bp); \ +/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to gram_text[] goes here, if %array \ */\ +/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; - /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 130 #define YY_END_OF_BUFFER 131 @@ -474,7 +700,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[582] = +static const flex_int16_t yy_accept[579] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -487,77 +713,76 @@ static yyconst flex_int16_t yy_accept[582] = 128, 122, 125, 126, 128, 92, 128, 117, 116, 128, 115, 114, 87, 2, 1, 85, 87, 87, 86, 87, - 88, 2, 1, 88, 88, 80, 0, 78, 62, 0, + 88, 2, 1, 88, 88, 80, 78, 62, 0, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 72, 66, - 66, 4, 3, 69, 67, 69, 0, 76, 0, 89, - 112, 110, 101, 112, 103, 104, 105, 106, 107, 108, - 112, 109, 112, 99, 99, 100, 127, 120, 121, 0, - 123, 0, 122, 124, 0, 91, 0, 0, 93, 113, - 113, 113, 113, 87, 85, 62, 62, 0, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 72, 66, 66, + 4, 3, 69, 67, 69, 0, 76, 0, 89, 112, + 110, 101, 112, 103, 104, 105, 106, 107, 108, 112, + 109, 112, 99, 99, 100, 127, 120, 121, 0, 123, + 0, 122, 124, 0, 91, 0, 0, 93, 113, 113, + 113, 113, 87, 85, 62, 0, 74, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 3, 69, 68, 75, 0, 101, 0, 0, 102, 0, + 62, 62, 62, 62, 62, 62, 62, 62, 3, 69, + 68, 75, 0, 101, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 74, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 0, 101, 0, 0, 62, 7, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 0, 101, + 0, 0, 62, 7, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 23, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 23, 62, 62, 62, 62, 62, 62, 62, 62, 62, - - 62, 62, 62, 62, 62, 36, 62, 62, 62, 62, - 62, 62, 44, 62, 47, 62, 62, 50, 0, 0, - 0, 62, 8, 62, 62, 62, 13, 14, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 26, 62, 62, - 62, 62, 62, 62, 62, 62, 32, 62, 34, 62, - 62, 62, 62, 62, 62, 41, 62, 43, 45, 48, - 62, 0, 0, 111, 6, 62, 10, 62, 62, 62, - 16, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 33, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 0, 62, - - 11, 62, 62, 62, 62, 62, 62, 62, 62, 62, + + 62, 62, 36, 62, 62, 62, 62, 62, 62, 44, + 62, 47, 62, 62, 50, 0, 0, 0, 62, 8, + 62, 62, 62, 13, 14, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 26, 62, 62, 62, 62, 62, + 62, 62, 62, 32, 62, 34, 62, 62, 62, 62, + 62, 62, 41, 62, 43, 45, 48, 62, 0, 0, + 111, 6, 62, 10, 62, 62, 62, 16, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 33, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 0, 62, 11, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 0, 59, 62, 62, 38, 62, 62, 40, - 62, 62, 62, 49, 5, 0, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 22, 62, - 62, 62, 62, 62, 29, 62, 58, 30, 62, 62, - 62, 62, 62, 42, 62, 62, 0, 62, 62, 62, - 62, 62, 17, 53, 62, 62, 62, 62, 62, 24, - 25, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 0, 0, 62, 62, 12, 62, 62, 62, - - 62, 62, 21, 62, 62, 62, 62, 62, 62, 62, - 37, 62, 62, 62, 62, 62, 62, 62, 62, 18, - 62, 62, 62, 27, 56, 62, 62, 62, 35, 39, - 60, 46, 61, 9, 51, 62, 62, 0, 54, 62, - 62, 62, 0, 56, 62, 62, 62, 15, 52, 62, - 62, 62, 62, 62, 62, 62, 62, 20, 62, 62, - 62, 62, 62, 28, 57, 62, 62, 62, 62, 62, - 62, 62, 19, 55, 62, 62, 62, 62, 62, 31, - 0 + 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, + 59, 62, 62, 38, 62, 62, 40, 62, 62, 62, + 49, 5, 0, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 22, 62, 62, 62, 62, + 62, 29, 62, 58, 30, 62, 62, 62, 62, 62, + 42, 62, 62, 0, 62, 62, 62, 62, 62, 17, + 53, 62, 62, 62, 62, 62, 24, 25, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, + 0, 62, 62, 12, 62, 62, 62, 62, 62, 21, + + 62, 62, 62, 62, 62, 62, 62, 37, 62, 62, + 62, 62, 62, 62, 62, 62, 18, 62, 62, 62, + 27, 56, 62, 62, 62, 35, 39, 60, 46, 61, + 9, 51, 62, 62, 0, 54, 62, 62, 62, 0, + 56, 62, 62, 62, 15, 52, 62, 62, 62, 62, + 62, 62, 62, 62, 20, 62, 62, 62, 62, 62, + 28, 57, 62, 62, 62, 62, 62, 62, 62, 19, + 55, 62, 62, 62, 62, 62, 31, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 5, 6, 7, 8, 6, 9, 6, 10, 6, - 6, 11, 6, 12, 13, 14, 15, 16, 17, 17, - 17, 17, 17, 17, 17, 18, 18, 19, 20, 21, - 22, 23, 24, 6, 25, 25, 25, 25, 25, 25, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 27, 26, 26, 28, 26, 26, - 29, 30, 31, 6, 32, 6, 33, 34, 35, 36, - - 37, 38, 39, 40, 41, 26, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 26, 54, - 55, 26, 56, 57, 58, 6, 1, 1, 1, 1, + 1, 5, 1, 6, 7, 1, 8, 1, 9, 1, + 1, 10, 1, 11, 12, 13, 14, 15, 16, 16, + 16, 16, 16, 16, 16, 17, 17, 18, 19, 20, + 21, 22, 23, 1, 24, 24, 24, 24, 24, 24, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 26, 25, 25, 27, 25, 25, + 28, 29, 30, 1, 31, 1, 32, 33, 34, 35, + + 36, 37, 38, 39, 40, 25, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 25, 53, + 54, 25, 55, 56, 57, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -574,438 +799,422 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[60] = +static const YY_CHAR yy_meta[59] = { 0, - 1, 2, 3, 1, 2, 4, 5, 4, 5, 5, - 5, 5, 6, 7, 8, 9, 9, 9, 4, 5, - 10, 5, 10, 4, 9, 11, 11, 11, 12, 4, - 13, 11, 9, 9, 9, 9, 9, 9, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 5, 5, 5, 1 + 1, 2, 3, 1, 2, 4, 1, 4, 4, 4, + 4, 5, 6, 2, 7, 7, 7, 1, 4, 8, + 4, 8, 1, 7, 9, 9, 9, 10, 1, 11, + 9, 7, 7, 7, 7, 7, 7, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 4, 4, 4, 1 } ; -static yyconst flex_int16_t yy_base[609] = +static const flex_int16_t yy_base[605] = { 0, - 0, 1065, 1061, 1060, 57, 58, 59, 60, 79, 94, - 53, 62, 117, 126, 135, 144, 100, 145, 154, 163, - 68, 69, 65, 70, 98, 155, 101, 164, 221, 1062, - 174, 193, 1069, 0, 1074, 1074, 1074, 280, 1074, 1074, - 1074, 339, 119, 164, 197, 1074, 114, 1074, 398, 1074, - 1074, 1074, 1025, 1074, 1052, 1074, 1074, 1074, 451, 1074, - 1074, 1074, 1074, 1074, 1074, 128, 1074, 1074, 1023, 1052, - 54, 1043, 1074, 1050, 1074, 1074, 1004, 1074, 331, 63, - 190, 1074, 1074, 1074, 153, 1074, 185, 1074, 1074, 346, - 1074, 1074, 0, 1074, 0, 0, 192, 1074, 1074, 1018, - - 1074, 1074, 1074, 339, 1017, 0, 0, 1074, 0, 354, - 1018, 1012, 169, 311, 1016, 1013, 1010, 329, 1017, 331, - 1001, 334, 331, 98, 334, 1007, 1014, 1017, 1074, 505, - 0, 1074, 0, 0, 374, 549, 1026, 1074, 1007, 1074, - 1074, 1074, 357, 0, 1074, 1074, 1074, 1074, 1074, 1074, - 0, 1074, 0, 1034, 365, 1025, 1074, 1074, 1074, 382, - 1074, 391, 1074, 1074, 398, 1074, 406, 410, 1015, 1074, - 416, 1014, 421, 0, 0, 0, 0, 430, 0, 998, - 1006, 393, 992, 993, 990, 991, 362, 988, 995, 990, - 341, 999, 984, 988, 407, 994, 979, 980, 393, 979, - - 979, 987, 988, 991, 974, 980, 974, 979, 970, 983, - 0, 0, 0, 1074, 972, 420, 0, 0, 0, 439, - 434, 445, 174, 451, 442, 457, 410, 468, 474, 485, - 489, 435, 1074, 983, 978, 962, 81, 962, 975, 960, - 964, 972, 971, 970, 993, 954, 965, 952, 989, 968, - 961, 962, 371, 465, 308, 949, 950, 433, 961, 950, - 957, 941, 952, 948, 941, 945, 951, 950, 940, 951, - 949, 946, 1074, 0, 0, 933, 0, 942, 928, 934, - 929, 942, 921, 926, 939, 960, 936, 924, 929, 917, - 0, 921, 916, 929, 442, 928, 923, 926, 921, 911, - - 923, 915, 906, 913, 919, 918, 903, 467, 912, 901, - 914, 899, 0, 904, 0, 903, 901, 0, 941, 0, - 0, 890, 0, 901, 906, 890, 0, 0, 480, 890, - 893, 482, 906, 905, 904, 903, 894, 0, 887, 886, - 894, 886, 892, 884, 878, 876, 0, 875, 0, 912, - 888, 886, 875, 874, 871, 0, 868, 0, 484, 0, - 868, 504, 0, 1074, 0, 866, 866, 880, 861, 860, - 485, 863, 865, 864, 860, 865, 868, 857, 859, 855, - 854, 869, 864, 867, 862, 852, 860, 523, 849, 858, - 845, 860, 859, 854, 844, 838, 837, 850, 534, 502, - - 0, 835, 848, 847, 834, 833, 844, 828, 827, 828, - 864, 839, 842, 829, 836, 835, 819, 820, 817, 818, - 832, 817, 538, 1074, 832, 819, 0, 814, 813, 0, - 816, 827, 826, 0, 1074, 851, 810, 809, 809, 805, - 804, 803, 802, 812, 798, 797, 810, 813, 0, 801, - 794, 805, 804, 798, 0, 797, 0, 0, 795, 789, - 802, 786, 785, 0, 800, 799, 825, 782, 781, 780, - 794, 793, 0, 0, 785, 778, 777, 774, 787, 0, - 0, 780, 779, 768, 767, 776, 783, 768, 764, 762, - 743, 739, 773, 541, 729, 727, 0, 714, 712, 703, - - 704, 700, 0, 700, 681, 657, 517, 525, 664, 662, - 0, 655, 653, 662, 660, 661, 658, 642, 641, 551, - 639, 638, 645, 566, 573, 637, 636, 574, 0, 0, - 0, 0, 0, 0, 0, 577, 576, 587, 1074, 548, - 549, 566, 594, 1074, 562, 561, 558, 0, 0, 569, - 568, 560, 567, 566, 551, 560, 559, 0, 559, 558, - 538, 529, 520, 0, 0, 524, 521, 510, 533, 483, - 482, 484, 0, 0, 490, 461, 457, 445, 420, 0, - 1074, 616, 629, 642, 655, 668, 681, 694, 701, 712, - 725, 738, 749, 756, 764, 772, 783, 791, 437, 388, - - 372, 208, 200, 162, 137, 83, 69, 802 + 0, 1001, 997, 996, 56, 57, 58, 61, 63, 90, + 76, 87, 70, 97, 117, 121, 66, 130, 140, 144, + 79, 107, 99, 109, 153, 159, 148, 152, 201, 998, + 182, 258, 1004, 0, 1009, 1009, 1009, 265, 1009, 1009, + 1009, 320, 153, 313, 153, 1009, 61, 1009, 330, 1009, + 1009, 1009, 961, 1009, 988, 1009, 1009, 1009, 383, 1009, + 1009, 1009, 1009, 1009, 1009, 161, 1009, 1009, 959, 988, + 110, 979, 1009, 986, 1009, 1009, 940, 1009, 169, 144, + 254, 1009, 1009, 1009, 250, 1009, 187, 1009, 1009, 265, + 1009, 1009, 0, 1009, 0, 0, 261, 1009, 1009, 954, + + 1009, 1009, 1009, 266, 953, 0, 1009, 0, 320, 954, + 948, 241, 293, 952, 949, 946, 250, 953, 294, 937, + 303, 245, 150, 311, 943, 950, 953, 1009, 436, 0, + 1009, 0, 0, 346, 480, 962, 1009, 943, 1009, 1009, + 1009, 342, 0, 1009, 1009, 1009, 1009, 1009, 1009, 0, + 1009, 0, 970, 330, 961, 1009, 1009, 1009, 365, 1009, + 369, 1009, 1009, 374, 1009, 378, 382, 951, 1009, 388, + 950, 392, 0, 0, 0, 398, 1009, 934, 942, 374, + 928, 929, 926, 927, 360, 924, 931, 926, 368, 935, + 920, 924, 398, 930, 915, 916, 333, 915, 915, 923, + + 924, 927, 910, 916, 910, 915, 906, 919, 0, 0, + 0, 1009, 908, 402, 0, 0, 0, 423, 431, 453, + 410, 459, 443, 465, 390, 471, 475, 479, 483, 379, + 919, 914, 898, 81, 898, 911, 896, 900, 908, 907, + 906, 929, 890, 901, 888, 925, 904, 897, 898, 415, + 448, 412, 885, 886, 420, 897, 886, 893, 877, 888, + 884, 877, 881, 887, 886, 876, 887, 885, 882, 1009, + 0, 0, 869, 0, 878, 864, 870, 865, 878, 857, + 862, 875, 896, 872, 860, 865, 853, 0, 857, 852, + 865, 333, 864, 859, 862, 857, 847, 859, 851, 842, + + 849, 855, 854, 839, 467, 848, 837, 850, 835, 0, + 840, 0, 839, 837, 0, 876, 0, 0, 826, 0, + 837, 842, 826, 0, 0, 475, 826, 829, 477, 842, + 841, 840, 839, 830, 0, 823, 822, 830, 822, 828, + 820, 814, 812, 0, 811, 0, 848, 824, 822, 811, + 810, 807, 0, 804, 0, 479, 0, 804, 484, 0, + 1009, 0, 802, 802, 816, 797, 796, 480, 799, 801, + 800, 796, 801, 804, 793, 795, 791, 790, 805, 800, + 803, 798, 788, 796, 516, 785, 794, 781, 796, 795, + 790, 780, 774, 773, 786, 519, 495, 0, 771, 784, + + 783, 770, 769, 780, 764, 763, 764, 800, 775, 778, + 765, 772, 771, 755, 756, 753, 754, 768, 753, 525, + 1009, 768, 755, 0, 750, 749, 0, 752, 763, 762, + 0, 1009, 787, 746, 745, 745, 741, 740, 739, 738, + 748, 734, 733, 746, 749, 0, 737, 730, 741, 740, + 734, 0, 733, 0, 0, 731, 725, 738, 722, 721, + 0, 736, 735, 761, 718, 717, 716, 730, 729, 0, + 0, 721, 714, 713, 710, 723, 0, 0, 716, 715, + 704, 703, 712, 719, 714, 705, 701, 683, 679, 710, + 499, 675, 673, 0, 663, 660, 651, 639, 619, 0, + + 616, 611, 607, 511, 513, 615, 615, 0, 607, 606, + 617, 616, 615, 614, 598, 540, 536, 538, 537, 546, + 545, 549, 539, 538, 543, 0, 0, 0, 0, 0, + 0, 0, 546, 545, 556, 1009, 531, 533, 535, 569, + 1009, 531, 530, 527, 0, 0, 538, 532, 524, 531, + 529, 513, 516, 515, 0, 499, 498, 491, 467, 461, + 0, 0, 459, 439, 435, 434, 389, 381, 378, 0, + 0, 390, 366, 347, 350, 307, 0, 1009, 590, 601, + 612, 623, 634, 645, 656, 662, 671, 682, 693, 702, + 708, 713, 722, 729, 286, 277, 259, 187, 179, 173, + + 135, 133, 87, 738 } ; -static yyconst flex_int16_t yy_def[609] = +static const flex_int16_t yy_def[605] = { 0, - 581, 1, 582, 582, 583, 583, 583, 583, 584, 584, - 585, 585, 583, 583, 583, 583, 583, 583, 583, 583, - 583, 583, 583, 583, 583, 583, 583, 583, 581, 29, - 586, 586, 581, 587, 581, 581, 581, 581, 581, 581, - 581, 588, 581, 589, 589, 581, 581, 581, 588, 581, - 581, 581, 587, 581, 581, 581, 581, 581, 590, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 591, - 591, 581, 581, 591, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 592, - 581, 581, 593, 581, 593, 594, 581, 581, 581, 593, - - 581, 581, 581, 581, 581, 587, 595, 581, 596, 595, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 581, 588, - 49, 581, 597, 598, 589, 598, 581, 581, 581, 581, - 581, 581, 581, 599, 581, 581, 581, 581, 581, 581, - 600, 581, 601, 591, 591, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 593, 594, 595, 596, 581, 595, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 597, 598, 136, 581, 581, 581, 602, 603, 601, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 592, 581, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 581, 581, 604, 605, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 581, 606, - 607, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 581, 600, 581, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 581, 596, - - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 581, 581, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 581, 581, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 608, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 608, 608, 596, 596, 596, 596, 596, 596, - - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 581, 581, 596, - 596, 596, 581, 581, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, - 0, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - - 581, 581, 581, 581, 581, 581, 581, 581 + 578, 1, 579, 579, 580, 580, 580, 580, 581, 581, + 582, 582, 580, 580, 580, 580, 580, 580, 580, 580, + 580, 580, 580, 580, 580, 580, 580, 580, 578, 29, + 583, 583, 578, 584, 578, 578, 578, 578, 578, 578, + 578, 585, 578, 586, 586, 578, 578, 578, 585, 578, + 578, 578, 584, 578, 578, 578, 578, 578, 587, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 588, + 588, 578, 578, 588, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 589, + 578, 578, 590, 578, 590, 591, 578, 578, 578, 590, + + 578, 578, 578, 578, 578, 584, 578, 592, 578, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 578, 585, 49, + 578, 593, 594, 586, 594, 578, 578, 578, 578, 578, + 578, 578, 595, 578, 578, 578, 578, 578, 578, 596, + 578, 597, 588, 588, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 590, 591, 592, 578, 578, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + + 592, 592, 592, 592, 592, 592, 592, 592, 593, 594, + 135, 578, 578, 578, 598, 599, 597, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 589, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 578, 578, + 600, 601, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 578, 602, 603, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 578, 596, + 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 578, 592, 592, 592, 592, + + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 578, + 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 578, 578, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 604, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 604, + 604, 592, 592, 592, 592, 592, 592, 592, 592, 592, + + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 578, 578, 592, 592, 592, 578, + 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, + 592, 592, 592, 592, 592, 592, 592, 0, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + + 578, 578, 578, 578 } ; -static yyconst flex_int16_t yy_nxt[1134] = +static const flex_int16_t yy_nxt[1068] = { 0, - 34, 35, 36, 34, 35, 34, 37, 34, 38, 39, - 40, 41, 34, 42, 43, 44, 45, 45, 34, 46, - 47, 48, 40, 34, 49, 49, 49, 49, 50, 34, - 34, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 34, 35, 36, 34, 35, 37, 34, 38, 39, 40, + 41, 34, 42, 43, 44, 45, 45, 34, 46, 47, + 48, 40, 34, 49, 49, 49, 49, 50, 34, 34, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 51, 52, 40, 34, 57, - 57, 61, 61, 58, 58, 71, 155, 86, 62, 62, - 75, 75, 86, 72, 71, 73, 154, 364, 85, 85, - 64, 36, 72, 64, 73, 161, 59, 59, 59, 59, - 65, 363, 162, 66, 87, 64, 36, 67, 64, 87, - - 88, 69, 75, 91, 89, 65, 76, 68, 66, 78, - 92, 74, 67, 279, 79, 60, 60, 60, 60, 75, - 74, 280, 68, 76, 137, 77, 78, 90, 75, 132, - 90, 79, 76, 133, 77, 78, 138, 75, 132, 203, - 79, 76, 133, 80, 78, 321, 75, 75, 204, 79, - 76, 76, 80, 78, 78, 81, 75, 88, 79, 79, - 76, 89, 80, 78, 81, 75, 91, 166, 79, 76, - 320, 80, 78, 92, 81, 102, 36, 79, 102, 135, - 135, 135, 167, 81, 90, 103, 168, 169, 104, 168, - 82, 136, 83, 90, 102, 36, 161, 102, 163, 82, - - 105, 83, 132, 162, 103, 182, 133, 104, 275, 82, - 164, 84, 135, 135, 135, 183, 274, 136, 82, 165, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 51, 52, 40, 34, 57, 57, + 61, 58, 58, 61, 64, 36, 62, 64, 75, 62, + 136, 76, 75, 65, 78, 76, 66, 77, 78, 79, + 67, 75, 137, 79, 59, 59, 59, 71, 85, 59, + 68, 64, 36, 361, 64, 72, 69, 73, 71, 75, + + 65, 86, 76, 66, 77, 78, 72, 67, 73, 75, + 79, 86, 276, 60, 60, 60, 85, 68, 60, 75, + 277, 154, 76, 75, 80, 78, 76, 87, 80, 78, + 79, 153, 75, 74, 79, 76, 81, 87, 78, 360, + 81, 318, 75, 79, 74, 76, 75, 80, 78, 76, + 91, 80, 78, 79, 91, 88, 92, 79, 89, 81, + 92, 88, 131, 81, 89, 160, 132, 134, 134, 134, + 131, 82, 161, 83, 132, 82, 90, 83, 157, 317, + 90, 90, 158, 102, 36, 272, 102, 90, 167, 168, + 201, 167, 103, 271, 82, 104, 84, 159, 82, 202, + 84, 93, 94, 36, 93, 94, 93, 93, 93, 93, - 93, 93, 95, 93, 96, 97, 98, 98, 98, 93, - 93, 93, 93, 93, 93, 96, 96, 96, 96, 93, - 93, 99, 96, 96, 96, 96, 96, 96, 96, 96, + 93, 95, 93, 96, 97, 98, 98, 98, 93, 93, + 93, 93, 93, 93, 96, 96, 96, 96, 93, 93, + 99, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 93, 93, 93, 93, - 107, 107, 107, 107, 107, 107, 107, 107, 108, 107, - 107, 107, 107, 109, 107, 107, 107, 107, 107, 107, - - 107, 107, 107, 110, 109, 109, 109, 109, 107, 107, - 107, 109, 109, 111, 112, 113, 114, 115, 116, 109, - 117, 109, 118, 119, 120, 121, 122, 109, 123, 124, - 125, 126, 127, 109, 128, 129, 107, 107, 107, 106, - 300, 158, 106, 301, 106, 159, 106, 171, 172, 132, - 171, 130, 130, 133, 184, 178, 178, 106, 178, 185, - 160, 190, 106, 194, 186, 191, 198, 201, 106, 106, - 205, 202, 216, 216, 192, 173, 195, 155, 248, 206, - 219, 196, 199, 220, 221, 200, 220, 154, 207, 135, - 135, 135, 222, 223, 249, 222, 218, 106, 581, 224, - - 225, 581, 224, 581, 243, 581, 296, 226, 227, 179, - 226, 168, 169, 297, 168, 244, 581, 229, 172, 253, - 229, 581, 231, 232, 166, 231, 236, 581, 581, 259, - 237, 178, 178, 260, 178, 273, 273, 581, 254, 167, - 220, 221, 238, 220, 158, 217, 222, 223, 159, 222, - 163, 255, 224, 225, 339, 224, 581, 142, 226, 227, - 142, 226, 164, 160, 173, 304, 143, 143, 580, 168, - 169, 165, 168, 340, 142, 229, 172, 144, 229, 353, - 142, 579, 305, 145, 146, 233, 229, 172, 147, 229, - 231, 232, 369, 231, 373, 148, 396, 405, 354, 149, - - 298, 150, 151, 152, 153, 106, 578, 299, 106, 577, - 106, 370, 106, 374, 437, 397, 406, 130, 130, 399, - 399, 399, 576, 106, 423, 423, 423, 423, 106, 526, - 575, 574, 573, 438, 106, 106, 435, 527, 436, 423, - 423, 423, 423, 435, 424, 572, 571, 494, 527, 399, - 399, 399, 538, 538, 538, 538, 527, 570, 569, 424, - 550, 551, 568, 106, 213, 213, 213, 543, 543, 543, - 543, 567, 539, 213, 543, 543, 543, 543, 566, 551, - 551, 213, 213, 213, 213, 213, 213, 544, 538, 538, - 538, 538, 565, 564, 544, 543, 543, 543, 543, 563, - - 562, 561, 560, 559, 558, 557, 556, 555, 539, 554, - 553, 552, 549, 548, 547, 544, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 96, 96, 96, 96, 96, 93, 93, 93, 93, 102, + 36, 162, 102, 165, 105, 217, 170, 171, 103, 170, + 131, 104, 107, 163, 132, 131, 180, 108, 166, 132, + 199, 188, 164, 216, 200, 189, 181, 109, 108, 108, + 108, 108, 215, 172, 190, 108, 108, 110, 111, 112, + + 113, 114, 115, 108, 116, 108, 117, 118, 119, 120, + 121, 108, 122, 123, 124, 125, 126, 108, 127, 128, + 106, 176, 176, 106, 176, 192, 106, 134, 134, 134, + 578, 129, 129, 578, 196, 182, 578, 106, 193, 135, + 183, 154, 106, 194, 336, 184, 203, 578, 106, 106, + 197, 153, 578, 198, 577, 204, 214, 214, 578, 578, + 134, 134, 134, 337, 205, 135, 218, 219, 256, 218, + 220, 221, 257, 220, 177, 222, 223, 106, 222, 224, + 225, 578, 224, 167, 168, 576, 167, 578, 141, 227, + 171, 141, 227, 229, 230, 575, 229, 142, 142, 176, + + 176, 240, 176, 165, 245, 141, 233, 172, 143, 250, + 234, 141, 241, 574, 144, 145, 270, 270, 166, 146, + 246, 573, 235, 572, 218, 219, 147, 218, 251, 571, + 148, 160, 149, 150, 151, 152, 106, 570, 161, 106, + 157, 252, 106, 297, 158, 569, 298, 129, 129, 293, + 162, 301, 177, 106, 220, 221, 294, 220, 106, 159, + 222, 223, 163, 222, 106, 106, 224, 225, 302, 224, + 568, 164, 167, 168, 567, 167, 227, 171, 350, 227, + 227, 171, 295, 227, 229, 230, 366, 229, 370, 296, + 393, 402, 566, 106, 211, 211, 211, 351, 396, 396, + + 396, 432, 565, 211, 491, 367, 434, 371, 564, 394, + 403, 211, 211, 211, 211, 211, 211, 420, 420, 420, + 420, 432, 523, 433, 524, 435, 420, 420, 420, 420, + 563, 562, 561, 396, 396, 396, 421, 535, 535, 535, + 535, 524, 547, 524, 548, 421, 540, 540, 540, 540, + 540, 540, 540, 540, 560, 559, 536, 535, 535, 535, + 535, 548, 558, 548, 557, 541, 556, 555, 554, 541, + 540, 540, 540, 540, 553, 552, 536, 551, 550, 549, + 546, 545, 544, 543, 542, 539, 538, 537, 534, 541, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + + 54, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 106, 546, 545, 106, 542, 106, 106, 541, 540, - 537, 536, 535, 106, 131, 534, 533, 131, 532, 131, - - 131, 531, 131, 530, 131, 529, 131, 134, 528, 134, - 525, 134, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 524, 154, 154, 154, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 174, - 523, 522, 174, 174, 174, 521, 520, 519, 174, 518, - 174, 175, 175, 517, 175, 516, 175, 176, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 177, 177, 494, - 177, 515, 177, 211, 211, 514, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 211, 212, 212, 513, 212, - - 512, 212, 493, 493, 511, 493, 493, 493, 493, 493, - 493, 493, 493, 493, 493, 510, 509, 508, 507, 506, - 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, - 495, 494, 492, 491, 490, 489, 488, 487, 486, 485, - 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, - 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, - 464, 463, 462, 461, 460, 459, 458, 457, 456, 455, - 454, 453, 452, 451, 450, 449, 448, 447, 446, 445, - 444, 443, 442, 441, 440, 439, 434, 433, 432, 431, - 430, 429, 428, 427, 426, 425, 422, 421, 420, 419, - - 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, - 408, 407, 404, 403, 402, 401, 400, 398, 395, 394, - 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, - 383, 382, 381, 380, 379, 378, 377, 376, 375, 372, - 371, 368, 367, 366, 365, 362, 361, 360, 359, 358, - 357, 356, 355, 352, 351, 350, 349, 348, 347, 346, - 345, 344, 343, 342, 341, 338, 337, 336, 335, 334, - 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, - 323, 322, 319, 318, 317, 316, 315, 314, 313, 312, - 311, 310, 309, 308, 307, 306, 303, 302, 295, 294, - - 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, - 283, 282, 281, 278, 277, 276, 272, 271, 270, 269, - 268, 267, 266, 265, 264, 263, 262, 261, 258, 257, - 256, 252, 251, 250, 247, 246, 245, 242, 241, 240, - 239, 235, 234, 230, 228, 156, 155, 215, 214, 210, - 209, 208, 197, 193, 189, 188, 187, 181, 180, 139, - 139, 157, 155, 156, 155, 139, 140, 139, 581, 100, - 55, 55, 53, 33, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581 + 63, 63, 63, 70, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 106, 533, 532, 531, 106, + 106, 530, 529, 528, 527, 106, 130, 526, 525, 522, + 130, 130, 130, 521, 130, 520, 130, 133, 133, 519, + 133, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 153, 153, 153, 153, 153, 153, 153, 518, + 153, 153, 153, 169, 169, 169, 169, 169, 169, 169, + + 169, 169, 173, 517, 516, 173, 173, 515, 514, 173, + 513, 173, 174, 174, 174, 491, 174, 175, 175, 175, + 512, 175, 209, 209, 511, 209, 209, 209, 209, 209, + 209, 209, 209, 210, 210, 210, 510, 210, 490, 490, + 509, 490, 490, 490, 490, 490, 490, 490, 490, 508, + 507, 506, 505, 504, 503, 502, 501, 500, 499, 498, + 497, 496, 495, 494, 493, 492, 491, 489, 488, 487, + 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, + 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, + 466, 465, 464, 463, 462, 461, 460, 459, 458, 457, + + 456, 455, 454, 453, 452, 451, 450, 449, 448, 447, + 446, 445, 444, 443, 442, 441, 440, 439, 438, 437, + 436, 431, 430, 429, 428, 427, 426, 425, 424, 423, + 422, 419, 418, 417, 416, 415, 414, 413, 412, 411, + 410, 409, 408, 407, 406, 405, 404, 401, 400, 399, + 398, 397, 395, 392, 391, 390, 389, 388, 387, 386, + 385, 384, 383, 382, 381, 380, 379, 378, 377, 376, + 375, 374, 373, 372, 369, 368, 365, 364, 363, 362, + 359, 358, 357, 356, 355, 354, 353, 352, 349, 348, + 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, + + 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, + 325, 324, 323, 322, 321, 320, 319, 316, 315, 314, + 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, + 303, 300, 299, 292, 291, 290, 289, 288, 287, 286, + 285, 284, 283, 282, 281, 280, 279, 278, 275, 274, + 273, 269, 268, 267, 266, 265, 264, 263, 262, 261, + 260, 259, 258, 255, 254, 253, 249, 248, 247, 244, + 243, 242, 239, 238, 237, 236, 232, 231, 228, 226, + 155, 154, 213, 212, 208, 207, 206, 195, 191, 187, + 186, 185, 179, 178, 138, 138, 156, 154, 155, 154, + + 138, 139, 138, 578, 100, 55, 55, 53, 33, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578 } ; -static yyconst flex_int16_t yy_chk[1134] = +static const flex_int16_t yy_chk[1068] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, - 6, 7, 8, 5, 6, 11, 71, 23, 7, 8, - 21, 22, 24, 11, 12, 11, 71, 607, 21, 22, - 9, 9, 12, 9, 12, 80, 5, 6, 7, 8, - 9, 606, 80, 9, 23, 10, 10, 9, 10, 24, - - 25, 10, 17, 27, 25, 10, 17, 9, 10, 17, - 27, 11, 10, 237, 17, 5, 6, 7, 8, 13, - 12, 237, 10, 13, 47, 13, 13, 25, 14, 43, - 27, 13, 14, 43, 14, 14, 47, 15, 66, 124, - 14, 15, 66, 15, 15, 605, 16, 18, 124, 15, - 16, 18, 16, 16, 18, 15, 19, 26, 16, 18, - 19, 26, 19, 19, 16, 20, 28, 85, 19, 20, - 604, 20, 20, 28, 19, 31, 31, 20, 31, 44, - 44, 44, 85, 20, 26, 31, 87, 87, 31, 87, - 15, 44, 15, 28, 32, 32, 223, 32, 81, 16, - - 32, 16, 97, 223, 32, 113, 97, 32, 603, 19, - 81, 19, 45, 45, 45, 113, 602, 44, 20, 81, + 1, 1, 1, 1, 1, 1, 1, 1, 5, 6, + 7, 5, 6, 8, 9, 9, 7, 9, 17, 8, + 47, 17, 13, 9, 17, 13, 9, 13, 13, 17, + 9, 21, 47, 13, 5, 6, 7, 11, 21, 8, + 9, 10, 10, 603, 10, 11, 10, 11, 12, 14, + + 10, 23, 14, 10, 14, 14, 12, 10, 12, 22, + 14, 24, 234, 5, 6, 7, 22, 10, 8, 15, + 234, 71, 15, 16, 15, 15, 16, 23, 16, 16, + 15, 71, 18, 11, 16, 18, 15, 24, 18, 602, + 16, 601, 19, 18, 12, 19, 20, 19, 19, 20, + 27, 20, 20, 19, 28, 25, 27, 20, 25, 19, + 28, 26, 43, 20, 26, 80, 43, 45, 45, 45, + 66, 15, 80, 15, 66, 16, 27, 16, 79, 600, + 28, 25, 79, 31, 31, 599, 31, 26, 87, 87, + 123, 87, 31, 598, 19, 31, 19, 79, 20, 123, + 20, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 32, + 32, 81, 32, 85, 32, 597, 90, 90, 32, 90, + 97, 32, 38, 81, 97, 104, 112, 38, 85, 104, + 122, 117, 81, 596, 122, 117, 112, 38, 38, 38, + 38, 38, 595, 90, 117, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 42, - 255, 79, 42, 255, 42, 79, 42, 90, 90, 104, - 90, 42, 42, 104, 114, 110, 110, 42, 110, 114, - 79, 118, 42, 120, 114, 118, 122, 123, 42, 42, - 125, 123, 143, 143, 118, 90, 120, 155, 191, 125, - 601, 120, 122, 160, 160, 122, 160, 155, 125, 135, - 135, 135, 162, 162, 191, 162, 600, 42, 49, 165, - - 165, 49, 165, 49, 187, 49, 253, 167, 167, 110, - 167, 168, 168, 253, 168, 187, 49, 171, 171, 195, - 171, 49, 173, 173, 227, 173, 182, 49, 49, 199, - 182, 178, 178, 199, 178, 216, 216, 232, 195, 227, - 220, 220, 182, 220, 221, 599, 222, 222, 221, 222, - 225, 195, 224, 224, 295, 224, 49, 59, 226, 226, - 59, 226, 225, 221, 232, 258, 59, 59, 579, 228, - 228, 225, 228, 295, 59, 229, 229, 59, 229, 308, - 59, 578, 258, 59, 59, 178, 230, 230, 59, 230, - 231, 231, 329, 231, 332, 59, 359, 371, 308, 59, - - 254, 59, 59, 59, 59, 130, 577, 254, 130, 576, - 130, 329, 130, 332, 400, 359, 371, 130, 130, 362, - 362, 362, 575, 130, 388, 388, 388, 388, 130, 507, - 572, 571, 570, 400, 130, 130, 399, 508, 399, 423, - 423, 423, 423, 494, 388, 569, 568, 494, 507, 399, - 399, 399, 520, 520, 520, 520, 508, 567, 566, 423, - 540, 541, 563, 130, 136, 136, 136, 524, 524, 524, - 524, 562, 520, 136, 525, 525, 525, 525, 561, 540, - 541, 136, 136, 136, 136, 136, 136, 524, 538, 538, - 538, 538, 560, 559, 525, 543, 543, 543, 543, 557, - - 556, 555, 554, 553, 552, 551, 550, 547, 538, 546, - 545, 542, 537, 536, 528, 543, 582, 582, 582, 582, - 582, 582, 582, 582, 582, 582, 582, 582, 582, 583, - 583, 583, 583, 583, 583, 583, 583, 583, 583, 583, - 583, 583, 584, 584, 584, 584, 584, 584, 584, 584, - 584, 584, 584, 584, 584, 585, 585, 585, 585, 585, - 585, 585, 585, 585, 585, 585, 585, 585, 586, 586, - 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, - 586, 587, 527, 526, 587, 523, 587, 587, 522, 521, - 519, 518, 517, 587, 588, 516, 515, 588, 514, 588, - - 588, 513, 588, 512, 588, 510, 588, 589, 509, 589, - 506, 589, 590, 590, 590, 590, 590, 590, 590, 590, - 590, 590, 590, 590, 590, 591, 591, 591, 591, 591, - 591, 591, 591, 591, 505, 591, 591, 591, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 593, - 504, 502, 593, 593, 593, 501, 500, 499, 593, 498, - 593, 594, 594, 496, 594, 495, 594, 595, 595, 595, - 595, 595, 595, 595, 595, 595, 595, 596, 596, 493, - 596, 492, 596, 597, 597, 491, 597, 597, 597, 597, - 597, 597, 597, 597, 597, 597, 598, 598, 490, 598, - - 489, 598, 608, 608, 488, 608, 608, 608, 608, 608, - 608, 608, 608, 608, 608, 487, 486, 485, 484, 483, - 482, 479, 478, 477, 476, 475, 472, 471, 470, 469, - 468, 467, 466, 465, 463, 462, 461, 460, 459, 456, - 454, 453, 452, 451, 450, 448, 447, 446, 445, 444, - 443, 442, 441, 440, 439, 438, 437, 436, 433, 432, - 431, 429, 428, 426, 425, 422, 421, 420, 419, 418, - 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, - 407, 406, 405, 404, 403, 402, 398, 397, 396, 395, - 394, 393, 392, 391, 390, 389, 387, 386, 385, 384, - - 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, - 373, 372, 370, 369, 368, 367, 366, 361, 357, 355, - 354, 353, 352, 351, 350, 348, 346, 345, 344, 343, - 342, 341, 340, 339, 337, 336, 335, 334, 333, 331, - 330, 326, 325, 324, 322, 319, 317, 316, 314, 312, - 311, 310, 309, 307, 306, 305, 304, 303, 302, 301, - 300, 299, 298, 297, 296, 294, 293, 292, 290, 289, - 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, - 278, 276, 272, 271, 270, 269, 268, 267, 266, 265, - 264, 263, 262, 261, 260, 259, 257, 256, 252, 251, - - 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, - 240, 239, 238, 236, 235, 234, 215, 210, 209, 208, - 207, 206, 205, 204, 203, 202, 201, 200, 198, 197, - 196, 194, 193, 192, 190, 189, 188, 186, 185, 184, - 183, 181, 180, 172, 169, 156, 154, 139, 137, 128, - 127, 126, 121, 119, 117, 116, 115, 112, 111, 105, - 100, 77, 74, 72, 70, 69, 55, 53, 33, 30, - 4, 3, 2, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581 + 42, 109, 109, 42, 109, 119, 42, 44, 44, 44, + 49, 42, 42, 49, 121, 113, 49, 42, 119, 44, + 113, 154, 42, 119, 292, 113, 124, 49, 42, 42, + 121, 154, 49, 121, 576, 124, 142, 142, 49, 49, + 134, 134, 134, 292, 124, 44, 159, 159, 197, 159, + 161, 161, 197, 161, 109, 164, 164, 42, 164, 166, + 166, 230, 166, 167, 167, 575, 167, 49, 59, 170, + 170, 59, 170, 172, 172, 574, 172, 59, 59, 176, + + 176, 185, 176, 225, 189, 59, 180, 230, 59, 193, + 180, 59, 185, 573, 59, 59, 214, 214, 225, 59, + 189, 572, 180, 569, 218, 218, 59, 218, 193, 568, + 59, 221, 59, 59, 59, 59, 129, 567, 221, 129, + 219, 193, 129, 252, 219, 566, 252, 129, 129, 250, + 223, 255, 176, 129, 220, 220, 250, 220, 129, 219, + 222, 222, 223, 222, 129, 129, 224, 224, 255, 224, + 565, 223, 226, 226, 564, 226, 227, 227, 305, 227, + 228, 228, 251, 228, 229, 229, 326, 229, 329, 251, + 356, 368, 563, 129, 135, 135, 135, 305, 359, 359, + + 359, 491, 560, 135, 491, 326, 397, 329, 559, 356, + 368, 135, 135, 135, 135, 135, 135, 385, 385, 385, + 385, 396, 504, 396, 505, 397, 420, 420, 420, 420, + 558, 557, 556, 396, 396, 396, 385, 517, 517, 517, + 517, 504, 537, 505, 538, 420, 521, 521, 521, 521, + 522, 522, 522, 522, 554, 553, 517, 535, 535, 535, + 535, 537, 552, 538, 551, 521, 550, 549, 548, 522, + 540, 540, 540, 540, 547, 544, 535, 543, 542, 539, + 534, 533, 525, 524, 523, 520, 519, 518, 516, 540, + 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, + + 579, 580, 580, 580, 580, 580, 580, 580, 580, 580, + 580, 580, 581, 581, 581, 581, 581, 581, 581, 581, + 581, 581, 581, 582, 582, 582, 582, 582, 582, 582, + 582, 582, 582, 582, 583, 583, 583, 583, 583, 583, + 583, 583, 583, 583, 583, 584, 515, 514, 513, 584, + 584, 512, 511, 510, 509, 584, 585, 507, 506, 503, + 585, 585, 585, 502, 585, 501, 585, 586, 586, 499, + 586, 587, 587, 587, 587, 587, 587, 587, 587, 587, + 587, 587, 588, 588, 588, 588, 588, 588, 588, 498, + 588, 588, 588, 589, 589, 589, 589, 589, 589, 589, + + 589, 589, 590, 497, 496, 590, 590, 495, 493, 590, + 492, 590, 591, 591, 591, 490, 591, 592, 592, 592, + 489, 592, 593, 593, 488, 593, 593, 593, 593, 593, + 593, 593, 593, 594, 594, 594, 487, 594, 604, 604, + 486, 604, 604, 604, 604, 604, 604, 604, 604, 485, + 484, 483, 482, 481, 480, 479, 476, 475, 474, 473, + 472, 469, 468, 467, 466, 465, 464, 463, 462, 460, + 459, 458, 457, 456, 453, 451, 450, 449, 448, 447, + 445, 444, 443, 442, 441, 440, 439, 438, 437, 436, + 435, 434, 433, 430, 429, 428, 426, 425, 423, 422, + + 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, + 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, + 399, 395, 394, 393, 392, 391, 390, 389, 388, 387, + 386, 384, 383, 382, 381, 380, 379, 378, 377, 376, + 375, 374, 373, 372, 371, 370, 369, 367, 366, 365, + 364, 363, 358, 354, 352, 351, 350, 349, 348, 347, + 345, 343, 342, 341, 340, 339, 338, 337, 336, 334, + 333, 332, 331, 330, 328, 327, 323, 322, 321, 319, + 316, 314, 313, 311, 309, 308, 307, 306, 304, 303, + 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, + + 291, 290, 289, 287, 286, 285, 284, 283, 282, 281, + 280, 279, 278, 277, 276, 275, 273, 269, 268, 267, + 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, + 256, 254, 253, 249, 248, 247, 246, 245, 244, 243, + 242, 241, 240, 239, 238, 237, 236, 235, 233, 232, + 231, 213, 208, 207, 206, 205, 204, 203, 202, 201, + 200, 199, 198, 196, 195, 194, 192, 191, 190, 188, + 187, 186, 184, 183, 182, 181, 179, 178, 171, 168, + 155, 153, 138, 136, 127, 126, 125, 120, 118, 116, + 115, 114, 111, 110, 105, 100, 77, 74, 72, 70, + + 69, 55, 53, 33, 30, 4, 3, 2, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, + 578, 578, 578, 578, 578, 578, 578 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int gram__flex_debug; -int gram__flex_debug = 1; +extern int yy_flex_debug; +int yy_flex_debug = 1; -static yyconst flex_int16_t yy_rule_linenum[130] = +static const flex_int16_t yy_rule_linenum[130] = { 0, - 179, 182, 183, 184, 192, 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, - 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, - 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 269, 273, 274, 275, 277, 284, 288, 295, 300, - 303, 306, 309, 317, 324, 325, 326, 332, 339, 346, - 366, 376, 391, 396, 415, 428, 444, 459, 476, 477, - 488, 499, 500, 512, 520, 530, 549, 561, 575, 576, - - 587, 596, 606, 607, 608, 609, 610, 611, 612, 615, - 617, 625, 643, 648, 649, 655, 656, 667, 673, 679, - 685, 701, 702, 706, 713, 730, 751, 784, 785 + 186, 189, 190, 191, 199, 217, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, + 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, + 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 276, 280, 281, 282, 284, 291, 295, 302, 307, + 310, 313, 316, 324, 331, 332, 333, 339, 346, 353, + 373, 383, 398, 403, 422, 435, 451, 466, 483, 484, + 495, 506, 507, 519, 527, 537, 556, 568, 582, 583, + + 594, 603, 613, 614, 615, 616, 617, 618, 619, 622, + 624, 632, 650, 655, 656, 662, 663, 674, 680, 686, + 692, 708, 709, 713, 720, 737, 758, 791, 792 } ; /* The intent behind this definition is that it'll catch @@ -1015,11 +1224,11 @@ static yyconst flex_int16_t yy_rule_linenum[130] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *gram_text; -#line 1 "../../src/scan-gram.l" +char *yytext; +#line 1 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -1036,7 +1245,7 @@ char *gram_text; You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 -#line 24 "../../src/scan-gram.l" +#line 24 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Work around a bug in flex 2.5.31. See Debian bug 333231 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ #undef gram_wrap @@ -1061,16 +1270,13 @@ char *gram_text; #define YY_DECL GRAM_LEX_DECL -#define YY_USER_INIT \ - code_start = scanner_cursor = loc->start; \ - /* Location of scanner cursor. */ static boundary scanner_cursor; -#define YY_USER_ACTION location_compute (loc, &scanner_cursor, gram_text, gram_leng); +#define YY_USER_ACTION location_compute (loc, &scanner_cursor, yytext, yyleng); static size_t no_cr_read (FILE *, char *, size_t); -#define YY_INPUT(buf, result, size) ((result) = no_cr_read (gram_in, buf, size)) +#define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size)) #define RETURN_PERCENT_PARAM(Value) \ RETURN_VALUE(PERCENT_PARAM, param, param_ ## Value) @@ -1086,14 +1292,14 @@ static size_t no_cr_read (FILE *, char *, size_t); #define ROLLBACK_CURRENT_TOKEN \ do { \ - scanner_cursor.column -= mbsnwidth (gram_text, gram_leng, 0); \ + scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \ yyless (0); \ } while (0) #define DEPRECATED(Msg) \ do { \ size_t i; \ - deprecated_directive (loc, gram_text, Msg); \ + deprecated_directive (loc, yytext, Msg); \ scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \ for (i = strlen (Msg); i != 0; --i) \ unput (Msg[i - 1]); \ @@ -1115,41 +1321,43 @@ gram_scanner_last_string_free (void) } static void handle_syncline (char *, location); -static unsigned long int scan_integer (char const *p, int base, location loc); +static unsigned long scan_integer (char const *p, int base, location loc); static int convert_ucn_to_byte (char const *hex_text); static void unexpected_eof (boundary, char const *); static void unexpected_newline (boundary, char const *); -/* A C-like comment in directives/rules. */ +#line 1329 "src/scan-gram.c" +#line 106 "/Users/akim/src/gnu/bison/src/scan-gram.l" + /* A C-like comment in directives/rules. */ -/* Strings and characters in directives/rules. */ + /* Strings and characters in directives/rules. */ -/* A identifier was just read in directives/rules. Special state -to capture the sequence 'identifier :'. */ + /* A identifier was just read in directives/rules. Special state + to capture the sequence 'identifier :'. */ -/* POSIX says that a tag must be both an id and a C union member, but -historically almost any character is allowed in a tag. We -disallow NUL, as this simplifies our implementation. We match -angle brackets in nested pairs: several languages use them for -generics/template types. */ + /* POSIX says that a tag must be both an id and a C union member, but + historically almost any character is allowed in a tag. We + disallow NUL, as this simplifies our implementation. We match + angle brackets in nested pairs: several languages use them for + generics/template types. */ -/* Four types of user code: -- prologue (code between '%{' '%}' in the first section, before %%); -- actions, printers, union, etc, (between braced in the middle section); -- epilogue (everything after the second %%). -- predicate (code between '%?{' and '{' in middle section); */ + /* Four types of user code: + - prologue (code between '%{' '%}' in the first section, before %%); + - actions, printers, union, etc, (between braced in the middle section); + - epilogue (everything after the second %%). + - predicate (code between '%?{' and '{' in middle section); */ -/* C and C++ comments in code. */ + /* C and C++ comments in code. */ -/* Strings and characters in code. */ + /* Strings and characters in code. */ -/* Bracketed identifiers support. */ + /* Bracketed identifiers support. */ /* Zero or more instances of backslash-newline. Following GCC, allow white space between the backslash and the newline. */ /* An equal sign, with optional leading whitespaces. This is used in some deprecated constructs. */ -#line 1153 "src/scan-gram.c" +#line 1360 "src/scan-gram.c" #define INITIAL 0 #define SC_YACC_COMMENT 1 @@ -1188,7 +1396,7 @@ generics/template types. */ /* %if-reentrant */ /* %if-c-only */ -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* %endif */ /* %if-reentrant */ @@ -1198,31 +1406,31 @@ static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int gram_lex_destroy (void ); +int yylex_destroy ( void ); -int gram_get_debug (void ); +int yyget_debug ( void ); -void gram_set_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE gram_get_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void gram_set_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *gram_get_in (void ); +FILE *yyget_in ( void ); -void gram_set_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *gram_get_out (void ); +FILE *yyget_out ( void ); -void gram_set_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t gram_get_leng (void ); + int yyget_leng ( void ); -char *gram_get_text (void ); +char *yyget_text ( void ); -int gram_get_lineno (void ); +int yyget_lineno ( void ); -void gram_set_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* %if-bison-bridge */ /* %endif */ @@ -1233,36 +1441,37 @@ void gram_set_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int gram_wrap (void ); +extern "C" int yywrap ( void ); #else -extern int gram_wrap (void ); +extern int yywrap ( void ); #endif #endif /* %not-for-header */ - - static void yyunput (int c,char *buf_ptr ); +#ifndef YY_NO_UNPUT + static void yyunput ( int c, char *buf_ptr ); + +#endif /* %ok-for-header */ /* %endif */ #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif /* %ok-for-header */ @@ -1275,7 +1484,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1284,7 +1498,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( gram_text, gram_leng, 1, gram_out )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ @@ -1299,20 +1513,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ - (c = getc( gram_in )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( gram_in ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, gram_in))==0 && ferror(gram_in)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -1320,7 +1534,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(gram_in); \ + clearerr(yyin); \ } \ }\ \ @@ -1353,11 +1567,9 @@ static int input (void ); /* %if-tables-serialization structures and prototypes */ /* %not-for-header */ - /* %ok-for-header */ /* %not-for-header */ - /* %tables-yydmap generated elements */ /* %endif */ /* end tables serialization structures and prototypes */ @@ -1371,15 +1583,15 @@ static int input (void ); #define YY_DECL_IS_OURS 1 /* %if-c-only Standard (non-C++) definition */ -extern int gram_lex (void); +extern int yylex (void); -#define YY_DECL int gram_lex (void) +#define YY_DECL int yylex (void) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after gram_text and gram_leng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1388,28 +1600,62 @@ extern int gram_lex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif /* %% [6.0] YY_RULE_SETUP definition goes here */ #define YY_RULE_SETUP \ - if ( gram_leng > 0 ) \ + if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (gram_text[gram_leng - 1] == '\n'); \ + (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /* %not-for-header */ - /** The main scanner function which does all the work. */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) +/* %if-c-only */ + yyin = stdin; +/* %endif */ +/* %if-c++-only */ +/* %endif */ + + if ( ! yyout ) +/* %if-c-only */ + yyout = stdout; +/* %endif */ +/* %if-c++-only */ +/* %endif */ + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { /* %% [7.0] user's declarations go here */ -#line 149 "../../src/scan-gram.l" +#line 147 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Nesting level. Either for nested braces, or nested angle brackets @@ -1423,7 +1669,7 @@ YY_DECL location id_loc PACIFY_CC (= empty_location); /* Where containing code started, when applicable. Its initial - value is relevant only when gram_lex is invoked in the SC_EPILOGUE + value is relevant only when yylex is invoked in the SC_EPILOGUE start condition. */ boundary code_start = scanner_cursor; @@ -1431,54 +1677,29 @@ YY_DECL when applicable. */ boundary token_start PACIFY_CC (= scanner_cursor); + /* We cannot trust YY_USER_INIT, whose semantics changes over time + (it moved in Flex 2.5.38). */ + static bool first = true; + if (first) + { + scanner_cursor = loc->start; + first = false; + } + /*-----------------------. | Scanning white space. | `-----------------------*/ -#line 1441 "src/scan-gram.c" +#line 1695 "src/scan-gram.c" - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! gram_in ) -/* %if-c-only */ - gram_in = stdin; -/* %endif */ -/* %if-c++-only */ -/* %endif */ - - if ( ! gram_out ) -/* %if-c-only */ - gram_out = stdout; -/* %endif */ -/* %if-c++-only */ -/* %endif */ - - if ( ! YY_CURRENT_BUFFER ) { - gram_ensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - gram__create_buffer(gram_in,YY_BUF_SIZE ); - } - - gram__load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { /* %% [8.0] yymore()-related code goes here */ yy_cp = (yy_c_buf_p); - /* Support of gram_text. */ + /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of @@ -1492,7 +1713,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1501,13 +1722,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 582 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 579 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 581 ); + while ( yy_current_state != 578 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1517,21 +1738,21 @@ yy_find_action: YY_DO_BEFORE_ACTION; -/* %% [11.0] code for gram_lineno update goes here */ +/* %% [11.0] code for yylineno update goes here */ do_action: /* This label is used only to access EOF actions. */ /* %% [12.0] debug code goes here */ - if ( gram__flex_debug ) + if ( yy_flex_debug ) { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); else if ( yy_act < 130 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], gram_text ); + (long)yy_rule_linenum[yy_act], yytext ); else if ( yy_act == 130 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", - gram_text ); + yytext ); else if ( yy_act == 131 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else @@ -1551,23 +1772,23 @@ do_action: /* This label is used only to access EOF actions. */ /* Comments and white space. */ case 1: YY_RULE_SETUP -#line 179 "../../src/scan-gram.l" +#line 186 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, Wother, _("stray ',' treated as white space")); } YY_BREAK case 2: /* rule 2 can match eol */ -#line 183 "../../src/scan-gram.l" +#line 190 "/Users/akim/src/gnu/bison/src/scan-gram.l" case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 183 "../../src/scan-gram.l" +#line 190 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case 4: YY_RULE_SETUP -#line 184 "../../src/scan-gram.l" +#line 191 "/Users/akim/src/gnu/bison/src/scan-gram.l" { token_start = loc->start; context_state = YY_START; @@ -1579,9 +1800,9 @@ YY_RULE_SETUP case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 192 "../../src/scan-gram.l" +#line 199 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - handle_syncline (gram_text + sizeof "#line " - 1, *loc); + handle_syncline (yytext + sizeof "#line " - 1, *loc); } YY_BREAK @@ -1597,316 +1818,315 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP -#line 210 "../../src/scan-gram.l" +#line 217 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 7: YY_RULE_SETUP -#line 211 "../../src/scan-gram.l" +#line 218 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_CODE; YY_BREAK case 8: YY_RULE_SETUP -#line 212 "../../src/scan-gram.l" +#line 219 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_FLAG("parse.trace"); YY_BREAK case 9: YY_RULE_SETUP -#line 213 "../../src/scan-gram.l" +#line 220 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_DEFAULT_PREC; YY_BREAK case 10: YY_RULE_SETUP -#line 214 "../../src/scan-gram.l" +#line 221 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_DEFINE; YY_BREAK case 11: YY_RULE_SETUP -#line 215 "../../src/scan-gram.l" +#line 222 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_DEFINES; YY_BREAK case 12: YY_RULE_SETUP -#line 216 "../../src/scan-gram.l" +#line 223 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_DESTRUCTOR; YY_BREAK case 13: YY_RULE_SETUP -#line 217 "../../src/scan-gram.l" +#line 224 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_DPREC; YY_BREAK case 14: YY_RULE_SETUP -#line 218 "../../src/scan-gram.l" +#line 225 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_EMPTY; YY_BREAK case 15: YY_RULE_SETUP -#line 219 "../../src/scan-gram.l" +#line 226 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_ERROR_VERBOSE; YY_BREAK case 16: YY_RULE_SETUP -#line 220 "../../src/scan-gram.l" +#line 227 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_EXPECT; YY_BREAK case 17: YY_RULE_SETUP -#line 221 "../../src/scan-gram.l" +#line 228 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_EXPECT_RR; YY_BREAK case 18: YY_RULE_SETUP -#line 222 "../../src/scan-gram.l" +#line 229 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_FILE_PREFIX; YY_BREAK case 19: YY_RULE_SETUP -#line 223 "../../src/scan-gram.l" +#line 230 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_YACC; YY_BREAK case 20: YY_RULE_SETUP -#line 224 "../../src/scan-gram.l" +#line 231 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_INITIAL_ACTION; YY_BREAK case 21: YY_RULE_SETUP -#line 225 "../../src/scan-gram.l" +#line 232 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_GLR_PARSER; YY_BREAK case 22: YY_RULE_SETUP -#line 226 "../../src/scan-gram.l" +#line 233 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_LANGUAGE; YY_BREAK case 23: YY_RULE_SETUP -#line 227 "../../src/scan-gram.l" +#line 234 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_LEFT; YY_BREAK case 24: YY_RULE_SETUP -#line 228 "../../src/scan-gram.l" +#line 235 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM(lex); YY_BREAK case 25: YY_RULE_SETUP -#line 229 "../../src/scan-gram.l" +#line 236 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_FLAG("locations"); YY_BREAK case 26: YY_RULE_SETUP -#line 230 "../../src/scan-gram.l" +#line 237 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_MERGE; YY_BREAK case 27: YY_RULE_SETUP -#line 231 "../../src/scan-gram.l" +#line 238 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NAME_PREFIX; YY_BREAK case 28: YY_RULE_SETUP -#line 232 "../../src/scan-gram.l" +#line 239 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NO_DEFAULT_PREC; YY_BREAK case 29: YY_RULE_SETUP -#line 233 "../../src/scan-gram.l" +#line 240 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NO_LINES; YY_BREAK case 30: YY_RULE_SETUP -#line 234 "../../src/scan-gram.l" +#line 241 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 31: YY_RULE_SETUP -#line 235 "../../src/scan-gram.l" +#line 242 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NONDETERMINISTIC_PARSER; YY_BREAK case 32: YY_RULE_SETUP -#line 236 "../../src/scan-gram.l" +#line 243 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NTERM; YY_BREAK case 33: YY_RULE_SETUP -#line 237 "../../src/scan-gram.l" +#line 244 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_OUTPUT; YY_BREAK case 34: YY_RULE_SETUP -#line 238 "../../src/scan-gram.l" +#line 245 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM(both); YY_BREAK case 35: YY_RULE_SETUP -#line 239 "../../src/scan-gram.l" +#line 246 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM(parse); YY_BREAK case 36: YY_RULE_SETUP -#line 240 "../../src/scan-gram.l" +#line 247 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_PREC; YY_BREAK case 37: YY_RULE_SETUP -#line 241 "../../src/scan-gram.l" +#line 248 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_PRECEDENCE; YY_BREAK case 38: YY_RULE_SETUP -#line 242 "../../src/scan-gram.l" +#line 249 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_PRINTER; YY_BREAK case 39: YY_RULE_SETUP -#line 243 "../../src/scan-gram.l" +#line 250 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_FLAG("api.pure"); YY_BREAK case 40: YY_RULE_SETUP -#line 244 "../../src/scan-gram.l" +#line 251 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_REQUIRE; YY_BREAK case 41: YY_RULE_SETUP -#line 245 "../../src/scan-gram.l" +#line 252 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_RIGHT; YY_BREAK case 42: YY_RULE_SETUP -#line 246 "../../src/scan-gram.l" +#line 253 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_SKELETON; YY_BREAK case 43: YY_RULE_SETUP -#line 247 "../../src/scan-gram.l" +#line 254 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_START; YY_BREAK case 44: YY_RULE_SETUP -#line 248 "../../src/scan-gram.l" +#line 255 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 45: YY_RULE_SETUP -#line 249 "../../src/scan-gram.l" +#line 256 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 46: YY_RULE_SETUP -#line 250 "../../src/scan-gram.l" +#line 257 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TOKEN_TABLE; YY_BREAK case 47: YY_RULE_SETUP -#line 251 "../../src/scan-gram.l" +#line 258 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TYPE; YY_BREAK case 48: YY_RULE_SETUP -#line 252 "../../src/scan-gram.l" +#line 259 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_UNION; YY_BREAK case 49: YY_RULE_SETUP -#line 253 "../../src/scan-gram.l" +#line 260 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_VERBOSE; YY_BREAK case 50: YY_RULE_SETUP -#line 254 "../../src/scan-gram.l" +#line 261 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_YACC; YY_BREAK /* deprecated */ case 51: YY_RULE_SETUP -#line 257 "../../src/scan-gram.l" +#line 264 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%default-prec"); YY_BREAK case 52: YY_RULE_SETUP -#line 258 "../../src/scan-gram.l" +#line 265 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%define parse.error verbose"); YY_BREAK case 53: YY_RULE_SETUP -#line 259 "../../src/scan-gram.l" +#line 266 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%expect-rr"); YY_BREAK case 54: /* rule 54 can match eol */ YY_RULE_SETUP -#line 260 "../../src/scan-gram.l" +#line 267 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%file-prefix"); YY_BREAK case 55: YY_RULE_SETUP -#line 261 "../../src/scan-gram.l" +#line 268 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%fixed-output-files"); YY_BREAK case 56: /* rule 56 can match eol */ YY_RULE_SETUP -#line 262 "../../src/scan-gram.l" +#line 269 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%name-prefix"); YY_BREAK case 57: YY_RULE_SETUP -#line 263 "../../src/scan-gram.l" +#line 270 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%no-default-prec"); YY_BREAK case 58: YY_RULE_SETUP -#line 264 "../../src/scan-gram.l" +#line 271 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%no-lines"); YY_BREAK case 59: /* rule 59 can match eol */ YY_RULE_SETUP -#line 265 "../../src/scan-gram.l" +#line 272 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%output"); YY_BREAK case 60: YY_RULE_SETUP -#line 266 "../../src/scan-gram.l" +#line 273 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%pure-parser"); YY_BREAK case 61: YY_RULE_SETUP -#line 267 "../../src/scan-gram.l" +#line 274 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED("%token-table"); YY_BREAK case 62: -/* rule 62 can match eol */ YY_RULE_SETUP -#line 269 "../../src/scan-gram.l" +#line 276 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - complain (loc, complaint, _("invalid directive: %s"), quote (gram_text)); + complain (loc, complaint, _("invalid directive: %s"), quote (yytext)); } YY_BREAK case 63: YY_RULE_SETUP -#line 273 "../../src/scan-gram.l" +#line 280 "/Users/akim/src/gnu/bison/src/scan-gram.l" return EQUAL; YY_BREAK case 64: YY_RULE_SETUP -#line 274 "../../src/scan-gram.l" +#line 281 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PIPE; YY_BREAK case 65: YY_RULE_SETUP -#line 275 "../../src/scan-gram.l" +#line 282 "/Users/akim/src/gnu/bison/src/scan-gram.l" return SEMICOLON; YY_BREAK case 66: YY_RULE_SETUP -#line 277 "../../src/scan-gram.l" +#line 284 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - val->uniqstr = uniqstr_new (gram_text); + val->uniqstr = uniqstr_new (yytext); id_loc = *loc; bracketed_id_str = NULL; BEGIN SC_AFTER_IDENTIFIER; @@ -1914,17 +2134,17 @@ YY_RULE_SETUP YY_BREAK case 67: YY_RULE_SETUP -#line 284 "../../src/scan-gram.l" +#line 291 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - val->integer = scan_integer (gram_text, 10, *loc); + val->integer = scan_integer (yytext, 10, *loc); return INT; } YY_BREAK case 68: YY_RULE_SETUP -#line 288 "../../src/scan-gram.l" +#line 295 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - val->integer = scan_integer (gram_text, 16, *loc); + val->integer = scan_integer (yytext, 16, *loc); return INT; } YY_BREAK @@ -1932,33 +2152,33 @@ YY_RULE_SETUP accept "1FOO" as "1 FOO". */ case 69: YY_RULE_SETUP -#line 295 "../../src/scan-gram.l" +#line 302 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - complain (loc, complaint, _("invalid identifier: %s"), quote (gram_text)); + complain (loc, complaint, _("invalid identifier: %s"), quote (yytext)); } YY_BREAK /* Characters. */ case 70: YY_RULE_SETUP -#line 300 "../../src/scan-gram.l" +#line 307 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER; YY_BREAK /* Strings. */ case 71: YY_RULE_SETUP -#line 303 "../../src/scan-gram.l" +#line 310 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_STRING; YY_BREAK /* Prologue. */ case 72: YY_RULE_SETUP -#line 306 "../../src/scan-gram.l" +#line 313 "/Users/akim/src/gnu/bison/src/scan-gram.l" code_start = loc->start; BEGIN SC_PROLOGUE; YY_BREAK /* Code in between braces. */ case 73: YY_RULE_SETUP -#line 309 "../../src/scan-gram.l" +#line 316 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; nesting = 0; @@ -1970,7 +2190,7 @@ YY_RULE_SETUP case 74: /* rule 74 can match eol */ YY_RULE_SETUP -#line 317 "../../src/scan-gram.l" +#line 324 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; code_start = loc->start; @@ -1980,17 +2200,17 @@ YY_RULE_SETUP /* A type. */ case 75: YY_RULE_SETUP -#line 324 "../../src/scan-gram.l" +#line 331 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_ANY; YY_BREAK case 76: YY_RULE_SETUP -#line 325 "../../src/scan-gram.l" +#line 332 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_NONE; YY_BREAK case 77: YY_RULE_SETUP -#line 326 "../../src/scan-gram.l" +#line 333 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; token_start = loc->start; @@ -1999,7 +2219,7 @@ YY_RULE_SETUP YY_BREAK case 78: YY_RULE_SETUP -#line 332 "../../src/scan-gram.l" +#line 339 "/Users/akim/src/gnu/bison/src/scan-gram.l" { static int percent_percent_count; if (++percent_percent_count == 2) @@ -2009,7 +2229,7 @@ YY_RULE_SETUP YY_BREAK case 79: YY_RULE_SETUP -#line 339 "../../src/scan-gram.l" +#line 346 "/Users/akim/src/gnu/bison/src/scan-gram.l" { bracketed_id_str = NULL; bracketed_id_start = loc->start; @@ -2019,15 +2239,15 @@ YY_RULE_SETUP YY_BREAK case 80: YY_RULE_SETUP -#line 346 "../../src/scan-gram.l" +#line 353 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", - ngettext ("invalid character", "invalid characters", gram_leng), - quote_mem (gram_text, gram_leng)); + ngettext ("invalid character", "invalid characters", yyleng), + quote_mem (yytext, yyleng)); } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 352 "../../src/scan-gram.l" +#line 359 "/Users/akim/src/gnu/bison/src/scan-gram.l" { loc->start = loc->end = scanner_cursor; yyterminate (); @@ -2042,7 +2262,7 @@ case YY_STATE_EOF(INITIAL): case 81: YY_RULE_SETUP -#line 366 "../../src/scan-gram.l" +#line 373 "/Users/akim/src/gnu/bison/src/scan-gram.l" complain (loc, complaint, _("invalid null character")); YY_BREAK @@ -2053,7 +2273,7 @@ complain (loc, complaint, _("invalid null character")); case 82: YY_RULE_SETUP -#line 376 "../../src/scan-gram.l" +#line 383 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { @@ -2072,7 +2292,7 @@ YY_RULE_SETUP YY_BREAK case 83: YY_RULE_SETUP -#line 391 "../../src/scan-gram.l" +#line 398 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); *loc = id_loc; @@ -2081,7 +2301,7 @@ YY_RULE_SETUP YY_BREAK case 84: YY_RULE_SETUP -#line 396 "../../src/scan-gram.l" +#line 403 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); @@ -2090,7 +2310,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_AFTER_IDENTIFIER): -#line 402 "../../src/scan-gram.l" +#line 409 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); *loc = id_loc; @@ -2105,24 +2325,24 @@ case YY_STATE_EOF(SC_AFTER_IDENTIFIER): case 85: YY_RULE_SETUP -#line 415 "../../src/scan-gram.l" +#line 422 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { complain (loc, complaint, _("unexpected identifier in bracketed name: %s"), - quote (gram_text)); + quote (yytext)); } else { - bracketed_id_str = uniqstr_new (gram_text); + bracketed_id_str = uniqstr_new (yytext); bracketed_id_loc = *loc; } } YY_BREAK case 86: YY_RULE_SETUP -#line 428 "../../src/scan-gram.l" +#line 435 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; if (bracketed_id_str) @@ -2141,16 +2361,16 @@ YY_RULE_SETUP YY_BREAK case 87: YY_RULE_SETUP -#line 444 "../../src/scan-gram.l" +#line 451 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", ngettext ("invalid character in bracketed name", - "invalid characters in bracketed name", gram_leng), - quote_mem (gram_text, gram_leng)); + "invalid characters in bracketed name", yyleng), + quote_mem (yytext, yyleng)); } YY_BREAK case YY_STATE_EOF(SC_BRACKETED_ID): -#line 451 "../../src/scan-gram.l" +#line 458 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; unexpected_eof (bracketed_id_start, "]"); @@ -2161,7 +2381,7 @@ case YY_STATE_EOF(SC_BRACKETED_ID): case 88: YY_RULE_SETUP -#line 459 "../../src/scan-gram.l" +#line 466 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; val->uniqstr = bracketed_id_str; @@ -2179,17 +2399,17 @@ YY_RULE_SETUP case 89: YY_RULE_SETUP -#line 476 "../../src/scan-gram.l" +#line 483 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK case 90: /* rule 90 can match eol */ YY_RULE_SETUP -#line 477 "../../src/scan-gram.l" +#line 484 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case YY_STATE_EOF(SC_YACC_COMMENT): -#line 478 "../../src/scan-gram.l" +#line 485 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2201,11 +2421,11 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; case 91: /* rule 91 can match eol */ YY_RULE_SETUP -#line 488 "../../src/scan-gram.l" +#line 495 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_COMMENT): -#line 489 "../../src/scan-gram.l" +#line 496 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2217,17 +2437,17 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; case 92: /* rule 92 can match eol */ YY_RULE_SETUP -#line 499 "../../src/scan-gram.l" +#line 506 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case 93: /* rule 93 can match eol */ YY_RULE_SETUP -#line 500 "../../src/scan-gram.l" +#line 507 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_LINE_COMMENT): -#line 501 "../../src/scan-gram.l" +#line 508 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK @@ -2239,7 +2459,7 @@ BEGIN context_state; case 94: YY_RULE_SETUP -#line 512 "../../src/scan-gram.l" +#line 519 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = token_start; @@ -2249,13 +2469,13 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_ESCAPED_STRING): -#line 519 "../../src/scan-gram.l" +#line 526 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK case 95: /* rule 95 can match eol */ YY_RULE_SETUP -#line 520 "../../src/scan-gram.l" +#line 527 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK @@ -2267,7 +2487,7 @@ unexpected_newline (token_start, "\""); case 96: YY_RULE_SETUP -#line 530 "../../src/scan-gram.l" +#line 537 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = token_start; @@ -2291,11 +2511,11 @@ YY_RULE_SETUP case 97: /* rule 97 can match eol */ YY_RULE_SETUP -#line 549 "../../src/scan-gram.l" +#line 556 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 550 "../../src/scan-gram.l" +#line 557 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK @@ -2306,7 +2526,7 @@ unexpected_eof (token_start, "'"); case 98: YY_RULE_SETUP -#line 561 "../../src/scan-gram.l" +#line 568 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) @@ -2324,16 +2544,16 @@ YY_RULE_SETUP case 99: /* rule 99 can match eol */ YY_RULE_SETUP -#line 575 "../../src/scan-gram.l" +#line 582 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case 100: YY_RULE_SETUP -#line 576 "../../src/scan-gram.l" -STRING_GROW; nesting += gram_leng; +#line 583 "/Users/akim/src/gnu/bison/src/scan-gram.l" +STRING_GROW; nesting += yyleng; YY_BREAK case YY_STATE_EOF(SC_TAG): -#line 578 "../../src/scan-gram.l" +#line 585 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, ">"); YY_BREAK @@ -2344,78 +2564,78 @@ unexpected_eof (token_start, ">"); case 101: YY_RULE_SETUP -#line 587 "../../src/scan-gram.l" +#line 594 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - unsigned long int c = strtoul (gram_text + 1, NULL, 8); + unsigned long c = strtoul (yytext + 1, NULL, 8); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), - gram_text+1); + yytext+1); else obstack_1grow (&obstack_for_string, c); } YY_BREAK case 102: YY_RULE_SETUP -#line 596 "../../src/scan-gram.l" +#line 603 "/Users/akim/src/gnu/bison/src/scan-gram.l" { verify (UCHAR_MAX < ULONG_MAX); - unsigned long int c = strtoul (gram_text + 2, NULL, 16); + unsigned long c = strtoul (yytext + 2, NULL, 16); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), - gram_text+1); + yytext+1); else obstack_1grow (&obstack_for_string, c); } YY_BREAK case 103: YY_RULE_SETUP -#line 606 "../../src/scan-gram.l" +#line 613 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\a'); YY_BREAK case 104: YY_RULE_SETUP -#line 607 "../../src/scan-gram.l" +#line 614 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\b'); YY_BREAK case 105: YY_RULE_SETUP -#line 608 "../../src/scan-gram.l" +#line 615 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\f'); YY_BREAK case 106: YY_RULE_SETUP -#line 609 "../../src/scan-gram.l" +#line 616 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\n'); YY_BREAK case 107: YY_RULE_SETUP -#line 610 "../../src/scan-gram.l" +#line 617 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\r'); YY_BREAK case 108: YY_RULE_SETUP -#line 611 "../../src/scan-gram.l" +#line 618 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\t'); YY_BREAK case 109: YY_RULE_SETUP -#line 612 "../../src/scan-gram.l" +#line 619 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\v'); YY_BREAK /* \\[\"\'?\\] would be shorter, but it confuses xgettext. */ case 110: YY_RULE_SETUP -#line 615 "../../src/scan-gram.l" -obstack_1grow (&obstack_for_string, gram_text[1]); +#line 622 "/Users/akim/src/gnu/bison/src/scan-gram.l" +obstack_1grow (&obstack_for_string, yytext[1]); YY_BREAK case 111: YY_RULE_SETUP -#line 617 "../../src/scan-gram.l" +#line 624 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - int c = convert_ucn_to_byte (gram_text); + int c = convert_ucn_to_byte (yytext); if (c <= 0) complain (loc, complaint, _("invalid number after \\-escape: %s"), - gram_text+1); + yytext+1); else obstack_1grow (&obstack_for_string, c); } @@ -2423,9 +2643,9 @@ YY_RULE_SETUP case 112: /* rule 112 can match eol */ YY_RULE_SETUP -#line 625 "../../src/scan-gram.l" +#line 632 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - char const *p = gram_text + 1; + char const *p = yytext + 1; /* Quote only if escaping won't make the character visible. */ if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p)) p = quote (p); @@ -2444,7 +2664,7 @@ YY_RULE_SETUP case 113: /* rule 113 can match eol */ YY_RULE_SETUP -#line 643 "../../src/scan-gram.l" +#line 650 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK @@ -2452,17 +2672,17 @@ STRING_GROW; case 114: YY_RULE_SETUP -#line 648 "../../src/scan-gram.l" +#line 655 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case 115: /* rule 115 can match eol */ YY_RULE_SETUP -#line 649 "../../src/scan-gram.l" +#line 656 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 650 "../../src/scan-gram.l" +#line 657 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK @@ -2470,17 +2690,17 @@ unexpected_eof (token_start, "'"); case 116: YY_RULE_SETUP -#line 655 "../../src/scan-gram.l" +#line 662 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case 117: /* rule 117 can match eol */ YY_RULE_SETUP -#line 656 "../../src/scan-gram.l" +#line 663 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 657 "../../src/scan-gram.l" +#line 664 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK @@ -2491,7 +2711,7 @@ unexpected_eof (token_start, "\""); case 118: YY_RULE_SETUP -#line 667 "../../src/scan-gram.l" +#line 674 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2501,7 +2721,7 @@ YY_RULE_SETUP YY_BREAK case 119: YY_RULE_SETUP -#line 673 "../../src/scan-gram.l" +#line 680 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2512,7 +2732,7 @@ YY_RULE_SETUP case 120: /* rule 120 can match eol */ YY_RULE_SETUP -#line 679 "../../src/scan-gram.l" +#line 686 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2523,7 +2743,7 @@ YY_RULE_SETUP case 121: /* rule 121 can match eol */ YY_RULE_SETUP -#line 685 "../../src/scan-gram.l" +#line 692 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2540,13 +2760,13 @@ YY_RULE_SETUP case 122: /* rule 122 can match eol */ YY_RULE_SETUP -#line 701 "../../src/scan-gram.l" +#line 708 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting++; YY_BREAK case 123: /* rule 123 can match eol */ YY_RULE_SETUP -#line 702 "../../src/scan-gram.l" +#line 709 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting--; YY_BREAK /* Tokenize '<<%' correctly (as '<<' '%') rather than incorrrectly @@ -2554,12 +2774,12 @@ STRING_GROW; nesting--; case 124: /* rule 124 can match eol */ YY_RULE_SETUP -#line 706 "../../src/scan-gram.l" +#line 713 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_BRACED_CODE): case YY_STATE_EOF(SC_PREDICATE): -#line 708 "../../src/scan-gram.l" +#line 715 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "}"); YY_BREAK @@ -2567,7 +2787,7 @@ unexpected_eof (code_start, "}"); case 125: YY_RULE_SETUP -#line 713 "../../src/scan-gram.l" +#line 720 "/Users/akim/src/gnu/bison/src/scan-gram.l" { obstack_1grow (&obstack_for_string, '}'); @@ -2587,7 +2807,7 @@ YY_RULE_SETUP case 126: YY_RULE_SETUP -#line 730 "../../src/scan-gram.l" +#line 737 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) @@ -2610,7 +2830,7 @@ YY_RULE_SETUP case 127: YY_RULE_SETUP -#line 751 "../../src/scan-gram.l" +#line 758 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2620,7 +2840,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 759 "../../src/scan-gram.l" +#line 766 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "%}"); YY_BREAK @@ -2631,7 +2851,7 @@ unexpected_eof (code_start, "%}"); case YY_STATE_EOF(SC_EPILOGUE): -#line 770 "../../src/scan-gram.l" +#line 777 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2645,19 +2865,19 @@ case YY_STATE_EOF(SC_EPILOGUE): | By default, grow the string obstack with the input. | `-----------------------------------------------------*/ case 128: -#line 785 "../../src/scan-gram.l" +#line 792 "/Users/akim/src/gnu/bison/src/scan-gram.l" case 129: /* rule 129 can match eol */ YY_RULE_SETUP -#line 785 "../../src/scan-gram.l" +#line 792 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case 130: YY_RULE_SETUP -#line 787 "../../src/scan-gram.l" +#line 794 "/Users/akim/src/gnu/bison/src/scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2661 "src/scan-gram.c" +#line 2880 "src/scan-gram.c" case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): yyterminate(); @@ -2674,15 +2894,19 @@ case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed gram_in at a new source and called - * gram_lex(). If so, then we have to assure + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = gram_in; +/* %if-c-only */ + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; +/* %endif */ +/* %if-c++-only */ +/* %endif */ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -2737,11 +2961,11 @@ case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): { (yy_did_buffer_switch_on_eof) = 0; - if ( gram_wrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * gram_text, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the @@ -2790,12 +3014,12 @@ case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -} /* end of gram_lex */ + } /* end of user's declarations */ +} /* end of yylex */ /* %ok-for-header */ /* %if-c++-only */ /* %not-for-header */ - /* %ok-for-header */ /* %endif */ @@ -2813,9 +3037,9 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -2844,7 +3068,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -2857,7 +3081,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2871,7 +3095,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2880,11 +3104,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - gram_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -2912,7 +3137,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - gram_restart(gram_in ); + yyrestart( yyin ); } else @@ -2926,12 +3151,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) gram_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -2947,14 +3175,13 @@ static int yy_get_next_buffer (void) /* %if-c-only */ /* %not-for-header */ - static yy_state_type yy_get_previous_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; /* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = (yy_start); @@ -2963,7 +3190,7 @@ static int yy_get_next_buffer (void) for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 59); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 58); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2972,10 +3199,10 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 582 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 579 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -2992,11 +3219,11 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register int yy_is_jam; + int yy_is_jam; /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ - register char *yy_cp = (yy_c_buf_p); + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 59; + YY_CHAR yy_c = 58; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -3005,36 +3232,37 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 582 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 579 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 581); + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 578); return yy_is_jam ? 0 : yy_current_state; } +#ifndef YY_NO_UNPUT /* %if-c-only */ - static void yyunput (int c, register char * yy_bp ) + static void yyunput (int c, char * yy_bp ) /* %endif */ /* %if-c++-only */ /* %endif */ { - register char *yy_cp; + char *yy_cp; yy_cp = (yy_c_buf_p); - /* undo effects of setting up gram_text */ + /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register yy_size_t number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + int number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = + char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -3043,7 +3271,7 @@ static int yy_get_next_buffer (void) yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -3051,7 +3279,7 @@ static int yy_get_next_buffer (void) *--yy_cp = (char) c; -/* %% [18.0] update gram_lineno here */ +/* %% [18.0] update yylineno here */ (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; @@ -3060,6 +3288,7 @@ static int yy_get_next_buffer (void) /* %if-c-only */ /* %endif */ +#endif /* %if-c-only */ #ifndef YY_NO_INPUT @@ -3089,7 +3318,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -3106,14 +3335,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - gram_restart(gram_in ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( gram_wrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -3132,10 +3361,10 @@ static int yy_get_next_buffer (void) } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve gram_text */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); -/* %% [19.0] update BOL and gram_lineno */ +/* %% [19.0] update BOL and yylineno */ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); return c; @@ -3150,28 +3379,31 @@ static int yy_get_next_buffer (void) * @note This function does not reset the start condition to @c INITIAL . */ /* %if-c-only */ - void gram_restart (FILE * input_file ) + void yyrestart (FILE * input_file ) /* %endif */ /* %if-c++-only */ /* %endif */ { if ( ! YY_CURRENT_BUFFER ){ - gram_ensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - gram__create_buffer(gram_in,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - gram__init_buffer(YY_CURRENT_BUFFER,input_file ); - gram__load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } +/* %if-c++-only */ +/* %endif */ + /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ /* %if-c-only */ - void gram__switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3179,10 +3411,10 @@ static int yy_get_next_buffer (void) /* TODO. We should be able to replace this entire function body * with - * gram_pop_buffer_state(); - * gram_push_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - gram_ensure_buffer_stack (); + yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -3195,25 +3427,29 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - gram__load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during - * EOF (gram_wrap()) processing, but the only time this flag - * is looked at is after gram_wrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } /* %if-c-only */ -static void gram__load_buffer_state (void) +static void yy_load_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - gram_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %if-c-only */ + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ (yy_hold_char) = *(yy_c_buf_p); } @@ -3224,39 +3460,42 @@ static void gram__load_buffer_state (void) * @return the allocated buffer state. */ /* %if-c-only */ - YY_BUFFER_STATE gram__create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) /* %endif */ /* %if-c++-only */ /* %endif */ { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) gram_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in gram__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) gram_alloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in gram__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - gram__init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } +/* %if-c++-only */ +/* %endif */ + /** Destroy the buffer. - * @param b a buffer created with gram__create_buffer() + * @param b a buffer created with yy_create_buffer() * */ /* %if-c-only */ - void gram__delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3269,17 +3508,17 @@ static void gram__load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - gram_free((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - gram_free((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a gram_restart() or at EOF. + * such as during a yyrestart() or at EOF. */ /* %if-c-only */ - static void gram__init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3287,13 +3526,17 @@ static void gram__load_buffer_state (void) { int oerrno = errno; - gram__flush_buffer(b ); + yy_flush_buffer( b ); +/* %if-c-only */ b->yy_input_file = file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ b->yy_fill_buffer = 1; - /* If b is the current buffer, then gram__init_buffer was _probably_ - * called from gram_restart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -3316,7 +3559,7 @@ static void gram__load_buffer_state (void) * */ /* %if-c-only */ - void gram__flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3339,7 +3582,7 @@ static void gram__load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - gram__load_buffer_state( ); + yy_load_buffer_state( ); } /* %if-c-or-c++ */ @@ -3350,7 +3593,7 @@ static void gram__load_buffer_state (void) * */ /* %if-c-only */ -void gram_push_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3358,9 +3601,9 @@ void gram_push_buffer_state (YY_BUFFER_STATE new_buffer ) if (new_buffer == NULL) return; - gram_ensure_buffer_stack(); + yyensure_buffer_stack(); - /* This block is copied from gram__switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -3374,8 +3617,8 @@ void gram_push_buffer_state (YY_BUFFER_STATE new_buffer ) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from gram__switch_to_buffer. */ - gram__load_buffer_state( ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /* %endif */ @@ -3386,7 +3629,7 @@ void gram_push_buffer_state (YY_BUFFER_STATE new_buffer ) * */ /* %if-c-only */ -void gram_pop_buffer_state (void) +void yypop_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3394,13 +3637,13 @@ void gram_pop_buffer_state (void) if (!YY_CURRENT_BUFFER) return; - gram__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - gram__load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -3411,7 +3654,7 @@ void gram_pop_buffer_state (void) * Guarantees space for at least one push. */ /* %if-c-only */ -static void gram_ensure_buffer_stack (void) +static void yyensure_buffer_stack (void) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -3424,15 +3667,15 @@ static void gram_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)gram_alloc + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in gram_ensure_buffer_stack()" ); - + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -3441,15 +3684,15 @@ static void gram_ensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)gram_realloc + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in gram_ensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -3463,9 +3706,9 @@ static void gram_ensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE gram__scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; @@ -3473,53 +3716,53 @@ YY_BUFFER_STATE gram__scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) gram_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in gram__scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - gram__switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan a string. The next call to gram_lex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * gram__scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE gram__scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return gram__scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan the given bytes. The next call to gram_lex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE gram__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -3527,19 +3770,19 @@ YY_BUFFER_STATE gram__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_l int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) gram_alloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in gram__scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = gram__scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in gram__scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -3555,9 +3798,9 @@ YY_BUFFER_STATE gram__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_l #endif /* %if-c-only */ -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* %endif */ @@ -3570,14 +3813,14 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up gram_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - gram_text[gram_leng] = (yy_hold_char); \ - (yy_c_buf_p) = gram_text + yyless_macro_arg; \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ - gram_leng = yyless_macro_arg; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) @@ -3590,82 +3833,82 @@ static void yy_fatal_error (yyconst char* msg ) /** Get the current line number. * */ -int gram_get_lineno (void) +int yyget_lineno (void) { - - return gram_lineno; + + return yylineno; } /** Get the input stream. * */ -FILE *gram_get_in (void) +FILE *yyget_in (void) { - return gram_in; + return yyin; } /** Get the output stream. * */ -FILE *gram_get_out (void) +FILE *yyget_out (void) { - return gram_out; + return yyout; } /** Get the length of the current token. * */ -yy_size_t gram_get_leng (void) +int yyget_leng (void) { - return gram_leng; + return yyleng; } /** Get the current token. * */ -char *gram_get_text (void) +char *yyget_text (void) { - return gram_text; + return yytext; } /* %if-reentrant */ /* %endif */ /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void gram_set_lineno (int line_number ) +void yyset_lineno (int _line_number ) { - gram_lineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * - * @see gram__switch_to_buffer + * @see yy_switch_to_buffer */ -void gram_set_in (FILE * in_str ) +void yyset_in (FILE * _in_str ) { - gram_in = in_str ; + yyin = _in_str ; } -void gram_set_out (FILE * out_str ) +void yyset_out (FILE * _out_str ) { - gram_out = out_str ; + yyout = _out_str ; } -int gram_get_debug (void) +int yyget_debug (void) { - return gram__flex_debug; + return yy_flex_debug; } -void gram_set_debug (int bdebug ) +void yyset_debug (int _bdebug ) { - gram__flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } /* %endif */ @@ -3679,50 +3922,50 @@ void gram_set_debug (int bdebug ) static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. - * This function is called from gram_lex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT - gram_in = stdin; - gram_out = stdout; + yyin = stdin; + yyout = stdout; #else - gram_in = (FILE *) 0; - gram_out = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * gram_lex_init() + * yylex_init() */ return 0; } /* %endif */ /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ -/* gram_lex_destroy is for both reentrant and non-reentrant scanners. */ -int gram_lex_destroy (void) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - gram__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; - gram_pop_buffer_state(); + yypop_buffer_state(); } /* Destroy the stack itself. */ - gram_free((yy_buffer_stack) ); + yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * gram_lex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( ); /* %if-reentrant */ @@ -3736,18 +3979,19 @@ int gram_lex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -3755,13 +3999,14 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *gram_alloc (yy_size_t size ) +void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } -void *gram_realloc (void * ptr, yy_size_t size ) +void *yyrealloc (void * ptr, yy_size_t size ) { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -3769,12 +4014,12 @@ void *gram_realloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void gram_free (void * ptr ) +void yyfree (void * ptr ) { - free( (char *) ptr ); /* see gram_realloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } /* %if-tables-serialization definitions */ @@ -3784,8 +4029,7 @@ void gram_free (void * ptr ) /* %ok-for-header */ -#line 787 "../../src/scan-gram.l" - +#line 794 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Read bytes from FP into buffer BUF of size SIZE. Return the @@ -3840,11 +4084,11 @@ no_cr_read (FILE *fp, char *buf, size_t size) | Scan NUMBER for a base-BASE integer at location LOC. | `------------------------------------------------------*/ -static unsigned long int +static unsigned long scan_integer (char const *number, int base, location loc) { verify (INT_MAX < ULONG_MAX); - unsigned long int num = strtoul (number, NULL, base); + unsigned long num = strtoul (number, NULL, base); if (INT_MAX < num) { @@ -3867,7 +4111,7 @@ static int convert_ucn_to_byte (char const *ucn) { verify (UCHAR_MAX <= INT_MAX); - unsigned long int code = strtoul (ucn + 2, NULL, 16); + unsigned long code = strtoul (ucn + 2, NULL, 16); /* FIXME: Currently we assume Unicode-compatible unibyte characters on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes). On @@ -3922,7 +4166,7 @@ static void handle_syncline (char *args, location loc) { char *file; - unsigned long int lineno = strtoul (args, &file, 10); + unsigned long lineno = strtoul (args, &file, 10); if (INT_MAX <= lineno) { complain (&loc, Wother, _("line number overflow")); @@ -4012,6 +4256,6 @@ gram_scanner_free (void) { obstack_free (&obstack_for_string, 0); /* Reclaim Flex's buffers. */ - gram_lex_destroy (); + yylex_destroy (); } diff --git a/contrib/tools/bison/src/scan-gram.h b/contrib/tools/bison/src/scan-gram.h index ee397ed2e7..f135959e3c 100644 --- a/contrib/tools/bison/src/scan-gram.h +++ b/contrib/tools/bison/src/scan-gram.h @@ -1,6 +1,7 @@ /* Bison Grammar Scanner - Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/scan-skel.c b/contrib/tools/bison/src/scan-skel.c index 74f90d56db..e6caf1b977 100644 --- a/contrib/tools/bison/src/scan-skel.c +++ b/contrib/tools/bison/src/scan-skel.c @@ -1,22 +1,27 @@ -#line 2 "lex.yy.c" +#line 1 "src/scan-skel.c" -#line 4 "lex.yy.c" +#line 3 "src/scan-skel.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ /* %not-for-header */ - /* %if-c-only */ /* %if-not-reentrant */ #define yy_create_buffer skel__create_buffer #define yy_delete_buffer skel__delete_buffer -#define yy_flex_debug skel__flex_debug +#define yy_scan_buffer skel__scan_buffer +#define yy_scan_string skel__scan_string +#define yy_scan_bytes skel__scan_bytes #define yy_init_buffer skel__init_buffer #define yy_flush_buffer skel__flush_buffer #define yy_load_buffer_state skel__load_buffer_state #define yy_switch_to_buffer skel__switch_to_buffer +#define yypush_buffer_state skel_push_buffer_state +#define yypop_buffer_state skel_pop_buffer_state +#define yyensure_buffer_stack skel_ensure_buffer_stack +#define yy_flex_debug skel__flex_debug #define yyin skel_in #define yyleng skel_leng #define yylex skel_lex @@ -35,8 +40,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -45,11 +50,244 @@ /* %endif */ /* %if-c-only */ - +#ifdef yy_create_buffer +#define skel__create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer skel__create_buffer +#endif + +#ifdef yy_delete_buffer +#define skel__delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer skel__delete_buffer +#endif + +#ifdef yy_scan_buffer +#define skel__scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer skel__scan_buffer +#endif + +#ifdef yy_scan_string +#define skel__scan_string_ALREADY_DEFINED +#else +#define yy_scan_string skel__scan_string +#endif + +#ifdef yy_scan_bytes +#define skel__scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes skel__scan_bytes +#endif + +#ifdef yy_init_buffer +#define skel__init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer skel__init_buffer +#endif + +#ifdef yy_flush_buffer +#define skel__flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer skel__flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define skel__load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state skel__load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define skel__switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer skel__switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define skel_push_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state skel_push_buffer_state +#endif + +#ifdef yypop_buffer_state +#define skel_pop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state skel_pop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define skel_ensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack skel_ensure_buffer_stack +#endif + +#ifdef yylex +#define skel_lex_ALREADY_DEFINED +#else +#define yylex skel_lex +#endif + +#ifdef yyrestart +#define skel_restart_ALREADY_DEFINED +#else +#define yyrestart skel_restart +#endif + +#ifdef yylex_init +#define skel_lex_init_ALREADY_DEFINED +#else +#define yylex_init skel_lex_init +#endif + +#ifdef yylex_init_extra +#define skel_lex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra skel_lex_init_extra +#endif + +#ifdef yylex_destroy +#define skel_lex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy skel_lex_destroy +#endif + +#ifdef yyget_debug +#define skel_get_debug_ALREADY_DEFINED +#else +#define yyget_debug skel_get_debug +#endif + +#ifdef yyset_debug +#define skel_set_debug_ALREADY_DEFINED +#else +#define yyset_debug skel_set_debug +#endif + +#ifdef yyget_extra +#define skel_get_extra_ALREADY_DEFINED +#else +#define yyget_extra skel_get_extra +#endif + +#ifdef yyset_extra +#define skel_set_extra_ALREADY_DEFINED +#else +#define yyset_extra skel_set_extra +#endif + +#ifdef yyget_in +#define skel_get_in_ALREADY_DEFINED +#else +#define yyget_in skel_get_in +#endif + +#ifdef yyset_in +#define skel_set_in_ALREADY_DEFINED +#else +#define yyset_in skel_set_in +#endif + +#ifdef yyget_out +#define skel_get_out_ALREADY_DEFINED +#else +#define yyget_out skel_get_out +#endif + +#ifdef yyset_out +#define skel_set_out_ALREADY_DEFINED +#else +#define yyset_out skel_set_out +#endif + +#ifdef yyget_leng +#define skel_get_leng_ALREADY_DEFINED +#else +#define yyget_leng skel_get_leng +#endif + +#ifdef yyget_text +#define skel_get_text_ALREADY_DEFINED +#else +#define yyget_text skel_get_text +#endif + +#ifdef yyget_lineno +#define skel_get_lineno_ALREADY_DEFINED +#else +#define yyget_lineno skel_get_lineno +#endif + +#ifdef yyset_lineno +#define skel_set_lineno_ALREADY_DEFINED +#else +#define yyset_lineno skel_set_lineno +#endif + +#ifdef yywrap +#define skel_wrap_ALREADY_DEFINED +#else +#define yywrap skel_wrap +#endif + /* %endif */ +#ifdef yyalloc +#define skel_alloc_ALREADY_DEFINED +#else +#define yyalloc skel_alloc +#endif + +#ifdef yyrealloc +#define skel_realloc_ALREADY_DEFINED +#else +#define yyrealloc skel_realloc +#endif + +#ifdef yyfree +#define skel_free_ALREADY_DEFINED +#else +#define yyfree skel_free +#endif + /* %if-c-only */ +#ifdef yytext +#define skel_text_ALREADY_DEFINED +#else +#define yytext skel_text +#endif + +#ifdef yyleng +#define skel_leng_ALREADY_DEFINED +#else +#define yyleng skel_leng +#endif + +#ifdef yyin +#define skel_in_ALREADY_DEFINED +#else +#define yyin skel_in +#endif + +#ifdef yyout +#define skel_out_ALREADY_DEFINED +#else +#define yyout skel_out +#endif + +#ifdef yy_flex_debug +#define skel__flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug skel__flex_debug +#endif + +#ifdef yylineno +#define skel_lineno_ALREADY_DEFINED +#else +#define yylineno skel_lineno +#endif + /* %endif */ /* First, we deal with platform-specific or compiler-specific issues. */ @@ -127,50 +365,39 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* %endif */ +/* begin standard C++ headers. */ /* %if-c++-only */ /* %endif */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* %not-for-header */ - /* Returned upon end-of-file. */ #define YY_NULL 0 /* %ok-for-header */ /* %not-for-header */ - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* %ok-for-header */ /* %if-reentrant */ @@ -185,20 +412,16 @@ typedef unsigned int flex_uint32_t; * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE skel_restart(skel_in ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -223,43 +446,43 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + /* %if-not-reentrant */ -extern int skel_leng; +extern int yyleng; /* %endif */ /* %if-c-only */ /* %if-not-reentrant */ -extern FILE *skel_in, *skel_out; +extern FILE *yyin, *yyout; /* %endif */ /* %endif */ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ - /* Undo effects of setting up skel_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up skel_text again */ \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -277,7 +500,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -305,7 +528,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -322,8 +545,8 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via skel_restart()), so that the user can continue scanning by - * just pointing skel_in at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -332,13 +555,12 @@ struct yy_buffer_state /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - /* %if-not-reentrant */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* %endif */ /* %ok-for-header */ @@ -353,7 +575,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -363,115 +584,112 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* %if-not-reentrant */ /* %not-for-header */ - -/* yy_hold_char holds the character lost when skel_text is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int skel_leng; +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow skel_wrap()'s to do buffer switches - * instead of setting up a fresh skel_in. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; /* %ok-for-header */ /* %endif */ -void skel_restart (FILE *input_file ); -void skel__switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE skel__create_buffer (FILE *file,int size ); -void skel__delete_buffer (YY_BUFFER_STATE b ); -void skel__flush_buffer (YY_BUFFER_STATE b ); -void skel_push_buffer_state (YY_BUFFER_STATE new_buffer ); -void skel_pop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -static void skel_ensure_buffer_stack (void ); -static void skel__load_buffer_state (void ); -static void skel__init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -#define YY_FLUSH_BUFFER skel__flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE skel__scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE skel__scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE skel__scan_bytes (yyconst char *bytes,int len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); /* %endif */ -void *skel_alloc (yy_size_t ); -void *skel_realloc (void *,yy_size_t ); -void skel_free (void * ); - -#define yy_new_buffer skel__create_buffer +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - skel_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - skel__create_buffer(skel_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - skel_ensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - skel__create_buffer(skel_in,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -/* %% [1.0] skel_text/skel_in/skel_out/yy_state_type/skel_lineno etc. def's & init go here */ +/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ -#define skel_wrap(n) 1 +#define skel_wrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP #define FLEX_DEBUG +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *skel_in = (FILE *) 0, *skel_out = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; -extern int skel_lineno; +extern int yylineno; +int yylineno = 1; -int skel_lineno = 1; +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext -extern char *skel_text; -#define yytext_ptr skel_text +/* %% [1.5] DFA */ /* %if-c-only Standard (non-C++) definition */ -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* %endif */ /* Done after the current pattern has been matched and before the - * corresponding action - sets up skel_text. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ -/* %% [2.0] code to fiddle skel_text and skel_leng for yymore() goes here \ */\ - skel_leng = (size_t) (yy_cp - yy_bp); \ +/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to skel_text[] goes here, if %array \ */\ +/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; - /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 25 #define YY_END_OF_BUFFER 26 @@ -482,7 +700,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[72] = +static const flex_int16_t yy_accept[72] = { 0, 0, 0, 0, 0, 0, 0, 26, 14, 13, 1, 12, 15, 22, 24, 23, 23, 14, 1, 12, 6, @@ -494,7 +712,7 @@ static yyconst flex_int16_t yy_accept[72] = 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -526,14 +744,14 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[25] = +static const YY_CHAR yy_meta[25] = { 0, 1, 1, 2, 1, 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[79] = +static const flex_int16_t yy_base[79] = { 0, 0, 2, 68, 67, 9, 12, 74, 0, 109, 69, 14, 0, 36, 109, 109, 109, 0, 68, 58, 109, @@ -545,7 +763,7 @@ static yyconst flex_int16_t yy_base[79] = 109, 82, 86, 90, 94, 97, 101, 104 } ; -static yyconst flex_int16_t yy_def[79] = +static const flex_int16_t yy_def[79] = { 0, 72, 72, 73, 73, 74, 74, 71, 75, 71, 75, 76, 77, 78, 71, 71, 71, 75, 75, 76, 71, @@ -557,7 +775,7 @@ static yyconst flex_int16_t yy_def[79] = 0, 71, 71, 71, 71, 71, 71, 71 } ; -static yyconst flex_int16_t yy_nxt[134] = +static const flex_int16_t yy_nxt[134] = { 0, 71, 71, 9, 10, 9, 10, 70, 11, 69, 11, 15, 16, 15, 15, 16, 15, 20, 21, 22, 20, @@ -576,7 +794,7 @@ static yyconst flex_int16_t yy_nxt[134] = 71, 71, 71 } ; -static yyconst flex_int16_t yy_chk[134] = +static const flex_int16_t yy_chk[134] = { 0, 0, 0, 1, 1, 2, 2, 68, 1, 67, 2, 5, 5, 5, 6, 6, 6, 11, 11, 11, 21, @@ -598,14 +816,14 @@ static yyconst flex_int16_t yy_chk[134] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int skel__flex_debug; -int skel__flex_debug = 1; +extern int yy_flex_debug; +int yy_flex_debug = 1; -static yyconst flex_int16_t yy_rule_linenum[25] = +static const flex_int16_t yy_rule_linenum[25] = { 0, - 72, 73, 74, 75, 76, 77, 79, 80, 82, 83, - 84, 87, 88, 89, 102, 104, 105, 106, 107, 108, - 110, 129, 134, 135 + 73, 74, 75, 76, 77, 78, 80, 81, 83, 84, + 85, 88, 89, 90, 103, 105, 106, 107, 108, 109, + 111, 130, 135, 136 } ; /* The intent behind this definition is that it'll catch @@ -615,11 +833,11 @@ static yyconst flex_int16_t yy_rule_linenum[25] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *skel_text; -#line 1 "scan-skel.l" +char *yytext; +#line 1 "src/scan-skel.l" /* Scan Bison Skeletons. -*- C -*- - Copyright (C) 2001-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -636,7 +854,7 @@ char *skel_text; You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 -#line 24 "scan-skel.l" +#line 24 "src/scan-skel.l" /* Work around a bug in flex 2.5.31. See Debian bug 333231 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ #undef skel_wrap @@ -665,9 +883,9 @@ static void at_output (int argc, char *argv[], char **name, int *lineno); static void fail_for_at_directive_too_many_args (char const *at_directive_name); static void fail_for_at_directive_too_few_args (char const *at_directive_name); static void fail_for_invalid_at (char const *at); +#line 886 "src/scan-skel.c" - -#line 671 "lex.yy.c" +#line 888 "src/scan-skel.c" #define INITIAL 0 #define SC_AT_DIRECTIVE_ARGS 1 @@ -693,7 +911,7 @@ static void fail_for_invalid_at (char const *at); /* %if-reentrant */ /* %if-c-only */ -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* %endif */ /* %if-reentrant */ @@ -703,31 +921,31 @@ static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int skel_lex_destroy (void ); +int yylex_destroy ( void ); -int skel_get_debug (void ); +int yyget_debug ( void ); -void skel_set_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE skel_get_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void skel_set_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *skel_get_in (void ); +FILE *yyget_in ( void ); -void skel_set_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *skel_get_out (void ); +FILE *yyget_out ( void ); -void skel_set_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -int skel_get_leng (void ); + int yyget_leng ( void ); -char *skel_get_text (void ); +char *yyget_text ( void ); -int skel_get_lineno (void ); +int yyget_lineno ( void ); -void skel_set_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* %if-bison-bridge */ /* %endif */ @@ -738,34 +956,35 @@ void skel_set_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int skel_wrap (void ); +extern "C" int yywrap ( void ); #else -extern int skel_wrap (void ); +extern int yywrap ( void ); #endif #endif /* %not-for-header */ - +#ifndef YY_NO_UNPUT + +#endif /* %ok-for-header */ /* %endif */ #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif /* %ok-for-header */ @@ -792,7 +1011,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( skel_text, skel_leng, 1, skel_out )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ @@ -807,20 +1026,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ - (c = getc( skel_in )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( skel_in ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, skel_in))==0 && ferror(skel_in)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -828,7 +1047,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(skel_in); \ + clearerr(yyin); \ } \ }\ \ @@ -861,11 +1080,9 @@ static int input (void ); /* %if-tables-serialization structures and prototypes */ /* %not-for-header */ - /* %ok-for-header */ /* %not-for-header */ - /* %tables-yydmap generated elements */ /* %endif */ /* end tables serialization structures and prototypes */ @@ -879,15 +1096,15 @@ static int input (void ); #define YY_DECL_IS_OURS 1 /* %if-c-only Standard (non-C++) definition */ -extern int skel_lex (void); +extern int yylex (void); -#define YY_DECL int skel_lex (void) +#define YY_DECL int yylex (void) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after skel_text and skel_leng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -896,7 +1113,7 @@ extern int skel_lex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif /* %% [6.0] YY_RULE_SETUP definition goes here */ @@ -904,34 +1121,14 @@ extern int skel_lex (void); YY_USER_ACTION /* %not-for-header */ - /** The main scanner function which does all the work. */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; -/* %% [7.0] user's declarations go here */ -#line 57 "scan-skel.l" - - - - int out_lineno PACIFY_CC (= 0); - char *out_name = NULL; - - /* Currently, only the @complain directive takes multiple arguments, and - never more than 7, with argv[0] being the directive name and argv[1] - being the type of complaint to dispatch. */ -#define ARGC_MAX 9 - int argc = 0; - char *argv[ARGC_MAX]; - at_directive at_ptr = NULL; - - -#line 934 "lex.yy.c" - if ( !(yy_init) ) { (yy_init) = 1; @@ -943,35 +1140,56 @@ YY_DECL if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ - if ( ! skel_in ) + if ( ! yyin ) /* %if-c-only */ - skel_in = stdin; + yyin = stdin; /* %endif */ /* %if-c++-only */ /* %endif */ - if ( ! skel_out ) + if ( ! yyout ) /* %if-c-only */ - skel_out = stdout; + yyout = stdout; /* %endif */ /* %if-c++-only */ /* %endif */ if ( ! YY_CURRENT_BUFFER ) { - skel_ensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - skel__create_buffer(skel_in,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - skel__load_buffer_state( ); + yy_load_buffer_state( ); } - while ( 1 ) /* loops until end-of-file is reached */ + { +/* %% [7.0] user's declarations go here */ +#line 57 "src/scan-skel.l" + + + +#line 61 "src/scan-skel.l" + int out_lineno PACIFY_CC (= 0); + char *out_name = NULL; + + /* Currently, only the @complain directive takes multiple arguments, and + never more than 7, with argv[0] being the directive name and argv[1] + being the type of complaint to dispatch. */ +#define ARGC_MAX 9 + int argc = 0; + char *argv[ARGC_MAX]; + at_directive at_ptr = NULL; + + +#line 1185 "src/scan-skel.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { /* %% [8.0] yymore()-related code goes here */ yy_cp = (yy_c_buf_p); - /* Support of skel_text. */ + /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of @@ -984,7 +1202,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -994,9 +1212,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 72 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_current_state != 71 ); @@ -1009,21 +1227,21 @@ yy_find_action: YY_DO_BEFORE_ACTION; -/* %% [11.0] code for skel_lineno update goes here */ +/* %% [11.0] code for yylineno update goes here */ do_action: /* This label is used only to access EOF actions. */ /* %% [12.0] debug code goes here */ - if ( skel__flex_debug ) + if ( yy_flex_debug ) { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); else if ( yy_act < 25 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], skel_text ); + (long)yy_rule_linenum[yy_act], yytext ); else if ( yy_act == 25 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", - skel_text ); + yytext ); else if ( yy_act == 26 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else @@ -1042,84 +1260,84 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 72 "scan-skel.l" +#line 73 "src/scan-skel.l" continue; YY_BREAK case 2: YY_RULE_SETUP -#line 73 "scan-skel.l" -fputc ('@', skel_out); +#line 74 "src/scan-skel.l" +fputc ('@', yyout); YY_BREAK case 3: YY_RULE_SETUP -#line 74 "scan-skel.l" -fputc ('[', skel_out); +#line 75 "src/scan-skel.l" +fputc ('[', yyout); YY_BREAK case 4: YY_RULE_SETUP -#line 75 "scan-skel.l" -fputc (']', skel_out); +#line 76 "src/scan-skel.l" +fputc (']', yyout); YY_BREAK case 5: YY_RULE_SETUP -#line 76 "scan-skel.l" +#line 77 "src/scan-skel.l" continue; /* Used by b4_cat in ../data/bison.m4. */ YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 77 "scan-skel.l" +#line 78 "src/scan-skel.l" continue; YY_BREAK case 7: YY_RULE_SETUP -#line 79 "scan-skel.l" -fprintf (skel_out, "%d", out_lineno + 1); +#line 80 "src/scan-skel.l" +fprintf (yyout, "%d", out_lineno + 1); YY_BREAK case 8: YY_RULE_SETUP -#line 80 "scan-skel.l" -fputs (quotearg_style (c_quoting_style, out_name), skel_out); +#line 81 "src/scan-skel.l" +fputs (quotearg_style (c_quoting_style, out_name), yyout); YY_BREAK case 9: YY_RULE_SETUP -#line 82 "scan-skel.l" +#line 83 "src/scan-skel.l" at_init (&argc, argv, &at_ptr, &at_basename); YY_BREAK case 10: YY_RULE_SETUP -#line 83 "scan-skel.l" +#line 84 "src/scan-skel.l" at_init (&argc, argv, &at_ptr, &at_complain); YY_BREAK case 11: YY_RULE_SETUP -#line 84 "scan-skel.l" +#line 85 "src/scan-skel.l" at_init (&argc, argv, &at_ptr, &at_output); YY_BREAK /* This pattern must not match more than the previous @ patterns. */ case 12: YY_RULE_SETUP -#line 87 "scan-skel.l" -fail_for_invalid_at (skel_text); +#line 88 "src/scan-skel.l" +fail_for_invalid_at (yytext); YY_BREAK case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 88 "scan-skel.l" +#line 89 "src/scan-skel.l" out_lineno++; ECHO; YY_BREAK case 14: YY_RULE_SETUP -#line 89 "scan-skel.l" +#line 90 "src/scan-skel.l" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): -#line 91 "scan-skel.l" +#line 92 "src/scan-skel.l" { if (out_name) { free (out_name); - xfclose (skel_out); + xfclose (yyout); } return EOF; } @@ -1129,38 +1347,38 @@ case YY_STATE_EOF(INITIAL): case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 102 "scan-skel.l" +#line 103 "src/scan-skel.l" STRING_GROW; YY_BREAK case 16: YY_RULE_SETUP -#line 104 "scan-skel.l" +#line 105 "src/scan-skel.l" obstack_1grow (&obstack_for_string, '@'); YY_BREAK case 17: YY_RULE_SETUP -#line 105 "scan-skel.l" +#line 106 "src/scan-skel.l" obstack_1grow (&obstack_for_string, '['); YY_BREAK case 18: YY_RULE_SETUP -#line 106 "scan-skel.l" +#line 107 "src/scan-skel.l" obstack_1grow (&obstack_for_string, ']'); YY_BREAK case 19: YY_RULE_SETUP -#line 107 "scan-skel.l" +#line 108 "src/scan-skel.l" continue; /* For starting an argument that begins with whitespace. */ YY_BREAK case 20: /* rule 20 can match eol */ YY_RULE_SETUP -#line 108 "scan-skel.l" +#line 109 "src/scan-skel.l" continue; YY_BREAK case 21: YY_RULE_SETUP -#line 110 "scan-skel.l" +#line 111 "src/scan-skel.l" { if (argc >= ARGC_MAX) fail_for_at_directive_too_many_args (argv[0]); @@ -1168,7 +1386,7 @@ YY_RULE_SETUP argv[argc++] = obstack_finish0 (&obstack_for_string); /* Like M4, skip whitespace after a comma. */ - if (skel_text[1] == ',') + if (yytext[1] == ',') BEGIN SC_AT_DIRECTIVE_SKIP_WS; else { @@ -1182,8 +1400,8 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 129 "scan-skel.l" -fail_for_invalid_at (skel_text); +#line 130 "src/scan-skel.l" +fail_for_invalid_at (yytext); YY_BREAK @@ -1191,12 +1409,12 @@ fail_for_invalid_at (skel_text); case 23: /* rule 23 can match eol */ YY_RULE_SETUP -#line 134 "scan-skel.l" +#line 135 "src/scan-skel.l" continue; YY_BREAK case 24: YY_RULE_SETUP -#line 135 "scan-skel.l" +#line 136 "src/scan-skel.l" yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; YY_BREAK @@ -1204,16 +1422,16 @@ yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; case YY_STATE_EOF(SC_AT_DIRECTIVE_ARGS): case YY_STATE_EOF(SC_AT_DIRECTIVE_SKIP_WS): -#line 140 "scan-skel.l" +#line 141 "src/scan-skel.l" complain (NULL, fatal, _("unclosed %s directive in skeleton"), argv[0]); YY_BREAK case 25: YY_RULE_SETUP -#line 143 "scan-skel.l" +#line 144 "src/scan-skel.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1217 "lex.yy.c" +#line 1434 "src/scan-skel.c" case YY_END_OF_BUFFER: { @@ -1228,15 +1446,19 @@ YY_FATAL_ERROR( "flex scanner jammed" ); { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed skel_in at a new source and called - * skel_lex(). If so, then we have to assure + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = skel_in; +/* %if-c-only */ + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; +/* %endif */ +/* %if-c++-only */ +/* %endif */ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1291,11 +1513,11 @@ YY_FATAL_ERROR( "flex scanner jammed" ); { (yy_did_buffer_switch_on_eof) = 0; - if ( skel_wrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * skel_text, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the @@ -1344,12 +1566,12 @@ YY_FATAL_ERROR( "flex scanner jammed" ); "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -} /* end of skel_lex */ + } /* end of user's declarations */ +} /* end of yylex */ /* %ok-for-header */ /* %if-c++-only */ /* %not-for-header */ - /* %ok-for-header */ /* %endif */ @@ -1367,9 +1589,9 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1398,7 +1620,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1418,7 +1640,7 @@ static int yy_get_next_buffer (void) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); @@ -1434,11 +1656,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - skel_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1456,7 +1679,7 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); + (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } @@ -1466,7 +1689,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - skel_restart(skel_in ); + yyrestart( yyin ); } else @@ -1480,12 +1703,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) skel_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1501,14 +1727,13 @@ static int yy_get_next_buffer (void) /* %if-c-only */ /* %not-for-header */ - static yy_state_type yy_get_previous_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; /* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = (yy_start); @@ -1516,7 +1741,7 @@ static int yy_get_next_buffer (void) for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1526,9 +1751,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 72 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1545,11 +1770,11 @@ static int yy_get_next_buffer (void) /* %if-c++-only */ /* %endif */ { - register int yy_is_jam; + int yy_is_jam; /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ - register char *yy_cp = (yy_c_buf_p); + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1559,17 +1784,19 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 72 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 71); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } +#ifndef YY_NO_UNPUT /* %if-c-only */ /* %endif */ +#endif /* %if-c-only */ #ifndef YY_NO_INPUT @@ -1599,7 +1826,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1616,14 +1843,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - skel_restart(skel_in ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( skel_wrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1642,10 +1869,10 @@ static int yy_get_next_buffer (void) } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve skel_text */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); -/* %% [19.0] update BOL and skel_lineno */ +/* %% [19.0] update BOL and yylineno */ return c; } @@ -1659,28 +1886,31 @@ static int yy_get_next_buffer (void) * @note This function does not reset the start condition to @c INITIAL . */ /* %if-c-only */ - void skel_restart (FILE * input_file ) + void yyrestart (FILE * input_file ) /* %endif */ /* %if-c++-only */ /* %endif */ { if ( ! YY_CURRENT_BUFFER ){ - skel_ensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - skel__create_buffer(skel_in,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - skel__init_buffer(YY_CURRENT_BUFFER,input_file ); - skel__load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } +/* %if-c++-only */ +/* %endif */ + /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ /* %if-c-only */ - void skel__switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1688,10 +1918,10 @@ static int yy_get_next_buffer (void) /* TODO. We should be able to replace this entire function body * with - * skel_pop_buffer_state(); - * skel_push_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - skel_ensure_buffer_stack (); + yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1704,25 +1934,29 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - skel__load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during - * EOF (skel_wrap()) processing, but the only time this flag - * is looked at is after skel_wrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } /* %if-c-only */ -static void skel__load_buffer_state (void) +static void yy_load_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - skel_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %if-c-only */ + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ (yy_hold_char) = *(yy_c_buf_p); } @@ -1733,39 +1967,42 @@ static void skel__load_buffer_state (void) * @return the allocated buffer state. */ /* %if-c-only */ - YY_BUFFER_STATE skel__create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) /* %endif */ /* %if-c++-only */ /* %endif */ { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) skel_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in skel__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) skel_alloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in skel__create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - skel__init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } +/* %if-c++-only */ +/* %endif */ + /** Destroy the buffer. - * @param b a buffer created with skel__create_buffer() + * @param b a buffer created with yy_create_buffer() * */ /* %if-c-only */ - void skel__delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1778,24 +2015,17 @@ static void skel__load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - skel_free((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - skel_free((void *) b ); + yyfree( (void *) b ); } -/* %if-c-only */ - -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a skel_restart() or at EOF. + * such as during a yyrestart() or at EOF. */ /* %if-c-only */ - static void skel__init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1803,13 +2033,17 @@ static void skel__load_buffer_state (void) { int oerrno = errno; - skel__flush_buffer(b ); + yy_flush_buffer( b ); +/* %if-c-only */ b->yy_input_file = file; +/* %endif */ +/* %if-c++-only */ +/* %endif */ b->yy_fill_buffer = 1; - /* If b is the current buffer, then skel__init_buffer was _probably_ - * called from skel_restart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -1832,7 +2066,7 @@ static void skel__load_buffer_state (void) * */ /* %if-c-only */ - void skel__flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1855,7 +2089,7 @@ static void skel__load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - skel__load_buffer_state( ); + yy_load_buffer_state( ); } /* %if-c-or-c++ */ @@ -1866,7 +2100,7 @@ static void skel__load_buffer_state (void) * */ /* %if-c-only */ -void skel_push_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1874,9 +2108,9 @@ void skel_push_buffer_state (YY_BUFFER_STATE new_buffer ) if (new_buffer == NULL) return; - skel_ensure_buffer_stack(); + yyensure_buffer_stack(); - /* This block is copied from skel__switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -1890,8 +2124,8 @@ void skel_push_buffer_state (YY_BUFFER_STATE new_buffer ) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from skel__switch_to_buffer. */ - skel__load_buffer_state( ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /* %endif */ @@ -1902,7 +2136,7 @@ void skel_push_buffer_state (YY_BUFFER_STATE new_buffer ) * */ /* %if-c-only */ -void skel_pop_buffer_state (void) +void yypop_buffer_state (void) /* %endif */ /* %if-c++-only */ /* %endif */ @@ -1910,13 +2144,13 @@ void skel_pop_buffer_state (void) if (!YY_CURRENT_BUFFER) return; - skel__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - skel__load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1927,12 +2161,12 @@ void skel_pop_buffer_state (void) * Guarantees space for at least one push. */ /* %if-c-only */ -static void skel_ensure_buffer_stack (void) +static void yyensure_buffer_stack (void) /* %endif */ /* %if-c++-only */ /* %endif */ { - int num_to_alloc; + yy_size_t num_to_alloc; if (!(yy_buffer_stack)) { @@ -1940,15 +2174,15 @@ static void skel_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)skel_alloc + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in skel_ensure_buffer_stack()" ); - + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1957,15 +2191,15 @@ static void skel_ensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)skel_realloc + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in skel_ensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -1979,9 +2213,9 @@ static void skel_ensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE skel__scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; @@ -1989,53 +2223,53 @@ YY_BUFFER_STATE skel__scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) skel_alloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in skel__scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - skel__switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan a string. The next call to skel_lex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * skel__scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE skel__scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return skel__scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } /* %endif */ /* %if-c-only */ -/** Setup the input buffer state to scan the given bytes. The next call to skel_lex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE skel__scan_bytes (yyconst char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -2043,19 +2277,19 @@ YY_BUFFER_STATE skel__scan_bytes (yyconst char * yybytes, int _yybytes_len ) int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) skel_alloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in skel__scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = skel__scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in skel__scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2071,9 +2305,9 @@ YY_BUFFER_STATE skel__scan_bytes (yyconst char * yybytes, int _yybytes_len ) #endif /* %if-c-only */ -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* %endif */ @@ -2086,14 +2320,14 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up skel_text. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - skel_text[skel_leng] = (yy_hold_char); \ - (yy_c_buf_p) = skel_text + yyless_macro_arg; \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ - skel_leng = yyless_macro_arg; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) @@ -2106,82 +2340,82 @@ static void yy_fatal_error (yyconst char* msg ) /** Get the current line number. * */ -int skel_get_lineno (void) +int yyget_lineno (void) { - - return skel_lineno; + + return yylineno; } /** Get the input stream. * */ -FILE *skel_get_in (void) +FILE *yyget_in (void) { - return skel_in; + return yyin; } /** Get the output stream. * */ -FILE *skel_get_out (void) +FILE *yyget_out (void) { - return skel_out; + return yyout; } /** Get the length of the current token. * */ -int skel_get_leng (void) +int yyget_leng (void) { - return skel_leng; + return yyleng; } /** Get the current token. * */ -char *skel_get_text (void) +char *yyget_text (void) { - return skel_text; + return yytext; } /* %if-reentrant */ /* %endif */ /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void skel_set_lineno (int line_number ) +void yyset_lineno (int _line_number ) { - skel_lineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * - * @see skel__switch_to_buffer + * @see yy_switch_to_buffer */ -void skel_set_in (FILE * in_str ) +void yyset_in (FILE * _in_str ) { - skel_in = in_str ; + yyin = _in_str ; } -void skel_set_out (FILE * out_str ) +void yyset_out (FILE * _out_str ) { - skel_out = out_str ; + yyout = _out_str ; } -int skel_get_debug (void) +int yyget_debug (void) { - return skel__flex_debug; + return yy_flex_debug; } -void skel_set_debug (int bdebug ) +void yyset_debug (int _bdebug ) { - skel__flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } /* %endif */ @@ -2195,50 +2429,50 @@ void skel_set_debug (int bdebug ) static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. - * This function is called from skel_lex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT - skel_in = stdin; - skel_out = stdout; + yyin = stdin; + yyout = stdout; #else - skel_in = (FILE *) 0; - skel_out = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * skel_lex_init() + * yylex_init() */ return 0; } /* %endif */ /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ -/* skel_lex_destroy is for both reentrant and non-reentrant scanners. */ -int skel_lex_destroy (void) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - skel__delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; - skel_pop_buffer_state(); + yypop_buffer_state(); } /* Destroy the stack itself. */ - skel_free((yy_buffer_stack) ); + yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * skel_lex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( ); /* %if-reentrant */ @@ -2252,18 +2486,19 @@ int skel_lex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -2271,13 +2506,14 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *skel_alloc (yy_size_t size ) +void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } -void *skel_realloc (void * ptr, yy_size_t size ) +void *yyrealloc (void * ptr, yy_size_t size ) { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -2285,12 +2521,12 @@ void *skel_realloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void skel_free (void * ptr ) +void yyfree (void * ptr ) { - free( (char *) ptr ); /* see skel_realloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } /* %if-tables-serialization definitions */ @@ -2300,16 +2536,15 @@ void skel_free (void * ptr ) /* %ok-for-header */ -#line 143 "scan-skel.l" - +#line 144 "src/scan-skel.l" static void at_init (int *argc, char *argv[], at_directive *at_ptr, at_directive fun) { *at_ptr = fun; - skel_text[skel_leng-1] = '\0'; - obstack_grow (&obstack_for_string, skel_text, skel_leng); + yytext[yyleng-1] = '\0'; + obstack_grow (&obstack_for_string, yytext, yyleng); argv[(*argc)++] = obstack_finish (&obstack_for_string); BEGIN SC_AT_DIRECTIVE_ARGS; } @@ -2337,7 +2572,7 @@ skel_scanner_free (void) { obstack_free (&obstack_for_string, 0); /* Reclaim Flex's buffers. */ - skel_lex_destroy (); + yylex_destroy (); } static inline warnings @@ -2355,7 +2590,7 @@ flag (const char *arg) else if (STREQ (arg, "warn")) return Wother; else - aver (false); + abort (); } static void @@ -2365,7 +2600,7 @@ at_basename (int argc, char *argv[], char **out_namep, int *out_linenop) (void) out_linenop; if (2 < argc) fail_for_at_directive_too_many_args (argv[0]); - fputs (last_component (argv[1]), skel_out); + fputs (last_component (argv[1]), yyout); } static void @@ -2404,11 +2639,12 @@ at_output (int argc, char *argv[], char **out_namep, int *out_linenop) if (*out_namep) { free (*out_namep); - xfclose (skel_out); + xfclose (yyout); } *out_namep = xstrdup (argv[1]); - output_file_name_check (out_namep); - skel_out = xfopen (*out_namep, "wb"); + output_file_name_check (out_namep, true); + /* If there were errors, do not generate the output. */ + yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "wb"); *out_linenop = 1; } diff --git a/contrib/tools/bison/src/scan-skel.h b/contrib/tools/bison/src/scan-skel.h index 019d38af5a..f76abde10d 100644 --- a/contrib/tools/bison/src/scan-skel.h +++ b/contrib/tools/bison/src/scan-skel.h @@ -1,6 +1,7 @@ /* Scan Bison Skeletons. - Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/state.c b/contrib/tools/bison/src/state.c index c11b10f7dd..7037b358ea 100644 --- a/contrib/tools/bison/src/state.c +++ b/contrib/tools/bison/src/state.c @@ -1,6 +1,7 @@ /* Type definitions for the finite state machine for Bison. - Copyright (C) 2001-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/state.h b/contrib/tools/bison/src/state.h index 37cd9bf9ec..f8ef6d2a0d 100644 --- a/contrib/tools/bison/src/state.h +++ b/contrib/tools/bison/src/state.h @@ -1,7 +1,7 @@ /* Type definitions for the finite state machine for Bison. - Copyright (C) 1984, 1989, 2000-2004, 2007, 2009-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2004, 2007, 2009-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -135,7 +135,7 @@ typedef struct /* Is the TRANSITIONS->states[Num] labelled by the error token? */ # define TRANSITION_IS_ERROR(Transitions, Num) \ - (TRANSITION_SYMBOL (Transitions, Num) == errtoken->number) + (TRANSITION_SYMBOL (Transitions, Num) == errtoken->content->number) /* When resolving a SR conflicts, if the reduction wins, the shift is disabled. */ diff --git a/contrib/tools/bison/src/symlist.c b/contrib/tools/bison/src/symlist.c index 50915c18bd..201ddabdba 100644 --- a/contrib/tools/bison/src/symlist.c +++ b/contrib/tools/bison/src/symlist.c @@ -1,7 +1,7 @@ /* Lists of symbols for Bison - Copyright (C) 2002, 2005-2007, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002, 2005-2007, 2009-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -21,7 +21,6 @@ #include <config.h> #include "system.h" -#include "complain.h" #include "symlist.h" /*--------------------------------------. @@ -174,45 +173,33 @@ symbol_list * symbol_list_n_get (symbol_list *l, int n) { int i; - - if (n < 0) - return NULL; - + aver (0 <= n); for (i = 0; i < n; ++i) { l = l->next; - if (l == NULL - || (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL)) - return NULL; + aver (l); } - + aver (l->content_type == SYMLIST_SYMBOL); + aver (l->content.sym); return l; } - /*--------------------------------------------------------------. | Get the data type (alternative in the union) of the value for | | symbol N in symbol list L. | `--------------------------------------------------------------*/ uniqstr -symbol_list_n_type_name_get (symbol_list *l, location loc, int n) +symbol_list_n_type_name_get (symbol_list *l, int n) { - l = symbol_list_n_get (l, n); - if (!l) - { - complain (&loc, complaint, _("invalid $ value: $%d"), n); - return NULL; - } - aver (l->content_type == SYMLIST_SYMBOL); - return l->content.sym->type_name; + return symbol_list_n_get (l, n)->content.sym->content->type_name; } bool symbol_list_null (symbol_list *node) { - return !node || - (node->content_type == SYMLIST_SYMBOL && !(node->content.sym)); + return (!node + || (node->content_type == SYMLIST_SYMBOL && !node->content.sym)); } void @@ -223,8 +210,8 @@ symbol_list_code_props_set (symbol_list *node, code_props_type kind, { case SYMLIST_SYMBOL: symbol_code_props_set (node->content.sym, kind, cprops); - if (node->content.sym->status == undeclared) - node->content.sym->status = used; + if (node->content.sym->content->status == undeclared) + node->content.sym->content->status = used; break; case SYMLIST_TYPE: semantic_type_code_props_set diff --git a/contrib/tools/bison/src/symlist.h b/contrib/tools/bison/src/symlist.h index c369f69bb1..3ade17049a 100644 --- a/contrib/tools/bison/src/symlist.h +++ b/contrib/tools/bison/src/symlist.h @@ -1,7 +1,7 @@ /* Lists of symbols for Bison - Copyright (C) 2002, 2005-2007, 2009-2013 Free Software Foundation, - Inc. + Copyright (C) 2002, 2005-2007, 2009-2015, 2018 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -116,12 +116,15 @@ void symbol_list_free (symbol_list *list); /** Return the length of \c l. */ int symbol_list_length (symbol_list const *l); -/** Get item \c n in symbol list \c l. */ +/** Get item \c n in symbol list \c l. + ** \pre 0 <= n + ** \post res != NULL + **/ symbol_list *symbol_list_n_get (symbol_list *l, int n); /* Get the data type (alternative in the union) of the value for symbol N in rule RULE. */ -uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n); +uniqstr symbol_list_n_type_name_get (symbol_list *l, int n); /* Check whether the node is a border element of a rule. */ bool symbol_list_null (symbol_list *node); diff --git a/contrib/tools/bison/src/symtab.c b/contrib/tools/bison/src/symtab.c index c50a98a7c3..a91ac3f860 100644 --- a/contrib/tools/bison/src/symtab.c +++ b/contrib/tools/bison/src/symtab.c @@ -1,6 +1,6 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000-2002, 2004-2013 Free Software + Copyright (C) 1984, 1989, 2000-2002, 2004-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -58,6 +58,32 @@ static symgraph **prec_nodes; bool *used_assoc = NULL; +/*--------------------------. +| Create a new sym_content. | +`--------------------------*/ + +static sym_content * +sym_content_new (symbol *s) +{ + sym_content *res = xmalloc (sizeof *res); + + res->symbol = s; + + res->type_name = NULL; + for (int i = 0; i < CODE_PROPS_SIZE; ++i) + code_props_none_init (&res->props[i]); + + res->number = NUMBER_UNDEFINED; + res->prec = 0; + res->assoc = undef_assoc; + res->user_token_number = USER_NUMBER_UNDEFINED; + + res->class = unknown_sym; + res->status = undeclared; + + return res; +} + /*---------------------------------. | Create a new symbol, named TAG. | `---------------------------------*/ @@ -76,22 +102,10 @@ symbol_new (uniqstr tag, location loc) res->tag = tag; res->location = loc; - - res->type_name = NULL; - { - int i; - for (i = 0; i < CODE_PROPS_SIZE; ++i) - code_props_none_init (&res->props[i]); - } - - res->number = NUMBER_UNDEFINED; - res->prec = 0; - res->assoc = undef_assoc; - res->user_token_number = USER_NUMBER_UNDEFINED; - + res->location_of_lhs = false; res->alias = NULL; - res->class = unknown_sym; - res->status = undeclared; + res->content = sym_content_new (res); + res->is_alias = false; if (nsyms == SYMBOL_NUMBER_MAXIMUM) complain (NULL, fatal, _("too many symbols in input grammar (limit is %d)"), @@ -100,6 +114,66 @@ symbol_new (uniqstr tag, location loc) return res; } +/*--------------------. +| Free a sym_content. | +`--------------------*/ + +static void +sym_content_free (sym_content *sym) +{ + free (sym); +} + + +/*---------------------------------------------------------. +| Free a symbol and its associated content if appropriate. | +`---------------------------------------------------------*/ + +static void +symbol_free (void *ptr) +{ + symbol *sym = (symbol *)ptr; + if (!sym->is_alias) + sym_content_free (sym->content); + free (sym); + +} + +/* If needed, swap first and second so that first has the earliest + location (according to location_cmp). + + Many symbol features (e.g., user token numbers) are not assigned + during the parsing, but in a second step, via a traversal of the + symbol table sorted on tag. + + However, error messages make more sense if we keep the first + declaration first. +*/ + +static +void symbols_sort (symbol **first, symbol **second) +{ + if (0 < location_cmp ((*first)->location, (*second)->location)) + { + symbol* tmp = *first; + *first = *second; + *second = tmp; + } +} + +/* Likewise, for locations. */ + +static +void locations_sort (location *first, location *second) +{ + if (0 < location_cmp (*first, *second)) + { + location tmp = *first; + *first = *second; + *second = tmp; + } +} + char const * code_props_type_string (code_props_type kind) { @@ -110,9 +184,10 @@ code_props_type_string (code_props_type kind) case printer: return "%printer"; } - assert (0); + abort (); } + /*----------------------------------------. | Create a new semantic type, named TAG. | `----------------------------------------*/ @@ -126,11 +201,8 @@ semantic_type_new (uniqstr tag, const location *loc) res->tag = tag; res->location = loc ? *loc : empty_location; res->status = undeclared; - { - int i; - for (i = 0; i < CODE_PROPS_SIZE; ++i) - code_props_none_init (&res->props[i]); - } + for (int i = 0; i < CODE_PROPS_SIZE; ++i) + code_props_none_init (&res->props[i]); return res; } @@ -141,12 +213,12 @@ semantic_type_new (uniqstr tag, const location *loc) `-----------------*/ #define SYMBOL_ATTR_PRINT(Attr) \ - if (s->Attr) \ - fprintf (f, " %s { %s }", #Attr, s->Attr) + if (s->content->Attr) \ + fprintf (f, " %s { %s }", #Attr, s->content->Attr) #define SYMBOL_CODE_PRINT(Attr) \ - if (s->props[Attr].code) \ - fprintf (f, " %s { %s }", #Attr, s->props[Attr].code) + if (s->content->props[Attr].code) \ + fprintf (f, " %s { %s }", #Attr, s->content->props[Attr].code) void symbol_print (symbol const *s, FILE *f) @@ -173,7 +245,7 @@ symbol_print (symbol const *s, FILE *f) static bool is_identifier (uniqstr s) { - static char const alphanum[26 + 26 + 1 + 10 + 1] = + static char const alphanum[26 + 26 + 1 + 10] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_" @@ -193,7 +265,6 @@ is_identifier (uniqstr s) uniqstr symbol_id_get (symbol const *sym) { - aver (sym->user_token_number != USER_NUMBER_HAS_STRING_ALIAS); if (sym->alias) sym = sym->alias; return is_identifier (sym->tag) ? sym->tag : 0; @@ -210,6 +281,7 @@ symbol_redeclaration (symbol *s, const char *what, location first, location second) { unsigned i = 0; + locations_sort (&first, &second); complain_indent (&second, complaint, &i, _("%s redeclaration for %s"), what, s->tag); i += SUB_INDENT; @@ -222,6 +294,7 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first, location second) { unsigned i = 0; + locations_sort (&first, &second); complain_indent (&second, complaint, &i, _("%s redeclaration for <%s>"), what, s->tag); i += SUB_INDENT; @@ -230,6 +303,13 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first, } +void +symbol_location_as_lhs_set (symbol *sym, location loc) +{ + if (!sym->location_of_lhs) + sym->location = loc; +} + /*-----------------------------------------------------------------. | Set the TYPE_NAME associated with SYM. Does nothing if passed 0 | @@ -241,13 +321,13 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc) { if (type_name) { - if (sym->type_name) - symbol_redeclaration (sym, "%type", sym->type_location, loc); + if (sym->content->type_name) + symbol_redeclaration (sym, "%type", sym->content->type_location, loc); else { uniqstr_assert (type_name); - sym->type_name = type_name; - sym->type_location = loc; + sym->content->type_name = type_name; + sym->content->type_location = loc; } } } @@ -260,12 +340,12 @@ void symbol_code_props_set (symbol *sym, code_props_type kind, code_props const *code) { - if (sym->props[kind].code) + if (sym->content->props[kind].code) symbol_redeclaration (sym, code_props_type_string (kind), - sym->props[kind].location, + sym->content->props[kind].location, code->location); else - sym->props[kind] = *code; + sym->content->props[kind] = *code; } /*-----------------------------------------------------. @@ -293,14 +373,14 @@ code_props * symbol_code_props_get (symbol *sym, code_props_type kind) { /* Per-symbol code props. */ - if (sym->props[kind].code) - return &sym->props[kind]; + if (sym->content->props[kind].code) + return &sym->content->props[kind]; /* Per-type code props. */ - if (sym->type_name) + if (sym->content->type_name) { code_props *code = - &semantic_type_get (sym->type_name, NULL)->props[kind]; + &semantic_type_get (sym->content->type_name, NULL)->props[kind]; if (code->code) return code; } @@ -308,8 +388,8 @@ symbol_code_props_get (symbol *sym, code_props_type kind) /* Apply default code props's only to user-defined symbols. */ if (sym->tag[0] != '$' && sym != errtoken) { - code_props *code = - &semantic_type_get (sym->type_name ? "*" : "", NULL)->props[kind]; + code_props *code = &semantic_type_get (sym->content->type_name ? "*" : "", + NULL)->props[kind]; if (code->code) return code; } @@ -326,14 +406,15 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc) { if (a != undef_assoc) { - if (sym->prec) - symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location, - loc); + sym_content *s = sym->content; + if (s->prec) + symbol_redeclaration (sym, assoc_to_string (a), + s->prec_location, loc); else { - sym->prec = prec; - sym->assoc = a; - sym->prec_location = loc; + s->prec = prec; + s->assoc = a; + s->prec_location = loc; } } @@ -350,26 +431,26 @@ void symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) { bool warned = false; - if (sym->class != unknown_sym && sym->class != class) + if (sym->content->class != unknown_sym && sym->content->class != class) { complain (&loc, complaint, _("symbol %s redefined"), sym->tag); /* Don't report both "redefined" and "redeclared". */ warned = true; } - if (class == nterm_sym && sym->class != nterm_sym) - sym->number = nvars++; - else if (class == token_sym && sym->number == NUMBER_UNDEFINED) - sym->number = ntokens++; + if (class == nterm_sym && sym->content->class != nterm_sym) + sym->content->number = nvars++; + else if (class == token_sym && sym->content->number == NUMBER_UNDEFINED) + sym->content->number = ntokens++; - sym->class = class; + sym->content->class = class; if (declaring) { - if (sym->status == declared && !warned) + if (sym->content->status == declared && !warned) complain (&loc, Wother, _("symbol %s redeclared"), sym->tag); else - sym->status = declared; + sym->content->status = declared; } } @@ -383,10 +464,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) { int *user_token_numberp; - if (sym->user_token_number != USER_NUMBER_HAS_STRING_ALIAS) - user_token_numberp = &sym->user_token_number; - else - user_token_numberp = &sym->alias->user_token_number; + user_token_numberp = &sym->content->user_token_number; if (*user_token_numberp != USER_NUMBER_UNDEFINED && *user_token_numberp != user_token_number) complain (&loc, complaint, _("redefining user token number of %s"), @@ -396,12 +474,12 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) /* User defined $end token? */ if (user_token_number == 0) { - endtoken = sym; + endtoken = sym->content->symbol; /* It is always mapped to 0, so it was already counted in NTOKENS. */ - if (endtoken->number != NUMBER_UNDEFINED) + if (endtoken->content->number != NUMBER_UNDEFINED) --ntokens; - endtoken->number = 0; + endtoken->content->number = 0; } } @@ -414,29 +492,27 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) static inline bool symbol_check_defined (symbol *sym) { - if (sym->class == unknown_sym) + sym_content *s = sym->content; + if (s->class == unknown_sym) { - assert (sym->status != declared); + assert (s->status != declared); complain (&sym->location, - sym->status == needed ? complaint : Wother, + s->status == needed ? complaint : Wother, _("symbol %s is used, but is not defined as a token" " and has no rules"), sym->tag); - sym->class = nterm_sym; - sym->number = nvars++; + s->class = nterm_sym; + s->number = nvars++; } - { - int i; - for (i = 0; i < 2; ++i) - symbol_code_props_get (sym, i)->is_used = true; - } + for (int i = 0; i < 2; ++i) + symbol_code_props_get (sym, i)->is_used = true; /* Set the semantic type status associated to the current symbol to 'declared' so that we could check semantic types unnecessary uses. */ - if (sym->type_name) + if (s->type_name) { - semantic_type *sem_type = semantic_type_get (sym->type_name, NULL); + semantic_type *sem_type = semantic_type_get (s->type_name, NULL); if (sem_type) sem_type->status = declared; } @@ -452,8 +528,7 @@ semantic_type_check_defined (semantic_type *sem_type) || !*sem_type->tag || STREQ (sem_type->tag, "*")) { - int i; - for (i = 0; i < 2; ++i) + for (int i = 0; i < 2; ++i) if (sem_type->props[i].kind != CODE_PROPS_NONE && ! sem_type->props[i].is_used) complain (&sem_type->location, Wother, @@ -482,79 +557,61 @@ semantic_type_check_defined_processor (void *sem_type, } -void -symbol_make_alias (symbol *sym, symbol *str, location loc) -{ - if (str->alias) - complain (&loc, Wother, - _("symbol %s used more than once as a literal string"), str->tag); - else if (sym->alias) - complain (&loc, Wother, - _("symbol %s given more than one literal string"), sym->tag); - else - { - str->class = token_sym; - str->user_token_number = sym->user_token_number; - sym->user_token_number = USER_NUMBER_HAS_STRING_ALIAS; - str->alias = sym; - sym->alias = str; - str->number = sym->number; - symbol_type_set (str, sym->type_name, loc); - } -} - - -/*---------------------------------------------------------. -| Check that THIS, and its alias, have same precedence and | -| associativity. | -`---------------------------------------------------------*/ +/*-------------------------------------------------------------------. +| Merge the properties (precedence, associativity, etc.) of SYM, and | +| its string-named alias STR; check consistency. | +`-------------------------------------------------------------------*/ -static inline void -symbol_check_alias_consistency (symbol *this) +static void +symbol_merge_properties (symbol *sym, symbol *str) { - symbol *sym = this; - symbol *str = this->alias; - - /* Check only the symbol in the symbol-string pair. */ - if (!(this->alias - && this->user_token_number == USER_NUMBER_HAS_STRING_ALIAS)) - return; - - if (str->type_name != sym->type_name) + if (str->content->type_name != sym->content->type_name) { - if (str->type_name) - symbol_type_set (sym, str->type_name, str->type_location); + if (str->content->type_name) + symbol_type_set (sym, + str->content->type_name, str->content->type_location); else - symbol_type_set (str, sym->type_name, sym->type_location); + symbol_type_set (str, + sym->content->type_name, sym->content->type_location); } - { - int i; - for (i = 0; i < CODE_PROPS_SIZE; ++i) - if (str->props[i].code) - symbol_code_props_set (sym, i, &str->props[i]); - else if (sym->props[i].code) - symbol_code_props_set (str, i, &sym->props[i]); - } + for (int i = 0; i < CODE_PROPS_SIZE; ++i) + if (str->content->props[i].code) + symbol_code_props_set (sym, i, &str->content->props[i]); + else if (sym->content->props[i].code) + symbol_code_props_set (str, i, &sym->content->props[i]); - if (sym->prec || str->prec) + if (sym->content->prec || str->content->prec) { - if (str->prec) - symbol_precedence_set (sym, str->prec, str->assoc, - str->prec_location); + if (str->content->prec) + symbol_precedence_set (sym, str->content->prec, str->content->assoc, + str->content->prec_location); else - symbol_precedence_set (str, sym->prec, sym->assoc, - sym->prec_location); + symbol_precedence_set (str, sym->content->prec, sym->content->assoc, + sym->content->prec_location); } } -static bool -symbol_check_alias_consistency_processor (void *this, - void *null ATTRIBUTE_UNUSED) +void +symbol_make_alias (symbol *sym, symbol *str, location loc) { - symbol_check_alias_consistency (this); - return true; + if (str->alias) + complain (&loc, Wother, + _("symbol %s used more than once as a literal string"), str->tag); + else if (sym->alias) + complain (&loc, Wother, + _("symbol %s given more than one literal string"), sym->tag); + else + { + symbol_merge_properties (sym, str); + sym_content_free (str->content); + str->content = sym->content; + str->content->symbol = str; + str->is_alias = true; + str->alias = sym; + sym->alias = str; + } } @@ -566,13 +623,11 @@ symbol_check_alias_consistency_processor (void *this, static inline bool symbol_pack (symbol *this) { - aver (this->number != NUMBER_UNDEFINED); - if (this->class == nterm_sym) - this->number += ntokens; - else if (this->user_token_number == USER_NUMBER_HAS_STRING_ALIAS) - return true; + aver (this->content->number != NUMBER_UNDEFINED); + if (this->content->class == nterm_sym) + this->content->number += ntokens; - symbols[this->number] = this; + symbols[this->content->number] = this->content->symbol; return true; } @@ -582,22 +637,11 @@ symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED) return symbol_pack (this); } - static void user_token_number_redeclaration (int num, symbol *first, symbol *second) { unsigned i = 0; - /* User token numbers are not assigned during the parsing, but in a - second step, via a traversal of the symbol table sorted on tag. - - However, error messages make more sense if we keep the first - declaration first. */ - if (location_cmp (first->location, second->location) > 0) - { - symbol* tmp = first; - first = second; - second = tmp; - } + symbols_sort (&first, &second); complain_indent (&second->location, complaint, &i, _("user token number %d redeclaration for %s"), num, second->tag); @@ -615,17 +659,18 @@ static inline bool symbol_translation (symbol *this) { /* Non-terminal? */ - if (this->class == token_sym - && this->user_token_number != USER_NUMBER_HAS_STRING_ALIAS) + if (this->content->class == token_sym + && !this->is_alias) { - /* A token which translation has already been set? */ - if (token_translations[this->user_token_number] != undeftoken->number) + /* A token which translation has already been set?*/ + if (token_translations[this->content->user_token_number] + != undeftoken->content->number) user_token_number_redeclaration - (this->user_token_number, - symbols[token_translations[this->user_token_number]], - this); + (this->content->user_token_number, + symbols[token_translations[this->content->user_token_number]], this); else - token_translations[this->user_token_number] = this->number; + token_translations[this->content->user_token_number] + = this->content->number; } return true; @@ -711,7 +756,7 @@ symbols_new (void) NULL, hash_symbol_hasher, hash_symbol_comparator, - free); + symbol_free); semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_semantic_type_hasher, @@ -729,10 +774,9 @@ symbol * symbol_from_uniqstr (const uniqstr key, location loc) { symbol probe; - symbol *entry; probe.tag = key; - entry = hash_lookup (symbol_table, &probe); + symbol *entry = hash_lookup (symbol_table, &probe); if (!entry) { @@ -755,10 +799,9 @@ semantic_type * semantic_type_from_uniqstr (const uniqstr key, const location *loc) { semantic_type probe; - semantic_type *entry; probe.tag = key; - entry = hash_lookup (semantic_type_table, &probe); + semantic_type *entry = hash_lookup (semantic_type_table, &probe); if (!entry) { @@ -807,12 +850,10 @@ dummy_symbol_get (location loc) static int dummy_count = 0; static char buf[256]; - symbol *sym; - sprintf (buf, "$@%d", ++dummy_count); - sym = symbol_get (buf, loc); - sym->class = nterm_sym; - sym->number = nvars++; + symbol *sym = symbol_get (buf, loc); + sym->content->class = nterm_sym; + sym->content->number = nvars++; return sym; } @@ -865,11 +906,8 @@ symbols_do (Hash_processor processor, void *processor_data, hash_get_entries (table, (void**)*sorted, count); qsort (*sorted, count, sizeof **sorted, symbols_cmp_qsort); } - { - size_t i; - for (i = 0; i < count; ++i) - processor ((*sorted)[i], processor_data); - } + for (size_t i = 0; i < count; ++i) + processor ((*sorted)[i], processor_data); } /*--------------------------------------------------------------. @@ -895,14 +933,13 @@ static void symbols_token_translations_init (void) { bool num_256_available_p = true; - int i; /* Find the highest user token number, and whether 256, the POSIX preferred user token number for the error token, is used. */ max_user_token_number = 0; - for (i = 0; i < ntokens; ++i) + for (int i = 0; i < ntokens; ++i) { - symbol *this = symbols[i]; + sym_content *this = symbols[i]->content; if (this->user_token_number != USER_NUMBER_UNDEFINED) { if (this->user_token_number > max_user_token_number) @@ -914,16 +951,16 @@ symbols_token_translations_init (void) /* If 256 is not used, assign it to error, to follow POSIX. */ if (num_256_available_p - && errtoken->user_token_number == USER_NUMBER_UNDEFINED) - errtoken->user_token_number = 256; + && errtoken->content->user_token_number == USER_NUMBER_UNDEFINED) + errtoken->content->user_token_number = 256; /* Set the missing user numbers. */ if (max_user_token_number < 256) max_user_token_number = 256; - for (i = 0; i < ntokens; ++i) + for (int i = 0; i < ntokens; ++i) { - symbol *this = symbols[i]; + sym_content *this = symbols[i]->content; if (this->user_token_number == USER_NUMBER_UNDEFINED) this->user_token_number = ++max_user_token_number; if (this->user_token_number > max_user_token_number) @@ -935,8 +972,8 @@ symbols_token_translations_init (void) /* Initialize all entries for literal tokens to the internal token number for $undefined, which represents all invalid inputs. */ - for (i = 0; i < max_user_token_number + 1; i++) - token_translations[i] = undeftoken->number; + for (int i = 0; i < max_user_token_number + 1; i++) + token_translations[i] = undeftoken->content->number; symbols_do (symbol_translation_processor, NULL, symbol_table, &symbols_sorted); } @@ -950,18 +987,13 @@ symbols_token_translations_init (void) void symbols_pack (void) { - symbols_do (symbol_check_alias_consistency_processor, NULL, - symbol_table, &symbols_sorted); - symbols = xcalloc (nsyms, sizeof *symbols); symbols_do (symbol_pack_processor, NULL, symbol_table, &symbols_sorted); /* Aliases leave empty slots in symbols, so remove them. */ { - int writei; - int readi; int nsyms_old = nsyms; - for (writei = 0, readi = 0; readi < nsyms_old; readi += 1) + for (int writei = 0, readi = 0; readi < nsyms_old; readi += 1) { if (symbols[readi] == NULL) { @@ -971,9 +1003,7 @@ symbols_pack (void) else { symbols[writei] = symbols[readi]; - symbols[writei]->number = writei; - if (symbols[writei]->alias) - symbols[writei]->alias->number = writei; + symbols[writei]->content->number = writei; writei += 1; } } @@ -982,11 +1012,11 @@ symbols_pack (void) symbols_token_translations_init (); - if (startsymbol->class == unknown_sym) + if (startsymbol->content->class == unknown_sym) complain (&startsymbol_location, fatal, _("the start symbol %s is undefined"), startsymbol->tag); - else if (startsymbol->class == token_sym) + else if (startsymbol->content->class == token_sym) complain (&startsymbol_location, fatal, _("the start symbol %s is a token"), startsymbol->tag); @@ -999,9 +1029,8 @@ symbols_pack (void) static void init_prec_nodes (void) { - int i; prec_nodes = xcalloc (nsyms, sizeof *prec_nodes); - for (i = 0; i < nsyms; ++i) + for (int i = 0; i < nsyms; ++i) { prec_nodes[i] = xmalloc (sizeof *prec_nodes[i]); symgraph *s = prec_nodes[i]; @@ -1092,8 +1121,7 @@ linkedlist_free (symgraphlink *node) static void assoc_free (void) { - int i; - for (i = 0; i < nsyms; ++i) + for (int i = 0; i < nsyms; ++i) { linkedlist_free (prec_nodes[i]->pred); linkedlist_free (prec_nodes[i]->succ); @@ -1109,9 +1137,8 @@ assoc_free (void) static void init_assoc (void) { - graphid i; used_assoc = xcalloc (nsyms, sizeof *used_assoc); - for (i = 0; i < nsyms; ++i) + for (graphid i = 0; i < nsyms; ++i) used_assoc[i] = false; } @@ -1123,9 +1150,9 @@ static inline bool is_assoc_useless (symbol *s) { return s - && s->assoc != undef_assoc - && s->assoc != precedence_assoc - && !used_assoc[s->number]; + && s->content->assoc != undef_assoc + && s->content->assoc != precedence_assoc + && !used_assoc[s->content->number]; } /*-------------------------------. @@ -1148,28 +1175,27 @@ register_assoc (graphid i, graphid j) void print_precedence_warnings (void) { - int i; if (!prec_nodes) init_prec_nodes (); if (!used_assoc) init_assoc (); - for (i = 0; i < nsyms; ++i) + for (int i = 0; i < nsyms; ++i) { symbol *s = symbols[i]; if (s - && s->prec != 0 + && s->content->prec != 0 && !prec_nodes[i]->pred && !prec_nodes[i]->succ) { if (is_assoc_useless (s)) - complain (&s->prec_location, Wprecedence, + complain (&s->content->prec_location, Wprecedence, _("useless precedence and associativity for %s"), s->tag); - else if (s->assoc == precedence_assoc) - complain (&s->prec_location, Wprecedence, + else if (s->content->assoc == precedence_assoc) + complain (&s->content->prec_location, Wprecedence, _("useless precedence for %s"), s->tag); } else if (is_assoc_useless (s)) - complain (&s->prec_location, Wprecedence, + complain (&s->content->prec_location, Wprecedence, _("useless associativity for %s, use %%precedence"), s->tag); } free (used_assoc); diff --git a/contrib/tools/bison/src/symtab.h b/contrib/tools/bison/src/symtab.h index bcc749511c..63b5fba2b6 100644 --- a/contrib/tools/bison/src/symtab.h +++ b/contrib/tools/bison/src/symtab.h @@ -1,7 +1,7 @@ /* Definitions for symtab.c and callers, part of Bison. - Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2013 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2015, 2018 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -50,6 +50,7 @@ typedef int symbol_number; typedef struct symbol symbol; +typedef struct sym_content sym_content; /* Declaration status of a symbol. @@ -73,24 +74,45 @@ typedef enum declared, } status; -typedef enum code_props_type code_props_type; enum code_props_type { destructor = 0, printer = 1, }; +typedef enum code_props_type code_props_type; enum { CODE_PROPS_SIZE = 2 }; -/* When extending this structure, be sure to complete - symbol_check_alias_consistency. */ struct symbol { /** The key, name of the symbol. */ uniqstr tag; - /** The location of its first occurrence. */ + + /** The "defining" location. */ location location; + /** Whether \a location is about the first uses as left-hand side + symbol of a rule (true), or simply the first occurrence (e.g., + in a %type, or as a rhs symbol of a rule). The former type of + location is more natural in error messages. This Boolean helps + moving from location of the first occurrence to first use as + lhs. */ + bool location_of_lhs; + + /** Points to the other in the symbol-string pair for an alias. */ + symbol *alias; + + /** Whether this symbol is the alias of another or not. */ + bool is_alias; + + /** All the info about the pointed symbol is there. */ + sym_content *content; +}; + +struct sym_content +{ + symbol *symbol; + /** Its \c \%type. Beware that this is the type_name as was entered by the user, @@ -117,10 +139,6 @@ struct symbol assoc assoc; int user_token_number; - /* Points to the other in the symbol-string pair for an alias. - Special value USER_NUMBER_HAS_STRING_ALIAS in the symbol half of the - symbol-string pair for an alias. */ - symbol *alias; symbol_class class; status status; }; @@ -128,12 +146,6 @@ struct symbol /** Undefined user number. */ # define USER_NUMBER_UNDEFINED -1 -/* 'symbol->user_token_number == USER_NUMBER_HAS_STRING_ALIAS' means - this symbol has a literal string alias. For instance, '%token foo - "foo"' has '"foo"' numbered regularly, and 'foo' numbered as - USER_NUMBER_HAS_STRING_ALIAS. */ -# define USER_NUMBER_HAS_STRING_ALIAS -9991 - /* Undefined internal token number. */ # define NUMBER_UNDEFINED (-1) @@ -174,6 +186,12 @@ uniqstr symbol_id_get (symbol const *sym); */ void symbol_make_alias (symbol *sym, symbol *str, location loc); +/** + * This symbol is used as the lhs of a rule. Record this location + * as definition point, if not already done. + */ +void symbol_location_as_lhs_set (symbol *sym, location loc); + /** Set the \c type_name associated with \c sym. Do nothing if passed 0 as \c type_name. */ diff --git a/contrib/tools/bison/src/system.h b/contrib/tools/bison/src/system.h index 3267f2d24c..caca04421e 100644 --- a/contrib/tools/bison/src/system.h +++ b/contrib/tools/bison/src/system.h @@ -1,6 +1,7 @@ /* System-dependent definitions for Bison. - Copyright (C) 2000-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2007, 2009-2015, 2018 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/contrib/tools/bison/src/tables.c b/contrib/tools/bison/src/tables.c index f06cba86b9..7da2788a66 100644 --- a/contrib/tools/bison/src/tables.c +++ b/contrib/tools/bison/src/tables.c @@ -1,6 +1,6 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2006, 2009-2013 Free + Copyright (C) 1984, 1986, 1989, 1992, 2000-2006, 2009-2015, 2018 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -83,7 +83,7 @@ int nvectors; static base_number **froms; static base_number **tos; -static unsigned int **conflict_tos; +static unsigned **conflict_tos; static size_t *tally; static base_number *width; @@ -112,9 +112,9 @@ base_number *base = NULL; base_number base_ninf = 0; static base_number *pos = NULL; -static unsigned int *conflrow; -unsigned int *conflict_table; -unsigned int *conflict_list; +static unsigned *conflrow; +unsigned *conflict_table; +unsigned *conflict_list; int conflict_list_cnt; static int conflict_list_free; @@ -290,7 +290,7 @@ action_row (state *s) /* Do not use any default reduction if there is a shift for error */ - if (sym == errtoken->number) + if (sym == errtoken->content->number) nodefault = true; } @@ -300,7 +300,7 @@ action_row (state *s) for (i = 0; i < errp->num; i++) { symbol *sym = errp->symbols[i]; - actrow[sym->number] = ACTION_NUMBER_MINIMUM; + actrow[sym->content->number] = ACTION_NUMBER_MINIMUM; } /* Turn off default reductions where requested by the user. See @@ -394,7 +394,7 @@ save_row (state_number s) /* Allocate non defaulted actions. */ base_number *sp1 = froms[s] = xnmalloc (count, sizeof *sp1); base_number *sp2 = tos[s] = xnmalloc (count, sizeof *sp2); - unsigned int *sp3 = conflict_tos[s] = + unsigned *sp3 = conflict_tos[s] = nondeterministic_parser ? xnmalloc (count, sizeof *sp3) : NULL; /* Store non defaulted actions. */ @@ -670,7 +670,7 @@ pack_vector (vector_number vector) size_t t = tally[i]; base_number *from = froms[i]; base_number *to = tos[i]; - unsigned int *conflict_to = conflict_tos[i]; + unsigned *conflict_to = conflict_tos[i]; aver (t != 0); @@ -698,7 +698,7 @@ pack_vector (vector_number vector) if (ok) { - int loc; + int loc PACIFY_CC (= -1); int k; for (k = 0; k < t; k++) { diff --git a/contrib/tools/bison/src/tables.h b/contrib/tools/bison/src/tables.h index c631584d6e..0eb0e5cd23 100644 --- a/contrib/tools/bison/src/tables.h +++ b/contrib/tools/bison/src/tables.h @@ -1,6 +1,7 @@ /* Prepare the LALR and GLR parser tables. - Copyright (C) 2002, 2004, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -121,8 +122,8 @@ extern base_number *base; keep parser tables small. */ extern base_number base_ninf; -extern unsigned int *conflict_table; -extern unsigned int *conflict_list; +extern unsigned *conflict_table; +extern unsigned *conflict_list; extern int conflict_list_cnt; extern base_number *table; diff --git a/contrib/tools/bison/src/uniqstr.c b/contrib/tools/bison/src/uniqstr.c index 4446c0ed86..bfe1d17218 100644 --- a/contrib/tools/bison/src/uniqstr.c +++ b/contrib/tools/bison/src/uniqstr.c @@ -1,6 +1,7 @@ /* Keep a unique copy of strings. - Copyright (C) 2002-2005, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2005, 2009-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -77,7 +78,8 @@ uniqstr_vsprintf (char const *format, ...) void uniqstr_assert (char const *str) { - if (!hash_lookup (uniqstrs_table, str)) + uniqstr s = hash_lookup (uniqstrs_table, str); + if (!s || s != str) { error (0, 0, "not a uniqstr: %s", quotearg (str)); diff --git a/contrib/tools/bison/src/uniqstr.h b/contrib/tools/bison/src/uniqstr.h index 006c10f4ad..fe04cb7948 100644 --- a/contrib/tools/bison/src/uniqstr.h +++ b/contrib/tools/bison/src/uniqstr.h @@ -1,6 +1,7 @@ /* Keeping a unique copy of strings. - Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2008-2015, 2018 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -20,6 +21,8 @@ #ifndef UNIQSTR_H_ # define UNIQSTR_H_ +# include <stdio.h> + /*-----------------------------------------. | Pointers to unique copies of C strings. | `-----------------------------------------*/ @@ -33,7 +36,7 @@ uniqstr uniqstr_new (char const *str); strings, use UNIQSTR_CONCAT, which is a convenient wrapper around this function. */ uniqstr uniqstr_vsprintf (char const *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2); /* Two uniqstr values have the same value iff they are the same. */ # define UNIQSTR_EQ(Ustr1, Ustr2) (!!((Ustr1) == (Ustr2))) diff --git a/contrib/tools/bison/ya.make b/contrib/tools/bison/ya.make index 6f8aa959ae..050b34b8d5 100644 --- a/contrib/tools/bison/ya.make +++ b/contrib/tools/bison/ya.make @@ -3,6 +3,8 @@ PROGRAM(bison) LICENSE( + Bison-exception-2.2 AND + CC-BY-4.0 AND GPL-3.0-only AND GPL-3.0-or-later AND GPL-3.0-or-later WITH Bison-exception-2.2 @@ -10,9 +12,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(3.0) +VERSION(3.1) -ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.0.tar.gz) +ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.1.tar.gz) PEERDIR( contrib/tools/bison/lib |