mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:27:42 +00:00
Miscellaneous compat work while seeing if GNU coreutils would build.
This commit is contained in:
parent
a7f1d892a9
commit
d7a41579e5
12 changed files with 92 additions and 2 deletions
|
@ -72,6 +72,8 @@ int fputc(int ch, FILE* stream)
|
|||
{
|
||||
assert(stream);
|
||||
write(stream->fd, &ch, 1);
|
||||
if (stream->eof)
|
||||
return EOF;
|
||||
return (byte)ch;
|
||||
}
|
||||
|
||||
|
@ -85,10 +87,31 @@ int putchar(int ch)
|
|||
return putc(ch, stdout);
|
||||
}
|
||||
|
||||
int fputs(const char* s, FILE* stream)
|
||||
{
|
||||
for (; *s; ++s) {
|
||||
int rc = putc(*s, stream);
|
||||
if (rc == EOF)
|
||||
return EOF;
|
||||
}
|
||||
return putc('\n', stream);
|
||||
}
|
||||
|
||||
int puts(const char* s)
|
||||
{
|
||||
fputs(s, stdout);
|
||||
}
|
||||
|
||||
void clearerr(FILE* stream)
|
||||
{
|
||||
assert(stream);
|
||||
stream->eof = false;
|
||||
stream->error = false;
|
||||
}
|
||||
|
||||
int ferror(FILE* stream)
|
||||
{
|
||||
return stream->error;
|
||||
}
|
||||
|
||||
size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream)
|
||||
|
@ -190,6 +213,7 @@ FILE* fopen(const char* pathname, const char* mode)
|
|||
auto* fp = (FILE*)malloc(sizeof(FILE));
|
||||
fp->fd = fd;
|
||||
fp->eof = false;
|
||||
fp->error = 0;
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
@ -201,6 +225,7 @@ FILE* fdopen(int fd, const char* mode)
|
|||
auto* fp = (FILE*)malloc(sizeof(FILE));
|
||||
fp->fd = fd;
|
||||
fp->eof = false;
|
||||
fp->error = 0;
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue