From: Jan Nieuwenhuizen Date: Fri, 1 Dec 2000 11:29:08 +0000 (+0100) Subject: patch::: 1.3.113.jcn3 X-Git-Tag: release/1.3.114~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2007f11f76fb92b495ac33621539aa481873302a;p=lilypond.git patch::: 1.3.113.jcn3 --- diff --git a/VERSION b/VERSION index 1677e99412..efcc3d8177 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=113 -MY_PATCH_LEVEL=jcn2 +MY_PATCH_LEVEL=jcn3 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/include/main.hh b/lily/include/main.hh index de6cf4f417..f8b2612d21 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -36,6 +36,7 @@ extern Array get_inclusion_names (); extern void set_inclusion_names (Array); extern File_path global_path; +extern Array global_score_header_fields; extern String default_outname_base_global; extern String default_outname_suffix_global; diff --git a/lily/include/paper-stream.hh b/lily/include/paper-stream.hh index ab5de0684e..4b5f51652b 100644 --- a/lily/include/paper-stream.hh +++ b/lily/include/paper-stream.hh @@ -13,7 +13,7 @@ class Paper_stream { public: bool outputting_comment_b_; - ostream *os; + ostream *os_; int nest_level; /// to check linelen in output. TeX has limits. int line_len_i_; @@ -32,4 +32,9 @@ private: void break_line(); }; +class ostream; +ostream *open_file_stream (String filename); +void close_file_stream (ostream *os); + + #endif // PAPER_STREAM_HH diff --git a/lily/main.cc b/lily/main.cc index 8a998eb9f0..b98056a375 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -51,6 +51,8 @@ String init_str_global; int default_count_global; File_path global_path; +Array global_score_header_fields; + bool safe_global_b = false; bool experimental_features_global_b = false; bool dependency_global_b = false; @@ -72,6 +74,7 @@ String distill_inname_str (String name_str, String& ext_r); Long_option_init theopts[] = { {_i ("EXT"), "output-format", 'f', _i ("use output format EXT (scm, ps, tex or as)")}, {0, "help", 'h', _i ("this help")}, + {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")}, {_i ("DIR"), "include", 'I', _i ("add DIR to search path")}, {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, {0, "dependencies", 'M', _i ("write Makefile dependencies for every input file")}, @@ -234,19 +237,6 @@ setup_paths () global_path.add (p); #if !KPATHSEA - /* - Although kpathsea seems nice, it is not universally available - (GNU/Windows). - - Compiling kpathsea seems not possible without - (compiling) a matching tex installation. Apart from the fact - that I cannot get kpathsea compiled for GNU/Windows, another - major problem is that TeX installations may be different on - different clients, so it wouldn't work anyway. While ugly, - this code is simple and effective. - -- jcn - */ - /* Urg: GNU make's $(word) index starts at 1 */ int i = 1; while (global_path.try_add (p + to_str (".") + to_str (i))) @@ -361,6 +351,9 @@ main (int argc, char **argv) case 'Q': find_old_relative_b= true; break; + case 'H': + global_score_header_fields.push (oparser_global_p->optional_argument_ch_C_); + break; case 'I': global_path.push (oparser_global_p->optional_argument_ch_C_); break; diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 2c2f179019..fbef9b808c 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -159,6 +159,7 @@ Paper_outputter::dump_scheme (SCM s) free (c); } } + void Paper_outputter::output_scope (Scope *scope, String prefix) { @@ -233,10 +234,42 @@ Paper_outputter::output_int_def (String k, int v) output_scheme (scm); } - - void Paper_outputter::output_string (SCM str) { *stream_p_ << ly_scm2string (str); } + +void +Paper_outputter::output_score_header_field (String filename, String key, String value) +{ + if (filename != "-") + filename += String (".") + key; + progress_indication (_f ("writing header field %s to %s...", + key, + filename == "-" ? String ("") : filename)); + + ostream* os = open_file_stream (filename); + *os << value; + close_file_stream (os); + progress_indication ("\n"); +} + +void +Paper_outputter::output_score_header_fields (Paper_def *paper) +{ + if (global_score_header_fields.size ()) + { + SCM fields = paper->scope_p_->to_alist (); + String base = paper->base_output_str (); + for (int i = 0; i < global_score_header_fields.size (); i++) + { + String key = paper->global_score_header_fields[i]; + SCM val = gh_assoc (ly_str02scm (key), fields); + String s + if (val != SCM_BOOL_F) + s = ly_scm2string (val); + output_score_header_field (base, key, s); + } + } +} diff --git a/lily/paper-score.cc b/lily/paper-score.cc index f00db3099c..b5f5e2d193 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -67,8 +67,6 @@ Paper_score::calc_breaking () return sol; } - - /* urg. clean me */ @@ -125,10 +123,13 @@ Paper_score::process () outputter_l_->output_scheme (scm); progress_indication ("\n"); + + outputter_l_->output_score_header_fields (paper_l_); + // huh? delete outputter_l_; outputter_l_ = 0; - + if (verbose_global_b) ly_display_scm (scm_gc_stats ()); } diff --git a/lily/paper-stream.cc b/lily/paper-stream.cc index caab11e504..c9454041bf 100644 --- a/lily/paper-stream.cc +++ b/lily/paper-stream.cc @@ -14,21 +14,20 @@ const int MAXLINELEN = 200; -Paper_stream::Paper_stream (String filename) +ostream* +open_file_stream (String filename) { if (filename.length_i () && (filename != "-")) os = new ofstream (filename.ch_C ()); else - // os = new ostream (cout.ostreambuf ()); os = new ostream (cout._strbuf); if (!*os) error (_f ("can't open file: `%s'", filename)); - nest_level = 0; - line_len_i_ = 0; - outputting_comment_b_=false; + return os; } -Paper_stream::~Paper_stream () +void +close_file_stream (ostream* os) { *os << flush; if (!*os) @@ -37,6 +36,19 @@ Paper_stream::~Paper_stream () exit_status_i_ = 1; } delete os; +} + +Paper_stream::Paper_stream (String filename) +{ + os_ = open_file_stream (filename); + nest_level = 0; + line_len_i_ = 0; + outputting_comment_b_=false; +} + +Paper_stream::~Paper_stream () +{ + close_file_stream (os_); assert (nest_level == 0); } @@ -48,7 +60,7 @@ Paper_stream::operator << (String s) { if (outputting_comment_b_) { - *os << *cp; + *os_ << *cp; if (*cp == '\n') { outputting_comment_b_=false; @@ -61,19 +73,19 @@ Paper_stream::operator << (String s) { case '%': outputting_comment_b_ = true; - *os << *cp; + *os_ << *cp; break; case '{': nest_level++; - *os << *cp; + *os_ << *cp; break; case '}': nest_level--; - *os << *cp; + *os_ << *cp; if (nest_level < 0) { - delete os; // we want to see the remains. + delete os_; // we want to see the remains. assert (nest_level>=0); } @@ -81,33 +93,33 @@ Paper_stream::operator << (String s) if (nest_level == 0) break; - *os << '%'; + *os_ << '%'; break_line (); break; case '\n': break_line (); break; case ' ': - *os << ' '; + *os_ << ' '; if (line_len_i_ > MAXLINELEN) break_line (); break; default: - *os << *cp; + *os_ << *cp; break; } } //urg, for debugging only!! - *os << flush; + *os_ << flush; return *this; } void Paper_stream::break_line () { - *os << '\n'; - *os << to_str (' ', nest_level); + *os_ << '\n'; + *os_ << to_str (' ', nest_level); outputting_comment_b_ = false; line_len_i_ = 0; }