Ticket #1755: token_functions.diff

File token_functions.diff, 2.3 KB (added by amit@…, 15 years ago)

Patch containing a fix for 1755

Line 
143a44,45
2> #include <ctype.h> // required for wide version of character checkers
3>
450a53,55
5> #ifdef iswpunct
6> # undef iswpunct
7> #endif
853a59,61
9> #ifdef iswspace
10> # undef iswspace
11> #endif
1260a69,70
13> using ::iswpunct;
14> using ::iswspace;
1565d74
16<
17197a207,227
18> //===========================================================================
19> // Tokenizer was broken for wide character separators, at least on Windows, since
20> // CRT functions isspace etc are only expect values in [0, 0xFF]. Debug build asserts
21> // if higher values are passed in. The traits extension class should take care of this.
22> // Assuming that the conditional will always get optimized out in the function
23> // implementations, argument types are not a problem since both forms of character classifiers
24> // expect an int.
25> template<typename traits>
26> struct traits_extension : public traits {
27> using typename traits::char_type;
28>
29> static bool isspace(char_type c)
30> {
31> return sizeof(char_type) == 1 ? std::isspace(c) : std::iswspace(c);
32> }
33>
34> static bool ispunct(char_type c)
35> {
36> return sizeof(char_type) == 1 ? std::ispunct(c) : std::iswpunct(c);
37> }
38> };
39383c413
40< typename Traits = typename std::basic_string<Char>::traits_type >
41---
42> typename Tr = typename std::basic_string<Char>::traits_type >
43386c416
44< typename Traits = std::basic_string<Char>::traits_type >
45---
46> typename Tr = std::basic_string<Char>::traits_type >
47389a420
48> typedef tokenizer_detail::traits_extension<Tr> Traits;
49502c533
50< return std::ispunct(E) != 0;
51---
52> return Traits::ispunct(E) != 0;
53511c542
54< return std::isspace(E) != 0;
55---
56> return Traits::isspace(E) != 0;
57530c561
58< class Traits = typename std::basic_string<Char>::traits_type >
59---
60> class Tr = typename std::basic_string<Char>::traits_type >
61533c564
62< class Traits = std::basic_string<Char>::traits_type >
63---
64> class Tr = std::basic_string<Char>::traits_type >
65537a569
66> typedef tokenizer_detail::traits_extension<Tr> Traits;
67552c584
68< int r = std::ispunct(E);
69---
70> int r = Traits::ispunct(E);
71564c596
72< int r = std::isspace(E);
73---
74> int r = Traits::isspace(E);