Skip to content

Commit

Permalink
Implement fputs using PDCLib
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed May 21, 2024
1 parent b340e32 commit 0726f24
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions mos-platform/common/c/stdio-full.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,27 @@ int fputc(int c, FILE *stream) {
return c;
}

int fputs(const char *__restrict__ s, FILE *__restrict__ stream) {
__stdio_not_yet_implemented();
int fputs(const char *restrict s, FILE *restrict stream) {
if (prep_write(stream) == EOF)
return EOF;

for (; *s; ++s) {
if (stream->status & FBIN) {
if (write_to_buffer(*s, stream) == EOF)
return EOF;
} else if (__from_ascii(*s, stream, write_to_buffer) == EOF) {
return EOF;
}
if ((stream->status & _IOLBF) && *s == '\n')
if (flush_buffer(stream) == EOF)
return EOF;
}

if (stream->status & _IONBF)
if (flush_buffer(stream) == EOF)
return EOF;

return 0;
}

int getchar(void) { return getc(stdin); }
Expand Down

0 comments on commit 0726f24

Please sign in to comment.