aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/printf.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/printf.c
parent0f702c6e7097c369517f891c172a84e2e439e9f7 (diff)
downloadplatform_external_arm-trusted-firmware-1bc9e1f6ebb339136842fca0fa6f897ec20fd1aa.tar.gz
platform_external_arm-trusted-firmware-1bc9e1f6ebb339136842fca0fa6f897ec20fd1aa.tar.bz2
platform_external_arm-trusted-firmware-1bc9e1f6ebb339136842fca0fa6f897ec20fd1aa.zip
Add strchr() and putchar() to local C library
Change-Id: I3659e119a242f8ef828e32bfdf5d0b4b7ac4f716
Diffstat (limited to 'lib/stdlib/printf.c')
-rw-r--r--lib/stdlib/printf.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/stdlib/printf.c b/lib/stdlib/printf.c
index 3d62497a7..61361b9cb 100644
--- a/lib/stdlib/printf.c
+++ b/lib/stdlib/printf.c
@@ -31,14 +31,30 @@
#include <stdio.h>
#include <stdarg.h>
- // Choose max of 128 chars for now.
+/* Choose max of 128 chars for now. */
#define PRINT_BUFFER_SIZE 128
int printf(const char *fmt, ...)
{
va_list args;
- va_start(args, fmt);
char buf[PRINT_BUFFER_SIZE];
+ int count;
+
+ va_start(args, fmt);
vsnprintf(buf, sizeof(buf) - 1, fmt, args);
+ va_end(args);
+
+ /* Use putchar directly as 'puts()' adds a newline. */
buf[PRINT_BUFFER_SIZE - 1] = '\0';
- return puts(buf);
+ count = 0;
+ while (buf[count])
+ {
+ if (putchar(buf[count]) != EOF) {
+ count++;
+ } else {
+ count = EOF;
+ break;
+ }
+ }
+
+ return count;
}