Explorar o código

fix getc - the classic error of trying to store EOF+0-255 in a char type..

Rich Felker %!s(int64=14) %!d(string=hai) anos
pai
achega
05b694028e
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      src/stdio/__uflow.c

+ 3 - 3
src/stdio/__uflow.c

@@ -5,7 +5,7 @@
 
 int __uflow(FILE *f)
 {
-	unsigned char c = EOF;
-	if (f->rend || !__toread(f)) f->read(f, &c, 1);
-	return c;
+	unsigned char c;
+	if ((f->rend || !__toread(f)) && f->read(f, &c, 1)==1) return c;
+	return EOF;
 }