From bf223a88385203a8b4e07e9745cd84e106d85470 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 17 Nov 2015 15:12:59 -0500 Subject: [PATCH] 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 Signed-off-by: Allan Stephens --- lib/libc/minimal/source/stdout/stdout_console.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/libc/minimal/source/stdout/stdout_console.c b/lib/libc/minimal/source/stdout/stdout_console.c index 261d5f97eb..063fb7a732 100644 --- a/lib/libc/minimal/source/stdout/stdout_console.c +++ b/lib/libc/minimal/source/stdout/stdout_console.c @@ -39,16 +39,15 @@ int fputc(int c, FILE *stream) int fputs(const char *restrict string, FILE *restrict stream) { - int c; - if (stream != stdout) { return EOF; } - for (c = (int) *string; c != 0; string++) { - if (_stdout_hook(c) == EOF) { + while (*string != '\0') { + if (_stdout_hook((int)*string) == EOF) { return EOF; } + string++; } return 0;