summaryrefslogtreecommitdiffstats
path: root/usr.bin/checknr
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2002-02-27 15:49:07 +0000
committerdwmalone <dwmalone@FreeBSD.org>2002-02-27 15:49:07 +0000
commit3de45f43acf9799d3a14d5eb07e6978995801974 (patch)
tree09b54c0420c1270929a7449f18646fede99c5329 /usr.bin/checknr
parent27b6691da301de473d5e24f7e53230d7bcb07b56 (diff)
downloadFreeBSD-src-3de45f43acf9799d3a14d5eb07e6978995801974.zip
FreeBSD-src-3de45f43acf9799d3a14d5eb07e6978995801974.tar.gz
1) Don't use -Wall in Makefile.
2) Don't compile vendor ID. 3) WARNS=4 fixes (constness, make a global local to avoid shadowing, unused parameters, rename local to avoid shadowing, remove junk after #endif) 4) remove some "register"s.
Diffstat (limited to 'usr.bin/checknr')
-rw-r--r--usr.bin/checknr/Makefile2
-rw-r--r--usr.bin/checknr/checknr.c64
2 files changed, 34 insertions, 32 deletions
diff --git a/usr.bin/checknr/Makefile b/usr.bin/checknr/Makefile
index 85e4c48..8a47b59 100644
--- a/usr.bin/checknr/Makefile
+++ b/usr.bin/checknr/Makefile
@@ -1,6 +1,6 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
+# $FreeBSD$
PROG= checknr
-CFLAGS+=-Wall
.include <bsd.prog.mk>
diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c
index 743ed04..24e04f7 100644
--- a/usr.bin/checknr/checknr.c
+++ b/usr.bin/checknr/checknr.c
@@ -37,9 +37,14 @@ static const char copyright[] =
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
+#if 0
#ifndef lint
-static const char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
+#endif
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
/*
* checknr: check an nroff/troff input file for matching macro calls.
@@ -58,12 +63,12 @@ static const char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93";
#define MAXCMDS 500 /* Max number of commands known */
void addcmd __P((char *));
-void addmac __P((char *));
-int binsrch __P((char *));
+void addmac __P((const char *));
+int binsrch __P((const char *));
void checkknown __P((char *));
void chkcmd __P((char *, char *));
void complain __P((int));
-int eq __P((char *, char *));
+int eq __P((const char *, const char *));
void nomatch __P((char *));
void pe __P((int));
void process __P((FILE *));
@@ -85,8 +90,8 @@ int stktop;
* The kinds of opening and closing brackets.
*/
struct brstr {
- char *opbr;
- char *clbr;
+ const char *opbr;
+ const char *clbr;
} br[MAXBR] = {
/* A few bare bones troff commands */
#define SZ 0
@@ -143,7 +148,7 @@ struct brstr {
* All commands known to nroff, plus macro packages.
* Used so we can complain about unrecognized commands.
*/
-char *knowncmds[MAXCMDS] = {
+const char *knowncmds[MAXCMDS] = {
"$c", "$f", "$h", "$p", "$s", "(b", "(c", "(d", "(f", "(l", "(q", "(t",
"(x", "(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x", ")z", "++",
"+c", "1C", "1c", "2C", "2c", "@(", "@)", "@C", "@D", "@F", "@I", "@M",
@@ -178,8 +183,7 @@ char *knowncmds[MAXCMDS] = {
};
int lineno; /* current line number in input file */
-char line[256]; /* the current line */
-char *cfilename; /* name of current file */
+const char *cfilename; /* name of current file */
int nfiles; /* number of files to process */
int fflag; /* -f: ignore \f */
int sflag; /* -s: ignore \s */
@@ -211,10 +215,8 @@ char **argv;
for (i=0; br[i].opbr; i++)
;
for (cp=argv[1]+3; cp[-1]; cp += 6) {
- br[i].opbr = malloc(3);
- strncpy(br[i].opbr, cp, 2);
- br[i].clbr = malloc(3);
- strncpy(br[i].clbr, cp+3, 2);
+ br[i].opbr = strncpy(malloc(3), cp, 2);
+ br[i].clbr = strncpy(malloc(3), cp+3, 2);
addmac(br[i].opbr); /* knows pairs are also known cmds */
addmac(br[i].clbr);
i++;
@@ -280,9 +282,10 @@ void
process(f)
FILE *f;
{
- register int i, n;
+ int i, n;
char mac[5]; /* The current macro or nroff command */
int pl;
+ static char line[256]; /* the current line */
stktop = -1;
for (lineno = 1; fgets(line, sizeof line, f); lineno++) {
@@ -404,10 +407,10 @@ int i;
void
chkcmd(line, mac)
-char *line;
+char *line __unused;
char *mac;
{
- register int i;
+ int i;
/*
* Check to see if it matches top of stack.
@@ -444,7 +447,7 @@ void
nomatch(mac)
char *mac;
{
- register int i, j;
+ int i, j;
/*
* Look for a match further down on stack
@@ -488,19 +491,19 @@ char *mac;
/* eq: are two strings equal? */
int
eq(s1, s2)
-char *s1, *s2;
+const char *s1, *s2;
{
return (strcmp(s1, s2) == 0);
}
/* print the first part of an error message, given the line number */
void
-pe(lineno)
-int lineno;
+pe(linen)
+int linen;
{
if (nfiles > 1)
printf("%s: ", cfilename);
- printf("%d: ", lineno);
+ printf("%d: ", linen);
}
void
@@ -556,14 +559,14 @@ char *line;
*/
void
addmac(mac)
-char *mac;
+const char *mac;
{
- register char **src, **dest, **loc;
+ const char **src, **dest, **loc;
if (binsrch(mac) >= 0){ /* it's OK to redefine something */
#ifdef DEBUG
printf("binsrch(%s) -> already in table\n", mac);
-#endif DEBUG
+#endif
return;
}
/* binsrch sets slot as a side effect */
@@ -575,8 +578,7 @@ printf("binsrch(%s) -> %d\n", mac, slot);
dest = src+1;
while (dest > loc)
*dest-- = *src--;
- *loc = malloc(3);
- strcpy(*loc, mac);
+ *loc = strcpy(malloc(3), mac);
ncmds++;
#ifdef DEBUG
printf("after: %s %s %s %s %s, %d cmds\n", knowncmds[slot-2], knowncmds[slot-1], knowncmds[slot], knowncmds[slot+1], knowncmds[slot+2], ncmds);
@@ -589,12 +591,12 @@ printf("after: %s %s %s %s %s, %d cmds\n", knowncmds[slot-2], knowncmds[slot-1],
*/
int
binsrch(mac)
-char *mac;
+const char *mac;
{
- register char *p; /* pointer to current cmd in list */
- register int d; /* difference if any */
- register int mid; /* mid point in binary search */
- register int top, bot; /* boundaries of bin search, inclusive */
+ const char *p; /* pointer to current cmd in list */
+ int d; /* difference if any */
+ int mid; /* mid point in binary search */
+ int top, bot; /* boundaries of bin search, inclusive */
top = ncmds-1;
bot = 0;
OpenPOWER on IntegriCloud