projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
75bf848
)
Begin to split undifferentiated longs into semantic types.
author
Eric S. Raymond
<esr@thyrsus.com>
Tue, 6 Jun 2017 18:28:27 +0000
(14:28 -0400)
committer
Eric S. Raymond
<esr@thyrsus.com>
Tue, 6 Jun 2017 18:28:27 +0000
(14:28 -0400)
advent.h
patch
|
blob
|
history
misc.c
patch
|
blob
|
history
diff --git
a/advent.h
b/advent.h
index 396454e97f0e7c2ba8f1b2f9ef3c2923129ba085..9dc6202c0da80546228c1d2944c8944c33ebc8b0 100644
(file)
--- a/
advent.h
+++ b/
advent.h
@@
-9,6
+9,9
@@
typedef struct lcg_state
unsigned long a, c, m, x;
} lcg_state;
unsigned long a, c, m, x;
} lcg_state;
+typedef long token_t; /* word token - someday this will be a character array */
+typedef long vocab_t; /* index into a vocabulary array */
+
extern long ABB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
LINK[], LNLENG, LNPOSN,
PARMS[], PLACE[];
extern long ABB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
LINK[], LNLENG, LNPOSN,
PARMS[], PLACE[];
@@
-21,17
+24,17
@@
extern lcg_state lcgstate;
#define READ_MODE "rb"
#define WRITE_MODE "wb"
#define READ_MODE "rb"
#define WRITE_MODE "wb"
-extern void SPEAK(
long
);
-extern void PSPEAK(
long,long
);
-extern void RSPEAK(
long
);
+extern void SPEAK(
vocab_t
);
+extern void PSPEAK(
vocab_t,int
);
+extern void RSPEAK(
vocab_t
);
extern void SETPRM(long,long,long);
extern void SETPRM(long,long,long);
-extern bool fGETIN(FILE *,
long*,long*,long*,long
*);
+extern bool fGETIN(FILE *,
token_t*,token_t*,token_t*,token_t
*);
#define GETIN(input,WORD1,WORD1X,WORD2,WORD2X) fGETIN(input,&WORD1,&WORD1X,&WORD2,&WORD2X)
#define GETIN(input,WORD1,WORD1X,WORD2,WORD2X) fGETIN(input,&WORD1,&WORD1X,&WORD2,&WORD2X)
-extern long YES(FILE *,
long,long,long
);
-extern long GETTXT(
long,long,long
);
-extern
long
MAKEWD(long);
+extern long YES(FILE *,
vocab_t,vocab_t,vocab_t
);
+extern long GETTXT(
bool,bool,bool
);
+extern
token_t
MAKEWD(long);
extern void fPUTTXT(long,long*,long);
#define PUTTXT(WORD,STATE,CASE) fPUTTXT(WORD,&STATE,CASE)
extern void fPUTTXT(long,long*,long);
#define PUTTXT(WORD,STATE,CASE) fPUTTXT(WORD,&STATE,CASE)
diff --git
a/misc.c
b/misc.c
index 46772d53498936d296cdfc9333a5d450c2826901..e6ee7d1dbeee6e726fad14c4046d4194950309d4 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-12,7
+12,7
@@
/* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
/* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
-void SPEAK(
long
N) {
+void SPEAK(
vocab_t
N) {
long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE;
/* Print the message which starts at LINES(N). Precede it with a blank line
long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE;
/* Print the message which starts at LINES(N). Precede it with a blank line
@@
-111,7
+111,7
@@
L40: if(BLANK)TYPE0();
return;
}
return;
}
-void PSPEAK(
long MSG,long
SKIP) {
+void PSPEAK(
vocab_t MSG,int
SKIP) {
long I, M;
/* Find the skip+1st message from msg and print it. MSG should be the index of
long I, M;
/* Find the skip+1st message from msg and print it. MSG should be the index of
@@
-129,7
+129,7
@@
L9: SPEAK(M);
return;
}
return;
}
-void RSPEAK(
long
I) {
+void RSPEAK(
vocab_t
I) {
/* Print the I-TH "random" message (section 6 of database). */
/* Print the I-TH "random" message (section 6 of database). */
@@
-194,8
+194,8
@@
L22: JUNK=GETTXT(false,true,true);
#undef WORD2X
#define GETIN(SRC,WORD1,WORD1X,WORD2,WORD2X) fGETIN(SRC,&WORD1,&WORD1X,&WORD2,&WORD2X)
#undef WORD2X
#define GETIN(SRC,WORD1,WORD1X,WORD2,WORD2X) fGETIN(SRC,&WORD1,&WORD1X,&WORD2,&WORD2X)
-long YES(FILE *input,
long X, long Y, long
Z) {
-
long
YEAH, REPLY, JUNK1, JUNK2, JUNK3;
+long YES(FILE *input,
vocab_t X, vocab_t Y, vocab_t
Z) {
+
token_t
YEAH, REPLY, JUNK1, JUNK2, JUNK3;
/* Print message X, wait for yes/no answer. If yes, print Y and return true;
* if no, print Z and return false. */
/* Print message X, wait for yes/no answer. If yes, print Y and return true;
* if no, print Z and return false. */
@@
-223,7
+223,7
@@
L20: YEAH=false;
* machine dependent i/o stuff is on the following page. See that page
* for a description of MAPCOM's inline array. */
* machine dependent i/o stuff is on the following page. See that page
* for a description of MAPCOM's inline array. */
-long GETTXT(
long SKIP,long ONEWRD, long
UPPER) {
+long GETTXT(
bool SKIP,bool ONEWRD, bool
UPPER) {
/* Take characters from an input line and pack them into 30-bit words.
* Skip says to skip leading blanks. ONEWRD says stop if we come to a
* blank. UPPER says to map all letters to uppercase. If we reach the
/* Take characters from an input line and pack them into 30-bit words.
* Skip says to skip leading blanks. ONEWRD says stop if we come to a
* blank. UPPER says to map all letters to uppercase. If we reach the