[hackers] [sbase] Audit logname(1) || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:54:16 +0100 (CET)

commit 683d108387cb8e7ac7fdaa03fab77b41a8ba5d44
Author: FRIGN <dev_AT_frign.de>
Date: Tue Mar 17 00:44:18 2015 +0100

    Audit logname(1)
    
    1) Add usage().
    2) Idiomatic argv0-setter. We don't use arg.h, as we do not process
       flags or arguments.
    3) Remove program-name from eprintf-call. This is done in the eprintf-
       function itself when the DEBUG-define is set.
       We'll activate it by default later.
    4) Add empty line before return.

diff --git a/README b/README
index ecace49..c936841 100644
--- a/README
+++ b/README
_AT_@ -41,7 +41,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
 =*| link yes none
 =*| ln yes none
 =*| logger yes none
-=* logname yes none
+=*| logname yes none
 = ls no (-C), -S, -f, -m, -s, -x
 =*| md5sum non-posix none
 =*| mkdir yes none
diff --git a/logname.c b/logname.c
index f1981a5..11d287b 100644
--- a/logname.c
+++ b/logname.c
_AT_@ -4,17 +4,26 @@
 
 #include "util.h"
 
+static void
+usage(void)
+{
+ eprintf("usage: %s\n", argv0);
+}
+
 int
 main(int argc, char *argv[])
 {
         char *login;
 
- argv0 = argv[0];
- if (argc != 1)
- eprintf("usage: %s\n", argv0);
+ argv0 = argv[0], argc--, argv++;
+
+ if (argc)
+ usage();
+
         if ((login = getlogin()))
                 puts(login);
         else
- eprintf("%s: no login name\n", argv0);
+ eprintf("no login name\n");
+
         return 0;
 }
Received on Tue Mar 24 2015 - 23:54:16 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:11:58 CET