Handle ^Z in dietline and fix build target

This commit is contained in:
pancake 2012-08-09 10:13:46 +02:00
parent 44ee3ce8d2
commit d2c48b1358
2 changed files with 7 additions and 6 deletions

View File

@ -4,3 +4,5 @@ OBJ=line.o
#LINK=-L../cons -lr_cons -Wl,-R../cons ../util/*.a
include ../rules.mk
line.o: dietline.c

View File

@ -53,15 +53,14 @@ static int r_line_readchar() {
#else
do {
int ret = read (0, buf, 1);
if (ret == -1)
return 0; // read no char
if (ret == 0) // EOF
return -1;
//eprintf ("(((%x)))\n", *buf);
if (ret == -1) return 0; // read no char
if (ret == 0) return -1; // eof
// TODO: add support for other invalid chars
if (*buf==0x1a) { // ^Z
kill (getpid (), SIGSTOP);
}
if (*buf==0xc2 || *buf==0xc3) {
read (0, buf+1, 1);
//eprintf ("(((%x)))\n", buf[1]);
*buf = '\0';
}
} while (*buf == '\0');