passenger 4.0.27 → 4.0.28

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (156) hide show
  1. data.tar.gz.asc +7 -7
  2. data/.gitignore +1 -0
  3. data/NEWS +22 -0
  4. data/build/preprocessor.rb +10 -0
  5. data/build/rpm.rb +74 -65
  6. data/debian.template/rules.template +8 -0
  7. data/dev/copy_boost_headers.rb +11 -2
  8. data/doc/Users guide Apache.idmap.txt +161 -145
  9. data/doc/Users guide Apache.txt +12 -1
  10. data/doc/Users guide Nginx.idmap.txt +142 -126
  11. data/doc/Users guide Nginx.txt +14 -1
  12. data/doc/Users guide Standalone.txt +1 -0
  13. data/doc/users_guide_snippets/environment_variables.txt +1 -1
  14. data/doc/users_guide_snippets/installation.txt +2 -0
  15. data/doc/users_guide_snippets/tips.txt +118 -0
  16. data/ext/apache2/Configuration.cpp +0 -6
  17. data/ext/apache2/Configuration.hpp +0 -5
  18. data/ext/apache2/ConfigurationCommands.cpp +7 -0
  19. data/ext/apache2/ConfigurationFields.hpp +2 -0
  20. data/ext/apache2/ConfigurationSetters.cpp +24 -0
  21. data/ext/apache2/CreateDirConfig.cpp +1 -0
  22. data/ext/apache2/Hooks.cpp +0 -1
  23. data/ext/apache2/MergeDirConfig.cpp +7 -0
  24. data/ext/apache2/SetHeaders.cpp +5 -1
  25. data/ext/boost/cregex.hpp +39 -0
  26. data/ext/boost/libs/regex/src/c_regex_traits.cpp +193 -0
  27. data/ext/boost/libs/regex/src/cpp_regex_traits.cpp +117 -0
  28. data/ext/boost/libs/regex/src/cregex.cpp +660 -0
  29. data/ext/boost/libs/regex/src/instances.cpp +32 -0
  30. data/ext/boost/libs/regex/src/internals.hpp +35 -0
  31. data/ext/boost/libs/regex/src/posix_api.cpp +296 -0
  32. data/ext/boost/libs/regex/src/regex.cpp +227 -0
  33. data/ext/boost/libs/regex/src/regex_debug.cpp +59 -0
  34. data/ext/boost/libs/regex/src/regex_raw_buffer.cpp +72 -0
  35. data/ext/boost/libs/regex/src/regex_traits_defaults.cpp +692 -0
  36. data/ext/boost/libs/regex/src/static_mutex.cpp +179 -0
  37. data/ext/boost/libs/regex/src/wc_regex_traits.cpp +301 -0
  38. data/ext/boost/libs/regex/src/wide_posix_api.cpp +315 -0
  39. data/ext/boost/libs/regex/src/winstances.cpp +35 -0
  40. data/ext/boost/regex.h +100 -0
  41. data/ext/boost/regex.hpp +37 -0
  42. data/ext/boost/regex/concepts.hpp +1128 -0
  43. data/ext/boost/regex/config.hpp +435 -0
  44. data/ext/boost/regex/config/borland.hpp +72 -0
  45. data/ext/boost/regex/config/cwchar.hpp +207 -0
  46. data/ext/boost/regex/mfc.hpp +190 -0
  47. data/ext/boost/regex/pattern_except.hpp +100 -0
  48. data/ext/boost/regex/pending/object_cache.hpp +165 -0
  49. data/ext/boost/regex/pending/static_mutex.hpp +179 -0
  50. data/ext/boost/regex/pending/unicode_iterator.hpp +776 -0
  51. data/ext/boost/regex/regex_traits.hpp +35 -0
  52. data/ext/boost/regex/user.hpp +93 -0
  53. data/ext/boost/regex/v4/basic_regex.hpp +782 -0
  54. data/ext/boost/regex/v4/basic_regex_creator.hpp +1571 -0
  55. data/ext/boost/regex/v4/basic_regex_parser.hpp +2874 -0
  56. data/ext/boost/regex/v4/c_regex_traits.hpp +211 -0
  57. data/ext/boost/regex/v4/char_regex_traits.hpp +81 -0
  58. data/ext/boost/regex/v4/cpp_regex_traits.hpp +1099 -0
  59. data/ext/boost/regex/v4/cregex.hpp +330 -0
  60. data/ext/boost/regex/v4/error_type.hpp +59 -0
  61. data/ext/boost/regex/v4/fileiter.hpp +455 -0
  62. data/ext/boost/regex/v4/instances.hpp +222 -0
  63. data/ext/boost/regex/v4/iterator_category.hpp +91 -0
  64. data/ext/boost/regex/v4/iterator_traits.hpp +135 -0
  65. data/ext/boost/regex/v4/match_flags.hpp +138 -0
  66. data/ext/boost/regex/v4/match_results.hpp +702 -0
  67. data/ext/boost/regex/v4/mem_block_cache.hpp +99 -0
  68. data/ext/boost/regex/v4/perl_matcher.hpp +587 -0
  69. data/ext/boost/regex/v4/perl_matcher_common.hpp +996 -0
  70. data/ext/boost/regex/v4/perl_matcher_non_recursive.hpp +1642 -0
  71. data/ext/boost/regex/v4/perl_matcher_recursive.hpp +991 -0
  72. data/ext/boost/regex/v4/primary_transform.hpp +146 -0
  73. data/ext/boost/regex/v4/protected_call.hpp +81 -0
  74. data/ext/boost/regex/v4/regbase.hpp +180 -0
  75. data/ext/boost/regex/v4/regex.hpp +202 -0
  76. data/ext/boost/regex/v4/regex_format.hpp +1156 -0
  77. data/ext/boost/regex/v4/regex_fwd.hpp +73 -0
  78. data/ext/boost/regex/v4/regex_grep.hpp +155 -0
  79. data/ext/boost/regex/v4/regex_iterator.hpp +201 -0
  80. data/ext/boost/regex/v4/regex_match.hpp +382 -0
  81. data/ext/boost/regex/v4/regex_merge.hpp +93 -0
  82. data/ext/boost/regex/v4/regex_raw_buffer.hpp +210 -0
  83. data/ext/boost/regex/v4/regex_replace.hpp +99 -0
  84. data/ext/boost/regex/v4/regex_search.hpp +217 -0
  85. data/ext/boost/regex/v4/regex_split.hpp +172 -0
  86. data/ext/boost/regex/v4/regex_token_iterator.hpp +342 -0
  87. data/ext/boost/regex/v4/regex_traits.hpp +189 -0
  88. data/ext/boost/regex/v4/regex_traits_defaults.hpp +371 -0
  89. data/ext/boost/regex/v4/regex_workaround.hpp +232 -0
  90. data/ext/boost/regex/v4/states.hpp +301 -0
  91. data/ext/boost/regex/v4/sub_match.hpp +512 -0
  92. data/ext/boost/regex/v4/syntax_type.hpp +105 -0
  93. data/ext/boost/regex/v4/u32regex_iterator.hpp +193 -0
  94. data/ext/boost/regex/v4/u32regex_token_iterator.hpp +377 -0
  95. data/ext/boost/regex/v4/w32_regex_traits.hpp +741 -0
  96. data/ext/boost/regex_fwd.hpp +33 -0
  97. data/ext/common/AgentsStarter.h +0 -11
  98. data/ext/common/ApplicationPool2/Common.h +1 -7
  99. data/ext/common/ApplicationPool2/DirectSpawner.h +3 -3
  100. data/ext/common/ApplicationPool2/Group.h +166 -69
  101. data/ext/common/ApplicationPool2/Implementation.cpp +55 -10
  102. data/ext/common/ApplicationPool2/Options.h +45 -10
  103. data/ext/common/ApplicationPool2/PipeWatcher.h +1 -2
  104. data/ext/common/ApplicationPool2/Pool.h +29 -7
  105. data/ext/common/ApplicationPool2/Process.h +22 -3
  106. data/ext/common/ApplicationPool2/Session.h +1 -0
  107. data/ext/common/ApplicationPool2/SmartSpawner.h +5 -10
  108. data/ext/common/ApplicationPool2/Spawner.h +10 -15
  109. data/ext/common/ApplicationPool2/SuperGroup.h +10 -9
  110. data/ext/common/Constants.h +1 -3
  111. data/ext/common/Hooks.h +193 -0
  112. data/ext/common/Logging.cpp +67 -2
  113. data/ext/common/Logging.h +23 -1
  114. data/ext/common/Utils.cpp +0 -21
  115. data/ext/common/Utils.h +0 -42
  116. data/ext/common/Utils/CachedFileStat.hpp +1 -1
  117. data/ext/common/Utils/StrIntUtils.h +61 -14
  118. data/ext/common/Utils/StringMap.h +4 -0
  119. data/ext/common/agents/HelperAgent/AgentOptions.h +4 -4
  120. data/ext/common/agents/HelperAgent/Main.cpp +2 -3
  121. data/ext/common/agents/HelperAgent/RequestHandler.h +65 -2
  122. data/ext/common/agents/LoggingAgent/FilterSupport.h +3 -1
  123. data/ext/common/agents/Watchdog/Main.cpp +8 -72
  124. data/ext/nginx/CacheLocationConfig.c +29 -1
  125. data/ext/nginx/Configuration.c +0 -12
  126. data/ext/nginx/Configuration.h +0 -1
  127. data/ext/nginx/ConfigurationCommands.c +10 -0
  128. data/ext/nginx/ConfigurationFields.h +2 -0
  129. data/ext/nginx/CreateLocationConfig.c +4 -0
  130. data/ext/nginx/MergeLocationConfig.c +6 -0
  131. data/ext/oxt/system_calls.cpp +7 -1
  132. data/ext/oxt/system_calls.hpp +7 -7
  133. data/helper-scripts/node-loader.js +6 -2
  134. data/helper-scripts/rack-loader.rb +5 -2
  135. data/helper-scripts/rack-preloader.rb +5 -2
  136. data/lib/phusion_passenger.rb +1 -1
  137. data/lib/phusion_passenger/apache2/config_options.rb +8 -0
  138. data/lib/phusion_passenger/constants.rb +0 -1
  139. data/lib/phusion_passenger/nginx/config_options.rb +9 -2
  140. data/lib/phusion_passenger/platform_info/apache.rb +2 -1
  141. data/lib/phusion_passenger/platform_info/compiler.rb +15 -1
  142. data/lib/phusion_passenger/platform_info/cxx_portability.rb +2 -0
  143. data/node_lib/phusion_passenger/httplib_emulation.js +85 -17
  144. data/node_lib/phusion_passenger/request_handler.js +10 -2
  145. data/rpm/Vagrantfile +32 -0
  146. data/rpm/get_distro_id.py +4 -0
  147. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +2 -2
  148. data/test/cxx/ApplicationPool2/PoolTest.cpp +60 -9
  149. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +2 -6
  150. data/test/cxx/CachedFileStatTest.cpp +5 -5
  151. data/test/cxx/RequestHandlerTest.cpp +3 -6
  152. data/test/cxx/UtilsTest.cpp +30 -0
  153. data/test/node/httplib_emulation_spec.js +491 -0
  154. data/test/node/spec_helper.js +25 -0
  155. metadata +78 -2
  156. metadata.gz.asc +7 -7
