From 41ed9793498916c63d375326ea8c9b3fa1479dd6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 5 Jan 2013 00:44:24 -0600 Subject: Use basename() where appropriate. --- toys/posix/ln.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'toys/posix/ln.c') diff --git a/toys/posix/ln.c b/toys/posix/ln.c index fea6fff2..d69aabf4 100644 --- a/toys/posix/ln.c +++ b/toys/posix/ln.c @@ -47,11 +47,8 @@ void ln_main(void) int rc; char *try = toys.optargs[i]; - if (S_ISDIR(buf.st_mode)) { - new = strrchr(try, '/'); - if (!new) new = try; - new = xmsprintf("%s/%s", dest, new); - } else new = dest; + if (S_ISDIR(buf.st_mode)) new = xmsprintf("%s/%s", dest, basename(try)); + else new = dest; /* Silently unlink the existing target. If it doesn't exist, * then we just move on */ if (toys.optflags & FLAG_f) unlink(new); -- cgit v1.2.3