mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-09-21 07:01:57 +00:00
cli: Drop #ifdefs for CONFIG_AUTO_COMPLETE in cli_readline
Use a static inline and adjust the logic to avoid the need for #ifdefs in cli_readline_into_buffer() Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
039f8cc375
commit
6321391ac3
2 changed files with 48 additions and 43 deletions
|
@ -386,8 +386,8 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
|
|||
REFRESH_TO_EOL();
|
||||
continue;
|
||||
}
|
||||
#ifdef CONFIG_AUTO_COMPLETE
|
||||
case '\t': {
|
||||
case '\t':
|
||||
if (IS_ENABLED(CONFIG_AUTO_COMPLETE)) {
|
||||
int num2, col;
|
||||
|
||||
/* do not autocomplete when in the middle */
|
||||
|
@ -406,7 +406,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
|
|||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
fallthrough;
|
||||
default:
|
||||
cread_add_char(ichar, insert, &num, &eol_num, buf,
|
||||
*len);
|
||||
|
@ -519,14 +519,15 @@ static int cread_line_simple(const char *const prompt, char *p)
|
|||
continue;
|
||||
|
||||
default:
|
||||
/*
|
||||
* Must be a normal character then
|
||||
*/
|
||||
if (n < CONFIG_SYS_CBSIZE-2) {
|
||||
/* Must be a normal character then */
|
||||
if (n >= CONFIG_SYS_CBSIZE - 2) { /* Buffer full */
|
||||
putc('\a');
|
||||
break;
|
||||
}
|
||||
if (c == '\t') { /* expand TABs */
|
||||
#ifdef CONFIG_AUTO_COMPLETE
|
||||
if (IS_ENABLED(CONFIG_AUTO_COMPLETE)) {
|
||||
/*
|
||||
* if auto completion triggered just
|
||||
* if auto-completion triggered just
|
||||
* continue
|
||||
*/
|
||||
*p = '\0';
|
||||
|
@ -536,15 +537,15 @@ static int cread_line_simple(const char *const prompt, char *p)
|
|||
p = p_buf + n; /* reset */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
puts(tab_seq + (col & 07));
|
||||
col += 8 - (col & 07);
|
||||
} else {
|
||||
char __maybe_unused buf[2];
|
||||
|
||||
/*
|
||||
* Echo input using puts() to force an
|
||||
* LCD flush if we are using an LCD
|
||||
* Echo input using puts() to force an LCD
|
||||
* flush if we are using an LCD
|
||||
*/
|
||||
++col;
|
||||
buf[0] = c;
|
||||
|
@ -553,9 +554,7 @@ static int cread_line_simple(const char *const prompt, char *p)
|
|||
}
|
||||
*p++ = c;
|
||||
++n;
|
||||
} else { /* Buffer full */
|
||||
putc('\a');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,12 @@ int var_complete(int argc, char *const argv[], char last_char, int maxv,
|
|||
char *cmdv[]);
|
||||
int cmd_auto_complete(const char *const prompt, char *buf, int *np,
|
||||
int *colp);
|
||||
#else
|
||||
static inline int cmd_auto_complete(const char *const prompt, char *buf,
|
||||
int *np, int *colp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue