[hackers] [sbase] use always static for usage and keep usage definition above main || dwts

From: <git_AT_suckless.org>
Date: Tue, 22 Apr 2014 15:49:26 +0200

commit 459161481a21202d60db2207db49acb85897a0ea
Author: dwts <mr.dwts_AT_gmail.com>
Date: Tue Apr 22 16:44:16 2014 +0300

    use always static for usage and keep usage definition above main

diff --git a/cksum.c b/cksum.c
index e762e85..bb2c322 100644
--- a/cksum.c
+++ b/cksum.c
_AT_@ -7,7 +7,12 @@
 #include "util.h"
 
 static void cksum(FILE *, const char *);
-static void usage(void);
+
+static void
+usage(void)
+{
+ eprintf("usage: %s [files...]
", argv0);
+}
 
 static const unsigned long crctab[] = { 0x00000000,
 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
_AT_@ -113,8 +118,3 @@ cksum(FILE *fp, const char *s)
         putchar('
');
 }
 
-void
-usage(void)
-{
- eprintf("usage: %s [files...]
", argv0);
-}
diff --git a/du.c b/du.c
index df7d3c0..304fee1 100644
--- a/du.c
+++ b/du.c
_AT_@ -20,7 +20,7 @@ static bool kflag = false;
 static long du(const char *);
 static void print(long n, char *path);
 
-void
+static void
 usage(void)
 {
         eprintf("usage: %s [-a | -s] [-k] [file...]
", argv0);
diff --git a/env.c b/env.c
index e4d050c..f82c178 100644
--- a/env.c
+++ b/env.c
_AT_@ -8,7 +8,11 @@
 
 extern char **environ;
 
-static void usage(void);
+static void
+usage(void)
+{
+ eprintf("usage: env [-i] [-u name]... [name=value]... [cmd [arg...]]
");
+}
 
 int
 main(int argc, char *argv[])
_AT_@ -39,8 +43,3 @@ main(int argc, char *argv[])
         return EXIT_SUCCESS;
 }
 
-void
-usage(void)
-{
- eprintf("usage: env [-i] [-u name]... [name=value]... [cmd [arg...]]
");
-}
diff --git a/grep.c b/grep.c
index e8f6e79..269ec92 100644
--- a/grep.c
+++ b/grep.c
_AT_@ -12,7 +12,6 @@ enum { Match = 0, NoMatch = 1, Error = 2 };
 
 static void addpattern(const char *);
 static bool grep(FILE *, const char *);
-static void usage(void);
 
 static bool eflag = false;
 static bool vflag = false;
_AT_@ -25,6 +24,12 @@ static struct plist {
         struct plist *next;
 } *phead;
 
+static void
+usage(void)
+{
+ enprintf(Error, "usage: %s [-Ecilnqv] [-e pattern] pattern [files...]
", argv0);
+}
+
 int
 main(int argc, char *argv[])
 {
_AT_@ -158,8 +163,3 @@ end:
         return match;
 }
 
-void
-usage(void)
-{
- enprintf(Error, "usage: %s [-Ecilnqv] [-e pattern] pattern [files...]
", argv0);
-}
diff --git a/test.c b/test.c
index dd8b0be..a66343b 100644
--- a/test.c
+++ b/test.c
_AT_@ -9,7 +9,15 @@
 
 static bool unary(const char *, const char *);
 static bool binary(const char *, const char *, const char *);
-static void usage(void);
+
+static void
+usage(void)
+{
+ const char *ket = (*argv0 == '[') ? " ]" : "";
+
+ eprintf("usage: %s string%s
"
+ " %s [!] [-bcdefgkhLnprSstuwxz] string%s
", argv0, ket, argv0, ket);
+}
 
 int
 main(int argc, char *argv[])
_AT_@ -149,11 +157,3 @@ binary(const char *arg1, const char *op, const char *arg2)
         return false;
 }
 
-void
-usage(void)
-{
- const char *ket = (*argv0 == '[') ? " ]" : "";
-
- eprintf("usage: %s string%s
"
- " %s [!] [-bcdefgkhLnprSstuwxz] string%s
", argv0, ket, argv0, ket);
-}
diff --git a/yes.c b/yes.c
index ebbbdf9..6294c0b 100644
--- a/yes.c
+++ b/yes.c
_AT_@ -3,7 +3,11 @@
 #include <stdlib.h>
 #include "util.h"
 
-static void usage(void);
+static void
+usage(void)
+{
+ eprintf("usage: %s [string]
", argv0);
+}
 
 int
 main(int argc, char *argv[])
_AT_@ -18,8 +22,3 @@ main(int argc, char *argv[])
         return EXIT_FAILURE; /* should not reach */
 }
 
-void
-usage(void)
-{
- eprintf("usage: %s [string]
", argv0);
-}
Received on Tue Apr 22 2014 - 15:49:26 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 22 2014 - 16:00:11 CEST