]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3552: Don't modify lists returned by markup list functions in interpret-markup...
authorDavid Kastrup <dak@gnu.org>
Sat, 14 Sep 2013 09:09:18 +0000 (11:09 +0200)
committerDavid Kastrup <dak@gnu.org>
Wed, 18 Sep 2013 09:27:08 +0000 (11:27 +0200)
This requires either
a) copying any list manually
b) interpreting markup lists right-to-left
c) more complicated and/or non-O(n) algorithms

This patch chooses b).  Modifying the lists is not really appropriate
since the lists may be created by user-written markup commands and any
problems resulting from not expecting modifications of the return
value might be quite hard to debug.

scm/markup.scm

index 69a6ad13ffaf886912531f7704772e34a9fc7025..64a113973880e2f11e4b157aba24b6b368b5469b 100644 (file)
@@ -48,16 +48,13 @@ Example:
 (define-public interpret-markup ly:text-interface::interpret-markup)
 
 (define-public (interpret-markup-list layout props markup-list)
-  ;; This relies on the markup list returned by a markup list command
-  ;; to be modifiable
-  (reverse!
-   (fold
-    (lambda (m prev)
-      (if (markup-command-list? m)
-          (reverse! (apply (car m) layout props (cdr m)) prev)
-          (cons (interpret-markup layout props m) prev)))
-    '()
-    markup-list)))
+  (fold-right
+   (lambda (m prev)
+     (if (markup-command-list? m)
+         (append (apply (car m) layout props (cdr m)) prev)
+         (cons (interpret-markup layout props m) prev)))
+   '()
+   markup-list))
 
 (define-public (prepend-alist-chain key val chain)
   (cons (acons key val (car chain)) (cdr chain)))