change gets to return \n, to distinguish 0-byte read from empty line

This commit is contained in:
rsc 2007-08-08 08:04:20 +00:00
parent 07018064bb
commit a059f02596
1 changed files with 1 additions and 1 deletions

2
ulib.c
View File

@ -67,9 +67,9 @@ gets(char *buf, int max)
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
buf[i++] = c;
}
buf[i] = '\0';
return buf;