@@ -248,28 +248,32 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline);
248
248
* Private Data
249
249
****************************************************************************/
250
250
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[] = "'\"`";
253
253
#ifndef NSH_DISABLE_SEMICOLON
254
- static const char g_line_separator[] = "\"'#;\n";
254
+ static const char g_line_separator[] = "\"'#;\n";
255
255
#endif
256
256
#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;
262
265
#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;
264
268
#endif
265
269
#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";
270
274
#endif
271
275
#ifdef NEED_NULLSTRING
272
- static const char g_nullstring[] = "";
276
+ static const char g_nullstring[] = "";
273
277
#endif
274
278
275
279
/****************************************************************************
@@ -2447,12 +2451,6 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
2447
2451
#ifdef CONFIG_NSH_PIPELINE
2448
2452
bool bg_save = false;
2449
2453
#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
2456
2454
2457
2455
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
2458
2456
char tracebuf[CONFIG_NSH_LINELEN + 1];
@@ -2601,12 +2599,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
2601
2599
}
2602
2600
}
2603
2601
2604
- if (!strncmp(argv[argc], g_redirect_out2, redirect_out2_len ))
2602
+ if (!strncmp(argv[argc], g_redirect_out2, g_redirect_out2_len ))
2605
2603
{
2606
2604
FAR char *arg;
2607
- if (argv[argc][redirect_out2_len ])
2605
+ if (argv[argc][g_redirect_out2_len ])
2608
2606
{
2609
- arg = &argv[argc][redirect_out2_len ];
2607
+ arg = &argv[argc][g_redirect_out2_len ];
2610
2608
}
2611
2609
else
2612
2610
{
@@ -2625,12 +2623,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
2625
2623
param.oflags_out = O_WRONLY | O_CREAT | O_APPEND;
2626
2624
param.file_out = nsh_getfullpath(vtbl, arg);
2627
2625
}
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 ))
2629
2627
{
2630
2628
FAR char *arg;
2631
- if (argv[argc][redirect_out1_len ])
2629
+ if (argv[argc][g_redirect_out1_len ])
2632
2630
{
2633
- arg = &argv[argc][redirect_out1_len ];
2631
+ arg = &argv[argc][g_redirect_out1_len ];
2634
2632
}
2635
2633
else
2636
2634
{
@@ -2649,12 +2647,12 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
2649
2647
param.oflags_out = O_WRONLY | O_CREAT | O_TRUNC;
2650
2648
param.file_out = nsh_getfullpath(vtbl, arg);
2651
2649
}
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 ))
2653
2651
{
2654
2652
FAR char *arg;
2655
- if (argv[argc][redirect_in1_len ])
2653
+ if (argv[argc][g_redirect_in1_len ])
2656
2654
{
2657
- arg = &argv[argc][redirect_in1_len ];
2655
+ arg = &argv[argc][g_redirect_in1_len ];
2658
2656
}
2659
2657
else
2660
2658
{
@@ -2674,14 +2672,14 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
2674
2672
param.file_in = nsh_getfullpath(vtbl, arg);
2675
2673
}
2676
2674
#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 ))
2678
2676
{
2679
2677
FAR char *arg;
2680
2678
FAR char *sh_argv[4];
2681
2679
2682
- if (argv[argc][pipeline1_len ])
2680
+ if (argv[argc][g_pipeline1_len ])
2683
2681
{
2684
- arg = &argv[argc][pipeline1_len ];
2682
+ arg = &argv[argc][g_pipeline1_len ];
2685
2683
}
2686
2684
else
2687
2685
{
0 commit comments