blob: 693a6bff3df6a31d15980a9d4c07f3f8b1fee786 [file] [log] [blame]
Harry Liebel0f702c62013-12-17 18:19:04 +00001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Harry Liebel0f702c62013-12-17 18:19:04 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Harry Liebel0f702c62013-12-17 18:19:04 +00005 */
6
7#include <stdio.h>
Harry Liebel0f702c62013-12-17 18:19:04 +00008
9int puts(const char *s)
10{
11 int count = 0;
12 while(*s)
13 {
Harry Liebel1bc9e1f2013-12-12 16:46:30 +000014 if (putchar(*s++) != EOF) {
Harry Liebel0f702c62013-12-17 18:19:04 +000015 count++;
16 } else {
Harry Liebel1bc9e1f2013-12-12 16:46:30 +000017 count = EOF;
Harry Liebel0f702c62013-12-17 18:19:04 +000018 break;
19 }
20 }
Harry Liebel1bc9e1f2013-12-12 16:46:30 +000021
22 /* According to the puts(3) manpage, the function should write a
23 * trailing newline.
24 */
25 if ((count != EOF) && (putchar('\n') != EOF))
26 count++;
27 else
28 count = EOF;
29
Harry Liebel0f702c62013-12-17 18:19:04 +000030 return count;
31}