1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 07:27:59 -08:00

- General changes:

- Remove -? from getopt(3) options, but still keep (or add) -h where applicable
- Replace hardcoded program strings by getprogname(3)

- Specific changes:
- atc(6): this used -? and -u for usage(), remove both from game and manpage
- bcd(6): use __progname instead of getprogname(3), no need to include stdlib.h
- hunt(6): replace fputs(3) by fprintf(3)

OK tb@ after his suggestions
This commit is contained in:
mestre 2016-03-07 12:07:55 +00:00
parent 51015a3ee9
commit 6fa5e1da34
27 changed files with 87 additions and 91 deletions

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: atc.6,v 1.22 2015/11/29 16:04:14 jmc Exp $
.\" $OpenBSD: atc.6,v 1.23 2016/03/07 12:07:55 mestre Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -34,7 +34,7 @@
.\"
.\" Copyright (c) 1986 Ed James. All rights reserved.
.\"
.Dd $Mdocdate: November 29 2015 $
.Dd $Mdocdate: March 7 2016 $
.Dt ATC 6
.Os
.Sh NAME
@ -42,7 +42,7 @@
.Nd air traffic controller game
.Sh SYNOPSIS
.Nm atc
.Op Fl lpqstu?
.Op Fl lpqst
.Op Fl f Ar game
.Op Fl g Ar game
.Op Fl r Ar seed
@ -91,11 +91,6 @@ successfully dealt with.
.It Fl t
Same as
.Fl s .
.It Fl u
Print the usage line and exit.
.It Fl \&?
Same as
.Fl u .
.El
.Sh GOALS
Your goal in

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.27 2016/01/07 16:00:31 tb Exp $ */
/* $OpenBSD: main.c,v 1.28 2016/03/07 12:07:55 mestre Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
@ -71,7 +71,7 @@ main(int argc, char *argv[])
makenoise = 1;
seed = NULL;
while ((ch = getopt(argc, argv, "f:g:lpqr:stu?")) != -1) {
while ((ch = getopt(argc, argv, "f:g:hlpqr:st")) != -1) {
switch (ch) {
case 'f':
case 'g':
@ -93,8 +93,7 @@ main(int argc, char *argv[])
case 't':
f_showscore = 1;
break;
case 'u':
case '?':
case 'h':
default:
f_usage = 1;
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: banner.c,v 1.20 2016/01/07 16:00:31 tb Exp $ */
/* $OpenBSD: banner.c,v 1.21 2016/03/07 12:07:55 mestre Exp $ */
/* $NetBSD: banner.c,v 1.4 1995/04/22 11:55:15 cgd Exp $ */
/*
@ -1034,10 +1034,11 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "width is %s: %s", errstr, optarg);
break;
case '?': case 'h':
case 'h':
default:
(void)fprintf(stderr,
"usage: banner [-w width] message ...\n");
"usage: %s [-w width] message ...\n",
getprogname());
return 1;
}
argc -= optind;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bcd.c,v 1.24 2016/01/08 20:15:15 mestre Exp $ */
/* $OpenBSD: bcd.c,v 1.25 2016/03/07 12:07:55 mestre Exp $ */
/* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */
/*
@ -115,11 +115,11 @@ int decode(char *buf);
int columns = 48;
int
main(int argc, char *argv[])
{
char cardline[1024];
extern char *__progname;
int dflag = 0;
int ch;
@ -135,8 +135,9 @@ main(int argc, char *argv[])
columns = 80;
break;
default:
fprintf(stderr, "usage: bcd [-l] [string ...]\n");
fprintf(stderr, "usage: bcd -d [-l]\n");
fprintf(stderr, "usage: %s [-l] [string ...]\n",
__progname);
fprintf(stderr, "usage: %s -d [-l]\n", __progname);
return 1;
}
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bog.c,v 1.29 2016/01/10 13:18:07 mestre Exp $ */
/* $OpenBSD: bog.c,v 1.30 2016/03/07 12:07:55 mestre Exp $ */
/* $NetBSD: bog.c,v 1.5 1995/04/24 12:22:32 cgd Exp $ */
/*-
@ -97,7 +97,7 @@ main(int argc, char *argv[])
minlength = -1;
tlimit = 180; /* 3 minutes is standard */
while ((ch = getopt(argc, argv, "Bbcdt:w:")) != -1)
while ((ch = getopt(argc, argv, "Bbcdht:w:")) != -1)
switch(ch) {
case 'B':
grid = 5;
@ -119,7 +119,7 @@ main(int argc, char *argv[])
if ((minlength = atoi(optarg)) < 3)
errx(1, "min word length must be > 2");
break;
case '?':
case 'h':
default:
usage();
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bs.c,v 1.38 2016/01/10 14:10:39 mestre Exp $ */
/* $OpenBSD: bs.c,v 1.39 2016/03/07 12:07:55 mestre Exp $ */
/*
* Copyright (c) 1986, Bruce Holloway
* All rights reserved.
@ -1266,7 +1266,7 @@ playagain(void)
__dead void
usage(void)
{
(void) fprintf(stderr, "usage: bs [-b | -s] [-c]\n");
(void) fprintf(stderr, "usage: %s [-b | -s] [-c]\n", getprogname());
(void) fprintf(stderr, "\tWhere the options are:\n");
(void) fprintf(stderr, "\t-b : play a blitz game\n");
(void) fprintf(stderr, "\t-s : play a salvo game\n");

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crib.c,v 1.22 2016/01/07 16:00:32 tb Exp $ */
/* $OpenBSD: crib.c,v 1.23 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $ */
/*-
@ -47,7 +47,7 @@ main(int argc, char *argv[])
if (pledge("stdio rpath tty proc exec", NULL) == -1)
err(1, "pledge");
while ((ch = getopt(argc, argv, "emqr")) != -1)
while ((ch = getopt(argc, argv, "ehmqr")) != -1)
switch (ch) {
case 'e':
explain = TRUE;
@ -61,9 +61,10 @@ main(int argc, char *argv[])
case 'r':
rflag = TRUE;
break;
case '?':
case 'h':
default:
(void) fprintf(stderr, "usage: cribbage [-emqr]\n");
(void) fprintf(stderr, "usage: %s [-emqr]\n",
getprogname());
return 1;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: factor.c,v 1.26 2016/01/07 16:00:32 tb Exp $ */
/* $OpenBSD: factor.c,v 1.27 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */
/*
@ -88,9 +88,9 @@ main(int argc, char *argv[])
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
while ((ch = getopt(argc, argv, "")) != -1) {
while ((ch = getopt(argc, argv, "h")) != -1) {
switch (ch) {
case '?':
case 'h':
default:
usage();
}
@ -286,6 +286,6 @@ pr_bigfact(u_int64_t val) /* Factor this value. */
void
usage(void)
{
(void)fprintf(stderr, "usage: factor [number ...]\n");
(void)fprintf(stderr, "usage: %s [number ...]\n", getprogname());
exit (1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fish.c,v 1.22 2016/01/10 13:35:09 mestre Exp $ */
/* $OpenBSD: fish.c,v 1.23 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: fish.c,v 1.3 1995/03/23 08:28:18 cgd Exp $ */
/*-
@ -95,7 +95,6 @@ main(int argc, char *argv[])
case 'p':
promode = 1;
break;
case '?':
case 'h':
default:
usage();
@ -489,6 +488,6 @@ instructions(void)
void
usage(void)
{
(void)fprintf(stderr, "usage: fish [-p]\n");
(void)fprintf(stderr, "usage: %s [-p]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fortune.c,v 1.52 2016/03/05 11:06:43 tb Exp $ */
/* $OpenBSD: fortune.c,v 1.53 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */
/*-
@ -247,9 +247,9 @@ getargs(int argc, char *argv[])
ignore_case = 0;
#ifdef DEBUG
while ((ch = getopt(argc, argv, "aDefilm:osw")) != -1)
while ((ch = getopt(argc, argv, "aDefhilm:osw")) != -1)
#else
while ((ch = getopt(argc, argv, "aefilm:osw")) != -1)
while ((ch = getopt(argc, argv, "aefhilm:osw")) != -1)
#endif /* DEBUG */
switch(ch) {
case 'a': /* any fortune */
@ -287,7 +287,7 @@ getargs(int argc, char *argv[])
case 'i': /* case-insensitive match */
ignore_case = 1;
break;
case '?':
case 'h':
default:
usage();
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: strfile.c,v 1.27 2016/01/07 16:00:32 tb Exp $ */
/* $OpenBSD: strfile.c,v 1.28 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */
/*-
@ -257,7 +257,7 @@ getargs(int argc, char *argv[])
extern int optind;
int ch;
while ((ch = getopt(argc, argv, "c:iorsx")) != -1) {
while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) {
switch(ch) {
case 'c': /* new delimiting char */
Delimch = *optarg;
@ -281,7 +281,7 @@ getargs(int argc, char *argv[])
case 'x': /* set the rotated bit */
Xflag++;
break;
case '?':
case 'h':
default:
usage();
}
@ -308,7 +308,7 @@ void
usage(void)
{
(void) fprintf(stderr,
"strfile [-iorsx] [-c char] sourcefile [datafile]\n");
"%s [-iorsx] [-c char] sourcefile [datafile]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: unstr.c,v 1.14 2016/01/10 13:35:09 mestre Exp $ */
/* $OpenBSD: unstr.c,v 1.15 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: unstr.c,v 1.3 1995/03/23 08:29:00 cgd Exp $ */
/*-
@ -101,7 +101,7 @@ void
getargs(char *av[])
{
if (!*++av) {
(void) fprintf(stderr, "usage: unstr datafile\n");
(void) fprintf(stderr, "usage: %s datafile\n", getprogname());
exit(1);
}
Infile = *av;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: grdc.c,v 1.25 2016/01/07 16:00:32 tb Exp $ */
/* $OpenBSD: grdc.c,v 1.26 2016/03/07 12:07:56 mestre Exp $ */
/*
*
* Copyright 2002 Amos Shapir. Public domain.
@ -79,7 +79,6 @@ main(int argc, char *argv[])
scrol = 1;
break;
case 'h':
case '?':
default:
usage();
}
@ -233,7 +232,8 @@ main(int argc, char *argv[])
clear();
refresh();
endwin();
fprintf(stderr, "grdc terminated by signal %d\n", sigtermed);
fprintf(stderr, "%s terminated by signal %d\n",
getprogname(), sigtermed);
return 1;
}
} while (n == 0 || nowtv.tv_sec < endtv.tv_sec);
@ -293,6 +293,6 @@ getwinsize(int *wid, int *ht)
void
usage(void)
{
(void)fprintf(stderr, "usage: grdc [-s] [number]\n");
(void)fprintf(stderr, "usage: %s [-s] [number]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hunt.c,v 1.20 2016/01/10 14:10:39 mestre Exp $ */
/* $OpenBSD: hunt.c,v 1.21 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: hunt.c,v 1.8 1998/09/13 15:27:28 hubertf Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@ -141,9 +141,9 @@ main(int ac, char **av)
break;
default:
usage:
fputs("usage: hunt [-bcfmqSs] [-n name] [-p port] "
"[-t team] [-w message] [[-h] host]\n",
stderr);
fprintf(stderr, "usage: %s [-bcfmqSs] [-n name] "
"[-p port] [-t team] [-w message] [[-h] host]\n",
getprogname());
return 1;
}
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: morse.c,v 1.21 2016/01/19 23:21:26 sthen Exp $ */
/* $OpenBSD: morse.c,v 1.22 2016/03/07 12:07:56 mestre Exp $ */
/*
* Copyright (c) 1988, 1993
@ -142,9 +142,10 @@ main(int argc, char *argv[])
case 's':
sflag = 1;
break;
case '?': case 'h':
case 'h':
default:
fprintf(stderr, "usage: morse [-d | -s] [string ...]\n");
fprintf(stderr, "usage: %s [-d | -s] [string ...]\n",
getprogname());
return 1;
}
argc -= optind;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: number.c,v 1.19 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: number.c,v 1.20 2016/03/07 12:07:56 mestre Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@ -85,7 +85,6 @@ main(int argc, char *argv[])
case 'l':
lflag = 1;
break;
case '?':
case 'h':
default:
usage();
@ -328,6 +327,6 @@ pfract(int len)
void
usage(void)
{
(void)fprintf(stderr, "usage: number [-l] [--] [# ...]\n");
(void)fprintf(stderr, "usage: %s [-l] [--] [# ...]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: setup.c,v 1.18 2016/01/10 13:35:10 mestre Exp $ */
/* $OpenBSD: setup.c,v 1.19 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: setup.c,v 1.4 1995/04/24 12:24:41 cgd Exp $ */
/*
@ -77,12 +77,12 @@ main(int argc, char *argv[])
int ch;
char path[PATH_MAX], *prefix;
while ((ch = getopt(argc, argv, "m:")) != -1)
while ((ch = getopt(argc, argv, "hm:")) != -1)
switch(ch) {
case 'm':
monsterfile = optarg;
break;
case '?':
case 'h':
default:
break;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pig.c,v 1.16 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: pig.c,v 1.17 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $ */
/*-
@ -50,9 +50,9 @@ main(int argc, char *argv[])
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
while ((ch = getopt(argc, argv, "")) != -1)
while ((ch = getopt(argc, argv, "h")) != -1)
switch(ch) {
case '?':
case 'h':
default:
usage();
}
@ -117,6 +117,6 @@ pigout(char *buf, int len)
void
usage(void)
{
(void)fprintf(stderr, "usage: pig\n");
(void)fprintf(stderr, "usage: %s\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pom.c,v 1.21 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: pom.c,v 1.22 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: pom.c,v 1.6 1996/02/06 22:47:29 jtc Exp $ */
/*
@ -261,6 +261,7 @@ void
badformat(void)
{
warnx("illegal time format");
(void)fprintf(stderr, "usage: pom [[[[[cc]yy]mm]dd]HH]\n");
(void)fprintf(stderr, "usage: %s [[[[[cc]yy]mm]dd]HH]\n",
getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ppt.c,v 1.16 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: ppt.c,v 1.17 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: ppt.c,v 1.4 1995/03/23 08:35:40 cgd Exp $ */
/*
@ -71,7 +71,7 @@ main(int argc, char **argv)
case 'b':
bflag = 1;
break;
case '?': case 'h':
case 'h':
default:
usage();
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: primes.c,v 1.21 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: primes.c,v 1.22 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $ */
/*
@ -104,9 +104,9 @@ main(int argc, char *argv[])
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
while ((ch = getopt(argc, argv, "")) != -1) {
while ((ch = getopt(argc, argv, "h")) != -1) {
switch (ch) {
case '?':
case 'h':
default:
usage();
}
@ -322,6 +322,6 @@ primes(ubig start, ubig stop)
void
usage(void)
{
(void)fprintf(stderr, "usage: primes [start [stop]]\n");
(void)fprintf(stderr, "usage: %s [start [stop]]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: quiz.c,v 1.28 2016/01/10 13:35:10 mestre Exp $ */
/* $OpenBSD: quiz.c,v 1.29 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */
/*-
@ -68,7 +68,7 @@ main(int argc, char *argv[])
err(1, "pledge");
indexfile = _PATH_QUIZIDX;
while ((ch = getopt(argc, argv, "i:t")) != -1)
while ((ch = getopt(argc, argv, "hi:t")) != -1)
switch(ch) {
case 'i':
indexfile = optarg;
@ -76,7 +76,7 @@ main(int argc, char *argv[])
case 't':
tflag = 1;
break;
case '?':
case 'h':
default:
usage();
}
@ -363,6 +363,6 @@ void
usage(void)
{
(void)fprintf(stderr,
"usage: quiz [-t] [-i file] category1 category2\n");
"usage: %s [-t] [-i file] category1 category2\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: random.c,v 1.19 2016/01/10 13:35:10 mestre Exp $ */
/* $OpenBSD: random.c,v 1.20 2016/03/07 12:07:56 mestre Exp $ */
/* $NetBSD: random.c,v 1.3 1995/04/22 07:44:05 cgd Exp $ */
/*
@ -61,7 +61,7 @@ main(int argc, char *argv[])
unbuffer_output = 1;
break;
default:
case '?': case 'h':
case 'h':
usage();
}
@ -123,6 +123,6 @@ void
usage(void)
{
(void)fprintf(stderr, "usage: random [-er] [denominator]\n");
(void)fprintf(stderr, "usage: %s [-er] [denominator]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.24 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: main.c,v 1.25 2016/03/07 12:07:57 mestre Exp $ */
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
/*
@ -43,7 +43,7 @@
void
usage(void)
{
fprintf(stderr, "usage: robots [-ajrst] [scorefile]\n");
fprintf(stderr, "usage: %s [-ajrst] [scorefile]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: snake.c,v 1.25 2016/02/09 13:41:59 mestre Exp $ */
/* $OpenBSD: snake.c,v 1.26 2016/03/07 12:07:57 mestre Exp $ */
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
/*
@ -171,7 +171,6 @@ main(int argc, char *argv[])
case 't': /* slow terminal */
fast = 0;
break;
case '?':
case 'h':
default:
fprintf(stderr, "usage: %s [-st] [-l length] "

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tetris.c,v 1.29 2016/01/07 16:00:33 tb Exp $ */
/* $OpenBSD: tetris.c,v 1.30 2016/03/07 12:07:57 mestre Exp $ */
/* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */
/*-
@ -356,6 +356,7 @@ onintr(int signo)
void
usage(void)
{
(void)fprintf(stderr, "usage: tetris [-cps] [-k keys] [-l level]\n");
(void)fprintf(stderr, "usage: %s [-cps] [-k keys] "
"[-l level]\n", getprogname());
exit(1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wump.c,v 1.32 2016/01/10 13:35:10 mestre Exp $ */
/* $OpenBSD: wump.c,v 1.33 2016/03/07 12:07:57 mestre Exp $ */
/*
* Copyright (c) 1989, 1993
@ -179,7 +179,6 @@ main(int argc, char *argv[])
errx(1,
"wumpii like extra doors in their caves!");
break;
case '?':
default:
usage();
}
@ -909,8 +908,8 @@ void
usage(void)
{
(void)fprintf(stderr,
"usage: wump [-ho] [-a arrows] [-b bats] [-p pits] "
"[-r rooms] [-t tunnels]\n");
"usage: %s [-ho] [-a arrows] [-b bats] [-p pits] "
"[-r rooms] [-t tunnels]\n", getprogname());
exit(1);
}