From: hanwen <hanwen>
Date: Thu, 19 Feb 2004 20:01:33 +0000 (+0000)
Subject: * scm/output-tex.scm (output-scopes): don't dump fraction exactly.
X-Git-Tag: release/2.1.27~33
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1fac269b1b5903125b38cadd7d60a15e14d1fc1f;p=lilypond.git

* scm/output-tex.scm (output-scopes): don't dump fraction exactly.

* lily/paper-score.cc (process): dump header only once.

* lily/paper-outputter.cc (Paper_outputter): move logic into
Scheme.

* scm/output-tex.scm (output-scopes): new function.
(output-paper-def): new function
(tex-string-def): new function
(symbol->tex-key): new function
---

diff --git a/ChangeLog b/ChangeLog
index e11510c827..4791a61dad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2004-02-19  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+	* scm/output-tex.scm (output-scopes): don't dump fraction exactly.
+
+	* lily/paper-score.cc (process): dump header only once.
+
+	* lily/paper-outputter.cc (Paper_outputter): move logic into
+	Scheme.
+
+	* scm/output-tex.scm (output-scopes): new function.
+	(output-paper-def): new function
+	(tex-string-def): new function
+	(symbol->tex-key): new function
+
+	* scripts/convert-ly.py (conv): add rule for | ~
+
 2004-02-19  Heikki Junes  <hjunes@cc.hut.fi>
 
 	* input/regression/{many}.ly: refresh, trying to guess how
diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile
index 09192b7e5a..a9a3c97fa2 100644
--- a/Documentation/user/GNUmakefile
+++ b/Documentation/user/GNUmakefile
@@ -68,6 +68,7 @@ $(outdir)/lilypond/lilypond.html: $(outdir)/lilypond.texi
 	mkdir -p $(dir $@)
 	$(MAKEINFO) -I$(outdir) --output=$(outdir)/lilypond --html $<
 	$(MAKEINFO) -I$(outdir) --output=$@ --html --no-split --no-headers $<
