aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2002-04-29 07:00:50 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2002-04-29 07:00:50 +0000
commitd02475fdae3da10c9b821e529c6dda775279974c (patch)
treed1753560c9bea2394fc6f1e1f074278827a71eec /libstdc++-v3/src
parent189ab118de817bf9ec6a3f77712f8c2112cdc7b6 (diff)
downloadgcc-d02475fdae3da10c9b821e529c6dda775279974c.tar.gz
gcc-d02475fdae3da10c9b821e529c6dda775279974c.tar.bz2
gcc-d02475fdae3da10c9b821e529c6dda775279974c.zip
re PR libstdc++/5280 (Problems with named locales and iostreams (gnulocale))
2002-04-28 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/5280 * config/io/basic_file_stdio.h (__basic_file::sys_getc): Return int. (__basic_file::sys_ungetc): Take int. * config/io/basic_file_stdio.cc (__basic_file::sys_ungetc): Same. * include/bits/fstream.tcc (basic_filebuf::_M_underflow_common): Use sys_getc for unbuffered input. * testsuite/27_io/narrow_stream_objects.cc (test06): New. * src/ios.cc (_M_grow_words): Adjust error checking. * testsuite/27_io/ios_base_storage.cc: Same. From-SVN: r52879
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/ios.cc43
1 files changed, 22 insertions, 21 deletions
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index 1d97bf9e7a8..8e834fd65b0 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -226,33 +226,35 @@ namespace std
// Precondition: _M_word_size <= ix
int newsize = _S_local_word_size;
_Words* words = _M_local_word;
- int i = 0;
if (ix > _S_local_word_size - 1)
{
- const int max = numeric_limits<int>::max();
- if (ix < max)
- newsize = ix + 1;
+ if (ix < numeric_limits<int>::max())
+ {
+ newsize = ix + 1;
+ try
+ { words = new _Words[newsize]; }
+ catch (...)
+ {
+ delete [] _M_word;
+ _M_word = 0;
+ _M_streambuf_state |= badbit;
+ if (_M_streambuf_state & _M_exception)
+ __throw_ios_failure("ios_base::_M_grow_words failure");
+ return _M_word_zero;
+ }
+ for (int i = 0; i < _M_word_size; i++)
+ words[i] = _M_word[i];
+ if (_M_word && _M_word != _M_local_word)
+ {
+ delete [] _M_word;
+ _M_word = 0;
+ }
+ }
else
- newsize = max;
-
- try
- { words = new _Words[newsize]; }
- catch (...)
{
- delete [] _M_word;
- _M_word = 0;
_M_streambuf_state |= badbit;
- if (_M_streambuf_state & _M_exception)
- __throw_ios_failure("ios_base::_M_grow_words caused exception");
return _M_word_zero;
}
- for (; i < _M_word_size; i++)
- words[i] = _M_word[i];
- if (_M_word && _M_word != _M_local_word)
- {
- delete [] _M_word;
- _M_word = 0;
- }
}
_M_word = words;
_M_word_size = newsize;
@@ -351,4 +353,3 @@ namespace std
return __ret;
}
} // namespace std
-