Skip to content

Commit

Permalink
bios/main: handle all types of carriage return (\r, \n, \r\n or \n\r)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Oct 9, 2018
1 parent 9f083e9 commit 10624c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions litex/soc/software/bios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,17 @@ static void crcbios(void)

static void readstr(char *s, int size)
{
static char skip = 0;
char c[2];
int ptr;

c[1] = 0;
ptr = 0;
while(1) {
c[0] = readchar();
if (c[0] == skip)
continue;
skip = 0;
switch(c[0]) {
case 0x7f:
case 0x08:
Expand All @@ -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;
Expand Down

0 comments on commit 10624c2

Please sign in to comment.