Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 1 | /* |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 5 | */ |
6 | |||||
7 | #include <stdio.h> | ||||
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 8 | |
9 | int puts(const char *s) | ||||
10 | { | ||||
11 | int count = 0; | ||||
12 | while(*s) | ||||
13 | { | ||||
Harry Liebel | 1bc9e1f | 2013-12-12 16:46:30 +0000 | [diff] [blame] | 14 | if (putchar(*s++) != EOF) { |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 15 | count++; |
16 | } else { | ||||
Harry Liebel | 1bc9e1f | 2013-12-12 16:46:30 +0000 | [diff] [blame] | 17 | count = EOF; |
Harry Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 18 | break; |
19 | } | ||||
20 | } | ||||
Harry Liebel | 1bc9e1f | 2013-12-12 16:46:30 +0000 | [diff] [blame] | 21 | |
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 Liebel | 0f702c6 | 2013-12-17 18:19:04 +0000 | [diff] [blame] | 30 | return count; |
31 | } |