Added 'linty' target for make
"make linty" does lots of error checking while compiling. Simplified the standard make's CFLAGS. Cleaned up code to eliminate resulting warnings generated by "make linty".
This commit is contained in:
parent
d92da99106
commit
d844c2a391
6 changed files with 20 additions and 19 deletions
7
Makefile
7
Makefile
|
@ -25,9 +25,7 @@
|
|||
VERS=1.0
|
||||
|
||||
CC?=gcc
|
||||
CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wall -Wpedantic -Wextra -g
|
||||
CCFLAGS+=-Wstrict-prototypes
|
||||
CCFLAGS+=-Wmissing-prototypes
|
||||
CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wpedantic
|
||||
LIBS=
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
|
@ -118,5 +116,8 @@ refresh: advent.html
|
|||
|
||||
dist: advent-$(VERS).tar.gz
|
||||
|
||||
linty: CCFLAGS += -W -Wall -Wextra -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wfloat-equal -Wcast-align -Wwrite-strings -Waggregate-return -Wcast-qual -Wswitch-enum -Wwrite-strings -Wunreachable-code -Winit-self -Wpointer-arith -O2
|
||||
linty: advent
|
||||
|
||||
debug: CCFLAGS += -O0 --coverage -g
|
||||
debug: advent
|
||||
|
|
2
advent.h
2
advent.h
|
@ -84,7 +84,7 @@ extern bool oldstyle, editline, prompt;
|
|||
#define WRITE_MODE "wb"
|
||||
extern char* xstrdup(const char*);
|
||||
extern void packed_to_token(long, char token[]);
|
||||
extern void newspeak(char*);
|
||||
extern void newspeak(const char*);
|
||||
extern void PSPEAK(vocab_t,int);
|
||||
extern void RSPEAK(vocab_t);
|
||||
extern void SETPRM(long,long,long);
|
||||
|
|
|
@ -487,12 +487,12 @@ static int read_database(FILE* database) {
|
|||
* whether the abbreviated description is printed. Counts modulo 5
|
||||
* unless "LOOK" is used. */
|
||||
|
||||
static void write_0d(FILE* header_file, long single, char* varname)
|
||||
static void write_0d(FILE* header_file, long single, const char* varname)
|
||||
{
|
||||
fprintf(header_file, "LOCATION long %s INITIALIZE(= %ld);\n", varname, single);
|
||||
}
|
||||
|
||||
static void write_1d(FILE* header_file, long array[], long dim, char* varname)
|
||||
static void write_1d(FILE* header_file, long array[], long dim, const char* varname)
|
||||
{
|
||||
fprintf(header_file, "LOCATION long %s[] INITIALIZE(= {\n", varname);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
|
@ -508,7 +508,7 @@ static void write_1d(FILE* header_file, long array[], long dim, char* varname)
|
|||
fprintf(header_file, "\n});\n");
|
||||
}
|
||||
|
||||
static void write_hints(FILE* header_file, long matrix[][HINTLEN], long dim1, long dim2, char* varname)
|
||||
static void write_hints(FILE* header_file, long matrix[][HINTLEN], long dim1, long dim2, const char* varname)
|
||||
{
|
||||
fprintf(header_file, "LOCATION long %s[][%ld] INITIALIZE(= {\n", varname, dim2);
|
||||
for (int i = 0; i < dim1; ++i)
|
||||
|
|
4
main.c
4
main.c
|
@ -913,7 +913,7 @@ static void listobjects(void)
|
|||
static bool do_command(FILE *cmdin)
|
||||
/* Get and execute a command */
|
||||
{
|
||||
long verb, V1, V2;
|
||||
long verb=0, V1, V2;
|
||||
long kmod, defn;
|
||||
static long igo = 0;
|
||||
static long obj = 0;
|
||||
|
@ -950,7 +950,7 @@ static bool do_command(FILE *cmdin)
|
|||
for (;;) {
|
||||
if (game.loc == 0)
|
||||
croak(cmdin);
|
||||
char* msg = locations[game.loc].description.small;
|
||||
const char* msg = locations[game.loc].description.small;
|
||||
if (MOD(game.abbrev[game.loc],game.abbnum) == 0 || msg == 0)
|
||||
msg=locations[game.loc].description.big;
|
||||
if (!FORCED(game.loc) && DARK(game.loc)) {
|
||||
|
|
2
misc.c
2
misc.c
|
@ -45,7 +45,7 @@ void packed_to_token(long packed, char token[6])
|
|||
|
||||
/* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
|
||||
|
||||
void newspeak(char* msg)
|
||||
void newspeak(const char* msg)
|
||||
{
|
||||
// Do nothing if we got a null pointer.
|
||||
if (msg == NULL)
|
||||
|
|
|
@ -28,7 +28,7 @@ def write_regular_messages(name, h, c):
|
|||
h += " {},\n".format(key)
|
||||
h += "};\n\n"
|
||||
|
||||
c += "char* {}[] = {{\n".format(name)
|
||||
c += "const char* {}[] = {{\n".format(name)
|
||||
index = 0
|
||||
for key, text in dungeon[name]:
|
||||
if text == None:
|
||||
|
@ -47,13 +47,13 @@ with open(yaml_name, "r") as f:
|
|||
h = """#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
char* inventory;
|
||||
char** longs;
|
||||
const char* inventory;
|
||||
const char** longs;
|
||||
} object_description_t;
|
||||
|
||||
typedef struct {
|
||||
char* small;
|
||||
char* big;
|
||||
const char* small;
|
||||
const char* big;
|
||||
} descriptions_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -62,9 +62,9 @@ typedef struct {
|
|||
|
||||
extern location_t locations[];
|
||||
extern object_description_t object_descriptions[];
|
||||
extern char* arbitrary_messages[];
|
||||
extern char* class_messages[];
|
||||
extern char* turn_threshold_messages[];
|
||||
extern const char* arbitrary_messages[];
|
||||
extern const char* class_messages[];
|
||||
extern const char* turn_threshold_messages[];
|
||||
|
||||
extern size_t CLSSES;
|
||||
|
||||
|
@ -118,7 +118,7 @@ for key, data in dungeon["object_descriptions"]:
|
|||
c += " .inventory = {},\n".format(data["inventory"])
|
||||
try:
|
||||
data["longs"][0]
|
||||
c += " .longs = (char* []) {\n"
|
||||
c += " .longs = (const char* []) {\n"
|
||||
for l in data["longs"]:
|
||||
l = c_escape(l)
|
||||
c += " \"{}\",\n".format(l)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue