Really mean it about strict C99 compliance.

This commit is contained in:
Jason S. Ninneman 2017-05-29 09:30:37 -07:00
parent 4beb21e08f
commit 519d8f07e6
5 changed files with 15 additions and 6 deletions

View file

@ -1,5 +1,6 @@
# Makefile for the open-source release of adventure 2.5 # Makefile for the open-source release of adventure 2.5
CCFLAGS=-std=c99
LIBS=-lrt LIBS=-lrt
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
GCCVERSIONGTEQ4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4) GCCVERSIONGTEQ4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4)
@ -13,10 +14,10 @@ OBJS=main.o init.o actions1.o actions2.o score.o misc.o
SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control misc.h main.h share.h funcs.h SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control misc.h main.h share.h funcs.h
.c.o: .c.o:
$(CC) -O $(DBX) -c $< $(CC) $(CCFLAGS) -O $(DBX) -c $<
advent: $(OBJS) database.o advent: $(OBJS) database.o
$(CC) -Wall -std=c99 -O $(DBX) -o advent $(OBJS) database.o $(LIBS) $(CC) $(CCFLAGS) -O $(DBX) -o advent $(OBJS) database.o $(LIBS)
main.o: main.h misc.h funcs.h database.h main.o: main.h misc.h funcs.h database.h
@ -32,7 +33,7 @@ misc.o: misc.h main.h database.h
database.c database.h: compile database.c database.h: compile
./compile ./compile
$(CC) $(OPTIONS) -O $(DBX) -c database.c $(CC) $(CCFLAGS) -O $(DBX) -c database.c
clean: clean:
rm -f *.o advent advent.html advent.6 database.[ch] compile rm -f *.o advent advent.html advent.6 database.[ch] compile

View file

@ -523,7 +523,7 @@ L8300: SPK=201;
/* This next part is shared with the "resume" code. The two cases are /* This next part is shared with the "resume" code. The two cases are
* distinguished by the value of kk (-1 for suspend, +1 for resume). */ * distinguished by the value of kk (-1 for suspend, +1 for resume). */
L8305: DATIME(I,K); L8305: DATIME(&I,&K);
K=I+650*K; K=I+650*K;
SAVWRD(KK,K); SAVWRD(KK,K);
K=VRSION; K=VRSION;

2
main.c
View file

@ -8,6 +8,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <getopt.h> #include <getopt.h>
#include <signal.h> #include <signal.h>
#include <time.h>
#include "main.h" #include "main.h"
#include "database.h" #include "database.h"
#include "misc.h" #include "misc.h"
@ -920,4 +921,5 @@ L12400: LIMIT= -1;
L18999: RSPEAK(SPK); L18999: RSPEAK(SPK);
L19000: RSPEAK(136); L19000: RSPEAK(136);
score(0); score(0);
return true;
} }

7
misc.c
View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/time.h>
#include "main.h" #include "main.h"
#include "share.h" /* for SETUP */ #include "share.h" /* for SETUP */
#include "misc.h" #include "misc.h"
@ -1002,5 +1003,11 @@ L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F));
void DATIME(long* D, long* T) {
struct timeval tv;
gettimeofday(&tv, NULL);
*D = (long) tv.tv_sec;
*T = (long) tv.tv_usec;
}
long fIABS(N)long N; {return(N<0? -N : N);} long fIABS(N)long N; {return(N<0? -N : N);}
long fMOD(N,M)long N, M; {return(N%M);} long fMOD(N,M)long N, M; {return(N%M);}

3
misc.h
View file

@ -1,4 +1,3 @@
#include <time.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
@ -68,7 +67,7 @@ extern void fMPINIT();
#define MPINIT() fMPINIT() #define MPINIT() fMPINIT()
extern void fSAVEIO(long,long,long*); extern void fSAVEIO(long,long,long*);
#define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR) #define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR)
#define DATIME(D,T) do {struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); D=ts.tv_sec, T=ts.tv_nsec;} while (0) extern void DATIME(long*, long*);
extern long fIABS(long); extern long fIABS(long);
#define IABS(N) fIABS(N) #define IABS(N) fIABS(N)
extern long fMOD(long,long); extern long fMOD(long,long);