On Feb 09 17:46:51, h...@stare.cz wrote: > Whenever unistd.h declares getopt(3), it also declares > the extern optind and optarg, so files including unistd.h > don't need to declare those themselves, right? > > Jan > > Index: games/fortune/strfile/strfile.c > =================================================================== > RCS file: /cvs/src/games/fortune/strfile/strfile.c,v > retrieving revision 1.29 > diff -u -p -r1.29 strfile.c > --- games/fortune/strfile/strfile.c 4 Jun 2017 13:39:25 -0000 1.29 > +++ games/fortune/strfile/strfile.c 9 Feb 2020 16:23:42 -0000 > @@ -252,8 +252,6 @@ main(int ac, char *av[]) > void > getargs(int argc, char *argv[]) > { > - extern char *optarg; > - extern int optind; > int ch; > > while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) { > Index: games/hunt/hunt/hunt.c > =================================================================== > RCS file: /cvs/src/games/hunt/hunt/hunt.c,v > retrieving revision 1.22 > diff -u -p -r1.22 hunt.c > --- games/hunt/hunt/hunt.c 8 Apr 2017 22:50:41 -0000 1.22 > +++ games/hunt/hunt/hunt.c 9 Feb 2020 16:23:42 -0000 > @@ -85,8 +85,6 @@ int > main(int ac, char **av) > { > int c; > - extern int optind; > - extern char *optarg; > long enter_status; > int option; > struct servent *se; > Index: games/hunt/huntd/driver.c > =================================================================== > RCS file: /cvs/src/games/hunt/huntd/driver.c,v > retrieving revision 1.29 > diff -u -p -r1.29 driver.c > --- games/hunt/huntd/driver.c 21 Jan 2017 08:22:57 -0000 1.29 > +++ games/hunt/huntd/driver.c 9 Feb 2020 16:23:42 -0000 > @@ -80,8 +80,6 @@ main(int ac, char **av) > static fd_set read_fds; > static FLAG first = TRUE; > static FLAG server = FALSE; > - extern int optind; > - extern char *optarg; > extern char *__progname; > int c; > static struct timeval linger = { 0, 0 }; > Index: games/robots/main.c > =================================================================== > RCS file: /cvs/src/games/robots/main.c,v > retrieving revision 1.28 > diff -u -p -r1.28 main.c > --- games/robots/main.c 28 Jun 2019 13:32:52 -0000 1.28 > +++ games/robots/main.c 9 Feb 2020 16:23:42 -0000 > @@ -56,7 +56,6 @@ main(int ac, char *av[]) > int score_err = 0; /* hold errno from score file open */ > int ch; > int ret; > - extern int optind; > char *home; > #ifdef FANCY > char *sp; > Index: regress/lib/libc/db/dbtest.c > =================================================================== > RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v > retrieving revision 1.16 > diff -u -p -r1.16 dbtest.c > --- regress/lib/libc/db/dbtest.c 27 Jul 2017 15:08:37 -0000 1.16 > +++ regress/lib/libc/db/dbtest.c 9 Feb 2020 16:23:48 -0000 > @@ -76,8 +76,6 @@ int XXlineno; /* Fast > breakpoint for > int > main(int argc, char *argv[]) > { > - extern int optind; > - extern char *optarg; > enum S command, state; > DB *dbp; > DBT data, key, keydata; > Index: regress/lib/libc/getaddrinfo/gaitest.c > =================================================================== > RCS file: /cvs/src/regress/lib/libc/getaddrinfo/gaitest.c,v > retrieving revision 1.6 > diff -u -p -r1.6 gaitest.c > --- regress/lib/libc/getaddrinfo/gaitest.c 9 Jun 2009 18:15:08 -0000 > 1.6 > +++ regress/lib/libc/getaddrinfo/gaitest.c 9 Feb 2020 16:23:48 -0000 > @@ -119,8 +119,6 @@ main(argc, argv) > struct addrinfo *res; > int error, i; > char *p, *q; > - extern int optind; > - extern char *optarg; > int c; > char nbuf[10]; > > Index: regress/lib/libc/regex/main.c > =================================================================== > RCS file: /cvs/src/regress/lib/libc/regex/main.c,v > retrieving revision 1.10 > diff -u -p -r1.10 main.c > --- regress/lib/libc/regex/main.c 13 Jul 2016 06:17:11 -0000 1.10 > +++ regress/lib/libc/regex/main.c 9 Feb 2020 16:23:48 -0000 > @@ -41,8 +41,6 @@ main(int argc, char *argv[]) > int c; > int errflg = 0; > register int i; > - extern int optind; > - extern char *optarg; > > progname = argv[0]; > > Index: regress/lib/libutil/fmt_scaled/fmt_test.c > =================================================================== > RCS file: /cvs/src/regress/lib/libutil/fmt_scaled/fmt_test.c,v > retrieving revision 1.15 > diff -u -p -r1.15 fmt_test.c > --- regress/lib/libutil/fmt_scaled/fmt_test.c 16 Mar 2017 02:42:31 -0000 > 1.15 > +++ regress/lib/libutil/fmt_scaled/fmt_test.c 9 Feb 2020 16:23:49 -0000 > @@ -36,8 +36,6 @@ __dead static void usage(int stat) > int > main(int argc, char **argv) > { > - extern char *optarg; > - extern int optind; > int i, ch; > > while ((ch = getopt(argc, argv, "hv")) != -1) { > >
On Feb 09 09:49:35, mill...@openbsd.org wrote: > On Sun, 09 Feb 2020 17:46:51 +0100, Jan Stary wrote: > > > Whenever unistd.h declares getopt(3), it also declares > > the extern optind and optarg, so files including unistd.h > > don't need to declare those themselves, right? > > Correct. Most of those date back from before optind and optarg > were defined for you by unistd.h. So can they be removed now?