1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

optional flags must be sorted and enclosed in single brackets,

as style(9) suggests; usage() should be a function; minor KNF fix

ok otto@
This commit is contained in:
sobrado 2007-09-10 07:42:26 +00:00
parent b588fb28ba
commit b2da3940d1

View File

@ -1,5 +1,5 @@
/*
* $OpenBSD: readlink.c,v 1.23 2007/02/12 19:10:08 otto Exp $
* $OpenBSD: readlink.c,v 1.24 2007/09/10 07:42:26 sobrado Exp $
*
* Copyright (c) 1997
* Kenneth Stailey (hereinafter referred to as the author)
@ -34,6 +34,8 @@
#include <string.h>
#include <unistd.h>
static void usage(void);
int
main(int argc, char *argv[])
{
@ -50,23 +52,19 @@ main(int argc, char *argv[])
nflag = 1;
break;
default:
(void)fprintf(stderr,
"usage: readlink [-n] [-f] symlink\n");
exit(1);
usage();
}
argc -= optind;
argv += optind;
if (argc != 1) {
fprintf(stderr, "usage: readlink [-n] [-f] symlink\n");
exit(1);
}
if (argc != 1)
usage();
n = strlen(argv[0]);
if (n > PATH_MAX - 1) {
fprintf(stderr,
"readlink: filename longer than PATH_MAX-1 (%d)\n",
PATH_MAX - 1);
"readlink: filename longer than PATH_MAX-1 (%d)\n",
PATH_MAX - 1);
exit(1);
}
@ -84,3 +82,10 @@ main(int argc, char *argv[])
putchar('\n');
exit(0);
}
static void
usage(void)
{
(void)fprintf(stderr, "usage: readlink [-fn] file\n");
exit(1);
}