]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4609/1: Let nalist_to_alist accept temporary overrides/reverts
authorDavid Kastrup <dak@gnu.org>
Tue, 15 Sep 2015 10:57:17 +0000 (12:57 +0200)
committerDavid Kastrup <dak@gnu.org>
Sun, 20 Sep 2015 13:09:38 +0000 (15:09 +0200)
lily/context-property.cc
lily/nested-property.cc

index 99b16f669b116d3028c738e2532918ae01ae265c..446306cd5d0ec3e6b65f4a816374fbff80d9bc57 100644 (file)
@@ -82,7 +82,11 @@ private:
   // cooked_from_ is the value of alist_ from which the expansion has
   // been done
   SCM cooked_from_;
-  // nested_ is a count of nested overrides in alist_
+  // nested_ is a count of nested overrides in alist_ Or rather: of
+  // entries that must not appear in the cooked list and are
+  // identified by having a "key" that is not a symbol.  Temporary
+  // overrides and reverts also meet that description and have a
+  // nominal key of #t/#f and a value of the original cons cell.
   int nested_;
 
   Grob_properties (SCM alist, SCM based_on) :
@@ -247,7 +251,7 @@ Grob_property_info::matched_pop (SCM cell)
     {
       if (scm_is_eq (scm_car (p), cell))
         {
-          if (scm_is_pair (scm_car (cell)))
+          if (!scm_is_symbol (key))
             props_->nested_--;
           props_->alist_ = partial_list_copy (current_alist, p, scm_cdr (p));
           return;
index 4c79918f09b6abe37e990fcd81348ab710a82c58..7c8b13047d726e8f8d45fc2e44300402e038d31a 100644 (file)
@@ -154,11 +154,20 @@ nalist_to_alist (SCM nalist, int nested)
   SCM copied = SCM_EOL;
   SCM partials = SCM_EOL;
   // partials is a alist of partial overrides
-  for (;;)
+  while (nested)
     {
       SCM elt = scm_car (nalist);
       nalist = scm_cdr (nalist);
       SCM key = scm_car (elt);
+      if (!scm_is_symbol (key))
+        --nested;
+      if (scm_is_bool (key))
+        {
+          if (scm_is_false (key))
+            continue;
+          elt = scm_cdr (elt);
+          key = scm_car (elt);
+        }
       if (scm_is_pair (key))
         // nested override: record for key in partial
         {
@@ -168,23 +177,20 @@ nalist_to_alist (SCM nalist, int nested)
                                   partials);
           else
             scm_set_cdr_x (pair, scm_cons (elt, scm_cdr (pair)));
-          if (!--nested)
-            break;
+          continue;
         }
-      else
-        // plain override: apply any known corresponding partials
+
+      // plain override: apply any known corresponding partials
+      SCM pair = assq_pop_x (key, &partials);
+      if (scm_is_true (pair))
         {
-          SCM pair = assq_pop_x (key, &partials);
-          if (scm_is_true (pair))
-            {
-              SCM value = scm_cdr (elt);
-              for (SCM pp = scm_cdr (pair); scm_is_pair (pp); pp = scm_cdr (pp))
-                value = nested_property_alist (value, scm_cdaar (pp), scm_cdar (pp));
-              copied = scm_acons (key, value, copied);
-            }
-          else
-            copied = scm_cons (elt, copied);
+          SCM value = scm_cdr (elt);
+          for (SCM pp = scm_cdr (pair); scm_is_pair (pp); pp = scm_cdr (pp))
+            value = nested_property_alist (value, scm_cdaar (pp), scm_cdar (pp));
+          copied = scm_acons (key, value, copied);
         }
+      else
+        copied = scm_cons (elt, copied);
     }
   // Now need to work off the remaining partials.  All of them are
   // unique, so we can push them to `copied' after resolving without