nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From masay...@apache.org
Subject [incubator-nuttx-apps] branch master updated: nsh/command: do not show the module application in built-in list
Date Fri, 03 Apr 2020 06:59:55 GMT
This is an automated email from the ASF dual-hosted git repository.

masayuki 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 9968461  nsh/command: do not show the module application in built-in list
9968461 is described below

commit 9968461c2be694e042035f774ab6e98e088cceab
Author: chao.an <anchao@xiaomi.com>
AuthorDate: Fri Feb 21 10:32:23 2020 +0800

    nsh/command: do not show the module application in built-in list
    
    Change-Id: Ia6dd5dcf7d7eb829fde67c522f7ee2155a4051ce
    Signed-off-by: chao.an <anchao@xiaomi.com>
---
 nshlib/nsh_command.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 819bfae..da749a8 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -766,12 +766,12 @@ static inline void help_allcmds(FAR struct nsh_vtbl_s *vtbl)
 static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
 {
 #ifdef CONFIG_NSH_BUILTIN_APPS
-  FAR const char *name;
-  unsigned int num_builtins;
-  unsigned int column_width;
-  unsigned int builtin_width;
+  FAR const struct builtin_s *builtin;
   unsigned int builtins_per_line;
   unsigned int num_builtin_rows;
+  unsigned int builtin_width;
+  unsigned int num_builtins;
+  unsigned int column_width;
   unsigned int i;
   unsigned int j;
   unsigned int k;
@@ -781,17 +781,29 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
   num_builtins = 0;
   column_width = 0;
 
-  for (i = 0; (name = builtin_getname(i)) != NULL; i++)
+  for (i = 0; (builtin = builtin_for_index(i)) != NULL; i++)
     {
+      if (builtin->main == NULL)
+        {
+          continue;
+        }
+
       num_builtins++;
 
-      builtin_width = strlen(name);
+      builtin_width = strlen(builtin->name);
       if (builtin_width > column_width)
         {
           column_width = builtin_width;
         }
     }
 
+  /* Skip the printing if no available built-in commands */
+
+  if (num_builtins == 0)
+    {
+      return;
+    }
+
   column_width += 2;
 
   /* Determine the number of commands to put on one line */
@@ -817,13 +829,18 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
     {
       nsh_output(vtbl, "  ");
       for (j = 0, k = i;
-           j < builtins_per_line && k < num_builtins;
+           j < builtins_per_line &&
+           (builtin = builtin_for_index(k));
            j++, k += num_builtin_rows)
         {
-          name = builtin_getname(k);
-          nsh_output(vtbl, "%s", name);
+          if (builtin->main == NULL)
+            {
+              continue;
+            }
+
+          nsh_output(vtbl, "%s", builtin->name);
 
-          for (builtin_width = strlen(name);
+          for (builtin_width = strlen(builtin->name);
                builtin_width < column_width;
                builtin_width++)
             {


Mime
View raw message