OSDN Git Service

In angband_fgets() replace nonprintables with '?' rather than strip them. Without...
authorEric Branlund <ebranlund@fastmail.com>
Fri, 14 May 2021 21:57:22 +0000 (14:57 -0700)
committerEric Branlund <ebranlund@fastmail.com>
Fri, 14 May 2021 21:57:22 +0000 (14:57 -0700)
src/util/angband-files.cpp

index 8cebec3..cc4409f 100644 (file)
@@ -236,7 +236,7 @@ FILE *angband_fopen_temp(char *buf, int max)
  *
  * Read a string, without a newline, to a file
  *
- * Process tabs, strip internal non-printables
+ * Process tabs, replace internal non-printables with '?'
  */
 errr angband_fgets(FILE *fff, char *buf, huge n)
 {
@@ -283,6 +283,10 @@ errr angband_fgets(FILE *fff, char *buf, huge n)
                 buf[i++] = *s;
                 if (i >= n)
                     break;
+            } else {
+                buf[i++] = '?';
+                if (i >= n)
+                    break;
             }
         }