mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-18 07:58:53 +08:00
2000-0508 Steven King <sxking@uswest.net>
* bits/char_traits.h: use wchar_t utility functions for char_traits<wchar_t> methods. * testsuite/21_string/char_traits.cc: New (test02): test char_traits<wchar_t> 2000-05-08 Benjamin Kosnik <bkoz@cygnus.com> * acinclude.m4 (GLIBCPP_CXXFLAGS): Add bits for solaris2.8. From-SVN: r33783
This commit is contained in:
parent
408607542a
commit
8445e42a24
@ -1,5 +1,14 @@
|
||||
2000-0508 Steven King <sxking@uswest.net>
|
||||
|
||||
* bits/char_traits.h: use wchar_t utility functions for
|
||||
char_traits<wchar_t> methods.
|
||||
* testsuite/21_string/char_traits.cc: New (test02): test
|
||||
char_traits<wchar_t>
|
||||
|
||||
2000-05-08 Benjamin Kosnik <bkoz@cygnus.com>
|
||||
|
||||
* acinclude.m4 (GLIBCPP_CXXFLAGS): Add bits for solaris2.8.
|
||||
|
||||
* bits/fstream.tcc (filebuf::_M_init_filebuf): Don't set
|
||||
_M_buf_size based on macro, instead use _M_buf_size_opt.
|
||||
* bits/std_streambuf.h (basic_streambuf): Add _M_buf_size_opt.
|
||||
|
@ -297,7 +297,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
ctype_default=yes
|
||||
|
||||
dnl Test for <ctype> functionality -- gnu-linux
|
||||
AC_MSG_CHECKING([for gnu-linux <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for gnu-linux ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -313,7 +313,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for solaris 2.6 or 2.7 <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for solaris 2.[6,7,8] ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -336,7 +336,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
ctype_default=no
|
||||
else
|
||||
ctype_include_dir="config/solaris/solaris2.7"
|
||||
AC_MSG_RESULT("solaris2.7")
|
||||
AC_MSG_RESULT("solaris2.[6,7]")
|
||||
ctype_default=no
|
||||
fi
|
||||
fi
|
||||
@ -344,7 +344,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- solaris 2.5.1
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for solaris 2.5.1 <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for solaris 2.5.1 ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -360,7 +360,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- aix
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for aix <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for aix ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -377,7 +377,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- newlib
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for newlib <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for newlib ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
|
12
libstdc++-v3/aclocal.m4
vendored
12
libstdc++-v3/aclocal.m4
vendored
@ -309,7 +309,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
ctype_default=yes
|
||||
|
||||
dnl Test for <ctype> functionality -- gnu-linux
|
||||
AC_MSG_CHECKING([for gnu-linux <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for gnu-linux ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -325,7 +325,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for solaris 2.6 or 2.7 <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for solaris 2.[6,7,8] ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -348,7 +348,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
ctype_default=no
|
||||
else
|
||||
ctype_include_dir="config/solaris/solaris2.7"
|
||||
AC_MSG_RESULT("solaris2.7")
|
||||
AC_MSG_RESULT("solaris2.[6,7]")
|
||||
ctype_default=no
|
||||
fi
|
||||
fi
|
||||
@ -356,7 +356,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- solaris 2.5.1
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for solaris 2.5.1 <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for solaris 2.5.1 ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -372,7 +372,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- aix
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for aix <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for aix ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
@ -389,7 +389,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
|
||||
|
||||
dnl Test for <ctype> functionality -- newlib
|
||||
if test $ctype_default = "yes"; then
|
||||
AC_MSG_CHECKING([for newlib <ctype>])
|
||||
AC_MSG_CHECKING([<ctype> for newlib ])
|
||||
AC_TRY_COMPILE([#include <ctype.h>],
|
||||
[int
|
||||
foo (int a)
|
||||
|
@ -243,48 +243,27 @@ namespace std {
|
||||
|
||||
static int
|
||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
for (size_t __i = 0; __i < __n; ++__i)
|
||||
if (!eq(__s1[__i], __s2[__i]))
|
||||
return lt(__s1[__i], __s2[__i]) ? -1 : 1;
|
||||
return 0;
|
||||
}
|
||||
{ return wmemcmp(__s1, __s2, __n); }
|
||||
|
||||
static size_t
|
||||
length(const char_type* __s)
|
||||
{
|
||||
const char_type* __p = __s;
|
||||
while (*__p)
|
||||
++__p;
|
||||
return (__p - __s);
|
||||
}
|
||||
{ return wcslen (__s); }
|
||||
|
||||
static const char_type*
|
||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{
|
||||
for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
|
||||
if (*__p == __a)
|
||||
return __p;
|
||||
return 0;
|
||||
}
|
||||
{ return wmemchr(__s, __a, __n); }
|
||||
|
||||
static char_type*
|
||||
move(char_type* __s1, const char_type* __s2, int_type __n)
|
||||
{ return static_cast<wchar_t*>(memmove(__s1, __s2,
|
||||
__n * sizeof(wchar_t))); }
|
||||
{ return wmemmove(__s1, __s2, __n); }
|
||||
|
||||
static char_type*
|
||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{ return static_cast<wchar_t*>(memcpy(__s1, __s2,
|
||||
__n * sizeof(wchar_t))); }
|
||||
{ return wmemcpy(__s1, __s2, __n); }
|
||||
|
||||
static char_type*
|
||||
assign(char_type* __s, size_t __n, char_type __a)
|
||||
{
|
||||
for (char_type* __p = __s; __p < __s + __n; ++__p)
|
||||
assign(*__p, __a);
|
||||
return __s;
|
||||
}
|
||||
{ return wmemset(__s, __a, __n); }
|
||||
|
||||
static char_type
|
||||
to_char_type(const int_type& __c) { return char_type(__c); }
|
||||
|
22
libstdc++-v3/configure
vendored
22
libstdc++-v3/configure
vendored
@ -3463,8 +3463,8 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
|
||||
|
||||
ctype_default=yes
|
||||
|
||||
echo $ac_n "checking for gnu-linux <ctype>""... $ac_c" 1>&6
|
||||
echo "configure:3468: checking for gnu-linux <ctype>" >&5
|
||||
echo $ac_n "checking <ctype> for gnu-linux ""... $ac_c" 1>&6
|
||||
echo "configure:3468: checking <ctype> for gnu-linux " >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3470 "configure"
|
||||
#include "confdefs.h"
|
||||
@ -3495,8 +3495,8 @@ rm -f conftest*
|
||||
fi
|
||||
|
||||
if test $ctype_default = "yes"; then
|
||||
echo $ac_n "checking for solaris 2.6 or 2.7 <ctype>""... $ac_c" 1>&6
|
||||
echo "configure:3500: checking for solaris 2.6 or 2.7 <ctype>" >&5
|
||||
echo $ac_n "checking <ctype> for solaris 2.6,7,8 ""... $ac_c" 1>&6
|
||||
echo "configure:3500: checking <ctype> for solaris 2.6,7,8 " >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3502 "configure"
|
||||
#include "confdefs.h"
|
||||
@ -3564,15 +3564,15 @@ cross_compiling=$ac_cv_prog_cc_cross
|
||||
ctype_default=no
|
||||
else
|
||||
ctype_include_dir="config/solaris/solaris2.7"
|
||||
echo "$ac_t"""solaris2.7"" 1>&6
|
||||
echo "$ac_t"""solaris2.6,7"" 1>&6
|
||||
ctype_default=no
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ctype_default = "yes"; then
|
||||
echo $ac_n "checking for solaris 2.5.1 <ctype>""... $ac_c" 1>&6
|
||||
echo "configure:3576: checking for solaris 2.5.1 <ctype>" >&5
|
||||
echo $ac_n "checking <ctype> for solaris 2.5.1 ""... $ac_c" 1>&6
|
||||
echo "configure:3576: checking <ctype> for solaris 2.5.1 " >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3578 "configure"
|
||||
#include "confdefs.h"
|
||||
@ -3603,8 +3603,8 @@ rm -f conftest*
|
||||
fi
|
||||
|
||||
if test $ctype_default = "yes"; then
|
||||
echo $ac_n "checking for aix <ctype>""... $ac_c" 1>&6
|
||||
echo "configure:3608: checking for aix <ctype>" >&5
|
||||
echo $ac_n "checking <ctype> for aix ""... $ac_c" 1>&6
|
||||
echo "configure:3608: checking <ctype> for aix " >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3610 "configure"
|
||||
#include "confdefs.h"
|
||||
@ -3636,8 +3636,8 @@ rm -f conftest*
|
||||
fi
|
||||
|
||||
if test $ctype_default = "yes"; then
|
||||
echo $ac_n "checking for newlib <ctype>""... $ac_c" 1>&6
|
||||
echo "configure:3641: checking for newlib <ctype>" >&5
|
||||
echo $ac_n "checking <ctype> for newlib ""... $ac_c" 1>&6
|
||||
echo "configure:3641: checking <ctype> for newlib " >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 3643 "configure"
|
||||
#include "confdefs.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 1999-06-03 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
|
||||
@ -103,17 +103,102 @@ int test01(void)
|
||||
c2 = array1[0];
|
||||
test &= c1 != c2;
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert(test);
|
||||
#endif
|
||||
return test;
|
||||
}
|
||||
|
||||
int test02(void)
|
||||
{
|
||||
bool test = true;
|
||||
const std::wstring str_01(L"zuma beach");
|
||||
const std::wstring str_02(L"montara and ocean beach");
|
||||
|
||||
// 21.1.1 character traits requirements
|
||||
|
||||
// Key for decoding what function signatures really mean:
|
||||
// X == char_traits<_CharT>
|
||||
// [c,d] == _CharT
|
||||
// [p,q] == const _CharT*
|
||||
// s == _CharT*
|
||||
// [n,i,j] == size_t
|
||||
// f == X::int_type
|
||||
// pos == X::pos_type
|
||||
// state == X::state_type
|
||||
|
||||
// void X::assign(wchar_t c, wchar_t d)
|
||||
// assigns c = d;
|
||||
wchar_t c1 = L'z';
|
||||
wchar_t c2 = L'u';
|
||||
test &= c1 != c2;
|
||||
std::char_traits<wchar_t>::assign(c1,c2);
|
||||
test &= c1 == L'u';
|
||||
|
||||
// char* X::move(char* s, const char* p, size_t n)
|
||||
// for each i in [0,n) performs X::assign(s[i], p[i]). Copies
|
||||
// correctly even where p is in [s, s + n), and yields s.
|
||||
wchar_t array1[] = {L'z', L'u', L'm', L'a', L' ', L'b', L'e', L'a', L'c', L'h', 0};
|
||||
const wchar_t str_lit1[] = L"montara and ocean beach";
|
||||
int len = sizeof(str_lit1) + sizeof(array1) - 1; // two terminating chars
|
||||
wchar_t array2[len];
|
||||
|
||||
test &= str_lit1[0] == 'm';
|
||||
c1 = array2[0];
|
||||
c2 = str_lit1[0];
|
||||
wchar_t c3 = array2[1];
|
||||
wchar_t c4 = str_lit1[1];
|
||||
std::char_traits<wchar_t>::move(array2, str_lit1, 0);
|
||||
test &= array2[0] == c1;
|
||||
test &= str_lit1[0] == c2;
|
||||
std::char_traits<wchar_t>::move(array2, str_lit1, 1);
|
||||
test &= array2[0] == c2;
|
||||
test &= str_lit1[0] == c2;
|
||||
test &= array2[1] == c3;
|
||||
test &= str_lit1[1] == c4;
|
||||
std::char_traits<wchar_t>::move(array2, str_lit1, 2);
|
||||
test &= array2[0] == c2;
|
||||
test &= str_lit1[0] == c2;
|
||||
test &= array2[1] == c4;
|
||||
test &= str_lit1[1] == c4;
|
||||
|
||||
wchar_t* pc1 = array1 + 1;
|
||||
c1 = pc1[0];
|
||||
c2 = array1[0];
|
||||
test &= c1 != c2;
|
||||
wchar_t* pc2 = std::char_traits<wchar_t>::move(array1, pc1, 0);
|
||||
c3 = pc1[0];
|
||||
c4 = array1[0];
|
||||
test &= c1 == c3;
|
||||
test &= c2 == c4;
|
||||
test &= pc2 == array1;
|
||||
|
||||
c1 = pc1[0];
|
||||
c2 = array1[0];
|
||||
wchar_t* pc3 = pc1;
|
||||
pc2 = std::char_traits<wchar_t>::move(array1, pc1, 10);
|
||||
c3 = pc1[0];
|
||||
c4 = array1[0];
|
||||
test &= c1 != c3; // underlying wchar_t array changed.
|
||||
test &= c4 != c3;
|
||||
test &= pc2 == array1;
|
||||
test &= pc3 == pc1; // but pointers o-tay
|
||||
c1 = *(str_01.data());
|
||||
c2 = array1[0];
|
||||
test &= c1 != c2;
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert(test);
|
||||
#endif
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user