ctype_base.h (ctype_base): Consistency with linux.

2000-12-13  Benjamin Kosnik  <bkoz@redhat.com>

	* config/os/generic/bits/ctype_base.h (ctype_base): Consistency
	with linux.
	* config/os/generic/bits/ctype_inline.h (is): Same.
	* config/os/solaris/solaris2.5/bits/ctype_inline.h (is): Same.
	* config/os/solaris/solaris2.5/bits/ctype_base.h: Same.
	* config/os/solaris/solaris2.6/bits/ctype_inline.h (is): Same.
	* config/os/solaris/solaris2.6/bits/ctype_base.h: Same.
	* config/os/solaris/solaris2.7/bits/ctype_inline.h (is): Same.
	* config/os/solaris/solaris2.7/bits/ctype_base.h: Same.
	* config/os/irix/bits/ctype_inline.h (is): Same.
	* config/os/irix/bits/ctype_base.h (ctype_base): Same.
	* config/os/aix/bits/ctype_inline.h (is): Same.
	* config/os/aix/bits/ctype_base.h (ctype_base): Same.
	* config/os/bsd/netbsd/bits/ctype_inline.h (is): Same.
	* config/os/bsd/netbsd/bits/ctype_base.h (ctype_base): Same.
	* config/os/bsd/freebsd/bits/ctype_base.h (ctype_base): Same.
	* config/os/bsd/freebsd/bits/ctype_inline.h (is): Same.
	* config/os/newlib/bits/ctype_inline.h (is): Same.
	* config/os/newlib/bits/ctype_base.h (ctype_base): Same.

	* testsuite/22_locale/ctype_char_members.cc (test01): Add tests, fix.
	* testsuite/22_locale/ctype.cc (test01): Add tests for
	ctype_base::mask bitmask features.
	* src/locale.cc: Define const static data for ctype_base.
	* config/os/gnu-linux/bits/ctype_base.h (ctype_base): Make
	ctype_base::mask type an integer type, not an enum.
	* config/os/gnu-linux/bits/ctype_inline.h (is): Implement correctly.
	* include/bits/locale_facets.h: Tweaks.

	* include/bits/ios_base.h: Formatting tweaks.

	* docs/html/17_intro/C++STYLE: Add.

From-SVN: r38243
This commit is contained in:
Benjamin Kosnik 2000-12-14 07:20:37 +00:00 committed by Benjamin Kosnik
parent 413c5c85ca
commit d9ab8adb37
28 changed files with 418 additions and 262 deletions

View File

@ -1,3 +1,38 @@
2000-12-13 Benjamin Kosnik <bkoz@redhat.com>
* config/os/generic/bits/ctype_base.h (ctype_base): Consistency
with linux.
* config/os/generic/bits/ctype_inline.h (is): Same.
* config/os/solaris/solaris2.5/bits/ctype_inline.h (is): Same.
* config/os/solaris/solaris2.5/bits/ctype_base.h: Same.
* config/os/solaris/solaris2.6/bits/ctype_inline.h (is): Same.
* config/os/solaris/solaris2.6/bits/ctype_base.h: Same.
* config/os/solaris/solaris2.7/bits/ctype_inline.h (is): Same.
* config/os/solaris/solaris2.7/bits/ctype_base.h: Same.
* config/os/irix/bits/ctype_inline.h (is): Same.
* config/os/irix/bits/ctype_base.h (ctype_base): Same.
* config/os/aix/bits/ctype_inline.h (is): Same.
* config/os/aix/bits/ctype_base.h (ctype_base): Same.
* config/os/bsd/netbsd/bits/ctype_inline.h (is): Same.
* config/os/bsd/netbsd/bits/ctype_base.h (ctype_base): Same.
* config/os/bsd/freebsd/bits/ctype_base.h (ctype_base): Same.
* config/os/bsd/freebsd/bits/ctype_inline.h (is): Same.
* config/os/newlib/bits/ctype_inline.h (is): Same.
* config/os/newlib/bits/ctype_base.h (ctype_base): Same.
* testsuite/22_locale/ctype_char_members.cc (test01): Add tests, fix.
* testsuite/22_locale/ctype.cc (test01): Add tests for
ctype_base::mask bitmask features.
* src/locale.cc: Define const static data for ctype_base.
* config/os/gnu-linux/bits/ctype_base.h (ctype_base): Make
ctype_base::mask type an integer type, not an enum.
* config/os/gnu-linux/bits/ctype_inline.h (is): Implement correctly.
* include/bits/locale_facets.h: Tweaks.
* include/bits/ios_base.h: Formatting tweaks.
* docs/html/17_intro/C++STYLE: Add.
2000-12-12 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* acinclude.m4 (GLIBCPP_CHECK_CTYPE_SUPPORT): Don't link ctype

