From 91ad96d55a9848ab482d0946987aaa68af76d357 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 5 Jul 2002 13:29:38 +0000 Subject: [PATCH] GCC-3.1.1 fixes * lily/include/stream.hh: * lily/include/moment.hh: * lily/include/midi-stream.hh: * lily/streams.cc: * lily/scm-option.cc: * lily/parser.yy: * lily/my-lily-lexer.cc: * lily/moment.cc: * lily/midi-stream.cc: * lily/main.cc: * lily/lexer.ll: * lily/includable-lexer.cc: * flower/include/source-file.hh: * flower/include/parray.hh: * flower/include/dictionary.hh: * flower/include/array.icc: * flower/string.cc: * flower/source-file.cc: * flower/getopt-long.cc: gcc-3.1 fixes. * stepmake/stepmake/generic-targets.make: Add comment about warning. * lexer-gcc-3.0.patch: Add comment, and a fix for installations that have an unpatched flex and gcc-3.1.x. * Documentation/topdocs/INSTALL.texi: Add comments and instructions on gcc-3.1.x. * lexer-gcc-3.1.sh: New file. * aclocal.m4: regenerate. * stepmake/aclocal.m4: Version compare fix. --- ChangeLog | 36 +++++++++++++++ Documentation/topdocs/INSTALL.texi | 26 +++++++++-- aclocal.m4 | 2 +- flower/getopt-long.cc | 3 +- flower/include/array.icc | 3 +- flower/include/dictionary.hh | 2 +- flower/include/parray.hh | 3 +- flower/include/source-file.hh | 6 +-- flower/source-file.cc | 10 ++-- flower/string.cc | 3 +- lexer-gcc-3.0.patch | 6 ++- lexer-gcc-3.1.sh | 63 ++++++++++++++++++++++++++ lily/includable-lexer.cc | 2 +- lily/include/midi-stream.hh | 4 +- lily/include/moment.hh | 2 +- lily/include/stream.hh | 16 +++---- lily/lexer.ll | 2 +- lily/main.cc | 63 +++++++++++++------------- lily/midi-stream.cc | 6 +-- lily/moment.cc | 4 +- lily/my-lily-lexer.cc | 3 +- lily/parser.yy | 3 +- lily/scm-option.cc | 14 +++--- lily/streams.cc | 21 +++++---- stepmake/aclocal.m4 | 2 +- stepmake/stepmake/generic-targets.make | 2 +- 26 files changed, 214 insertions(+), 93 deletions(-) create mode 100755 lexer-gcc-3.1.sh diff --git a/ChangeLog b/ChangeLog index d2b1dbad2f..9826ebd839 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2002-07-05 Jan Nieuwenhuizen + + * lily/include/stream.hh: + * lily/include/moment.hh: + * lily/include/midi-stream.hh: + * lily/streams.cc: + * lily/scm-option.cc: + * lily/parser.yy: + * lily/my-lily-lexer.cc: + * lily/moment.cc: + * lily/midi-stream.cc: + * lily/main.cc: + * lily/lexer.ll: + * lily/includable-lexer.cc: + * flower/include/source-file.hh: + * flower/include/parray.hh: + * flower/include/dictionary.hh: + * flower/include/array.icc: + * flower/string.cc: + * flower/source-file.cc: + * flower/getopt-long.cc: gcc-3.1 fixes. + + * stepmake/stepmake/generic-targets.make: Add comment about warning. + + * lexer-gcc-3.0.patch: Add comment, and a fix for installations + that have an unpatched flex and gcc-3.1.x. + + * Documentation/topdocs/INSTALL.texi: Add comments and + instructions on gcc-3.1.x. + + * lexer-gcc-3.1.sh: New file. + + * aclocal.m4: regenerate. + + * stepmake/aclocal.m4: Version compare fix. + 2002-07-05 Han-Wen * ly/engraver-init.ly (RhythmicStaffContext): stems up by default. diff --git a/Documentation/topdocs/INSTALL.texi b/Documentation/topdocs/INSTALL.texi index 5577074df1..a7ced0fd3c 100644 --- a/Documentation/topdocs/INSTALL.texi +++ b/Documentation/topdocs/INSTALL.texi @@ -137,7 +137,9 @@ EGCS 1.1 may work, but is no longer supported. Check out @uref{ftp://ftp.gnu.org/gnu/gcc/, the gcc site}. WARNING: if you choose to upgrade to GCC 3.x, enquire if your -distribution supports g++ 3.x and flex. +distribution supports g++ 3.x and flex. At the time of writing (Fri +Jul 5 2002), @strong{no} distribution that we know of ships a flex +that generates gcc-3.1.x compliant C++ code. @item Python (version 1.5 or newer). Check out @uref{http://www.python.org, the python website}. @@ -156,8 +158,8 @@ Check out @uref{http://www.gnu.org/software/flex/,the Flex webpage}. WARNING: plain Flex 2.5.4(a) generates invalid C++ code. GCC 3.x chokes on this. If you wish to use GCC 3.x, make sure that your -distribution supports g++ 3.x and flex. For a workaround, see -lexer-gcc-3.0 below. +distribution supports g++ 3.x and flex. For workarounds, see +lexer-gcc-3.0.patch and lexer-gcc-3.1.sh in the source directory. @item Bison (version 1.25 or newer). Check out @uref{http://www.gnu.org/software/bison/,the bison webpage} @@ -621,7 +623,7 @@ send bug reports to @email{bug-lilypond@@gnu.org}. Bugs that are not fault of LilyPond are documented here. -@unnumberedsubsec FLex-2.5.4a and gcc-3.0 +@unnumberedsubsec Flex-2.5.4a and gcc-3.x Flex 2.5.4a does not produce g++-3.0 compliant C++ code. To compile LilyPond with gcc-3.0 you may do: @@ -635,6 +637,22 @@ LilyPond with gcc-3.0 you may do: Note that this is fixed in Debian/unstable for flex >= 2.5.4a-13. +@unnumberedsubsec Flex-2.5.4a and gcc-3.1.x + +Flex 2.5.4a does not produce g++-3.1.1 compliant C++ code. To compile +LilyPond with gcc-3.1.1 you may do: + +@example + CONF=gcc-3.1 ./lexer-gcc-3.1.sh + CPPFLAGS=$(pwd)/lily/out-gcc-3.1 CC=gcc-3.1 CXX=g++-3.1 \ + ./configure --enable-config=gcc-3.1 + CONF=gcc-3.1 ./lexer-gcc-3.1.sh + make conf=gcc-3.1 +@end example + +Note that this is @strong{not} fixed in Debian/unstable for flex <= +2.5.4a-26. + @unnumberedsubsec Linux-2.4.0, Guile-1.4 --with-threads There's a bug in certain kernels around version 2.4.0, that is diff --git a/aclocal.m4 b/aclocal.m4 index 686026ab08..d5b5bdd22b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -41,7 +41,7 @@ AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [ if ([$]3) {three = [$]3} else {three = 0} } - {printf "%s%s%s\n", [$]1*100, [$]2*10, three}' + {printf "%d\n", [$]1*1000000 + [$]2*1000 + three}' ]) diff --git a/flower/getopt-long.cc b/flower/getopt-long.cc index 7395555e79..c081f3028a 100644 --- a/flower/getopt-long.cc +++ b/flower/getopt-long.cc @@ -6,10 +6,11 @@ #include #include -#include #include #include +#include + #include "config.h" #include "getopt-long.hh" #include "international.hh" diff --git a/flower/include/array.icc b/flower/include/array.icc index 46194f587f..47636d3354 100644 --- a/flower/include/array.icc +++ b/flower/include/array.icc @@ -49,8 +49,7 @@ Array::insert (T k, int j) } template INLINE void -Array::sort (int (*compare) (T const&,T const&), - int lower = -1, int upper = -1) +Array::sort (int (*compare) (T const&,T const&), int lower, int upper) { if (lower < 0) { diff --git a/flower/include/dictionary.hh b/flower/include/dictionary.hh index d77f3aec98..3b39641e5a 100644 --- a/flower/include/dictionary.hh +++ b/flower/include/dictionary.hh @@ -47,7 +47,7 @@ public: } bool elem_b (String s) { - std::map::const_iterator ki (find (s)); + typename std::map::const_iterator ki (find (s)); return ki != end (); } diff --git a/flower/include/parray.hh b/flower/include/parray.hh index c39ec2500b..eb259ede4b 100644 --- a/flower/include/parray.hh +++ b/flower/include/parray.hh @@ -195,8 +195,7 @@ typecast_array (Link_array const &a, T * /* dummy */ ) template inline void -Link_array::sort (int (*compare) (T *const&,T *const&), - int lower = -1, int upper = -1) +Link_array::sort (int (*compare)(T *const&,T *const&), int lower, int upper) { if (lower < 0) { diff --git a/flower/include/source-file.hh b/flower/include/source-file.hh index 45985174ab..777213267d 100644 --- a/flower/include/source-file.hh +++ b/flower/include/source-file.hh @@ -6,7 +6,7 @@ #ifndef SOURCE_FILE_HH #define SOURCE_FILE_HH -#include +#include #include "flower-proto.hh" #include "string.hh" @@ -32,7 +32,7 @@ public: char const* ch_C () const; virtual String error_str (char const* pos_ch_C ) const; - istream * istream_l (); + std::istream * istream_l (); bool in_b (char const* pos_ch_C ) const; int length_i () const; virtual int line_i (char const* pos_ch_C ) const; @@ -59,7 +59,7 @@ public: private: String name_str_; - istream* istream_p_; + std::istream* istream_p_; File_storage * storage_p_; }; diff --git a/flower/source-file.cc b/flower/source-file.cc index 9d2b902e55..6e607980fe 100644 --- a/flower/source-file.cc +++ b/flower/source-file.cc @@ -9,7 +9,7 @@ #include -#include +#include #include "string.hh" #include "flower-proto.hh" @@ -34,7 +34,7 @@ Source_file::Source_file (String name_str, String data_str) pos_ch_C_ = ch_C (); } -istream* +std::istream* Source_file::istream_l () { /* @@ -45,11 +45,11 @@ Source_file::istream_l () if (!istream_p_) { if (length_i ()) // can-t this be done without such a hack? - istream_p_ = new istrstream (ch_C (), length_i ()); + istream_p_ = new std::stringstream (ch_C ()); else { - istream_p_ = new istrstream ("", 0); - istream_p_->setstate (ios::eofbit); + istream_p_ = new std::istringstream (""); + istream_p_->setstate (std::ios::eofbit); // istream_p_->set (ios::eofbit); } } diff --git a/flower/string.cc b/flower/string.cc index e08e908efe..2550404c0b 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -12,11 +12,12 @@ #include #include -#include #include #include #include +#include + #include "string.hh" #include "libc-extension.hh" #include "string-convert.hh" diff --git a/lexer-gcc-3.0.patch b/lexer-gcc-3.0.patch index fedefc258c..00e1ccc46e 100644 --- a/lexer-gcc-3.0.patch +++ b/lexer-gcc-3.0.patch @@ -1,3 +1,7 @@ +# Patch file documenting fix for flex-2.5.4 and gcc-3.x +# +# For usage of this patch, see INSTALL.txt + --- ./lily/out-gcc-3.0/lexer.cc~ Tue Jun 26 13:12:26 2001 +++ ./lily/out-gcc-3.0/lexer.cc Tue Jun 26 13:11:56 2001 @@ -21,7 +21,7 @@ @@ -5,7 +9,7 @@ #include -class istream; -+#include ++#include #include /* Use prototypes in function declarations. */ diff --git a/lexer-gcc-3.1.sh b/lexer-gcc-3.1.sh new file mode 100755 index 0000000000..7d816302b8 --- /dev/null +++ b/lexer-gcc-3.1.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# script documenting fixes for flex-2.5.4 and gcc-3.1 + +includes="$HOME/usr/include /usr/local/include /usr/include" + +for i in $includes; do + file=$i/FlexLexer.h + if [ -f "$file" ]; then + break + else + file= + fi +done + +if [ -z "$file" ]; then + cat </std::istream/' \ + -e 's/\/std::ostream/' \ + $file > lily/$outdir/FlexLexer.h +echo "done" + +file=lily/$outdir/lexer.cc +rm -f $file +make conf=$CONF -C lily $outdir/lexer.cc || exit 0 + +if [ -f "$file" ]; then + echo -n "Generating and fixing $file... " + + mv $file $file.orig + sed -e 's/\/std::cin/g' \ + -e 's/\/std::cout/g' \ + -e 's/\/std::cerr/g' \ + $file.orig > $file + echo "done" +fi + +cat < */ -#include +#include #include "file-path.hh" diff --git a/lily/include/midi-stream.hh b/lily/include/midi-stream.hh index fbe3973cd2..995c048332 100644 --- a/lily/include/midi-stream.hh +++ b/lily/include/midi-stream.hh @@ -7,7 +7,7 @@ #ifndef MIDI_STREAM_HH #define MIDI_STREAM_HH -#include +#include #include "string.hh" /// Midi outputfile @@ -21,7 +21,7 @@ struct Midi_stream { void open (); - ostream* os_p_; + std::ostream* os_p_; String filename_str_; }; diff --git a/lily/include/moment.hh b/lily/include/moment.hh index 30689a5d26..96f2843cef 100644 --- a/lily/include/moment.hh +++ b/lily/include/moment.hh @@ -63,7 +63,7 @@ INSTANTIATE_COMPARE (Moment const&, Moment::compare); #ifdef STREAM_SUPPORT -ostream & operator << ( ostream &,Moment const &); +std::ostream & operator << (std::ostream &, Moment const &); #endif #endif /* MOMENT_HH */ diff --git a/lily/include/stream.hh b/lily/include/stream.hh index ad747a0760..fa34b86c30 100644 --- a/lily/include/stream.hh +++ b/lily/include/stream.hh @@ -9,19 +9,19 @@ source file of the GNU LilyPond music typesetter #ifndef STREAM_HH #define STREAM_HH -#include "string.hh" +#include +#include + +#include "string.hh" -#include /* gcc 3.0 */ #if __GNUC__ > 2 -ostream *open_file_stream (String filename, - std::ios_base::openmode mode=std::ios::out); +std::ostream *open_file_stream (String filename, + std::ios_base::openmode mode=std::ios::out); #else -ostream *open_file_stream (String filename, int mode=ios::out); +std::ostream *open_file_stream (String filename, int mode=ios::out); #endif -void close_file_stream (ostream *os); - - +void close_file_stream (std::ostream *os); #endif /* STREAM_HH */ diff --git a/lily/lexer.ll b/lily/lexer.ll index 5d224403ca..c90632a355 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -24,9 +24,9 @@ #include #include -#include /* gcc 3.0 */ #include +#include #include "score.hh" #include "lily-guile.hh" diff --git a/lily/main.cc b/lily/main.cc index 0e789e75c9..6bfd9413e8 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -8,11 +8,12 @@ #include #include -#include #include #include #include +#include + #include "config.h" #if HAVE_GETTEXT @@ -137,23 +138,23 @@ usage () /* No version number or newline here. It confuses help2man */ - cout << _f ("Usage: %s [OPTION]... FILE...", "lilypond").ch_C(); - cout << "\n\n"; - cout << _ ("Typeset music and or play MIDI from FILE").ch_C(); - cout << "\n\n"; - cout << + std::cout << _f ("Usage: %s [OPTION]... FILE...", "lilypond").ch_C(); + std::cout << "\n\n"; + std::cout << _ ("Typeset music and or play MIDI from FILE").ch_C(); + std::cout << "\n\n"; + std::cout << _ ( "LilyPond is a music typesetter. It produces beautiful sheet music\n" "using a high level description file as input. LilyPond is part of \n" "the GNU Project.\n" ).ch_C(); - cout << '\n'; - cout << _ ("Options:").ch_C(); - cout << '\n'; - cout << Long_option_init::table_str (options_static).ch_C(); - cout << '\n'; - cout << _ ("This binary was compiled with the following options:") .ch_C() + std::cout << '\n'; + std::cout << _ ("Options:").ch_C(); + std::cout << '\n'; + std::cout << Long_option_init::table_str (options_static).ch_C(); + std::cout << '\n'; + std::cout << _ ("This binary was compiled with the following options:") .ch_C() << " " << #ifdef NDEBUG "NDEBUG " @@ -164,41 +165,41 @@ _ ( "\n"; - cout << endl; + std::cout << std::endl; - cout << _f ("Report bugs to %s", "bug-lilypond@gnu.org").ch_C() << endl; + std::cout << _f ("Report bugs to %s", "bug-lilypond@gnu.org").ch_C() << std::endl; } void version () { identify (stdout); - cout << '\n'; - cout << _f ("" + std::cout << '\n'; + std::cout << _f ("" "This is free software. It is covered by the GNU General Public License,\n" "and you are welcome to change it and/or distribute copies of it under\n" "certain conditions. Invoke as `%s --warranty' for more information.\n", "lilypond").ch_C(); - cout << endl; + std::cout << std::endl; - cout << _f ("Copyright (c) %s by", "1996--2002").ch_C(); - cout << '\n'; - cout << " Han-Wen Nienhuys \n"; - cout << " Jan Nieuwenhuizen \n"; + std::cout << _f ("Copyright (c) %s by", "1996--2002").ch_C(); + std::cout << '\n'; + std::cout << " Han-Wen Nienhuys \n"; + std::cout << " Jan Nieuwenhuizen \n"; } void notice () { - cout << '\n'; - cout << _ ("GNU LilyPond -- The music typesetter").ch_C(); - cout << '\n'; - cout << _f ("Copyright (c) %s by", "1996--2002").ch_C(); - cout << '\n'; - cout << " Han-Wen Nienhuys \n"; - cout << " Jan Nieuwenhuizen \n"; - cout << '\n'; - cout << _ ( + std::cout << '\n'; + std::cout << _ ("GNU LilyPond -- The music typesetter").ch_C(); + std::cout << '\n'; + std::cout << _f ("Copyright (c) %s by", "1996--2002").ch_C(); + std::cout << '\n'; + std::cout << " Han-Wen Nienhuys \n"; + std::cout << " Jan Nieuwenhuizen \n"; + std::cout << '\n'; + std::cout << _ ( " This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License version 2\n" "as published by the Free Software Foundation.\n" @@ -323,7 +324,7 @@ main_prog (void * , int, char**) */ init_lily_guile (prefix_directory); - cout << endl; + std::cout << std::endl; call_constructors (); all_fonts_global_p = new All_font_metrics (global_path.str ()); diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index 3d5b366a10..afce7e3b54 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -20,11 +20,7 @@ Midi_stream::Midi_stream (String filename) { filename_str_ = filename; -#if __GCC__ > 2 - os_p_ = open_file_stream (filename, ios::out|ios::bin); -#else - os_p_ = open_file_stream (filename, ios::out|ios::binary); -#endif + os_p_ = open_file_stream (filename, std::ios::out|std::ios::binary); } Midi_stream::~Midi_stream () diff --git a/lily/moment.cc b/lily/moment.cc index 3c504ecc04..8de57af23b 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -204,8 +204,8 @@ Moment::operator - () const #ifdef STREAM_SUPPORT -ostream & -operator << (ostream &os, Moment const &m) +std::ostream & +operator << (std::ostream &os, Moment const &m) { os << m.str (); return os; diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 59e8d2f4a3..de7e68637d 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -6,9 +6,10 @@ (c) 1997--2002 Han-Wen Nienhuys */ -#include #include +#include + #include "lily-proto.hh" #include "scm-hash.hh" #include "interval.hh" diff --git a/lily/parser.yy b/lily/parser.yy index 698398adcc..3019fe3982 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -24,7 +24,8 @@ this. */ #include -#include + +//#include #include "translator-def.hh" #include "lily-guile.hh" diff --git a/lily/scm-option.cc b/lily/scm-option.cc index e924020aa7..fca566f9bd 100644 --- a/lily/scm-option.cc +++ b/lily/scm-option.cc @@ -7,7 +7,7 @@ */ -#include +#include #include "string.hh" #include "lily-guile.hh" @@ -72,7 +72,7 @@ This function is useful to call from the command line: @code{lilypond -e */ if (var == ly_symbol2scm ("help")) { - cout << _("lilypond -e EXPR means + std::cout << _("lilypond -e EXPR means evalute EXPR as Scheme after init.scm has been read. In particular, the function set-lily-option allows for access to some internal @@ -81,12 +81,12 @@ variables. Usage: (set-lily-option SYMBOL VAL) possible options for SYMBOL are : -").ch_C()< #endif -#include -#include + +#include +#include #include "stream.hh" #include "file-path.hh" @@ -15,23 +16,23 @@ #include "main.hh" #if __GNUC__ > 2 -ostream * +std::ostream * open_file_stream (String filename, std::ios_base::openmode mode) #else -ostream * +std::ostream * open_file_stream (String filename, int mode) #endif { - ostream *os; + std::ostream *os; if ((filename == "-")) - os = &cout; + os = &std::cout; else { Path p = split_path (filename); if (!p.dir.empty_b ()) if (mkdir (p.dir.ch_C (), 0777) == -1 && errno != EEXIST) error (_f ("can't create directory: `%s'", p.dir)); - os = new ofstream (filename.ch_C (), mode); + os = new std::ofstream (filename.ch_C (), mode); } if (!*os) error (_f ("can't open file: `%s'", filename)); @@ -39,15 +40,15 @@ open_file_stream (String filename, int mode) } void -close_file_stream (ostream *os) +close_file_stream (std::ostream *os) { - *os << flush; + *os << std::flush; if (!*os) { warning (_ ("Error syncing file (disk full?)")); exit_status_global = 1; } - if (os != &cout) + if (os != &std::cout) delete os; os = 0; } diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 9b05585edd..e8aeb960a9 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -38,7 +38,7 @@ AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [ if ([$]3) {three = [$]3} else {three = 0} } - {printf "%s%s%s\n", [$]1*100, [$]2*10, three}' + {printf "%d\n", [$]1*1000000 + [$]2*1000 + three}' ]) diff --git a/stepmake/stepmake/generic-targets.make b/stepmake/stepmake/generic-targets.make index f9b49024a7..b6e588fd6e 100644 --- a/stepmake/stepmake/generic-targets.make +++ b/stepmake/stepmake/generic-targets.make @@ -127,7 +127,7 @@ installextradoc: $(foreach i, $(EXTRA_DOC_FILES),\ cp -r $(i) $(prefix)/doc/$(package) &&) true -include $(outdir)/dummy.dep $(DEP_FILES) +include $(outdir)/dummy.dep $(DEP_FILES) # expect a warning here $(outdir)/dummy.dep: -mkdir -p $(outdir) -- 2.39.2