X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpaper-stream.cc;h=bb4ec7121deb5d9baa17ab676a17b12cb00a0d50;hb=949737e17ed7cbc231a3c08e45d32897a636d94d;hp=72d14a69b520e8781f192a2b08454207674f948d;hpb=068b30ff4bfe81e6dd41ac3736bbc52980e79a1f;p=lilypond.git diff --git a/lily/paper-stream.cc b/lily/paper-stream.cc index 72d14a69b5..bb4ec7121d 100644 --- a/lily/paper-stream.cc +++ b/lily/paper-stream.cc @@ -3,11 +3,10 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ #include -#include #include "main.hh" #include "paper-stream.hh" @@ -20,14 +19,13 @@ Paper_stream::Paper_stream (String filename) if (filename.length_i () && (filename != "-")) os = new ofstream (filename.ch_C ()); else -// os = new ostream (cout.ostreambuf ()); + // os = new ostream (cout.ostreambuf ()); os = new ostream (cout._strbuf); if (!*os) - error (_f ("can't open file: `%s\'", filename)); + error (_f ("Can't open file: `%s'", filename)); nest_level = 0; line_len_i_ = 0; - outputting_comment=false; - // header (); + outputting_comment_b_=false; } Paper_stream::~Paper_stream () @@ -35,7 +33,7 @@ Paper_stream::~Paper_stream () *os << flush; if (!*os) { - warning (_ ("error syncing file (disk full?)")); + warning (_ ("Error syncing file (disk full?)")); exit_status_i_ = 1; } delete os; @@ -44,69 +42,73 @@ Paper_stream::~Paper_stream () // print string. don't forget indent. Paper_stream& -Paper_stream::operator << (Scalar s) +Paper_stream::operator << (String s) { for (char const *cp = s.ch_C (); *cp; cp++) { - if (outputting_comment) - { - *os << *cp; - if (*cp == '\n') - { - outputting_comment=false; - - } - continue; - } - line_len_i_ ++; - switch (*cp) + if (outputting_comment_b_) + { + *os << *cp; + if (*cp == '\n') { - case '%': - outputting_comment = true; - *os << *cp; - break; - case '{': - nest_level++; - *os << *cp; - break; - case '}': - nest_level--; - *os << *cp; - - if (nest_level < 0) - { - delete os; // we want to see the remains. - assert (nest_level>=0); - } - - /* don't break line if not nested; very ugly for ps */ - if (nest_level == 0) - break; - - /* FALLTHROUGH */ - - case '\n': - break_line (); - break; - case ' ': - *os << ' '; - if (line_len_i_ > MAXLINELEN) - break_line (); - - break; - default: - *os << *cp; - break; - } + outputting_comment_b_=false; + line_len_i_ =0; + } + continue; + } + line_len_i_ ++; + switch (*cp) + { + case '%': + outputting_comment_b_ = true; + *os << *cp; + break; + case '{': + nest_level++; + *os << *cp; + break; + case '}': + nest_level--; + *os << *cp; + + if (nest_level < 0) + { + delete os; // we want to see the remains. + assert (nest_level>=0); + } + + /* don't break line if not nested; very ugly for ps */ + if (nest_level == 0) + break; + + *os << '%'; + break_line (); + break; + case '\n': + break_line (); + break; + case ' ': + *os << ' '; + if (line_len_i_ > MAXLINELEN) + break_line (); + + break; + default: + *os << *cp; + break; + } } + //urg, for debugging only!! + *os << flush; return *this; } void Paper_stream::break_line () { - *os << "%\n"; + *os << '\n'; *os << to_str (' ', nest_level); + outputting_comment_b_ = false; line_len_i_ = 0; }