You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/06/22 13:27:53 UTC
[incubator-nuttx-apps] branch master updated: apps/system: fix
command history behavior (2)
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 8b66a62 apps/system: fix command history behavior (2)
8b66a62 is described below
commit 8b66a6238a2cacb934a3a586c0188b1539035f8e
Author: Peter Bee <bi...@xiaomi.com>
AuthorDate: Fri Mar 19 13:42:52 2021 +0800
apps/system: fix command history behavior (2)
N/A
Fixing "last command" misbehavior when one command in history is a
substring of another.
Signed-off-by: Peter Bee <bi...@xiaomi.com>
Change-Id: I1ea205e3f2461b6c2377147cb9fc878ba5b19b4f
---
system/readline/readline_common.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/system/readline/readline_common.c b/system/readline/readline_common.c
index 18a7fb7..6fdf9b5 100644
--- a/system/readline/readline_common.c
+++ b/system/readline/readline_common.c
@@ -601,6 +601,8 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf,
buf[nch++] = g_cmdhist.buf[idx][i];
RL_PUTC(vtbl, g_cmdhist.buf[idx][i]);
}
+
+ buf[nch] = '\0';
}
}
#endif /* CONFIG_READLINE_CMD_HISTORY */
@@ -682,7 +684,7 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf,
* buffer, don't save it again.
*/
- if (strncmp(buf, g_cmdhist.buf[g_cmdhist.head], nch) != 0)
+ if (strncmp(buf, g_cmdhist.buf[g_cmdhist.head], nch + 1) != 0)
{
g_cmdhist.head = (g_cmdhist.head + 1) % RL_CMDHIST_LEN;