diff options
author | Tom Rini <trini@konsulko.com> | 2023-11-07 18:33:09 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-11-07 18:33:09 -0500 |
commit | 1e4d9dd871512e1955e45ac1c3095fb063c0d07c (patch) | |
tree | 3770d9ca70d5f8447a25bdabe03c7c60f4fd29aa /common/cli_simple.c | |
parent | 3af0e9556c968fc2c40e3778d8f1e668a90af92e (diff) | |
parent | d7f592da6ee90b11cea4d2ad4d0f39d6d26fc3b6 (diff) |
Merge branch '2023-11-07-assorted-big-cleanups' into next
- Merge in changes such that CONFIG_CMDLINE can be disabled and merge
in a series that starts to remove <common.h> usage.
Diffstat (limited to 'common/cli_simple.c')
-rw-r--r-- | common/cli_simple.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/common/cli_simple.c b/common/cli_simple.c index e80ba488a5e..f89ba92d1b0 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -22,44 +22,6 @@ #define debug_parser(fmt, args...) \ debug_cond(DEBUG_PARSER, fmt, ##args) - -int cli_simple_parse_line(char *line, char *argv[]) -{ - int nargs = 0; - - debug_parser("%s: \"%s\"\n", __func__, line); - while (nargs < CONFIG_SYS_MAXARGS) { - /* skip any white space */ - while (isblank(*line)) - ++line; - - if (*line == '\0') { /* end of line, no more args */ - argv[nargs] = NULL; - debug_parser("%s: nargs=%d\n", __func__, nargs); - return nargs; - } - - argv[nargs++] = line; /* begin of argument string */ - - /* find end of string */ - while (*line && !isblank(*line)) - ++line; - - if (*line == '\0') { /* end of line, no more args */ - argv[nargs] = NULL; - debug_parser("parse_line: nargs=%d\n", nargs); - return nargs; - } - - *line++ = '\0'; /* terminate current arg */ - } - - printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS); - - debug_parser("%s: nargs=%d\n", __func__, nargs); - return nargs; -} - int cli_simple_process_macros(const char *input, char *output, int max_size) { char c, prev; @@ -172,6 +134,44 @@ int cli_simple_process_macros(const char *input, char *output, int max_size) return ret; } +#ifdef CONFIG_CMDLINE +int cli_simple_parse_line(char *line, char *argv[]) +{ + int nargs = 0; + + debug_parser("%s: \"%s\"\n", __func__, line); + while (nargs < CONFIG_SYS_MAXARGS) { + /* skip any white space */ + while (isblank(*line)) + ++line; + + if (*line == '\0') { /* end of line, no more args */ + argv[nargs] = NULL; + debug_parser("%s: nargs=%d\n", __func__, nargs); + return nargs; + } + + argv[nargs++] = line; /* begin of argument string */ + + /* find end of string */ + while (*line && !isblank(*line)) + ++line; + + if (*line == '\0') { /* end of line, no more args */ + argv[nargs] = NULL; + debug_parser("parse_line: nargs=%d\n", nargs); + return nargs; + } + + *line++ = '\0'; /* terminate current arg */ + } + + printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS); + + debug_parser("%s: nargs=%d\n", __func__, nargs); + return nargs; +} + /* * WARNING: * @@ -346,3 +346,4 @@ int cli_simple_run_command_list(char *cmd, int flag) return rcode; } +#endif |