Mostly confine assumptions about what token_t is to misc.c

The token_t things like WD* are presently longs and will someday be
char[6].  By introducing some trivial functions - wordeq(),
wordempty(), and wordclear() - we mostly hide the difference.

All runtime knowledge about packing now lives only in misc.c and the
list of magic WORD_* defines in advent.h.  Outside this, literals are
now accessed through #define names that could expand to either longs
or strings.

Still to be done: WD* values are sometiimes compated to zero in
ways implying they can be negative. Must figure out wat thus means.
This commit is contained in:
Eric S. Raymond 2017-06-19 17:21:45 -04:00
parent 87961483a2
commit a678b68b39
5 changed files with 28 additions and 6 deletions

View file

@ -91,6 +91,9 @@ extern void* xmalloc(size_t size);
extern char* xstrdup(const char*);
extern void packed_to_token(long, char token[]);
extern void speak(const char*);
extern bool wordeq(token_t, token_t);
extern bool wordempty(token_t);
extern void wordclear(token_t *);
extern void PSPEAK(vocab_t, int);
extern void RSPEAK(vocab_t);
extern void SETPRM(long, long, long);