This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[libstdc++v3]: Patch to ctype-noninline.h for mingw32
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, libstdc++ at gcc dot gnu dot org
- Cc: mingw-dvlpr <mingw-dvlpr at lists dot sourceforge dot net>
- Date: Fri, 18 Jan 2002 15:26:51 +1100 (EST)
- Subject: [libstdc++v3]: Patch to ctype-noninline.h for mingw32
Mingw32 was left out of recent changes to config/os/<target>/bits,
which was a good thing since beakage forced me to re-examine the
toupper/tolower code.
_pctype points to ctype table for current locale, while _ctype[] is
the classic C-locale table and is the correct choice for default
initialisation.
Attached patch allows C-locale ctype<char> to work correctly on mingw.
ChangeLog
2002-01-17 Danny Smith <dannysmith@users.sourceforge.net>
* config/os/mingw32/bits/ctype_noninline.h: Declare _ctype
instead of _pctype. Use to define _S_ctable.
Add definition for alternate ctor.
Initialise _M_ctable to _S_ctable in ctors.
(do_toupper, do_tolower): Use inline code appropriate for C-locale
rather than ::toupper, ::tolower.
Index: mingw32/bits/ctype_noninline.h
===================================================================
RCS file:
/cvs/gcc/gcc/libstdc++-v3/config/os/mingw32/bits/ctype_noninline.h,v
retrieving revision 1.2
diff -u -p -r1.2 ctype_noninline.h
--- ctype_noninline.h 2002/01/16 19:57:29 1.2
+++ ctype_noninline.h 2002/01/18 01:10:48
@@ -33,26 +33,41 @@
// Information as gleaned from /mingw32/include/ctype.h.
-// This should be in mingw's ctype.h but isn't in older versions
+ // This should be in mingw's ctype.h but isn't in older versions
+ // Static classic C-locale table. _ctype[0] is EOF
+ extern "C" unsigned short __declspec(dllimport) _ctype[];
+
+ // Data for classic_table().
+ const ctype_base::mask* ctype<char>::_S_ctable = _ctype + 1;
- extern "C" unsigned short* __declspec(dllimport) _pctype;
+ ctype<char>::ctype(__c_locale, const mask* __table = 0, bool __del =
false,
+ size_t __refs = 0)
+ : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
+ _M_toupper(NULL), _M_tolower(NULL),
+ _M_table(__table == 0 ? _S_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(NULL), _M_tolower(NULL),
- _M_ctable(NULL), _M_table(__table == 0 ? (_pctype) : __table)
- { }
+ : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
+ _M_toupper(NULL), _M_tolower(NULL),
+ _M_table(__table == 0 ? _S_ctable : __table)
+ { }
+
char
ctype<char>::do_toupper(char __c) const
- { return ::toupper((int) __c); }
+ {
+ return (this->is(ctype_base::lower, __c) ?
+ (__c - 'a' + 'A') : __c);
+ }
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = ::toupper((int) *__low);
+ *__low = this->do_toupper(*__low);
++__low;
}
return __high;
@@ -60,14 +75,17 @@
char
ctype<char>::do_tolower(char __c) const
- { return ::tolower((int) __c); }
+ {
+ return (this->is(ctype_base::upper, __c) ?
+ (__c - 'A' + 'a') : __c);
+ }
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
- *__low = ::tolower((int) *__low);
+ *__low = this->do_tolower(*__low);
++__low;
}
return __high;
http://my.yahoo.com.au - My Yahoo!
- It's My Yahoo! Get your own!