Comment polishing.
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index 6dd24e0c89f6ced0e9b67c7a162b3caf6e9b82e6..752bc8ee2cd3f483f5994abf0e5f750a24331ea6 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -138,7 +138,7 @@ void newspeak(char* msg)
 
   // Render the final string.
   char rendered[2000]; // FIXME: to be replaced with dynamic allocation
-  sprintf((char *)&rendered, copy, parameters[1], parameters[2], parameters[3], parameters[4]); // FIXME: to be replaced with vsprintf()
+  sprintf(rendered, copy, parameters[1], parameters[2], parameters[3], parameters[4]); // FIXME: to be replaced with vsprintf()
 
   // Print the message.
   printf("%s\n", rendered);
@@ -640,14 +640,14 @@ bool MAPLIN(FILE *fp)
      *  and is not changed thereafter unless the routines on this page choose
      *  to do so. */
 
-    if (prompt)
-       fputs("> ", stdout);
     do {
        if (!editline) {
+           if (prompt)
+               fputs("> ", stdout);
            IGNORE(fgets(rawbuf,sizeof(rawbuf)-1,fp));
            eof = (feof(fp));
        } else {
-           char *cp = linenoise(prompt ? "> ": "");
+           char *cp = linenoise("> ");
            eof = (cp == NULL);
            if (!eof) {
                strncpy(rawbuf, cp, sizeof(rawbuf)-1);
@@ -663,10 +663,17 @@ bool MAPLIN(FILE *fp)
            fclose(logfp);
        return false;
     } else {
+       FILE *efp = NULL;
        if (logfp && fp == stdin)
-           IGNORE(fputs(rawbuf, logfp));
+           efp = logfp;
        else if (!isatty(0))
-           IGNORE(fputs(rawbuf, stdout));
+           efp = stdout;
+       if (efp != NULL)
+       {
+           if (prompt)
+               fputs("> ", efp);
+           IGNORE(fputs(rawbuf, efp));
+       }
        strcpy(INLINE+1, rawbuf);
        LNLENG=0;
        for (i=1; i<=(long)sizeof(INLINE) && INLINE[i]!=0; i++) {