diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-05-11 18:36:18 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-05-11 18:36:18 +0000 |
commit | 63cdea24dc015481c84d87a03b0a235ba64d1cdb (patch) | |
tree | 7320be9d6f1dbfded17ce2adc0f1283d45926540 /gnu/lib | |
parent | 39ba6e4a38d9c7f62a15e06841e8cfd354d73d4b (diff) |
use the ctype stuff in libc instead of re-rolling our own.
okay and comments from otto@ (static cast) and kettenis@.
Major bump.
Diffstat (limited to 'gnu/lib')
4 files changed, 31 insertions, 132 deletions
diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h index 564093dd557..8ec1d3f2d47 100644 --- a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2005 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 @@ -31,28 +31,25 @@ // ISO C++ 14882: 22.1 Locales // -// Default information, may not be appropriate for specific host. +// Information appropriate for OpenBSD. struct ctype_base { // Non-standard typedefs. - typedef const int* __to_type; + typedef const short* __to_type; // 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; + 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 = _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/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h index 0da0c7ccfb5..b3bb4c6a923 100644 --- a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// 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 @@ -34,103 +34,17 @@ // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc -// The following definitions are portable, but insanely slow. If one -// cares at all about performance, then specialized ctype -// functionality should be added for the native os in question: see -// the config/os/bits/ctype_*.h files. - -// Constructing a synthetic "C" table should be seriously considered... - bool ctype<char>:: is(mask __m, char __c) const - { - if (_M_table) - return _M_table[static_cast<unsigned char>(__c)] & __m; - else - { - bool __ret = true; - bool __any_match = false; - const size_t __bitmasksize = 10; - size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0 - for (;__ret && __bitcur <= __bitmasksize; ++__bitcur) - { - mask __bit = static_cast<mask>(1 << __bitcur); - if (__m & __bit) - { - __any_match = true; - bool __testis; - switch (__bit) - { - case space: - __testis = isspace(__c); - break; - case print: - __testis = isprint(__c); - break; - case cntrl: - __testis = iscntrl(__c); - break; - case upper: - __testis = isupper(__c); - break; - case lower: - __testis = islower(__c); - break; - case alpha: - __testis = isalpha(__c); - break; - case digit: - __testis = isdigit(__c); - break; - case punct: - __testis = ispunct(__c); - break; - case xdigit: - __testis = isxdigit(__c); - break; - case alnum: - __testis = isalnum(__c); - break; - case graph: - __testis = isgraph(__c); - break; - default: - __testis = false; - break; - } - __ret &= __testis; - } - } - return __ret & __any_match; - } - } - + { return _M_table[static_cast<unsigned char>(__c)] & __m; } + const char* ctype<char>:: is(const char* __low, const char* __high, mask* __vec) const { - if (_M_table) - while (__low < __high) - *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; - else - { - // Highest bitmask in ctype_base == 10. - const size_t __bitmasksize = 10; - for (;__low < __high; ++__vec, ++__low) - { - mask __m = 0; - // Lowest bitmask in ctype_base == 0 - size_t __i = 0; - for (;__i <= __bitmasksize; ++__i) - { - mask __bit = static_cast<mask>(1 << __i); - if (this->is(__bit, *__low)) - __m |= __bit; - } - *__vec = __m; - } - } + while (__low < __high) + *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; return __high; } @@ -138,13 +52,8 @@ ctype<char>:: scan_is(mask __m, const char* __low, const char* __high) const { - if (_M_table) - while (__low < __high - && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) - ++__low; - else - while (__low < __high && !this->is(__m, *__low)) - ++__low; + while (__low < __high && !this->is(__m, *__low)) + ++__low; return __low; } @@ -152,12 +61,7 @@ ctype<char>:: scan_not(mask __m, const char* __low, const char* __high) const { - if (_M_table) - while (__low < __high - && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) - ++__low; - else - while (__low < __high && this->is(__m, *__low) != 0) - ++__low; + while (__low < __high && this->is(__m, *__low) != 0) + ++__low; return __low; } diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h index d07dc8b9d7c..9943f2f7270 100644 --- a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h @@ -31,7 +31,7 @@ // // ISO C++ 14882: 22.1 Locales // - + // Information as gleaned from /usr/include/ctype.h const ctype_base::mask* @@ -41,14 +41,12 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_table(__table ? __table : classic_table()) + _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _ctype_ + 1) { } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_table(__table ? __table : classic_table()) + _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _ctype_ + 1) { } char @@ -60,7 +58,7 @@ { while (__low < __high) { - *__low = ::toupper((int) *__low); + *__low = ::toupper(static_cast<int>(*__low)); ++__low; } return __high; @@ -68,14 +66,14 @@ char ctype<char>::do_tolower(char __c) const - { return ::tolower((int) __c); } + { return ::tolower(static_cast<int>(__c)); } const char* ctype<char>::do_tolower(char* __low, const char* __high) const { while (__low < __high) { - *__low = ::tolower((int) *__low); + *__low = ::tolower(static_cast<int>(*__low)); ++__low; } return __high; diff --git a/gnu/lib/libstdc++/shlib_version b/gnu/lib/libstdc++/shlib_version index e081648f0bb..b97da722d51 100644 --- a/gnu/lib/libstdc++/shlib_version +++ b/gnu/lib/libstdc++/shlib_version @@ -1,2 +1,2 @@ -major=38 +major=39 minor=0 |