]> git.lyx.org Git - lyx.git/blob - 3rdparty/boost/libs/regex/src/w32_regex_traits.cpp
0f825702477ff981e5e16cf1fa4b38a16486faef
[lyx.git] / 3rdparty / boost / libs / regex / src / w32_regex_traits.cpp
1 /*
2  *
3  * Copyright (c) 2004
4  * John Maddock
5  *
6  * Use, modification and distribution are subject to the 
7  * Boost Software License, Version 1.0. (See accompanying file 
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11  
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         w32_regex_traits.cpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Implements w32_regex_traits<char> (and associated helper classes).
17   */
18
19 #define BOOST_REGEX_SOURCE
20 #include <boost/regex/config.hpp>
21
22 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_NO_WIN32_LOCALE)
23 #include <boost/regex/regex_traits.hpp>
24 #include <boost/regex/pattern_except.hpp>
25
26 #define WIN32_LEAN_AND_MEAN
27 #ifndef NOMINMAX
28 #  define NOMINMAX
29 #endif
30 #define NOGDI
31 #include <windows.h>
32
33 #if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
34 #pragma comment(lib, "user32.lib")
35 #endif
36
37 #ifdef BOOST_NO_STDC_NAMESPACE
38 namespace std{
39    using ::memset;
40 }
41 #endif
42
43 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
44
45 #ifdef BOOST_NO_ANSI_APIS
46 UINT get_code_page_for_locale_id(lcid_type idx)
47 {
48    WCHAR code_page_string[7];
49    if (::GetLocaleInfoW(idx, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0)
50        return 0;
51
52    return static_cast<UINT>(_wtol(code_page_string));
53 }
54 #endif
55
56
57 void w32_regex_traits_char_layer<char>::init() 
58 {
59    // we need to start by initialising our syntax map so we know which
60    // character is used for which purpose:
61    std::memset(m_char_map, 0, sizeof(m_char_map));
62    cat_type cat;
63    std::string cat_name(w32_regex_traits<char>::get_catalog_name());
64    if(cat_name.size())
65    {
66       cat = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_open(cat_name);
67       if(!cat)
68       {
69          std::string m("Unable to open message catalog: ");
70          std::runtime_error err(m + cat_name);
71          ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
72       }
73    }
74    //
75    // if we have a valid catalog then load our messages:
76    //
77    if(cat)
78    {
79       for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
80       {
81          string_type mss = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, i, get_default_syntax(i));
82          for(string_type::size_type j = 0; j < mss.size(); ++j)
83          {
84             m_char_map[static_cast<unsigned char>(mss[j])] = i;
85          }
86       }
87    }
88    else
89    {
90       for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
91       {
92          const char* ptr = get_default_syntax(i);
93          while(ptr && *ptr)
94          {
95             m_char_map[static_cast<unsigned char>(*ptr)] = i;
96             ++ptr;
97          }
98       }
99    }
100    //
101    // finish off by calculating our escape types:
102    //
103    unsigned char i = 'A';
104    do
105    {
106       if(m_char_map[i] == 0)
107       {
108          if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0002u, (char)i)) 
109             m_char_map[i] = regex_constants::escape_type_class;
110          else if(::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0001u, (char)i)) 
111             m_char_map[i] = regex_constants::escape_type_not_class;
112       }
113    }while(0xFF != i++);
114
115    //
116    // fill in lower case map:
117    //
118    char char_map[1 << CHAR_BIT];
119    for(int ii = 0; ii < (1 << CHAR_BIT); ++ii)
120       char_map[ii] = static_cast<char>(ii);
121 #ifndef BOOST_NO_ANSI_APIS
122    int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT);
123    BOOST_ASSERT(r != 0);
124 #else
125    UINT code_page = get_code_page_for_locale_id(this->m_locale);
126    BOOST_ASSERT(code_page != 0);
127
128    WCHAR wide_char_map[1 << CHAR_BIT];
129    int conv_r = ::MultiByteToWideChar(code_page, 0,  char_map, 1 << CHAR_BIT,  wide_char_map, 1 << CHAR_BIT);
130    BOOST_ASSERT(conv_r != 0);
131
132    WCHAR wide_lower_map[1 << CHAR_BIT];
133    int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE,  wide_char_map, 1 << CHAR_BIT,  wide_lower_map, 1 << CHAR_BIT);
134    BOOST_ASSERT(r != 0);
135
136    conv_r = ::WideCharToMultiByte(code_page, 0,  wide_lower_map, r,  this->m_lower_map, 1 << CHAR_BIT,  NULL, NULL);
137    BOOST_ASSERT(conv_r != 0);
138 #endif
139    if(r < (1 << CHAR_BIT))
140    {
141       // if we have multibyte characters then not all may have been given
142       // a lower case mapping:
143       for(int jj = r; jj < (1 << CHAR_BIT); ++jj)
144          this->m_lower_map[jj] = static_cast<char>(jj);
145    }
146
147 #ifndef BOOST_NO_ANSI_APIS
148    r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map);
149 #else
150    r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map);
151 #endif
152    BOOST_ASSERT(0 != r);
153 }
154
155 BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale()
156 {
157    return ::GetUserDefaultLCID();
158 }
159
160 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx)
161 {
162 #ifndef BOOST_NO_ANSI_APIS
163    WORD mask;
164    if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
165       return true;
166    return false;
167 #else
168    UINT code_page = get_code_page_for_locale_id(idx);
169    if (code_page == 0)
170        return false;
171
172    WCHAR wide_c;
173    if (::MultiByteToWideChar(code_page, 0,  &c, 1,  &wide_c, 1) == 0)
174        return false;
175
176    WORD mask;
177    if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
178       return true;
179    return false;
180 #endif
181 }
182
183 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type idx)
184 {
185    WORD mask;
186    if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
187       return true;
188    return false;
189 }
190 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
191 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type idx)
192 {
193    WORD mask;
194    wchar_t c = ca;
195    if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
196       return true;
197    return false;
198 }
199 #endif
200
201 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx)
202 {
203 #ifndef BOOST_NO_ANSI_APIS
204    WORD mask;
205    if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
206       return true;
207    return false;
208 #else
209    UINT code_page = get_code_page_for_locale_id(idx);
210    if (code_page == 0)
211        return false;
212
213    WCHAR wide_c;
214    if (::MultiByteToWideChar(code_page, 0,  &c, 1,  &wide_c, 1) == 0)
215        return false;
216
217    WORD mask;
218    if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
219       return true;
220    return false;
221 #endif
222 }
223
224 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type idx)
225 {
226    WORD mask;
227    if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
228       return true;
229    return false;
230 }
231 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
232 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type idx)
233 {
234    WORD mask;
235    wchar_t c = ca;
236    if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
237       return true;
238    return false;
239 }
240 #endif
241
242 void free_module(void* mod)
243 {
244    ::FreeLibrary(static_cast<HMODULE>(mod));
245 }
246
247 BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name)
248 {
249 #ifndef BOOST_NO_ANSI_APIS
250    cat_type result(::LoadLibraryA(name.c_str()), &free_module);
251    return result;
252 #else
253    LPWSTR wide_name = (LPWSTR)_alloca( (name.size() + 1) * sizeof(WCHAR) );
254    if (::MultiByteToWideChar(CP_ACP, 0,  name.c_str(), name.size(),  wide_name, name.size() + 1) == 0)
255        return cat_type();
256
257    cat_type result(::LoadLibraryW(wide_name), &free_module);
258    return result;
259 #endif
260 }
261
262 BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def)
263 {
264 #ifndef BOOST_NO_ANSI_APIS
265    char buf[256];
266    if(0 == ::LoadStringA(
267       static_cast<HMODULE>(cat.get()),
268       i,
269       buf,
270       256
271    ))
272    {
273       return def;
274    }
275 #else
276    WCHAR wbuf[256];
277    int r = ::LoadStringW(
278       static_cast<HMODULE>(cat.get()),
279       i,
280       wbuf,
281       256
282    );
283    if (r == 0)
284       return def;
285
286
287    int buf_size = 1 + ::WideCharToMultiByte(CP_ACP, 0,  wbuf, r,  NULL, 0,  NULL, NULL);
288    LPSTR buf = (LPSTR)_alloca(buf_size);
289    if (::WideCharToMultiByte(CP_ACP, 0,  wbuf, r,  buf, buf_size,  NULL, NULL) == 0)
290       return def; // failed conversion.
291 #endif
292    return std::string(buf);
293 }
294
295 #ifndef BOOST_NO_WREGEX
296 BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def)
297 {
298    wchar_t buf[256];
299    if(0 == ::LoadStringW(
300       static_cast<HMODULE>(cat.get()),
301       i,
302       buf,
303       256
304    ))
305    {
306       return def;
307    }
308    return std::wstring(buf);
309 }
310 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
311 BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string<unsigned short>& def)
312 {
313    unsigned short buf[256];
314    if(0 == ::LoadStringW(
315       static_cast<HMODULE>(cat.get()),
316       i,
317       (LPWSTR)buf,
318       256
319    ))
320    {
321       return def;
322    }
323    return std::basic_string<unsigned short>(buf);
324 }
325 #endif
326 #endif
327 BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2)
328 {
329 #ifndef BOOST_NO_ANSI_APIS
330    int bytes = ::LCMapStringA(
331       idx,       // locale identifier
332       LCMAP_SORTKEY,  // mapping transformation type
333       p1,  // source string
334       static_cast<int>(p2 - p1),        // number of characters in source string
335       0,  // destination buffer
336       0        // size of destination buffer
337       );
338    if(!bytes)
339       return std::string(p1, p2);
340    std::string result(++bytes, '\0');
341    bytes = ::LCMapStringA(
342       idx,       // locale identifier
343       LCMAP_SORTKEY,  // mapping transformation type
344       p1,  // source string
345       static_cast<int>(p2 - p1),        // number of characters in source string
346       &*result.begin(),  // destination buffer
347       bytes        // size of destination buffer
348       );
349 #else
350    UINT code_page = get_code_page_for_locale_id(idx);
351    if(code_page == 0)
352       return std::string(p1, p2);
353
354    int src_len = static_cast<int>(p2 - p1);
355    LPWSTR wide_p1 = (LPWSTR)_alloca( (src_len + 1) * 2 );
356    if(::MultiByteToWideChar(code_page, 0,  p1, src_len,  wide_p1, src_len + 1) == 0)
357       return std::string(p1, p2);
358
359    int bytes = ::LCMapStringW(
360       idx,       // locale identifier
361       LCMAP_SORTKEY,  // mapping transformation type
362       wide_p1,  // source string
363       src_len,        // number of characters in source string
364       0,  // destination buffer
365       0        // size of destination buffer
366       );
367    if(!bytes)
368       return std::string(p1, p2);
369    std::string result(++bytes, '\0');
370    bytes = ::LCMapStringW(
371       idx,       // locale identifier
372       LCMAP_SORTKEY,  // mapping transformation type
373       wide_p1,  // source string
374       src_len,        // number of characters in source string
375       (LPWSTR)&*result.begin(),  // destination buffer
376       bytes        // size of destination buffer
377       );
378 #endif
379    if(bytes > static_cast<int>(result.size()))
380       return std::string(p1, p2);
381    while(result.size() && result[result.size()-1] == '\0')
382    {
383       result.erase(result.size()-1);
384    }
385    return result;
386 }
387
388 #ifndef BOOST_NO_WREGEX
389 BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2)
390 {
391    int bytes = ::LCMapStringW(
392       idx,       // locale identifier
393       LCMAP_SORTKEY,  // mapping transformation type
394       p1,  // source string
395       static_cast<int>(p2 - p1),        // number of characters in source string
396       0,  // destination buffer
397       0        // size of destination buffer
398       );
399    if(!bytes)
400       return std::wstring(p1, p2);
401    std::string result(++bytes, '\0');
402    bytes = ::LCMapStringW(
403       idx,       // locale identifier
404       LCMAP_SORTKEY,  // mapping transformation type
405       p1,  // source string
406       static_cast<int>(p2 - p1),        // number of characters in source string
407       reinterpret_cast<wchar_t*>(&*result.begin()),  // destination buffer *of bytes*
408       bytes        // size of destination buffer
409       );
410    if(bytes > static_cast<int>(result.size()))
411       return std::wstring(p1, p2);
412    while(result.size() && result[result.size()-1] == L'\0')
413    {
414       result.erase(result.size()-1);
415    }
416    std::wstring r2;
417    for(std::string::size_type i = 0; i < result.size(); ++i)
418       r2.append(1, static_cast<wchar_t>(static_cast<unsigned char>(result[i])));
419    return r2;
420 }
421 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
422 BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type idx, const unsigned short* p1, const unsigned short* p2)
423 {
424    int bytes = ::LCMapStringW(
425       idx,       // locale identifier
426       LCMAP_SORTKEY,  // mapping transformation type
427       (LPCWSTR)p1,  // source string
428       static_cast<int>(p2 - p1),        // number of characters in source string
429       0,  // destination buffer
430       0        // size of destination buffer
431       );
432    if(!bytes)
433       return std::basic_string<unsigned short>(p1, p2);
434    std::string result(++bytes, '\0');
435    bytes = ::LCMapStringW(
436       idx,       // locale identifier
437       LCMAP_SORTKEY,  // mapping transformation type
438       (LPCWSTR)p1,  // source string
439       static_cast<int>(p2 - p1),        // number of characters in source string
440       reinterpret_cast<wchar_t*>(&*result.begin()),  // destination buffer *of bytes*
441       bytes        // size of destination buffer
442       );
443    if(bytes > static_cast<int>(result.size()))
444       return std::basic_string<unsigned short>(p1, p2);
445    while(result.size() && result[result.size()-1] == L'\0')
446    {
447       result.erase(result.size()-1);
448    }
449    std::basic_string<unsigned short> r2;
450    for(std::string::size_type i = 0; i < result.size(); ++i)
451       r2.append(1, static_cast<unsigned short>(static_cast<unsigned char>(result[i])));
452    return r2;
453 }
454 #endif
455 #endif
456 BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx)
457 {
458    char result[2];
459 #ifndef BOOST_NO_ANSI_APIS
460    int b = ::LCMapStringA(
461       idx,       // locale identifier
462       LCMAP_LOWERCASE,  // mapping transformation type
463       &c,  // source string
464       1,        // number of characters in source string
465       result,  // destination buffer
466       1);        // size of destination buffer
467    if(b == 0)
468       return c;
469 #else
470    UINT code_page = get_code_page_for_locale_id(idx);
471    if (code_page == 0)
472       return c;
473
474    WCHAR wide_c;
475    if (::MultiByteToWideChar(code_page, 0,  &c, 1,  &wide_c, 1) == 0)
476       return c;
477
478    WCHAR wide_result;
479    int b = ::LCMapStringW(
480       idx,       // locale identifier
481       LCMAP_LOWERCASE,  // mapping transformation type
482       &wide_c,  // source string
483       1,        // number of characters in source string
484       &wide_result,  // destination buffer
485       1);        // size of destination buffer
486    if(b == 0)
487       return c;
488
489    if (::WideCharToMultiByte(code_page, 0,  &wide_result, 1,  result, 2,  NULL, NULL) == 0)
490        return c;  // No single byte lower case equivalent available
491 #endif
492    return result[0];
493 }
494
495 #ifndef BOOST_NO_WREGEX
496 BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx)
497 {
498    wchar_t result[2];
499    int b = ::LCMapStringW(
500       idx,       // locale identifier
501       LCMAP_LOWERCASE,  // mapping transformation type
502       &c,  // source string
503       1,        // number of characters in source string
504       result,  // destination buffer
505       1);        // size of destination buffer
506    if(b == 0)
507       return c;
508    return result[0];
509 }
510 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
511 BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type idx)
512 {
513    wchar_t result[2];
514    int b = ::LCMapStringW(
515       idx,       // locale identifier
516       LCMAP_LOWERCASE,  // mapping transformation type
517       (wchar_t const*)&c,  // source string
518       1,        // number of characters in source string
519       result,  // destination buffer
520       1);        // size of destination buffer
521    if(b == 0)
522       return c;
523    return result[0];
524 }
525 #endif
526 #endif
527 BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx)
528 {
529    char result[2];
530 #ifndef BOOST_NO_ANSI_APIS
531    int b = ::LCMapStringA(
532       idx,       // locale identifier
533       LCMAP_UPPERCASE,  // mapping transformation type
534       &c,  // source string
535       1,        // number of characters in source string
536       result,  // destination buffer
537       1);        // size of destination buffer
538    if(b == 0)
539       return c;
540 #else
541    UINT code_page = get_code_page_for_locale_id(idx);
542    if(code_page == 0)
543        return c;
544
545    WCHAR wide_c;
546    if (::MultiByteToWideChar(code_page, 0,  &c, 1,  &wide_c, 1) == 0)
547        return c;
548
549    WCHAR wide_result;
550    int b = ::LCMapStringW(
551       idx,       // locale identifier
552       LCMAP_UPPERCASE,  // mapping transformation type
553       &wide_c,  // source string
554       1,        // number of characters in source string
555       &wide_result,  // destination buffer
556       1);        // size of destination buffer
557    if(b == 0)
558       return c;
559
560    if (::WideCharToMultiByte(code_page, 0,  &wide_result, 1,  result, 2,  NULL, NULL) == 0)
561        return c;  // No single byte upper case equivalent available.
562 #endif
563    return result[0];
564 }
565
566 #ifndef BOOST_NO_WREGEX
567 BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx)
568 {
569    wchar_t result[2];
570    int b = ::LCMapStringW(
571       idx,       // locale identifier
572       LCMAP_UPPERCASE,  // mapping transformation type
573       &c,  // source string
574       1,        // number of characters in source string
575       result,  // destination buffer
576       1);        // size of destination buffer
577    if(b == 0)
578       return c;
579    return result[0];
580 }
581 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
582 BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type idx)
583 {
584    wchar_t result[2];
585    int b = ::LCMapStringW(
586       idx,       // locale identifier
587       LCMAP_UPPERCASE,  // mapping transformation type
588       (wchar_t const*)&c,  // source string
589       1,        // number of characters in source string
590       result,  // destination buffer
591       1);        // size of destination buffer
592    if(b == 0)
593       return c;
594    return result[0];
595 }
596 #endif
597 #endif
598 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c)
599 {
600    WORD mask;
601 #ifndef BOOST_NO_ANSI_APIS
602    if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
603       return true;
604 #else
605    UINT code_page = get_code_page_for_locale_id(idx);
606    if(code_page == 0)
607        return false;
608
609    WCHAR wide_c;
610    if (::MultiByteToWideChar(code_page, 0,  &c, 1,  &wide_c, 1) == 0)
611        return false;
612
613    if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
614       return true;
615 #endif
616    if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_'))
617       return true;
618    return false;
619 }
620
621 #ifndef BOOST_NO_WREGEX
622 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, wchar_t c)
623 {
624    WORD mask;
625    if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
626       return true;
627    if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
628       return true;
629    if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff))
630       return true;
631    return false;
632 }
633 #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
634 BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, unsigned short c)
635 {
636    WORD mask;
637    if(::GetStringTypeExW(idx, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
638       return true;
639    if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
640       return true;
641    if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff))
642       return true;
643    return false;
644 }
645 #endif
646 #endif
647
648 } // BOOST_REGEX_DETAIL_NS
649 } // boost
650
651 #endif
652