From f0ceda71175427f29f36f48c1842751ac3380361 Mon Sep 17 00:00:00 2001 From: hjp Date: Fri, 9 Jul 1999 21:04:43 +0000 Subject: [PATCH] Print list of all error codes if no argument given. --- errno/errno.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/errno/errno.c b/errno/errno.c index ef09e34..8ee3b97 100644 --- a/errno/errno.c +++ b/errno/errno.c @@ -4,7 +4,7 @@ char *cmnd; -void usage(void) { +static void usage(void) { fprintf(stderr, "Usage: %s errno ...\n", cmnd); exit(1); } @@ -15,12 +15,20 @@ int main(int argc, char **argv) { cmnd = argv[0]; - if (argc <= 1) usage(); + if (argc <= 1) { + int e; + for (e = 0;; e++) { + printf("%d\t%s\n", e, strerror(e)); + } + } else { + for (i = 1; i < argc; i++) { + int e = strtoul(argv[i], NULL, 0); - for (i = 1; i < argc; i++) { - int e = strtoul(argv[i], NULL, 0); - - printf("%d\t%s\n", e, strerror(e)); + printf("%d\t%s\n", e, strerror(e)); + } } return 0; } +/* + * vim:sw=4 + */