mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
cli_simple: Rework this support slightly
The interactive portion of our non-HUSH 'simple' parser is guarded by CONFIG_CMDLINE already. Much of the code behind this simple parser is also used as "input" parser, such as from menu interfaces and so forth and not strictly command line input. To support this, always build the assorted cli object files, but guard the interactive portions of cli_simple.c with a CMDLINE check. Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
d83f4e6265
commit
2cb52fbf1d
2 changed files with 40 additions and 39 deletions
|
@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
|
|||
obj-y += init/
|
||||
obj-y += main.o
|
||||
obj-y += exports.o
|
||||
obj-y += cli_getch.o cli_simple.o cli_readline.o
|
||||
obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
|
||||
obj-$(CONFIG_AUTOBOOT) += autoboot.o
|
||||
obj-y += version.o
|
||||
|
@ -38,7 +39,6 @@ obj-$(CONFIG_SPLASH_SOURCE) += splash_source.o
|
|||
obj-$(CONFIG_MENU) += menu.o
|
||||
obj-$(CONFIG_UPDATE_COMMON) += update.o
|
||||
obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
|
||||
obj-$(CONFIG_CMDLINE) += cli_getch.o cli_readline.o cli_simple.o
|
||||
|
||||
endif # !CONFIG_SPL_BUILD
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue