delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/05/19/19:46:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Carey Evans" <carey DOT evans AT gmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: ctype<char> custom table lookup in C++
Date: 19 May 2005 16:41:32 -0700
Organization: http://groups.google.com
Lines: 29
Message-ID: <1116546092.867392.97940@g43g2000cwa.googlegroups.com>
NNTP-Posting-Host: 210.54.0.162
Mime-Version: 1.0
X-Trace: posting.google.com 1116546098 24614 127.0.0.1 (19 May 2005 23:41:38 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Thu, 19 May 2005 23:41:38 +0000 (UTC)
User-Agent: G2/0.2
Complaints-To: groups-abuse AT google DOT com
Injection-Info: g43g2000cwa.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

I've been trying to write a custom C++ ctype<char> facet to support the
full range of characters in codepage 850, not just ASCII.  However,
I've run across a problem with the ctype<char>::is(mask,char) lookup on
the custom table I pass to the ctype<char> constructor.

The ISO C++ standard says of is(mask m, char c) that:

> The first form returns table()[(unsigned char)c] & m; ...

but with GCC 3.4.3 in DJGPP, it returns (from ctype_inline.h):

> _M_table[static_cast<unsigned char>(__c + 1)] & __m;

which means that all the character classifications in my custom class
are off by one.

On the other hand, the second form of is(const char*,const char*,mask*)
works with my custom table, but not with the ctype<char> from the
standard locale.

The correct solution appears to me to be to remove the "+ 1" from the
is() function, and add it to the ctype<char> constructors in
ctype_noninline.h to do something like:

> _M_table(__table ? __table : __dj_ctype_flags + 1)

-- 
Carey Evans

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019