summaryrefslogtreecommitdiffstats
path: root/usr.bin/pr/egetopt.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-06-21 10:14:57 +0000
committermarkm <markm@FreeBSD.org>2002-06-21 10:14:57 +0000
commitfc82eac8d1c9cddfbc8b7085045a2fe83ce99ea5 (patch)
tree342df25149a7f051a1f6c39089bc49f8be0ff27d /usr.bin/pr/egetopt.c
parent3cb15a07730691698451fea4fb50c24bfdeb382f (diff)
downloadFreeBSD-src-fc82eac8d1c9cddfbc8b7085045a2fe83ce99ea5.zip
FreeBSD-src-fc82eac8d1c9cddfbc8b7085045a2fe83ce99ea5.tar.gz
Modernise this code by rounding up the usual suspects: register keyword,
consts, ANSIfication of functions, proper use of __FBSDID() and so on. This commit is non-functional from a code-execution perspective, but pr(1) now compiles WARNS=6 clean.
Diffstat (limited to 'usr.bin/pr/egetopt.c')
-rw-r--r--usr.bin/pr/egetopt.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/usr.bin/pr/egetopt.c b/usr.bin/pr/egetopt.c
index dd5bbbd..47dd8a1 100644
--- a/usr.bin/pr/egetopt.c
+++ b/usr.bin/pr/egetopt.c
@@ -35,9 +35,14 @@
* SUCH DAMAGE.
*/
+#if 0
#ifndef lint
static char sccsid[] = "@(#)egetopt.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
+#endif
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
#include <ctype.h>
#include <stdio.h>
@@ -64,18 +69,16 @@ int eoptopt; /* character checked for validity */
char *eoptarg; /* argument associated with option */
#define BADCH (int)'?'
-#define EMSG ""
+
+static char emsg[] = "";
int
-egetopt(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
+egetopt(int nargc, char * const *nargv, const char *ostr)
{
- static char *place = EMSG; /* option letter processing */
- register char *oli; /* option letter list index */
+ static char *place = emsg; /* option letter processing */
+ char *oli; /* option letter list index */
static int delim; /* which option delimeter */
- register char *p;
+ char *p;
static char savec = '\0';
if (savec != '\0') {
@@ -89,7 +92,7 @@ egetopt(nargc, nargv, ostr)
*/
if ((eoptind >= nargc) ||
((*(place = nargv[eoptind]) != '-') && (*place != '+'))) {
- place = EMSG;
+ place = emsg;
return (EOF);
}
@@ -99,7 +102,7 @@ egetopt(nargc, nargv, ostr)
* found "--"
*/
++eoptind;
- place = EMSG;
+ place = emsg;
return (EOF);
}
}
@@ -128,7 +131,7 @@ egetopt(nargc, nargv, ostr)
eoptarg = place-1;
if (*p == '\0') {
- place = EMSG;
+ place = emsg;
++eoptind;
} else {
place = p;
@@ -192,7 +195,7 @@ egetopt(nargc, nargv, ostr)
/*
* no arg, but IS required
*/
- place = EMSG;
+ place = emsg;
if (eopterr) {
if (!(p = strrchr(*nargv, '/')))
p = *nargv;
@@ -209,7 +212,7 @@ egetopt(nargc, nargv, ostr)
*/
eoptarg = nargv[eoptind];
}
- place = EMSG;
+ place = emsg;
++eoptind;
return (eoptopt);
}
OpenPOWER on IntegriCloud