X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Carey Evans" Newsgroups: comp.os.msdos.djgpp Subject: Bugs fixes for G++ ctype specialisation Date: 31 May 2005 15:11:26 -0700 Organization: http://groups.google.com Lines: 113 Message-ID: <1117577486.704501.203930@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: 210.54.0.162 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1117577492 3482 127.0.0.1 (31 May 2005 22:11:32 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Tue, 31 May 2005 22:11:32 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse AT google DOT com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=210.54.0.162; posting-account=a2Dz9g0AAAAQI7DN4N6e935Thq5XWCRh To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com The patch below changes ctype_inline.h and ctype_nonline.h to work in line with the C++ standard, section 22.2.1.3. Currently is(mask,char), scan_is() and scan_not() don't follow the spec and only work for the classic ctype table, is(const char*,const char*,mask*) doesn't work anyway, and do_tolower() and do_toupper() don't work for non-ASCII characters. This patch makes the DJGPP versions of ctype_inline.h and ctype_noninline.h almost identical to the Solaris versions, apart from the names of the pointers to the ctype flags, tolower and toupper tables. diff -u -r bits.dist/ctype_inline.h bits/ctype_inline.h --- bits.dist/ctype_inline.h 2004-11-06 16:21:54.000000000 +1300 +++ bits/ctype_inline.h 2005-06-01 09:53:08.000000000 +1200 @@ -37,7 +37,7 @@ bool ctype:: is(mask __m, char __c) const - { return _M_table[static_cast(__c + 1)] & __m; } + { return _M_table[static_cast(__c)] & __m; } const char* ctype:: @@ -52,7 +52,8 @@ ctype:: scan_is(mask __m, const char* __low, const char* __high) const { - while (__low < __high && !this->is(__m, *__low)) + while (__low < __high + && !(_M_table[static_cast(*__low)] & __m)) ++__low; return __low; } @@ -61,7 +62,8 @@ ctype:: scan_not(mask __m, const char* __low, const char* __high) const { - while (__low < __high && this->is(__m, *__low) != 0) + while (__low < __high + && (_M_table[static_cast(*__low)] & __m) != 0) ++__low; return __low; } diff -u -r bits.dist/ctype_noninline.h bits/ctype_noninline.h --- bits.dist/ctype_noninline.h 2004-11-06 16:21:54.000000000 +1300 +++ bits/ctype_noninline.h 2005-06-01 09:56:38.000000000 +1200 @@ -35,13 +35,13 @@ const ctype_base::mask* ctype::classic_table() throw() - { return 0; } + { return __dj_ctype_flags + 1; } ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) : facet(__refs), _M_del(__table != 0 && __del), - _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), - _M_table(__table ? __table : __dj_ctype_flags) + _M_toupper(__dj_ctype_toupper + 1), _M_tolower(__dj_ctype_tolower + 1), + _M_table(__table ? __table : classic_table()) { memset(_M_widen, 0, sizeof(_M_widen)); _M_widen_ok = 0; @@ -51,8 +51,8 @@ ctype::ctype(const mask* __table, bool __del, size_t __refs) : facet(__refs), _M_del(__table != 0 && __del), - _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), - _M_table(__table ? __table : __dj_ctype_flags) + _M_toupper(__dj_ctype_toupper + 1), _M_tolower(__dj_ctype_tolower + 1), + _M_table(__table ? __table : classic_table()) { memset(_M_widen, 0, sizeof(_M_widen)); _M_widen_ok = 0; @@ -62,14 +62,14 @@ char ctype::do_toupper(char __c) const - { return _M_toupper[static_cast(__c)+1]; } + { return _M_toupper[static_cast(__c)]; } const char* ctype::do_toupper(char* __low, const char* __high) const { while (__low < __high) { - *__low = ::toupper(static_cast (*__low)); + *__low = _M_toupper[static_cast(*__low)]; ++__low; } return __high; @@ -77,14 +77,14 @@ char ctype::do_tolower(char __c) const - { return _M_tolower[static_cast(__c)+1]; } + { return _M_tolower[static_cast(__c)]; } const char* ctype::do_tolower(char* __low, const char* __high) const { while (__low < __high) { - *__low = ::tolower(static_cast (*__low)); + *__low = _M_tolower[static_cast(*__low)]; ++__low; } return __high;