libc/puts: newline was omitted for empty string

`puts("");` did not print a newline. The standard
behavior is to print a newline even if the string
is empty.

Signed-off-by: liamHowatt <liamjmh0@gmail.com>
This commit is contained in:
liamHowatt 2024-11-30 13:38:04 +00:00 committed by Xiang Xiao
parent 6135892d66
commit 0bdc9d24ab

View file

@ -57,7 +57,7 @@ int puts(FAR const IPTR char *s)
/* Write the string without its trailing '\0' */
nwritten = fputs_unlocked(s, stream);
if (nwritten > 0)
if (nwritten >= 0)
{
/* Followed by a newline */