From: Reinhold Kainhofer Date: Fri, 9 Sep 2011 16:46:25 +0000 (+0200) Subject: Fix 380: Try to auto-detect cyclic references in header fields X-Git-Tag: release/2.15.12-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=25be0aa5e4481df77568b99357764f5b1ff46ceb;p=lilypond.git Fix 380: Try to auto-detect cyclic references in header fields Inside \fromproperty, simply change the props so that all references to the currently interpreted property point to a function that prints out a warning and returns a null markup, while interpreting the contents of the property. This is a specialized case of the cycle detection, since the hare+ tortoise algorithm does not tell us where the cycle was causes. For properties we have a simple way to detect cyclic dependencies, so we can tell the user which definition caused the problem. --- diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 88a9e9c7aa..803b691215 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1883,6 +1883,14 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction. ;; property ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-markup-command (property-recursive layout props symbol) + (symbol?) + #:category other + "Print out a warning when a header field markup contains some recursive +markup definition." + (ly:warning "Recursive definition of property ~a detected!" symbol) + empty-stencil) + (define-markup-command (fromproperty layout props symbol) (symbol?) #:category other @@ -1905,7 +1913,8 @@ returns an empty markup. @end lilypond" (let ((m (chain-assoc-get symbol props))) (if (markup? m) - (interpret-markup layout props m) + ;; prevent infinite loops by clearing the interpreted property: + (interpret-markup layout (cons (list (cons symbol `(,property-recursive-markup ,symbol))) props) m) empty-stencil))) (define-markup-command (on-the-fly layout props procedure arg)