summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-26 20:22:01 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-26 20:22:01 +0000
commitd0a1c7ab0d21c5844f32ce5cf5bf59f0604ea0f0 (patch)
tree3c84540d40359c04272384d387191f13feb0cae6 /libstdc++-v3
parent51b3a6cac6a2da32c885ea03fe4e738b2a0d5e74 (diff)
downloadgcc-d0a1c7ab0d21c5844f32ce5cf5bf59f0604ea0f0.tar.gz
2000-06-13 Brent Verner <brent@rcfile.org>
* bits/string.tcc (string::rfind): Fix. * testsuite/21_strings/rfind.cc: New file. 2000-06-26 Anthony Williams <anthony@anthonyw.cjb.net> * testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error. 2000-06-26 Branko Cibej <branko.cibej@hermes.si> * testsuite/27_io/filebuf_members.cc (test_01): Fixed typos. * mkcheck.in: Make the *.txt and *.tst files writable after copying them to $TEST_DIR. * testsuite/27_io/ostream_inserter_arith.cc: Renamed __TEST_NUMPUT_VERBOSE to TEST_NUMPUT_VERBOSE. Define TEST_NUMPUT_VERBOSE only if DEBUG_ASSERT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34719 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog19
-rw-r--r--libstdc++-v3/bits/string.tcc16
-rw-r--r--libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_members.cc6
-rw-r--r--libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc14
5 files changed, 42 insertions, 23 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 366e05766e2..a5c10cef47f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,8 +1,23 @@
+2000-06-13 Brent Verner <brent@rcfile.org>
+
+ * bits/string.tcc (string::rfind): Fix.
+ * testsuite/21_strings/rfind.cc: New file.
+
+2000-06-26 Anthony Williams <anthony@anthonyw.cjb.net>
+
+ * testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error.
+
2000-06-26 Branko Cibej <branko.cibej@hermes.si>
- * mkcheck.in: Make the *.txt and *.tst files writable
- after copying them to $TEST_DIR.
+ * testsuite/27_io/filebuf_members.cc (test_01): Fixed typos.
+
+ * mkcheck.in: Make the *.txt and *.tst files writable after
+ copying them to $TEST_DIR.
+ * testsuite/27_io/ostream_inserter_arith.cc: Renamed
+ __TEST_NUMPUT_VERBOSE to TEST_NUMPUT_VERBOSE.
+ Define TEST_NUMPUT_VERBOSE only if DEBUG_ASSERT.
+
2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it.
diff --git a/libstdc++-v3/bits/string.tcc b/libstdc++-v3/bits/string.tcc
index d727151bd72..85179513548 100644
--- a/libstdc++-v3/bits/string.tcc
+++ b/libstdc++-v3/bits/string.tcc
@@ -634,14 +634,14 @@ namespace std
size_type __size = this->size();
if (__n <= __size)
{
- size_t __xpos = __size - __n;
- if (__xpos > __pos)
- __xpos = __pos;
-
- for (++__xpos; __xpos-- > 0; )
- if (traits_type::eq(_M_data()[__xpos], *__s)
- && traits_type::compare(_M_data() + __xpos, __s, __n) == 0)
- return __xpos;
+ __pos = std::min(__size - __n ,__pos);
+ const _CharT* __data = _M_data();
+ do
+ {
+ if (traits_type::compare(__data + __pos, __s, __n) == 0)
+ return __pos;
+ }
+ while (__pos-- > 0);
}
return npos;
}
diff --git a/libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc b/libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc
index 9756b0345b4..24edff4ec9d 100644
--- a/libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc
+++ b/libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc
@@ -1,6 +1,6 @@
// 1999-06-04 bkoz
-// Copyright (C) 1999 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000 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
@@ -79,8 +79,9 @@ int test01(void)
// NB: As strlen(str_lit01) != csz01, this test is undefined. It
// should not crash, but what gets constructed is a bit arbitrary.
+ // The "maverick's" of all string objects.
try {
- std::string str04(str_lit01, npos); // the "maverick's" of all string objects.
+ std::string str04(str_lit01, npos);
test &= true;
}
catch(std::length_error& fail) {
@@ -90,9 +91,10 @@ int test01(void)
test &= false;
}
+ // Build a maxsize-1 lengthed string consisting of all A's
try {
- std::string str03(str_lit01, csz01 - 1);
- test &= str03.size() != 0;
+ std::string str03(csz01 - 1, 'A');
+ test &= str03.size() == csz01 - 1;
test &= str03.size() <= str03.capacity();
}
// NB: bad_alloc is regrettable but entirely kosher for
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_members.cc b/libstdc++-v3/testsuite/27_io/filebuf_members.cc
index d26fd3b87c6..5057074529b 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_members.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_members.cc
@@ -47,7 +47,7 @@ test_01()
int close_num;
// read (ext)
- int fd = open(name01, O_RDONLY);
+ int fd = open(name_01, O_RDONLY);
test &= fd >= 0;
{
@@ -59,11 +59,11 @@ test_01()
// read (standard)
- FILE* f = fopen(name01, "r");
+ FILE* f = fopen(name_01, "r");
test &= !f;
{
- std::ifstream ifstream1(name02);
+ std::ifstream ifstream1(name_01);
test &= ifstream1.is_open();
std::ios_base::iostate st01 = ifstream1.rdstate();
test &= st01 == std::ios_base::goodbit;
diff --git a/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc b/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
index 519c89cb4c9..88ec5e48181 100644
--- a/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
+++ b/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
@@ -28,7 +28,9 @@
using namespace std;
-#define __TEST_NUMPUT_VERBOSE 1
+#ifndef DEBUG_ASSERT
+# define TEST_NUMPUT_VERBOSE 1
+#endif
struct _TestCase
{
@@ -190,7 +192,7 @@ void test01()
for (int j=0; j<sizeof(testcases)/sizeof(testcases[0]); j++)
{
_TestCase & tc = testcases[j];
-#ifdef __TEST_NUMPUT_VERBOSE
+#ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << tc.result << endl;
#endif
// test double with char type
@@ -201,7 +203,7 @@ void test01()
os.imbue(__loc);
apply_formatting(tc, os);
os << tc.val;
-#ifdef __TEST_NUMPUT_VERBOSE
+#ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl;
#endif
assert(os && os.str() == tc.result);
@@ -214,7 +216,7 @@ void test01()
os.imbue(__loc);
apply_formatting(tc, os);
os << (long double)tc.val;
-#ifdef __TEST_NUMPUT_VERBOSE
+#ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl;
#endif
assert(os && os.str() == tc.result);
@@ -257,7 +259,7 @@ void test02()
char largebuf[512];
sprintf(largebuf, "%.*Le", prec, val);
-#ifdef __TEST_NUMPUT_VERBOSE
+#ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << largebuf << endl;
cout << "result: " << os.str() << endl;
#endif
@@ -298,7 +300,7 @@ int main()
{
test01();
test02();
-#ifdef __TEST_NUMPUT_VERBOSE
+#ifdef TEST_NUMPUT_VERBOSE
cout << "Test passed!" << endl;
#endif
return 0;