From d74b562f508475192b6783b0b2d4dae4e5c2fa93 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 May 2017 23:01:06 -0500 Subject: Move strend() to lib/lib.c --- toys/posix/basename.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'toys/posix/basename.c') diff --git a/toys/posix/basename.c b/toys/posix/basename.c index c123cc79..0436bfe7 100644 --- a/toys/posix/basename.c +++ b/toys/posix/basename.c @@ -23,12 +23,7 @@ void basename_main(void) char *base = basename(*toys.optargs), *suffix = toys.optargs[1]; // chop off the suffix if provided - if (suffix && *suffix) { - long bl = strlen(base), sl = strlen(suffix); - char *s = base + bl - sl; - - if (bl > sl && !strcmp(s, suffix)) *s = 0; - } + if (suffix && *suffix && (suffix = strend(base, suffix))) *suffix = 0; puts(base); } -- cgit v1.2.3