(sl_command_loop): new return code -2 for EOF
(sl_loop): treat all return value from sl_command_loop >= 0 as ok, and continue. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15100 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
10
lib/sl/sl.c
10
lib/sl/sl.c
@@ -293,7 +293,11 @@ static char *sl_readline(const char *prompt)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return values: 0 on success, -1 on fatal error, or return value of command */
|
/* return values:
|
||||||
|
* 0 on success,
|
||||||
|
* -1 on fatal error,
|
||||||
|
* -2 if EOF, or
|
||||||
|
* return value of command */
|
||||||
int
|
int
|
||||||
sl_command_loop(SL_cmd *cmds, const char *prompt, void **data)
|
sl_command_loop(SL_cmd *cmds, const char *prompt, void **data)
|
||||||
{
|
{
|
||||||
@@ -305,7 +309,7 @@ sl_command_loop(SL_cmd *cmds, const char *prompt, void **data)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
buf = sl_readline(prompt);
|
buf = sl_readline(prompt);
|
||||||
if(buf == NULL)
|
if(buf == NULL)
|
||||||
return 1;
|
return -2;
|
||||||
|
|
||||||
if(*buf)
|
if(*buf)
|
||||||
add_history(buf);
|
add_history(buf);
|
||||||
@@ -332,7 +336,7 @@ sl_loop(SL_cmd *cmds, const char *prompt)
|
|||||||
{
|
{
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
while((ret = sl_command_loop(cmds, prompt, &data)) == 0)
|
while((ret = sl_command_loop(cmds, prompt, &data)) >= 0)
|
||||||
;
|
;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user