From 447a815de9e11223d731f4f7ecfd66f982d39fc0 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 13 Apr 2003 11:48:48 +0000 Subject: [PATCH] * lily/lexer.ll (avoid_silly_flex_induced_gcc_warnings): Disable. * lily/includable-lexer.cc [!HAVE_FLEXLEXER_YY_CURRENT_BUFFER] (yy_current_buffer): New macro, compile hacks for flex 2.5.29. * lily/include/includable-lexer.hh: * lily/lexer.ll: Hack for multiple include of FlexLexer.h. * config.hh.in (HAVE_FLEXLEXER_YY_CURRENT_BUFFER): Add. * aclocal.m4: Regenerate. * stepmake/aclocal.m4 (STEPMAKE_FLEXLEXER): Check for yyFlexLexer.yy_current_buffer, which was removed in flex-2.5.29. --- ChangeLog | 17 +++++++++++++++++ aclocal.m4 | 24 +++++++++++++++++++++++- config.hh.in | 3 +++ lily/includable-lexer.cc | 12 ++++++++++++ lily/include/includable-lexer.hh | 3 ++- lily/include/my-lily-lexer.hh | 4 +--- lily/lexer.ll | 9 ++++++++- stepmake/aclocal.m4 | 22 ++++++++++++++++++++++ 8 files changed, 88 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9540db5ead..81c32e13f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2003-04-13 Jan Nieuwenhuizen + * flex-2.5.31 hits Debian/unstable. Fixes below. + + * lily/lexer.ll (avoid_silly_flex_induced_gcc_warnings): Disable. + + * lily/includable-lexer.cc [!HAVE_FLEXLEXER_YY_CURRENT_BUFFER] + (yy_current_buffer): New macro, compile hacks for flex 2.5.29. + + * lily/include/includable-lexer.hh: + * lily/lexer.ll: Hack for multiple include of FlexLexer.h. + + * config.hh.in (HAVE_FLEXLEXER_YY_CURRENT_BUFFER): Add. + + * aclocal.m4: Regenerate. + + * stepmake/aclocal.m4 (STEPMAKE_FLEXLEXER): Check for + yyFlexLexer.yy_current_buffer, which was removed in flex-2.5.29. + * scm/pdf.scm (use-modules): Include lily. * scm/pdftex.scm (start-system): Bugfix: add closing brace (Beernd diff --git a/aclocal.m4 b/aclocal.m4 index 6acd560cef..f72cb501a7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ dnl aclocal.m4 -*-shell-script-*- dnl WARNING WARNING WARNING -dnl do not edit! this is aclocal.m4, generated from /users/hanwen/usr/src/lilypond/stepmake/aclocal.m4 +dnl do not edit! this is aclocal.m4, generated from /home/janneke/lily/stepmake/aclocal.m4 dnl aclocal.m4 -*-shell-script-*- dnl StepMake subroutines for configure.in @@ -334,6 +334,28 @@ AC_DEFUN(STEPMAKE_FLEXLEXER, [ warn='FlexLexer.h (flex package)' STEPMAKE_ADD_ENTRY($1, $warn) fi + # check for yyFlexLexer.yy_current_buffer, + # in 2.5.4 <= flex < 2.5.29 + AC_LANG_PUSH(C++) + AC_CACHE_CHECK([for yyFlexLexer.yy_current_buffer], + [stepmake_flexlexer_yy_current_buffer], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +class yy_flex_lexer: public yyFlexLexer +{ + public: + yy_flex_lexer () + { + yy_current_buffer = 0; + } +}; +]])], + [stepmake_flexlexer_yy_current_buffer=yes], + [stepmake_flexlexer_yy_current_buffer=no])) + if test $stepmake_flexlexer_yy_current_buffer = yes; then + AC_DEFINE(HAVE_FLEXLEXER_YY_CURRENT_BUFFER, 1, [Define to 1 if yyFlexLexer has yy_current_buffer.]) + fi + AC_LANG_POP(C++) ]) diff --git a/config.hh.in b/config.hh.in index 5e276610b9..71848269c4 100644 --- a/config.hh.in +++ b/config.hh.in @@ -27,6 +27,9 @@ /* define if you have vsnprintf */ #define HAVE_VSNPRINTF 0 +/* define if you have yyFlexLexer.yy_current_buffer */ +#undef HAVE_FLEXLEXER_YY_CURRENT_BUFFER + /* define if you have gettext */ #define HAVE_GETTEXT 0 diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index 6d5207a084..e22180aad5 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -26,9 +26,17 @@ #define YYSTATE YY_START #endif +/* Flex >= 2.5.29 has include stack; but we don't use that yet. */ +#ifndef HAVE_FLEXLEXER_YY_CURRENT_BUFFER +#define yy_current_buffer \ + (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0) +#endif + Includable_lexer::Includable_lexer () { +#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; +#endif allow_includes_b_ = true; } @@ -106,10 +114,14 @@ Includable_lexer::close_input () if (verbose_global_b) progress_indication ("]"); yy_delete_buffer (yy_current_buffer); +#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; +#endif if (state_stack_.empty ()) { +#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER yy_current_buffer = 0; +#endif return false; } else diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index a05d707b0d..2406c259bb 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -6,12 +6,13 @@ (c) 1997--2002 Han-Wen Nienhuys */ - #ifndef INCLUDABLE_LEXER_HH #define INCLUDABLE_LEXER_HH +#ifndef LEXER_CC using namespace std; #include +#endif #include "string.hh" #include "parray.hh" diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index 27b98cda64..123cf74704 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -9,8 +9,7 @@ #ifndef LEXER_HH #define LEXER_HH -using namespace std; -#include +#include "includable-lexer.hh" #include "input.hh" #include "dictionary.hh" @@ -18,7 +17,6 @@ using namespace std; #include "flower-proto.hh" #include "array.hh" #include "string.hh" -#include "includable-lexer.hh" #include "duration.hh" #include "pitch.hh" #include "protected-scm.hh" diff --git a/lily/lexer.ll b/lily/lexer.ll index 31f7820f03..332257ff80 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -1,6 +1,6 @@ %{ // -*-Fundamental-*- /* - lexer.l -- implement the Flex lexer + lexer.ll -- implement the Flex lexer source file of the LilyPond music typesetter @@ -26,6 +26,10 @@ #include #include +/* Flex >= 2.5.29 fix; FlexLexer.h's multiple include bracing breaks + when building the actual lexer. */ +#define LEXER_CC + #include using namespace std; @@ -783,6 +787,8 @@ scan_fraction (String frac) return gh_cons (gh_int2scm (n), gh_int2scm (d)); } +// Breaks for flex 2.5.31 +#if 0 /* avoid silly flex induced gcc warnings */ static void yy_push_state (int) {;} static void yy_pop_state () {;} @@ -799,6 +805,7 @@ avoid_silly_flex_induced_gcc_warnings () yy_top_state (); avoid_silly_flex_induced_gcc_warnings (); } +#endif SCM lookup_markup_command (String s) diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 695aeddca5..8851cc4e7a 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -331,6 +331,28 @@ AC_DEFUN(STEPMAKE_FLEXLEXER, [ warn='FlexLexer.h (flex package)' STEPMAKE_ADD_ENTRY($1, $warn) fi + # check for yyFlexLexer.yy_current_buffer, + # in 2.5.4 <= flex < 2.5.29 + AC_LANG_PUSH(C++) + AC_CACHE_CHECK([for yyFlexLexer.yy_current_buffer], + [stepmake_flexlexer_yy_current_buffer], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +class yy_flex_lexer: public yyFlexLexer +{ + public: + yy_flex_lexer () + { + yy_current_buffer = 0; + } +}; +]])], + [stepmake_flexlexer_yy_current_buffer=yes], + [stepmake_flexlexer_yy_current_buffer=no])) + if test $stepmake_flexlexer_yy_current_buffer = yes; then + AC_DEFINE(HAVE_FLEXLEXER_YY_CURRENT_BUFFER, 1, [Define to 1 if yyFlexLexer has yy_current_buffer.]) + fi + AC_LANG_POP(C++) ]) -- 2.39.5