Make GETTXT() a bit closer to actual C.

This commit is contained in:
Jason S. Ninneman 2017-06-03 10:55:48 -07:00
parent 681ecd9a4f
commit ab46b5261b

65
misc.c
View file

@ -257,44 +257,53 @@ L42: NUMBER=NUMBER*SIGN;
} }
long GETTXT(long SKIP,long ONEWRD, long UPPER) { long GETTXT(long SKIP,long ONEWRD, long UPPER) {
long CHAR, TEXT, I; static long SPLITTING = -1;
/* Take characters from an input line and pack them into 30-bit words. /* Take characters from an input line and pack them into 30-bit words.
* Skip says to skip leading blanks. ONEWRD says stop if we come to a * Skip says to skip leading blanks. ONEWRD says stop if we come to a
* blank. UPPER says to map all letters to uppercase. If we reach the * blank. UPPER says to map all letters to uppercase. If we reach the
* end of the line, the word is filled up with blanks (which encode as 0's). * end of the line, the word is filled up with blanks (which encode as 0's).
* If we're already at end of line when TEXT is called, we return -1. */ * If we're already at end of line when TEXT is called, we return -1. */
if(LNPOSN != SPLITTING)SPLITTING = -1; long CHAR;
TEXT= -1; long TEXT;
L10: if(LNPOSN > LNLENG)return(TEXT); static long SPLITTING = -1;
if((!SKIP) || INLINE[LNPOSN] != 0) goto L11;
LNPOSN=LNPOSN+1;
goto L10;
L11: TEXT=0; if(LNPOSN != SPLITTING)
/* 15 */ for (I=1; I<=5; I++) { SPLITTING = -1;
TEXT=TEXT*64; TEXT= -1;
if(LNPOSN > LNLENG || (ONEWRD && INLINE[LNPOSN] == 0)) goto L15; while (true) {
CHAR=INLINE[LNPOSN]; if(LNPOSN > LNLENG)
if(CHAR >= 63) goto L12; return(TEXT);
SPLITTING = -1; if((!SKIP) || INLINE[LNPOSN] != 0)
if(UPPER && CHAR >= 37)CHAR=CHAR-26; break;
TEXT=TEXT+CHAR; LNPOSN=LNPOSN+1;
goto L14; }
L12: if(SPLITTING == LNPOSN) goto L13; TEXT=0;
TEXT=TEXT+63; for (int I=1; I<=5; I++) {
SPLITTING = LNPOSN; TEXT=TEXT*64;
goto L15; if(LNPOSN > LNLENG || (ONEWRD && INLINE[LNPOSN] == 0))
continue;
CHAR=INLINE[LNPOSN];
if(CHAR < 63) {
SPLITTING = -1;
if(UPPER && CHAR >= 37)
CHAR=CHAR-26;
TEXT=TEXT+CHAR;
LNPOSN=LNPOSN+1;
continue;
}
if(SPLITTING != LNPOSN) {
TEXT=TEXT+63;
SPLITTING = LNPOSN;
continue;
}
L13: TEXT=TEXT+CHAR-63; TEXT=TEXT+CHAR-63;
SPLITTING = -1; SPLITTING = -1;
L14: LNPOSN=LNPOSN+1; LNPOSN=LNPOSN+1;
L15: /*etc*/ ; }
} /* end loop */
return(TEXT); return(TEXT);
} }
long MAKEWD(long LETTRS) { long MAKEWD(long LETTRS) {