Skip to content

Commit

Permalink
oops - broke circular buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 30, 2007
1 parent 71d5bf4 commit 3732119
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ console_intr(int (*getc)(void))
break;
default:
if(c != 0 && input.e < input.r+INPUT_BUF){
input.buf[input.e++] = c;
input.buf[input.e++ % INPUT_BUF] = c;
cons_putc(c);
if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){
input.w = input.e;
Expand Down Expand Up @@ -250,7 +250,7 @@ console_read(struct inode *ip, char *dst, int n)
}
sleep(&input.r, &input.lock);
}
c = input.buf[input.r++];
c = input.buf[input.r++ % INPUT_BUF];
if(c == C('D')){ // EOF
if(n < target){
// Save ^D for next time, to make sure
Expand All @@ -263,8 +263,6 @@ console_read(struct inode *ip, char *dst, int n)
--n;
if(c == '\n')
break;
if(input.r >= INPUT_BUF)
input.r = 0;
}
release(&input.lock);
ilock(ip);
Expand Down

0 comments on commit 3732119

Please sign in to comment.