Commit ff76d1ee by Andreas Schwab Committed by Jeff Law

iostream.cc: Add missing calls to isfx and setup a cleanup region for the locked stream.


	* 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.

From-SVN: r28573
parent 80832cf2
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.
Mon Jun 28 09:25:23 1999 Hans-Peter Nilsson <hp@bitrange.com> Mon Jun 28 09:25:23 1999 Hans-Peter Nilsson <hp@bitrange.com>
* configure.in (post-target): Use "$(topsrcdir)", not "$(srcdir)/..". * configure.in (post-target): Use "$(topsrcdir)", not "$(srcdir)/..".
......
...@@ -71,6 +71,8 @@ int skip_ws(streambuf* sb) ...@@ -71,6 +71,8 @@ int skip_ws(streambuf* sb)
istream& istream::get(char& c) istream& istream::get(char& c)
{ {
if (ipfx1()) { if (ipfx1()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
int ch = _strbuf->sbumpc(); int ch = _strbuf->sbumpc();
if (ch == EOF) { if (ch == EOF) {
set(ios::eofbit|ios::failbit); set(ios::eofbit|ios::failbit);
...@@ -80,6 +82,8 @@ istream& istream::get(char& c) ...@@ -80,6 +82,8 @@ istream& istream::get(char& c)
c = (char)ch; c = (char)ch;
_gcount = 1; _gcount = 1;
} }
isfx();
_IO_cleanup_region_end (0);
} }
else else
_gcount = 0; _gcount = 0;
...@@ -102,10 +106,12 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */) ...@@ -102,10 +106,12 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */)
{ {
_gcount = 0; _gcount = 0;
if (ipfx1()) { if (ipfx1()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
register streambuf* sb = _strbuf; register streambuf* sb = _strbuf;
if (delim == EOF) { if (delim == EOF) {
_gcount = sb->ignore(n); _gcount = sb->ignore(n);
return *this; goto unlock;
} }
for (;;) { for (;;) {
#if 0 #if 0
...@@ -122,6 +128,9 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */) ...@@ -122,6 +128,9 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */)
if (ch == delim) if (ch == delim)
break; break;
} }
unlock:
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -129,9 +138,13 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */) ...@@ -129,9 +138,13 @@ istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */)
istream& istream::read(char *s, streamsize n) istream& istream::read(char *s, streamsize n)
{ {
if (ipfx1()) { if (ipfx1()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
_gcount = _strbuf->sgetn(s, n); _gcount = _strbuf->sgetn(s, n);
if (_gcount != n) if (_gcount != n)
set(ios::failbit|ios::eofbit); set(ios::failbit|ios::eofbit);
isfx();
_IO_cleanup_region_end (0);
} }
else else
_gcount = 0; _gcount = 0;
...@@ -184,11 +197,15 @@ streampos istream::tellg() ...@@ -184,11 +197,15 @@ streampos istream::tellg()
istream& istream::operator>>(char& c) istream& istream::operator>>(char& c)
{ {
if (ipfx0()) { if (ipfx0()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
int ch = _strbuf->sbumpc(); int ch = _strbuf->sbumpc();
if (ch == EOF) if (ch == EOF)
set(ios::eofbit|ios::failbit); set(ios::eofbit|ios::failbit);
else else
c = (char)ch; c = (char)ch;
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -200,6 +217,8 @@ istream::operator>> (char* ptr) ...@@ -200,6 +217,8 @@ istream::operator>> (char* ptr)
int w = width(0); int w = width(0);
if (ipfx0()) if (ipfx0())
{ {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
register streambuf* sb = _strbuf; register streambuf* sb = _strbuf;
for (;;) for (;;)
{ {
...@@ -219,6 +238,8 @@ istream::operator>> (char* ptr) ...@@ -219,6 +238,8 @@ istream::operator>> (char* ptr)
} }
if (p == ptr) if (p == ptr)
set(ios::failbit); set(ios::failbit);
isfx();
_IO_cleanup_region_end (0);
} }
*p = '\0'; *p = '\0';
return *this; return *this;
...@@ -234,6 +255,9 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg) ...@@ -234,6 +255,9 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg)
{ {
if (!stream.ipfx0()) if (!stream.ipfx0())
return 0; return 0;
int retval;
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
stream._strbuf);
register streambuf* sb = stream.rdbuf(); register streambuf* sb = stream.rdbuf();
int base = 10; int base = 10;
int ndigits = 0; int ndigits = 0;
...@@ -254,7 +278,7 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg) ...@@ -254,7 +278,7 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg)
ch = sb->sbumpc(); ch = sb->sbumpc();
if (ch == EOF) { if (ch == EOF) {
val = 0; val = 0;
return 1; goto unlock;
} }
if (ch == 'x' || ch == 'X') { if (ch == 'x' || ch == 'X') {
base = 16; base = 16;
...@@ -290,19 +314,26 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg) ...@@ -290,19 +314,26 @@ static int read_int(istream& stream, unsigned LONGEST& val, int& neg)
if (ndigits == 0) if (ndigits == 0)
goto fail; goto fail;
else else
return 1; goto unlock;
} }
ndigits++; ndigits++;
val = base * val + digit; val = base * val + digit;
ch = sb->sbumpc(); ch = sb->sbumpc();
} }
return 1; unlock:
retval = 1;
goto out;
fail: fail:
stream.set(ios::failbit); stream.set(ios::failbit);
return 0; retval = 0;
goto out;
eof_fail: eof_fail:
stream.set(ios::failbit|ios::eofbit); stream.set(ios::failbit|ios::eofbit);
return 0; retval = 0;
out:
stream.isfx();
_IO_cleanup_region_end (0);
return retval;
} }
#define READ_INT(TYPE) \ #define READ_INT(TYPE) \
...@@ -334,6 +365,8 @@ istream& istream::operator>>(long double& x) ...@@ -334,6 +365,8 @@ istream& istream::operator>>(long double& x)
{ {
if (ipfx0()) if (ipfx0())
{ {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
#if _G_HAVE_LONG_DOUBLE_IO #if _G_HAVE_LONG_DOUBLE_IO
scan("%Lg", &x); scan("%Lg", &x);
#else #else
...@@ -341,6 +374,8 @@ istream& istream::operator>>(long double& x) ...@@ -341,6 +374,8 @@ istream& istream::operator>>(long double& x)
scan("%lg", &y); scan("%lg", &y);
x = y; x = y;
#endif #endif
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -348,20 +383,34 @@ istream& istream::operator>>(long double& x) ...@@ -348,20 +383,34 @@ istream& istream::operator>>(long double& x)
istream& istream::operator>>(double& x) istream& istream::operator>>(double& x)
{ {
if (ipfx0()) if (ipfx0())
{
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
scan("%lg", &x); scan("%lg", &x);
isfx();
_IO_cleanup_region_end (0);
}
return *this; return *this;
} }
istream& istream::operator>>(float& x) istream& istream::operator>>(float& x)
{ {
if (ipfx0()) if (ipfx0())
{
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
scan("%g", &x); scan("%g", &x);
isfx();
_IO_cleanup_region_end (0);
}
return *this; return *this;
} }
istream& istream::operator>>(register streambuf* sbuf) istream& istream::operator>>(register streambuf* sbuf)
{ {
if (ipfx0()) { if (ipfx0()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
register streambuf* inbuf = rdbuf(); register streambuf* inbuf = rdbuf();
// FIXME: Should optimize! // FIXME: Should optimize!
for (;;) { for (;;) {
...@@ -375,6 +424,8 @@ istream& istream::operator>>(register streambuf* sbuf) ...@@ -375,6 +424,8 @@ istream& istream::operator>>(register streambuf* sbuf)
break; break;
} }
} }
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -789,8 +840,8 @@ ostream& ostream::operator<<(const char *s) ...@@ -789,8 +840,8 @@ ostream& ostream::operator<<(const char *s)
if (flags() & ios::left && padding > 0) // Left adjustment. if (flags() & ios::left && padding > 0) // Left adjustment.
if (_IO_padn(sbuf, fill_char, padding) != padding) if (_IO_padn(sbuf, fill_char, padding) != padding)
set(ios::badbit); set(ios::badbit);
osfx();
failed: failed:
osfx();
_IO_cleanup_region_end (0); _IO_cleanup_region_end (0);
} }
return *this; return *this;
......
...@@ -173,6 +173,7 @@ protected: ...@@ -173,6 +173,7 @@ protected:
int get() { if (!ipfx1()) return EOF; int get() { if (!ipfx1()) return EOF;
else { int ch = _strbuf->sbumpc(); else { int ch = _strbuf->sbumpc();
if (ch == EOF) set(ios::eofbit); if (ch == EOF) set(ios::eofbit);
isfx();
return ch; return ch;
} } } }
int peek(); int peek();
......
...@@ -37,6 +37,8 @@ istream& istream::getline(char* buf, int len, char delim) ...@@ -37,6 +37,8 @@ istream& istream::getline(char* buf, int len, char delim)
int ch; int ch;
if (ipfx1()) if (ipfx1())
{ {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
streambuf *sb = rdbuf(); streambuf *sb = rdbuf();
_gcount = _IO_getline_info(sb, buf, len - 1, delim, -1, &ch); _gcount = _IO_getline_info(sb, buf, len - 1, delim, -1, &ch);
if (ch != EOF) if (ch != EOF)
...@@ -48,6 +50,8 @@ istream& istream::getline(char* buf, int len, char delim) ...@@ -48,6 +50,8 @@ istream& istream::getline(char* buf, int len, char delim)
set(ios::failbit); set(ios::failbit);
sb->sungetc(); // Leave delimiter unread. sb->sungetc(); // Leave delimiter unread.
} }
isfx();
_IO_cleanup_region_end (0);
} }
else else
ch = EOF; ch = EOF;
...@@ -67,11 +71,15 @@ istream& istream::get(char* buf, int len, char delim) ...@@ -67,11 +71,15 @@ istream& istream::get(char* buf, int len, char delim)
} }
if (ipfx1()) if (ipfx1())
{ {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
streambuf *sbuf = rdbuf(); streambuf *sbuf = rdbuf();
int ch; int ch;
_gcount = _IO_getline_info(sbuf, buf, len - 1, delim, -1, &ch); _gcount = _IO_getline_info(sbuf, buf, len - 1, delim, -1, &ch);
if (_gcount == 0 && ch == EOF) if (_gcount == 0 && ch == EOF)
set(ios::failbit|ios::eofbit); set(ios::failbit|ios::eofbit);
isfx();
_IO_cleanup_region_end (0);
} }
buf[_gcount] = '\0'; buf[_gcount] = '\0';
return *this; return *this;
...@@ -123,6 +131,8 @@ char *_sb_readline (streambuf *sb, long& total, char terminator) ...@@ -123,6 +131,8 @@ char *_sb_readline (streambuf *sb, long& total, char terminator)
istream& istream::gets(char **s, char delim /* = '\n' */) istream& istream::gets(char **s, char delim /* = '\n' */)
{ {
if (ipfx1()) { if (ipfx1()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
long size = 0; long size = 0;
streambuf *sb = rdbuf(); streambuf *sb = rdbuf();
*s = _sb_readline (sb, size, delim); *s = _sb_readline (sb, size, delim);
...@@ -132,6 +142,8 @@ istream& istream::gets(char **s, char delim /* = '\n' */) ...@@ -132,6 +142,8 @@ istream& istream::gets(char **s, char delim /* = '\n' */)
if (_gcount == 0) if (_gcount == 0)
set(ios::failbit); set(ios::failbit);
} }
isfx();
_IO_cleanup_region_end (0);
} }
else { else {
_gcount = 0; _gcount = 0;
......
...@@ -31,6 +31,8 @@ istream& istream::get(streambuf& sb, char delim /* = '\n' */) ...@@ -31,6 +31,8 @@ istream& istream::get(streambuf& sb, char delim /* = '\n' */)
_gcount = 0; _gcount = 0;
if (ipfx1()) if (ipfx1())
{ {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
register streambuf* isb = rdbuf(); register streambuf* isb = rdbuf();
for (;;) for (;;)
{ {
...@@ -54,6 +56,8 @@ istream& istream::get(streambuf& sb, char delim /* = '\n' */) ...@@ -54,6 +56,8 @@ istream& istream::get(streambuf& sb, char delim /* = '\n' */)
if (delimp != NULL) if (delimp != NULL)
break; break;
} }
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -29,10 +29,14 @@ the executable file might be covered by the GNU General Public License. */ ...@@ -29,10 +29,14 @@ the executable file might be covered by the GNU General Public License. */
istream& istream::scan(const char *format ...) istream& istream::scan(const char *format ...)
{ {
if (ipfx0()) { if (ipfx0()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
_strbuf->vscan(format, ap, this); _strbuf->vscan(format, ap, this);
va_end(ap); va_end(ap);
isfx();
_IO_cleanup_region_end (0);
} }
return *this; return *this;
} }
...@@ -40,6 +44,12 @@ istream& istream::scan(const char *format ...) ...@@ -40,6 +44,12 @@ istream& istream::scan(const char *format ...)
istream& istream::vscan(const char *format, _IO_va_list args) istream& istream::vscan(const char *format, _IO_va_list args)
{ {
if (ipfx0()) if (ipfx0())
{
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
_strbuf->vscan(format, args, this); _strbuf->vscan(format, args, this);
isfx();
_IO_cleanup_region_end (0);
}
return *this; return *this;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment