From: David Kastrup Date: Tue, 15 Sep 2015 10:57:17 +0000 (+0200) Subject: Issue 4609/1: Let nalist_to_alist accept temporary overrides/reverts X-Git-Tag: release/2.19.28-1~5^2~8^2~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=66f2e4d70f2ca06003240100b3305b91ba504354;p=lilypond.git Issue 4609/1: Let nalist_to_alist accept temporary overrides/reverts --- diff --git a/lily/context-property.cc b/lily/context-property.cc index 99b16f669b..446306cd5d 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -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; diff --git a/lily/nested-property.cc b/lily/nested-property.cc index 4c79918f09..7c8b13047d 100644 --- a/lily/nested-property.cc +++ b/lily/nested-property.cc @@ -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