diff options
author | Rob Landley <rob@landley.net> | 2019-10-21 17:20:34 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-10-21 17:20:34 -0500 |
commit | b301240424c7fed2ca8b836e2c9531d6ec59750d (patch) | |
tree | 20c0b3516bb13a19d4778dbe89d082d17afcb988 /toys | |
parent | 944d818cd97cc5e5d5f710a595405faf075da9d3 (diff) | |
download | toybox-b301240424c7fed2ca8b836e2c9531d6ec59750d.tar.gz |
Remove getdirname(), it's _not_ a drop-in replacement for dirname
(it returns a malloc), and doesn't match the object lifetime of getbasename()
(which always returns some or all of its argument string). The dirname() in
libc modifies its argument string, but that's what posix says to do:
https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/dirname.html
so I guess we can live with it.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/cp.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index bba54809..a843b90a 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -410,11 +410,10 @@ void cp_main(void) } if (destdir) { - char *s = FLAG(D) ? getdirname(src) : getbasename(src); + char *s = FLAG(D) ? dirname(src) : getbasename(src); TT.destname = xmprintf("%s/%s", destname, s); if (FLAG(D)) { - free(s); if (!(s = fileunderdir(TT.destname, destname))) { error_msg("%s not under %s", TT.destname, destname); continue; |