summaryrefslogtreecommitdiff
path: root/apps/nshlib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-10 00:46:27 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-10 00:46:27 +0000
commitf0fef8e21fd0459b75b3e5faf318634e5befbdaf (patch)
treed9451e3904a1b2e84bce6b183ccaca719b78ff51 /apps/nshlib
parent9768bf44e8f274eecc92f4eefbf0496f32649196 (diff)
downloadpx4-nuttx-f0fef8e21fd0459b75b3e5faf318634e5befbdaf.tar.gz
px4-nuttx-f0fef8e21fd0459b75b3e5faf318634e5befbdaf.tar.bz2
px4-nuttx-f0fef8e21fd0459b75b3e5faf318634e5befbdaf.zip
Fix a readline bug. If a NUL is received, it would return end-of-file
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5633 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib')
-rw-r--r--apps/nshlib/nsh_consolemain.c2
-rw-r--r--apps/nshlib/nsh_session.c11
2 files changed, 6 insertions, 7 deletions
diff --git a/apps/nshlib/nsh_consolemain.c b/apps/nshlib/nsh_consolemain.c
index 8be44f7aa..27e9d6db9 100644
--- a/apps/nshlib/nsh_consolemain.c
+++ b/apps/nshlib/nsh_consolemain.c
@@ -42,8 +42,6 @@
#include <stdio.h>
#include <assert.h>
-#include <apps/readline.h>
-
#include "nsh.h"
#include "nsh_console.h"
diff --git a/apps/nshlib/nsh_session.c b/apps/nshlib/nsh_session.c
index 8079b2de5..0c5249672 100644
--- a/apps/nshlib/nsh_session.c
+++ b/apps/nshlib/nsh_session.c
@@ -129,11 +129,13 @@ int nsh_session(FAR struct console_stdio_s *pstate)
fputs(g_nshprompt, pstate->cn_outstream);
fflush(pstate->cn_outstream);
- /* Get the next line of input */
+ /* Get the next line of input. readline() returns EOF on end-of-file
+ * or any read failure.
+ */
ret = readline(pstate->cn_line, CONFIG_NSH_LINELEN,
INSTREAM(pstate), OUTSTREAM(pstate));
- if (ret > 0)
+ if (ret != EOF)
{
/* Parse process the command */
@@ -142,9 +144,8 @@ int nsh_session(FAR struct console_stdio_s *pstate)
}
/* Readline normally returns the number of characters read,
- * but will return 0 on end of file or a negative value
- * if an error occurs. Either will cause the session to
- * terminate.
+ * but will return EOF on end of file or if an error occurs.
+ * EOF will cause the session to terminate.
*/
else