+1999-08-07 Andreas Schwab <schwab@suse.de>
+
+ * iostream.cc: Add missing calls to isfx and setup a cleanup
+ region for the locked stream.
+ * iostream.h: Likewise.
+ * isgetline.cc: Likewise.
+ * isgetsb.cc: Likewise.
+ * isscan.cc: Likewise.
+
Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
* gcc-2.95 Released.
istream& istream::get(char& c)
{
if (ipfx1()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
int ch = _strbuf->sbumpc();
if (ch == EOF) {
set(ios::eofbit|ios::failbit);
c = (char)ch;
_gcount = 1;
}
+ isfx();
+ _IO_cleanup_region_end (0);
}
else
_gcount = 0;
{
_gcount = 0;
if (ipfx1()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
register streambuf* sb = _strbuf;
if (delim == EOF) {
_gcount = sb->ignore(n);
- return *this;
+ goto unlock;
}
for (;;) {
#if 0
if (ch == delim)
break;
}
+ unlock:
+ isfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
istream& istream::read(char *s, streamsize n)
{
if (ipfx1()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
_gcount = _strbuf->sgetn(s, n);
if (_gcount != n)
set(ios::failbit|ios::eofbit);
+ isfx();
+ _IO_cleanup_region_end (0);
}
else
_gcount = 0;
istream& istream::operator>>(char& c)
{
if (ipfx0()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
int ch = _strbuf->sbumpc();
if (ch == EOF)
set(ios::eofbit|ios::failbit);
else
c = (char)ch;
+ isfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
int w = width(0);
if (ipfx0())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
register streambuf* sb = _strbuf;
for (;;)
{
}
if (p == ptr)
set(ios::failbit);
+ isfx();
+ _IO_cleanup_region_end (0);
}
*p = '\0';
return *this;
{
if (!stream.ipfx0())
return 0;
+ int retval;
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ stream._strbuf);
register streambuf* sb = stream.rdbuf();
int base = 10;
int ndigits = 0;
ch = sb->sbumpc();
if (ch == EOF) {
val = 0;
- return 1;
+ goto unlock;
}
if (ch == 'x' || ch == 'X') {
base = 16;
if (ndigits == 0)
goto fail;
else
- return 1;
+ goto unlock;
}
ndigits++;
val = base * val + digit;
ch = sb->sbumpc();
}
- return 1;
+ unlock:
+ retval = 1;
+ goto out;
fail:
stream.set(ios::failbit);
- return 0;
+ retval = 0;
+ goto out;
eof_fail:
stream.set(ios::failbit|ios::eofbit);
- return 0;
+ retval = 0;
+ out:
+ stream.isfx();
+ _IO_cleanup_region_end (0);
+ return retval;
}
#define READ_INT(TYPE) \
{
if (ipfx0())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
#if _G_HAVE_LONG_DOUBLE_IO
scan("%Lg", &x);
#else
scan("%lg", &y);
x = y;
#endif
+ isfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
istream& istream::operator>>(double& x)
{
if (ipfx0())
+ {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
scan("%lg", &x);
+ isfx();
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
istream& istream::operator>>(float& x)
{
if (ipfx0())
+ {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
scan("%g", &x);
+ isfx();
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
istream& istream::operator>>(register streambuf* sbuf)
{
if (ipfx0()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
register streambuf* inbuf = rdbuf();
// FIXME: Should optimize!
for (;;) {
break;
}
}
+ isfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
if (flags() & ios::left && padding > 0) // Left adjustment.
if (_IO_padn(sbuf, fill_char, padding) != padding)
set(ios::badbit);
- osfx();
failed:
+ osfx();
_IO_cleanup_region_end (0);
}
return *this;
int get() { if (!ipfx1()) return EOF;
else { int ch = _strbuf->sbumpc();
if (ch == EOF) set(ios::eofbit);
+ isfx();
return ch;
} }
int peek();
int ch;
if (ipfx1())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
streambuf *sb = rdbuf();
_gcount = _IO_getline_info(sb, buf, len - 1, delim, -1, &ch);
if (ch != EOF)
set(ios::failbit);
sb->sungetc(); // Leave delimiter unread.
}
+ isfx();
+ _IO_cleanup_region_end (0);
}
else
ch = EOF;
}
if (ipfx1())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
streambuf *sbuf = rdbuf();
int ch;
_gcount = _IO_getline_info(sbuf, buf, len - 1, delim, -1, &ch);
if (_gcount == 0 && ch == EOF)
set(ios::failbit|ios::eofbit);
+ isfx();
+ _IO_cleanup_region_end (0);
}
buf[_gcount] = '\0';
return *this;
istream& istream::gets(char **s, char delim /* = '\n' */)
{
if (ipfx1()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
long size = 0;
streambuf *sb = rdbuf();
*s = _sb_readline (sb, size, delim);
if (_gcount == 0)
set(ios::failbit);
}
+ isfx();
+ _IO_cleanup_region_end (0);
}
else {
_gcount = 0;
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this library; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include "iostream.h"
-#include <string.h>
-
-istream& istream::get(streambuf& sb, char delim /* = '\n' */)
-{
- _gcount = 0;
- if (ipfx1())
- {
- register streambuf* isb = rdbuf();
- for (;;)
- {
- streamsize len = isb->_IO_read_end - isb->_IO_read_ptr;
- if (len <= 0)
- if (__underflow(isb) == EOF)
- break;
- else
- len = isb->_IO_read_end - isb->_IO_read_ptr;
- char *delimp = (char*)memchr((void*)isb->_IO_read_ptr, delim, len);
- if (delimp != NULL)
- len = delimp - isb->_IO_read_ptr;
- int written = sb.sputn(isb->_IO_read_ptr, len);
- isb->_IO_read_ptr += written;
- _gcount += written;
- if (written != len)
- {
- set(ios::failbit);
- break;
- }
- if (delimp != NULL)
- break;
- }
- }
- return *this;
-}
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
+ isfx();
+ _IO_cleanup_region_end (0);
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this library; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include <iostream.h>
-#include <stdarg.h>
-
-istream& istream::scan(const char *format ...)
-{
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- _strbuf->vscan(format, ap, this);
- va_end(ap);
- }
- return *this;
-}
-
-istream& istream::vscan(const char *format, _IO_va_list args)
-{
- if (ipfx0())
- _strbuf->vscan(format, args, this);
- return *this;
-}
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
+ isfx();
+ _IO_cleanup_region_end (0);
+ {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
+ isfx();
+ _IO_cleanup_region_end (0);
+ }