Use arg.h as much as possible and add usage() where missing

Rename eusage() to usage() as well.
This commit is contained in:
sin 2013-10-07 17:13:01 +01:00
parent 5b5f062184
commit f349dd5987
4 changed files with 29 additions and 11 deletions

10
nice.c
View File

@ -6,7 +6,7 @@
#include <unistd.h>
#include "util.h"
static void eusage(void);
static void usage(void);
int
main(int argc, char **argv)
@ -15,15 +15,15 @@ main(int argc, char **argv)
ARGBEGIN {
case 'n':
val = estrtol(EARGF(eusage()), 10);
val = estrtol(EARGF(usage()), 10);
break;
default:
eusage();
usage();
break;
} ARGEND;
if(argc == 0)
eusage();
usage();
errno = 0;
nice((int)MAX(INT_MIN, MIN(val, INT_MAX)));
@ -38,7 +38,7 @@ main(int argc, char **argv)
}
static void
eusage(void)
usage(void)
{
eprintf("usage: nice [-n inc] command [options ...]\n");
}

View File

@ -1,14 +1,26 @@
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
extern char **environ;
static void
usage(void)
{
eprintf("usage: %s [variable...]\n", argv0);
}
int
main(int argc, char **argv)
{
char *var;
ARGBEGIN {
default:
usage();
} ARGEND;
if(argc == 1) {
while(*environ)
printf("%s\n", *environ++);

View File

@ -11,7 +11,7 @@
static int strtop(const char *);
static bool renice(int, int, long);
static void eusage(void);
static void usage(void);
int
main(int argc, char **argv)
@ -22,7 +22,7 @@ main(int argc, char **argv)
ARGBEGIN {
case 'n':
adj = EARGF(eusage());
adj = EARGF(usage());
break;
case 'g':
which = PRIO_PGRP;
@ -34,12 +34,12 @@ main(int argc, char **argv)
which = PRIO_USER;
break;
default:
eusage();
usage();
break;
} ARGEND;
if(argc == 0 || !adj)
eusage();
usage();
val = estrtol(adj, 10);
for(i = 0; i < argc; i++) {
@ -112,7 +112,7 @@ renice(int which, int who, long adj)
}
static void
eusage(void)
usage(void)
{
eprintf("renice -n inc [-g | -p | -u] ID ...\n");
}

8
wc.c
View File

@ -14,6 +14,12 @@ static bool wflag = false;
static char cmode = 0;
static long tc = 0, tl = 0, tw = 0;
static void
usage(void)
{
eprintf("usage: %s [-clmw] [files...]\n", argv0);
}
int
main(int argc, char *argv[])
{
@ -34,7 +40,7 @@ main(int argc, char *argv[])
wflag = true;
break;
default:
eprintf("usage: %s [-clmw] [files...]\n", argv0);
usage();
} ARGEND;
if (argc == 0) {