
Hi Joe,
On Sun, Feb 24, 2013 at 12:56 PM, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Simon,
On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass sjg@chromium.org wrote:
Remove #ifdefs in favour of autoconf for this code. This involves removing a few unnecessary #ifdefs in headers also.
We have two versions of the code - one that handles command line editing and one that is just a simple implementation. Create a new function called readline_into_buffer() which calls either cread_line() or the new simple_readline(), created to hold the 'simple' code.
The cread_print_hist_list() function is not actually used anywhere, so punt it.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
common/main.c | 186 ++++++++++++++++++++++++------------------------------ include/command.h | 2 - include/common.h | 2 - 3 files changed, 84 insertions(+), 106 deletions(-)
diff --git a/common/main.c b/common/main.c index e1483db..3966321 100644 --- a/common/main.c +++ b/common/main.c
[snip]
It would be great if you separated the following unrelated formatting changes into a separate patch.
OK, will do.
/* * Special character handling */ switch (c) {
case '\r': /* Enter */
case '\r': /* Enter */ case '\n': *p = '\0'; puts ("\r\n");
return (p - p_buf);
return p - p_buf;
case '\0': /* nul */
case '\0': /* nul */ continue;
case 0x03: /* ^C - break */
case 0x03: /* ^C - break */ p_buf[0] = '\0'; /* discard input */
return (-1);
return -1;
case 0x15: /* ^U - erase line */
case 0x15: /* ^U - erase line */ while (col > plen) { puts (erase_seq); --col;
@@ -1045,15 +988,15 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout) n = 0; continue;
case 0x17: /* ^W - erase word */
case 0x17: /* ^W - erase word */ p=delete_char(p_buf, p, &col, &n, plen); while ((n > 0) && (*p != ' ')) { p=delete_char(p_buf, p, &col, &n, plen); } continue;
case 0x08: /* ^H - backspace */
case 0x7F: /* DEL - backspace */
case 0x08: /* ^H - backspace */
case 0x7F: /* DEL - backspace */ p=delete_char(p_buf, p, &col, &n, plen); continue;
@@ -1062,22 +1005,28 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout) * Must be a normal character then */ if (n < CONFIG_SYS_CBSIZE-2) {
if (c == '\t') { /* expand TABs */
-#ifdef CONFIG_AUTO_COMPLETE
/* if auto completion triggered just continue */
*p = '\0';
if (cmd_auto_complete(prompt, console_buffer, &n, &col)) {
p = p_buf + n; /* reset */
continue;
if (c == '\t') { /* expand TABs */
if (autoconf_auto_complete()) {
/*
* if auto completion triggered
* just continue
*/
*p = '\0';
if (cmd_auto_complete(prompt,
console_buffer,
&n, &col)) {
/* reset */
p = p_buf + n;
continue;
} }
-#endif puts (tab_seq+(col&07)); col += 8 - (col&07); } else { char buf[2];
/*
* Echo input using puts() to force am
* Echo input using puts() to force an * LCD flush if we are using an LCD */ ++col;
[snip]
Regards, Simon