diff options
author | Elliott Hughes <enh@google.com> | 2014-05-05 21:33:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-05 21:33:22 +0000 |
commit | 8ec21d9ded4c05744b3f9388bf824a508d7c95c2 (patch) | |
tree | 93e55457598d2ad8801ab8b5bb5f0fddf25294b0 /libc | |
parent | 580b246917d58fafc757daaf097b6bd20b17970a (diff) | |
parent | 53b24382f5299931af5d08c933a765334a092c56 (diff) | |
download | bionic-8ec21d9ded4c05744b3f9388bf824a508d7c95c2.zip bionic-8ec21d9ded4c05744b3f9388bf824a508d7c95c2.tar.gz bionic-8ec21d9ded4c05744b3f9388bf824a508d7c95c2.tar.bz2 |
Merge "Switch to current upstream OpenBSD wsetup.c."
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Android.mk | 2 | ||||
-rw-r--r-- | libc/upstream-openbsd/lib/libc/stdio/wsetup.c (renamed from libc/upstream-freebsd/lib/libc/stdio/wsetup.c) | 20 |
2 files changed, 8 insertions, 14 deletions
diff --git a/libc/Android.mk b/libc/Android.mk index 9b71f6a..4b81f7e 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -226,7 +226,6 @@ libc_upstream_freebsd_src_files := \ upstream-freebsd/lib/libc/stdio/makebuf.c \ upstream-freebsd/lib/libc/stdio/mktemp.c \ upstream-freebsd/lib/libc/stdio/setvbuf.c \ - upstream-freebsd/lib/libc/stdio/wsetup.c \ upstream-freebsd/lib/libc/stdlib/abs.c \ upstream-freebsd/lib/libc/stdlib/getopt_long.c \ upstream-freebsd/lib/libc/stdlib/imaxabs.c \ @@ -436,6 +435,7 @@ libc_upstream_openbsd_src_files := \ upstream-openbsd/lib/libc/stdio/wbuf.c \ upstream-openbsd/lib/libc/stdio/wprintf.c \ upstream-openbsd/lib/libc/stdio/wscanf.c \ + upstream-openbsd/lib/libc/stdio/wsetup.c \ upstream-openbsd/lib/libc/stdlib/atoi.c \ upstream-openbsd/lib/libc/stdlib/atol.c \ upstream-openbsd/lib/libc/stdlib/atoll.c \ diff --git a/libc/upstream-freebsd/lib/libc/stdio/wsetup.c b/libc/upstream-openbsd/lib/libc/stdio/wsetup.c index 70f8247..0834223 100644 --- a/libc/upstream-freebsd/lib/libc/stdio/wsetup.c +++ b/libc/upstream-openbsd/lib/libc/stdio/wsetup.c @@ -1,3 +1,4 @@ +/* $OpenBSD: wsetup.c,v 1.7 2005/08/08 08:05:36 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -30,13 +31,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)wsetup.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include "local.h" @@ -44,7 +38,7 @@ __FBSDID("$FreeBSD$"); /* * Various output routines call wsetup to be sure it is safe to write, * because either _flags does not include __SWR, or _buf is NULL. - * _wsetup returns 0 if OK to write; otherwise, it returns EOF and sets errno. + * _wsetup returns 0 if OK to write, nonzero otherwise. */ int __swsetup(FILE *fp) @@ -57,11 +51,8 @@ __swsetup(FILE *fp) * If we are not writing, we had better be reading and writing. */ if ((fp->_flags & __SWR) == 0) { - if ((fp->_flags & __SRW) == 0) { - errno = EBADF; - fp->_flags |= __SERR; + if ((fp->_flags & __SRW) == 0) return (EOF); - } if (fp->_flags & __SRD) { /* clobber any ungetc data */ if (HASUB(fp)) @@ -76,8 +67,11 @@ __swsetup(FILE *fp) /* * Make a buffer if necessary, then set _w. */ - if (fp->_bf._base == NULL) + if (fp->_bf._base == NULL) { + if ((fp->_flags & (__SSTR | __SALC)) == __SSTR) + return (EOF); __smakebuf(fp); + } if (fp->_flags & __SLBF) { /* * It is line buffered, so make _lbfsize be -_bufsize |