summaryrefslogtreecommitdiff
path: root/libstdc++-v3/config
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2000-12-14 07:20:37 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2000-12-14 07:20:37 +0000
commitd9ab8adb37794252f225f068ebd1b050a351bb46 (patch)
treedc9f61b3f86b17f8ce77a373cf2578b9d5c0469e /libstdc++-v3/config
parent413c5c85ca7279123136a308e51d0270857db518 (diff)
downloadgcc-d9ab8adb37794252f225f068ebd1b050a351bb46.tar.gz
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
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r--libstdc++-v3/config/os/aix/bits/ctype_base.h35
-rw-r--r--libstdc++-v3/config/os/aix/bits/ctype_inline.h11
-rw-r--r--libstdc++-v3/config/os/bsd/freebsd/bits/ctype_base.h55
-rw-r--r--libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h12
-rw-r--r--libstdc++-v3/config/os/bsd/netbsd/bits/ctype_base.h33
-rw-r--r--libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h11
-rw-r--r--libstdc++-v3/config/os/generic/bits/ctype_base.h29
-rw-r--r--libstdc++-v3/config/os/generic/bits/ctype_inline.h14
-rw-r--r--libstdc++-v3/config/os/gnu-linux/bits/ctype_base.h37
-rw-r--r--libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h17
-rw-r--r--libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h10
-rw-r--r--libstdc++-v3/config/os/irix/bits/ctype_base.h33
-rw-r--r--libstdc++-v3/config/os/irix/bits/ctype_inline.h18
-rw-r--r--libstdc++-v3/config/os/newlib/bits/ctype_base.h32
-rw-r--r--libstdc++-v3/config/os/newlib/bits/ctype_inline.h11
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_base.h31
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h13
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_base.h34
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h19
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_base.h35
-rw-r--r--libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h19
21 files changed, 271 insertions, 238 deletions
diff --git a/libstdc++-v3/config/os/aix/bits/ctype_base.h b/libstdc++-v3/config/os/aix/bits/ctype_base.h
index bae6bb4a458..166e5d06307 100644
--- a/libstdc++-v3/config/os/aix/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/aix/bits/ctype_base.h
@@ -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;
};
-
-
-
-
-
-
diff --git a/libstdc++-v3/config/os/aix/bits/ctype_inline.h b/libstdc++-v3/config/os/aix/bits/ctype_inline.h
index 06a42112bfc..c376f356723 100644
--- a/libstdc++-v3/config/os/aix/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/aix/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_base.h b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_base.h
index ea97e91a781..98b6265ddeb 100644
--- a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_base.h
@@ -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
- };
};
diff --git a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h
index 92ffe703fd6..64566c27bf1 100644
--- a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_base.h b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_base.h
index 648d839d9a6..ceea8acbc90 100644
--- a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_base.h
@@ -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;
};
-
-
-
diff --git a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h
index 952b0da8c98..23a6d19bbb2 100644
--- a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/generic/bits/ctype_base.h b/libstdc++-v3/config/os/generic/bits/ctype_base.h
index 08b85344390..58976b6670a 100644
--- a/libstdc++-v3/config/os/generic/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/generic/bits/ctype_base.h
@@ -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;
};
diff --git a/libstdc++-v3/config/os/generic/bits/ctype_inline.h b/libstdc++-v3/config/os/generic/bits/ctype_inline.h
index 20648a1dcbf..74429a2a059 100644
--- a/libstdc++-v3/config/os/generic/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/generic/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_base.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_base.h
index dfd29fbc4da..b546e0163c4 100644
--- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_base.h
@@ -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;
};
-
-
-
-
diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h
index fdba4e7535e..9fe7b16f7b6 100644
--- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h
index a03af593222..0013c5b079a 100644
--- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h
+++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h
@@ -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
diff --git a/libstdc++-v3/config/os/irix/bits/ctype_base.h b/libstdc++-v3/config/os/irix/bits/ctype_base.h
index b23cdad88a7..08557d158d7 100644
--- a/libstdc++-v3/config/os/irix/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/irix/bits/ctype_base.h
@@ -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;
};
-
-
-
-
diff --git a/libstdc++-v3/config/os/irix/bits/ctype_inline.h b/libstdc++-v3/config/os/irix/bits/ctype_inline.h
index 55641fe80a1..4a76dc5c6bd 100644
--- a/libstdc++-v3/config/os/irix/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/irix/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_base.h b/libstdc++-v3/config/os/newlib/bits/ctype_base.h
index 447073e2a04..973d41053b2 100644
--- a/libstdc++-v3/config/os/newlib/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/newlib/bits/ctype_base.h
@@ -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;
};
-
-
-
diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h
index ff8bb67c1ed..b2dd42b2854 100644
--- a/libstdc++-v3/config/os/newlib/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/newlib/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_base.h b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_base.h
index 1f4e1d65d3d..ad2babdb338 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_base.h
@@ -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;
};
diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h
index 88a93b4c7ba..d6259a44eac 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_base.h b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_base.h
index 4e2618f89e7..5f8d10aaf6f 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_base.h
@@ -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;
};
-
diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h
index 819fc19caed..2ea6f69b97f 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_inline.h
@@ -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;
}
diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_base.h b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_base.h
index 782a09b2fed..9b8bddc8d37 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_base.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_base.h
@@ -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;
};
-
diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h
index 819fc19caed..2ea6f69b97f 100644
--- a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_inline.h
@@ -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;
}