summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-08-17 21:25:02 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-08-17 21:25:02 +0000
commit10e5cadf726aa1983d5356a264d2c5724c1e517d (patch)
tree57322953a92d6bdaa1ce9da8a40d3421b9947fb8 /usr.bin
parente63187eca56a3ad82e60da45f9367e9665e9da64 (diff)
Don't call getopt(3) since a) there are not switches and b) '-' is
a perfectly reasonable character to have in a pathname.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/basename/basename.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/usr.bin/basename/basename.c b/usr.bin/basename/basename.c
index 2f335b78936..efa4218004e 100644
--- a/usr.bin/basename/basename.c
+++ b/usr.bin/basename/basename.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basename.c,v 1.2 1996/06/26 05:31:37 deraadt Exp $ */
+/* $OpenBSD: basename.c,v 1.3 1997/08/17 21:25:01 millert Exp $ */
/* $NetBSD: basename.c,v 1.9 1995/09/02 05:29:46 jtc Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)basename.c 8.4 (Berkeley) 5/4/95";
#endif
-static char rcsid[] = "$OpenBSD: basename.c,v 1.2 1996/06/26 05:31:37 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: basename.c,v 1.3 1997/08/17 21:25:01 millert Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -61,21 +61,13 @@ main(argc, argv)
char **argv;
{
char *p;
- int ch;
setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "")) != -1)
- switch(ch) {
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 1 && argc != 2)
+ if (argc != 2 && argc != 3)
usage();
+ argc--;
+ argv++;
/*
* (1) If string is // it is implementation defined whether steps (2)
@@ -88,9 +80,8 @@ main(argc, argv)
for (p = *argv;; ++p) {
if (!*p) {
if (p > *argv)
- (void)printf("/\n");
- else
- (void)printf("\n");
+ (void)putchar('/');
+ (void)putchar('\n');
exit(0);
}
if (*p != '/')
@@ -135,7 +126,7 @@ main(argc, argv)
p[off] = '\0';
}
}
- (void)printf("%s\n", p);
+ (void)puts(p);
exit(0);
}