[hackers] [sbase] Use arg.h as much as possible and add usage() where missing || sin
commit f349dd5987cb1f3a3eda69700c6ac52f9e0f8ade
Author: sin <sin_AT_2f30.org>
Date: Mon Oct 7 17:13:01 2013 +0100
Use arg.h as much as possible and add usage() where missing
Rename eusage() to usage() as well.
diff --git a/nice.c b/nice.c
index e5baeb4..7755b90 100644
--- a/nice.c
+++ b/nice.c
_AT_@ -6,7 +6,7 @@
#include <unistd.h>
#include "util.h"
-static void eusage(void);
+static void usage(void);
int
main(int argc, char **argv)
_AT_@ -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)));
_AT_@ -38,7 +38,7 @@ main(int argc, char **argv)
}
static void
-eusage(void)
+usage(void)
{
eprintf("usage: nice [-n inc] command [options ...]
");
}
diff --git a/printenv.c b/printenv.c
index ddb91ab..b839983 100644
--- a/printenv.c
+++ b/printenv.c
_AT_@ -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...]
", argv0);
+}
+
int
main(int argc, char **argv)
{
char *var;
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
+
if(argc == 1) {
while(*environ)
printf("%s
", *environ++);
diff --git a/renice.c b/renice.c
index 9090ea5..1d60d41 100644
--- a/renice.c
+++ b/renice.c
_AT_@ -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)
_AT_@ -22,7 +22,7 @@ main(int argc, char **argv)
ARGBEGIN {
case 'n':
- adj = EARGF(eusage());
+ adj = EARGF(usage());
break;
case 'g':
which = PRIO_PGRP;
_AT_@ -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++) {
_AT_@ -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 ...
");
}
diff --git a/wc.c b/wc.c
index 4226a44..5b89d40 100644
--- a/wc.c
+++ b/wc.c
_AT_@ -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...]
", argv0);
+}
+
int
main(int argc, char *argv[])
{
_AT_@ -34,7 +40,7 @@ main(int argc, char *argv[])
wflag = true;
break;
default:
- eprintf("usage: %s [-clmw] [files...]
", argv0);
+ usage();
} ARGEND;
if (argc == 0) {
Received on Mon Oct 07 2013 - 18:14:10 CEST
This archive was generated by hypermail 2.3.0
: Mon Oct 07 2013 - 18:24:22 CEST