lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix 380: Try to auto-detect cyclic references in header fields (issu


From: reinhold . kainhofer
Subject: Re: Fix 380: Try to auto-detect cyclic references in header fields (issue 4951073)
Date: Wed, 14 Sep 2011 22:20:42 +0000

Reviewers: J_lowe, hanwenn, joeneeman,

Message:
On 2011/09/13 19:46:52, joeneeman wrote:

http://codereview.appspot.com/4951073/diff/3001/scm/define-markup-commands.scm
File scm/define-markup-commands.scm (right):


http://codereview.appspot.com/4951073/diff/3001/scm/define-markup-commands.scm#newcode1897
scm/define-markup-commands.scm:1897: (interpret-markup layout (cons
(list (list
symbol `(,property-recursive-markup symbol))) props) m)
props is an alist, right?

No, it's a list of alists (for chain-assoc-get), so:

In that case, I think you want
(interpret-markup layout (cons (cons symbol `(,...)) props) m)

The correct code is (notice also the , before "symbol"):

(interpret-markup layout (cons (list (cons symbol
`(,property-recursive-markup ,symbol))) props) m)

The latest patch fixes this, and now I correctly get the warning
messages:

Vorverarbeitung der grafischen Elemente...
Warnung: Recursive definition of property header:title detected!
Ideale Seitenanzahl wird gefunden...


Description:
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.

Unfortunately, it seems that the new function is not correctly assigned
in the properties for now, because there is no warning (but at least
the recursion is broken)...

Please review this at http://codereview.appspot.com/4951073/

Affected files:
  A input/regression/header-cyclic-reference.ly
  M scm/define-markup-commands.scm


Index: input/regression/header-cyclic-reference.ly
diff --git a/input/regression/header-cyclic-reference.ly b/input/regression/header-cyclic-reference.ly
new file mode 100644
index 0000000000000000000000000000000000000000..3508958419c921ac888c50026aa2532b862ad369
--- /dev/null
+++ b/input/regression/header-cyclic-reference.ly
@@ -0,0 +1,12 @@
+\version "2.15.11"
+#(ly:set-option 'warning-as-error #f)
+
+\header {
+  texidoc = "Cyclic references in header fields should cause a warning, but
+not crash LilyPond with an endless loop"
+
+  title = \markup {Cyclic reference to \fromproperty #'header:title }
+}
+\score {
+  { c' d' e' f' }
+}
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index 18728e57d9809de9b1865209cfb5e7677103b59d..1f39ca668ee44fe2a822861d8ee0b32ea04465fe 100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -1863,6 +1863,14 @@ Add padding @var{amount} around @var{arg} in the address@hidden
 ;; 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
@@ -1885,7 +1893,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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]