cosmetic changes (thanks Harry Porter)

This commit is contained in:
Frans Kaashoek 2022-08-12 10:57:16 -04:00
parent 8bd04852c9
commit dd5a720044
3 changed files with 10 additions and 10 deletions

View file

@ -27,7 +27,7 @@
// //
// send one character to the uart. // send one character to the uart.
// called by printf, and to echo input characters, // called by printf(), and to echo input characters,
// but not from write(). // but not from write().
// //
void void
@ -45,8 +45,8 @@ struct {
struct spinlock lock; struct spinlock lock;
// input // input
#define INPUT_BUF 128 #define INPUT_BUF_SIZE 128
char buf[INPUT_BUF]; char buf[INPUT_BUF_SIZE];
uint r; // Read index uint r; // Read index
uint w; // Write index uint w; // Write index
uint e; // Edit index uint e; // Edit index
@ -96,7 +96,7 @@ consoleread(int user_dst, uint64 dst, int n)
sleep(&cons.r, &cons.lock); sleep(&cons.r, &cons.lock);
} }
c = cons.buf[cons.r++ % INPUT_BUF]; c = cons.buf[cons.r++ % INPUT_BUF_SIZE];
if(c == C('D')){ // end-of-file if(c == C('D')){ // end-of-file
if(n < target){ if(n < target){
@ -143,7 +143,7 @@ consoleintr(int c)
break; break;
case C('U'): // Kill line. case C('U'): // Kill line.
while(cons.e != cons.w && while(cons.e != cons.w &&
cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){ cons.buf[(cons.e-1) % INPUT_BUF_SIZE] != '\n'){
cons.e--; cons.e--;
consputc(BACKSPACE); consputc(BACKSPACE);
} }
@ -156,16 +156,16 @@ consoleintr(int c)
} }
break; break;
default: default:
if(c != 0 && cons.e-cons.r < INPUT_BUF){ if(c != 0 && cons.e-cons.r < INPUT_BUF_SIZE){
c = (c == '\r') ? '\n' : c; c = (c == '\r') ? '\n' : c;
// echo back to the user. // echo back to the user.
consputc(c); consputc(c);
// store for consumption by consoleread(). // store for consumption by consoleread().
cons.buf[cons.e++ % INPUT_BUF] = c; cons.buf[cons.e++ % INPUT_BUF_SIZE] = c;
if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){ if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF_SIZE){
// wake up consoleread() if a whole line (or end-of-file) // wake up consoleread() if a whole line (or end-of-file)
// has arrived. // has arrived.
cons.w = cons.e; cons.w = cons.e;

View file

@ -175,7 +175,7 @@ uartgetc(void)
// handle a uart interrupt, raised because input has // handle a uart interrupt, raised because input has
// arrived, or the uart is ready for more output, or // arrived, or the uart is ready for more output, or
// both. called from trap.c. // both. called from devintr().
void void
uartintr(void) uartintr(void)
{ {