prettiness police
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 4 Apr 1994 07:31:05 +0000 (23:31 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 4 Apr 1994 07:31:05 +0000 (23:31 -0800)
SCCS-vsn: usr.bin/logname/logname.c 8.2

usr/src/usr.bin/logname/logname.c

index 8d374fa..9e7da61 100644 (file)
@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright (c) 1991, 1993
+ * Copyright (c) 1991, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
@@ -7,20 +7,24 @@
 
 #ifndef lint
 static char copyright[] =
 
 #ifndef lint
 static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
+"@(#) Copyright (c) 1991, 1993, 1994\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)logname.c  8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)logname.c  8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
+#include <err.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+void usage __P((void));
+
+int
 main(argc, argv)
        int argc;
        char *argv[];
 main(argc, argv)
        int argc;
        char *argv[];
@@ -29,7 +33,7 @@ main(argc, argv)
        char *p;
 
        while ((ch = getopt(argc, argv, "")) != EOF)
        char *p;
 
        while ((ch = getopt(argc, argv, "")) != EOF)
-               switch(ch) {
+               switch (ch) {
                case '?':
                default:
                        usage();
                case '?':
                default:
                        usage();
@@ -37,14 +41,13 @@ main(argc, argv)
        argc -= optind;
        argv += optind;
 
        argc -= optind;
        argv += optind;
 
-       if ((p = getlogin()) == NULL) {
-               (void)fprintf(stderr, "logname: %s\n", strerror(errno));
-               exit(1);
-       }
+       if ((p = getlogin()) == NULL)
+               err(1, NULL);
        (void)printf("%s\n", p);
        exit(0);
 }
 
        (void)printf("%s\n", p);
        exit(0);
 }
 
+void
 usage()
 {
        (void)fprintf(stderr, "usage: logname\n");
 usage()
 {
        (void)fprintf(stderr, "usage: logname\n");