More goto removal.

This commit is contained in:
Eric S. Raymond 2017-06-07 19:10:39 -04:00
parent da5976dc8c
commit 19b3ac4ccd

67
misc.c
View file

@ -31,7 +31,7 @@ L10:
state=0; state=0;
for (I=K; I<=L; I++) { for (I=K; I<=L; I++) {
PUTTXT(LINES[I],state,2); PUTTXT(LINES[I],state,2);
} /* end loop */ }
LNPOSN=0; LNPOSN=0;
L30: L30:
LNPOSN=LNPOSN+1; LNPOSN=LNPOSN+1;
@ -184,7 +184,7 @@ bool fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X)
* blanks may follow the word. If a second word appears, it is returned in * blanks may follow the word. If a second word appears, it is returned in
* WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */ * WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */
{ {
long JUNK; long junk;
for (;;) { for (;;) {
if (game.blklin) if (game.blklin)
@ -196,12 +196,16 @@ bool fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X)
if (game.blklin && WORD1 < 0) if (game.blklin && WORD1 < 0)
continue; continue;
WORD1X=GETTXT(false,true,true); WORD1X=GETTXT(false,true,true);
L12: JUNK=GETTXT(false,true,true); do {
if(JUNK > 0) goto L12; junk=GETTXT(false,true,true);
} while
(junk > 0);
WORD2=GETTXT(true,true,true); WORD2=GETTXT(true,true,true);
WORD2X=GETTXT(false,true,true); WORD2X=GETTXT(false,true,true);
L22: JUNK=GETTXT(false,true,true); do {
if(JUNK > 0) goto L22; junk=GETTXT(false,true,true);
} while
(junk > 0);
if (GETTXT(true,true,true) <= 0) if (GETTXT(true,true,true) <= 0)
return true; return true;
RSPEAK(53); RSPEAK(53);
@ -356,13 +360,11 @@ void SHFTXT(long from, long delta)
k=from+LNLENG-I; k=from+LNLENG-I;
j=k+delta; j=k+delta;
INLINE[j]=INLINE[k]; INLINE[j]=INLINE[k];
} /* end loop */ }
} }
LNLENG=LNLENG+delta; LNLENG=LNLENG+delta;
return;
} }
void TYPE0(void) void TYPE0(void)
/* Type a blank line. This procedure is provided as a convenience for callers /* Type a blank line. This procedure is provided as a convenience for callers
* who otherwise have no use for MAPCOM. */ * who otherwise have no use for MAPCOM. */
@ -378,7 +380,6 @@ void TYPE0(void)
/* Suspend/resume I/O routines (SAVWDS, SAVARR, SAVWRD) */ /* Suspend/resume I/O routines (SAVWDS, SAVARR, SAVWRD) */
#undef SAVWDS
void fSAVWDS(long *W1, long *W2, long *W3, long *W4, void fSAVWDS(long *W1, long *W2, long *W3, long *W4,
long *W5, long *W6, long *W7) long *W5, long *W6, long *W7)
/* Write or read 7 variables. See SAVWRD. */ /* Write or read 7 variables. See SAVWRD. */
@ -390,11 +391,8 @@ void fSAVWDS(long *W1, long *W2, long *W3, long *W4,
SAVWRD(0,(*W5)); SAVWRD(0,(*W5));
SAVWRD(0,(*W6)); SAVWRD(0,(*W6));
SAVWRD(0,(*W7)); SAVWRD(0,(*W7));
return;
} }
#define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7)
#undef SAVARR
void fSAVARR(long arr[], long n) void fSAVARR(long arr[], long n)
/* Write or read an array of n words. See SAVWRD. */ /* Write or read an array of n words. See SAVWRD. */
{ {
@ -405,7 +403,6 @@ void fSAVARR(long arr[], long n)
} }
return; return;
} }
#define SAVARR(ARR,N) fSAVARR(ARR,N)
void fSAVWRD(long op, long *pword) void fSAVWRD(long op, long *pword)
/* If OP<0, start writing a file, using word to initialise encryption; save /* If OP<0, start writing a file, using word to initialise encryption; save
@ -479,25 +476,23 @@ long VOCAB(long id, long init)
long i, lexeme; long i, lexeme;
for (i=1; i<=TABSIZ; i++) { for (i=1; i<=TABSIZ; i++) {
if(KTAB[i] == -1) if (KTAB[i] == -1) {
goto L2; lexeme= -1;
if(init >= 0 && KTAB[i]/1000 != init)
goto L1;
if(ATAB[i] == id)
goto L3;
L1:;
}
BUG(21);
L2: lexeme= -1;
if (init < 0) if (init < 0)
return(lexeme); return(lexeme);
BUG(5); BUG(5);
}
L3: lexeme=KTAB[i]; if (init >= 0 && KTAB[i]/1000 != init)
if(init >= 0)lexeme=MOD(lexeme,1000); continue;
if (ATAB[i] == id) {
lexeme=KTAB[i];
if (init >= 0)
lexeme=MOD(lexeme,1000);
return(lexeme); return(lexeme);
} }
}
BUG(21);
}
void DSTROY(long object) void DSTROY(long object)
/* Permanently eliminate "object" by moving to a non-existent location. */ /* Permanently eliminate "object" by moving to a non-existent location. */
@ -706,7 +701,7 @@ void BUG(long num)
void MAPLIN(FILE *fp) void MAPLIN(FILE *fp)
{ {
long I, VAL; long i, val;
/* Read a line of input, from the specified input source, /* Read a line of input, from the specified input source,
* translate the chars to integers in the range 0-126 and store * translate the chars to integers in the range 0-126 and store
@ -733,7 +728,8 @@ void MAPLIN(FILE *fp)
* and is not changed thereafter unless the routines on this page choose * and is not changed thereafter unless the routines on this page choose
* to do so. */ * to do so. */
if(MAP2[1] == 0)MPINIT(); if (MAP2[1] == 0)
MPINIT();
if (!oldstyle && fp == stdin) if (!oldstyle && fp == stdin)
fputs("> ", stdout); fputs("> ", stdout);
@ -751,11 +747,12 @@ void MAPLIN(FILE *fp)
IGNORE(fputs(rawbuf, stdout)); IGNORE(fputs(rawbuf, stdout));
strcpy(INLINE+1, rawbuf); strcpy(INLINE+1, rawbuf);
LNLENG=0; LNLENG=0;
for (I=1; I<=(long)sizeof(INLINE) && INLINE[I]!=0; I++) { for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
VAL=INLINE[I]+1; val=INLINE[i]+1;
INLINE[I]=MAP1[VAL]; INLINE[i]=MAP1[val];
if(INLINE[I] != 0)LNLENG=I; if (INLINE[i] != 0)
} /* end loop */ LNLENG=i;
}
LNPOSN=1; LNPOSN=1;
} }
} }