From: martin-s Date: Thu, 25 Aug 2011 21:59:05 +0000 (+0000) Subject: Fix:Core:Return useful values in case of wordexp error X-Git-Tag: navit-0.5.0.5194svn~482 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da87bce31288a11182db57aa4e8d72f6a5df0624;p=profile%2Fivi%2Fnavit.git Fix:Core:Return useful values in case of wordexp error git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4713 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/file.c b/navit/navit/file.c index 2ce2358..14324aa 100644 --- a/navit/navit/file.c +++ b/navit/navit/file.c @@ -828,6 +828,7 @@ file_destroy(struct file *f) struct file_wordexp { int err; + char *pattern; wordexp_t we; }; @@ -836,6 +837,7 @@ file_wordexp_new(const char *pattern) { struct file_wordexp *ret=g_new0(struct file_wordexp, 1); + ret->pattern=g_strdup(pattern); ret->err=wordexp(pattern, &ret->we, 0); if (ret->err) dbg(0,"wordexp('%s') returned %d\n", pattern, ret->err); @@ -845,12 +847,16 @@ file_wordexp_new(const char *pattern) int file_wordexp_get_count(struct file_wordexp *wexp) { + if (wexp->error) + return 1; return wexp->we.we_wordc; } char ** file_wordexp_get_array(struct file_wordexp *wexp) { + if (wexp->error) + return &wexp->pattern; return wexp->we.we_wordv; } @@ -859,6 +865,7 @@ file_wordexp_destroy(struct file_wordexp *wexp) { if (! wexp->err) wordfree(&wexp->we); + g_free(wexp->pattern); g_free(wexp); }