(readline): be more liberal in what we accept from el_gets. if count
== 0 -> interpret it as EOF. also copy the string first and then cut of the newline, it's cleaner git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7988 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1995 - 2000 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -73,7 +73,8 @@ readline(const char* prompt)
|
||||
HistEvent ev;
|
||||
#endif
|
||||
int count;
|
||||
char *ret;
|
||||
const char *str;
|
||||
|
||||
if(e == NULL){
|
||||
#ifdef EL_INIT_FOUR
|
||||
e = el_init("", stdin, stdout, stderr);
|
||||
@@ -91,11 +92,16 @@ readline(const char* prompt)
|
||||
el_set(e, EL_EDITOR, "emacs"); /* XXX? */
|
||||
}
|
||||
pr = prompt ? prompt : "";
|
||||
ret = (char*)el_gets(e, &count);
|
||||
if (ret) {
|
||||
str = el_gets(e, &count);
|
||||
if (str && count > 0) {
|
||||
char *ret = strdup (str);
|
||||
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ret[strlen(ret) - 1] == '\n')
|
||||
ret[strlen(ret) - 1] = '\0';
|
||||
return strdup(ret);
|
||||
return ret;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user