mirror of
https://github.com/fluencelabs/musl
synced 2025-05-28 23:21:34 +00:00
internally, the idiom of passing nmemb=1 to fwrite and interpreting the return value of fwrite (which is necessarily 0 or 1) as failure/success is fairly widely used. this is not correct, however, when the size argument is unknown and may be zero, since C requires fwrite to return 0 in that special case. previously fwrite always returned nmemb on success, but this was changed for conformance with ISO C by commit 500c6886c654fd45e4926990fee2c61d816be197.
11 lines
197 B
C
11 lines
197 B
C
#include "stdio_impl.h"
|
|
#include <string.h>
|
|
|
|
int fputs(const char *restrict s, FILE *restrict f)
|
|
{
|
|
size_t l = strlen(s);
|
|
return (fwrite(s, 1, l, f)==l) - 1;
|
|
}
|
|
|
|
weak_alias(fputs, fputs_unlocked);
|