From 80d82aa2e18c9937ff30a009ff90a11a5779d323 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:44:33 +0000 Subject: [PATCH] lilypond-1.3.15 --- lily/score-element.cc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lily/score-element.cc b/lily/score-element.cc index b7d6ce8a79..6d3be5981c 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -198,7 +198,7 @@ Score_element::lookup_l () const { Score_element * urg = (Score_element*)this; SCM sz = urg->remove_elt_property ("fontsize"); - int i = (sz != SCM_UNDEFINED) + int i = (gh_number_p (sz)) ? gh_scm2int (sz) : 0; @@ -367,6 +367,9 @@ Score_element::add_dependency (Score_element*e) SCM Score_element::handle_broken_smobs (SCM s, SCM criterion) { + again: + + Score_element *sc = unsmob_element ( s); if (sc) { @@ -402,16 +405,25 @@ Score_element::handle_broken_smobs (SCM s, SCM criterion) /* UGH! breaks on circular lists. */ - gh_set_car_x (s, handle_broken_smobs (gh_car (s), criterion)); - gh_set_cdr_x (s, handle_broken_smobs (gh_cdr (s), criterion)); - - SCM c = gh_cdr(s); - - // gh_list_p () is linear, this is O(1) - bool list = gh_pair_p (c) || c == SCM_EOL; + SCM car = handle_broken_smobs (gh_car (s), criterion); + SCM cdr = gh_cdr (s); - if (gh_car (s) == SCM_UNDEFINED && list) - return c; + if (car == SCM_UNDEFINED + && (gh_pair_p (cdr) || cdr == SCM_EOL)) + { + /* + This is tail-recursion, ie. + + return handle_broken_smobs (cdr, criterion); + + We don't want to rely on the compiler to do this. */ + s = cdr; + goto again; + } + + gh_set_car_x (s, car); + gh_set_cdr_x (s, handle_broken_smobs (cdr, criterion)); + return s; } return s; } -- 2.39.5