]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3746: Fix unfold-repeats-fully with alternatives
authorDavid Kastrup <dak@gnu.org>
Sun, 22 Dec 2013 09:33:31 +0000 (10:33 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 28 Dec 2013 08:50:07 +0000 (09:50 +0100)
When fewer alternatives than repeats are given, the _first_ alternative
needs to get reused (the previous code wrongly used the last one).

scm/music-functions.scm

index 592cff33c320ab0173e4ca319fa068f75ba0c829..c094ebfa40345d3cd839a77a54408e45b019d2df 100644 (file)
@@ -390,19 +390,17 @@ beats to be distinguished."
      (and (music-is-of-type? m 'unfolded-repeated-music)
           (make-sequential-music
            (ly:music-deep-copy
-            (let loop ((n (ly:music-property m 'repeat-count))
-                       (alts (ly:music-property m 'elements))
-                       (body (ly:music-property m 'element)))
+            (let ((n (ly:music-property m 'repeat-count))
+                  (alts (ly:music-property m 'elements))
+                  (body (ly:music-property m 'element)))
               (cond ((<= n 0) '())
-                    ((null? alts)
-                     (cons body (loop (1- n) alts body)))
+                    ((null? alts) (make-list n body))
                     (else
-                     (cons* body (car alts)
-                            (loop (1- n)
-                                  (if (pair? (cdr alts))
-                                      (cdr alts)
-                                      alts)
-                                  body)))))))))
+                     (concatenate
+                      (zip (make-list n body)
+                           (append! (make-list (max 0 (- n (length alts)))
+                                               (car alts))
+                                    alts))))))))))
    (unfold-repeats music)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;