If one defines HUSH_2021_PARSER, cli_loop() will jump on hush 2021 parser code.
Signed-off-by: Francis Laniel <francis.lan...@amarulasolutions.com> Reviewed-by: Simon Glass <s...@chromium.org> --- common/cli.c | 14 +++++++++++--- include/cli_hush.h | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/cli.c b/common/cli.c index d86046a728..090677f7a0 100644 --- a/common/cli.c +++ b/common/cli.c @@ -40,12 +40,15 @@ int run_command(const char *cmd, int flag) return 1; return 0; -#else +#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; if (flag & CMD_FLAG_ENV) hush_flags |= FLAG_CONT_ON_NEWLINE; return parse_string_outer(cmd, hush_flags); +#else /* HUSH_2021_PARSER */ + /* Not yet implemented. */ + return 0; #endif } @@ -104,7 +107,7 @@ int run_command_list(const char *cmd, int len, int flag) memcpy(buff, cmd, len); buff[len] = '\0'; } -#ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON); #else /* @@ -225,7 +228,12 @@ err: void cli_loop(void) { bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP); -#ifdef CONFIG_HUSH_PARSER +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + parse_and_run_file(); + printf("Problem\n"); + /* This point is never reached */ + for (;;); +#elif CONFIG_IS_ENABLED(CONFIG_HUSH_OLD_PARSER) parse_file_outer(); /* This point is never reached */ for (;;); diff --git a/include/cli_hush.h b/include/cli_hush.h index 2bd35670c7..f6c04929b9 100644 --- a/include/cli_hush.h +++ b/include/cli_hush.h @@ -14,9 +14,17 @@ extern int u_boot_hush_start(void); extern int parse_string_outer(const char *, int); +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) extern int parse_file_outer(void); +#elif CONFIG_IS_ENABLED(HUSH_2021_PARSER) +extern void parse_and_run_file(void); +#endif +#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER) int set_local_var(const char *s, int flg_export); +#elif CONFIG_IS_ENABLED(HUSH_2021_PARSER) +int set_local_var(char *s, int flg_export); +#endif void unset_local_var(const char *name); char *get_local_var(const char *s); -- 2.25.1