From 1bc9e1f6ebb339136842fca0fa6f897ec20fd1aa Mon Sep 17 00:00:00 2001 From: Harry Liebel Date: Thu, 12 Dec 2013 16:46:30 +0000 Subject: Add strchr() and putchar() to local C library Change-Id: I3659e119a242f8ef828e32bfdf5d0b4b7ac4f716 --- lib/stdlib/puts.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/stdlib/puts.c') diff --git a/lib/stdlib/puts.c b/lib/stdlib/puts.c index 069a64fc..7549eb88 100644 --- a/lib/stdlib/puts.c +++ b/lib/stdlib/puts.c @@ -29,19 +29,27 @@ */ #include -#include int puts(const char *s) { int count = 0; while(*s) { - if (console_putc(*s++)) { + if (putchar(*s++) != EOF) { count++; } else { - count = EOF; // -1 in stdio.h + count = EOF; break; } } + + /* According to the puts(3) manpage, the function should write a + * trailing newline. + */ + if ((count != EOF) && (putchar('\n') != EOF)) + count++; + else + count = EOF; + return count; } -- cgit