aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/basic_string.h6
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc32
-rw-r--r--libstdc++-v3/include/bits/char_traits.h5
4 files changed, 22 insertions, 28 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 859c72d..84efd3b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-12 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/bits/basic_string.h (_S_find(const _CharT* __beg, const
+ _CharT* __end, _CharT __c): Remove.
+ * include/bits/basic_string.tcc: Substitute traits::find for _S_find.
+ * include/bits/char_traits.h: Tweak.
+
2001-01-12 Laurynas Biveinis <lauras@softhome.net>
* acinclude.m4 (GLIBCPP_CHECK_CTYPE_SUPPORT): check for DJGPP <ctype.h>
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 6f3b372..06b0820 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -1,6 +1,6 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 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
@@ -839,10 +839,6 @@ namespace std {
int
compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2 = npos) const;
-
- private:
- static const _CharT*
- _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c);
};
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index a9ac2c9..27b0fad 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -574,23 +574,15 @@ namespace std
return __n;
}
- // String operations
- template<typename _CharT, typename _Traits, typename _Alloc>
- const _CharT*
- basic_string<_CharT, _Traits, _Alloc>::
- _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c)
- {
- return find_if(__beg, __end, _Char_traits_match<_CharT, _Traits>(__c));
- }
-
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
find(const _CharT* __s, size_type __pos, size_type __n) const
{
+ size_type __size = this->size();
size_t __xpos = __pos;
const _CharT* __data = _M_data();
- for (; __xpos + __n <= this->size(); ++__xpos)
+ for (; __xpos + __n <= __size; ++__xpos)
if (traits_type::compare(__data + __xpos, __s, __n) == 0)
return __xpos;
return npos;
@@ -606,9 +598,9 @@ namespace std
if (__pos < __size)
{
const _CharT* __data = _M_data();
- const _CharT* __end = __data + __size;
- const _CharT* __p = _S_find(__data + __pos, __end, __c);
- if (__p != __end)
+ size_type __n = __size - __pos;
+ const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
+ if (__p)
__ret = __p - __data;
}
return __ret;
@@ -659,11 +651,10 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>::
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
{
- const _CharT* __end = __s + __n;
for (; __n && __pos < this->size(); ++__pos)
{
- const _CharT* __p = _S_find(__s, __end, _M_data()[__pos]);
- if (__p != __end)
+ const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
+ if (__p)
return __pos;
}
return npos;
@@ -681,8 +672,7 @@ namespace std
__size = __pos;
do
{
- const _CharT* __p = _S_find(__s, __s + __n, _M_data()[__size]);
- if (__p != __s + __n)
+ if (traits_type::find(__s, __n, _M_data()[__size]))
return __size;
}
while (__size-- != 0);
@@ -697,7 +687,7 @@ namespace std
{
size_t __xpos = __pos;
for (; __n && __xpos < this->size(); ++__xpos)
- if (_S_find(__s, __s + __n, _M_data()[__xpos]) == __s + __n)
+ if (!traits_type::find(__s, __n, _M_data()[__xpos]))
return __xpos;
return npos;
}
@@ -708,7 +698,7 @@ namespace std
find_first_not_of(_CharT __c, size_type __pos) const
{
size_t __xpos = __pos;
- for (; __xpos < size(); ++__xpos)
+ for (; __xpos < this->size(); ++__xpos)
if (!traits_type::eq(_M_data()[__xpos], __c))
return __xpos;
return npos;
@@ -726,7 +716,7 @@ namespace std
__size = __pos;
do
{
- if (_S_find(__s, __s + __n, _M_data()[__size]) == __s + __n)
+ if (!traits_type::find(__s, __n, _M_data()[__size]))
return __size;
}
while (__size--);
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index baab722..4d78332 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -1,6 +1,6 @@
// Character Traits for use by standard string and iostream -*- C++ -*-
-// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 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
@@ -144,6 +144,7 @@ namespace std {
{ return eq_int_type(__c, eof()) ? int_type(0) : __c; }
};
+
// 21.1.4 char_traits specializations
template<>
struct char_traits<char>
@@ -297,7 +298,7 @@ namespace std {
_Char_traits_match(_CharT const& __c) : _M_c(__c) { }
bool
- operator()(_CharT const& __a) { return _Traits::eq(_M_c,__a); }
+ operator()(_CharT const& __a) { return _Traits::eq(_M_c, __a); }
};
} // namespace std