You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/01 14:18:16 UTC

[incubator-nuttx-apps] 02/02: Remove trailing whitespace from commands as parameters

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 6285990a5c4fe01accce6daef0f7dd3f12c1203c
Author: Norman Rasmussen <no...@rasmussen.co.za>
AuthorDate: Fri Dec 31 06:02:26 2021 -0800

    Remove trailing whitespace from commands as parameters
---
 nshlib/nsh_parse.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c
index bca4c6c..c15115e 100644
--- a/nshlib/nsh_parse.c
+++ b/nshlib/nsh_parse.c
@@ -829,7 +829,7 @@ static FAR char *nsh_filecat(FAR struct nsh_vtbl_s *vtbl, FAR char *s1,
   fd = open(filename, O_RDONLY);
   if (fd < 0)
     {
-      nsh_error(vtbl, g_fmtcmdfailed,  "``", "open", NSH_ERRNO);
+      nsh_error(vtbl, g_fmtcmdfailed, "``", "open", NSH_ERRNO);
       goto errout_with_alloc;
     }
 
@@ -877,6 +877,13 @@ static FAR char *nsh_filecat(FAR struct nsh_vtbl_s *vtbl, FAR char *s1,
       index += nbytesread;
     }
 
+  /* Remove trailing whitespace */
+
+  for (;
+       index > s1size &&
+       strchr(g_token_separator, argument[index - 1]) != NULL;
+       index--);
+
   /* Make sure that the new string is null terminated */
 
   argument[index] = '\0';