+	sed -i 's!../lilypond-internals!lilypond-internals/!g' $(outdir)/lilypond.html
 	rm -f $(outdir)/lilypond/*.png $(outdir)/lilypond/*.ly 
 	-ln -f $(outdir)/*.png $(outdir)/*.ly $(outdir)/lilypond/
 
diff --git a/Documentation/user/lilypond.tely b/Documentation/user/lilypond.tely
index 3166eaa8c5..8ca8673cff 100644
--- a/Documentation/user/lilypond.tely
+++ b/Documentation/user/lilypond.tely
@@ -130,7 +130,10 @@ Copyright 1999--2004 by the authors
 @top GNU LilyPond --- The music typesetter
 @c HJJ: Info needs `@top', which is a synonym for `@unnumbered' in TeX.
 
-This is the user manual for GNU LilyPond 2.1.0.
+This is the user manual for GNU LilyPond 2.1.x series.
+@ifhtml
+(See the bottom of this page for the exact version number).
+@end ifhtml
 
 @cindex web site
 
diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely
index a31f1cabce..dad049a905 100644
--- a/Documentation/user/refman.itely
+++ b/Documentation/user/refman.itely
@@ -429,8 +429,7 @@ note splitting (see @ref{Automatic note splitting}).
 
 In this manual: @ref{Automatic note splitting}.
 
-Internals: @internalsref{TieEvent}, @internalsref{NewTieEvent},
-@internalsref{Tie} @c
+Internals: @internalsref{TieEvent}, @internalsref{Tie}.
 
 Examples: if you want less ties created for a chord, see
 @inputfileref{input/test,tie-sparse.ly}.
diff --git a/VERSION b/VERSION
index eda89cd94b..c753c9b86e 100644
--- a/VERSION
+++ b/VERSION
@@ -2,5 +2,5 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=1
 PATCH_LEVEL=25
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn1
 
diff --git a/input/regression/generic-output-property.ly b/input/regression/generic-output-property.ly
index 92f14fe729..95a4fdbf37 100644
--- a/input/regression/generic-output-property.ly
+++ b/input/regression/generic-output-property.ly
@@ -10,16 +10,19 @@ setting the @code{extra-offset} of a grob.
 
 \score{
 	\notes\relative c''{
-	    \applyoutput #(outputproperty-compatibility (make-type-checker 'note-head-interface) 'extra-offset '(2 . 3))
-  	c2
-	c
-	\context Score {
-	    \applyoutput #(outputproperty-compatibility (make-type-checker 'mark-interface) 'extra-offset '(-1 . 4))
-	}
-	\mark A
-	d1
-	\mark \default
-	e
+	    \context Bottom
+	      \applyoutput #(outputproperty-compatibility
+			   (make-type-checker 'note-head-interface)
+			   'extra-offset '(2 . 3))
+	    c2
+	    c
+	    \context Score {
+		\applyoutput #(outputproperty-compatibility (make-type-checker 'mark-interface) 'extra-offset '(-1 . 4))
+	    }
+	    \mark A
+	    d1
+	    \mark \default
+	    e
 }
 \paper{
 	raggedright = ##t
diff --git a/input/regression/instrument-name-markup.ly b/input/regression/instrument-name-markup.ly
index ffd694df1e..4fb745ddaa 100644
--- a/input/regression/instrument-name-markup.ly
+++ b/input/regression/instrument-name-markup.ly
@@ -10,7 +10,7 @@ including alterations. "
 \version "2.1.22"
 
 
-textFlat = \markup {\smaller \semiflat}
+textFlat = \markup {\smaller \flat}
 
 \score {
   \notes \new Staff {
diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc
index 7b24e37cde..e63c0354ac 100644
--- a/lily/accidental-engraver.cc
+++ b/lily/accidental-engraver.cc
@@ -20,12 +20,6 @@
 #include "context.hh"
 #include "protected-scm.hh"
 
-/**
-
-The algorithm for accidentals should be documented, and made
-tweakable.
-
-*/
 
 struct Accidental_entry {
   bool done_;
@@ -259,23 +253,13 @@ Accidental_engraver::process_acknowledged_grobs ()
 	  bool different = num < 0;
 	  num = abs (num);
 
-	  /* see if there's a tie that "changes" the accidental */
-	  /* works because if there's a tie, the note to the left
-	     is of the same pitch as the actual note */
-
+	  /* See if there's a tie that makes the accidental disappear */
 	  Grob *tie_break_reminder = 0;
 	  bool tie_changes = false;
 	  for (int j = 0; j < ties_.size (); j++)
 	    if (support == Tie::head (ties_[j], RIGHT))
 	      {
 		tie_changes = different;
-
-		/* Enable accidentals for broken tie
-
-		We only want an accidental on a broken tie, 
-		if the tie changes the accidental.
-		   
-		Maybe check property noTieBreakForceAccidental? */
 		if (different)
 		  tie_break_reminder = ties_[j];
 		break;
@@ -327,11 +311,11 @@ Accidental_engraver::process_acknowledged_grobs ()
 
 	      a->set_grob_property ("accidentals", accs);
 	      accidentals_[i].accidental_ = a;
- /*
-	We add the accidentals to the support of the arpeggio, so it is put left of the
-	accidentals. 
-	
-      */
+
+	      /*
+		We add the accidentals to the support of the arpeggio,
+		so it is put left of the accidentals.
+	      */
 	      for (int i = 0;  i < left_objects_.size ();  i++)
 		Side_position_interface::add_support (left_objects_[i], a);
 	      for (int i = 0;  i < right_objects_.size ();  i++)
@@ -353,27 +337,13 @@ Accidental_engraver::process_acknowledged_grobs ()
 	  int a = pitch->get_alteration ();
 	  SCM on_s = gh_cons (scm_int2num (o), scm_int2num (n));
 
-	  /*
-	    TODO: Speed this up!
-	    
-	    Perhaps only check translators mentioned in the auto-accidentals?
-	    -rz
-
-	    TODO: profile this.
-	    
-	    I'd be surprised if the impact of this would be
-	    measurable.  Anyway, it seems localsig doesn't change
-	    every time-step, but a set_property() is done every
-	    time. We could save on that, probably.
-
-	    --hwn.
-	    
-	    
-	  */
-
 	  while (origin)
 	    {
+	      /*
+		huh? we set props all the way to the top? 
+	       */
 	      SCM localsig = origin->get_property ("localKeySignature");
+	      bool change = false;
 	      if (tie_changes)
 		{
 		  /*
@@ -382,6 +352,8 @@ Accidental_engraver::process_acknowledged_grobs ()
 		  */
 		  localsig = ly_assoc_front_x
 		    (localsig, on_s, gh_cons (SCM_BOOL_T, barnum));
+
+		  change = true;
 		}
 	      else
 		{
@@ -390,9 +362,13 @@ Accidental_engraver::process_acknowledged_grobs ()
 		    noteheads with the same notename.
 		  */
 		  localsig = ly_assoc_front_x
-		    (localsig, on_s, gh_cons (scm_int2num (a), barnum)); 
+		    (localsig, on_s, gh_cons (scm_int2num (a), barnum));
+
+		  change = true;
 		}
-	      origin->set_property ("localKeySignature",  localsig);
+
+	      if (change)
+		origin->set_property ("localKeySignature",  localsig);
 	      origin = origin->daddy_context_;
 	    }
 	}
diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh
index 0f8ef616f6..14d357664e 100644
--- a/lily/include/paper-outputter.hh
+++ b/lily/include/paper-outputter.hh
@@ -38,20 +38,9 @@ public:
   
   void dump_scheme (SCM);
 
-  void output_int_def (String k, int v);
-  void output_Real_def (String k, Real v);
-  void output_String_def (String k, String v);
-  void output_scope (SCM, String prefix);
-  void output_version ();
-  void output_font_def (int i, String str);
-  void output_font_switch (int i);
-  void output_header ();
-  void output_comment (String s);
-  void output_string (SCM s);
+  void output_metadata (SCM);
+  void output_music_output_def (Music_output_def* odef);
   void output_scheme (SCM scm);
-
-  void write_header_field_to_file (String filename, SCM, SCM);
-  void write_header_fields_to_file (SCM);
 };
 
 #endif // PAPER_OUTPUTTER_HH
diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc
index a504341828..561c830387 100644
--- a/lily/paper-outputter.cc
+++ b/lily/paper-outputter.cc
@@ -26,13 +26,6 @@
 #include "ly-modules.hh"
 
 
-
-/*
-  TODO: this entire class should be implemented at Scheme level.
-
-
-  
- */
 Paper_outputter::Paper_outputter (String name)
 {
   if (safe_global_b)
@@ -43,14 +36,13 @@ Paper_outputter::Paper_outputter (String name)
   file_ = scm_open_file (scm_makfrom0str (name.to_str0 ()),
 			    scm_makfrom0str ("w"));
 
-  /*
-    ugh.
-   */
-  SCM exp = scm_list_n (ly_symbol2scm ("find-dumper"),
-			scm_makfrom0str (output_format_global.to_str0 ()),
-			SCM_UNDEFINED);
+  static SCM find_dumper;
+  if (!find_dumper)
+    find_dumper = scm_c_eval_string ("find-dumper");
 
-  output_func_  = scm_primitive_eval (exp);
+  
+  output_func_ = scm_call_1 (find_dumper,scm_makfrom0str (output_format_global.to_str0 ()));
+  output_scheme (gh_cons (ly_symbol2scm ("top-of-file"), SCM_EOL));
 }
 
 Paper_outputter::~Paper_outputter ()
@@ -59,46 +51,6 @@ Paper_outputter::~Paper_outputter ()
   file_ = SCM_EOL;
 }
 
