Clean up logic for exiting input loop and scoring.

This commit is contained in:
Eric S. Raymond 2017-05-24 11:16:59 -04:00
parent 263b5ac3ba
commit c703bd78d9
3 changed files with 30 additions and 29 deletions

11
misc.c
View file

@ -173,7 +173,7 @@ void fSETPRM(long FIRST, long P1, long P2) {
#define WORD1X (*wORD1X)
#define WORD2 (*wORD2)
#define WORD2X (*wORD2X)
void fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) {
bool fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) {
long JUNK;
/* Get a command from the adventurer. Snarf out the first word, pad it with
@ -185,7 +185,8 @@ long JUNK;
L10: if(BLKLIN)TYPE0();
MAPLIN(input);
if(input == stdin && feof(stdin)) score(1);
if (feof(input))
return false;
WORD1=GETTXT(true,true,true,0);
if(BLKLIN && WORD1 < 0) goto L10;
WORD1X=GETTXT(false,true,true,0);
@ -195,7 +196,7 @@ L12: JUNK=GETTXT(false,true,true,0);
WORD2X=GETTXT(false,true,true,0);
L22: JUNK=GETTXT(false,true,true,0);
if(JUNK > 0) goto L22;
if(GETTXT(true,true,true,0) <= 0)return;
if(GETTXT(true,true,true,0) <= 0)return true;
RSPEAK(53);
goto L10;
}
@ -883,7 +884,7 @@ void fMAPLIN(FILE *OPENED) {
if(MAP2[1] == 0)MPINIT();
if (!oldstyle && SETUP)
if (!oldstyle && SETUP && OPENED == stdin)
fputs("> ", stdout);
do {
IGNORE(fgets(raw_input,sizeof(INLINE)-1,OPENED));
@ -891,7 +892,7 @@ void fMAPLIN(FILE *OPENED) {
/* allow comments in logfiles */
(!feof(OPENED) && raw_input[0] == '#');
if (feof(OPENED)) {
if (logfp)
if (logfp && OPENED == stdin)
fclose(logfp);
} else {
if (logfp)