xiaoxiang781216 commented on code in PR #1559:
URL: https://github.com/apache/nuttx-apps/pull/1559#discussion_r1113432158


##########
nshlib/nsh_console.c:
##########
@@ -115,33 +82,22 @@ static int nsh_openifnotopen(struct console_stdio_s 
*pstate)
  *
  ****************************************************************************/
 
-#ifdef CONFIG_FILE_STREAM
 static void nsh_closeifnotclosed(struct console_stdio_s *pstate)
 {
-  if (pstate->cn_outstream == OUTSTREAM(pstate))
+  if (OUTFD(pstate) >= 0)

Review Comment:
   ```suggestion
     if (OUTFD(pstate) >= 0 && OUTFD(pstate) != STDOUT_FILENO)
   ```



##########
nshlib/nsh_session.c:
##########
@@ -194,34 +191,33 @@ int nsh_session(FAR struct console_stdio_s *pstate,
        * occurs. Either  will cause the session to terminate.
        */
 
-      ret = cle(pstate->cn_line, g_nshprompt, CONFIG_NSH_LINELEN,
-                INSTREAM(pstate), OUTSTREAM(pstate));
+      ret = cle_fd(pstate->cn_line, g_nshprompt, CONFIG_NSH_LINELEN,
+                   STDIN_FILENO, STDOUT_FILENO);

Review Comment:
   ```suggestion
                      INFD(pstate), OUTFD(pstate));
   ```



##########
nshlib/nsh_session.c:
##########
@@ -194,34 +191,33 @@ int nsh_session(FAR struct console_stdio_s *pstate,
        * occurs. Either  will cause the session to terminate.
        */
 
-      ret = cle(pstate->cn_line, g_nshprompt, CONFIG_NSH_LINELEN,
-                INSTREAM(pstate), OUTSTREAM(pstate));
+      ret = cle_fd(pstate->cn_line, g_nshprompt, CONFIG_NSH_LINELEN,
+                   STDIN_FILENO, STDOUT_FILENO);
       if (ret < 0)
         {
-          fprintf(pstate->cn_errstream, g_fmtcmdfailed, "nsh_session",
+          dprintf(ERRFD(pstate), g_fmtcmdfailed, "nsh_session",
                   "cle", NSH_ERRNO_OF(-ret));
           continue;
         }
 #else
       /* Display the prompt string */
 
-      fputs(g_nshprompt, pstate->cn_outstream);
-      fflush(pstate->cn_outstream);
+      write(OUTFD(pstate), g_nshprompt, strlen(g_nshprompt));
 
       /* readline() normally returns the number of characters read, but
        * will return EOF on end of file or if an error occurs.  EOF
        * will cause the session to terminate.
        */
 
-      ret = readline(pstate->cn_line, CONFIG_NSH_LINELEN,
-                    INSTREAM(pstate), OUTSTREAM(pstate));
+      ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
+                        STDIN_FILENO, STDOUT_FILENO);

Review Comment:
   ```suggestion
                           INFD(pstate), OUTFD(pstate));
   ```



-- 
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