* readline.c: Remove EOL.
authorSimon Josefsson <simon@josefsson.org>
Thu, 10 Nov 2005 02:19:29 +0000 (02:19 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 10 Nov 2005 02:19:29 +0000 (02:19 +0000)
lib/ChangeLog
lib/readline.c

index 91db74a..a84cf13 100644 (file)
@@ -1,3 +1,7 @@
+2005-11-10  Simon Josefsson  <jas@extundo.com>
+
+       * readline.c: Remove EOL.
+
 2005-11-08  Eric Blake  <ebb9@byu.net>
 
        * inet_ntop.h: Use #if !, not #ifndef, for AC_CHECK_DECLS.
index 3f8c18a..f2ddcaa 100644 (file)
@@ -33,6 +33,7 @@
 #include "readline.h"
 
 #include <stdio.h>
+#include <string.h>
 #include <getline.h>
 
 char *
@@ -47,5 +48,10 @@ 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')
+    out[strlen (out) - 1] = '\0';
+
   return out;
 }