From 644638bc02e9875d61844d38832c1d534a8f05fa Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Mon, 26 Jun 2000 20:22:01 +0000 Subject: [PATCH] [multiple changes] 2000-06-13 Brent Verner * bits/string.tcc (string::rfind): Fix. * testsuite/21_strings/rfind.cc: New file. 2000-06-26 Anthony Williams * testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error. 2000-06-26 Branko Cibej * 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. From-SVN: r34719 --- libstdc++-v3/ChangeLog | 19 +++++++++++++++++-- libstdc++-v3/bits/string.tcc | 16 ++++++++-------- .../testsuite/21_strings/ctor_copy_dtor.cc | 10 ++++++---- .../testsuite/27_io/filebuf_members.cc | 6 +++--- .../testsuite/27_io/ostream_inserter_arith.cc | 14 ++++++++------ 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 + + * bits/string.tcc (string::rfind): Fix. + * testsuite/21_strings/rfind.cc: New file. + +2000-06-26 Anthony Williams + + * testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error. + 2000-06-26 Branko Cibej - * 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 * 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