Commit 8fd05cb0 by Vadim Egorov Committed by Benjamin Kosnik

2000-05-01 Vadim Egorov <egorovv@@mailandnews.com>

        * bits/char_traits.h: Fix parameter types.
        * bits/string.tcc: Avoid traits_type::move.

From-SVN: r33603
parent b7805411
2000-05-01 Vadim Egorov <egorovv@@mailandnews.com>
* bits/char_traits.h: Fix parameter types.
* bits/string.tcc: Avoid traits_type::move.
2000-05-01 Benjamin Kosnik <bkoz@haight.constant.com> 2000-05-01 Benjamin Kosnik <bkoz@haight.constant.com>
* src/Makefile.am (AC_CXXFLAGS): Add CPUFLAGS here. * src/Makefile.am (AC_CXXFLAGS): Add CPUFLAGS here.
......
// Character Traits for use by standard string and iostream // Character Traits for use by standard string and iostream -*- C++ -*-
// Copyright (C) 1997-1999 Free Software Foundation, Inc. // Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -79,9 +79,9 @@ namespace std { ...@@ -79,9 +79,9 @@ namespace std {
{ return __c1 < __c2; } { return __c1 < __c2; }
static int static int
compare(const char_type* __s1, const char_type* __s2, int_type __n) compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ {
for (int_type __i = 0; __i < __n; ++__i) for (size_t __i = 0; __i < __n; ++__i)
if (!eq(__s1[__i],__s2[__i])) if (!eq(__s1[__i],__s2[__i]))
return lt(__s1[__i],__s2[__i]) ? -1 : 1; return lt(__s1[__i],__s2[__i]) ? -1 : 1;
return 0; return 0;
...@@ -96,25 +96,25 @@ namespace std { ...@@ -96,25 +96,25 @@ namespace std {
} }
static const char_type* static const char_type*
find(const char_type* __s, int __n, const char_type& __a) find(const char_type* __s, size_t __n, const char_type& __a)
{ {
for (const char_type* __p = __s; __p < __s+__n; ++__p) for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
if (*__p == __a) return __p; if (*__p == __a) return __p;
return 0; return 0;
} }
static char_type* static char_type*
move(char_type* __s1, const char_type* __s2, int_type __n) move(char_type* __s1, const char_type* __s2, size_t __n)
{ return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
static char_type* static char_type*
copy(char_type* __s1, const char_type* __s2, int_type __n) copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
static char_type* static char_type*
assign(char_type* __s, int_type __n, char_type __a) assign(char_type* __s, size_t __n, char_type __a)
{ {
for (char_type* __p = __s; __p - __s < __n; ++__p) for (char_type* __p = __s; __p < __s + __n; ++__p)
assign(*__p, __a); assign(*__p, __a);
return __s; return __s;
} }
...@@ -167,7 +167,7 @@ namespace std { ...@@ -167,7 +167,7 @@ namespace std {
{ return __c1 < __c2; } { return __c1 < __c2; }
static int static int
compare(const char_type* __s1, const char_type* __s2, int_type __n) compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ return memcmp(__s1, __s2, __n); } { return memcmp(__s1, __s2, __n); }
static size_t static size_t
...@@ -175,19 +175,19 @@ namespace std { ...@@ -175,19 +175,19 @@ namespace std {
{ return strlen(__s); } { return strlen(__s); }
static const char_type* static const char_type*
find(const char_type* __s, int __n, const char_type& __a) find(const char_type* __s, size_t __n, const char_type& __a)
{ return static_cast<char*>(memchr(__s, __a, __n)); } { return static_cast<char*>(memchr(__s, __a, __n)); }
static char_type* static char_type*
move(char_type* __s1, const char_type* __s2, int_type __n) move(char_type* __s1, const char_type* __s2, size_t __n)
{ return static_cast<char*>(memmove(__s1, __s2, __n)); } { return static_cast<char*>(memmove(__s1, __s2, __n)); }
static char_type* static char_type*
copy(char_type* __s1, const char_type* __s2, int_type __n) copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return static_cast<char*>(memcpy(__s1, __s2, __n)); } { return static_cast<char*>(memcpy(__s1, __s2, __n)); }
static char_type* static char_type*
assign(char_type* __s, int_type __n, char_type __a) assign(char_type* __s, size_t __n, char_type __a)
{ return static_cast<char*>(memset(__s, __a, __n)); } { return static_cast<char*>(memset(__s, __a, __n)); }
static char_type static char_type
...@@ -232,15 +232,17 @@ namespace std { ...@@ -232,15 +232,17 @@ namespace std {
static void static void
assign(char_type& __c1, const char_type& __c2) assign(char_type& __c1, const char_type& __c2)
{ __c1 = __c2; } { __c1 = __c2; }
static bool static bool
eq(const char_type& __c1, const char_type& __c2) eq(const char_type& __c1, const char_type& __c2)
{ return __c1 == __c2; } { return __c1 == __c2; }
static bool static bool
lt(const char_type& __c1, const char_type& __c2) lt(const char_type& __c1, const char_type& __c2)
{ return __c1 < __c2; } { return __c1 < __c2; }
static int static int
compare(const char_type* __s1, const char_type* __s2, int_type __n) compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ {
for (int_type __i = 0; __i < __n; ++__i) for (int_type __i = 0; __i < __n; ++__i)
if (!eq(__s1[__i], __s2[__i])) if (!eq(__s1[__i], __s2[__i]))
...@@ -258,9 +260,9 @@ namespace std { ...@@ -258,9 +260,9 @@ namespace std {
} }
static const char_type* static const char_type*
find (const char_type* __s, int __n, const char_type& __a) find(const char_type* __s, size_t __n, const char_type& __a)
{ {
for (const char_type* __p = __s; __p < __s+__n; ++__p) for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
if (*__p == __a) if (*__p == __a)
return __p; return __p;
return 0; return 0;
...@@ -272,12 +274,12 @@ namespace std { ...@@ -272,12 +274,12 @@ namespace std {
__n * sizeof(wchar_t))); } __n * sizeof(wchar_t))); }
static char_type* static char_type*
copy(char_type* __s1, const char_type* __s2, int_type __n) copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return static_cast<wchar_t*>(memcpy(__s1, __s2, { return static_cast<wchar_t*>(memcpy(__s1, __s2,
__n * sizeof(wchar_t))); } __n * sizeof(wchar_t))); }
static char_type* static char_type*
assign(char_type* __s, int_type __n, char_type __a) assign(char_type* __s, size_t __n, char_type __a)
{ {
for (char_type* __p = __s; __p < __s + __n; ++__p) for (char_type* __p = __s; __p < __s + __n; ++__p)
assign(*__p, __a); assign(*__p, __a);
...@@ -324,4 +326,3 @@ namespace std { ...@@ -324,4 +326,3 @@ namespace std {
#endif /* _CPP_BITS_CHAR_TRAITS_H */ #endif /* _CPP_BITS_CHAR_TRAITS_H */
...@@ -280,7 +280,7 @@ namespace std ...@@ -280,7 +280,7 @@ namespace std
_M_rep()->_M_dispose(__a); _M_rep()->_M_dispose(__a);
_M_data(__r->_M_refdata()); _M_data(__r->_M_refdata());
} }
else if (__how_much) else if (__how_much && __len1 != __len2)
{ {
// Work in-place // Work in-place
traits_type::move(_M_data() + __pos + __len2, __src, __how_much); traits_type::move(_M_data() + __pos + __len2, __src, __how_much);
...@@ -851,7 +851,3 @@ namespace std ...@@ -851,7 +851,3 @@ namespace std
} // std:: } // std::
#endif /* _CPP_BITS_STRING_TCC */ #endif /* _CPP_BITS_STRING_TCC */
// Local Variables:
// mode:c++
// End:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment