1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] file_merge: if BASE doesn't contain a slash, just return a copy of FILE.

Published in <sxssnatmh6s.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2001-12-02 13:44:16 -08:00
parent eb3cfe157a
commit f5799945b0
2 changed files with 11 additions and 4 deletions

View 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> 2001-12-01 Hrvoje Niksic <hniksic@arsdigita.com>
* ftp.c (getftp): When PWD fails, assume "/". * ftp.c (getftp): When PWD fails, assume "/".

View File

@ -744,9 +744,11 @@ make_directory (const char *directory)
} }
/* Merge BASE with FILE. BASE can be a directory or a file name, FILE /* 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") should be a file name.
will return "/foo/baz". file_merge("/foo/bar/", "baz") will return
"foo/bar/baz". 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. */ 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, '/'); const char *cut = (const char *)strrchr (base, '/');
if (!cut) if (!cut)
cut = base + strlen (base); return xstrdup (file);
result = (char *)xmalloc (cut - base + 1 + strlen (file) + 1); result = (char *)xmalloc (cut - base + 1 + strlen (file) + 1);
memcpy (result, base, cut - base); memcpy (result, base, cut - base);