X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Freadline.c;h=f93a115293e1af1cc557810f7ef04fa8dcc78dee;hb=943135931d5db0e1579e5b743e5c13dd5cc47158;hp=3f8c18ae444afd6ca2d3fa23a78769e5fdfb71de;hpb=222b0486b7db1b09293e05512873d633440efcb3;p=gnulib.git diff --git a/lib/readline.c b/lib/readline.c index 3f8c18ae4..f93a11529 100644 --- a/lib/readline.c +++ b/lib/readline.c @@ -1,5 +1,5 @@ /* readline.c --- Simple implementation of readline. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. Written by Simon Josefsson This program is free software; you can redistribute it and/or modify @@ -16,11 +16,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include -/* This module is intended to be used when the application only need +/* This module is intended to be used when the application only needs the readline interface. If you need more functions from the readline library, it is recommended to require the readline library (or improve this module) rather than #if-protect part of your @@ -33,6 +31,7 @@ #include "readline.h" #include +#include #include char * @@ -47,5 +46,9 @@ readline (const char *prompt) if (getline (&out, &size, stdin) < 0) return NULL; + while (*out && (out[strlen (out) - 1] == '\r' + || out[strlen (out) - 1] == '\n')) + out[strlen (out) - 1] = '\0'; + return out; }