From 89e75021fa591cada8147f107d72a1633503c310 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 28 Mar 2007 21:18:45 +0000 Subject: [PATCH] Various buglets fixed (from submitter): The changes to getstr() is so that the character that is passed in to it, is also processed just as the rest. I also removed one of the getc() calls otherwise you loose every second character. I also changed the strcpy of kname, so that it only happens if kname is '\0'. This is so that one can pass a kernel in through /boot.config. The last change to boot2.c is in parse(). If you tried to type a kernel name to boot, the first character was lost, the arg-- fix that. Submitted by: jhay --- sys/boot/arm/at91/boot2/boot2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/boot/arm/at91/boot2/boot2.c b/sys/boot/arm/at91/boot2/boot2.c index 5292f5792f60..d336f40f001f 100644 --- a/sys/boot/arm/at91/boot2/boot2.c +++ b/sys/boot/arm/at91/boot2/boot2.c @@ -114,12 +114,10 @@ getstr(int c) char *s; s = cmd; - if (c) - *s++ = c; - for (;;) { + if (c == 0) c = getc(10000); - - switch (c = getc(10000)) { + for (;;) { + switch (c) { case 0: break; case '\177': @@ -138,6 +136,7 @@ getstr(int c) *s++ = c; xputchar(c); } + c = getc(10000); } } @@ -170,7 +169,8 @@ main(void) /* Present the user with the boot2 prompt. */ - strcpy(kname, PATH_KERNEL); + if (*kname == '\0') + strcpy(kname, PATH_KERNEL); for (;;) { printf("\nDefault: %s\nboot: ", kname); if (!autoboot || (c = getc(2)) != -1) @@ -252,6 +252,7 @@ parse() opts ^= OPT_SET(flags[i]); } } else { + arg--; if ((i = ep - arg)) { if ((size_t)i >= sizeof(kname)) return -1;