stdio: Fix bug in fputs()

The previous implementation mistakenly kept outputting the first
character of the string endlessly.

Change-Id: I299c627a52158218be8e88c952935edb87a636fe
Suggested-by: Tom Yeon <tom.yeon@windriver.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2015-11-17 15:12:59 -05:00 committed by Anas Nashif
parent f1420515a7
commit bf223a8838

View file

@ -39,16 +39,15 @@ int fputc(int c, FILE *stream)
int fputs(const char *restrict string, FILE *restrict stream) int fputs(const char *restrict string, FILE *restrict stream)
{ {
int c;
if (stream != stdout) { if (stream != stdout) {
return EOF; return EOF;
} }
for (c = (int) *string; c != 0; string++) { while (*string != '\0') {
if (_stdout_hook(c) == EOF) { if (_stdout_hook((int)*string) == EOF) {
return EOF; return EOF;
} }
string++;
} }
return 0; return 0;