summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/ungetc.c
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2009-10-22 01:23:17 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2009-10-22 01:23:17 +0000
commitbe40cf4f6608dcb8157ec353ae0fc6e449a06a2d (patch)
tree29977358369874429c14c743243db3114f2dc01d /lib/libc/stdio/ungetc.c
parente990becb683185ae6d8df39ba534ec5200132b04 (diff)
Back out previous commit, as it caused too much growth for the install
media to fit
Diffstat (limited to 'lib/libc/stdio/ungetc.c')
-rw-r--r--lib/libc/stdio/ungetc.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index 9c4296df053..85e0895f7b5 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ungetc.c,v 1.10 2009/10/21 16:04:23 guenther Exp $ */
+/* $OpenBSD: ungetc.c,v 1.11 2009/10/22 01:23:16 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -82,20 +82,17 @@ ungetc(int c, FILE *fp)
return (EOF);
if (!__sdidinit)
__sinit();
- FLOCKFILE(fp);
_SET_ORIENTATION(fp, -1);
if ((fp->_flags & __SRD) == 0) {
/*
* Not already reading: no good unless reading-and-writing.
* Otherwise, flush any current write stuff.
*/
- if ((fp->_flags & __SRW) == 0) {
-error: FUNLOCKFILE(fp);
+ if ((fp->_flags & __SRW) == 0)
return (EOF);
- }
if (fp->_flags & __SWR) {
if (__sflush(fp))
- goto error;
+ return (EOF);
fp->_flags &= ~__SWR;
fp->_w = 0;
fp->_lbfsize = 0;
@@ -110,10 +107,9 @@ error: FUNLOCKFILE(fp);
*/
if (HASUB(fp)) {
if (fp->_r >= _UB(fp)._size && __submore(fp))
- goto error;
+ return (EOF);
*--fp->_p = c;
-inc_ret: fp->_r++;
- FUNLOCKFILE(fp);
+ fp->_r++;
return (c);
}
fp->_flags &= ~__SEOF;
@@ -126,7 +122,8 @@ inc_ret: fp->_r++;
if (fp->_bf._base != NULL && fp->_p > fp->_bf._base &&
fp->_p[-1] == c) {
fp->_p--;
- goto inc_ret;
+ fp->_r++;
+ return (c);
}
/*
@@ -140,6 +137,5 @@ inc_ret: fp->_r++;
fp->_ubuf[sizeof(fp->_ubuf) - 1] = c;
fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];
fp->_r = 1;
- FUNLOCKFILE(fp);
return (c);
}