WARNS=5
This commit is contained in:
parent
7899f1dc15
commit
beced5ea78
@ -1,8 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.5 2009/04/14 22:15:18 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.6 2013/08/11 06:39:47 dholland Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
WARNS?= 2 # fails -Wcast-qual
|
||||
|
||||
PROG= checknr
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: checknr.c,v 1.20 2008/07/21 14:19:21 lukem Exp $ */
|
||||
/* $NetBSD: checknr.c,v 1.21 2013/08/11 06:39:47 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: checknr.c,v 1.20 2008/07/21 14:19:21 lukem Exp $");
|
||||
__RCSID("$NetBSD: checknr.c,v 1.21 2013/08/11 06:39:47 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -75,8 +75,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
|
||||
@ -146,7 +146,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", "%A", "%B", "%C", "%D", "%I", "%J", "%N",
|
||||
"%O", "%P", "%Q", "%R", "%T", "%V", "(b", "(c", "(d", "(f", "(l", "(q",
|
||||
"(t", "(x", "(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x",
|
||||
@ -192,7 +192,7 @@ char *knowncmds[MAXCMDS] = {
|
||||
};
|
||||
|
||||
int lineno; /* current line number in input file */
|
||||
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 */
|
||||
@ -200,12 +200,12 @@ int ncmds; /* size of knowncmds */
|
||||
int slot; /* slot in knowncmds found by binsrch */
|
||||
|
||||
void addcmd(char *);
|
||||
void addmac(char *);
|
||||
int binsrch(char *);
|
||||
void addmac(const char *);
|
||||
int binsrch(const char *);
|
||||
void checkknown(char *);
|
||||
void chkcmd(char *, char *);
|
||||
void complain(int);
|
||||
int eq(const void *, const void *);
|
||||
static int eq(const char *, const char *);
|
||||
int main(int, char **);
|
||||
void nomatch(char *);
|
||||
void pe(int);
|
||||
@ -236,14 +236,18 @@ main(int argc, char **argv)
|
||||
for (i=0; br[i].opbr; i++)
|
||||
;
|
||||
for (cp=argv[1]+3; cp[-1]; cp += 6) {
|
||||
char *tmp;
|
||||
|
||||
if (i >= MAXBR)
|
||||
errx(1, "too many pairs");
|
||||
if ((br[i].opbr = malloc(3)) == NULL)
|
||||
if ((tmp = malloc(3)) == NULL)
|
||||
err(1, "malloc");
|
||||
strlcpy(br[i].opbr, cp, 3);
|
||||
if ((br[i].clbr = malloc(3)) == NULL)
|
||||
strlcpy(tmp, cp, 3);
|
||||
br[i].opbr = tmp;
|
||||
if ((tmp = malloc(3)) == NULL)
|
||||
err(1, "malloc");
|
||||
strlcpy(br[i].clbr, cp+3, 3);
|
||||
strlcpy(tmp, cp+3, 3);
|
||||
br[i].clbr = tmp;
|
||||
addmac(br[i].opbr); /* knows pairs are also known cmds */
|
||||
addmac(br[i].clbr);
|
||||
i++;
|
||||
@ -515,10 +519,10 @@ nomatch(char *mac)
|
||||
}
|
||||
|
||||
/* eq: are two strings equal? */
|
||||
int
|
||||
eq(const void *s1, const void *s2)
|
||||
static int
|
||||
eq(const char *s1, const char *s2)
|
||||
{
|
||||
return (strcmp((char *)s1, (char *)s2) == 0);
|
||||
return strcmp(s1, s2) == 0;
|
||||
}
|
||||
|
||||
/* print the first part of an error message, given the line number */
|
||||
@ -580,9 +584,9 @@ addcmd(char *line)
|
||||
* nroff programs, and the register loop below is pretty fast.
|
||||
*/
|
||||
void
|
||||
addmac(char *mac)
|
||||
addmac(const char *mac)
|
||||
{
|
||||
char **src, **dest, **loc;
|
||||
const char **src, **dest, **loc;
|
||||
|
||||
if (binsrch(mac) >= 0){ /* it's OK to redefine something */
|
||||
#ifdef DEBUG
|
||||
@ -614,9 +618,9 @@ addmac(char *mac)
|
||||
* If found, return the index. If not, return -1.
|
||||
*/
|
||||
int
|
||||
binsrch(char *mac)
|
||||
binsrch(const char *mac)
|
||||
{
|
||||
char *p; /* pointer to current cmd in list */
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user