Change yaz_filepath_resolve for path="" (empty)
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 25 Jul 2011 10:44:03 +0000 (12:44 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 25 Jul 2011 10:44:03 +0000 (12:44 +0200)
Applying empty path is equivalent to not passing a path at all or
passing just the path ".".

src/tpath.c
test/test_tpath.c

index a58bb3a..80dca2d 100644 (file)
@@ -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;
index 9009949..df1ff0e 100644 (file)
@@ -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));