View File

@ -35,28 +35,21 @@
struct ctype_base
{
typedef unsigned char mask;
// Non-standard typedefs.
typedef const int* __to_type;
enum
{
space = _ISSPACE,
print = _ISPRINT,
cntrl = _ISCNTRL,
upper = _ISUPPER,
lower = _ISLOWER,
alpha = _ISALPHA,
digit = _ISDIGIT,
punct = _ISPUNCT,
xdigit = _ISXDIGIT,
alnum = _ISALNUM,
graph = _ISGRAPH
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned char mask;
static const mask upper = _ISUPPER;
static const mask lower = _ISLOWER;
static const mask alpha = _ISALPHA;
static const mask digit = _ISDIGIT;
static const mask xdigit = _ISXDIGIT;
static const mask space = _ISSPACE;
static const mask print = _ISPRINT;
static const mask graph = _ISGRAPH;
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALNUM;
};

View File

@ -43,8 +43,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = __OBJ_DATA(__lc_ctype)->mask[*__low++];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = __OBJ_DATA(__lc_ctype)->mask[*__low++];
int __i = 0; // Lowest bitmask.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -37,40 +37,39 @@
struct ctype_base
{
typedef unsigned long mask;
// Non-standard typedefs.
typedef const int* __to_type;
enum
{
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned long mask;
#ifdef _CTYPE_S
// FreeBSD 4.0 uses this style of define.
space = _CTYPE_S,
print = _CTYPE_R,
cntrl = _CTYPE_C,
upper = _CTYPE_U,
lower = _CTYPE_L,
alpha = _CTYPE_A,
digit = _CTYPE_D,
punct = _CTYPE_P,
xdigit = _CTYPE_X,
alnum = _CTYPE_A | _CTYPE_D,
graph = _CTYPE_G
// FreeBSD 4.0 uses this style of define.
static const mask upper = _CTYPE_U;
static const mask lower = _CTYPE_L;
static const mask alpha = _CTYPE_A;
static const mask digit = _CTYPE_D;
static const mask xdigit = _CTYPE_X;
static const mask space = _CTYPE_S;
static const mask print = _CTYPE_R;
static const mask graph = _CTYPE_G;
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_A | _CTYPE_D;
#else
// Older versions, including Free BSD 3.4, use this style of define.
space = _S,
print = _R,
cntrl = _C,
upper = _U,
lower = _L,
alpha = _A,
digit = _D,
punct = _P,
xdigit = _X,
alnum = _A | _D,
graph = _G
// Older versions, including Free BSD 3.4, use this style of define.
static const mask upper = _U;
static const mask lower = _L;
static const mask alpha = _A;
static const mask digit = _D;
static const mask xdigit = _X;
static const mask space = _S;
static const mask print = _R;
static const mask graph = _G;
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _A | _D;
#endif
};
};

View File

@ -48,9 +48,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
// XXX
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask value, 1 == 1 << 0 means 0
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -38,26 +38,21 @@
struct ctype_base
{
typedef unsigned char mask;
// Non-standard typedefs.
typedef const unsigned char* __to_type;
enum
{
// NetBSD
space = _S,
print = _P | _U | _L | _N | _B,
cntrl = _C,
upper = _U,
lower = _L,
alpha = _U | _L,
digit = _N,
punct = _P,
xdigit = _N | _X,
alnum = _U | _L | _N,
graph = _P | _U | _L | _N,
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned char mask;
static const mask upper = _U;
static const mask lower = _L;
static const mask alpha = _U | _L;
static const mask digit = _N;
static const mask xdigit = _N | _X;
static const mask space = _S;
static const mask print = _P | _U | _L | _N | _B;
static const mask graph = _P | _U | _L | _N;
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
};

View File

@ -43,8 +43,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -35,24 +35,23 @@
struct ctype_base
{
typedef unsigned int mask;
// Non-standard typedefs.
typedef const int* __to_type;
enum
{
space = (1 << 0), // Whitespace
print = (1 << 1), // Printing
cntrl = (1 << 2), // Control character
upper = (1 << 3), // UPPERCASE
lower = (1 << 4), // lowercase
alpha = (1 << 5), // Alphabetic
digit = (1 << 6), // Numeric
punct = (1 << 7), // Punctuation
xdigit = (1 << 8), // Hexadecimal numeric
alnum = (1 << 9), // Alphanumeric
graph = (1 << 10) // Graphical
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned int mask;
static const mask upper = 1 << 0;
static const mask lower = 1 << 1;
static const mask alpha = 1 << 2;
static const mask digit = 1 << 3;
static const mask xdigit = 1 << 4;
static const mask space = 1 << 5;
static const mask print = 1 << 6;
static const mask graph = 1 << 7;
static const mask cntrl = 1 << 8;
static const mask punct = 1 << 9;
static const mask alnum = 1 << 10;
};

View File

@ -43,7 +43,7 @@
ctype<char>::
is(mask __m, char __c) const throw()
{
bool __ret = false;
bool __ret;
switch (__m)
{
case space:
@ -80,6 +80,7 @@
__ret = isgraph(__c);
break;
default:
__ret = false;
break;
}
return __ret;
@ -89,8 +90,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = 11; // Highest bitmask in ctype_base == 10
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask in ctype_base == 0
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -50,29 +50,20 @@
struct ctype_base
{
// Non-standard typedefs.
// XXX
typedef unsigned short mask;
typedef unsigned short __table_type;
typedef const int* __to_type;
// XXX
// enum mask
enum
{
space = _ISspace,
print = _ISprint,
cntrl = _IScntrl,
upper = _ISupper,
lower = _ISlower,
alpha = _ISalpha,
digit = _ISdigit,
punct = _ISpunct,
xdigit = _ISxdigit,
alnum = _ISalnum,
graph = _ISgraph
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned short mask;
static const mask upper = _ISupper;
static const mask lower = _ISlower;
static const mask alpha = _ISalpha;
static const mask digit = _ISdigit;
static const mask xdigit = _ISxdigit;
static const mask space = _ISspace;
static const mask print = _ISprint;
static const mask graph = _ISgraph;
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalnum;
};

View File

@ -37,14 +37,21 @@
bool
ctype<char>::
is(mask __m, char __c) const throw()
{ return _M_table[(unsigned char)(__c)] & __m; }
{ return _M_table[__c] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 1; // Lowest bitmask on linux, 1 <= x <= 15
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}
@ -52,7 +59,7 @@
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && !(_M_table[(unsigned char)(*__low)] & __m))
while (__low < __high && !(_M_table[*__low] & __m))
++__low;
return __low;
}
@ -62,7 +69,7 @@
scan_not(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high
&& (_M_table[(unsigned char)(*__low)] & __m) != 0)
&& (_M_table[*__low] & __m) != 0)
++__low;
return __low;
}

View File

@ -39,11 +39,11 @@
using _C_legacy::__ctype_b;
#endif
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
_M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
_M_ctable(__ctype_b), _M_table(__table == 0 ? _M_ctable: __table)
{ }
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) :
__ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
_M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
_M_ctable(__ctype_b), _M_table(__table == 0 ? _M_ctable : __table)
{ }
char
ctype<char>::do_toupper(char __c) const

