]> sjero.net Git - wget/commitdiff
[svn] file_merge: if BASE doesn't contain a slash, just return a copy of FILE.
authorhniksic <devnull@localhost>
Sun, 2 Dec 2001 21:44:16 +0000 (13:44 -0800)
committerhniksic <devnull@localhost>
Sun, 2 Dec 2001 21:44:16 +0000 (13:44 -0800)
Published in <sxssnatmh6s.fsf@florida.arsdigita.de>.

src/ChangeLog
src/utils.c

index b4377d41edee948b039524e82d7a2ad5ee958dcd..08d3733e7c371804c625827fafdf22bf93b196b0 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-02  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * utils.c (file_merge): If BASE doesn't contain a slash, just
+       return a copy of FILE.
+
 2001-12-01  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * ftp.c (getftp): When PWD fails, assume "/".
index 9edc09343282d8d442b986b150c59189111b0268..08e8bbba736681bd489e7decbe6a6ede309a8c6a 100644 (file)
@@ -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);