- /* 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 GETTXT 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=LNPOSN+1;
- }
-
- 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 < 63) {
- SPLITTING = -1;
- if(UPPER && current >= 37)
- current=current-26;
- TEXT=TEXT+current;
- LNPOSN=LNPOSN+1;
- continue;
- }
- if(SPLITTING != LNPOSN) {
- TEXT=TEXT+63;
- SPLITTING = LNPOSN;
- continue;
- }
-
- TEXT=TEXT+current-63;
- SPLITTING = -1;
- LNPOSN=LNPOSN+1;
- }
-
- return(TEXT);
-}
-
-static void BUG(long NUM) {
-
- /* The following conditions are currently considered fatal bugs. Numbers < 20
- * are detected while reading the database; the others occur at "run time".
- * 0 Message line > 70 characters
- * 1 Null line in message
- * 2 Too many words of messages
- * 3 Too many travel options
- * 4 Too many vocabulary words
- * 5 Required vocabulary word not found
- * 6 Too many RTEXT messages
- * 7 Too many hints
- * 8 Location has cond bit being set twice
- * 9 Invalid section number in database
- * 10 Too many locations
- * 11 Too many class or turn messages
- * 20 Special travel (500>L>300) exceeds goto list
- * 21 Ran off end of vocabulary table
- * 22 Vocabulary type (N/1000) not between 0 and 3
- * 23 Intransitive action verb exceeds goto list
- * 24 Transitive action verb exceeds goto list
- * 25 Conditional travel entry with no alternative
- * 26 Location has no travel entries
- * 27 Hint number exceeds goto list
- * 28 Invalid month returned by date function
- * 29 Too many parameters given to SETPRM */
-
- fprintf(stderr, "Fatal error %ld. See source code for interpretation.\n", NUM);
- exit(EXIT_FAILURE);
-}
-
-static void MAPLIN(FILE *OPENED) {
- /* Read a line of input, from the specified input source,
- * translate the chars to integers in the range 0-126 and store
- * them in the common array "INLINE". Integer values are as follows:
- * 0 = space [ASCII CODE 40 octal, 32 decimal]
- * 1-2 = !" [ASCII 41-42 octal, 33-34 decimal]
- * 3-10 = '()*+,-. [ASCII 47-56 octal, 39-46 decimal]
- * 11-36 = upper-case letters
- * 37-62 = lower-case letters
- * 63 = percent (%) [ASCII 45 octal, 37 decimal]
- * 64-73 = digits, 0 through 9
- * Remaining characters can be translated any way that is convenient;
- * The "TYPE" routine below is used to map them back to characters when
- * necessary. The above mappings are required so that certain special
- * characters are known to fit in 6 bits and/or can be easily spotted.
- * Array elements beyond the end of the line should be filled with 0,
- * and LNLENG should be set to the index of the last character.
- *
- * If the data file uses a character other than space (e.g., tab) to
- * separate numbers, that character should also translate to 0.
- *
- * This procedure may use the map1,map2 arrays to maintain static data for
- * the mapping. MAP2(1) is set to 0 when the program starts
- * and is not changed thereafter unless the routines on this page choose
- * to do so. */
-
- do {
- if (NULL == fgets(INLINE + 1, sizeof(INLINE) - 1, OPENED)) {
- printf("Failed fgets()\n");
- }
- }
- while (!feof(OPENED) && INLINE[1] == '#');
-
- LNLENG = 0;
- for (size_t i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i)
- {
- char val = INLINE[i];
- INLINE[i] = ascii_to_advent[(unsigned)val];
- if (INLINE[i] != 0)
- LNLENG = i;
- }
- LNPOSN = 1;
+ /* Read a line of input, from the specified input source,
+ * translate the chars to integers in the range 0-126 and store
+ * them in the common array "INLINE". Integer values are as follows:
+ * 0 = space [ASCII CODE 40 octal, 32 decimal]
+ * 1-2 = !" [ASCII 41-42 octal, 33-34 decimal]
+ * 3-10 = '()*+,-. [ASCII 47-56 octal, 39-46 decimal]
+ * 11-36 = upper-case letters
+ * 37-62 = lower-case letters
+ * 63 = percent (%) [ASCII 45 octal, 37 decimal]
+ * 64-73 = digits, 0 through 9
+ * Remaining characters can be translated any way that is convenient;
+ * The "TYPE" routine below is used to map them back to characters when
+ * necessary. The above mappings are required so that certain special
+ * characters are known to fit in 6 bits and/or can be easily spotted.
+ * Array elements beyond the end of the line should be filled with 0,
+ * and LNLENG should be set to the index of the last character.
+ *
+ * If the data file uses a character other than space (e.g., tab) to
+ * separate numbers, that character should also translate to 0.
+ *
+ * This procedure may use the map1,map2 arrays to maintain static data for
+ * the mapping. MAP2(1) is set to 0 when the program starts
+ * and is not changed thereafter unless the routines on this page choose
+ * to do so. */
+
+ do {
+ if (NULL == fgets(INLINE + 1, sizeof(INLINE) - 1, OPENED)) {
+ printf("Failed fgets()\n");
+ }
+ } while (!feof(OPENED) && INLINE[1] == '#');
+
+ LNLENG = 0;
+ for (size_t i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i) {
+ char val = INLINE[i];
+ INLINE[i] = ascii_to_advent[(unsigned)val];
+ if (INLINE[i] != 0)
+ LNLENG = i;
+ }
+ LNPOSN = 1;