View File

@ -35,26 +35,21 @@
struct ctype_base
{
typedef unsigned int mask;
// Non-standard typedefs.
typedef int* __to_type;
enum
{
space = _ISspace,
print = _ISprint,
cntrl = _IScntrl,
upper = _ISupper,
lower = _ISlower,
alpha = _ISalpha,
digit = _ISdigit,
punct = _ISpunct,
xdigit = _ISxdigit,
alnum = _ISalnum,
graph = _ISgraph
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned int mask;
static const mask upper = _ISupper;
static const mask lower = _ISlower;
static const mask alpha = _ISalpha;
static const mask digit = _ISdigit;
static const mask xdigit = _ISxdigit;
static const mask space = _ISspace;
static const mask print = _ISprint;
static const mask graph = _ISgraph;
static const mask cntrl = _IScntrl;
static const mask punct = _ISpunct;
static const mask alnum = _ISalnum;
};

View File

@ -37,14 +37,21 @@
bool
ctype<char>::
is(mask __m, char __c) const throw()
{ return (_M_table)[(unsigned char)(__c)] & __m; }
{ return (_M_table)[__c] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = (_M_table)[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 1; // Lowest bitmask on linux, 1 <= x <= 15
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}
@ -52,7 +59,7 @@
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && !((_M_table)[(unsigned char)(*__low)] & __m))
while (__low < __high && !((_M_table)[*__low] & __m))
++__low;
return __low;
}
@ -61,8 +68,7 @@
ctype<char>::
scan_not(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high
&& ((_M_table + 1)[(unsigned char)(*__low)] & __m) != 0)
while (__low < __high && ((_M_table + 1)[*__low] & __m) != 0)
++__low;
return __low;
}

