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;
for (I=K; I<=L; I++) {
PUTTXT(LINES[I],state,2);
} /* end loop */
}
LNPOSN=0;
L30:
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
* WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */
{
long JUNK;
long junk;
for (;;) {
if (game.blklin)
@ -196,12 +196,16 @@ bool fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X)
if (game.blklin && WORD1 < 0)
continue;
WORD1X=GETTXT(false,true,true);
L12: JUNK=GETTXT(false,true,true);
if(JUNK > 0) goto L12;
do {
junk=GETTXT(false,true,true);
} while
(junk > 0);
WORD2=GETTXT(true,true,true);
WORD2X=GETTXT(false,true,true);
L22: JUNK=GETTXT(false,true,true);
if(JUNK > 0) goto L22;
do {
junk=GETTXT(false,true,true);
} while
(junk > 0);
if (GETTXT(true,true,true) <= 0)
return true;
RSPEAK(53);
@ -356,13 +360,11 @@ void SHFTXT(long from, long delta)
k=from+LNLENG-I;
j=k+delta;
INLINE[j]=INLINE[k];
} /* end loop */
}
}
LNLENG=LNLENG+delta;
return;
}
void TYPE0(void)
/* Type a blank line. This procedure is provided as a convenience for callers
* who otherwise have no use for MAPCOM. */
@ -378,7 +380,6 @@ void TYPE0(void)
/* Suspend/resume I/O routines (SAVWDS, SAVARR, SAVWRD) */
#undef SAVWDS
void fSAVWDS(long *W1, long *W2, long *W3, long *W4,
long *W5, long *W6, long *W7)
/* 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,(*W6));
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)
/* Write or read an array of n words. See SAVWRD. */
{
@ -405,7 +403,6 @@ void fSAVARR(long arr[], long n)
}
return;
}
#define SAVARR(ARR,N) fSAVARR(ARR,N)
void fSAVWRD(long op, long *pword)
/* 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;
for (i=1; i<=TABSIZ; i++) {
if(KTAB[i] == -1)
goto L2;
if(init >= 0 && KTAB[i]/1000 != init)
goto L1;
if(ATAB[i] == id)
goto L3;
L1:;
}
BUG(21);
L2: lexeme= -1;
if (KTAB[i] == -1) {
lexeme= -1;
if (init < 0)
return(lexeme);
BUG(5);
L3: lexeme=KTAB[i];
if(init >= 0)lexeme=MOD(lexeme,1000);
}
if (init >= 0 && KTAB[i]/1000 != init)
continue;
if (ATAB[i] == id) {
lexeme=KTAB[i];
if (init >= 0)
lexeme=MOD(lexeme,1000);
return(lexeme);
}
}
BUG(21);
}
void DSTROY(long object)
/* Permanently eliminate "object" by moving to a non-existent location. */
@ -706,7 +701,7 @@ void BUG(long num)
void MAPLIN(FILE *fp)
{
long I, VAL;
long i, val;
/* Read a line of input, from the specified input source,
* 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
* to do so. */
if(MAP2[1] == 0)MPINIT();
if (MAP2[1] == 0)
MPINIT();
if (!oldstyle && fp == stdin)
fputs("> ", stdout);
@ -751,11 +747,12 @@ void MAPLIN(FILE *fp)
IGNORE(fputs(rawbuf, stdout));
strcpy(INLINE+1, rawbuf);
LNLENG=0;
for (I=1; I<=(long)sizeof(INLINE) && INLINE[I]!=0; I++) {
VAL=INLINE[I]+1;
INLINE[I]=MAP1[VAL];
if(INLINE[I] != 0)LNLENG=I;
} /* end loop */
for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {
val=INLINE[i]+1;
INLINE[i]=MAP1[val];
if (INLINE[i] != 0)
LNLENG=i;
}
LNPOSN=1;
}
}