aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-02-13 21:13:05 -0600
committerRob Landley <rob@landley.net>2012-02-13 21:13:05 -0600
commit3e7c25961e945eb3a617aea46791f9b135567e48 (patch)
tree8b9677063d9b814d7054770bc22b17cc578cb3f4 /toys
parent528e3ba874f0d89f5a4d1f8ce8c04adbaa2ec1e4 (diff)
downloadtoybox-3e7c25961e945eb3a617aea46791f9b135567e48.tar.gz
Minor code cleanup and typo fix.
Diffstat (limited to 'toys')
-rw-r--r--toys/basename.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/toys/basename.c b/toys/basename.c
index a6a3bb96..9f228b41 100644
--- a/toys/basename.c
+++ b/toys/basename.c
@@ -37,10 +37,8 @@ void basename_main(void)
// chop off the suffix if provided
if (suffix) {
- int suflen = strlen(suffix);
- int reslen = strlen(base);
- if (suflen < reslen && !strcmp( base+reslen-suflen, suffix))
- base[reslen-suflen] = 0;
+ arg = base + strlen(base) - strlen(suffix);
+ if (arg > base && !strcmp(arg, suffix)) *arg = 0;
}
puts(base);