fix echo for EOF ending
This commit is contained in:
parent
a850aeed63
commit
718829335b
2 changed files with 4 additions and 3 deletions
6
boot.c
6
boot.c
|
@ -39,12 +39,12 @@ int echo_size;
|
||||||
|
|
||||||
int readchar() {
|
int readchar() {
|
||||||
int ch = getchar();
|
int ch = getchar();
|
||||||
if (ch != '\n') {
|
if (ch == '\n' || ch == -1) {
|
||||||
echo_buffer[echo_size++] = ch;
|
|
||||||
} else {
|
|
||||||
echo_buffer[echo_size++] = 0;
|
echo_buffer[echo_size++] = 0;
|
||||||
printf("#@%s\n", echo_buffer);
|
printf("#@%s\n", echo_buffer);
|
||||||
echo_size = 0;
|
echo_size = 0;
|
||||||
|
} else {
|
||||||
|
echo_buffer[echo_size++] = ch;
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
1
demo/empty.c
Normal file
1
demo/empty.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
int main() {}
|
Loading…
Add table
Add a link
Reference in a new issue