From 9321b6bd4c982682c3c884785ff43c8c85152087 Mon Sep 17 00:00:00 2001 From: martin-s Date: Fri, 2 Jan 2009 14:30:18 +0000 Subject: [PATCH] Fix:Core:Fixed usage of wordexp in case of no match git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1876 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/plugin.c | 36 +++++++++++++++++++----------------- navit/navit/xmlconfig.c | 10 ++++++---- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/navit/navit/plugin.c b/navit/navit/plugin.c index bf29184..6496f74 100644 --- a/navit/navit/plugin.c +++ b/navit/navit/plugin.c @@ -240,26 +240,28 @@ plugin_new(struct attr *parent, struct attr **attrs) { count=file_wordexp_get_count(we); array=file_wordexp_get_array(we); dbg(2,"expanded to %d words\n",count); - for (i = 0 ; i < count ; i++) { - name=array[i]; - dbg(2,"name[%d]='%s'\n", i, name); - if (! (pl=g_hash_table_lookup(pls->hash, name))) { - pl=plugin_new_from_path(name); - if (! pl) { - dbg(0,"failed to create plugin '%s'\n", name); - continue; + if (count != 1 || file_exists(array[0])) { + for (i = 0 ; i < count ; i++) { + name=array[i]; + dbg(2,"name[%d]='%s'\n", i, name); + if (! (pl=g_hash_table_lookup(pls->hash, name))) { + pl=plugin_new_from_path(name); + if (! pl) { + dbg(0,"failed to create plugin '%s'\n", name); + continue; + } + g_hash_table_insert(pls->hash, plugin_get_name(pl), pl); + pls->list=g_list_append(pls->list, pl); + } else { + pls->list=g_list_remove(pls->list, pl); + pls->list=g_list_append(pls->list, pl); } - g_hash_table_insert(pls->hash, plugin_get_name(pl), pl); - pls->list=g_list_append(pls->list, pl); - } else { - pls->list=g_list_remove(pls->list, pl); - pls->list=g_list_append(pls->list, pl); + plugin_set_active(pl, active); + plugin_set_lazy(pl, lazy); + plugin_set_ondemand(pl, ondemand); } - plugin_set_active(pl, active); - plugin_set_lazy(pl, lazy); - plugin_set_ondemand(pl, ondemand); + file_wordexp_destroy(we); } - file_wordexp_destroy(we); return pl; #endif } diff --git a/navit/navit/xmlconfig.c b/navit/navit/xmlconfig.c index ee962c2..3a1ebec 100644 --- a/navit/navit/xmlconfig.c +++ b/navit/navit/xmlconfig.c @@ -494,10 +494,12 @@ xinclude(GMarkupParseContext *context, const gchar **attribute_names, const gcha we_files=file_wordexp_get_array(we); count=file_wordexp_get_count(we); dbg(1,"%d results\n", count); - for (i = 0 ; i < count ; i++) { - dbg(1,"result[%d]='%s'\n", i, we_files[i]); - doc_new.href=we_files[i]; - parse_file(&doc_new, error); + if (count != 1 || file_exists(we_files[0])) { + for (i = 0 ; i < count ; i++) { + dbg(1,"result[%d]='%s'\n", i, we_files[i]); + doc_new.href=we_files[i]; + parse_file(&doc_new, error); + } } file_wordexp_destroy(we); -- 2.7.4