-/* Line-parsing routines (GETTXT, MAKEWD, PUTTXT, SHFTXT) */
-
-long GETTXT(bool skip, bool onewrd, bool upper)
-/* 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
- * 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).
- * If we're already at end of line when TEXT is called, we return -1. */
-{
- long text;
- static long splitting = -1;
-
- if (LNPOSN != splitting)
- splitting = -1;
- text = -1;
- while (true) {
- if (LNPOSN > LNLENG)
- return (text);
- if ((!skip) || INLINE[LNPOSN] != 0)
- break;
- ++LNPOSN;
- }
-
- text = 0;
- for (int I = 1; I <= TOKLEN; I++) {
- text = text * 64;
- if (LNPOSN > LNLENG || (onewrd && INLINE[LNPOSN] == 0))
- continue;
- char current = INLINE[LNPOSN];
- if (current < ascii_to_advent['%']) {
- splitting = -1;
- if (upper && current >= ascii_to_advent['a'])
- current = current - 26;
- text = text + current;
- ++LNPOSN;
- continue;
- }
- if (splitting != LNPOSN) {
- text = text + ascii_to_advent['%'];
- splitting = LNPOSN;
- continue;
- }
-
- text = text + current - ascii_to_advent['%'];
- splitting = -1;
- ++LNPOSN;
- }
-
- return text;
-}
-
-token_t MAKEWD(long letters)
-/* Combine TOKLEN (currently 5) uppercase letters (represented by
- * pairs of decimal digits in lettrs) to form a 30-bit value matching
- * the one that GETTXT would return given those characters plus
- * trailing blanks. Caution: lettrs will overflow 31 bits if
- * 5-letter word starts with V-Z. As a kludgey workaround, you can
- * increment a letter by 5 by adding 50 to the next pair of
- * digits. */
-{
- long i = 1, word = 0;
-
- for (long k = letters; k != 0; k = k / 100) {
- word = word + i * (MOD(k, 50) + 10);
- i = i * 64;
- if (MOD(k, 100) > 50)word = word + i * 5;
- }
- i = 64L * 64L * 64L * 64L * 64L / i;
- word = word * i;
- return word;
-}
-