Pass WARNS=4, not without some gross preprocessor hackery.
XXX: does this program actually do anything useful these days?
This commit is contained in:
parent
e63a3e7105
commit
69c3e9d213
@ -1,7 +1,5 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
# $NetBSD: Makefile,v 1.8 2009/08/13 04:09:53 dholland Exp $
|
||||
|
||||
WARNS?= 2 # fails -Wcast-qual -Wshadow (etc)
|
||||
# $NetBSD: Makefile,v 1.9 2009/08/13 06:59:37 dholland Exp $
|
||||
|
||||
PROG= error
|
||||
SRCS= main.c input.c pi.c subr.c filter.c touch.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: error.h,v 1.14 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: error.h,v 1.15 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -85,7 +85,7 @@ typedef int Errorclass;
|
||||
/*
|
||||
* Resources to count and print out the error categories
|
||||
*/
|
||||
extern char *class_table[];
|
||||
extern const char *class_table[];
|
||||
extern int class_count[];
|
||||
|
||||
#define nunknown class_count[C_UNKNOWN]
|
||||
@ -109,7 +109,7 @@ extern FILE *queryfile; /* where the query responses from the user come from*/
|
||||
extern char *processname;
|
||||
extern char *scriptname;
|
||||
|
||||
extern char *suffixlist;
|
||||
extern const char *suffixlist;
|
||||
|
||||
extern boolean query;
|
||||
extern boolean terse;
|
||||
@ -128,7 +128,7 @@ int inquire(const char *, ...); /* inquire for yes/no */
|
||||
* Describes attributes about a language
|
||||
*/
|
||||
struct lang_desc {
|
||||
char *lang_name;
|
||||
const char *lang_name;
|
||||
const char *lang_incomment; /* one of the following defines */
|
||||
const char *lang_outcomment; /* one of the following defines */
|
||||
};
|
||||
@ -203,6 +203,58 @@ extern boolean *touchedfiles; /* which files we touched */
|
||||
extern int language;
|
||||
extern char *currentfilename;
|
||||
|
||||
/*
|
||||
* Macros for initializing arrays of string constants.
|
||||
* This is a fairly gross set of preprocessor hacks; the idea is
|
||||
* that instead of
|
||||
* static char *foo[4] = { "alpha", "beta", "gamma", "delta" };
|
||||
* you do
|
||||
* DECL_STRINGS_4(static, foo, "alpha", "beta", "gamma", "delta");
|
||||
*
|
||||
* and it comes out as
|
||||
* static char foo_0[] = "delta";
|
||||
* static char foo_1[] = "gamma";
|
||||
* static char foo_2[] = "beta";
|
||||
* static char foo_3[] = "alpha";
|
||||
* static char *foo[4] = { foo_3, foo_2, foo_1, foo_0 };
|
||||
*
|
||||
* none of which is const.
|
||||
*
|
||||
* Unfortunately, the string arrays this program slings around freely
|
||||
* can't be all const (because it munges some of them) and can't be
|
||||
* all non-const without something like this to initialize the ones
|
||||
* that need to contain string constants. Unfortunately you can't
|
||||
* mix (const char *const *) and (char **) in C, only in C++.
|
||||
*/
|
||||
|
||||
#define DECL_STR(sym, num, str) static char sym##_##num[] = str
|
||||
|
||||
#define DECL_S1(sym, s, ...) __VA_ARGS__ DECL_STR(sym, 0, s)
|
||||
#define DECL_S2(sym, s, ...) DECL_STR(sym, 1, s); DECL_S1(sym, __VA_ARGS__)
|
||||
#define DECL_S3(sym, s, ...) DECL_STR(sym, 2, s); DECL_S2(sym, __VA_ARGS__)
|
||||
#define DECL_S4(sym, s, ...) DECL_STR(sym, 3, s); DECL_S3(sym, __VA_ARGS__)
|
||||
#define DECL_S5(sym, s, ...) DECL_STR(sym, 4, s); DECL_S4(sym, __VA_ARGS__)
|
||||
#define DECL_S6(sym, s, ...) DECL_STR(sym, 5, s); DECL_S5(sym, __VA_ARGS__)
|
||||
|
||||
#define USE_S1(sym) sym##_0
|
||||
#define USE_S2(sym) sym##_1, USE_S1(sym)
|
||||
#define USE_S3(sym) sym##_2, USE_S2(sym)
|
||||
#define USE_S4(sym) sym##_3, USE_S3(sym)
|
||||
#define USE_S5(sym) sym##_4, USE_S4(sym)
|
||||
#define USE_S6(sym) sym##_5, USE_S5(sym)
|
||||
|
||||
#define DECL_STRS(num, class, sym, ...) \
|
||||
DECL_S##num(sym, __VA_ARGS__); \
|
||||
class char *sym[num] = { USE_S##num(sym) }
|
||||
|
||||
#define DECL_STRINGS_1(class, sym, ...) DECL_STRS(1, class, sym, __VA_ARGS__)
|
||||
#define DECL_STRINGS_2(class, sym, ...) DECL_STRS(2, class, sym, __VA_ARGS__)
|
||||
#define DECL_STRINGS_3(class, sym, ...) DECL_STRS(3, class, sym, __VA_ARGS__)
|
||||
#define DECL_STRINGS_4(class, sym, ...) DECL_STRS(4, class, sym, __VA_ARGS__)
|
||||
#define DECL_STRINGS_5(class, sym, ...) DECL_STRS(5, class, sym, __VA_ARGS__)
|
||||
#define DECL_STRINGS_6(class, sym, ...) DECL_STRS(6, class, sym, __VA_ARGS__)
|
||||
|
||||
|
||||
/*
|
||||
* Functional forwards
|
||||
*/
|
||||
@ -224,6 +276,7 @@ Errorclass pi(void);
|
||||
int position(const char *, char);
|
||||
void printerrors(bool, int, Eptr []);
|
||||
const char *plural(int);
|
||||
char *Strdup(const char *);
|
||||
char *substitute(char *, char, char);
|
||||
bool touchfiles(int, Eptr **, int *, char ***);
|
||||
const char *verbform(int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: input.c,v 1.15 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: input.c,v 1.16 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: input.c,v 1.15 2009/08/13 05:53:58 dholland Exp $");
|
||||
__RCSID("$NetBSD: input.c,v 1.16 2009/08/13 06:59:37 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -197,10 +197,10 @@ onelong(void)
|
||||
} else
|
||||
if (cur_wordc == 1 && language == INLD) {
|
||||
nwordv = Calloc(4, sizeof(char *));
|
||||
nwordv[0] = "ld:";
|
||||
nwordv[0] = Strdup("ld:"); /* XXX leaked */
|
||||
nwordv[1] = cur_wordv[1];
|
||||
nwordv[2] = "is";
|
||||
nwordv[3] = "undefined.";
|
||||
nwordv[2] = Strdup("is"); /* XXX leaked */
|
||||
nwordv[3] = Strdup("undefined.");/* XXX leaked */
|
||||
cur_wordc = 4;
|
||||
cur_wordv = nwordv - 1;
|
||||
return (C_NONSPEC);
|
||||
@ -423,8 +423,15 @@ lint2(void)
|
||||
return (C_UNKNOWN);
|
||||
} /* end of lint 2*/
|
||||
|
||||
#if 0 /* not const-correct */
|
||||
static char *Lint31[4] = {"returns", "value", "which", "is"};
|
||||
static char *Lint32[6] = {"value", "is", "used,", "but", "none", "returned"};
|
||||
#else
|
||||
DECL_STRINGS_4(static, Lint31,
|
||||
"returns", "value", "which", "is");
|
||||
DECL_STRINGS_6(static, Lint32,
|
||||
"value", "is", "used,", "but", "none", "returned");
|
||||
#endif
|
||||
|
||||
static Errorclass
|
||||
lint3(void)
|
||||
@ -442,10 +449,17 @@ lint3(void)
|
||||
/*
|
||||
* Special word vectors for use by F77 recognition
|
||||
*/
|
||||
#if 0 /* not const-correct */
|
||||
static char *F77_fatal[3] = {"Compiler", "error", "line"};
|
||||
static char *F77_error[3] = {"Error", "on", "line"};
|
||||
static char *F77_warning[3] = {"Warning", "on", "line"};
|
||||
static char *F77_no_ass[3] = {"Error.","No","assembly."};
|
||||
#else
|
||||
DECL_STRINGS_3(static, F77_fatal, "Compiler", "error", "line");
|
||||
DECL_STRINGS_3(static, F77_error, "Error", "on", "line");
|
||||
DECL_STRINGS_3(static, F77_warning, "Warning", "on", "line");
|
||||
DECL_STRINGS_3(static, F77_no_ass, "Error.", "No", "assembly.");
|
||||
#endif
|
||||
|
||||
static Errorclass
|
||||
f77(void)
|
||||
@ -487,8 +501,14 @@ f77(void)
|
||||
return (C_UNKNOWN);
|
||||
} /* end of f77 */
|
||||
|
||||
#if 0 /* not const-correct */
|
||||
static char *Make_Croak[3] = {"***", "Error", "code"};
|
||||
static char *Make_NotRemade[5] = {"not", "remade", "because", "of", "errors"};
|
||||
#else
|
||||
DECL_STRINGS_3(static, Make_Croak, "***", "Error", "code");
|
||||
DECL_STRINGS_5(static, Make_NotRemade,
|
||||
"not", "remade", "because", "of", "errors");
|
||||
#endif
|
||||
|
||||
static Errorclass
|
||||
make(void)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.16 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: main.c,v 1.17 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: main.c,v 1.16 2009/08/13 05:53:58 dholland Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.17 2009/08/13 06:59:37 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <signal.h>
|
||||
@ -66,7 +66,8 @@ Eptr **files; /* array of pointers into errors*/
|
||||
boolean *touchedfiles; /* which files we touched */
|
||||
int language = INCC;
|
||||
|
||||
char *currentfilename = "????";
|
||||
static char default_currentfilename[] = "????";
|
||||
char *currentfilename = default_currentfilename;
|
||||
char *processname;
|
||||
|
||||
boolean query = false; /* query the operator if touch files */
|
||||
@ -75,7 +76,7 @@ boolean terse = false; /* Terse output */
|
||||
static char im_on[] = _PATH_TTY; /* my tty name */
|
||||
static boolean notouch = false; /* don't touch ANY files */
|
||||
|
||||
char *suffixlist = ".*"; /* initially, can touch any file */
|
||||
const char *suffixlist = ".*"; /* initially, can touch any file */
|
||||
|
||||
static int errorsort(const void *, const void *);
|
||||
static void forkvi(int, char **);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pi.c,v 1.16 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: pi.c,v 1.17 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pi.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: pi.c,v 1.16 2009/08/13 05:53:58 dholland Exp $");
|
||||
__RCSID("$NetBSD: pi.c,v 1.17 2009/08/13 06:59:37 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -43,13 +43,18 @@ __RCSID("$NetBSD: pi.c,v 1.16 2009/08/13 05:53:58 dholland Exp $");
|
||||
#include <stdlib.h>
|
||||
#include "error.h"
|
||||
|
||||
static char *c_linenumber;
|
||||
#if 0 /* not const-correct */
|
||||
static char *unk_hdr[] = {"In", "program", "???"};
|
||||
#else
|
||||
DECL_STRINGS_3(static, unk_hdr, "In", "program", "???");
|
||||
#endif
|
||||
|
||||
static char *c_linenumber;
|
||||
static char **c_header = &unk_hdr[0];
|
||||
|
||||
static boolean alldigits(const char *);
|
||||
static boolean isdateformat(int, char **);
|
||||
static boolean instringset(const char *, char **);
|
||||
static boolean instringset(const char *, const char **);
|
||||
static boolean piptr(const char *);
|
||||
|
||||
|
||||
@ -136,21 +141,22 @@ static boolean piptr(const char *);
|
||||
* w - function bletch is never used
|
||||
* E - z undefined on lines 9 13
|
||||
*/
|
||||
static char *Months[] = {
|
||||
static const char *Months[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
0
|
||||
};
|
||||
static char *Days[] = {
|
||||
static const char *Days[] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0
|
||||
};
|
||||
static char *Piroutines[] = {
|
||||
static const char *Piroutines[] = {
|
||||
"program", "function", "procedure", 0
|
||||
};
|
||||
|
||||
|
||||
static boolean structured, multiple;
|
||||
|
||||
#if 0 /* not const-correct */
|
||||
static char *pi_Endmatched[] = {"End", "matched"};
|
||||
static char *pi_Inserted[] = {"Inserted", "keyword", "end", "matching"};
|
||||
|
||||
@ -162,6 +168,22 @@ static char *pi_und2[] = {"undefined", "on", "lines"};
|
||||
static char *pi_imp1[] = {"improperly", "used", "on", "line"};
|
||||
static char *pi_imp2[] = {"improperly", "used", "on", "lines"};
|
||||
|
||||
#else
|
||||
DECL_STRINGS_2(static, pi_Endmatched, "End", "matched");
|
||||
DECL_STRINGS_4(static, pi_Inserted, "Inserted", "keyword", "end", "matching");
|
||||
|
||||
DECL_STRINGS_6(static, pi_multiple,
|
||||
"Mutiply", "defined", "label", "in", "case,", "line");
|
||||
DECL_STRINGS_5(static, pi_structured,
|
||||
"is", "into", "a", "structured", "statement");
|
||||
|
||||
DECL_STRINGS_3(static, pi_und1, "undefined", "on", "line");
|
||||
DECL_STRINGS_3(static, pi_und2, "undefined", "on", "lines");
|
||||
DECL_STRINGS_4(static, pi_imp1, "improperly", "used", "on", "line");
|
||||
DECL_STRINGS_4(static, pi_imp2, "improperly", "used", "on", "lines");
|
||||
|
||||
#endif
|
||||
|
||||
static boolean
|
||||
alldigits(const char *string)
|
||||
{
|
||||
@ -171,7 +193,7 @@ alldigits(const char *string)
|
||||
}
|
||||
|
||||
static boolean
|
||||
instringset(const char *member, char **set)
|
||||
instringset(const char *member, const char **set)
|
||||
{
|
||||
for (; *set; set++) {
|
||||
if (strcmp(*set, member) == 0)
|
||||
@ -249,7 +271,7 @@ pi(void)
|
||||
nwordv[0] = strdup(currentfilename);
|
||||
nwordv[1] = strdup(c_linenumber);
|
||||
if (!longpiptr) {
|
||||
nwordv[2] = "pascal errortype";
|
||||
nwordv[2] = Strdup("pascal errortype"); /* XXX leaked */
|
||||
nwordv[3] = cur_wordv[1];
|
||||
nwordv[4] = strdup("%%%\n");
|
||||
if (strlen(nwordv[5]) > (8-2)) /* this is the pointer */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr.c,v 1.18 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: subr.c,v 1.19 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: subr.c,v 1.18 2009/08/13 05:53:58 dholland Exp $");
|
||||
__RCSID("$NetBSD: subr.c,v 1.19 2009/08/13 06:59:37 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
@ -81,6 +81,18 @@ Calloc(size_t nelements, size_t size)
|
||||
return (back);
|
||||
}
|
||||
|
||||
char *
|
||||
Strdup(const char *s)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
ret = strdup(s);
|
||||
if (ret == NULL) {
|
||||
errx(1, "Ran out of memory.");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* find the position of a given character in a string
|
||||
* (one based)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: touch.c,v 1.21 2009/08/13 05:53:58 dholland Exp $ */
|
||||
/* $NetBSD: touch.c,v 1.22 2009/08/13 06:59:37 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: touch.c,v 1.21 2009/08/13 05:53:58 dholland Exp $");
|
||||
__RCSID("$NetBSD: touch.c,v 1.22 2009/08/13 06:59:37 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -83,7 +83,7 @@ static void insert(int);
|
||||
static void text(Eptr, boolean);
|
||||
static boolean writetouched(int);
|
||||
static int mustoverwrite(FILE *, FILE *);
|
||||
static int mustwrite(const char *, int, FILE *);
|
||||
static int mustwrite(const char *, unsigned, FILE *);
|
||||
static void errorprint(FILE *, Eptr, boolean);
|
||||
static int probethisfile(const char *);
|
||||
|
||||
@ -158,7 +158,7 @@ countfiles(Eptr *errors)
|
||||
return (my_nfiles);
|
||||
}
|
||||
|
||||
char *class_table[] = {
|
||||
const char *class_table[] = {
|
||||
/*C_UNKNOWN 0 */ "Unknown",
|
||||
/*C_IGNORE 1 */ "ignore",
|
||||
/*C_SYNC 2 */ "synchronization",
|
||||
@ -449,7 +449,7 @@ static int
|
||||
oktotouch(const char *filename)
|
||||
{
|
||||
const char *src;
|
||||
char *pat;
|
||||
const char *pat;
|
||||
const char *osrc;
|
||||
|
||||
pat = suffixlist;
|
||||
@ -507,7 +507,7 @@ execvarg(int n_pissed_on, int *r_argc, char ***r_argv)
|
||||
sep = NULL;
|
||||
(*r_argv) = Calloc(n_pissed_on + 3, sizeof(char *));
|
||||
(*r_argc) = n_pissed_on + 2;
|
||||
(*r_argv)[1] = "+1;/###/";
|
||||
(*r_argv)[1] = Strdup("+1;/###/"); /* XXX leaked */
|
||||
n_pissed_on = 2;
|
||||
if (!terse) {
|
||||
fprintf(stdout, "You touched file(s):");
|
||||
@ -607,7 +607,7 @@ text(Eptr p, boolean use_all)
|
||||
static boolean
|
||||
writetouched(int overwrite)
|
||||
{
|
||||
int nread;
|
||||
unsigned nread;
|
||||
FILE *localfile;
|
||||
FILE *temp;
|
||||
int botch;
|
||||
@ -674,7 +674,7 @@ writetouched(int overwrite)
|
||||
static int
|
||||
mustoverwrite(FILE *preciousfile, FILE *temp)
|
||||
{
|
||||
int nread;
|
||||
unsigned nread;
|
||||
|
||||
while ((nread = fread(edbuf, 1, sizeof(edbuf), temp)) != 0) {
|
||||
if (mustwrite(edbuf, nread, preciousfile) == 0)
|
||||
@ -687,9 +687,9 @@ mustoverwrite(FILE *preciousfile, FILE *temp)
|
||||
* return 0 on catastrophe
|
||||
*/
|
||||
static int
|
||||
mustwrite(const char *base, int n, FILE *preciousfile)
|
||||
mustwrite(const char *base, unsigned n, FILE *preciousfile)
|
||||
{
|
||||
int nwrote;
|
||||
unsigned nwrote;
|
||||
|
||||
if (n <= 0)
|
||||
return (1);
|
||||
|
Loading…
Reference in New Issue
Block a user