diff --git a/.gitattributes b/.gitattributes index e8495d51..8b137891 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -ChangeLog merge=merge-changelog + diff --git a/Makefile.am b/Makefile.am index feb55681..5fae4ce5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,11 +88,13 @@ update-package-copyright-year: gen_start_date = 2012-01-16 .PHONY: gen-ChangeLog gen-ChangeLog: - $(AM_V_GEN)if test -d .git; then \ - $(top_srcdir)/build-aux/gitlog-to-changelog \ - --no-cluster \ - --amend=$(srcdir)/build-aux/git-log-fix \ - --since=$(gen_start_date) > $(distdir)/cl-t; \ - rm -f $(distdir)/ChangeLog; \ - mv $(distdir)/cl-t $(distdir)/ChangeLog; \ + $(AM_V_GEN)if test -d $(srcdir)/.git; then \ + $(top_srcdir)/build-aux/gitlog-to-changelog \ + --strip-tab \ + --strip-cherry-picked \ + --no-cluster \ + --amend=$(srcdir)/build-aux/git-log-fix \ + --since=$(gen_start_date) > $(distdir)/cl-t; \ + rm -f $(distdir)/ChangeLog; \ + mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/NEWS b/NEWS index 8f77271b..a3b2fa7c 100644 --- a/NEWS +++ b/NEWS @@ -73,7 +73,7 @@ Bison News ** Future changes: - The next major release will drop support for K&R C. + The next major release will drop support for generating parsers in K&R C. ** yacc.c: YYBACKUP works as expected. @@ -81,29 +81,52 @@ Bison News *** Location support is eliminated when not requested: - GLR parsers used to include location-related code even when - locations were not requested, and therefore not even usable. + GLR parsers used to include location-related code even when locations were + not requested, and therefore not even usable. *** __attribute__ is preserved: - __attribute__ is no longer disabled when __STRICT_ANSI__ is defined - (i.e., when -std is passed to GCC). + __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e., + when -std is passed to GCC). ** lalr1.java: several fixes: - The Java parser no longer throws ArrayIndexOutOfBoundsException if - the first token leads to a syntax error. Some minor clean ups. + The Java parser no longer throws ArrayIndexOutOfBoundsException if the + first token leads to a syntax error. Some minor clean ups. -** C++11 compatibility: +** Changes for C++: - C and C++ parsers use nullptr instead of 0 when __cplusplus is - 201103L or higher. +*** C++11 compatibility: -** C++ locations: + C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L + or higher. - The position and location constructors (and their initialize - methods) accept new arguments for line and column. Several issues - in the documentation were fixed. +*** Header guards + + The header files such as "parser.hh", "location.hh", etc. used a constant + name for preprocessor guards, for instance: + + #ifndef BISON_LOCATION_HH + # define BISON_LOCATION_HH + ... + #endif // !BISON_LOCATION_HH + + The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower + case characters are converted to upper case, and series of + non-alphanumerical characters are converted to an underscore. + + With "bison -o lang++/parser.cc", "location.hh" would now include: + + #ifndef YY_LANG_LOCATION_HH + # define YY_LANG_LOCATION_HH + ... + #endif // !YY_LANG_LOCATION_HH + +*** C++ locations: + + The position and location constructors (and their initialize methods) + accept new arguments for line and column. Several issues in the + documentation were fixed. ** liby is no longer asking for "rpl_fprintf" on some platforms. @@ -111,35 +134,37 @@ Bison News *** %printer is documented - The %printer directive, supported since at least Bison 1.50, is - finally documented. The %mfcalc example is extended to demonstrate - its use of printer. + The "%printer" directive, supported since at least Bison 1.50, is finally + documented. The "mfcalc" example is extended to demonstrate it. - The C++ parsers now also support yyoutput (as an alias to - debug_stream ()) for consistency with the C skeletons. + For consistency with the C skeletons, the C++ parsers now also support + "yyoutput" (as an alias to "debug_stream ()"). *** Several improvements have been made: - The layout for grammar excerpts was changed to a more compact - scheme. Named references are motivated. The description of the - automaton description file (*.output) is updated to the current - format. Incorrect index entries were fixed. Some other errors were - fixed. + The layout for grammar excerpts was changed to a more compact scheme. + Named references are motivated. The description of the automaton + description file (*.output) is updated to the current format. Incorrect + index entries were fixed. Some other errors were fixed. -** Changes to the build system: +** Building bison: + +*** Conflicting prototypes with recent/modified Flex. + + Fixed build problems with the current, unreleased, version of Flex, and + some modified versions of 2.5.35, which have modified function prototypes. *** Warnings during the build procedure have been eliminated. *** Several portability problems in the test suite have been fixed: - This includes warnings with some compilers, unexpected behavior of - tools such as diff, warning messages from the test suite itself, - etc. + This includes warnings with some compilers, unexpected behavior of tools + such as diff, warning messages from the test suite itself, etc. *** The install-pdf target work properly: - Running "make install-pdf" (or -dvi, -html, -info, and -ps) no - longer halts in the middle of its course. + Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer + halts in the middle of its course. * Changes in version 2.5 (2011-05-14): @@ -198,8 +223,8 @@ Bison News %define lr.type canonical-lr The default-reduction optimization in the parser tables can also be - adjusted using `%define lr.default-reductions'. For details on both - of these features, see the new section `Tuning LR' in the Bison + adjusted using "%define lr.default-reductions". For details on both + of these features, see the new section "Tuning LR" in the Bison manual. These features are experimental. More user feedback will help to @@ -215,7 +240,7 @@ Bison News cause error recovery to begin in a different syntactic context than the one in which the invalid token was encountered. Second, when verbose error messages are enabled (with %error-verbose or the - obsolete `#define YYERROR_VERBOSE'), the expected token list in the + obsolete "#define YYERROR_VERBOSE"), the expected token list in the syntax error message can both contain invalid tokens and omit valid tokens. @@ -240,7 +265,7 @@ Bison News %define parse.lac full - See the new section `LAC' in the Bison manual for additional + See the new section "LAC" in the Bison manual for additional details including a few caveats. LAC is an experimental feature. More user feedback will help to @@ -265,7 +290,7 @@ Bison News except that the manner in which Bison processes multiple definitions for the same NAME differs. Most importantly, -F and --force-define quietly override %define, but -D and --define do not. For further - details, see the section `Bison Options' in the Bison manual. + details, see the section "Bison Options" in the Bison manual. *** Variables renamed: @@ -323,8 +348,8 @@ Bison News Similarly to the C parsers, the C++ parsers now define the YYRHSLOC macro and use it in the default YYLLOC_DEFAULT. You are encouraged - to use it. If, for instance, your location structure has `first' - and `last' members, instead of + to use it. If, for instance, your location structure has "first" + and "last" members, instead of # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ @@ -395,7 +420,7 @@ Bison News ** Verbose syntax error message fixes: - When %error-verbose or the obsolete `#define YYERROR_VERBOSE' is + When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is specified, syntax error messages produced by the generated parser include the unexpected token as well as a list of expected tokens. The effect of %nonassoc on these verbose messages has been corrected @@ -406,7 +431,7 @@ Bison News in order to detect a syntax error. Because no unexpected token or expected tokens can then be reported, the verbose syntax error message described above is suppressed, and the parser instead - reports the simpler message, `syntax error'. Previously, this + reports the simpler message, "syntax error". Previously, this suppression was sometimes erroneously triggered by %nonassoc when a lookahead was actually required. Now verbose messages are suppressed only when all previous lookaheads have already been @@ -442,7 +467,7 @@ Bison News ** -W/--warnings fixes: -*** Bison now properly recognizes the `no-' versions of categories: +*** Bison now properly recognizes the "no-" versions of categories: For example, given the following command line, Bison now enables all warnings except warnings for incompatibilities with POSIX Yacc: @@ -453,7 +478,7 @@ Bison News Previously, conflict reports were independent of Bison's normal warning system. Now, Bison recognizes the warning categories - `conflicts-sr' and `conflicts-rr'. This change has important + "conflicts-sr" and "conflicts-rr". This change has important consequences for the -W and --warnings command-line options. For example: @@ -467,16 +492,16 @@ Bison News expected number of conflicts is not reported, so -W and --warning then have no effect on the conflict report. -*** The `none' category no longer disables a preceding `error': +*** The "none" category no longer disables a preceding "error": For example, for the following command line, Bison now reports errors instead of warnings for incompatibilities with POSIX Yacc: bison -Werror,none,yacc gram.y -*** The `none' category now disables all Bison warnings: +*** The "none" category now disables all Bison warnings: - Previously, the `none' category disabled only Bison warnings for + Previously, the "none" category disabled only Bison warnings for which there existed a specific -W/--warning category. However, given the following command line, Bison is now guaranteed to suppress all warnings: @@ -521,7 +546,7 @@ Bison News errors should no longer cause M4 to report a broken pipe on the affected platforms. -** `%prec IDENTIFIER' requires IDENTIFIER to be defined separately. +** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately. POSIX specifies that an error be reported for any identifier that does not appear on the LHS of a grammar rule and that is not defined by @@ -576,7 +601,7 @@ Bison News that YYFAIL will automatically invoke yyerror to report the syntax error so that you don't have to. However, there are several other subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from - inherent flaws when %error-verbose or `#define YYERROR_VERBOSE' is + inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is used. For a more detailed discussion, see: http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html @@ -587,7 +612,7 @@ Bison News Bison features compatible with it. Thus, during parser generation, Bison 2.5 will produce a warning whenever it discovers YYFAIL in a rule action. In a later release, YYFAIL will be disabled for - %error-verbose and `#define YYERROR_VERBOSE'. Eventually, YYFAIL will + %error-verbose and "#define YYERROR_VERBOSE". Eventually, YYFAIL will be removed altogether. There exists at least one case where Bison 2.5's YYFAIL warning will @@ -595,7 +620,7 @@ Bison News Bison-defined macros for the sole purpose of suppressing C preprocessor warnings (from GCC cpp's -Wunused-macros, for example). To avoid Bison's future warning, such YYFAIL uses can be moved to the - epilogue (that is, after the second `%%') in the Bison input file. In + epilogue (that is, after the second "%%") in the Bison input file. In this release (2.4.2), Bison already generates its own code to suppress C preprocessor warnings for YYFAIL, so projects can remove their own phony uses of YYFAIL if compatibility with Bison releases prior to @@ -623,7 +648,7 @@ Bison News exp: exp "+" exp { $$ = $1 + $3; }; - Some grammars still depend on this `feature'. Bison 2.4.1 restores + Some grammars still depend on this "feature". Bison 2.4.1 restores the previous behavior in the case of C output (specifically, when neither %language or %skeleton or equivalent command-line options are used) to leave more time for grammars depending on the old @@ -654,7 +679,7 @@ Bison News %define NAME "VALUE" -** The directive `%pure-parser' is now deprecated in favor of: +** The directive "%pure-parser" is now deprecated in favor of: %define api.pure @@ -664,15 +689,15 @@ Bison News ** Push Parsing Bison can now generate an LALR(1) parser in C with a push interface. That - is, instead of invoking `yyparse', which pulls tokens from `yylex', you can - push one token at a time to the parser using `yypush_parse', which will + is, instead of invoking "yyparse", which pulls tokens from "yylex", you can + push one token at a time to the parser using "yypush_parse", which will return to the caller after processing each token. By default, the push interface is disabled. Either of the following directives will enable it: %define api.push_pull "push" // Just push; does not require yylex. %define api.push_pull "both" // Push and pull; requires yylex. - See the new section `A Push Parser' in the Bison manual for details. + See the new section "A Push Parser" in the Bison manual for details. The current push parsing interface is experimental and may evolve. More user feedback will help to stabilize it. @@ -684,10 +709,10 @@ Bison News ** Java Bison can now generate an LALR(1) parser in Java. The skeleton is - `data/lalr1.java'. Consider using the new %language directive instead of + "data/lalr1.java". Consider using the new %language directive instead of %skeleton to select it. - See the new section `Java Parsers' in the Bison manual for details. + See the new section "Java Parsers" in the Bison manual for details. The current Java interface is experimental and may evolve. More user feedback will help to stabilize it. @@ -702,7 +727,7 @@ Bison News ** XML Automaton Report Bison can now generate an XML report of the LALR(1) automaton using the new - `--xml' option. The current XML schema is experimental and may evolve. More + "--xml" option. The current XML schema is experimental and may evolve. More user feedback will help to stabilize it. ** The grammar file may now specify the name of the parser header file using @@ -734,31 +759,31 @@ Bison News %define lr.keep_unreachable_states - See the %define entry in the `Bison Declaration Summary' in the Bison manual + See the %define entry in the "Bison Declaration Summary" in the Bison manual for further discussion. -** Lookahead Set Correction in the `.output' Report +** Lookahead Set Correction in the ".output" Report - When instructed to generate a `.output' file including lookahead sets - (using `--report=lookahead', for example), Bison now prints each reduction's + When instructed to generate a ".output" file including lookahead sets + (using "--report=lookahead", for example), Bison now prints each reduction's lookahead set only next to the associated state's one item that (1) is associated with the same rule as the reduction and (2) has its dot at the end of its RHS. Previously, Bison also erroneously printed the lookahead set next to all of the state's other items associated with the same rule. This - bug affected only the `.output' file and not the generated parser source + bug affected only the ".output" file and not the generated parser source code. -** --report-file=FILE is a new option to override the default `.output' file +** --report-file=FILE is a new option to override the default ".output" file name. -** The `=' that used to be required in the following directives is now +** The "=" that used to be required in the following directives is now deprecated: %file-prefix "parser" %name-prefix "c_" %output "parser.c" -** An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}' +** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}" Bison 2.3a provided a new set of directives as a more flexible alternative to the traditional Yacc prologue blocks. Those have now been consolidated into @@ -766,14 +791,14 @@ Bison News the purpose of the code and thus the location(s) where Bison should generate it: - 1. `%code {CODE}' replaces `%after-header {CODE}' - 2. `%code requires {CODE}' replaces `%start-header {CODE}' - 3. `%code provides {CODE}' replaces `%end-header {CODE}' - 4. `%code top {CODE}' replaces `%before-header {CODE}' + 1. "%code {CODE}" replaces "%after-header {CODE}" + 2. "%code requires {CODE}" replaces "%start-header {CODE}" + 3. "%code provides {CODE}" replaces "%end-header {CODE}" + 4. "%code top {CODE}" replaces "%before-header {CODE}" - See the %code entries in section `Bison Declaration Summary' in the Bison - manual for a summary of the new functionality. See the new section `Prologue - Alternatives' for a detailed discussion including the advantages of %code + See the %code entries in section "Bison Declaration Summary" in the Bison + manual for a summary of the new functionality. See the new section "Prologue + Alternatives" for a detailed discussion including the advantages of %code over the traditional Yacc prologues. The prologue alternatives are experimental. More user feedback will help to @@ -796,24 +821,24 @@ Bison News sometimes prove to be false alarms in existing grammars employing the Yacc constructs $0 or $-N (where N is some positive integer). - To enable these warnings, specify the option `--warnings=midrule-values' or - `-W', which is a synonym for `--warnings=all'. + To enable these warnings, specify the option "--warnings=midrule-values" or + "-W", which is a synonym for "--warnings=all". -** Default %destructor or %printer with `<*>' or `<>' +** Default %destructor or %printer with "<*>" or "<>" Bison now recognizes two separate kinds of default %destructor's and %printer's: - 1. Place `<*>' in a %destructor/%printer symbol list to define a default + 1. Place "<*>" in a %destructor/%printer symbol list to define a default %destructor/%printer for all grammar symbols for which you have formally declared semantic type tags. - 2. Place `<>' in a %destructor/%printer symbol list to define a default + 2. Place "<>" in a %destructor/%printer symbol list to define a default %destructor/%printer for all grammar symbols without declared semantic type tags. - Bison no longer supports the `%symbol-default' notation from Bison 2.3a. - `<*>' and `<>' combined achieve the same effect with one exception: Bison no + Bison no longer supports the "%symbol-default" notation from Bison 2.3a. + "<*>" and "<>" combined achieve the same effect with one exception: Bison no longer applies any %destructor to a mid-rule value if that mid-rule value is not actually ever referenced using either $$ or $n in a semantic action. @@ -821,11 +846,11 @@ Bison News feedback will help to determine whether they should become permanent features. - See the section `Freeing Discarded Symbols' in the Bison manual for further + See the section "Freeing Discarded Symbols" in the Bison manual for further details. ** %left, %right, and %nonassoc can now declare token numbers. This is required - by POSIX. However, see the end of section `Operator Precedence' in the Bison + by POSIX. However, see the end of section "Operator Precedence" in the Bison manual for a caveat concerning the treatment of literal strings. ** The nonfunctional --no-parser, -n, and %no-parser options have been @@ -859,17 +884,17 @@ Bison News %destructor { } guarantees that, when the parser discards any user-defined symbol that has a - semantic type tag other than `', it passes its semantic value to - `free'. However, when the parser discards a `STRING1' or a `string1', it - also prints its line number to `stdout'. It performs only the second - `%destructor' in this case, so it invokes `free' only once. + semantic type tag other than "", it passes its semantic value to + "free". However, when the parser discards a "STRING1" or a "string1", it + also prints its line number to "stdout". It performs only the second + "%destructor" in this case, so it invokes "free" only once. [Although we failed to mention this here in the 2.3a release, the default %destructor's and %printer's were experimental, and they were rewritten in future versions.] -** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with `-y', - `--yacc', or `%yacc'), Bison no longer generates #define statements for +** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y", + "--yacc", or "%yacc"), Bison no longer generates #define statements for associating token numbers with token names. Removing the #define statements helps to sanitize the global namespace during preprocessing, but POSIX Yacc requires them. Bison still generates an enum for token names in all cases. @@ -878,7 +903,7 @@ Bison News potentially incompatible with previous releases of Bison. As before, you declare prologue blocks in your grammar file with the - `%{ ... %}' syntax. To generate the pre-prologue, Bison concatenates all + "%{ ... %}" syntax. To generate the pre-prologue, Bison concatenates all prologue blocks that you've declared before the first %union. To generate the post-prologue, Bison concatenates all prologue blocks that you've declared after the first %union. @@ -907,7 +932,7 @@ Bison News * the code file before the contents of the header file. It does *not* * insert it into the header file. This is a good place to put * #include's that you want at the top of your code file. A common - * example is `#include "system.h"'. */ + * example is '#include "system.h"'. */ } %start-header { /* Bison inserts this block into both the header file and the code file. @@ -941,13 +966,13 @@ Bison News [Although we failed to mention this here in the 2.3a release, the prologue alternatives were experimental, and they were rewritten in future versions.] -** The option `--report=look-ahead' has been changed to `--report=lookahead'. +** The option "--report=look-ahead" has been changed to "--report=lookahead". The old spelling still works, but is not documented and may be removed in a future release. * Changes in version 2.3, 2006-06-05: -** GLR grammars should now use `YYRECOVERING ()' instead of `YYRECOVERING', +** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING", for compatibility with LALR(1) grammars. ** It is now documented that any definition of YYSTYPE or YYLTYPE should @@ -1013,7 +1038,7 @@ Bison News The %parse-params are available in the destructors (and the experimental printers) as per the documentation. -** Bison now warns if it finds a stray `$' or `@' in an action. +** Bison now warns if it finds a stray "$" or "@" in an action. ** %require "VERSION" This specifies that the grammar file depends on features implemented @@ -1022,16 +1047,16 @@ Bison News ** lalr1.cc: The token and value types are now class members. The tokens were defined as free form enums and cpp macros. YYSTYPE was defined as a free form union. They are now class members: - tokens are enumerations of the `yy::parser::token' struct, and the - semantic values have the `yy::parser::semantic_type' type. + tokens are enumerations of the "yy::parser::token" struct, and the + semantic values have the "yy::parser::semantic_type" type. If you do not want or can update to this scheme, the directive - `%define "global_tokens_and_yystype" "1"' triggers the global + '%define "global_tokens_and_yystype" "1"' triggers the global definition of tokens and YYSTYPE. This change is suitable both for previous releases of Bison, and this one. If you wish to update, then make sure older version of Bison will - fail using `%require "2.2"'. + fail using '%require "2.2"'. ** DJGPP support added. @@ -1099,10 +1124,10 @@ Bison News - A new directive "%expect-rr N" specifies the expected number of reduce/reduce conflicts in GLR parsers. - - %token numbers can now be hexadecimal integers, e.g., `%token FOO 0x12d'. + - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d". This is a GNU extension. - - The option `--report=lookahead' was changed to `--report=look-ahead'. + - The option "--report=lookahead" was changed to "--report=look-ahead". [However, this was changed back after 2.3.] - Experimental %destructor support has been added to lalr1.cc. @@ -1150,10 +1175,10 @@ Bison News This reverts to the behavior of Bison 1.33 and earlier, and improves compatibility with Yacc. - - `parse error' -> `syntax error' - Bison now uniformly uses the term `syntax error'; formerly, the code - and manual sometimes used the term `parse error' instead. POSIX - requires `syntax error' in diagnostics, and it was thought better to + - "parse error" -> "syntax error" + Bison now uniformly uses the term "syntax error"; formerly, the code + and manual sometimes used the term "parse error" instead. POSIX + requires "syntax error" in diagnostics, and it was thought better to be consistent. - The documentation now emphasizes that yylex and yyerror must be @@ -1166,7 +1191,7 @@ Bison News output as "foo\\bar.y". - Yacc command and library now available - The Bison distribution now installs a `yacc' command, as POSIX requires. + The Bison distribution now installs a "yacc" command, as POSIX requires. Also, Bison now installs a small library liby.a containing implementations of Yacc-compatible yyerror and main functions. This library is normally not useful, but POSIX requires it. @@ -1179,20 +1204,20 @@ Bison News ** Other compatibility issues - - %union directives can now have a tag before the `{', e.g., the - directive `%union foo {...}' now generates the C code - `typedef union foo { ... } YYSTYPE;'; this is for Yacc compatibility. - The default union tag is `YYSTYPE', for compatibility with Solaris 9 Yacc. - For consistency, YYLTYPE's struct tag is now `YYLTYPE' not `yyltype'. + - %union directives can now have a tag before the "{", e.g., the + directive "%union foo {...}" now generates the C code + "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility. + The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc. + For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype". This is for compatibility with both Yacc and Bison 1.35. - - `;' is output before the terminating `}' of an action, for + - ";" is output before the terminating "}" of an action, for compatibility with Bison 1.35. - Bison now uses a Yacc-style format for conflict reports, e.g., - `conflicts: 2 shift/reduce, 1 reduce/reduce'. + "conflicts: 2 shift/reduce, 1 reduce/reduce". - - `yystype' and `yyltype' are now obsolescent macros instead of being + - "yystype" and "yyltype" are now obsolescent macros instead of being typedefs or tags; they are no longer documented and are planned to be withdrawn in a future release. @@ -1200,13 +1225,13 @@ Bison News - GLR and inline Users of Bison have to decide how they handle the portability of the - C keyword `inline'. + C keyword "inline". - - `parsing stack overflow...' -> `parser stack overflow' - GLR parsers now report `parser stack overflow' as per the Bison manual. + - "parsing stack overflow..." -> "parser stack overflow" + GLR parsers now report "parser stack overflow" as per the Bison manual. ** Bison now warns if it detects conflicting outputs to the same file, - e.g., it generates a warning for `bison -d -o foo.h foo.y' since + e.g., it generates a warning for "bison -d -o foo.h foo.y" since that command outputs both code and header to foo.h. ** #line in output files @@ -1263,8 +1288,8 @@ Bison News ** Output Directory When not in Yacc compatibility mode, when the output file was not - specified, running `bison foo/bar.y' created `foo/bar.c'. It - now creates `bar.c'. + specified, running "bison foo/bar.y" created "foo/bar.c". It + now creates "bar.c". ** Undefined token The undefined token was systematically mapped to 2 which prevented @@ -1281,11 +1306,11 @@ Bison News will be mapped onto another number. ** Verbose error messages - They no longer report `..., expecting error or...' for states where + They no longer report "..., expecting error or..." for states where error recovery is possible. ** End token - Defaults to `$end' instead of `$'. + Defaults to "$end" instead of "$". ** Error recovery now conforms to documentation and to POSIX When a Bison-generated parser encounters a syntax error, it now pops @@ -1322,7 +1347,7 @@ Bison News Rules that can never be reduced because of conflicts are now reported. -** Incorrect `Token not used' +** Incorrect "Token not used" On a grammar such as %token useless useful @@ -1330,7 +1355,7 @@ Bison News exp: '0' %prec useful; where a token was used to set the precedence of the last rule, - bison reported both `useful' and `useless' as useless tokens. + bison reported both "useful" and "useless" as useless tokens. ** Revert the C++ namespace changes introduced in 1.31 as they caused too many portability hassles. @@ -1344,7 +1369,7 @@ Bison News ** Token end-of-file The token end of file may be specified by the user, in which case, the user symbol is used in the reports, the graphs, and the verbose - error messages instead of `$end', which remains being the default. + error messages instead of "$end", which remains being the default. For instance %token MYEOF 0 or @@ -1358,7 +1383,10 @@ Bison News Croatian, thanks to Denis Lackovic. ** Incorrect token definitions - When given `%token 'a' "A"', Bison used to output `#define 'a' 65'. + When given + %token 'a' "A" + bison used to output + #define 'a' 65 ** Token definitions as enums Tokens are output both as the traditional #define's, and, provided @@ -1370,7 +1398,7 @@ Bison News produces additional information: - itemset complete the core item sets with their closure - - lookahead [changed to `look-ahead' in 1.875e through 2.3, but changed back] + - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back] explicitly associate lookahead tokens to items - solved describe shift/reduce conflicts solving. @@ -1408,9 +1436,9 @@ Bison News ** File name clashes are detected $ bison foo.y -d -o foo.x - fatal error: header and parser would both be named `foo.x' + fatal error: header and parser would both be named "foo.x" -** A missing `;' at the end of a rule triggers a warning +** A missing ";" at the end of a rule triggers a warning In accordance with POSIX, and in agreement with other Yacc implementations, Bison will mandate this semicolon in the near future. This eases the implementation of a Bison parser of Bison @@ -1449,7 +1477,7 @@ Bison News GNU Gettext asserts 10 s/r conflicts, but there are 7. Now that Bison dies on incorrect %expectations, we fear there will be too many bug reports for Gettext, so _for the time being_, %expect - does not trigger an error when the input file is named `plural.y'. + does not trigger an error when the input file is named "plural.y". ** Use of alloca in parsers If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use @@ -1526,15 +1554,15 @@ Bison News New. ** --output - New, aliasing `--output-file'. + New, aliasing "--output-file". * Changes in version 1.30, 2001-10-26: -** `--defines' and `--graph' have now an optional argument which is the - output file name. `-d' and `-g' do not change; they do not take any +** "--defines" and "--graph" have now an optional argument which is the + output file name. "-d" and "-g" do not change; they do not take any argument. -** `%source_extension' and `%header_extension' are removed, failed +** "%source_extension" and "%header_extension" are removed, failed experiment. ** Portability fixes. @@ -1544,9 +1572,9 @@ Bison News ** The output file does not define const, as this caused problems when used with common autoconfiguration schemes. If you still use ancient compilers that lack const, compile with the equivalent of the C compiler option - `-Dconst='. Autoconf's AC_C_CONST macro provides one way to do this. + "-Dconst=". Autoconf's AC_C_CONST macro provides one way to do this. -** Added `-g' and `--graph'. +** Added "-g" and "--graph". ** The Bison manual is now distributed under the terms of the GNU FDL. @@ -1558,18 +1586,18 @@ Bison News ** Added the old Bison reference card. -** Added `--locations' and `%locations'. +** Added "--locations" and "%locations". -** Added `-S' and `--skeleton'. +** Added "-S" and "--skeleton". -** `%raw', `-r', `--raw' is disabled. +** "%raw", "-r", "--raw" is disabled. ** Special characters are escaped when output. This solves the problems of the #line lines with path names including backslashes. ** New directives. - `%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose', - `%debug', `%source_extension' and `%header_extension'. + "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose", + "%debug", "%source_extension" and "%header_extension". ** @$ Automatic location tracking. @@ -1686,4 +1714,5 @@ along with this program. If not, see . Local Variables: mode: outline +fill-column: 76 End: diff --git a/README-hacking b/README-hacking index f79a31a8..c4578fcc 100644 --- a/README-hacking +++ b/README-hacking @@ -15,25 +15,16 @@ First, if it is a large change, you must make sure they have signed the appropriate paperwork. Second, be sure to add their name and email address to THANKS. -** If a change fixes a test, mention the test in the ChangeLog entry. +** If a change fixes a test, mention the test in the commit message. ** Bug reports -If somebody reports a new bug, mention his name in the ChangeLog entry +If somebody reports a new bug, mention his name in the commit message and in the test case you write. Put him into THANKS. The correct response to most actual bugs is to write a new test case which demonstrates the bug. Then fix the bug, re-run the test suite, and check everything in. -** You may find it useful to install the git-merge-changelog merge driver: - - http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/git-merge-changelog.c - -When following the generic installation instructions there, keep in mind that -your clone of Bison's git repository already contains appropriate -.gitattributes files, and running Bison's bootstrap script will make the -necessary changes to .git/config. - * Hacking @@ -176,7 +167,7 @@ The autoconf files we use are currently: lib/m4sugar/m4sugar.m4 lib/m4sugar/foreach.m4 -These files don't change very often in autoconf, so it should be +These files don't change very often in Autoconf, so it should be relatively straight-forward to examine the differences in order to decide whether to update. @@ -196,6 +187,9 @@ release: - Build with -DGNULIB_POSIXCHECK. It suggests gnulib modules that can fix portability issues. +- Check with `make syntax-check' if there are issues diagnosed by + gnulib. + - run `make maintainer-check' which: - runs `valgrind -q bison' to run Bison under Valgrind. - runs the parsers under Valgrind. @@ -213,6 +207,9 @@ release: Bison's included XSLT style sheets with the output of --report=all and --graph. +- running `make maintainer-release-check' takes care of running + maintainer-check, maintainer-push-check and maintainer-xml-check. + - Change tests/atlocal/CFLAGS to add your preferred options. For instance, `-traditional' to check that the parsers are K&R. Note that it does not make sense for glr.c, which should be ANSI, @@ -260,16 +257,17 @@ occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac. The version number, *and* the date of the release (including for betas). -** Update ChangeLog -Should have an entry similar to `Version 1.49b.'. +** Mention the release name in a commit message +Should have an entry similar to `Version 2.3b.'. ** Tag the release -Before Bison will build with the right version number, you must tag the release -in git. Do this after all other changes. The command is similar to: +Before Bison will build with the right version number, you must tag +the release in git. Do this after all other changes. The command is +similar to: git tag -a v2.3b -The log message can be simply: +The commit message can be simply: Bison 2.3b diff --git a/THANKS b/THANKS index f2c5231a..9d0af4be 100644 --- a/THANKS +++ b/THANKS @@ -114,6 +114,7 @@ Tys Lefering gccbison@gmail.com Vin Shelton acs@alumni.princeton.edu W.C.A. Wijngaards wouter@NLnetLabs.nl Wayne Green wayne@infosavvy.com +Wei Song wsong83@gmail.com Wolfgang S. Kechel wolfgang.kechel@prs.de Wolfram Wagner ww@mpi-sb.mpg.de Wwp subscript@free.fr diff --git a/TODO b/TODO index d86d8d8b..21ef4b91 100644 --- a/TODO +++ b/TODO @@ -125,10 +125,6 @@ we do the same in yacc.c. The code bw glr.c and yacc.c is really alike, we can certainly factor some parts. -* Header guards - -From François: should we keep the directory part in the CPP guard? - * Yacc.c: CPP Macros diff --git a/bootstrap b/bootstrap index 16dc15c9..ce37a2c0 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-04-16.16; # UTC +scriptversion=2012-05-15.06; # UTC # Bootstrap this package from checked-out sources. @@ -36,6 +36,10 @@ nl=' LC_ALL=C export LC_ALL +# Ensure that CDPATH is not set. Otherwise, the output from cd +# would cause trouble in at least one use below. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + local_gl_dir=gl me=$0 @@ -126,7 +130,7 @@ extract_package_name=' p } ' -package=`sed -n "$extract_package_name" configure.ac` || exit +package=$(sed -n "$extract_package_name" configure.ac) || exit gnulib_name=lib$package build_aux=build-aux @@ -252,7 +256,7 @@ do usage exit;; --gnulib-srcdir=*) - GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;; + GNULIB_SRCDIR=${option#--gnulib-srcdir=};; --skip-po) SKIP_PO=t;; --force) @@ -303,7 +307,7 @@ insert_sorted_if_absent() { file=$1 str=$2 test -f $file || touch $file - echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \ + echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \ || { echo "$str" | sort_patterns - $file > $file.bak \ && mv $file.bak $file; } \ || exit 1 @@ -319,7 +323,7 @@ insert_vc_ignore() { # A .gitignore entry that does not start with '/' applies # recursively to subdirectories, so prepend '/' to every # .gitignore entry. - pattern=`echo "$pattern" | sed s,^,/,`;; + pattern=$(echo "$pattern" | sed s,^,/,);; esac insert_sorted_if_absent "$vc_ignore_file" "$pattern" } @@ -423,12 +427,28 @@ check_versions() { $use_git || continue fi # Honor $APP variables ($TAR, $AUTOCONF, etc.) - appvar=`echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_'` + appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_') test "$appvar" = TAR && appvar=AMTAR case $appvar in GZIP) ;; # Do not use $GZIP: it contains gzip options. *) eval "app=\${$appvar-$app}" ;; esac + + # Handle the still-experimental Automake-NG programs specially. + # They remain named as the mainstream Automake programs ("automake", + # and "aclocal") to avoid gratuitous incompatibilities with + # pre-existing usages (by, say, autoreconf, or custom autogen.sh + # scripts), but correctly identify themselves (as being part of + # "GNU automake-ng") when asked their version. + case $app in + automake-ng|aclocal-ng) + app=${app%-ng} + ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || { + echo "$me: Error: '$app' not found or not from Automake-NG" >&2 + ret=1 + continue + } ;; + esac if [ "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved # so we have to rely on $? rather than get_version. @@ -492,10 +512,8 @@ esac # When we can deduce that gnulib-tool will require patch, # and when patch is not already listed as a prerequisite, add it, too. -if test ! -d "$local_gl_dir" \ - || find "$local_gl_dir" -name '*.diff' -exec false {} +; then - : -else +if test -d "$local_gl_dir" \ + && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then case $buildreq in *patch*) ;; *) buildreq="patch - @@ -539,7 +557,7 @@ git_modules_config () { test -f .gitmodules && git config --file .gitmodules "$@" } -gnulib_path=`git_modules_config submodule.gnulib.path` +gnulib_path=$(git_modules_config submodule.gnulib.path) test -z "$gnulib_path" && gnulib_path=gnulib # Get gnulib files. @@ -612,10 +630,10 @@ download_po_files() { subdir=$1 domain=$2 echo "$me: getting translations into $subdir for $domain..." - cmd=`printf "$po_download_command_format" "$domain" "$subdir"` + cmd=$(printf "$po_download_command_format" "$domain" "$subdir") eval "$cmd" && return # Fallback to HTTP. - cmd=`printf "$po_download_command_format2" "$subdir" "$domain"` + cmd=$(printf "$po_download_command_format2" "$subdir" "$domain") eval "$cmd" } @@ -638,7 +656,7 @@ update_po_files() { && ls "$ref_po_dir"/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return - langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'` + langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g') test "$langs" = '*' && langs=x for po in $langs; do case $po in x) continue;; esac @@ -675,18 +693,18 @@ symlink_to_dir() # If the destination directory doesn't exist, create it. # This is required at least for "lib/uniwidth/cjk.h". - dst_dir=`dirname "$dst"` + dst_dir=$(dirname "$dst") if ! test -d "$dst_dir"; then mkdir -p "$dst_dir" # If we've just created a directory like lib/uniwidth, # tell version control system(s) it's ignorable. # FIXME: for now, this does only one level - parent=`dirname "$dst_dir"` + parent=$(dirname "$dst_dir") for dot_ig in x $vc_ignore; do test $dot_ig = x && continue ig=$parent/$dot_ig - insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'` + insert_vc_ignore $ig "${dst_dir##*/}" done fi @@ -710,10 +728,10 @@ symlink_to_dir() # so that broken tools aren't confused into skipping needed builds. See # . test -h "$dst" && - src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && - dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && + src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && + dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && test "$src_i" = "$dst_i" && - both_ls=`ls -dt "$src" "$dst"` && + both_ls=$(ls -dt "$src" "$dst") && test "X$both_ls" = "X$dst$nl$src" || { dot_dots= case $src in @@ -736,6 +754,22 @@ symlink_to_dir() } } +version_controlled_file() { + parent=$1 + file=$2 + if test -d .git; then + git rm -n "$file" > /dev/null 2>&1 + elif test -d .svn; then + svn log -r HEAD "$file" > /dev/null 2>&1 + elif test -d CVS; then + grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null | + grep '^/[^/]*/[0-9]' > /dev/null + else + echo "$me: no version control for $file?" >&2 + false + fi +} + # NOTE: we have to be careful to run both autopoint and libtoolize # before gnulib-tool, since gnulib-tool is likely to provide newer # versions of files "installed" by these two programs. @@ -748,37 +782,54 @@ with_gettext=yes grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ with_gettext=no -if test $with_gettext = yes; then - # Released autopoint has the tendency to install macros that have been - # obsoleted in current gnulib, so run this before gnulib-tool. - echo "$0: $AUTOPOINT --force" - $AUTOPOINT --force || exit -fi +if test $with_gettext = yes || test $use_libtool = 1; then -# Autoreconf runs aclocal before libtoolize, which causes spurious -# warnings if the initial aclocal is confused by the libtoolized -# (or worse out-of-date) macro directory. -if test $use_libtool = 1; then - echo "running: $LIBTOOLIZE --copy --install" - $LIBTOOLIZE --copy --install -fi + tempbase=.bootstrap$$ + trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15 -version_controlled_file() { - dir=$1 - file=$2 - found=no - if test -d CVS; then - grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | - grep '^/[^/]*/[0-9]' > /dev/null && found=yes - elif test -d .git; then - git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes - elif test -d .svn; then - svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes - else - echo "$me: no version control for $dir/$file?" >&2 + > $tempbase.0 > $tempbase.1 && + find . ! -type d -print | sort > $tempbase.0 || exit + + if test $with_gettext = yes; then + # Released autopoint has the tendency to install macros that have been + # obsoleted in current gnulib, so run this before gnulib-tool. + echo "$0: $AUTOPOINT --force" + $AUTOPOINT --force || exit fi - test $found = yes -} + + # Autoreconf runs aclocal before libtoolize, which causes spurious + # warnings if the initial aclocal is confused by the libtoolized + # (or worse out-of-date) macro directory. + # libtoolize 1.9b added the --install option; but we support back + # to libtoolize 1.5.22, where the install action was default. + if test $use_libtool = 1; then + install= + case $($LIBTOOLIZE --help) in + *--install*) install=--install ;; + esac + echo "running: $LIBTOOLIZE $install --copy" + $LIBTOOLIZE $install --copy + fi + + find . ! -type d -print | sort >$tempbase.1 + old_IFS=$IFS + IFS=$nl + for file in $(comm -13 $tempbase.0 $tempbase.1); do + IFS=$old_IFS + parent=${file%/*} + version_controlled_file "$parent" "$file" || { + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_vc_ignore "$ig" "${file##*/}" + done + } + done + IFS=$old_IFS + + rm -f $tempbase.0 $tempbase.1 + trap - 1 2 13 15 +fi # Import from gnulib. @@ -842,7 +893,7 @@ AUTOPOINT=true LIBTOOLIZE=true \ for file in $gnulib_extra_files; do case $file in */INSTALL) dst=INSTALL;; - build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; + build-aux/*) dst=$build_aux/${file#build-aux/};; *) dst=$file;; esac symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit @@ -863,7 +914,15 @@ if test $with_gettext = yes; then } ' po/Makevars.template >po/Makevars || exit 1 - cat $GNULIB_SRCDIR/build-aux/po/Makefile.in.in > po/Makefile.in.in || exit 1 + # If the 'gettext' module is in use, grab the latest Makefile.in.in. + # If only the 'gettext-h' module is in use, assume autopoint already + # put the correct version of this file into place. + case $gnulib_modules in + *gettext-h*) ;; + *gettext*) + cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1 + ;; + esac if test -d runtime-po; then # Similarly for runtime-po/Makevars, but not quite the same. diff --git a/bootstrap.conf b/bootstrap.conf index e6243a8d..237ae755 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -22,11 +22,12 @@ gnulib_modules=' gettext git-version-gen gitlog-to-changelog gpl-3.0 hash inttypes isnan javacomp-script javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr - mbswidth obstack perror pipe-posix progname + mbswidth obstack perror progname quote quotearg realloc-posix spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp unistd unistd-safer unlocked-io update-copyright unsetenv verify - warnings xalloc xalloc-die xstrndup + warnings + xalloc xalloc-die xmemdup0 xstrndup fprintf-posix printf-posix snprintf-posix sprintf-posix vsnprintf-posix vsprintf-posix diff --git a/build-aux/.gitignore b/build-aux/.gitignore index 3a663bf0..008e7452 100644 --- a/build-aux/.gitignore +++ b/build-aux/.gitignore @@ -4,6 +4,7 @@ /compile /config.guess /config.rpath +/config.rpath~ /config.sub /depcomp /gendocs.sh diff --git a/cfg.mk b/cfg.mk index ce755393..6ccef9c9 100644 --- a/cfg.mk +++ b/cfg.mk @@ -56,6 +56,7 @@ $(call exclude, \ bindtextdomain=^lib/main.c$$ \ program_name=^lib/main.c$$ \ prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \ + prohibit_always-defined_macros+=?|^lib/timevar.c$$ \ prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \ prohibit_always-defined_macros+=?|^tests/regression.at$$ \ prohibit_empty_lines_at_EOF=^src/parse-gram.h$$ \ diff --git a/configure.ac b/configure.ac index 763fe2a9..95a1b026 100644 --- a/configure.ac +++ b/configure.ac @@ -51,7 +51,7 @@ AM_INIT_AUTOMAKE([1.11.1 dist-xz nostdinc m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]], [gnu], [gnits])) AM_SILENT_RULES([yes]) -AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) +AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h]) # Checks for the compiler. AC_PROG_CC_STDC @@ -72,7 +72,7 @@ if test "$enable_gcc_warnings" = yes; then -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings' warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wstrict-prototypes' - warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant' + warn_cxx='-Wnoexcept' AC_LANG_PUSH([C]) for i in $warn_common $warn_c; do @@ -89,6 +89,8 @@ if test "$enable_gcc_warnings" = yes; then do gl_WARN_ADD([$i], [WARN_CXXFLAGS]) done + gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS], + [AC_LANG_PROGRAM([], [nullptr])]) gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS]) # Warnings for the test suite only. gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST]) @@ -116,9 +118,7 @@ AC_SUBST([YACC_LIBRARY]) # Checks for programs. AC_PROG_LEX -if test "$FLEX" != yes; then - AC_MSG_ERROR([Flex is required]) -fi +$LEX_IS_FLEX || AC_MSG_ERROR([Flex is required]) AC_PROG_YACC AC_PROG_RANLIB AC_PROG_GNU_M4 diff --git a/data/c.m4 b/data/c.m4 index e140ade8..0d30a496 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -17,6 +17,33 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + +# b4_tocpp(STRING) +# ---------------- +# Convert STRING into a valid C macro name. +m4_define([b4_tocpp], +[m4_toupper(m4_bpatsubst(m4_quote($1), [[^a-zA-Z0-9]+], [_]))]) + + +# b4_cpp_guard(FILE) +# ------------------ +# A valid C macro name to use as a CPP header guard for FILE. +m4_define([b4_cpp_guard], +[b4_tocpp(m4_defn([b4_prefix])/[$1])]) + + +# b4_cpp_guard_open(FILE) +# b4_cpp_guard_close(FILE) +# ------------------------ +# Open/close CPP inclusion guards for FILE. +m4_define([b4_cpp_guard_open], +[#ifndef b4_cpp_guard([$1]) +# define b4_cpp_guard([$1])]) + +m4_define([b4_cpp_guard_close], +[#endif b4_comment([!b4_cpp_guard([$1])])]) + + ## ---------------- ## ## Identification. ## ## ---------------- ## diff --git a/data/glr.c b/data/glr.c index e6a8e381..8f77aa61 100644 --- a/data/glr.c +++ b/data/glr.c @@ -810,9 +810,8 @@ static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__)); static void yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) { - yyGLRState* s; int i; - s = yyvsp[yylow0].yystate.yypred; + yyGLRState *s = yyvsp[yylow0].yystate.yypred; for (i = yylow0-1; i >= yylow1; i -= 1) { #if YYDEBUG @@ -1147,9 +1146,9 @@ yyexpandGLRStack (yyGLRStack* yystackp) { yyGLRStackItem* yynewItems; yyGLRStackItem* yyp0, *yyp1; - size_t yysize, yynewSize; + size_t yynewSize; size_t yyn; - yysize = yystackp->yynextFree - yystackp->yyitems; + size_t yysize = yystackp->yynextFree - yystackp->yyitems; if (YYMAXDEPTH - YYHEADROOM < yysize) yyMemoryExhausted (yystackp); yynewSize = 2*yysize; @@ -1172,7 +1171,7 @@ yyexpandGLRStack (yyGLRStack* yystackp) YYRELOC (yyp0, yyp1, yys0->yypred, yystate); if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL) yys1->yysemantics.yyfirstVal = - YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); + YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); } else { @@ -1464,8 +1463,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL) { - yyGLRState* yyp, *yysplit = yystackp->yysplitPoint; - yyp = yystackp->yytops.yystates[yyi]; + yyGLRState *yysplit = yystackp->yysplitPoint; + yyGLRState *yyp = yystackp->yytops.yystates[yyi]; while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn) { if (yyp->yylrState == yynewLRState && yyp->yypred == yys) @@ -1578,10 +1577,8 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) } else { - yySemanticOption** yyz0p; - yySemanticOption* yyz1; - yyz0p = &yys0->yysemantics.yyfirstVal; - yyz1 = yys1->yysemantics.yyfirstVal; + yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal; + yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal; while (YYID (yytrue)) { if (yyz1 == *yyz0p || yyz1 == YY_NULL) @@ -1663,14 +1660,9 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, YYSTYPE* yyvalp]b4_locuser_formals[) { yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; - int yynrhs; - int yychar_current; - YYSTYPE yylval_current;]b4_locations_if([ - YYLTYPE yylloc_current;])[ - YYRESULTTAG yyflag; - - yynrhs = yyrhsLength (yyopt->yyrule); - yyflag = yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); + int yynrhs = yyrhsLength (yyopt->yyrule); + YYRESULTTAG yyflag = + yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[); if (yyflag != yyok) { yyGLRState *yys; @@ -1683,18 +1675,20 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, if (yynrhs == 0) /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ - yychar_current = yychar; - yylval_current = yylval;]b4_locations_if([ - yylloc_current = yylloc;])[ - yychar = yyopt->yyrawchar; - yylval = yyopt->yyval;]b4_locations_if([ - yylloc = yyopt->yyloc;])[ - yyflag = yyuserAction (yyopt->yyrule, yynrhs, + { + int yychar_current = yychar; + YYSTYPE yylval_current = yylval;]b4_locations_if([ + YYLTYPE yylloc_current = yylloc;])[ + yychar = yyopt->yyrawchar; + yylval = yyopt->yyval;]b4_locations_if([ + yylloc = yyopt->yyloc;])[ + yyflag = yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, - yystackp, yyvalp]b4_locuser_args[); - yychar = yychar_current; - yylval = yylval_current;]b4_locations_if([ - yylloc = yylloc_current;])[ + yystackp, yyvalp]b4_locuser_args[); + yychar = yychar_current; + yylval = yylval_current;]b4_locations_if([ + yylloc = yylloc_current;])[ + } return yyflag; } @@ -1778,13 +1772,9 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[); if (!yys1->yyresolved) { - yySemanticOption *yyoption; yyGLRStackItem yyrhsloc[1 + YYMAXRHS]; int yynrhs; - int yychar_current; - YYSTYPE yylval_current; - YYLTYPE yylloc_current; - yyoption = yys1->yysemantics.yyfirstVal; + yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal; YYASSERT (yyoption != YY_NULL); yynrhs = yyrhsLength (yyoption->yyrule); if (yynrhs > 0) @@ -1810,16 +1800,18 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, yyGLRState *yyprevious = yyoption->yystate; yyrhsloc[0].yystate.yyloc = yyprevious->yyloc; } - yychar_current = yychar; - yylval_current = yylval; - yylloc_current = yylloc; - yychar = yyoption->yyrawchar; - yylval = yyoption->yyval; - yylloc = yyoption->yyloc; - YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); - yychar = yychar_current; - yylval = yylval_current; - yylloc = yylloc_current; + { + int yychar_current = yychar; + YYSTYPE yylval_current = yylval; + YYLTYPE yylloc_current = yylloc; + yychar = yyoption->yyrawchar; + yylval = yyoption->yyval; + yylloc = yyoption->yyloc; + YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs); + yychar = yychar_current; + yylval = yylval_current; + yylloc = yylloc_current; + } } } }]])[ diff --git a/data/lalr1.cc b/data/lalr1.cc index ef5e1cee..92f93c2c 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -126,8 +126,8 @@ b4_defines_if([], b4_locations_if([b4_percent_define_ifdef([[location_type]], [], [# Backward compatibility. - m4_define([b4_location_constructors]) - m4_include(b4_pkgdatadir/[location.cc])])]) + m4_define([b4_location_constructors]) + m4_include(b4_pkgdatadir/[location.cc])])]) m4_include(b4_pkgdatadir/[stack.hh]) b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) @@ -136,12 +136,15 @@ m4_changecom() m4_divert_push(0)dnl @output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) -dnl FIXME: This is wrong, we want computed header guards. [ +/** + ** \file ]b4_spec_defines_file[ + ** Define the ]b4_namespace_ref[::parser class. + */ + /* C++ LALR(1) parser skeleton written by Akim Demaille. */ -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H +]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_percent_code_get([[requires]])[ @@ -358,10 +361,9 @@ b4_public_types_define])[ /* Redirection for backward compatibility. */ # define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type #endif -]) -b4_percent_code_get([[provides]])[]dnl - -[#endif /* ! defined PARSER_HEADER_H */] +])[ +]b4_percent_code_get([[provides]])[ +]b4_cpp_guard_close([b4_spec_defines_file]) @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++]) b4_percent_code_get([[top]])[]dnl diff --git a/data/location.cc b/data/location.cc index e750779c..976fc34b 100644 --- a/data/location.cc +++ b/data/location.cc @@ -25,12 +25,11 @@ m4_divert_push(0)dnl b4_copyright([Positions for Bison parsers in C++])[ /** - ** \file position.hh + ** \file ]b4_dir_prefix[position.hh ** Define the ]b4_namespace_ref[::position class. */ -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH +]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[ # include # include @@ -150,17 +149,16 @@ b4_copyright([Positions for Bison parsers in C++])[ } ]b4_namespace_close[ -#endif // not BISON_POSITION_HH] +]b4_cpp_guard_close([b4_dir_prefix[]position.hh]) @output(b4_dir_prefix[]location.hh@)@ b4_copyright([Locations for Bison parsers in C++])[ /** - ** \file location.hh + ** \file ]b4_dir_prefix[location.hh ** Define the ]b4_namespace_ref[::location class. */ -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH +]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[ # include # include @@ -296,7 +294,7 @@ b4_copyright([Locations for Bison parsers in C++])[ ]b4_namespace_close[ -#endif // not BISON_LOCATION_HH] +]b4_cpp_guard_close([b4_dir_prefix[]location.hh]) m4_divert_pop(0) m4_popdef([b4_copyright_years])dnl m4_changecom([#]) diff --git a/data/stack.hh b/data/stack.hh index dcd0832b..cea7b41a 100644 --- a/data/stack.hh +++ b/data/stack.hh @@ -24,10 +24,14 @@ m4_divert_push(0)dnl @output(b4_dir_prefix[]stack.hh@)@ b4_copyright([Stack handling for Bison parsers in C++])[ -#ifndef BISON_STACK_HH -# define BISON_STACK_HH +/** + ** \file ]b4_dir_prefix[stack.hh + ** Define the ]b4_namespace_ref[::stack class. + */ -#include +]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[ + +# include ]b4_namespace_open[ template > @@ -109,8 +113,8 @@ b4_copyright([Stack handling for Bison parsers in C++])[ { public: slice (const S& stack, unsigned int range) - : stack_ (stack), - range_ (range) + : stack_ (stack) + , range_ (range) { } @@ -127,8 +131,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[ }; ]b4_namespace_close[ -#endif // not BISON_STACK_HH[]dnl -] +]b4_cpp_guard_close([b4_dir_prefix[]stack.hh]) m4_divert_pop(0) m4_popdef([b4_copyright_years])dnl m4_changecom([#]) diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 7740c775..3f24b9ac 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -7914,7 +7914,7 @@ calls @code{yyerror} and then returns 2. Because Bison parsers have growing stacks, hitting the upper limit usually results from using a right recursion instead of a left -recursion, @xref{Recursion, ,Recursive Rules}. +recursion, see @ref{Recursion, ,Recursive Rules}. @vindex YYMAXDEPTH By defining the macro @code{YYMAXDEPTH}, you can control how deep the @@ -11105,8 +11105,8 @@ My parser returns with error with a @samp{memory exhausted} message. What can I do? @end quotation -This question is already addressed elsewhere, @xref{Recursion, -,Recursive Rules}. +This question is already addressed elsewhere, see @ref{Recursion, ,Recursive +Rules}. @node How Can I Reset the Parser @section How Can I Reset the Parser diff --git a/gnulib b/gnulib index 1a0e0aef..338dd5d4 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 1a0e0aefd4b1fbef0c6e5d990bc01499fd153a0d +Subproject commit 338dd5d4362fdf5fb29b843d4d8a8f845bc750de diff --git a/lib/.gitignore b/lib/.gitignore index c1c7c06c..5eec7430 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -22,6 +22,7 @@ /c-ctype.h /c-strcase.h /c-strcasecmp.c +/c-strcaseeq.h /c-strncasecmp.c /calloc.c /charset.alias @@ -29,10 +30,14 @@ /cloexec.h /close-hook.c /close-hook.h +/close-stream.c +/close-stream.h /close.c +/closeout.c +/closeout.h /config.charset /config.h -/config.hin +/config.in.h /configmake.h /dirname-lgpl.c /dirname.c @@ -53,19 +58,25 @@ /fcntl.c /fcntl.h /fcntl.in.h +/fd-hook.c +/fd-hook.h /fd-safer-flag.c /fd-safer.c /float+.h +/float.c /float.h /float.in.h /fopen-safer.c /fopen.c +/fpending.c +/fpending.h /fprintf.c /fpucw.h /frexp.c /frexpl.c /fseterr.c /fseterr.h +/fstat.c /getdtablesize.c /getopt.c /getopt.h @@ -88,6 +99,7 @@ /isnanl-nolibm.h /isnanl.c /iswblank.c +/itold.c /ldexpl.c /localcharset.c /localcharset.h @@ -105,14 +117,18 @@ /mbuiter.h /memchr.c /memchr.valgrind +/msvc-inval.c +/msvc-inval.h +/msvc-nothrow.c +/msvc-nothrow.h /nonblocking.c /nonblocking.h /obstack.c /obstack.h /open.c +/pathmax.h /perror.c /pipe-safer.c -/pipe.c /pipe2-safer.c /pipe2.c /printf-args.c @@ -124,10 +140,13 @@ /printf-parse.c /printf-parse.h /printf.c +/progname.c +/progname.h /quote.c /quote.h /quotearg.c /quotearg.h +/raise.c /rawmemchr.c /rawmemchr.valgrind /realloc.c @@ -185,7 +204,10 @@ /strchrnul.valgrind /strdup.c /streq.h +/strerror-override.c +/strerror-override.h /strerror.c +/strerror_r.c /string.h /string.in.h /stripslash.c @@ -205,6 +227,7 @@ /sys_stat.in.h /sys_wait.h /sys_wait.in.h +/sysexits.in.h /time.h /time.in.h /unistd--.h @@ -236,33 +259,12 @@ /wctype.in.h /wcwidth.c /xalloc-die.c +/xalloc-oversized.h /xalloc.h /xmalloc.c /xsize.h /xstrndup.c /xstrndup.h -/c-strcaseeq.h -/fd-hook.c -/fd-hook.h -/float.c -/fstat.c -/itold.c -/msvc-inval.c -/msvc-inval.h -/msvc-nothrow.c -/msvc-nothrow.h -/pathmax.h -/raise.c -/strerror-override.c -/strerror-override.h -/strerror_r.c -/xalloc-oversized.h -/close-stream.c -/close-stream.h -/closeout.c -/closeout.h -/fpending.c -/fpending.h -/sysexits.in.h -/progname.c -/progname.h +/xmemdup0.c +/xmemdup0.h +/sys_types.in.h diff --git a/m4/.gitignore b/m4/.gitignore index 90e5ae15..990b1a57 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -38,6 +38,7 @@ /getdtablesize.m4 /getopt.m4 /gettext.m4 +/glibc2.m4 /glibc21.m4 /gnulib-cache.m4 /gnulib-common.m4 @@ -47,7 +48,12 @@ /iconv.m4 /include_next.m4 /inline.m4 +/intdiv0.m4 +/intl.m4 +/intl.m4~ +/intldir.m4 /intlmacosx.m4 +/intmax.m4 /intmax_t.m4 /inttypes-pri.m4 /inttypes.m4 @@ -61,6 +67,7 @@ /javacomp.m4 /javaexec.m4 /largefile.m4 +/lcmessage.m4 /ldexp.m4 /ldexpl.m4 /lib-ld.m4 @@ -71,6 +78,7 @@ /locale-fr.m4 /locale-ja.m4 /locale-zh.m4 +/lock.m4 /longlong.m4 /malloc.m4 /math_h.m4 @@ -88,12 +96,13 @@ /multiarch.m4 /nls.m4 /nocrash.m4 +/off_t.m4 /open.m4 /pathmax.m4 /perror.m4 -/pipe.m4 /pipe2.m4 /po.m4 +/po.m4~ /posix_spawn.m4 /printf-frexp.m4 /printf-frexpl.m4 @@ -144,14 +153,18 @@ /sys_ioctl_h.m4 /sys_socket_h.m4 /sys_stat_h.m4 +/sys_types_h.m4 /sys_wait_h.m4 +/sysexits.m4 /threadlib.m4 /time_h.m4 +/uintmax_t.m4 /unistd-safer.m4 /unistd_h.m4 /unlocked-io.m4 /vasnprintf.m4 /vfprintf-posix.m4 +/visibility.m4 /vsnprintf-posix.m4 /vsnprintf.m4 /vsprintf-posix.m4 @@ -167,4 +180,3 @@ /xalloc.m4 /xsize.m4 /xstrndup.m4 -/sysexits.m4 diff --git a/m4/flex.m4 b/m4/flex.m4 index 2073a0dc..984c5143 100644 --- a/m4/flex.m4 +++ b/m4/flex.m4 @@ -1,4 +1,4 @@ -# flex.m4 serial 1 +# flex.m4 serial 2 # Copyright (C) 2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -24,7 +24,7 @@ fi]) # and whether Lex declares yytext as a char * by default. m4_define([_AC_PROG_LEX_YYTEXT_DECL], [AC_CACHE_CHECK([whether lex is flex], - [ac_cv_prog_flex], + [ac_cv_prog_lex_is_flex], [cat >conftest.l <<_ACEOF[ %option debug nodefault noinput nounput noyywrap never-interactive %x SC_CONF_TEST @@ -32,15 +32,13 @@ m4_define([_AC_PROG_LEX_YYTEXT_DECL], a { BEGIN SC_CONF_TEST; } ]_ACEOF if _AC_DO_VAR([LEX conftest.l]); then - ac_cv_prog_flex=yes + ac_cv_prog_lex_is_flex=yes else - ac_cv_prog_flex=no + ac_cv_prog_lex_is_flex=no fi ]) -FLEX= -if test $ac_cv_prog_flex = yes; then - AC_SUBST([FLEX], [yes])dnl -fi +AC_SUBST([LEX_IS_FLEX], + [`test "$ac_cv_prog_lex_is_flex" = yes && echo true || echo false`])dnl cat >conftest.l <<_ACEOF[ %% diff --git a/po/.gitignore b/po/.gitignore index 79594c04..940ce9ef 100644 --- a/po/.gitignore +++ b/po/.gitignore @@ -6,6 +6,7 @@ /Makefile /Makefile.in /Makefile.in.in +/Makefile.in.in~ /Makevars /Makevars.template /POTFILES diff --git a/runtime-po/.gitignore b/runtime-po/.gitignore index 44ff8963..8675428f 100644 --- a/runtime-po/.gitignore +++ b/runtime-po/.gitignore @@ -6,6 +6,7 @@ /Makefile /Makefile.in /Makefile.in.in +/Makefile.in.in~ /Makevars /Makevars.template /POTFILES diff --git a/src/flex-scanner.h b/src/flex-scanner.h index 572464af..cf2b6b9e 100644 --- a/src/flex-scanner.h +++ b/src/flex-scanner.h @@ -21,7 +21,20 @@ # error "FLEX_PREFIX not defined" #endif +/* Whether this version of Flex is (strictly) greater than + Major.Minor.Subminor. */ +#define FLEX_VERSION_GT(Major, Minor, Subminor) \ + (defined YY_FLEX_MAJOR_VERSION \ + && (Major < YY_FLEX_MAJOR_VERSION \ + || (Major == YY_FLEX_MAJOR_VERSION \ + && (defined YY_FLEX_MINOR_VERSION \ + && (Minor < YY_FLEX_MINOR_VERSION \ + || (Minor == YY_FLEX_MINOR_VERSION \ + && defined YY_FLEX_SUBMINOR_VERSION \ + && Subminor < YY_FLEX_SUBMINOR_VERSION)))))) + /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ +#if ! FLEX_VERSION_GT (2, 5, 31) int FLEX_PREFIX (get_lineno) (void); FILE *FLEX_PREFIX (get_in) (void); FILE *FLEX_PREFIX (get_out) (void); @@ -33,6 +46,7 @@ void FLEX_PREFIX (set_out) (FILE *); int FLEX_PREFIX (get_debug) (void); void FLEX_PREFIX (set_debug) (int); int FLEX_PREFIX (lex_destroy) (void); +#endif #define last_string FLEX_PREFIX (last_string) @@ -51,12 +65,7 @@ int FLEX_PREFIX (lex_destroy) (void); versions according to the Flex manual) leak memory if yylex_destroy is not invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give an implementation here that at least appears to work with Flex 2.5.4. */ -#if !defined YY_FLEX_MAJOR_VERSION || YY_FLEX_MAJOR_VERSION < 2 \ - || (YY_FLEX_MAJOR_VERSION == 2 \ - && (!defined YY_FLEX_MINOR_VERSION || YY_FLEX_MINOR_VERSION < 5 \ - || (YY_FLEX_MINOR_VERSION == 5 \ - && (!defined YY_FLEX_SUBMINOR_VERSION \ - || YY_FLEX_SUBMINOR_VERSION < 9)))) +#if ! FLEX_VERSION_GT (2, 5, 9) # define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER) #endif @@ -73,16 +82,16 @@ int FLEX_PREFIX (lex_destroy) (void); static struct obstack obstack_for_string; -#define STRING_GROW \ +# define STRING_GROW \ obstack_grow (&obstack_for_string, yytext, yyleng) -#define STRING_FINISH \ +# define STRING_FINISH \ do { \ obstack_1grow (&obstack_for_string, '\0'); \ last_string = obstack_finish (&obstack_for_string); \ } while (0) -#define STRING_FREE \ +# define STRING_FREE \ obstack_free (&obstack_for_string, last_string) #endif diff --git a/src/getargs.c b/src/getargs.c index 06e6e972..8a3714e2 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -603,13 +603,19 @@ getargs (int argc, char *argv[]) /* Here, the -d and --defines options are differentiated. */ defines_flag = true; if (optarg) - spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_defines_file); + spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'g': graph_flag = true; if (optarg) - spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_graph_file); + spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'h': @@ -648,7 +654,10 @@ getargs (int argc, char *argv[]) case 'x': xml_flag = true; if (optarg) - spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_xml_file); + spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'y': @@ -669,6 +678,7 @@ getargs (int argc, char *argv[]) exit (EXIT_SUCCESS); case REPORT_FILE_OPTION: + free (spec_verbose_file); spec_verbose_file = xstrdup (AS_FILE_NAME (optarg)); break; diff --git a/src/parse-gram.y b/src/parse-gram.y index 532349bb..74eb4aee 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -32,6 +32,7 @@ #include "symlist.h" #include "scan-gram.h" #include "scan-code.h" +#include "xmemdup0.h" #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) static YYLTYPE lloc_default (YYLTYPE const *, int); @@ -353,7 +354,7 @@ prologue_declaration: xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); if (dir_length > 0) { - strncpy (skeleton_build, current_file, dir_length); + memcpy (skeleton_build, current_file, dir_length); skeleton_build[dir_length++] = '/'; } strcpy (skeleton_build + dir_length, skeleton_user); @@ -775,17 +776,7 @@ add_param (param_type type, char *decl, location loc) complain_at (loc, _("missing identifier in parameter declaration")); else { - char *name; - size_t name_len; - - for (name_len = 1; - memchr (alphanum, name_start[name_len], sizeof alphanum); - name_len++) - continue; - - name = xmalloc (name_len + 1); - memcpy (name, name_start, name_len); - name[name_len] = '\0'; + char *name = xmemdup0 (name_start, strspn (name_start, alphanum)); if (type & param_lex) muscle_pair_list_grow ("lex_param", decl, name); if (type & param_parse) diff --git a/src/scan-skel.l b/src/scan-skel.l index e15294a1..284a1207 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -77,7 +77,6 @@ static void fail_for_invalid_at (char const *at); "@oline@" fprintf (yyout, "%d", out_lineno + 1); "@ofile@" QPUTS (outname); -"@dir_prefix@" QPUTS (dir_prefix); @[a-z_]+"(" { yytext[yyleng-1] = '\0'; diff --git a/tests/local.at b/tests/local.at index 02e45597..c71a2a96 100644 --- a/tests/local.at +++ b/tests/local.at @@ -37,6 +37,33 @@ printf "$count\n";' $1], [0], [$3 ])]) +# AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES +# ------------------------------------------------ +# Don't interfere with caller's files. +m4_divert_text([PREPARE_TESTS], +[at_save_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak + done +} + +at_restore_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f at-bison-check-$at_save_file.bak || + mv at-bison-check-$at_save_file.bak $at_save_file + done +} +]) + +m4_define([AT_SAVE_SPECIAL_FILES], [at_save_special_files]) +m4_define([AT_RESTORE_SPECIAL_FILES], [at_restore_special_files]) + + + ## ------------------------------- ## ## Macros decoding Bison options. ## ## ------------------------------- ## @@ -288,10 +315,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # are added after the grammar file name, so skip these checks # in that case. if test -z "${POSIXLY_CORRECT+set}"; then - # Don't interfere with caller's files. - if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi - if test -f experr; then mv experr at-bison-check-experr.bak; fi - if test -f expout; then mv expout at-bison-check-expout.bak; fi + ]AT_SAVE_SPECIAL_FILES[ # To avoid expanding it repeatedly, store specified stdout. ]AT_DATA([expout], [$3])[ @@ -343,16 +367,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \ -Werror]], [[0]], [expout])[ - # Restore caller's files. - if test -f at-bison-check-expout.bak; then - mv at-bison-check-expout.bak expout - fi - if test -f at-bison-check-experr.bak; then - mv at-bison-check-experr.bak experr - fi - if test -f at-bison-check-stderr.bak; then - mv at-bison-check-stderr.bak stderr - fi + ]AT_RESTORE_SPECIAL_FILES[ fi ]]) ]) @@ -363,8 +378,9 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # defined. It doesn't make sense to invoke this macro if Bison is expected to # have a non-zero exit status. m4_define([AT_BISON_CHECK_XML], -[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then - mkdir xml-tests] +[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then] + AT_SAVE_SPECIAL_FILES + [mkdir xml-tests] m4_pushdef([AT_BISON_ARGS], [m4_bpatsubsts([[$1]], [--report(-file)?=[^][ ]*], [], @@ -386,8 +402,9 @@ m4_define([AT_BISON_CHECK_XML], AT_CHECK([[$XSLTPROC \ `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \ xml-tests/test.xml]], [[0]], [expout]) - [rm -rf xml-tests expout -fi]]) + [rm -rf xml-tests expout] + AT_RESTORE_SPECIAL_FILES +[fi]]) # AT_QUELL_VALGRIND # ----------------- diff --git a/tests/regression.at b/tests/regression.at index 41a2939d..ff798a87 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -1258,10 +1258,12 @@ AT_SETUP([[parse-gram.y: LALR = IELR]]) # output files have the same name. [cp $abs_top_srcdir/src/parse-gram.y input.y] AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]]) -[mv input.c expout] +[mv input.c lalr.c] +AT_CAPTURE_FILE([lalr.c]) AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]]) [mv input.c ielr.c] -AT_CHECK([[cat ielr.c]], [[0]], [[expout]]) +AT_CAPTURE_FILE([ielr.c]) +AT_CHECK([[diff lalr.c ielr.c]], [[0]]) AT_CLEANUP