From: David Kastrup Date: Sat, 14 Sep 2013 09:09:18 +0000 (+0200) Subject: Issue 3552: Don't modify lists returned by markup list functions in interpret-markup... X-Git-Tag: release/2.17.27-1~34 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1dc774fbea585861dd3c958f8ae1efa95e5165fe;p=lilypond.git Issue 3552: Don't modify lists returned by markup list functions in interpret-markup-list 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. --- diff --git a/scm/markup.scm b/scm/markup.scm index 69a6ad13ff..64a1139738 100644 --- a/scm/markup.scm +++ b/scm/markup.scm @@ -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)))