Fix last commit (ChangeLog entry still applicable).
[pspp] / lib / readline.c
index f2ddcaaaa13285e57618e71c7f85ccf65512e74a..88f39b21031ab401f1aaf40d4b42892281b4fd0b 100644 (file)
@@ -48,9 +48,8 @@ readline (const char *prompt)
   if (getline (&out, &size, stdin) < 0)
     return NULL;
 
-  if (out[strlen (out) - 1] == '\r')
-    out[strlen (out) - 1] = '\0';
-  if (out[strlen (out) - 1] == '\n')
+  while (*out && (out[strlen (out) - 1] == '\r'
+                 || out[strlen (out) - 1] == '\n'))
     out[strlen (out) - 1] = '\0';
 
   return out;