From: Akim Demaille Date: Mon, 3 Dec 2012 15:27:23 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~265 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=064e42b0aca1db0ca84b06b01cac5a40f3016591;p=platform%2Fupstream%2Fbison.git Merge remote-tracking branch 'origin/maint' * origin/maint: parser: accept #line NUM m4: use a safer pattern to enable/disable output tests: beware of gnulib's need for config.h gnulib: update yacc.c, glr.c: check and fix the display of locations formatting changes glr.c: remove stray macro Conflicts: data/c.m4 data/glr.cc data/lalr1.cc data/lalr1.java data/location.cc data/stack.hh data/yacc.c src/scan-gram.l --- 064e42b0aca1db0ca84b06b01cac5a40f3016591 diff --cc data/c.m4 index 91126a8,dc3d303..6c2f552 --- a/data/c.m4 +++ b/data/c.m4 @@@ -610,14 -655,40 +610,40 @@@ m4_define([b4_yy_location_print_define] #ifndef YY_LOCATION_PRINT # if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL + + /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ + + __attribute__((__unused__)) -]b4_c_function_def([yy_location_print_], ++]b4_function_define([yy_location_print_], + [static unsigned], + [[FILE *yyo], [yyo]], + [[YYLTYPE const * const yylocp], [yylocp]])[ + { + unsigned res = 0; + int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; + if (0 <= yylocp->first_line) + { + res += fprintf (yyo, "%d", yylocp->first_line); + if (0 <= yylocp->first_column) + res += fprintf (yyo, ".%d", yylocp->first_column); + } + if (0 <= yylocp->last_line) + { + if (yylocp->first_line < yylocp->last_line) + { + res += fprintf (yyo, "-%d", yylocp->last_line); + if (0 <= end_col) + res += fprintf (yyo, ".%d", end_col); + } + else if (0 <= end_col && yylocp->first_column < end_col) + res += fprintf (yyo, "-%d", end_col); + } + return res; + } + -# define YY_LOCATION_PRINT(File, Loc) \ +# define YY_LOCATION_PRINT(File, Loc) \ - do { \ - fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \ - if ((Loc).first_line < (Loc).last_line) \ - fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \ - else if ((Loc).first_column < (Loc).last_column - 1) \ - fprintf (File, "-%d", (Loc).last_column - 1); \ - } while (0) + yy_location_print_ (File, &(Loc)) + # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif diff --cc data/glr.cc index 8841f10,49b4fa1..3cecfd8 --- a/data/glr.cc +++ b/data/glr.cc @@@ -304,32 -342,5 +304,31 @@@ b4_percent_define_flag_if([[global_toke ]b4_namespace_close[ ]b4_percent_code_get([[provides]])[ +]m4_popdef([b4_parse_param])dnl +]) + +b4_defines_if( +[m4_changecom()dnl +m4_divert_push(0)dnl +@output(b4_spec_defines_file@)@ +b4_copyright([Skeleton interface for Bison GLR parsers in C++], + [2002-2012])[ + +/* C++ GLR parser skeleton written by Akim Demaille. */ + +]b4_cpp_guard_open([b4_spec_defines_file])[ +]b4_shared_declarations[ ]b4_cpp_guard_close([b4_spec_defines_file])[ - ]m4_divert_pop(0) - m4_changecom[#])]) -]b4_output_end() ++]b4_output_end()]) + +# Let glr.c (and b4_shared_declarations) believe that the user +# arguments include the parser itself. +m4_ifset([b4_parse_param], +[m4_pushdef([b4_parse_param], + [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],] +m4_defn([b4_parse_param]))], +[m4_pushdef([b4_parse_param], + [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]]) +]) +m4_include(b4_pkgdatadir/[glr.c]) +m4_popdef([b4_parse_param]) diff --cc data/lalr1.cc index 34eef13,237b246..fa3a48d --- a/data/lalr1.cc +++ b/data/lalr1.cc @@@ -333,32 -261,14 +333,31 @@@ b4_public_types_define]) #endif ])[ ]b4_percent_code_get([[provides]])[ +]]) + +# We do want M4 expansion after # for CPP macros. +m4_changecom() +b4_defines_if( +[m4_divert_push(0)dnl +@output(b4_spec_defines_file@)@ +b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) +[ +/** + ** \file ]b4_spec_defines_file[ + ** Define the ]b4_namespace_ref[::parser class. + */ + +/* C++ LALR(1) parser skeleton written by Akim Demaille. */ + +]b4_cpp_guard_open([b4_spec_defines_file])[ +]b4_shared_declarations[ ]b4_cpp_guard_close([b4_spec_defines_file]) - m4_divert_pop(0)dnl + b4_output_end() ]) - m4_divert_push(0)dnl - @output(b4_parser_file_name@)@ + b4_output_begin([b4_parser_file_name]) -b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], - [2002-2012]) +b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++]) b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [ @@@ -1138,8 -1110,34 +1137,10 @@@ b4_error_verbose_if([state_type yystate } #endif // ]b4_api_PREFIX[DEBUG - /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ - ]b4_parser_class_name[::token_number_type - ]b4_parser_class_name[::yytranslate_ (int t) - { - static - const token_number_type - translate_table[] = - { - ]b4_translate[ - }; - if ((unsigned int) t <= yyuser_token_number_max_) - return translate_table[t]; - else - return yyundef_token_; - } - - const int ]b4_parser_class_name[::yyeof_ = 0; - const int ]b4_parser_class_name[::yylast_ = ]b4_last[; - const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; - const int ]b4_parser_class_name[::yyempty_ = -2; - const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; - const int ]b4_parser_class_name[::yyterror_ = 1; - const int ]b4_parser_class_name[::yyerrcode_ = 256; - const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; - - const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; - const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; - +]b4_token_ctor_if([], [b4_yytranslate_define])[ ]b4_namespace_close[ ]b4_epilogue[]dnl - m4_divert_pop(0) + b4_output_end() ++ ++ +m4_popdef([b4_copyright_years])dnl diff --cc data/lalr1.java index 1cfaef3,e961fc5..02079fd --- a/data/lalr1.java +++ b/data/lalr1.java @@@ -17,21 -17,12 +17,20 @@@ m4_include(b4_pkgdatadir/[java.m4]) -b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])]) -m4_ifval(m4_defn([b4_symbol_destructors]), - [b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])], - []) +b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], + [b4_skeleton])]) + +# We don't depend on %debug in Java, but pacify warnings about non-used flags. +b4_parse_trace_if([0], [0]) + +m4_define([b4_symbol_no_destructor_assert], +[b4_symbol_if([$1], [has_destructor], + [b4_fatal([%s: %s: %%destructor does not make sense in Java], + [b4_skeleton], + [b4_symbol_action_location([$1], [destructor])])])]) +b4_symbol_foreach([b4_symbol_no_destructor_assert]) - m4_divert_push(0)dnl - @output(b4_parser_file_name@)@ + b4_output_begin([b4_parser_file_name]) b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], [2007-2012]) @@@ -873,5 -923,5 +872,5 @@@ b4_percent_code_get[]dn } -b4_epilogue +b4_epilogue[]dnl - m4_divert_pop(0)dnl + b4_output_end() diff --cc data/location.cc index 5879ea3,58182a3..b49028f --- a/data/location.cc +++ b/data/location.cc @@@ -262,50 -289,8 +262,53 @@@ m4_define([b4_location_define] ostr << '-' << last.column; return ostr; } +]]) + +# We do want M4 expansion after # for CPP macros. +m4_changecom() +b4_defines_if([ - m4_divert_push(0)dnl - @output(b4_dir_prefix[]position.hh@)@ ++b4_output_begin([b4_dir_prefix[]position.hh]) +b4_copyright([Positions for Bison parsers in C++])[ + +/** + ** \file ]b4_dir_prefix[position.hh + ** Define the ]b4_namespace_ref[::position class. + */ + +]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[ + +# include // std::max +# include +# include + +]b4_null_define[ + +]b4_namespace_open[ +]b4_position_define[ ]b4_namespace_close[ +]b4_cpp_guard_close([b4_dir_prefix[]position.hh]) - @output(b4_dir_prefix[]location.hh@)@ ++b4_output_end() ++ ++ ++b4_output_begin([b4_dir_prefix[]location.hh]) +b4_copyright([Locations for Bison parsers in C++])[ + +/** + ** \file ]b4_dir_prefix[location.hh + ** Define the ]b4_namespace_ref[::location class. + */ +]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[ + +# include "position.hh" + +]b4_namespace_open[ +]b4_location_define[ +]b4_namespace_close[ ]b4_cpp_guard_close([b4_dir_prefix[]location.hh]) - m4_divert_pop(0) - ])# b4_defines_if - m4_popdef([b4_copyright_years])dnl - m4_changecom([#]) + b4_output_end() ++]) ++ ++ ++m4_popdef([b4_copyright_years]) diff --cc data/stack.hh index bd94eb2,ab1049c..4fd136f --- a/data/stack.hh +++ b/data/stack.hh @@@ -116,30 -113,9 +116,27 @@@ m4_define([b4_stack_define] const S& stack_; unsigned int range_; }; +]]) + +b4_defines_if( - [# We do want M4 expansion after # for CPP macros. - m4_changecom() - m4_divert_push(0)dnl - @output(b4_dir_prefix[]stack.hh@)@ ++[b4_output_begin([b4_dir_prefix[]stack.hh]) +b4_copyright([Stack handling for Bison parsers in C++])[ + +/** + ** \file ]b4_dir_prefix[stack.hh + ** Define the ]b4_namespace_ref[::stack class. + */ + +]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[ + +# include + +]b4_namespace_open[ +]b4_stack_define[ ]b4_namespace_close[ ]b4_cpp_guard_close([b4_dir_prefix[]stack.hh]) - m4_divert_pop(0) - m4_popdef([b4_copyright_years])dnl - m4_changecom([#]) + b4_output_end() +]) + + m4_popdef([b4_copyright_years]) diff --cc data/yacc.c index 2b6d10a,810e2b2..9bd8028 --- a/data/yacc.c +++ b/data/yacc.c @@@ -326,11 -331,9 +326,8 @@@ m4_define([b4_shared_declarations] ## Output files. ## ## -------------- ## - # We do want M4 expansion after # for CPP macros. - m4_changecom() - m4_divert_push(0)dnl - @output(b4_parser_file_name@)@ + b4_output_begin([b4_parser_file_name]) -b4_copyright([Bison implementation for Yacc-like parsers in C], - [1984, 1989-1990, 2000-2012])[ +b4_copyright([Bison implementation for Yacc-like parsers in C])[ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ @@@ -1938,14 -2044,19 +1935,15 @@@ yypushreturn:]]) if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - ]b4_epilogue[]dnl + b4_output_end() + b4_defines_if( - [@output(b4_spec_defines_file@)@ - b4_copyright([Bison interface for Yacc-like parsers in C])[ + [b4_output_begin([b4_spec_defines_file])[ -]b4_copyright([Bison interface for Yacc-like parsers in C], - [1984, 1989-1990, 2000-2012])[ ++]b4_copyright([Bison interface for Yacc-like parsers in C])[ ]b4_shared_declarations[ - ]])dnl b4_defines_if - m4_divert_pop(0) - m4_popdef([b4_copyright_years]) + ]b4_output_end() -]) ++])# b4_defines_if diff --cc lib/.gitignore index e62b99c,1535447..ba37d12 --- a/lib/.gitignore +++ b/lib/.gitignore @@@ -271,5 -265,16 +271,11 @@@ /xsize.h /xstrndup.c /xstrndup.h -/xmemdup0.c -/xmemdup0.h -/sys_types.in.h -/obstack_printf.c /binary-io.c -/mbuiter.c /xsize.c + /bitrotate.c + /math.c + /sig-handler.c + /stdio.c + /unistd.c + /wctype-h.c diff --cc m4/.gitignore index 3dfdf6a,7d11249..80193db --- a/m4/.gitignore +++ b/m4/.gitignore @@@ -48,10 -48,8 +48,9 @@@ /hash.m4 /iconv.m4 /include_next.m4 - /inline.m4 /intdiv0.m4 /intl.m4 +/intl.m4~ /intldir.m4 /intlmacosx.m4 /intmax.m4 diff --cc src/scan-gram.l index f5c9b88,5e78cb9..e6f42ea --- a/src/scan-gram.l +++ b/src/scan-gram.l @@@ -981,16 -852,20 +981,20 @@@ convert_ucn_to_byte (char const *ucn static void handle_syncline (char *args, location loc) { - char *after_num; - unsigned long int lineno = strtoul (args, &after_num, 10); - char *file = strchr (after_num, '"') + 1; - *strchr (file, '"') = '\0'; + char *file; + unsigned long int lineno = strtoul (args, &file, 10); if (INT_MAX <= lineno) { - warn_at (loc, _("line number overflow")); + complain (&loc, Wother, _("line number overflow")); lineno = INT_MAX; } - current_file = uniqstr_new (file); + - file = mbschr (file, '"'); ++ file = strchr (file, '"'); + if (file) + { - *mbschr (file + 1, '"') = '\0'; ++ *strchr (file + 1, '"') = '\0'; + current_file = uniqstr_new (file + 1); + } boundary_set (&scanner_cursor, current_file, lineno, 1); }