ref: 22e4f93e4cfa71867709d7486793d4f7a912dbbf
parent: 7cd063ed492f851b6b4f68c981d88ed6a761b372
parent: d4d6143eec631fa520c26482defdf3804b051f26
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Aug 20 11:12:37 EDT 2018
Merge remote-tracking branch 'simple-cc/master'
--- a/lib/c/fopen.c
+++ b/lib/c/fopen.c
@@ -12,7 +12,7 @@
FILE *fp;
for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
- if (fp->flags & (_IOREAD | _IOWRITE | _IORW) == 0)
+ if ((fp->flags & (_IOREAD | _IOWRITE | _IORW)) == 0)
break;
}
if (fp == &__iob[FOPEN_MAX]) {
--- a/lib/c/fread.c
+++ b/lib/c/fread.c
@@ -8,6 +8,7 @@
{
unsigned char *bp = ptr;
size_t n, i;
+ int c;
if (size == 0)
return 0;
@@ -15,8 +16,9 @@
for (n = 0; n < nmemb; n++) {
i = size;
do {
- if ((*bp++ = getc(fp)) == EOF)
+ if ((c = getc(fp)) == EOF)
return n;
+ *bp++ = c;
} while (--i);
}