From 0c868a5fca204c12ac9b747d4706afad9892d6dd Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 5 Mar 1997 20:03:43 +0000 Subject: [PATCH] lilypond-0.0.39 --- bin/cpgento | 49 ++++++++++++++++++ m2m/include/m2m.hh | 57 +++++++++++++++++++++ m2m/lily-stream.cc | 122 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100755 bin/cpgento create mode 100644 m2m/include/m2m.hh create mode 100644 m2m/lily-stream.cc diff --git a/bin/cpgento b/bin/cpgento new file mode 100755 index 0000000000..2bb4da29af --- /dev/null +++ b/bin/cpgento @@ -0,0 +1,49 @@ +#!/bin/sh +# cpgento +# + +if test $# -ne 1 +then + echo "Usage: " + echo " cpgento LOCATION, e.g.:"; + echo + echo " cpgento /mnt/aix/usr/src/lily" + echo " CP=rcp cpgento fred@pcnov095.win.tue.nl:music/lily" + exit 1 +fi + +MAKE=${MAKE:-make} +CP=${CP:-cp} + +genlily="out/parser.hh out/parser.cc out/lexer.cc" +echo generating $genlily ... +$MAKE -C lily $genlily + +genm2m="out/midi-parser.hh out/midi-parser.cc out/midi-lexer.cc" +echo generating $genm2m ... +$MAKE -C m2m $genm2m + +lilydir=`pwd | sed "s/.*\///"` +todir=$1/$lilydir +echo "copying $lilydir -> $todir" + +cpto() { + name=$1 + tostuff=$todir/$name/out + genstuff="$2" + if [ "$CP" = "cp" -a \! -d $tostuff ] + then + echo mkdir -p $tostuff + mkdir -p $tostuff + fi + echo $CP $genstuff $tostuff + (cd $name; $CP $genstuff $tostuff) +} + +cpto lily "$genlily" +cpto m2m "$genm2m" + +# if you cannot gen the above, you-ll probably want: +flexlexerh=/usr/include/FlexLexer.h +cpto lib $flexlexerh + diff --git a/m2m/include/m2m.hh b/m2m/include/m2m.hh new file mode 100644 index 0000000000..fd404e4349 --- /dev/null +++ b/m2m/include/m2m.hh @@ -0,0 +1,57 @@ +// +// m2m.hh -- generic m2m include file +// +// copyright 1997 Jan Nieuwenhuizen + +#ifndef M2M_HH +#define M2M_HH + +// yes, i know this hurts the dependency calc, however, +// having includes in headers sucks, and long trial and error +// include lists also suck. +// if you want less dependecies, break lib/exe down in smaller +// modules. + +#include +#include +#include +#include +#include +#include + +#include "proto.hh" +#include "plist.hh" +#include "debug.hh" +#ifdef mtor +#undef mtor +#endif + +#include "string.hh" +#include "string-convert.hh" + +#include "lgetopt.hh" + +#include "moment.hh" +#include "duration.hh" +#include "input-file.hh" +#include "source-file.hh" +#include "source.hh" + +// mustn-t do, these get touched! +// #include "fversion.hh" +// #include "version.hh" + +#include "midi-global.hh" + +#include "lily-stream.hh" +#include "midi-event.hh" +#include "midi-main.hh" +#include "midi-score.hh" +#include "midi-track.hh" +#include "midi-voice.hh" +#include "my-midi-lexer.hh" +#include "my-midi-parser.hh" +#include "track-column.hh" + +#endif // M2M_HH + diff --git a/m2m/lily-stream.cc b/m2m/lily-stream.cc new file mode 100644 index 0000000000..71385ab5e7 --- /dev/null +++ b/m2m/lily-stream.cc @@ -0,0 +1,122 @@ +// +// lily-stream.cc +// +// source file of the LilyPond music typesetter +// +// (c) 1997 Jan Nieuwenhuizen + +// should i be named Mudela_stream? + +#include "m2m.hh" + +Lily_stream::Lily_stream( String filename_str ) +{ + filename_str_ = filename_str; + os_p_ = 0; + indent_i_ = 0; + comment_mode_bo_ = false; + column_i_ = 0; + wrap_column_i_ = 78; + open(); + header(); +} + +Lily_stream::~Lily_stream() +{ + delete os_p_; + if ( indent_i_ ) + warning( "lily indent level: " + String( indent_i_ ), 0 ); +} + +Lily_stream& +Lily_stream::operator <<( String str ) +{ + while ( str.length_i() ) { + int max_i = wrap_column_i_ - column_i_; + String line = str.left_str( max_i ); + + while ( max_i && ( max_i < line.length_i() ) + && ( isalnum( line[ max_i ] ) + || ( line[ max_i ] == '\\' ) ) ) + max_i--; + if ( max_i ) + line = str.left_str( max_i + 1 ); + else // cannot break neatly... + max_i = wrap_column_i_ - column_i_ - 1; + + str = str.mid_str( max_i + 1, INT_MAX ); + *os_p_ << line; + check_comment( line ); + column_i_ += line.length_i(); + if ( column_i_ >= wrap_column_i_ ) { + //brr. + if ( comment_mode_bo_ ) + str = "%" + str; + newline(); + } + } + return *this; +} + +Lily_stream& +Lily_stream::operator <<( Midi_event& midi_event_r ) +{ + midi_event_r.output_mudela( *this, false ); + return *this; +} + +void +Lily_stream::check_comment( String str ) +{ + int newline_i = str.index_last_i( '\n' ); + if ( newline_i != -1 ) { + str = str.mid_str( newline_i +1, INT_MAX ); + comment_mode_bo_ = false; + } + if ( str.index_i( '%' ) != -1 ) + comment_mode_bo_ = true; +} + +void +Lily_stream::header() +{ + *os_p_ << "% Creator: " << version_str() << "\n"; + *os_p_ << "% Automatically generated, at "; + time_t t( time( 0 ) ); + *os_p_ << ctime( &t ); + *os_p_ << "% from input file: "; + *os_p_ << midi_parser_l_g->filename_str_; + *os_p_ << "\n\n"; +} + +void +Lily_stream::indent() +{ + indent_i_++; + newline(); +} + +void +Lily_stream::newline() +{ + *os_p_ << "\n" << String( '\t', indent_i_ ); + column_i_ = indent_i_ * 8; + comment_mode_bo_ = false; +} + +void +Lily_stream::open() +{ + os_p_ = new ofstream( filename_str_ ); + if ( !*os_p_ ) + error ( "can't open `" + filename_str_ + "\'", 0 ); +} + +void +Lily_stream::tnedni() +{ + assert( indent_i_ > 0 ); + indent_i_--; + newline(); +} + -- 2.39.5