From 9dba177f0fcfff591da208b07428ae3d45666084 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 25 Jul 2011 12:44:03 +0200 Subject: [PATCH] Change yaz_filepath_resolve for path="" (empty) Applying empty path is equivalent to not passing a path at all or passing just the path ".". --- src/tpath.c | 4 +++- test/test_tpath.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tpath.c b/src/tpath.c index a58bb3a..80dca2d 100644 --- a/src/tpath.c +++ b/src/tpath.c @@ -74,7 +74,9 @@ size_t yaz_filepath_comp(const char **path_p, const char **comp) char *yaz_filepath_resolve(const char *fname, const char *path, const char *base, char *fullpath) { - for(;;) + if (path && *path == '\0') + path = 0; + for (;;) { struct stat stat_buf; size_t slen = 0; diff --git a/test/test_tpath.c b/test/test_tpath.c index 9009949..df1ff0e 100644 --- a/test/test_tpath.c +++ b/test/test_tpath.c @@ -23,7 +23,7 @@ static void tst_tpath(void) YAZ_CHECK(!yaz_filepath_resolve("does_not_exist", ".", 0, fullpath)); YAZ_CHECK(yaz_filepath_resolve("test_tpath", 0, 0, fullpath)); - YAZ_CHECK(!yaz_filepath_resolve("test_tpath", "", 0, fullpath)); + YAZ_CHECK(yaz_filepath_resolve("test_tpath", "", 0, fullpath)); YAZ_CHECK(yaz_filepath_resolve("test_tpath", ".", 0, fullpath)); YAZ_CHECK(!yaz_filepath_resolve("test_tpath", "unknown_dir", 0, fullpath)); -- 1.7.10.4