summaryrefslogtreecommitdiff
path: root/lib/stdlib/puts.c
diff options
context:
space:
mode:
authorHarry Liebel <Harry.Liebel@arm.com>2013-12-12 16:46:30 +0000
committerDan Handley <dan.handley@arm.com>2013-12-20 15:52:16 +0000
commit1bc9e1f6ebb339136842fca0fa6f897ec20fd1aa (patch)
treedc5438c152dbc0c303a8283720ac585bdc812fcf /lib/stdlib/puts.c
parent0f702c6e7097c369517f891c172a84e2e439e9f7 (diff)
Add strchr() and putchar() to local C library
Change-Id: I3659e119a242f8ef828e32bfdf5d0b4b7ac4f716
Diffstat (limited to 'lib/stdlib/puts.c')
-rw-r--r--lib/stdlib/puts.c14
1 files changed, 11 insertions, 3 deletions
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 <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;
}