diff --git a/src/ChangeLog b/src/ChangeLog index b4377d41..08d3733e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-12-02 Hrvoje Niksic + + * utils.c (file_merge): If BASE doesn't contain a slash, just + return a copy of FILE. + 2001-12-01 Hrvoje Niksic * ftp.c (getftp): When PWD fails, assume "/". diff --git a/src/utils.c b/src/utils.c index 9edc0934..08e8bbba 100644 --- a/src/utils.c +++ b/src/utils.c @@ -744,9 +744,11 @@ make_directory (const char *directory) } /* Merge BASE with FILE. BASE can be a directory or a file name, FILE - should be a file name. For example, file_merge("/foo/bar", "baz") - will return "/foo/baz". file_merge("/foo/bar/", "baz") will return - "foo/bar/baz". + should be a file name. + + file_merge("/foo/bar", "baz") => "/foo/baz" + file_merge("/foo/bar/", "baz") => "/foo/bar/baz" + file_merge("foo", "bar") => "bar" In other words, it's a simpler and gentler version of uri_merge_1. */ @@ -757,7 +759,7 @@ file_merge (const char *base, const char *file) const char *cut = (const char *)strrchr (base, '/'); if (!cut) - cut = base + strlen (base); + return xstrdup (file); result = (char *)xmalloc (cut - base + 1 + strlen (file) + 1); memcpy (result, base, cut - base);