View File

@ -37,25 +37,21 @@
struct ctype_base
{
typedef char mask;
// Non-standard typedefs.
typedef const int* __to_type;
enum
{
space = 010, // Whitespace
print = 020 | 01 | 02 | 04 | 0200, // Printing
cntrl = 040, // Control character
upper = 01, // UPPERCASE
lower = 02, // lowercase
alpha = 01 | 02, // Alphabetic
digit = 04, // Numeric
punct = 020, // Punctuation
xdigit = 0200, // Hexadecimal numeric
alnum = 01 | 02 | 04, // Alphanumeric
graph = 020 | 01 | 02 | 04 // Graphical
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef char mask;
static const mask upper = _U;
static const mask lower = _L;
static const mask alpha = _U | _L;
static const mask digit = _N;
static const mask xdigit = _X | _N;
static const mask space = _S;
static const mask print = _P | _U | _L | _N | _B;
static const mask graph = _P | _U | _L | _N;
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
};

View File

@ -43,8 +43,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = (_M_table + 1)[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask with newlib, 1 << 0 == 01
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 1997-1999 Cygnus Solutions
// Copyright (C) 1997-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
@ -35,22 +35,21 @@
struct ctype_base
{
typedef unsigned char mask;
// Non-standard typedefs.
typedef const int* __to_type;
enum
{
space = 010, // Whitespace
print = 020 | 01 | 02 | 04 | 0200, // Printing
cntrl = 040, // Control character
upper = 01, // UPPERCASE
lower = 02, // lowercase
alpha = 01 | 02, // Alphabetic
digit = 04, // Numeric
punct = 020, // Punctuation
xdigit = 0200, // Hexadecimal numeric
alnum = 01 | 02 | 04, // Alphanumeric
graph = 020 | 01 | 02 | 04 // Graphical
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned char mask;
static const mask upper = 01;
static const mask lower = 02;
static const mask alpha = 01 | 02;
static const mask digit = 04;
static const mask xdigit = 0200;
static const mask space = 010;
static const mask print = 020 | 01 | 02 | 04 | 0200;
static const mask graph = 020 | 01 | 02 | 04;
static const mask cntrl = 040;
static const mask punct = 020;
static const mask alnum = 01 | 02 | 04;
};

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 2000 Cygnus Solutions
// Copyright (C) 1997-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
@ -43,8 +43,15 @@
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = (_M_table + 1)[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask in ctype_base::mask.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 1997-1999 Cygnus Solutions
// Copyright (C) 1997-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
@ -32,27 +32,25 @@
//
// Information as gleaned from /usr/include/ctype.h. Looks like this
// only works with solaris2.6 and solaris2.7, but not solaris2.5.1.
// only works with solaris2.6.
struct ctype_base
{
typedef unsigned int mask;
// Non-standard typedefs.
typedef long* __to_type;
enum
{
space = _ISSPACE,
print = _ISPRINT,
cntrl = _ISCNTRL,
upper = _ISUPPER,
lower = _ISLOWER,
alpha = _ISALPHA,
digit = _ISDIGIT,
punct = _ISPUNCT,
xdigit = _ISXDIGIT,
alnum = _ISALNUM,
graph = _ISGRAPH
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned int mask;
static const mask upper = _ISUPPER;
static const mask lower = _ISLOWER;
static const mask alpha = _ISALPHA;
static const mask digit = _ISDIGIT;
static const mask xdigit = _ISXDIGIT;
static const mask space = _ISSPACE;
static const mask print = _ISPRINT;
static const mask graph = _ISGRAPH;
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALNUM;
};

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 2000 Cygnus Solutions
// Copyright (C) 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
@ -37,14 +37,21 @@
bool
ctype<char>::
is(mask __m, char __c) const throw()
{ return _M_table[(unsigned char)(__c)] & __m; }
{ return _M_table[__c] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask value from ctype_base.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}
@ -52,7 +59,7 @@
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && !(_M_table[(unsigned char)(*__low)] & __m))
while (__low < __high && !(_M_table[*__low] & __m))
++__low;
return __low;
}
@ -62,7 +69,7 @@
scan_not(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high
&& (_M_table[(unsigned char)(*__low)] & __m) != 0)
&& (_M_table[*__low] & __m) != 0)
++__low;
return __low;
}

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 1997-1999 Cygnus Solutions
// Copyright (C) 1997-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
@ -32,27 +32,26 @@
//
// Information as gleaned from /usr/include/ctype.h. Looks like this
// only works with solaris2.6 and solaris2.7, but not solaris2.5.1.
// only works with solaris2.7 and solaris2.8. Thanks for not changing
// things, sun engineers!
struct ctype_base
{
typedef unsigned int mask;
// Non-standard typedefs.
typedef int* __to_type;
enum
{
space = _ISSPACE,
print = _ISPRINT,
cntrl = _ISCNTRL,
upper = _ISUPPER,
lower = _ISLOWER,
alpha = _ISALPHA,
digit = _ISDIGIT,
punct = _ISPUNCT,
xdigit = _ISXDIGIT,
alnum = _ISALNUM,
graph = _ISGRAPH
};
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
typedef unsigned int mask;
static const mask upper = _ISUPPER;
static const mask lower = _ISLOWER;
static const mask alpha = _ISALPHA;
static const mask digit = _ISDIGIT;
static const mask xdigit = _ISXDIGIT;
static const mask space = _ISSPACE;
static const mask print = _ISPRINT;
static const mask graph = _ISGRAPH;
static const mask cntrl = _ISCNTRL;
static const mask punct = _ISPUNCT;
static const mask alnum = _ISALNUM;
};

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 2000 Cygnus Solutions
// Copyright (C) 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
@ -37,14 +37,21 @@
bool
ctype<char>::
is(mask __m, char __c) const throw()
{ return _M_table[(unsigned char)(__c)] & __m; }
{ return _M_table[__c] & __m; }
const char*
ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const throw()
{
while (__low < __high)
*__vec++ = _M_table[(unsigned char)(*__low++)];
const int __bitmasksize = sizeof(mask) * 8;
for (;__low < __high; ++__vec, ++__low)
{
mask __m = _M_table[*__low];
int __i = 0; // Lowest bitmask value from ctype_base.
while (__i < __bitmasksize && !(__m & static_cast<mask>(1 << __i)))
++__i;
*__vec = static_cast<mask>(1 << __i);
}
return __high;
}
@ -52,7 +59,7 @@
ctype<char>::
scan_is(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high && !(_M_table[(unsigned char)(*__low)] & __m))
while (__low < __high && !(_M_table[*__low] & __m))
++__low;
return __low;
}
@ -62,7 +69,7 @@
scan_not(mask __m, const char* __low, const char* __high) const throw()
{
while (__low < __high
&& (_M_table[(unsigned char)(*__low)] & __m) != 0)
&& (_M_table[*__low] & __m) != 0)
++__low;
return __low;
}

