test_bug_11988.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. *
  3. * Copyright (c) 2016
  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. #include <boost/config.hpp>
  12. #ifndef BOOST_NO_CXX11_CHAR32_T
  13. #include <cstddef>
  14. namespace boost {
  15. std::size_t hash_value(char32_t const& c) { return c; }
  16. }
  17. #include <boost/regex.hpp>
  18. struct char32_traits
  19. {
  20. typedef char32_t char_type;
  21. typedef std::size_t size_type;
  22. typedef std::vector<char32_t> string_type;
  23. typedef int locale_type; // not used
  24. typedef unsigned char_class_type;
  25. static size_type length(const char32_t* p)
  26. {
  27. size_type result = 0;
  28. while(*p)
  29. {
  30. ++p;
  31. ++result;
  32. }
  33. return result;
  34. }
  35. static char_type translate(char_type c) { return c; }
  36. static char_type translate_nocase(char_type c) { return c; }
  37. static string_type transform(const char32_t* p1, const char32_t* p2)
  38. {
  39. return string_type(p1, p2);
  40. }
  41. static string_type transform_primary(const char32_t* p1, const char32_t* p2)
  42. {
  43. return string_type(p1, p2);
  44. }
  45. static char_class_type lookup_classname(const char32_t* p1, const char32_t* p2)
  46. {
  47. std::string s(p1, p2);
  48. return boost::c_regex_traits<char>::lookup_classname(s.c_str(), s.c_str() + s.length());
  49. return 0;
  50. }
  51. static string_type lookup_collatename(const char32_t* p1, const char32_t* p2)
  52. {
  53. return string_type(p1, p2);
  54. }
  55. static bool isctype(char_type c, char_class_type t)
  56. {
  57. if(c < 0xff)
  58. return boost::c_regex_traits<char>::isctype(c, t);
  59. return false;
  60. }
  61. static boost::intmax_t value(char_type c, int radix)
  62. {
  63. switch(radix)
  64. {
  65. case 8:
  66. if((c >= '0') && (c <= '7'))
  67. return c - '0';
  68. break;
  69. case 10:
  70. if((c >= '0') && (c <= '9'))
  71. return c - '0';
  72. break;
  73. case 16:
  74. if((c >= '0') && (c <= '9'))
  75. return c - '0';
  76. if((c >= 'a') && (c <= 'f'))
  77. return (c - 'a') + 10;
  78. if((c >= 'A') && (c <= 'F'))
  79. return (c - 'A') + 10;
  80. break;
  81. }
  82. return -1;
  83. }
  84. static locale_type imbue(locale_type) { return 0; }
  85. static locale_type getloc() { return 0; }
  86. };
  87. int main()
  88. {
  89. char32_t big_char[] = { 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFFFF, 0 };
  90. boost::basic_regex<char32_t, char32_traits> e(U"\\x{F}\\x{FF}\\x{FFF}\\x{FFFF}\\x{FFFFF}\\x{FFFFFF}\\x{FFFFFFF}\\x{FFFFFFFF}");
  91. if(!regex_match(big_char, e))
  92. {
  93. return 1;
  94. }
  95. return 0;
  96. }
  97. #else
  98. int main() { return 0; }
  99. #endif