acassis commented on a change in pull request #892:
URL: 
https://github.com/apache/incubator-nuttx-apps/pull/892#discussion_r758343383



##########
File path: system/readline/readline.c
##########
@@ -177,52 +36,20 @@ static void readline_write(FAR struct rl_common_s *vtbl,
 /****************************************************************************
  * Name: readline
  *
- *   readline() reads in at most one less than 'buflen' characters from
- *   'instream' and stores them into the buffer pointed to by 'buf'.
- *   Characters are echoed on 'outstream'.  Reading stops after an EOF or a
- *   newline.  If a newline is read, it is stored into the buffer.  A null
- *   terminator is stored after the last character in the buffer.
- *
- *   This version of realine assumes that we are reading and writing to
- *   a VT100 console.  This will not work well if 'instream' or 'outstream'
- *   corresponds to a raw byte steam.
- *
- *   This function is inspired by the GNU readline but is an entirely
- *   different creature.
- *
- * Input Parameters:
- *   buf       - The user allocated buffer to be filled.
- *   buflen    - the size of the buffer.
- *   instream  - The stream to read characters from
- *   outstream - The stream to each characters to.
- *
- * Returned values:
- *   On success, the (positive) number of bytes transferred is returned.
- *   EOF is returned to indicate either an end of file condition or a
- *   failure.
+ *   readline() is same as readline_fd() but accept the file stream instead
+ *   of file handle.
  *
  ****************************************************************************/
 
+#ifdef CONFIG_FILE_STREAM
 ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream)
 {
-  struct readline_s vtbl;
-
   /* Sanity checks */
 
   DEBUGASSERT(instream && outstream);
 
-  /* Set up the vtbl structure */
-
-  vtbl.vtbl.rl_getc  = readline_getc;
-  vtbl.infd          = instream->fs_fd;
+  /* Let readline_fd do the work */
 
-#ifdef CONFIG_READLINE_ECHO
-  vtbl.vtbl.rl_putc  = readline_putc;
-  vtbl.vtbl.rl_write = readline_write;
-  vtbl.outfd         = outstream->fs_fd;
-#endif
-
-  /* The let the common readline logic do the work */
-
-  return readline_common(&vtbl.vtbl, buf, buflen);
+  return readline_fd(buf, buflen, instream->fs_fd, outstream->fs_fd);
 }
+#endif

Review comment:
       @xiaoxiang781216 what is your plan creating the readline_fd() ? :-)
   Should it be possible to use the new "readline" even when CONFIG_FILE_STREAM 
is not defined? In the past we had a readline version was used in the "minnsh" 
PoC, but the "minnsh" was removed when the VFS support was required to get a 
NuttX compliant code. Using minnsh it was possible to run NuttX on a MCU with 
less than 2KB RAM: https://flickr.com/photos/79703543@N00/18013069041/ It was 
similar to ChibiOS/NIL idea, but with even more features.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to