diff --git a/sys/arch/luna68k/stand/boot/getline.c b/sys/arch/luna68k/stand/boot/getline.c index 50287eeadec9..010874d2606b 100644 --- a/sys/arch/luna68k/stand/boot/getline.c +++ b/sys/arch/luna68k/stand/boot/getline.c @@ -1,4 +1,4 @@ -/* $NetBSD: getline.c,v 1.2 2013/01/20 07:32:45 tsutsui Exp $ */ +/* $NetBSD: getline.c,v 1.3 2014/01/03 06:37:13 tsutsui Exp $ */ /* * Copyright (c) 1992 OMRON Corporation. @@ -79,40 +79,54 @@ #include int -getline(char *prompt, char *buff) +getline(const char *prompt, char *buff) { int c; - char *p = buff; + char *p, *lp = buff; printf("%s", prompt); - for(;;) { - c = getchar() & 0x7F; + for (;;) { + c = getchar() & 0x7f; switch (c) { - case 0x0a: - case 0x0d: + case '\n': + case '\r': + *lp = '\0'; putchar('\n'); - *p = '\0'; goto outloop; - case 0x08: + case '\b': case 0x7f: - if (p > buff) { - putchar(0x08); + if (lp > buff) { + lp--; + putchar('\b'); putchar(' '); - putchar(0x08); - p--; + putchar('\b'); } break; + case 'r' & 0x1f: + putchar('\n'); + printf("%s", prompt); + for (p = buff; p < lp; ++p) + putchar(*p); + break; + + case 'u' & 0x1f: + case 'w' & 0x1f: + lp = buff; + printf("\n%s", prompt); + break; + default: - *p++ = c; + *lp++ = c; putchar(c); break; } } outloop: - return(strlen(buff)); + *lp = '\0'; + return lp - buff; } diff --git a/sys/arch/luna68k/stand/boot/init_main.c b/sys/arch/luna68k/stand/boot/init_main.c index 509d7e8ecc40..bbc20057153c 100644 --- a/sys/arch/luna68k/stand/boot/init_main.c +++ b/sys/arch/luna68k/stand/boot/init_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */ +/* $NetBSD: init_main.c,v 1.7 2014/01/03 06:37:13 tsutsui Exp $ */ /* * Copyright (c) 1992 OMRON Corporation. @@ -112,7 +112,7 @@ char *argv[MAXARGS]; #define BOOT_TIMEOUT 10 int boot_timeout = BOOT_TIMEOUT; -char prompt[16] = "boot> "; +static const char prompt[] = "boot> "; void main(void) diff --git a/sys/arch/luna68k/stand/boot/samachdep.h b/sys/arch/luna68k/stand/boot/samachdep.h index 445b4715a5f8..d1908203d697 100644 --- a/sys/arch/luna68k/stand/boot/samachdep.h +++ b/sys/arch/luna68k/stand/boot/samachdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: samachdep.h,v 1.12 2014/01/03 06:15:10 tsutsui Exp $ */ +/* $NetBSD: samachdep.h,v 1.13 2014/01/03 06:37:13 tsutsui Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -103,7 +103,7 @@ int fsdump(int, char **); int fsrestore(int, char **); /* getline.c */ -int getline(char *, char *); +int getline(const char *, char *); /* if_le.c */ int leinit(void *);