CLE: Forgot to NUL terminate the command line

This commit is contained in:
Gregory Nutt 2014-02-02 12:53:58 -06:00
parent 9d49d3969f
commit 3fbce9ed5e
2 changed files with 12 additions and 6 deletions

View File

@ -813,8 +813,7 @@
6.34 2014-xx-xx Gregory Nutt <gnutt@nuttx.org>
* apps/system/cle: Add a EMACS-like command line editor. This CLE,
is really more like readline than the NuttX readline is! Not fully
fully on initial checkout (2014-02-02).
is really more like readline than the NuttX readline is! (2014-02-02).
* apps/nshlib: Use of the standard tiney readline (about .25KB) is now
an option and can be replaces with the EMACX-like CLE (about 2KB)
(2014-02-02).

View File

@ -536,7 +536,8 @@ static void cle_clrtoeol(FAR struct cle_s *priv)
*
* Description:
* Make space for new text of size 'increment' at the specified cursor
* position.
* position. This function will not allow text grow beyound (linelen - 1)
* in size.
*
****************************************************************************/
@ -550,8 +551,9 @@ static bool cle_opentext(FAR struct cle_s *priv, uint16_t pos, uint16_t incremen
* of 'increment'
*/
if (priv->nchars + increment > priv->linelen)
if (priv->nchars + increment >= priv->linelen)
{
CLE_BEL(priv);
return false;
}
@ -641,7 +643,7 @@ static void cle_showtext(FAR struct cle_s *priv)
/* Loop for each column */
for (column = 0; column < priv->nchars && column < priv->linelen; )
for (column = 0; column < priv->nchars; )
{
/* Perform TAB expansion */
@ -937,5 +939,10 @@ int cle(FAR char *line, uint16_t linelen, FILE *instream, FILE *outstream)
/* The editor loop */
return cle_editloop(&priv);
ret = cle_editloop(&priv);
/* Make sure that the line is NUL terminated */
line[priv.nchars] = '\0';
return ret;
}