@@ -0,0 +1,35 @@
1
+ /*
2
+ *
3
+ * Copyright (c) 1998-2002
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 regex_traits.hpp
15
+ * VERSION see <boost/version.hpp>
16
+ * DESCRIPTION: Declares regular expression traits classes.
17
+ */
18
+
19
+ #ifndef BOOST_REGEX_TRAITS_HPP
20
+ #define BOOST_REGEX_TRAITS_HPP
21
+
22
+ #ifndef BOOST_REGEX_CONFIG_HPP
23
+ # include <boost/regex/config.hpp>
24
+ #endif
25
+
26
+ # ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED
27
+ # include <boost/regex/v4/regex_traits.hpp>
28
+ # endif
29
+
30
+ #endif // include
31
+
32
+
33
+
34
+
35
+
@@ -0,0 +1,93 @@
1
+ /*
2
+ *
3
+ * Copyright (c) 1998-2002
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 user.hpp
15
+ * VERSION see <boost/version.hpp>
16
+ * DESCRIPTION: User settable options.
17
+ */
18
+
19
+ // define if you want the regex library to use the C locale
20
+ // even on Win32:
21
+ // #define BOOST_REGEX_USE_C_LOCALE
22
+
23
+ // define this is you want the regex library to use the C++
24
+ // locale:
25
+ // #define BOOST_REGEX_USE_CPP_LOCALE
26
+
27
+ // define this if the runtime library is a dll, and you
28
+ // want BOOST_REGEX_DYN_LINK to set up dll exports/imports
29
+ // with __declspec(dllexport)/__declspec(dllimport.)
30
+ // #define BOOST_REGEX_HAS_DLL_RUNTIME
31
+
32
+ // define this if you want to dynamically link to regex,
33
+ // if the runtime library is also a dll (Probably Win32 specific,
34
+ // and has no effect unless BOOST_REGEX_HAS_DLL_RUNTIME is set):
35
+ // #define BOOST_REGEX_DYN_LINK
36
+
37
+ // define this if you don't want the lib to automatically
38
+ // select its link libraries:
39
+ // #define BOOST_REGEX_NO_LIB
40
+
41
+ // define this if templates with switch statements cause problems:
42
+ // #define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
43
+
44
+ // define this to disable Win32 support when available:
45
+ // #define BOOST_REGEX_NO_W32
46
+
47
+ // define this if bool is not a real type:
48
+ // #define BOOST_REGEX_NO_BOOL
49
+
50
+ // define this if no template instances are to be placed in
51
+ // the library rather than users object files:
52
+ // #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
53
+
54
+ // define this if the forward declarations in regex_fwd.hpp
55
+ // cause more problems than they are worth:
56
+ // #define BOOST_REGEX_NO_FWD
57
+
58
+ // define this if your compiler supports MS Windows structured
59
+ // exception handling.
60
+ // #define BOOST_REGEX_HAS_MS_STACK_GUARD
61
+
62
+ // define this if you want to use the recursive algorithm
63
+ // even if BOOST_REGEX_HAS_MS_STACK_GUARD is not defined.
64
+ // #define BOOST_REGEX_RECURSIVE
65
+
66
+ // define this if you want to use the non-recursive
67
+ // algorithm, even if the recursive version would be the default.
68
+ // #define BOOST_REGEX_NON_RECURSIVE
69
+
70
+ // define this if you want to set the size of the memory blocks
71
+ // used by the non-recursive algorithm.
72
+ // #define BOOST_REGEX_BLOCKSIZE 4096
73
+
74
+ // define this if you want to set the maximum number of memory blocks
75
+ // used by the non-recursive algorithm.
76
+ // #define BOOST_REGEX_MAX_BLOCKS 1024
77
+
78
+ // define this if you want to set the maximum number of memory blocks
79
+ // cached by the non-recursive algorithm: Normally this is 16, but can be
80
+ // higher if you have multiple threads all using boost.regex, or lower
81
+ // if you don't want boost.regex to cache memory.
82
+ // #define BOOST_REGEX_MAX_CACHE_BLOCKS 16
83
+
84
+ // define this if you want to be able to access extended capture
85
+ // information in your sub_match's (caution this will slow things
86
+ // down quite a bit).
87
+ // #define BOOST_REGEX_MATCH_EXTRA
88
+
89
+ // define this if you want to enable support for Unicode via ICU.
90
+ // #define BOOST_HAS_ICU
91
+
92
+ // define this if you want regex to use __cdecl calling convensions, even when __fastcall is available:
93
+ // #define BOOST_REGEX_NO_FASTCALL
@@ -0,0 +1,782 @@
1
+ /*
2
+ *
3
+ * Copyright (c) 1998-2004 John Maddock
4
+ * Copyright 2011 Garmin Ltd. or its subsidiaries
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * 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 basic_regex.cpp
15
+ * VERSION see <boost/version.hpp>
16
+ * DESCRIPTION: Declares template class basic_regex.
17
+ */
18
+
19
+ #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP
20
+ #define BOOST_REGEX_V4_BASIC_REGEX_HPP
21
+
22
+ #include <boost/type_traits/is_same.hpp>
23
+ #include <boost/functional/hash.hpp>
24
+
25
+ #ifdef BOOST_MSVC
26
+ #pragma warning(push)
27
+ #pragma warning(disable: 4103)
28
+ #endif
29
+ #ifdef BOOST_HAS_ABI_HEADERS
30
+ # include BOOST_ABI_PREFIX
31
+ #endif
32
+ #ifdef BOOST_MSVC
33
+ #pragma warning(pop)
34
+ #endif
35
+
36
+ namespace boost{
37
+ #ifdef BOOST_MSVC
38
+ #pragma warning(push)
39
+ #pragma warning(disable : 4251 4231 4800)
40
+ #if BOOST_MSVC < 1600
41
+ #pragma warning(disable : 4660)
42
+ #endif
43
+ #endif
44
+
45
+ namespace re_detail{
46
+
47
+ //
48
+ // forward declaration, we will need this one later:
49
+ //
50
+ template <class charT, class traits>
51
+ class basic_regex_parser;
52
+
53
+ template <class I>
54
+ void bubble_down_one(I first, I last)
55
+ {
56
+ if(first != last)
57
+ {
58
+ I next = last - 1;
59
+ while((next != first) && (*next < *(next-1)))
60
+ {
61
+ (next-1)->swap(*next);
62
+ --next;
63
+ }
64
+ }
65
+ }
66
+
67
+ template <class Iterator>
68
+ inline int hash_value_from_capture_name(Iterator i, Iterator j)
69
+ {
70
+ std::size_t r = boost::hash_range(i, j);
71
+ r %= ((std::numeric_limits<int>::max)() - 10001);
72
+ r += 10000;
73
+ return static_cast<int>(r);
74
+ }
75
+
76
+ class named_subexpressions
77
+ {
78
+ public:
79
+ struct name
80
+ {
81
+ template <class charT>
82
+ name(const charT* i, const charT* j, int idx)
83
+ : index(idx)
84
+ {
85
+ hash = hash_value_from_capture_name(i, j);
86
+ }
87
+ name(int h, int idx)
88
+ : index(idx), hash(h)
89
+ {
90
+ }
91
+ int index;
92
+ int hash;
93
+ bool operator < (const name& other)const
94
+ {
95
+ return hash < other.hash;
96
+ }
97
+ bool operator == (const name& other)const
98
+ {
99
+ return hash == other.hash;
100
+ }
101
+ void swap(name& other)
102
+ {
103
+ std::swap(index, other.index);
104
+ std::swap(hash, other.hash);
105
+ }
106
+ };
107
+
108
+ typedef std::vector<name>::const_iterator const_iterator;
109
+ typedef std::pair<const_iterator, const_iterator> range_type;
110
+
111
+ named_subexpressions(){}
112
+
113
+ template <class charT>
114
+ void set_name(const charT* i, const charT* j, int index)
115
+ {
116
+ m_sub_names.push_back(name(i, j, index));
117
+ bubble_down_one(m_sub_names.begin(), m_sub_names.end());
118
+ }
119
+ template <class charT>
120
+ int get_id(const charT* i, const charT* j)const
121
+ {
122
+ name t(i, j, 0);
123
+ typename std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
124
+ if((pos != m_sub_names.end()) && (*pos == t))
125
+ {
126
+ return pos->index;
127
+ }
128
+ return -1;
129
+ }
130
+ template <class charT>
131
+ range_type equal_range(const charT* i, const charT* j)const
132
+ {
133
+ name t(i, j, 0);
134
+ return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
135
+ }
136
+ int get_id(int h)const
137
+ {
138
+ name t(h, 0);
139
+ std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
140
+ if((pos != m_sub_names.end()) && (*pos == t))
141
+ {
142
+ return pos->index;
143
+ }
144
+ return -1;
145
+ }
146
+ range_type equal_range(int h)const
147
+ {
148
+ name t(h, 0);
149
+ return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
150
+ }
151
+ private:
152
+ std::vector<name> m_sub_names;
153
+ };
154
+
155
+ //
156
+ // class regex_data:
157
+ // represents the data we wish to expose to the matching algorithms.
158
+ //
159
+ template <class charT, class traits>
160
+ struct regex_data : public named_subexpressions
161
+ {
162
+ typedef regex_constants::syntax_option_type flag_type;
163
+ typedef std::size_t size_type;
164
+
165
+ regex_data(const ::boost::shared_ptr<
166
+ ::boost::regex_traits_wrapper<traits> >& t)
167
+ : m_ptraits(t), m_expression(0), m_expression_len(0) {}
168
+ regex_data()
169
+ : m_ptraits(new ::boost::regex_traits_wrapper<traits>()), m_expression(0), m_expression_len(0) {}
170
+
171
+ ::boost::shared_ptr<
172
+ ::boost::regex_traits_wrapper<traits>
173
+ > m_ptraits; // traits class instance
174
+ flag_type m_flags; // flags with which we were compiled
175
+ int m_status; // error code (0 implies OK).
176
+ const charT* m_expression; // the original expression
177
+ std::ptrdiff_t m_expression_len; // the length of the original expression
178
+ size_type m_mark_count; // the number of marked sub-expressions
179
+ re_detail::re_syntax_base* m_first_state; // the first state of the machine
180
+ unsigned m_restart_type; // search optimisation type
181
+ unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match
182
+ unsigned int m_can_be_null; // whether we can match a null string
183
+ re_detail::raw_storage m_data; // the buffer in which our states are constructed
184
+ typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character
185
+ std::vector<
186
+ std::pair<
187
+ std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*.
188
+ bool m_has_recursions; // whether we have recursive expressions;
189
+ };
190
+ //
191
+ // class basic_regex_implementation
192
+ // pimpl implementation class for basic_regex.
193
+ //
194
+ template <class charT, class traits>
195
+ class basic_regex_implementation
196
+ : public regex_data<charT, traits>
197
+ {
198
+ public:
199
+ typedef regex_constants::syntax_option_type flag_type;
200
+ typedef std::ptrdiff_t difference_type;
201
+ typedef std::size_t size_type;
202
+ typedef typename traits::locale_type locale_type;
203
+ typedef const charT* const_iterator;
204
+
205
+ basic_regex_implementation(){}
206
+ basic_regex_implementation(const ::boost::shared_ptr<
207
+ ::boost::regex_traits_wrapper<traits> >& t)
208
+ : regex_data<charT, traits>(t) {}
209
+ void assign(const charT* arg_first,
210
+ const charT* arg_last,
211
+ flag_type f)
212
+ {
213
+ regex_data<charT, traits>* pdat = this;
214
+ basic_regex_parser<charT, traits> parser(pdat);
215
+ parser.parse(arg_first, arg_last, f);
216
+ }
217
+
218
+ locale_type BOOST_REGEX_CALL imbue(locale_type l)
219
+ {
220
+ return this->m_ptraits->imbue(l);
221
+ }
222
+ locale_type BOOST_REGEX_CALL getloc()const
223
+ {
224
+ return this->m_ptraits->getloc();
225
+ }
226
+ std::basic_string<charT> BOOST_REGEX_CALL str()const
227
+ {
228
+ std::basic_string<charT> result;
229
+ if(this->m_status == 0)
230
+ result = std::basic_string<charT>(this->m_expression, this->m_expression_len);
231
+ return result;
232
+ }
233
+ const_iterator BOOST_REGEX_CALL expression()const
234
+ {
235
+ return this->m_expression;
236
+ }
237
+ std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
238
+ {
239
+ if(n == 0)
240
+ boost::throw_exception(std::out_of_range("0 is not a valid subexpression index."));
241
+ const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
242
+ std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
243
+ return p;
244
+ }
245
+ //
246
+ // begin, end:
247
+ const_iterator BOOST_REGEX_CALL begin()const
248
+ {
249
+ return (this->m_status ? 0 : this->m_expression);
250
+ }
251
+ const_iterator BOOST_REGEX_CALL end()const
252
+ {
253
+ return (this->m_status ? 0 : this->m_expression + this->m_expression_len);
254
+ }
255
+ flag_type BOOST_REGEX_CALL flags()const
256
+ {
257
+ return this->m_flags;
258
+ }
259
+ size_type BOOST_REGEX_CALL size()const
260
+ {
261
+ return this->m_expression_len;
262
+ }
263
+ int BOOST_REGEX_CALL status()const
264
+ {
265
+ return this->m_status;
266
+ }
267
+ size_type BOOST_REGEX_CALL mark_count()const
268
+ {
269
+ return this->m_mark_count;
270
+ }
271
+ const re_detail::re_syntax_base* get_first_state()const
272
+ {
273
+ return this->m_first_state;
274
+ }
275
+ unsigned get_restart_type()const
276
+ {
277
+ return this->m_restart_type;
278
+ }
279
+ const unsigned char* get_map()const
280
+ {
281
+ return this->m_startmap;
282
+ }
283
+ const ::boost::regex_traits_wrapper<traits>& get_traits()const
284
+ {
285
+ return *(this->m_ptraits);
286
+ }
287
+ bool can_be_null()const
288
+ {
289
+ return this->m_can_be_null;
290
+ }
291
+ const regex_data<charT, traits>& get_data()const
292
+ {
293
+ basic_regex_implementation<charT, traits> const* p = this;
294
+ return *static_cast<const regex_data<charT, traits>*>(p);
295
+ }
296
+ };
297
+
298
+ } // namespace re_detail
299
+ //
300
+ // class basic_regex:
301
+ // represents the compiled
302
+ // regular expression:
303
+ //
304
+
305
+ #ifdef BOOST_REGEX_NO_FWD
306
+ template <class charT, class traits = regex_traits<charT> >
307
+ #else
308
+ template <class charT, class traits >
309
+ #endif
310
+ class basic_regex : public regbase
311
+ {
312
+ public:
313
+ // typedefs:
314
+ typedef std::size_t traits_size_type;
315
+ typedef typename traits::string_type traits_string_type;
316
+ typedef charT char_type;
317
+ typedef traits traits_type;
318
+
319
+ typedef charT value_type;
320
+ typedef charT& reference;
321
+ typedef const charT& const_reference;
322
+ typedef const charT* const_iterator;
323
+ typedef const_iterator iterator;
324
+ typedef std::ptrdiff_t difference_type;
325
+ typedef std::size_t size_type;
326
+ typedef regex_constants::syntax_option_type flag_type;
327
+ // locale_type
328
+ // placeholder for actual locale type used by the
329
+ // traits class to localise *this.
330
+ typedef typename traits::locale_type locale_type;
331
+
332
+ public:
333
+ explicit basic_regex(){}
334
+ explicit basic_regex(const charT* p, flag_type f = regex_constants::normal)
335
+ {
336
+ assign(p, f);
337
+ }
338
+ basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
339
+ {
340
+ assign(p1, p2, f);
341
+ }
342
+ basic_regex(const charT* p, size_type len, flag_type f)
343
+ {
344
+ assign(p, len, f);
345
+ }
346
+ basic_regex(const basic_regex& that)
347
+ : m_pimpl(that.m_pimpl) {}
348
+ ~basic_regex(){}
349
+ basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that)
350
+ {
351
+ return assign(that);
352
+ }
353
+ basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr)
354
+ {
355
+ return assign(ptr);
356
+ }
357
+
358
+ //
359
+ // assign:
360
+ basic_regex& assign(const basic_regex& that)
361
+ {
362
+ m_pimpl = that.m_pimpl;
363
+ return *this;
364
+ }
365
+ basic_regex& assign(const charT* p, flag_type f = regex_constants::normal)
366
+ {
367
+ return assign(p, p + traits::length(p), f);
368
+ }
369
+ basic_regex& assign(const charT* p, size_type len, flag_type f)
370
+ {
371
+ return assign(p, p + len, f);
372
+ }
373
+ private:
374
+ basic_regex& do_assign(const charT* p1,
375
+ const charT* p2,
376
+ flag_type f);
377
+ public:
378
+ basic_regex& assign(const charT* p1,
379
+ const charT* p2,
380
+ flag_type f = regex_constants::normal)
381
+ {
382
+ return do_assign(p1, p2, f);
383
+ }
384
+ #if !defined(BOOST_NO_MEMBER_TEMPLATES)
385
+
386
+ template <class ST, class SA>
387
+ unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
388
+ {
389
+ return set_expression(p.data(), p.data() + p.size(), f);
390
+ }
391
+
392
+ template <class ST, class SA>
393
+ explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
394
+ {
395
+ assign(p, f);
396
+ }
397
+
398
+ template <class InputIterator>
399
+ basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
400
+ {
401
+ typedef typename traits::string_type seq_type;
402
+ seq_type a(arg_first, arg_last);
403
+ if(a.size())
404
+ assign(static_cast<const charT*>(&*a.begin()), static_cast<const charT*>(&*a.begin() + a.size()), f);
405
+ else
406
+ assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
407
+ }
408
+
409
+ template <class ST, class SA>
410
+ basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
411
+ {
412
+ return assign(p.data(), p.data() + p.size(), regex_constants::normal);
413
+ }
414
+
415
+ template <class string_traits, class A>
416
+ basic_regex& BOOST_REGEX_CALL assign(
417
+ const std::basic_string<charT, string_traits, A>& s,
418
+ flag_type f = regex_constants::normal)
419
+ {
420
+ return assign(s.data(), s.data() + s.size(), f);
421
+ }
422
+
423
+ template <class InputIterator>
424
+ basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first,
425
+ InputIterator arg_last,
426
+ flag_type f = regex_constants::normal)
427
+ {
428
+ typedef typename traits::string_type seq_type;
429
+ seq_type a(arg_first, arg_last);
430
+ if(a.size())
431
+ {
432
+ const charT* p1 = &*a.begin();
433
+ const charT* p2 = &*a.begin() + a.size();
434
+ return assign(p1, p2, f);
435
+ }
436
+ return assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
437
+ }
438
+ #else
439
+ unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
440
+ {
441
+ return set_expression(p.data(), p.data() + p.size(), f);
442
+ }
443
+
444
+ basic_regex(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
445
+ {
446
+ assign(p, f);
447
+ }
448
+
449
+ basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
450
+ {
451
+ return assign(p.data(), p.data() + p.size(), regex_constants::normal);
452
+ }
453
+
454
+ basic_regex& BOOST_REGEX_CALL assign(
455
+ const std::basic_string<charT>& s,
456
+ flag_type f = regex_constants::normal)
457
+ {
458
+ return assign(s.data(), s.data() + s.size(), f);
459
+ }
460
+
461
+ #endif
462
+
463
+ //
464
+ // locale:
465
+ locale_type BOOST_REGEX_CALL imbue(locale_type l);
466
+ locale_type BOOST_REGEX_CALL getloc()const
467
+ {
468
+ return m_pimpl.get() ? m_pimpl->getloc() : locale_type();
469
+ }
470
+ //
471
+ // getflags:
472
+ // retained for backwards compatibility only, "flags"
473
+ // is now the preferred name:
474
+ flag_type BOOST_REGEX_CALL getflags()const
475
+ {
476
+ return flags();
477
+ }
478
+ flag_type BOOST_REGEX_CALL flags()const
479
+ {
480
+ return m_pimpl.get() ? m_pimpl->flags() : 0;
481
+ }
482
+ //
483
+ // str:
484
+ std::basic_string<charT> BOOST_REGEX_CALL str()const
485
+ {
486
+ return m_pimpl.get() ? m_pimpl->str() : std::basic_string<charT>();
487
+ }
488
+ //
489
+ // begin, end, subexpression:
490
+ std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
491
+ {
492
+ if(!m_pimpl.get())
493
+ boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
494
+ return m_pimpl->subexpression(n);
495
+ }
496
+ const_iterator BOOST_REGEX_CALL begin()const
497
+ {
498
+ return (m_pimpl.get() ? m_pimpl->begin() : 0);
499
+ }
500
+ const_iterator BOOST_REGEX_CALL end()const
501
+ {
502
+ return (m_pimpl.get() ? m_pimpl->end() : 0);
503
+ }
504
+ //
505
+ // swap:
506
+ void BOOST_REGEX_CALL swap(basic_regex& that)throw()
507
+ {
508
+ m_pimpl.swap(that.m_pimpl);
509
+ }
510
+ //
511
+ // size:
512
+ size_type BOOST_REGEX_CALL size()const
513
+ {
514
+ return (m_pimpl.get() ? m_pimpl->size() : 0);
515
+ }
516
+ //
517
+ // max_size:
518
+ size_type BOOST_REGEX_CALL max_size()const
519
+ {
520
+ return UINT_MAX;
521
+ }
522
+ //
523
+ // empty:
524
+ bool BOOST_REGEX_CALL empty()const
525
+ {
526
+ return (m_pimpl.get() ? 0 != m_pimpl->status() : true);
527
+ }
528
+
529
+ size_type BOOST_REGEX_CALL mark_count()const
530
+ {
531
+ return (m_pimpl.get() ? m_pimpl->mark_count() : 0);
532
+ }
533
+
534
+ int status()const
535
+ {
536
+ return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty);
537
+ }
538
+
539
+ int BOOST_REGEX_CALL compare(const basic_regex& that) const
540
+ {
541
+ if(m_pimpl.get() == that.m_pimpl.get())
542
+ return 0;
543
+ if(!m_pimpl.get())
544
+ return -1;
545
+ if(!that.m_pimpl.get())
546
+ return 1;
547
+ if(status() != that.status())
548
+ return status() - that.status();
549
+ if(flags() != that.flags())
550
+ return flags() - that.flags();
551
+ return str().compare(that.str());
552
+ }
553
+ bool BOOST_REGEX_CALL operator==(const basic_regex& e)const
554
+ {
555
+ return compare(e) == 0;
556
+ }
557
+ bool BOOST_REGEX_CALL operator != (const basic_regex& e)const
558
+ {
559
+ return compare(e) != 0;
560
+ }
561
+ bool BOOST_REGEX_CALL operator<(const basic_regex& e)const
562
+ {
563
+ return compare(e) < 0;
564
+ }
565
+ bool BOOST_REGEX_CALL operator>(const basic_regex& e)const
566
+ {
567
+ return compare(e) > 0;
568
+ }
569
+ bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const
570
+ {
571
+ return compare(e) <= 0;
572
+ }
573
+ bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const
574
+ {
575
+ return compare(e) >= 0;
576
+ }
577
+
578
+ //
579
+ // The following are deprecated as public interfaces
580
+ // but are available for compatibility with earlier versions.
581
+ const charT* BOOST_REGEX_CALL expression()const
582
+ {
583
+ return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0);
584
+ }
585
+ unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
586
+ {
587
+ assign(p1, p2, f | regex_constants::no_except);
588
+ return status();
589
+ }
590
+ unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal)
591
+ {
592
+ assign(p, f | regex_constants::no_except);
593
+ return status();
594
+ }
595
+ unsigned int BOOST_REGEX_CALL error_code()const
596
+ {
597
+ return status();
598
+ }
599
+ //
600
+ // private access methods:
601
+ //
602
+ const re_detail::re_syntax_base* get_first_state()const
603
+ {
604
+ BOOST_ASSERT(0 != m_pimpl.get());
605
+ return m_pimpl->get_first_state();
606
+ }
607
+ unsigned get_restart_type()const
608
+ {
609
+ BOOST_ASSERT(0 != m_pimpl.get());
610
+ return m_pimpl->get_restart_type();
611
+ }
612
+ const unsigned char* get_map()const
613
+ {
614
+ BOOST_ASSERT(0 != m_pimpl.get());
615
+ return m_pimpl->get_map();
616
+ }
617
+ const ::boost::regex_traits_wrapper<traits>& get_traits()const
618
+ {
619
+ BOOST_ASSERT(0 != m_pimpl.get());
620
+ return m_pimpl->get_traits();
621
+ }
622
+ bool can_be_null()const
623
+ {
624
+ BOOST_ASSERT(0 != m_pimpl.get());
625
+ return m_pimpl->can_be_null();
626
+ }
627
+ const re_detail::regex_data<charT, traits>& get_data()const
628
+ {
629
+ BOOST_ASSERT(0 != m_pimpl.get());
630
+ return m_pimpl->get_data();
631
+ }
632
+ boost::shared_ptr<re_detail::named_subexpressions > get_named_subs()const
633
+ {
634
+ return m_pimpl;
635
+ }
636
+
637
+ private:
638
+ shared_ptr<re_detail::basic_regex_implementation<charT, traits> > m_pimpl;
639
+ };
640
+
641
+ //
642
+ // out of line members;
643
+ // these are the only members that mutate the basic_regex object,
644
+ // and are designed to provide the strong exception guarentee
645
+ // (in the event of a throw, the state of the object remains unchanged).
646
+ //
647
+ template <class charT, class traits>
648
+ basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p1,
649
+ const charT* p2,
650
+ flag_type f)
651
+ {
652
+ shared_ptr<re_detail::basic_regex_implementation<charT, traits> > temp;
653
+ if(!m_pimpl.get())
654
+ {
655
+ temp = shared_ptr<re_detail::basic_regex_implementation<charT, traits> >(new re_detail::basic_regex_implementation<charT, traits>());
656
+ }
657
+ else
658
+ {
659
+ temp = shared_ptr<re_detail::basic_regex_implementation<charT, traits> >(new re_detail::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits));
660
+ }
661
+ temp->assign(p1, p2, f);
662
+ temp.swap(m_pimpl);
663
+ return *this;
664
+ }
665
+
666
+ template <class charT, class traits>
667
+ typename basic_regex<charT, traits>::locale_type BOOST_REGEX_CALL basic_regex<charT, traits>::imbue(locale_type l)
668
+ {
669
+ shared_ptr<re_detail::basic_regex_implementation<charT, traits> > temp(new re_detail::basic_regex_implementation<charT, traits>());
670
+ locale_type result = temp->imbue(l);
671
+ temp.swap(m_pimpl);
672
+ return result;
673
+ }
674
+
675
+ //
676
+ // non-members:
677
+ //
678
+ template <class charT, class traits>
679
+ void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2)
680
+ {
681
+ e1.swap(e2);
682
+ }
683
+
684
+ #ifndef BOOST_NO_STD_LOCALE
685
+ template <class charT, class traits, class traits2>
686
+ std::basic_ostream<charT, traits>&
687
+ operator << (std::basic_ostream<charT, traits>& os,
688
+ const basic_regex<charT, traits2>& e)
689
+ {
690
+ return (os << e.str());
691
+ }
692
+ #else
693
+ template <class traits>
694
+ std::ostream& operator << (std::ostream& os, const basic_regex<char, traits>& e)
695
+ {
696
+ return (os << e.str());
697
+ }
698
+ #endif
699
+
700
+ //
701
+ // class reg_expression:
702
+ // this is provided for backwards compatibility only,
703
+ // it is deprecated, no not use!
704
+ //
705
+ #ifdef BOOST_REGEX_NO_FWD
706
+ template <class charT, class traits = regex_traits<charT> >
707
+ #else
708
+ template <class charT, class traits >
709
+ #endif
710
+ class reg_expression : public basic_regex<charT, traits>
711
+ {
712
+ public:
713
+ typedef typename basic_regex<charT, traits>::flag_type flag_type;
714
+ typedef typename basic_regex<charT, traits>::size_type size_type;
715
+ explicit reg_expression(){}
716
+ explicit reg_expression(const charT* p, flag_type f = regex_constants::normal)
717
+ : basic_regex<charT, traits>(p, f){}
718
+ reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
719
+ : basic_regex<charT, traits>(p1, p2, f){}
720
+ reg_expression(const charT* p, size_type len, flag_type f)
721
+ : basic_regex<charT, traits>(p, len, f){}
722
+ reg_expression(const reg_expression& that)
723
+ : basic_regex<charT, traits>(that) {}
724
+ ~reg_expression(){}
725
+ reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that)
726
+ {
727
+ return this->assign(that);
728
+ }
729
+
730
+ #if !defined(BOOST_NO_MEMBER_TEMPLATES)
731
+ template <class ST, class SA>
732
+ explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
733
+ : basic_regex<charT, traits>(p, f)
734
+ {
735
+ }
736
+
737
+ template <class InputIterator>
738
+ reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
739
+ : basic_regex<charT, traits>(arg_first, arg_last, f)
740
+ {
741
+ }
742
+
743
+ template <class ST, class SA>
744
+ reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
745
+ {
746
+ this->assign(p);
747
+ return *this;
748
+ }
749
+ #else
750
+ explicit reg_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
751
+ : basic_regex<charT, traits>(p, f)
752
+ {
753
+ }
754
+
755
+ reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
756
+ {
757
+ this->assign(p);
758
+ return *this;
759
+ }
760
+ #endif
761
+
762
+ };
763
+
764
+ #ifdef BOOST_MSVC
765
+ #pragma warning (pop)
766
+ #endif
767
+
768
+ } // namespace boost
769
+
770
+ #ifdef BOOST_MSVC
771
+ #pragma warning(push)
772
+ #pragma warning(disable: 4103)
773
+ #endif
774
+ #ifdef BOOST_HAS_ABI_HEADERS
775
+ # include BOOST_ABI_SUFFIX
776
+ #endif
777
+ #ifdef BOOST_MSVC
778
+ #pragma warning(pop)
779
+ #endif
780
+
781
+ #endif
782
+