Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/checknr WARNS=5
details: https://anonhg.NetBSD.org/src/rev/67bc3f9aba45
branches: trunk
changeset: 789232:67bc3f9aba45
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Aug 11 06:39:47 2013 +0000
description:
WARNS=5
diffstat:
usr.bin/checknr/Makefile | 4 +---
usr.bin/checknr/checknr.c | 44 ++++++++++++++++++++++++--------------------
2 files changed, 25 insertions(+), 23 deletions(-)
diffs (137 lines):
diff -r 90ea9eebf1c6 -r 67bc3f9aba45 usr.bin/checknr/Makefile
--- a/usr.bin/checknr/Makefile Sun Aug 11 06:32:13 2013 +0000
+++ b/usr.bin/checknr/Makefile Sun Aug 11 06:39:47 2013 +0000
@@ -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>
diff -r 90ea9eebf1c6 -r 67bc3f9aba45 usr.bin/checknr/checknr.c
--- a/usr.bin/checknr/checknr.c Sun Aug 11 06:32:13 2013 +0000
+++ b/usr.bin/checknr/checknr.c Sun Aug 11 06:39:47 2013 +0000
@@ -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 @@
#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 @@
* 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 @@
* 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 @@
};
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 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 @@
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 @@
}
/* 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 @@
* 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 @@
* 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 */
Home |
Main Index |
Thread Index |
Old Index