In article , msternerkthse
wrote:
| The following code on line 841 of c_regex_traits.cpp in the regex
| library caused a crash when I used it in CodeWarrior 8.1 under OSX:
|
| std::string l(std::setlocale(LC_CTYPE, 0));
|
| Afaict the crash was caused by setlocale() returning 0. To fix this I
| had to resort to the following ugly hack:
|
| namespace std
| {
| const char* mysetlocale(int, const char*) { return "C"; }
| };
| #include "boost/regex.hpp"
| #define setlocale mysetlocale
| #include "boost/regex/src.cpp"
Hi Mikael,
We're having trouble duplicating the symptom of
std::setlocale(LC_CTYPE, 0) returning 0 in a small demo. Could you
confirm your CW version number with this:
#include <iostream>
int main()
{
std::cout << std::hex << __MSL_CPP__ << '\n';
}
That spits out the C++ lib version which usually tracks the product
version fairly closely. It may help us to track down your symptoms.
Thanks.
| The C locale was used because I had BOOST_REGEX_USE_C_LOCALE defined.
| I didn't want to use the C++ locale since it doesn't even provide the
| basic 0x00-0xFF unicode case mapping that's built into the C locale
| (due to limited locale support in CW I guess). I'm using the wregex
| class.
Fwiw, this is the behavior the C and C++ standards define. The "C"
locale doesn't map unicode characters. It only maps those characters
in the basic character set, which on Mac OS X translates to the ASCII
values 0x00-0x7F.
The CW 8.1 C++ locale support is actually fairly extensive, with much
unicode support built-in (as an extension to the standard). One can
also set up custom case mappings and/or classifications based on easily
defined locale data files, or programatically taking advantage of
ctype's protected interface. Unfortunately both the locale data files
and the protected interface are also extensions to the standard, so
this would not be portable code. Of course 100% portable code can also
be written to ctype's standard interface, but this is much less
convenient.
If you have any interest in pursueing the customization of locales in
Pro 8.x, please don't hesitate to ask in a CodeWarrior newsgroup or
contact me directly. There is also documentation on these details in
the "online help" that comes with your CodeWarrior.
Thank you for your support.
--
Howard Hinnant
Metrowerks