blob: 284cf8c52aab33c10b01e6b17d0022851a810eb9 [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;
Jonathan Wright9b2770e2018-03-06 16:23:28 +000012 while(*s) {
13 if (putchar(*s++) == EOF)
14 return EOF;
15 count++;
Harry Liebel0f702c62013-12-17 18:19:04 +000016 }
Harry Liebel1bc9e1f2013-12-12 16:46:30 +000017
18 /* According to the puts(3) manpage, the function should write a
19 * trailing newline.
20 */
Jonathan Wright9b2770e2018-03-06 16:23:28 +000021 if (putchar('\n') == EOF)
22 return EOF;
Harry Liebel1bc9e1f2013-12-12 16:46:30 +000023
Jonathan Wright9b2770e2018-03-06 16:23:28 +000024 return count + 1;
Harry Liebel0f702c62013-12-17 18:19:04 +000025}