Add test for urn actions.
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index b0ee4b6e0191c28324975a89f822dd0e328ef3a5..c47ce1d8ed4007cf8dc8e14b6c446a36e85794a8 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -27,7 +27,7 @@ void packed_to_token(long packed, char token[6])
   for (int i = 0; i < 5; ++i)
     {
       char advent = (packed >> i * 6) & 63;
-      token[4 - i] = advent_to_ascii[advent];
+      token[4 - i] = advent_to_ascii[(int) advent];
     }
 
   // Ensure the last character is \0.
@@ -549,11 +549,21 @@ bool MAPLIN(FILE *fp)
      * several cases with different requirements and partly because
      * of a quirk in linenoise().
      *
-     * The quirk shows up when you feed the program a test log on stdin.
-     * While fgets (as expected) consumes it a line at a time, linenoise()
-     * returns the first line and discards the rest.  Thus, there needs to
-     * be an editline (-s) option to fall back to fgets while still 
-     * prompting.
+     * The quirk shows up when you paste a test log from the clipboard
+     * to the program's command prompt.  While fgets (as expected)
+     * consumes it a line at a time, linenoise() returns the first
+     * line and discards the rest.  Thus, there needs to be an
+     * editline (-s) option to fall back to fgets while still
+     * prompting.  Note that linenoise does behave properly when
+     * fed redirected stdin.
+     *
+     * The logging is a bit of a mess because there are two distinct cases
+     * in which you want to echo commands.  One is when shipping them to 
+     * a log under the -l option, in which case you want to suppress
+     * prompt generation (so test logs are unadorned command sequences).
+     * On the other hand, if you redirected stdin and are feeding the program 
+     * a logfile, you *do* want prompt generation - it makes checkfiles
+     * easier to read when the commands are marked by a preceding prompt.
      */
     do {
        if (!editline) {
@@ -638,7 +648,7 @@ void TYPE(void)
     }
 
     for (i=1; i<=LNLENG; i++) {
-       INLINE[i]=advent_to_ascii[INLINE[i]];
+      INLINE[i]=advent_to_ascii[(int) INLINE[i]];
     }
     INLINE[LNLENG+1]=0;
     printf("%s\n", INLINE+1);