sbase

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

commit f349dd5987cb1f3a3eda69700c6ac52f9e0f8ade
parent 5b5f062184fbdbe7754114bbcab537d252e4234b
Author: sin <sin@2f30.org>
Date:   Mon,  7 Oct 2013 17:13:01 +0100

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

Rename eusage() to usage() as well.

Diffstat:
Mnice.c | 10+++++-----
Mprintenv.c | 12++++++++++++
Mrenice.c | 10+++++-----
Mwc.c | 8+++++++-
4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/nice.c b/nice.c @@ -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"); } diff --git a/printenv.c b/printenv.c @@ -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++); diff --git a/renice.c b/renice.c @@ -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"); } diff --git a/wc.c b/wc.c @@ -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) {