@@ -248,28 +248,32 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline);
248248 * Private Data
249249 ****************************************************************************/
250250
251- static const char g_token_separator [] = " \t\n" ;
252- static const char g_quote_separator [] = "'\"`" ;
251+ static const char g_token_separator [] = " \t\n" ;
252+ static const char g_quote_separator [] = "'\"`" ;
253253#ifndef NSH_DISABLE_SEMICOLON
254- static const char g_line_separator [] = "\"'#;\n" ;
254+ static const char g_line_separator [] = "\"'#;\n" ;
255255#endif
256256#ifdef CONFIG_NSH_ARGCAT
257- static const char g_arg_separator [] = "`$" ;
258- #endif
259- static const char g_redirect_out1 [] = ">" ;
260- static const char g_redirect_out2 [] = ">>" ;
261- static const char g_redirect_in1 [] = "<" ;
257+ static const char g_arg_separator [] = "`$" ;
258+ #endif
259+ static const char g_redirect_out1 [] = ">" ;
260+ static const size_t g_redirect_out1_len = sizeof (g_redirect_out1 ) - 1 ;
261+ static const char g_redirect_out2 [] = ">>" ;
262+ static const size_t g_redirect_out2_len = sizeof (g_redirect_out2 ) - 1 ;
263+ static const char g_redirect_in1 [] = "<" ;
264+ static const size_t g_redirect_in1_len = sizeof (g_redirect_in1 ) - 1 ;
262265#ifdef CONFIG_NSH_PIPELINE
263- static const char g_pipeline1 [] = "|" ;
266+ static const char g_pipeline1 [] = "|" ;
267+ static const size_t g_pipeline1_len = sizeof (g_pipeline1 ) - 1 ;
264268#endif
265269#ifdef NSH_HAVE_VARS
266- static const char g_exitstatus [] = "?" ;
267- static const char g_lastpid [] = "!" ;
268- static const char g_success [] = "0" ;
269- static const char g_failure [] = "1" ;
270+ static const char g_exitstatus [] = "?" ;
271+ static const char g_lastpid [] = "!" ;
272+ static const char g_success [] = "0" ;
273+ static const char g_failure [] = "1" ;
270274#endif
271275#ifdef NEED_NULLSTRING
272- static const char g_nullstring [] = "" ;
276+ static const char g_nullstring [] = "" ;
273277#endif
274278
275279/****************************************************************************
@@ -2447,12 +2451,6 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
24472451#ifdef CONFIG_NSH_PIPELINE
24482452 bool bg_save = false;
24492453#endif
2450- size_t redirect_out1_len = strlen (g_redirect_out1 );
2451- size_t redirect_out2_len = strlen (g_redirect_out2 );
2452- size_t redirect_in1_len = strlen (g_redirect_in1 );
2453- #ifdef CONFIG_NSH_PIPELINE
2454- size_t pipeline1_len = strlen (g_pipeline1 );
2455- #endif
24562454
24572455#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
24582456 char tracebuf [CONFIG_NSH_LINELEN + 1 ];
@@ -2601,12 +2599,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
26012599 }
26022600 }
26032601
2604- if (!strncmp (argv [argc ], g_redirect_out2 , redirect_out2_len ))
2602+ if (!strncmp (argv [argc ], g_redirect_out2 , g_redirect_out2_len ))
26052603 {
26062604 FAR char * arg ;
2607- if (argv [argc ][redirect_out2_len ])
2605+ if (argv [argc ][g_redirect_out2_len ])
26082606 {
2609- arg = & argv [argc ][redirect_out2_len ];
2607+ arg = & argv [argc ][g_redirect_out2_len ];
26102608 }
26112609 else
26122610 {
@@ -2625,12 +2623,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
26252623 param .oflags_out = O_WRONLY | O_CREAT | O_APPEND ;
26262624 param .file_out = nsh_getfullpath (vtbl , arg );
26272625 }
2628- else if (!strncmp (argv [argc ], g_redirect_out1 , redirect_out1_len ))
2626+ else if (!strncmp (argv [argc ], g_redirect_out1 , g_redirect_out1_len ))
26292627 {
26302628 FAR char * arg ;
2631- if (argv [argc ][redirect_out1_len ])
2629+ if (argv [argc ][g_redirect_out1_len ])
26322630 {
2633- arg = & argv [argc ][redirect_out1_len ];
2631+ arg = & argv [argc ][g_redirect_out1_len ];
26342632 }
26352633 else
26362634 {
@@ -2649,12 +2647,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
26492647 param .oflags_out = O_WRONLY | O_CREAT | O_TRUNC ;
26502648 param .file_out = nsh_getfullpath (vtbl , arg );
26512649 }
2652- else if (!strncmp (argv [argc ], g_redirect_in1 , redirect_in1_len ))
2650+ else if (!strncmp (argv [argc ], g_redirect_in1 , g_redirect_in1_len ))
26532651 {
26542652 FAR char * arg ;
2655- if (argv [argc ][redirect_in1_len ])
2653+ if (argv [argc ][g_redirect_in1_len ])
26562654 {
2657- arg = & argv [argc ][redirect_in1_len ];
2655+ arg = & argv [argc ][g_redirect_in1_len ];
26582656 }
26592657 else
26602658 {
@@ -2674,14 +2672,14 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
26742672 param .file_in = nsh_getfullpath (vtbl , arg );
26752673 }
26762674#ifdef CONFIG_NSH_PIPELINE
2677- else if (!strncmp (argv [argc ], g_pipeline1 , pipeline1_len ))
2675+ else if (!strncmp (argv [argc ], g_pipeline1 , g_pipeline1_len ))
26782676 {
26792677 FAR char * arg ;
26802678 FAR char * sh_argv [4 ];
26812679
2682- if (argv [argc ][pipeline1_len ])
2680+ if (argv [argc ][g_pipeline1_len ])
26832681 {
2684- arg = & argv [argc ][pipeline1_len ];
2682+ arg = & argv [argc ][g_pipeline1_len ];
26852683 }
26862684 else
26872685 {
0 commit comments