diff options
Diffstat (limited to 'newlib/libc/stdio/puts.c')
-rw-r--r-- | newlib/libc/stdio/puts.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c index 7b8b34b..4c60aaa 100644 --- a/newlib/libc/stdio/puts.c +++ b/newlib/libc/stdio/puts.c @@ -78,6 +78,7 @@ _DEFUN(_puts_r, (ptr, s), struct _reent *ptr _AND _CONST char * s) { +#ifdef _FVWRITE_IN_STREAMIO int result; size_t c = strlen (s); struct __suio uio; @@ -99,6 +100,33 @@ _DEFUN(_puts_r, (ptr, s), result = (__sfvwrite_r (ptr, fp, &uio) ? EOF : '\n'); _newlib_flockfile_end (fp); return result; +#else + int result = EOF; + const char *p = s; + FILE *fp; + _REENT_SMALL_CHECK_INIT (ptr); + + fp = _stdout_r (ptr); + _newlib_flockfile_start (fp); + ORIENT (fp, -1); + /* Make sure we can write. */ + if (cantwrite (ptr, fp)) + goto err; + + while (*p) + { + if (__sputc_r (ptr, *p++, fp) == EOF) + goto err; + } + if (__sputc_r (ptr, '\n', fp) == EOF) + goto err; + + result = '\n'; + +err: + _newlib_flockfile_end (fp); + return result; +#endif } #ifndef _REENT_ONLY |