From: Florent Kermarrec Date: Tue, 9 Oct 2018 08:06:32 +0000 (+0200) Subject: bios/main: handle all types of carriage return (\r, \n, \r\n or \n\r) X-Git-Tag: 24jan2021_ls180~1565 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10624c26da9577b7228e1af28ee26389bce7f905;p=litex.git bios/main: handle all types of carriage return (\r, \n, \r\n or \n\r) --- diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index 818a069d..e3db0ac0 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -442,6 +442,7 @@ static void crcbios(void) static void readstr(char *s, int size) { + static char skip = 0; char c[2]; int ptr; @@ -449,6 +450,9 @@ static void readstr(char *s, int size) ptr = 0; while(1) { c[0] = readchar(); + if (c[0] == skip) + continue; + skip = 0; switch(c[0]) { case 0x7f: case 0x08: @@ -460,7 +464,12 @@ static void readstr(char *s, int size) case 0x07: break; case '\r': + skip = '\n'; + s[ptr] = 0x00; + putsnonl("\n"); + return; case '\n': + skip = '\r'; s[ptr] = 0x00; putsnonl("\n"); return;