sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 459161481a21202d60db2207db49acb85897a0ea
parent 575b38391c9e329645559ed245456e46ba6a41c6
Author: dwts <mr.dwts@gmail.com>
Date:   Tue, 22 Apr 2014 16:44:16 +0300

use always static for usage and keep usage definition above main

Diffstat:
Mcksum.c | 12++++++------
Mdu.c | 2+-
Menv.c | 11+++++------
Mgrep.c | 12++++++------
Mtest.c | 18+++++++++---------
Myes.c | 11+++++------
6 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/cksum.c b/cksum.c @@ -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...]\n", argv0); +} static const unsigned long crctab[] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, @@ -113,8 +118,3 @@ cksum(FILE *fp, const char *s) putchar('\n'); } -void -usage(void) -{ - eprintf("usage: %s [files...]\n", argv0); -} diff --git a/du.c b/du.c @@ -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...]\n", argv0); diff --git a/env.c b/env.c @@ -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...]]\n"); +} int main(int argc, char *argv[]) @@ -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...]]\n"); -} diff --git a/grep.c b/grep.c @@ -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; @@ -25,6 +24,12 @@ static struct plist { struct plist *next; } *phead; +static void +usage(void) +{ + enprintf(Error, "usage: %s [-Ecilnqv] [-e pattern] pattern [files...]\n", argv0); +} + int main(int argc, char *argv[]) { @@ -158,8 +163,3 @@ end: return match; } -void -usage(void) -{ - enprintf(Error, "usage: %s [-Ecilnqv] [-e pattern] pattern [files...]\n", argv0); -} diff --git a/test.c b/test.c @@ -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\n" + " %s [!] [-bcdefgkhLnprSstuwxz] string%s\n", argv0, ket, argv0, ket); +} int main(int argc, char *argv[]) @@ -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\n" - " %s [!] [-bcdefgkhLnprSstuwxz] string%s\n", argv0, ket, argv0, ket); -} diff --git a/yes.c b/yes.c @@ -3,7 +3,11 @@ #include <stdlib.h> #include "util.h" -static void usage(void); +static void +usage(void) +{ + eprintf("usage: %s [string]\n", argv0); +} int main(int argc, char *argv[]) @@ -18,8 +22,3 @@ main(int argc, char *argv[]) return EXIT_FAILURE; /* should not reach */ } -void -usage(void) -{ - eprintf("usage: %s [string]\n", argv0); -}