use always static for usage and keep usage definition above main

This commit is contained in:
dwts 2014-04-22 16:44:16 +03:00 committed by sin
parent 575b38391c
commit 459161481a
6 changed files with 32 additions and 34 deletions

12
cksum.c
View File

@ -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);
}

2
du.c
View File

@ -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);

11
env.c
View File

@ -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");
}

12
grep.c
View File

@ -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);
}

18
test.c
View File

@ -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);
}

11
yes.c
View File

@ -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);
}