summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-05-09 17:44:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-05-09 17:44:54 +0000
commit049e630e8966eef26be87ff91fe63a2938402e20 (patch)
tree4a358fb90ded6ce3d1ca5bcf0fb35fa3f161a172
parentfb9b4c15068f0da6aeb78d700ed9b8b3fb3e7816 (diff)
back out change that busted how the tree builds
not approved by the right people, not tested by the right people, and work done by people who don't know how to test what they write you know who you are -- stop screwing with things you refuse to test completely.
-rw-r--r--usr.bin/readlink/readlink.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/usr.bin/readlink/readlink.c b/usr.bin/readlink/readlink.c
index 2b2ac7114b4..5c9fb07ed02 100644
--- a/usr.bin/readlink/readlink.c
+++ b/usr.bin/readlink/readlink.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: readlink.c,v 1.21 2006/05/09 17:03:51 ray Exp $
+ * $OpenBSD: readlink.c,v 1.22 2006/05/09 17:44:53 deraadt Exp $
*
* Copyright (c) 1997
* Kenneth Stailey (hereinafter referred to as the author)
@@ -27,20 +27,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <err.h>
#include <limits.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-__dead void usage(void);
-
int
main(int argc, char *argv[])
{
- int ch, n, fflag = 0, nflag = 0;
char buf[PATH_MAX];
+ int n, ch, nflag = 0, fflag = 0;
+ extern int optind;
while ((ch = getopt(argc, argv, "fn")) != -1)
switch (ch) {
@@ -51,24 +50,31 @@ main(int argc, char *argv[])
nflag = 1;
break;
default:
- usage();
+ (void)fprintf(stderr,
+ "usage: readlink [-n] [-f] symlink\n");
+ exit(1);
}
argc -= optind;
argv += optind;
- if (argc != 1)
- usage();
+ if (argc != 1) {
+ fprintf(stderr, "usage: readlink [-n] [-f] symlink\n");
+ exit(1);
+ }
- if (strlen(argv[0]) > PATH_MAX - 1)
- errx(1, "filename longer than PATH_MAX-1 (%d)",
- PATH_MAX - 1);
+ n = strlen(argv[0]);
+ if (n > PATH_MAX - 1) {
+ fprintf(stderr,
+ "readlink: filename longer than PATH_MAX-1 (%d)\n",
+ PATH_MAX - 1);
+ exit(1);
+ }
- if (fflag) {
- if (realpath(argv[0], buf) == NULL)
- err(1, "%s", argv[0]);
- } else {
+ if (fflag)
+ realpath(argv[0], buf);
+ else {
if ((n = readlink(argv[0], buf, sizeof buf-1)) < 0)
- err(1, "%s", argv[0]);
+ exit(1);
buf[n] = '\0';
}
@@ -77,12 +83,3 @@ main(int argc, char *argv[])
putchar('\n');
exit(0);
}
-
-void
-usage(void)
-{
- extern char *__progname;
-
- fprintf(stderr, "usage: %s [-fn] symlink\n", __progname);
- exit(1);
-}