From: Patrick McCarty <pnorcks@gmail.com>
Date: Sun, 2 Aug 2009 09:37:41 +0000 (-0700)
Subject: Fix handling of missing stencil expressions
X-Git-Tag: release/2.13.4-1~215
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eb4d92fc2b3eaa7cae8a08b311fa0139f0b2d7b1;p=lilypond.git

Fix handling of missing stencil expressions

I had not tested the case of multiple \book blocks.

For example, in output-ps.scm a warning is assigned for "utf-8-string",
but this assignment persists for the next \book block, which is
undesirable; the assignments are only supposed to be used while the
stencils are being dumped with the outputter.

This patch removes the "missing" stencil expressions from the
output-module when the outputter is closed.
---

diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc
index 3f98b8eb86..d366426093 100644
--- a/lily/paper-outputter.cc
+++ b/lily/paper-outputter.cc
@@ -112,5 +112,14 @@ void
 Paper_outputter::close ()
 {
   if (scm_port_p (file_) == SCM_BOOL_T)
-    scm_close_port (file_);
+    {
+      scm_close_port (file_);
+      /*
+	Remove the "warning" definitions for missing stencil
+	expressions so that we start fresh with the next \book
+	block.  --pmccarty
+      */
+      SCM proc = ly_lily_module_constant ("remove-stencil-warnings");
+      scm_call_1 (proc, output_module_);
+    }
 }
diff --git a/scm/backend-library.scm b/scm/backend-library.scm
index a985cbb487..9fa094f518 100644
--- a/scm/backend-library.scm
+++ b/scm/backend-library.scm
@@ -190,6 +190,8 @@
       scope)))
   (apply string-append (map output-scope scopes)))
 
+(define missing-stencil-list '())
+
 (define-public (backend-testing output-module)
   (define (missing-stencil-expression name)
     (begin
@@ -198,7 +200,16 @@
 
   (map (lambda (x)
 	 (if (not (module-defined? output-module x))
-	     (module-define! output-module x
-			     (lambda* (#:optional y . z)
-			       (missing-stencil-expression x)))))
+	     (begin
+	       (module-define! output-module x
+			       (lambda* (#:optional y . z)
+				 (missing-stencil-expression x)))
+	       (set! missing-stencil-list (append (list x)
+						  missing-stencil-list)))))
        (ly:all-stencil-commands)))
+
+(define-public (remove-stencil-warnings output-module)
+  (for-each
+    (lambda (x)
+      (module-remove! output-module x))
+    missing-stencil-list))