ctype_inline.h (is): (Make right code path:) Remove magic constants and restructure to handle...

* config/os/bsd/freebsd/bits/ctype_inline.h (is): (Make right
	code path:) Remove magic constants and restructure to handle
	ctype.h bit mask layout changes more gracefully.  (Make fast
	code path:) Use __maskrune (), if available.
	(is): Remove special case for digit and xdigit masks.

From-SVN: r38847
This commit is contained in:
Loren J. Rittle 2001-01-10 02:08:16 +00:00 committed by Gerald Pfeifer
parent 9088c6fcf6
commit 046585534e
2 changed files with 25 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2001-01-10 Loren J. Rittle <ljrittle@acm.org>
* config/os/bsd/freebsd/bits/ctype_inline.h (is): (Make right
code path:) Remove magic constants and restructure to handle
ctype.h bit mask layout changes more gracefully. (Make fast
code path:) Use __maskrune (), if available.
(is): Remove special case for digit and xdigit masks.
2001-01-09 Robert Lipe <robertlipe@usa.net> 2001-01-09 Robert Lipe <robertlipe@usa.net>

View File

@ -38,28 +38,34 @@
ctype<char>:: ctype<char>::
is(mask __m, char __c) const is(mask __m, char __c) const
{ {
if (__m & (digit | xdigit)) return __istype(__c, __m);
return __isctype(__c, __m);
else
return __istype(__c, __m);
} }
const char* const char*
ctype<char>:: ctype<char>::
is(const char* __low, const char* __high, mask* __vec) const is(const char* __low, const char* __high, mask* __vec) const
{ {
const int __bitmasksize = 11; // Highest bitmask in ctype_base == 10
for (;__low < __high; ++__vec, ++__low) for (;__low < __high; ++__vec, ++__low)
{ {
#if defined (_CTYPE_S) || defined (__istype)
*__vec = __maskrune (*__low, upper | lower | alpha | digit | xdigit
| space | print | graph | cntrl | punct | alnum);
#else
mask __m = 0; mask __m = 0;
int __i = 0; // Lowest bitmask in ctype_base == 0 if (this->is(upper, *__low)) __m |= upper;
for (;__i < __bitmasksize; ++__i) if (this->is(lower, *__low)) __m |= lower;
{ if (this->is(alpha, *__low)) __m |= alpha;
mask __bit = static_cast<mask>(1 << __i); if (this->is(digit, *__low)) __m |= digit;
if (this->is(__bit, *__low)) if (this->is(xdigit, *__low)) __m |= xdigit;
__m |= __bit; if (this->is(space, *__low)) __m |= space;
} if (this->is(print, *__low)) __m |= print;
if (this->is(graph, *__low)) __m |= graph;
if (this->is(cntrl, *__low)) __m |= cntrl;
if (this->is(punct, *__low)) __m |= punct;
// Do not include explicit line for alnum mask since it is a
// pure composite of masks on FreeBSD.
*__vec = __m; *__vec = __m;
#endif
} }
return __high; return __high;
} }