-
-/*
-  TODO: move this to Scheme  
- */
-void
-Paper_outputter::output_header ()
-{
-  time_t t (time (0));
-  String generate = ctime (&t);
-  generate = generate.left_string (generate.length () - 1) + " " + *tzname;
-  
-  /* Fixed length time stamp */
-  generate = generate + to_string (' ', (50 - generate.length ()) >? 0);
-  
-  /* Fixed length creator string */
-  String creator = gnu_lilypond_version_string ();
-  creator += " (http://lilypond.org)";
-  creator = creator + to_string (' ', (50 - creator.length ()) >? 0);
-  
-  SCM args_scm = scm_list_n (scm_makfrom0str (creator.to_str0 ()),
-			     scm_makfrom0str (generate.to_str0 ()),
-			     SCM_UNDEFINED);
-
-
-  SCM scm = gh_cons (ly_symbol2scm ("header"), args_scm);
-
-  output_scheme (scm);
-}
-
-
-
-void
-Paper_outputter::output_comment (String str)
-{
-  output_scheme (scm_list_n (ly_symbol2scm ("comment"),
-			  scm_makfrom0str ((char*)str.to_str0 ()),
-			  SCM_UNDEFINED)
-		 );
-}
-
 void
 Paper_outputter::output_scheme (SCM scm)
 {
@@ -106,105 +58,26 @@ Paper_outputter::output_scheme (SCM scm)
 }
 
 void
-Paper_outputter::output_scope (SCM mod, String prefix)
+Paper_outputter::output_metadata (SCM scopes)
 {
-  if (!SCM_MODULEP (mod))
-    return ;
+  SCM fields = SCM_EOL;
+  for (int i = dump_header_fieldnames_global.size (); i--;)
+    fields = gh_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
+				     fields);
   
-  SCM al = ly_module_to_alist (mod);
-  for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s))
-    {
-      SCM k = ly_caar (s);
-      SCM v = ly_cdar (s);
-      String s = ly_symbol2string (k);
-      
-      if (gh_string_p (v))
-	{
-	  output_String_def (prefix + s, ly_scm2string (v));
-	}
-      else if (scm_integer_p (v) == SCM_BOOL_T && scm_exact_p (v) == SCM_BOOL_T)
-	{
-	  output_int_def (prefix + s, gh_scm2int (v));	  
-	}
-      else if (gh_number_p (v))
-	{
-	  output_Real_def (prefix + s, gh_scm2double (v));
-	}
-    }
-}
-
-void
-Paper_outputter::output_version ()
-{
-  String id_string = "Engraved by LilyPond";
-  id_string += String_convert::pad_to (String (", ") + version_string (), 40);
-
-  output_String_def ("lilypondtagline", id_string);
-  output_String_def ("LilyPondVersion", version_string ());
-  output_String_def ("lilypondpaperunit", String (INTERNAL_UNIT));  
-}
-
-
-void
-Paper_outputter::output_Real_def (String k, Real v)
-{
-  
-  SCM scm = scm_list_n (ly_symbol2scm ("lily-def"),
-			scm_makfrom0str (k.get_str0 ()),
-			scm_makfrom0str (to_string (v).get_str0 ()),
-			SCM_UNDEFINED);
-  output_scheme (scm);
-}
-
-void
-Paper_outputter::output_String_def (String k, String v)
-{
-  
-  SCM scm = scm_list_n (ly_symbol2scm ("lily-def"),
-		     scm_makfrom0str (k.get_str0 ()),
-		     scm_makfrom0str (v.get_str0 ()),
-		     SCM_UNDEFINED);
-  output_scheme (scm);
-}
-
-void
-Paper_outputter::output_int_def (String k, int v)
-{
-  SCM scm = scm_list_n (ly_symbol2scm ("lily-def"),
-		     scm_makfrom0str (k.get_str0 ()),
-		     scm_makfrom0str (to_string (v).get_str0 ()),
-		     SCM_UNDEFINED);
-  output_scheme (scm);
-}
-
-void
-Paper_outputter::write_header_field_to_file (String filename, SCM key, SCM value)
-{
-  output_scheme (scm_list_n (ly_symbol2scm ("header-to-file"),
-			     scm_makfrom0str (filename.to_str0 ()),
-			     ly_quote_scm (key), value,
+  output_scheme (scm_list_n (ly_symbol2scm ("output-scopes"),
+			     scm_list_n (ly_symbol2scm ("quote"),
+					 scopes, SCM_UNDEFINED),
+			     scm_list_n (ly_symbol2scm ("quote"),
+					 fields, SCM_UNDEFINED),
+			     scm_makfrom0str (basename_.to_str0 ()), 
 			     SCM_UNDEFINED));
 }
 
+
 void
-Paper_outputter::write_header_fields_to_file (SCM mod)
+Paper_outputter::output_music_output_def (Music_output_def* odef)
 {
-  if (ly_module_p (mod)&&
-      dump_header_fieldnames_global.size ())
-    {
-      SCM fields = ly_module_to_alist (mod);
-      for (int i = 0; i < dump_header_fieldnames_global.size (); i++)
-	{
-	  String key = dump_header_fieldnames_global[i];
-	  SCM val = gh_assoc (ly_symbol2scm (key.to_str0 ()), fields);
-	  String s;
-	  /* Only write header field to file if it exists */
-	  if (gh_pair_p (val) && gh_string_p (ly_cdr (val)))
-	    {
-	      s = ly_scm2string (ly_cdr (val));
-	      /* Always write header field file, even if string is empty ... */
-	      write_header_field_to_file (basename_ , ly_car (val), ly_cdr (val));
-	    }
-	}
-    }
+  output_scheme (scm_list_n (ly_symbol2scm ("output-paper-def"),
+			     odef->self_scm (), SCM_UNDEFINED));
 }
diff --git a/lily/paper-score.cc b/lily/paper-score.cc
index 31f2dd7a63..202a16080a 100644
--- a/lily/paper-score.cc
+++ b/lily/paper-score.cc
@@ -81,7 +81,8 @@ Paper_score::process (String outname)
   progress_indication (_ ("Preprocessing graphical objects...") + " ");
 
   /*
-    Be sure to set breakability on first & last column.
+    Check out why we need this - removing gives assertion failures
+    down the road.
    */
   { /* doubly, also done in Score_engraver */
     Link_array<Grob> pc (system_->columns ());
@@ -89,30 +90,33 @@ Paper_score::process (String outname)
     pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
     pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
   }
+
   system_->pre_processing ();
  
   Array<Column_x_positions> breaking = calc_breaking ();
   system_->break_into_pieces (breaking);
   
   outputter_ = paper_->get_paper_outputter (outname);
-  outputter_->output_header ();
-  outputter_->output_version ();
 
   progress_indication ("\n");
 
-  if (global_input_file->header_)
-    {
-      outputter_->output_scope (global_input_file->header_, "lilypond");
-      outputter_->write_header_fields_to_file (global_input_file->header_);
-    }
-  
+  SCM scopes = SCM_EOL;
+
+  /*
+    Last one first.
+   */
   if (header_)
     {
-      outputter_->output_scope (header_, "lilypond");
-      outputter_->write_header_fields_to_file (header_);
+      scopes = scm_cons (header_, scopes);
     }
 
-  outputter_->output_scope (paper_->scope_, "lilypondpaper");
+  if (global_input_file->header_ && global_input_file->header_ != header_)
+    {
+      scopes = scm_cons (global_input_file->header_, scopes);
+    }
+  
+  outputter_->output_metadata (scopes);
+  outputter_->output_music_output_def (paper_);
 
   SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
   outputter_->output_scheme (scm);
diff --git a/lily/parser.yy b/lily/parser.yy
index a7ba07ef8b..99d5e8feb4 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -437,7 +437,7 @@ toplevel_expression:
 		SCM outname = scm_makfrom0str (p.to_string ().to_str0());
 
 		for (int i=0; i < sc->defs_.size (); i++)
-			default_rendering (sc->music_, sc->defs_[i]->self_scm(),head, outname);
+			default_rendering (sc->music_, sc->defs_[i]->self_scm(), head, outname);
 
 		if (sc->defs_.is_empty ())
 		{
diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly
index 736fef3a87..69510dbb9d 100644
--- a/ly/declarations-init.ly
+++ b/ly/declarations-init.ly
@@ -49,11 +49,6 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
     pt = #(/  in 72.27)
     cm = #(* 10 mm)
 
-    texsetting = ""
-    pssetting = ""
-    scmsetting = "(lilyponddefs.ps) findlibfile {exch pop //systemdict /run get exec} { /undefinedfilename signalerror } ifelse\n"% UGH. 
-
-
     #(define font-defaults
       '((font-family . music)
 	(font-shape . upright)
diff --git a/ly/init.ly b/ly/init.ly
index 5894ad2c70..0b9331dd19 100644
--- a/ly/init.ly
+++ b/ly/init.ly
@@ -17,14 +17,16 @@
 
 
 %%
-%% above message is to compensate for look ahead of the parser.
+%% above and below message is to compensate for look ahead of the parser.
 %%
 
 #(if (and (ly:get-option 'old-relative)
       (not (ly:get-option 'old-relative-used)))
   (ly:warn (string-append
 	    "\n"
-	    input-file-name ": old relative compatibility was not used.")))
+	    input-file-name ": old relative compatibility was not used."
+	)))% there is a problem at the end of the input file
+
 
 
 #(if (ly:get-option 'verbose)
diff --git a/scm/output-tex.scm b/scm/output-tex.scm
index 2128cec4fe..b1b289fdc9 100644
--- a/scm/output-tex.scm
+++ b/scm/output-tex.scm
@@ -13,6 +13,7 @@
 	     (ice-9 string-fun)
 	     (ice-9 format)
 	     (guile)
+	     (srfi srfi-13)
 	     (lily)
 	     )
 
