Make more improvements
This change includes many bug fixes, for the NT polyfills, strings, memory, boot, and math libraries which were discovered by adding more tools for recreational programming, such as PC emulation. Lemon has also been vendored because it works so well at parsing languages.
This commit is contained in:
@ -23,7 +23,5 @@
|
||||
* Returns number of bytes available in stream buffer.
|
||||
*/
|
||||
unsigned favail(FILE *f) {
|
||||
if (f->beg == f->end) return f->size;
|
||||
if (f->end > f->beg) return f->end - f->beg;
|
||||
return (f->size - f->beg) + f->end;
|
||||
return ((f->end - f->beg - 1) & (f->size - 1)) + 1;
|
||||
}
|
||||
|
||||
@ -17,8 +17,11 @@
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Writes string to stream.
|
||||
@ -32,15 +35,14 @@
|
||||
* @return strlen(s) or -1 w/ errno on error
|
||||
*/
|
||||
int fputs(const char *s, FILE *f) {
|
||||
unsigned char *p = (unsigned char *)s;
|
||||
int res = 0;
|
||||
while (*p) {
|
||||
if (fputc(*p++, f) == -1) {
|
||||
int i, n, m;
|
||||
n = strlen(s);
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (fputc(s[i], f) == -1) {
|
||||
if (ferror(f) == EINTR) continue;
|
||||
if (feof(f)) errno = f->state = EPIPE;
|
||||
return -1;
|
||||
}
|
||||
++res;
|
||||
}
|
||||
return ++res;
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ LIBC_STDIO_A_DIRECTDEPS = \
|
||||
LIBC_ALG \
|
||||
LIBC_BITS \
|
||||
LIBC_CALLS \
|
||||
LIBC_CALLS_HEFTY \
|
||||
LIBC_CONV \
|
||||
LIBC_ESCAPE \
|
||||
LIBC_FMT \
|
||||
|
||||
Reference in New Issue
Block a user