View File

@ -146,7 +146,18 @@ Notable areas of divergence from what may be previous local practice
-NOT-
sync()
Reason: ???
Reason: Koenig lookup.
11. constructor member intialization lists
should look like this:
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) :
__ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
_M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
_M_ctable(static_cast<const mask*>(__ctype_b),
_M_table(__table == 0 ? _M_ctable : __table)
{ }
The library currently has a mixture of GNU-C and modern C++ coding
styles. The GNU C usages will be combed out gradually.

View File

@ -40,7 +40,7 @@ namespace std {
// as permitted (but not required) in the standard, in order to provide
// better type safety in iostream calls. A side effect is that
// expressions involving them are no longer compile-time constants.
enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1<<16 };
enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1 << 16 };
inline _Ios_Fmtflags
operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
@ -71,7 +71,7 @@ namespace std {
{ return _Ios_Fmtflags(~static_cast<int>(__a)); }
enum _Ios_Openmode { _S_ios_openmode_end = 1<<16 };
enum _Ios_Openmode { _M_ios_openmode_end = 1 << 16 };
inline _Ios_Openmode
operator&(_Ios_Openmode __a, _Ios_Openmode __b)
@ -102,7 +102,7 @@ namespace std {
{ return _Ios_Openmode(~static_cast<int>(__a)); }
enum _Ios_Iostate { _S_ios_iostate_end = 1<<16 };
enum _Ios_Iostate { _M_ios_iostate_end = 1 << 16 };
inline _Ios_Iostate
operator&(_Ios_Iostate __a, _Ios_Iostate __b)
@ -132,7 +132,7 @@ namespace std {
operator~(_Ios_Iostate __a)
{ return _Ios_Iostate(~static_cast<int>(__a)); }
enum _Ios_Seekdir { _S_ios_Seekdir_end = 1<<16 };
enum _Ios_Seekdir { _M_ios_seekdir_end = 1 << 16 };
// 27.4.2 Class ios_base
class ios_base
@ -229,9 +229,8 @@ namespace std {
streamsize _M_width;
fmtflags _M_flags;
// 27.4.2.6 Members for callbacks
// 27.4.2.6 Members for callbacks
// 27.4.2.6 ios_base callbacks
struct _Callback_list
{
// Data Members
@ -259,7 +258,7 @@ namespace std {
void
_M_dispose_callbacks(void);
// 27.4.2.5 Members for iword/pword storage
// 27.4.2.5 Members for iword/pword storage
struct _Words
{
void* _M_pword;
@ -282,11 +281,11 @@ namespace std {
_M_init();
public:
// 27.4.2.1.6 Class ios_base::Init
// Used to initialize standard streams. In theory, g++ could use
// -finit-priority to order this stuff correctly without going
// through these machinations.
class Init
{
friend class ios_base;
@ -362,7 +361,7 @@ namespace std {
static bool
sync_with_stdio(bool __sync = true);
// Locales:
// Locales:
locale
imbue(const locale& __loc);

View File

@ -215,7 +215,6 @@ namespace std
public:
// Types:
typedef char char_type;
typedef ctype::mask mask;
private:
// Data Members:
@ -248,12 +247,10 @@ namespace std
virtual
~ctype();
// XXX
const mask*
table() const throw()
{ return _M_table; }
// XXX
const mask*
classic_table() throw()
{ return _M_ctable; }
@ -312,7 +309,6 @@ namespace std
public:
// Types:
typedef wchar_t char_type;
typedef ctype::mask mask;
typedef wctype_t __wmask_type;
// Data Members:

View File

@ -778,6 +778,19 @@ namespace std {
_Bad_use_facet::
~_Bad_use_facet() throw() { }
// Definitions for static const data members of ctype_base.
const ctype_base::mask ctype_base::space;
const ctype_base::mask ctype_base::print;
const ctype_base::mask ctype_base::cntrl;
const ctype_base::mask ctype_base::upper;
const ctype_base::mask ctype_base::lower;
const ctype_base::mask ctype_base::alpha;
const ctype_base::mask ctype_base::digit;
const ctype_base::mask ctype_base::punct;
const ctype_base::mask ctype_base::xdigit;
const ctype_base::mask ctype_base::alnum;
const ctype_base::mask ctype_base::graph;
// Platform-specific initialization code for ctype tables.
#include <bits/ctype_noninline.h>

View File

@ -30,5 +30,29 @@ int mask ();
class gnu_ctype: public std::ctype<unsigned char> { };
gnu_ctype facet01;
// 3: Sanity check ctype_base::mask bitmask requirements
void
test01()
{
using namespace std;
int main() { }
ctype_base::mask m01;
ctype_base::mask m02;
m01 = ctype_base::space;
m02 = ctype_base::xdigit;
m01 & m02;
m01 | m02;
m01 ^ m02;
m01 ~ m02;
m01 &= m02;
m01 |= m02;
m01 ^= m02;
}
int main()
{
test01();
return 0;
}

View File

@ -56,6 +56,22 @@ void test01()
int len = std::char_traits<char>::length(strlit00);
char c_array[len + 1];
// sanity check ctype_base::mask members
int i01 = std::ctype_base::space;
int i02 = std::ctype_base::upper;
int i03 = std::ctype_base::lower;
int i04 = std::ctype_base::digit;
int i05 = std::ctype_base::punct;
int i06 = std::ctype_base::alpha;
int i07 = std::ctype_base::xdigit;
int i08 = std::ctype_base::alnum;
int i09 = std::ctype_base::graph;
int i10 = std::ctype_base::print;
int i11 = std::ctype_base::cntrl;
int i12 = sizeof(std::ctype_base::mask);
VERIFY ( i01 != i02 != i03 != i04 != i05 != i06 != i07 != i08 != i09 );
VERIFY ( i01 != i10 != i11);
// bool is(mask m, char c) const;
VERIFY( gctype.is(std::ctype_base::space, c30) );
VERIFY( gctype.is(std::ctype_base::upper, c00) );
@ -72,20 +88,49 @@ void test01()
VERIFY( gctype.is(std::ctype_base::graph, c20) );
// const char* is(const char* low, const char* high, mask* vec) const
std::ctype_base::mask m01 = static_cast<std::ctype_base::mask>(0);
std::ctype_base::mask m02 = std::ctype_base::digit;
std::ctype_base::mask m00 = static_cast<std::ctype_base::mask>(0);
std::ctype_base::mask m01[3];
std::ctype_base::mask m02[13];
const char* cc0 = strlit00;
const char* cc1 = NULL;
const char* cc2 = NULL;
#if 1
cc1 = gctype.is(cc0, cc0, &m01);
VERIFY( cc1 == strlit00 );
cc2 = gctype.is(cc0, cc0 + 3, &m01);
VERIFY( cc2 == strlit00 + 3);
cc1 = gctype.is(cc0, cc0 + 13, &m02);
cc0 = strlit00;
m01[0] = m00;
m01[1] = m00;
m01[2] = m00;
cc1 = gctype.is(cc0, cc0, m01);
VERIFY( cc1 == strlit00 );
VERIFY( m01[0] == m00 );
VERIFY( m01[1] == m00 );
VERIFY( m01[2] == m00 );
cc0 = strlit00;
m01[0] = m00;
m01[1] = m00;
m01[2] = m00;
cc2 = gctype.is(cc0, cc0 + 3, m01);
VERIFY( cc2 == strlit00 + 3);
VERIFY( m01[0] != m00 );
VERIFY( m01[1] != m00 );
VERIFY( m01[2] != m00 );
VERIFY( gctype.is(m01[0], cc0[0]) );
VERIFY( gctype.is(m01[1], cc0[1]) );
VERIFY( gctype.is(m01[2], cc0[2]) );
cc0 = strlit00;
cc1 = gctype.is(cc0, cc0 + 13, m02);
VERIFY( cc1 == strlit00 + 13);
#endif
VERIFY( m02[6] != m00 );
VERIFY( m02[7] != m00 );
VERIFY( m02[8] != m00 );
VERIFY( m02[8] != m02[6] != m02[7] );
VERIFY( static_cast<bool>(m02[6] & std::ctype_base::alnum) );
VERIFY( static_cast<bool>(m02[7] & std::ctype_base::punct) );
VERIFY( static_cast<bool>(m02[8] & std::ctype_base::space) );
VERIFY( gctype.is(m02[6], cc0[6]) );
VERIFY( gctype.is(m02[7], cc0[7]) );
VERIFY( gctype.is(m02[8], cc0[8]) );
// char toupper(char c) const
c100 = gctype.toupper(c10);