@@ -58,6 +59,73 @@
 (define (unknown) 
   "%\n\\unknown\n")
 
+(define (symbol->tex-key sym)
+  (regexp-substitute/global
+   #f "_" (output-tex-string (symbol->string sym)) 'pre "X" 'post) )
+
+(define (tex-string-def prefix key str)
+  (if (equal? "" (sans-surrounding-whitespace (output-tex-string str)))
+      (string-append "\\let\\" prefix (symbol->tex-key key) "\\undefined%\n")
+      (string-append "\\def\\" prefix (symbol->tex-key key) "{"  (output-tex-string str) "}%\n")
+      ))
+
+(define (output-paper-def pd)
+  (apply
+   string-append
+   (module-map
+    (lambda (sym var)
+      (let
+	  ((val (variable-ref var))
+	   (key (symbol->tex-key sym))
+	   )
+
+	(cond
+	 ((string? val)
+	  (tex-string-def "lilypondpaper" sym val))
+	 ((number? val)
+	  (string-append "\\def\\lilypondpaper" key "{"
+			 (if (integer? val)
+			     (number->string val)
+			     (number->string (exact->inexact val)))
+			 "}%\n"))
+	 (else ""))
+	))
+      
+    (ly:output-def-scope pd))
+  ))
+
+(define (output-scopes scopes fields basename)
+  (define (output-scope scope)
+    (apply
+     string-append
+     (module-map
+     (lambda (sym var)
+       (let
+	   ((val (variable-ref var))
+	    (tex-key (symbol->string sym))
+	   )
+
+	 (cond
+	  ((memq sym fields)
+	     (header-to-file basename sym val))
+	  ((string? val)
+	   (tex-string-def "lilypond" sym val) )
+	  ((number? val)
+	   (string-append "\\def\\" tex-key "{"
+			  (if (integer? val)
+			      (number->string val)
+			      (number->string (exact->inexact val)))
+			      "}"))
+	  (else "") )
+
+	 ))
+     scope)
+    ))
+  
+  (apply string-append
+   (map output-scope scopes)) )
+
+
 (define (select-font name-mag-pair)
   (let*
       (
@@ -85,6 +153,13 @@
 	
 	(string-append "\\" (cddr c)))))
 
+(define (top-of-file)
+  (comment
+   (string-append
+    "generated by LilyPond "
+    (lilypond-version) " (http://lilypond.org)." )
+   ))
+
 (define (blank)
   "")