aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-10-03 16:28:16 +0000
committerPaolo Carlini <pcarlini@suse.de>2004-10-03 16:28:16 +0000
commitca2ac3d32102377ff62aa99810874752c46a4061 (patch)
treea6f6fd6c36b47218a1933f0c47f652d44d5d2c46 /libstdc++-v3
parent1ca23fa80a4bc938cab406fb12be71f0d7b1ca96 (diff)
2004-10-03 Paolo Carlini <pcarlini@suse.de>
Merged to mainline at tag libstdcxx_so_7-merge-20041003. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/libstdcxx_so_7-branch@88456 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog102
-rw-r--r--libstdc++-v3/ChangeLog.libstdcxx_so_7-branch4
-rw-r--r--libstdc++-v3/README7
-rw-r--r--libstdc++-v3/acconfig.h3
-rw-r--r--libstdc++-v3/acinclude.m419
-rw-r--r--libstdc++-v3/config.h.in3
-rwxr-xr-xlibstdc++-v3/configure30
-rw-r--r--libstdc++-v3/configure.ac1
-rw-r--r--libstdc++-v3/docs/html/configopts.html13
-rw-r--r--libstdc++-v3/docs/html/ext/howto.html6
-rw-r--r--libstdc++-v3/include/bits/basic_string.h9
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc22
-rw-r--r--libstdc++-v3/include/bits/c++config2
-rw-r--r--libstdc++-v3/include/bits/sstream.tcc53
-rw-r--r--libstdc++-v3/include/std/std_sstream.h27
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc89
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc80
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc7
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc61
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp2
-rw-r--r--libstdc++-v3/testsuite/testsuite_io.h87
25 files changed, 323 insertions, 387 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 560c5327ac4..bbf654d0f00 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,105 @@
+2004-10-03 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/stl_list.h: Trivial formatting fixes.
+ * include/bits/stl_tree.h: Likewise.
+
+2004-10-03 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/sstream.tcc (seekpos): In case of success, just
+ return __sp.
+
+2004-10-01 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/sstream.tcc (pbackfail): Implement correctly
+ 27.7.1.3/2, bullet 2: if mode & ios_base::out is false do not
+ write in the buffer.
+ * testsuite/27_io/basic_stringbuf/pbackfail/char/1.cc: New.
+ * testsuite/27_io/basic_stringbuf/pbackfail/char/2.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/pbackfail/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/pbackfail/wchar_t/2.cc: Likewise.
+ * testsuite/27_io/basic_istream/putback/char/1.cc: Tweak consistently.
+
+2004-10-01 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/sstream.tcc (seekpos): Minor rearrangement of two
+ conditionals consistently with seekoff.
+ * include/std/std_sstream.h (setbuf): Avoid a string temporary.
+ (_M_sync): Simplify a bit, clean-up comment.
+
+2004-09-30 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/10975 (DR 453)
+ * include/bits/sstream.tcc (seekoff): Don't fail if __beg == 0
+ and __off == 0.
+ * docs/html/ext/howto.html: Add an entry for DR 453.
+ * testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc: New.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc: Likewise.
+ * testsuite/27_io/basic_istream/tellg/char/1.cc: Tweak consistently.
+ * testsuite/27_io/basic_ostream/tellp/char/1.cc: Likewise.
+ * testsuite/27_io/basic_ostream/tellp/char/2.cc: Likewise.
+ * testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc: Fix and
+ move to...
+ * testsuite/27_io/basic_istream/seekp/char/2346-fstream.cc: ... here.
+ * testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc: Fix and
+ move to...
+ * testsuite/27_io/basic_istream/seekp/char/2346-sstream.cc: ... here.
+
+2004-09-29 Paolo Carlini <pcarlini@suse.de>
+
+ * include/std/std_sstream.h (basic_stringbuf(ios_base::openmode)):
+ Don't use _M_stringbuf_init, keep the pointers null, per 27.7.1.1.
+ (str()): Slightly tweak, protect from pptr() == 0.
+ (_M_update_egptr()): Likewise.
+ * include/bits/sstream.tcc (ssekoff, seekpos): In order to check
+ for an empty buffer use __beg instead of _M_string.capacity().
+ * testsuite/27_io/basic_stringbuf/cons/char/1.cc: New.
+ * testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc: Likewise.
+
+ * testsuite/27_io/basic_filebuf/cons/char/1.cc: New.
+ * testsuite/27_io/basic_filebuf/cons/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_streambuf/cons/char/1.cc: Update.
+ * testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc: Likewise.
+
+2004-09-29 Paolo Carlini <pcarlini@suse.de>
+ Benjamin Kosnik <bkoz@redhat.com>
+
+ * testsuite/testsuite_io.h (class constraint_buf): New, extended
+ and templatized version of constraint_filebuf; add typedefs for
+ streambuf/stringbuf/filebuf and wchar_t counterparts.
+
+2004-09-28 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/16612
+ * include/bits/basic_string.h (_M_dispose, _M_refcopy,
+ basic_string()): When _GLIBCXX_FULLY_DYNAMIC_STRING is defined,
+ don't deal with _S_empty_rep.
+ * include/bits/basic_string.tcc (_S_construct, _M_destroy,
+ _M_leak_hard, _M_mutate): Likewise.
+ * acinclude.m4 (GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING): New.
+ * acconfig.h: Add corresponding undef.
+ * configure.ac: Use GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING.
+ * docs/html/configopts.html: Document --enable-fully-dynamic-string.
+ * configure: Regenerate.
+ * config.h.in: Likewise.
+
+2004-09-28 Benjamin Kosnik <bkoz@redhat.com>
+ Paolo Carlini <pcarlini@suse.de>
+
+ * testsuite/21_strings/basic_string/operations/char/1.cc: New.
+ * testsuite/21_strings/basic_string/operations/wchar_t/1.cc: New.
+ * testsuite/21_strings/basic_string/element_access/char/empty.cc: New.
+ * testsuite/21_strings/basic_string/element_access/wchar_t/empty.cc:
+ New.
+
+2004-09-28 Paolo Carlini <pcarlini@suse.de>
+
+ * README: Remove obsolete entry about include/c_shadow.
+
+2004-09-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libstdc++/17469
+ * testsuite/lib/libstdc++.exp: Don't use global ld_library_path.
+
2004-09-24 Paolo Carlini <pcarlini@suse.de>
* src/localename.cc (locale::locale(const char*)): Minor tweaks:
diff --git a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
index 85bd8054890..06e8cf2e988 100644
--- a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
+++ b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
@@ -1,3 +1,7 @@
+2004-10-03 Paolo Carlini <pcarlini@suse.de>
+
+ Merged to mainline at tag libstdcxx_so_7-merge-20041003.
+
2004-09-24 Paolo Carlini <pcarlini@suse.de>
Merged to mainline at tag libstdcxx_so_7-merge-20040924.
diff --git a/libstdc++-v3/README b/libstdc++-v3/README
index 6844909a1cf..1064095fba7 100644
--- a/libstdc++-v3/README
+++ b/libstdc++-v3/README
@@ -35,13 +35,6 @@ It has subdirectories:
names into the std:: namespace.
[NB: this is the default, and is the same as --enable-cheaders=c_std]
- include/c_shadow
- Headers intended to shadow standard C headers provided by an
- underlying OS or C library, and other headers depended on directly
- by C++ headers (e.g. unistd.h). These are meant to wrap the names
- defined there into the _C_legacy namespace.
- [NB: this can be enabled via --enable-cheaders=c_shadow]
-
include/bits
Files included by standard headers and by other files in
the bits directory.
diff --git a/libstdc++-v3/acconfig.h b/libstdc++-v3/acconfig.h
index c2a96c2248b..cffecbd172f 100644
--- a/libstdc++-v3/acconfig.h
+++ b/libstdc++-v3/acconfig.h
@@ -45,6 +45,9 @@
// Define if LFS support is available.
#undef _GLIBCXX_USE_LFS
+// Define if a fully dynamic basic_string is wanted.
+#undef _GLIBCXX_FULLY_DYNAMIC_STRING
+
// Define if NLS translations are to be used.
#undef _GLIBCXX_USE_NLS
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 6e531007cac..6c9f13aa185 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -594,6 +594,25 @@ AC_DEFUN([GLIBCXX_CHECK_LFS], [
dnl
+dnl Check for whether a fully dynamic basic_string implementation should
+dnl be turned on, that does not put empty objects in per-process static
+dnl memory (mostly useful together with shared memory allocators, see PR
+dnl libstdc++/16612 for details).
+dnl
+dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING
+dnl --disable-fully-dynamic-string leaves _GLIBCXX_FULLY_DYNAMIC_STRING undefined
+dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
+dnl Where DEFAULT is either `yes' or `no'.
+dnl
+AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
+ GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
+ if test $enable_fully_dynamic_string = yes; then
+ AC_DEFINE(_GLIBCXX_FULLY_DYNAMIC_STRING)
+ fi
+])
+
+
+dnl
dnl Does any necessary configuration of the testsuite directory. Generates
dnl the testsuite_hooks.h header.
dnl
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index ecb29eb35db..acb7d732abc 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -46,6 +46,9 @@
// Define if LFS support is available.
#undef _GLIBCXX_USE_LFS
+// Define if a fully dynamic basic_string is wanted.
+#undef _GLIBCXX_FULLY_DYNAMIC_STRING
+
// Define if NLS translations are to be used.
#undef _GLIBCXX_USE_NLS
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 3c5d7206cff..b38e54980ca 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -884,6 +884,9 @@ Optional Features:
--enable-cxx-flags=FLAGS
pass compiler FLAGS when building library
[default=]
+ --enable-fully-dynamic-string
+ do not put empty strings in per-process static
+ memory [default=no]
--enable-symvers=STYLE enables symbol versioning of the shared library
[default=yes]
--enable-version-specific-runtime-libs
@@ -4394,7 +4397,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4397 "configure"' > conftest.$ac_ext
+ echo '#line 4400 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5015,7 +5018,7 @@ fi;
#
# Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style.
cat > conftest.$ac_ext << EOF
-#line 5018 "configure"
+#line 5021 "configure"
struct S { ~S(); };
void bar();
void foo()
@@ -7841,6 +7844,29 @@ echo "${ECHO_T}$EXTRA_CXX_FLAGS" >&6
+ # Check whether --enable-fully-dynamic-string or --disable-fully-dynamic-string was given.
+if test "${enable_fully_dynamic_string+set}" = set; then
+ enableval="$enable_fully_dynamic_string"
+
+ case "$enableval" in
+ yes|no) ;;
+ *) { { echo "$as_me:$LINENO: error: Argument to enable/disable fully-dynamic-string must be yes or no" >&5
+echo "$as_me: error: Argument to enable/disable fully-dynamic-string must be yes or no" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+
+else
+ enable_fully_dynamic_string=no
+fi;
+
+ if test $enable_fully_dynamic_string = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define _GLIBCXX_FULLY_DYNAMIC_STRING 1
+_ACEOF
+
+ fi
+
+
# No surprises, no surprises...
if test $atomicity_dir = cpu/generic ; then
{ echo "$as_me:$LINENO: WARNING: No native atomic operations are provided for this platform." >&5
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 345136d0743..eb70f8a3de9 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -94,6 +94,7 @@ GLIBCXX_ENABLE_CONCEPT_CHECKS([no])
GLIBCXX_ENABLE_DEBUG_FLAGS(["-g3 -O0"])
GLIBCXX_ENABLE_DEBUG([no])
GLIBCXX_ENABLE_CXX_FLAGS
+GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING([no])
# No surprises, no surprises...
if test $atomicity_dir = cpu/generic ; then
diff --git a/libstdc++-v3/docs/html/configopts.html b/libstdc++-v3/docs/html/configopts.html
index 8ef9c42eb5d..2c84e969a05 100644
--- a/libstdc++-v3/docs/html/configopts.html
+++ b/libstdc++-v3/docs/html/configopts.html
@@ -144,9 +144,8 @@ options</a></h1>
<dt><code>--enable-cheaders=OPTION </code></dt>
<dd><p>This allows the user to define what kind of C headers are
- used. Options are: c, c_std, and c_shadow. These correspond
- to the source directory's include/c, include/c_std, and
- include/c_shadow directories. The default is c_std.
+ used. Options are c and c_std. These correspond to the source
+ directory's include/c and include/c_std. The default is c_std.
</p>
</dd>
@@ -261,6 +260,14 @@ options</a></h1>
</p>
</dd>
+ <dt><code>--enable-fully-dynamic-string </code></dt>
+ <dd><p>This option enables a special version of basic_string avoiding
+ the optimization that allocates empty objects in static memory.
+ Mostly useful together with shared memory allocators, see PR
+ libstdc++/16612 for details.
+ </p>
+ </dd>
+
<dt><code>--enable-concept-checks </code></dt>
<dd><p>This turns on additional compile-time checks for instantiated
library templates, in the form of specialized templates,
diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html
index 5670c469768..5b4a69fb1f7 100644
--- a/libstdc++-v3/docs/html/ext/howto.html
+++ b/libstdc++-v3/docs/html/ext/howto.html
@@ -496,6 +496,12 @@
</dt>
<dd>Replace &quot;new&quot; with &quot;::new&quot;.
</dd>
+
+ <dt><a href="lwg-active.html#453">453</a>:
+ <em>basic_stringbuf::seekoff need not always fail for an empty stream</em>
+ </dt>
+ <dd>Don't fail if the next pointer is null and newoff is zero.
+ </dd>
<!--
<dt><a href="lwg-defects.html#"></a>:
<em></em>
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 7e6c669bd0b..1e79da4b4bd 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -211,7 +211,9 @@ namespace std
void
_M_dispose(const _Alloc& __a)
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (__builtin_expect(this != &_S_empty_rep(), false))
+#endif
if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0)
_M_destroy(__a);
} // XXX MT
@@ -222,7 +224,9 @@ namespace std
_CharT*
_M_refcopy() throw()
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (__builtin_expect(this != &_S_empty_rep(), false))
+#endif
__gnu_cxx::__atomic_add(&this->_M_refcount, 1);
return _M_refdata();
} // XXX MT
@@ -1957,11 +1961,14 @@ namespace std
size_type __n2) const;
};
-
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>::
basic_string()
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
: _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
+#else
+ : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
+#endif
// operator+
/**
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 7d27aab970c..49b6362e790 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -88,8 +88,10 @@ namespace std
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
input_iterator_tag)
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refdata();
+#endif
// Avoid reallocation for common case.
_CharT __buf[128];
size_type __len = 0;
@@ -134,11 +136,12 @@ namespace std
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
forward_iterator_tag)
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (__beg == __end && __a == _Alloc())
return _S_empty_rep()._M_refdata();
-
+#endif
// NB: Not required, but considered best practice.
- if (__builtin_expect(__is_null_pointer(__beg), 0))
+ if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0))
__throw_logic_error(__N("basic_string::_S_construct NULL not valid"));
const size_type __dnew = static_cast<size_type>(std::distance(__beg,
@@ -162,9 +165,10 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>::
_S_construct(size_type __n, _CharT __c, const _Alloc& __a)
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (__n == 0 && __a == _Alloc())
return _S_empty_rep()._M_refdata();
-
+#endif
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
if (__n)
@@ -358,8 +362,10 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_M_destroy(const _Alloc& __a) throw ()
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (this == &_S_empty_rep())
- return;
+ return;
+#endif
const size_type __size = sizeof(_Rep_base) +
(this->_M_capacity + 1) * sizeof(_CharT);
_Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
@@ -369,8 +375,10 @@ namespace std
void
basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard()
{
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (_M_rep() == &_S_empty_rep())
- return;
+ return;
+#endif
if (_M_rep()->_M_is_shared())
_M_mutate(0, 0, 0);
_M_rep()->_M_set_leaked();
@@ -385,8 +393,12 @@ namespace std
const size_type __new_size = __old_size + __len2 - __len1;
const size_type __how_much = __old_size - __pos - __len1;
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
if (_M_rep() == &_S_empty_rep()
|| _M_rep()->_M_is_shared() || __new_size > capacity())
+#else
+ if (_M_rep()->_M_is_shared() || __new_size > capacity())
+#endif
{
// Must reallocate.
const allocator_type __a = get_allocator();
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 24e3164e622..4500bb83623 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -35,7 +35,7 @@
#include <bits/os_defines.h>
// The current version of the C++ library in compressed ISO date format.
-#define __GLIBCXX__ 20040924
+#define __GLIBCXX__ 20041003
// Allow use of "export template." This is currently not a feature
// that g++ supports.
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index 137d6b3fff7..985a0e46d07 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -47,24 +47,29 @@ namespace std
pbackfail(int_type __c)
{
int_type __ret = traits_type::eof();
- const bool __testeof = traits_type::eq_int_type(__c, __ret);
-
if (this->eback() < this->gptr())
{
- const bool __testeq = traits_type::eq(traits_type::to_char_type(__c),
- this->gptr()[-1]);
- this->gbump(-1);
-
// Try to put back __c into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
- if (!__testeof && __testeq)
- __ret = __c;
- else if (__testeof)
- __ret = traits_type::not_eof(__c);
+ const bool __testeof = traits_type::eq_int_type(__c, __ret);
+ if (!__testeof)
+ {
+ const bool __testeq = traits_type::eq(traits_type::
+ to_char_type(__c),
+ this->gptr()[-1]);
+ const bool __testout = this->_M_mode & ios_base::out;
+ if (__testeq || __testout)
+ {
+ this->gbump(-1);
+ if (!__testeq)
+ *this->gptr() = traits_type::to_char_type(__c);
+ __ret = __c;
+ }
+ }
else
{
- *this->gptr() = traits_type::to_char_type(__c);
- __ret = __c;
+ this->gbump(-1);
+ __ret = traits_type::not_eof(__c);
}
}
return __ret;
@@ -123,6 +128,7 @@ namespace std
{
// Update egptr() to match the actual string end.
_M_update_egptr();
+
if (this->gptr() < this->egptr())
__ret = traits_type::to_int_type(*this->gptr());
}
@@ -141,10 +147,11 @@ namespace std
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
- if (_M_string.capacity() && (__testin || __testout || __testboth))
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 453. basic_stringbuf::seekoff need not always fail for an empty stream.
+ const char_type* __beg = __testin ? this->eback() : this->pbase();
+ if ((__beg || !__off) && (__testin || __testout || __testboth))
{
- char_type* __beg = __testin ? this->eback() : this->pbase();
-
_M_update_egptr();
off_type __newoffi = __off;
@@ -181,24 +188,24 @@ namespace std
seekpos(pos_type __sp, ios_base::openmode __mode)
{
pos_type __ret = pos_type(off_type(-1));
- if (_M_string.capacity())
- {
- off_type __pos (__sp);
- const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
- const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
- char_type* __beg = __testin ? this->eback() : this->pbase();
+ const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
+ const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
+ const char_type* __beg = __testin ? this->eback() : this->pbase();
+ if (__beg && (__testin || __testout))
+ {
_M_update_egptr();
+ const off_type __pos(__sp);
const bool __testpos = 0 <= __pos
&& __pos <= this->egptr() - __beg;
- if ((__testin || __testout) && __testpos)
+ if (__testpos)
{
if (__testin)
this->gbump((__beg + __pos) - this->gptr());
if (__testout)
this->pbump((__beg + __pos) - this->pptr());
- __ret = pos_type(off_type(__pos));
+ __ret = __sp;
}
}
return __ret;
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index 6b5728b94ce..3420999164c 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -111,8 +111,8 @@ namespace std
*/
explicit
basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
- : __streambuf_type(), _M_mode(), _M_string()
- { _M_stringbuf_init(__mode); }
+ : __streambuf_type(), _M_mode(__mode), _M_string()
+ { }
/**
* @brief Starts with an existing string buffer.
@@ -140,8 +140,7 @@ namespace std
__string_type
str() const
{
- const bool __testout = this->_M_mode & ios_base::out;
- if (__testout)
+ if (this->pptr())
{
// The current egptr() may not be the actual string end.
if (this->pptr() > this->egptr())
@@ -169,7 +168,7 @@ namespace std
}
protected:
- // Common initialization code for both ctors goes here.
+ // Common initialization code goes here.
/**
* @if maint
* @doctodo
@@ -220,7 +219,7 @@ namespace std
// things will quickly blow up.
// Step 1: Destroy the current internal array.
- _M_string = __string_type(__s, __n);
+ _M_string.assign(__s, __n);
// Step 2: Use the external array.
_M_sync(__s, 0, 0);
@@ -254,20 +253,19 @@ namespace std
{
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
- const __size_type __len = _M_string.size();
+ char_type* __end = __base + _M_string.size();
if (__testin)
- this->setg(__base, __base + __i, __base + __len);
+ this->setg(__base, __base + __i, __end);
if (__testout)
{
this->setp(__base, __base + _M_string.capacity());
this->pbump(__o);
- // We need a pointer to the string end anyway, even when
- // !__testin: in that case, however, for the correct
- // functioning of the streambuf inlines all the get area
- // pointers must be identical.
+ // egptr() always tracks the string end. When !__testin,
+ // for the correct functioning of the streambuf inlines
+ // the other get area pointers are identical.
if (!__testin)
- this->setg(__base + __len, __base + __len, __base + __len);
+ this->setg(__end, __end, __end);
}
}
@@ -277,9 +275,8 @@ namespace std
_M_update_egptr()
{
const bool __testin = this->_M_mode & ios_base::in;
- const bool __testout = this->_M_mode & ios_base::out;
- if (__testout && this->pptr() > this->egptr())
+ if (this->pptr() && this->pptr() > this->egptr())
if (__testin)
this->setg(this->eback(), this->gptr(), this->pptr());
else
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc
index 870d57aa355..b3c64f60d4d 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc
@@ -49,11 +49,11 @@ test01()
is_04.ignore(30);
is_04.clear();
state1 = is_04.rdstate();
- is_04.putback('|');
+ is_04.putback('t');
VERIFY( is_04.gcount() == 0 ); // DR 60
state2 = is_04.rdstate();
VERIFY( state1 == state2 );
- VERIFY( is_04.peek() == '|' );
+ VERIFY( is_04.peek() == 't' );
// istream& unget()
is_04.clear();
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc
deleted file mode 100644
index 72686f1b699..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// 2000-06-29 bkoz
-
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation
-//
-// This file is part of the GNU ISO C++ 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.
-
-// 27.6.1.3 unformatted input functions
-// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
-
-#include <istream>
-#include <fstream>
-#include <testsuite_hooks.h>
-
-const char* s = " lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
-const int times = 10;
-
-void write_rewind(std::iostream& stream)
-{
- for (int j = 0; j < times; j++)
- {
- bool test __attribute__((unused)) = true;
- std::streampos begin = stream.tellg();
-
- for (int i = 0; i < times; ++i)
- stream << j << '-' << i << s << '\n';
-
- stream.seekg(begin);
- std::streampos end = stream.tellg();
- std::streampos badpos = std::streampos(std::streambuf::off_type(-1));
- }
-}
-
-void check_contents(std::iostream& stream)
-{
- bool test __attribute__((unused)) = true;
-
- stream.clear();
- stream.seekg(0, std::ios::beg);
- int i = 0;
- int loop = times * times + 2;
- while (i < loop)
- {
- stream.ignore(80, '\n');
- if (stream.good())
- ++i;
- else
- break;
- }
- VERIFY( i == times );
-}
-
-// fstream
-// libstdc++/2346
-void test02()
-{
- std::fstream ofstrm;
- ofstrm.open("istream_seeks-3.txt", std::ios::out);
- if (!ofstrm)
- std::abort();
- write_rewind(ofstrm);
- ofstrm.close();
-
- std::fstream ifstrm;
- ifstrm.open("istream_seeks-3.txt", std::ios::in);
- check_contents(ifstrm);
- ifstrm.close();
-}
-
-int main()
-{
- test02();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc
deleted file mode 100644
index 60e43c9a78b..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// 2000-06-29 bkoz
-
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation
-//
-// This file is part of the GNU ISO C++ 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.
-
-// 27.6.1.3 unformatted input functions
-// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-
-#include <istream>
-#include <sstream>
-#include <testsuite_hooks.h>
-
-const char* s = " lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
-const int times = 10;
-
-void write_rewind(std::iostream& stream)
-{
- for (int j = 0; j < times; j++)
- {
- bool test __attribute__((unused)) = true;
- std::streampos begin = stream.tellg();
-
- for (int i = 0; i < times; ++i)
- stream << j << '-' << i << s << '\n';
-
- stream.seekg(begin);
- std::streampos end = stream.tellg();
- std::streampos badpos = std::streampos(std::streambuf::off_type(-1));
- }
-}
-
-void check_contents(std::iostream& stream)
-{
- bool test __attribute__((unused)) = true;
-
- stream.clear();
- stream.seekg(0, std::ios::beg);
- int i = 0;
- int loop = times * times + 2;
- while (i < loop)
- {
- stream.ignore(80, '\n');
- if (stream.good())
- ++i;
- else
- break;
- }
- VERIFY( i == times );
-}
-
-// stringstream
-// libstdc++/2346
-void test03()
-{
- std::stringstream sstrm;
-
- write_rewind(sstrm);
- check_contents(sstrm);
-}
-
-int main()
-{
- test03();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
index d213d040a11..4bbe40be919 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
@@ -31,20 +31,23 @@
void test01()
{
using namespace std;
+ typedef ios::off_type off_type;
typedef ios::pos_type pos_type;
bool test __attribute__((unused)) = true;
const char str_lit01[] = "istream_seeks-1.tst";
// in
- // test default ctors leave things in the same positions...
istringstream ist1;
pos_type p3 = ist1.tellg();
ifstream ifs1;
pos_type p4 = ifs1.tellg();
- VERIFY( p3 == p4 );
+ // N.B. We implement the resolution of DR 453 and
+ // istringstream::tellg() doesn't fail.
+ VERIFY( p3 == pos_type(off_type(0)) );
+ VERIFY( p4 == pos_type(off_type(-1)) );
// in
// test ctors leave things in the same positions...
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
index 5c8caced6f3..27506636b03 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
@@ -1,6 +1,6 @@
// 2000-06-29 bkoz
-// Copyright (C) 2000, 2003 Free Software Foundation
+// Copyright (C) 2000, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -25,24 +25,26 @@
#include <fstream>
#include <testsuite_hooks.h>
-
void test01()
{
using namespace std;
+ typedef ios::off_type off_type;
typedef ios::pos_type pos_type;
bool test __attribute__((unused)) = true;
const char str_lit01[] = "ostream_seeks-1.txt";
// out
- // test default ctors leave things in the same positions...
ostringstream ost1;
pos_type p1 = ost1.tellp();
ofstream ofs1;
pos_type p2 = ofs1.tellp();
- VERIFY( p1 == p2 );
+ // N.B. We implement the resolution of DR 453 and
+ // ostringstream::tellp() doesn't fail.
+ VERIFY( p1 == pos_type(off_type(0)) );
+ VERIFY( p2 == pos_type(off_type(-1)) );
// out
// test ctors leave things in the same positions...
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
index f82df5d4bb0..acdc3b4cc75 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
@@ -1,6 +1,6 @@
// 2000-03-23 bkoz
-// Copyright (C) 2000, 2003 Free Software Foundation
+// Copyright (C) 2000, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -33,13 +33,13 @@ void test01()
ostringstream ost;
pos_type pos1;
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(-1) );
+ VERIFY( pos1 == pos_type(off_type(0)) );
ost << "RZA ";
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(4) );
+ VERIFY( pos1 == pos_type(off_type(4)) );
ost << "ghost dog: way of the samurai";
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(33) );
+ VERIFY( pos1 == pos_type(off_type(33)) );
}
int main()
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
index 9400a599bfc..76a344cfe23 100644
--- a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
@@ -31,69 +31,12 @@
#include <streambuf>
#include <testsuite_hooks.h>
-
-class testbuf : public std::streambuf
-{
-public:
-
- // Typedefs:
- typedef std::streambuf::traits_type traits_type;
- typedef std::streambuf::char_type char_type;
-
- testbuf(): std::streambuf()
- { }
-
- bool
- check_pointers()
- {
- bool test __attribute__((unused)) = true;
- VERIFY( this->eback() == NULL );
- VERIFY( this->gptr() == NULL );
- VERIFY( this->egptr() == NULL );
- VERIFY( this->pbase() == NULL );
- VERIFY( this->pptr() == NULL );
- VERIFY( this->epptr() == NULL );
- return test;
- }
-
- int_type
- pub_uflow()
- { return (this->uflow()); }
-
- int_type
- pub_overflow(int_type __c = traits_type::eof())
- { return (this->overflow(__c)); }
-
- int_type
- pub_pbackfail(int_type __c)
- { return (this->pbackfail(__c)); }
-
- void
- pub_setg(char* beg, char* cur, char *end)
- { this->setg(beg, cur, end); }
-
- void
- pub_setp(char* beg, char* end)
- { this->setp(beg, end); }
-
-protected:
- int_type
- underflow()
- {
- int_type __retval = traits_type::eof();
- if (this->gptr() < this->egptr())
- __retval = traits_type::not_eof(0);
- return __retval;
- }
-};
+#include <testsuite_io.h>
void test01()
{
- typedef testbuf::traits_type traits_type;
- typedef testbuf::int_type int_type;
-
bool test __attribute__((unused)) = true;
- testbuf buf01;
+ __gnu_test::constraint_streambuf buf01;
// 27.5.2.1 basic_streambuf ctors
// default ctor initializes
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc
index a97b35f4d11..1721e4a820a 100644
--- a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc
@@ -32,69 +32,12 @@
#include <streambuf>
#include <testsuite_hooks.h>
-
-class testbuf : public std::wstreambuf
-{
-public:
-
- // Typedefs:
- typedef std::wstreambuf::traits_type traits_type;
- typedef std::wstreambuf::char_type char_type;
-
- testbuf(): std::wstreambuf()
- { }
-
- bool
- check_pointers()
- {
- bool test __attribute__((unused)) = true;
- VERIFY( this->eback() == NULL );
- VERIFY( this->gptr() == NULL );
- VERIFY( this->egptr() == NULL );
- VERIFY( this->pbase() == NULL );
- VERIFY( this->pptr() == NULL );
- VERIFY( this->epptr() == NULL );
- return test;
- }
-
- int_type
- pub_uflow()
- { return (this->uflow()); }
-
- int_type
- pub_overflow(int_type __c = traits_type::eof())
- { return (this->overflow(__c)); }
-
- int_type
- pub_pbackfail(int_type __c)
- { return (this->pbackfail(__c)); }
-
- void
- pub_setg(wchar_t* beg, wchar_t* cur, wchar_t* end)
- { this->setg(beg, cur, end); }
-
- void
- pub_setp(wchar_t* beg, wchar_t* end)
- { this->setp(beg, end); }
-
-protected:
- int_type
- underflow()
- {
- int_type __retval = traits_type::eof();
- if (this->gptr() < this->egptr())
- __retval = traits_type::not_eof(0);
- return __retval;
- }
-};
+#include <testsuite_io.h>
void test01()
{
- typedef testbuf::traits_type traits_type;
- typedef testbuf::int_type int_type;
-
bool test __attribute__((unused)) = true;
- testbuf buf01;
+ __gnu_test::constraint_wstreambuf buf01;
// 27.5.2.1 basic_streambuf ctors
// default ctor initializes
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 0b3b82b887e..2e8db1f4f5a 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -82,7 +82,7 @@ proc libstdc++_init { testfile } {
global cxx cxxflags
global includes
global gluefile wrap_flags
- global ld_library_path original_ld_library_path
+ global original_ld_library_path
global target_triplet
set blddir [lookfor_file [get_multilibs] libstdc++-v3]
diff --git a/libstdc++-v3/testsuite/testsuite_io.h b/libstdc++-v3/testsuite/testsuite_io.h
index e5e342eed14..809d0801c6d 100644
--- a/libstdc++-v3/testsuite/testsuite_io.h
+++ b/libstdc++-v3/testsuite/testsuite_io.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
-// Testing filebuf for the C++ library testsuite.
+// Testing streambuf/filebuf/stringbuf for the C++ library testsuite.
//
-// Copyright (C) 2003 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -32,6 +32,7 @@
#define _GLIBCXX_TESTSUITE_IO_H
#include <fstream>
+#include <sstream>
namespace __gnu_test
{
@@ -44,34 +45,60 @@ namespace __gnu_test
// Joint file position
// 27.8.1.4 - Overridden virtual functions p9
// If unbuffered, pbase == pptr == NULL
- class constraint_filebuf: public std::filebuf
- {
- public:
- bool
- write_position()
- {
- bool two = this->pptr() != NULL;
- bool one = this->pptr() < this->epptr();
- return one && two;
- }
-
- bool
- read_position()
- {
- bool one = this->gptr() != NULL;
- bool two = this->gptr() < this->egptr();
-
- return one && two;
- }
-
- bool
- unbuffered()
- {
- bool one = this->pbase() == NULL;
- bool two = this->pptr() == NULL;
- return one && two;
- }
- };
+ // 27.7.1.1 - Basic_stringbuf constructors p 1
+ // 27.8.1.2 - Basic_filebuf constructors p 1
+ // ... , initializing the base class with basic_streambuf() 27.5.2.1
+ template<typename T>
+ class constraint_buf
+ : public T
+ {
+ public:
+ bool
+ write_position()
+ {
+ bool one = this->pptr() != NULL;
+ bool two = this->pptr() < this->epptr();
+ return one && two;
+ }
+
+ bool
+ read_position()
+ {
+ bool one = this->gptr() != NULL;
+ bool two = this->gptr() < this->egptr();
+ return one && two;
+ }
+
+ bool
+ unbuffered()
+ {
+ bool one = this->pbase() == NULL;
+ bool two = this->pptr() == NULL;
+ return one && two;
+ }
+
+ bool
+ check_pointers()
+ {
+ bool one = this->eback() == NULL;
+ bool two = this->gptr() == NULL;
+ bool three = this->egptr() == NULL;
+
+ bool four = this->pbase() == NULL;
+ bool five = this->pptr() == NULL;
+ bool six = this->epptr() == NULL;
+ return one && two && three && four && five && six;
+ }
+ };
+
+ typedef constraint_buf<std::streambuf> constraint_streambuf;
+ typedef constraint_buf<std::filebuf> constraint_filebuf;
+ typedef constraint_buf<std::stringbuf> constraint_stringbuf;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef constraint_buf<std::wstreambuf> constraint_wstreambuf;
+ typedef constraint_buf<std::wfilebuf> constraint_wfilebuf;
+ typedef constraint_buf<std::wstringbuf> constraint_wstringbuf;
+#endif
// Used to check if basic_streambuf::pubsync() has been called.
// This is useful for checking if a function creates [io]stream::sentry