From: fred Date: Sun, 24 Mar 2002 19:58:06 +0000 (+0000) Subject: lilypond-0.1.15 X-Git-Tag: release/1.5.59~3866 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4daf1c26d572e4180b9295e7f912080bacadf975;p=lilypond.git lilypond-0.1.15 --- diff --git a/lily/translator-group.cc b/lily/translator-group.cc index c824164d50..29bd652ded 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -80,31 +80,40 @@ Translator_group::find_existing_translator_l (String n, String id) Link_array Translator_group::path_to_acceptable_translator (String type) const { - Link_array retval; - - if (type_str_ == type) - { - retval.push (output_def_l ()->find_translator_l (type)->group_l ()); - } - else for (int i=0; i < accepts_str_arr_.size (); i++) + Link_array accepted_arr; + for (int i=0; i < accepts_str_arr_.size (); i++) { Translator *t = output_def_l ()->find_translator_l (accepts_str_arr_[i]); if (!t || !t->group_l ()) continue; - - Translator_group * g = t->group_l (); + accepted_arr.push (t->group_l()); + } + + + for (int i=0; i < accepted_arr.size (); i++) + if (accepted_arr[i]->type_str_ == type) + { + Link_array retval; + retval.push (accepted_arr[i]); + return retval; + } + + Link_array best_result; + int best_depth= INT_MAX; + for (int i=0; i < accepted_arr.size (); i++) + { + Translator_group * g = accepted_arr[i]; Link_array result = g->path_to_acceptable_translator (type); - if (result.size ()) + if (result.size () && result.size () < best_depth) { - retval.push (output_def_l ()->find_translator_l (type_str_)->group_l ()); - retval.concat (result); - break; + result.insert (g,0); + best_result = result; } } - return retval; + return best_result; } Translator_group* @@ -116,17 +125,12 @@ Translator_group::find_create_translator_l (String n, String id) Link_array path = path_to_acceptable_translator (n); - /* - if path.size () == 1, then - type_str_ == n, but not id == id_str_ - */ - if (path.size () > 1) + if (path.size ()) { - assert (path.size () > 1); Translator_group * current = this; // start at 1. The first one (index 0) will be us. - for (int i=1; i < path.size (); i++) + for (int i=0; i < path.size (); i++) { Translator_group * new_group = path[i]->clone ()->group_l (); current->add (new_group);