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 <bijunda1@xiaomi.com> Change-Id: I1ea205e3f2461b6c2377147cb9fc878ba5b19b4f
This commit is contained in:
parent
01f8bef2ba
commit
8b66a6238a
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user