]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/system.cc (uniquify_list): new function
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 15 Jan 2004 19:36:19 +0000 (19:36 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 15 Jan 2004 19:36:19 +0000 (19:36 +0000)
(output_lines): uniquify_list () on all-elements

* input/regression/rest-pitch.ly (texidoc): add rest under beam.

* lily/system.cc (typeset_grob): warn if adding twice.

ChangeLog
input/regression/rest-pitch.ly
lily/include/paper-score.hh
lily/paper-score.cc
lily/system.cc

index 3262ef9298b52bcbd162782875123c2040ad2ec3..b513e8dac27807bf63f1b604b8f202fdae78ef95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2004-01-15  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/system.cc (uniquify_list): new function
+       (output_lines): uniquify_list () on all-elements
+
        * lily/beam.cc (rest_collision_callback): don't move anything if
        staff-position is set.
 
index 61f38fffc4d7cb397982cdb1c90759a421cfb1f8..3269b8996fd3a84eaa7b06f8b6fba1bef69987ec 100644 (file)
@@ -1,24 +1,23 @@
-#(ly:set-option 'old-relative)
 \version "2.1.7"
 \header {
 
 texidoc = "Rests can have pitches--these will be affected by
-transposition and relativization. If a rest has a pitch, rest
-collision will leave it alone."
+transposition and relativization. If a rest has a pitch, rest/rest and
+beam/rest collision resolving will leave it alone."
 
 }
 
     \paper { raggedright= ##t }
 
 \score { \notes\relative c'' 
-{
-   a4\rest b4\rest c4\rest
+        {
+            a4\rest b4\rest c4\rest
 
-<<d \\  d\rest^"rest pitch" >>
-<<d \\  r>>
-  c16 [ d r e] 
-  c16 [ d e\rest^"rest pitch" e] 
-  
-}
-}
+            <<d \\  d\rest^"rest pitch" >>
+            <<d \\  r>>
+            c16 [ d r e] 
+            c16 [ d e\rest^"rest pitch" e] 
+            
+        }
+     }
 
index 831f913e3ebbe2cc2f003b6368144ca3a7949c1d..505a2fc5717fe64cbb5d93b3384a9c9e19ec5ace 100644 (file)
@@ -15,7 +15,7 @@
 #include "lily-proto.hh"
 #include "music-output.hh"
 #include "lily-guile.hh"
-
+#include "protected-scm.hh"
 
 /** all stuff which goes onto paper. notes, signs, symbols in a score
      #Paper_score# contains the items, the columns.
@@ -23,7 +23,7 @@
     */
 class Paper_score : public Music_output
 {
-  SCM main_smob_;
+  Protected_scm main_smob_;
 public:
   Paper_def *paper_;
 
index 0cc8169ede947399a15ca164b3dcf5b0e7702f58..5e31a512ec9d93861b63f6da213f60469e657b4f 100644 (file)
@@ -42,10 +42,13 @@ Paper_score::typeset_line (System *l)
   main_smob_ = gh_cons (l->self_scm (), main_smob_);
   l->pscore_ = this;
 
+#if 0
   /*
     We don't unprotect l->self_scm (), we haven't got any place else to
     protect it from collection.  */
+#endif
 
+  scm_gc_unprotect_object (l->self_scm());
 }
 
 Paper_score::Paper_score (Paper_score const &s)
index a776eeba9a4f5f45c0a5ca78b6fe33a21926263b..ff5239153c4ae652c5fba8faf4f129832de07c76 100644 (file)
@@ -60,6 +60,48 @@ System::spanner_count () const
 }
   
 
+int
+scm_default_compare (const void * a, const void *b)
+{
+  SCM pa = *(SCM *)a;
+  SCM pb = *(SCM *)b;
+
+  if (pa < pb) return -1 ;
+  else if (pa > pb) return 1;
+  else return 0;
+}
+
+/*
+  modify L in place: sort it 
+*/
+
+SCM
+uniquify_list (SCM l)
+{
+  int len = scm_ilength (l);
+  SCM  * arr = new SCM[len];
+  int k = 0;
+  for (SCM s =l ; SCM_NNULLP (s); s = SCM_CDR(s))
+    arr[k++] = SCM_CAR(s);
+
+  assert (k == len);
+  qsort (arr, len, sizeof (SCM), &scm_default_compare);
+
+  k = 0;
+  SCM s =l;
+  for (int i = 0; i < len ; i++)
+    {
+      if (i && arr[i] == arr[i-1])
+       continue;
+
+      SCM_SETCAR(s, arr[i]);      
+      s = SCM_CDR(s);
+    }
+
+  SCM_SETCDR(s, SCM_EOL);
+  
+  return l; 
+}
 
 void
 System::typeset_grob (Grob * elem)
@@ -124,6 +166,21 @@ System::output_lines ()
     }
   handle_broken_dependencies ();
 
+  /*
+    Because the this->get_grob_property (all-elements) contains items
+    in 3 versions, handle_broken_dependencies () will leave duplicated
+    items in all-elements. Strictly speaking this is harmless, but it
+    leads to duplicated symbols in the output. uniquify_list() makes
+    sure that no duplicates are in the list.
+   */
+  for (int i=0; i < broken_intos_.size (); i++)
+    {
+      SCM al = broken_intos_[i]->get_grob_property ("all-elements");
+      al  = uniquify_list (al); 
+    }
+  
+
+  
   if (verbose_global_b)
     progress_indication (_f ("Element count %d.",  count + element_count ()));