Add strchr() and putchar() to local C library
Change-Id: I3659e119a242f8ef828e32bfdf5d0b4b7ac4f716
diff --git a/lib/stdlib/puts.c b/lib/stdlib/puts.c
index 069a64f..7549eb8 100644
--- a/lib/stdlib/puts.c
+++ b/lib/stdlib/puts.c
@@ -29,19 +29,27 @@
*/
#include <stdio.h>
-#include <console.h>
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;
}