static int read(FILE *input, token_t verb, token_t obj)
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
{
- int i;
int spk = ACTSPK[verb];
if (obj == INTRANSITIVE) {
obj = 0;
- for (i=1; i<=NOBJECTS; i++) {
+ for (int i=1; i<=NOBJECTS; i++) {
if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
obj = obj * NOBJECTS + i;
}
#define READ_MODE "rb"
#define WRITE_MODE "wb"
extern char* xstrdup(const char*);
-extern void packed_to_token(long, char token[6]);
+extern void packed_to_token(long, char token[]);
extern void newspeak(char*);
extern void PSPEAK(vocab_t,int);
extern void RSPEAK(vocab_t);
while (!feof(OPENED) && INLINE[1] == '#');
LNLENG = 0;
- for (size_t i = 1; i <= sizeof(INLINE) && INLINE[i] != 0; ++i)
+ for (size_t i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i)
{
char val = INLINE[i];
INLINE[i] = ascii_to_advent[(unsigned)val];
* scanned). If we're at the end of the line or encounter an illegal
* character (not a digit, hyphen, or blank), we return 0. */
- long DIGIT, GETNUM, SIGN;
+ long GETNUM, SIGN;
if(source != NULL) MAPLIN(source);
GETNUM = 0;
}
while (!(LNPOSN > LNLENG || INLINE[LNPOSN] == 0))
{
- DIGIT=INLINE[LNPOSN]-64;
+ long DIGIT=INLINE[LNPOSN]-64;
if(DIGIT < 0 || DIGIT > 9)
{
GETNUM=0;
* get full score. */
{
if (!DARK(game.loc)) {
- long obj;
++game.abbrev[game.loc];
for (int i=game.atloc[game.loc]; i != 0; i=game.link[i]) {
- obj=i;
+ long obj=i;
if (obj > NOBJECTS)obj=obj-NOBJECTS;
if (obj == STEPS && TOTING(NUGGET))
continue;
bool MAPLIN(FILE *fp)
{
- long i, val;
bool eof;
/* Read a line of input, from the specified input source.
if (!eof) {
strncpy(rawbuf, cp, sizeof(rawbuf)-1);
linenoiseHistoryAdd(rawbuf);
- strncat(rawbuf, "\n", sizeof(rawbuf)-1);
+ strncat(rawbuf, "\n", sizeof(rawbuf) - strlen(rawbuf) - 1);
linenoiseFree(cp);
}
}
* and is not changed thereafter unless the routines on this page choose
* to do so. */
LNLENG=0;
- for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
- val=INLINE[i];
+ for (long i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
+ long val=INLINE[i];
INLINE[i]=ascii_to_advent[val];
if (INLINE[i] != 0)
LNLENG=i;
{
long i, k;
FILE *fp = NULL;
- char *name;
-
+
if (!resume) {
/* Suspend. Offer to save things in a file, but charging
* some points (so can't win by using saved games to retry
}
while (fp == NULL) {
- name = linenoise("\nFile name: ");
+ char* name = linenoise("\nFile name: ");
if (name == NULL)
return GO_TOP;
fp = fopen(name,(resume ? READ_MODE : WRITE_MODE));