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.
- data.tar.gz.asc +7 -7
- data/.gitignore +1 -0
- data/NEWS +22 -0
- data/build/preprocessor.rb +10 -0
- data/build/rpm.rb +74 -65
- data/debian.template/rules.template +8 -0
- data/dev/copy_boost_headers.rb +11 -2
- data/doc/Users guide Apache.idmap.txt +161 -145
- data/doc/Users guide Apache.txt +12 -1
- data/doc/Users guide Nginx.idmap.txt +142 -126
- data/doc/Users guide Nginx.txt +14 -1
- data/doc/Users guide Standalone.txt +1 -0
- data/doc/users_guide_snippets/environment_variables.txt +1 -1
- data/doc/users_guide_snippets/installation.txt +2 -0
- data/doc/users_guide_snippets/tips.txt +118 -0
- data/ext/apache2/Configuration.cpp +0 -6
- data/ext/apache2/Configuration.hpp +0 -5
- data/ext/apache2/ConfigurationCommands.cpp +7 -0
- data/ext/apache2/ConfigurationFields.hpp +2 -0
- data/ext/apache2/ConfigurationSetters.cpp +24 -0
- data/ext/apache2/CreateDirConfig.cpp +1 -0
- data/ext/apache2/Hooks.cpp +0 -1
- data/ext/apache2/MergeDirConfig.cpp +7 -0
- data/ext/apache2/SetHeaders.cpp +5 -1
- data/ext/boost/cregex.hpp +39 -0
- data/ext/boost/libs/regex/src/c_regex_traits.cpp +193 -0
- data/ext/boost/libs/regex/src/cpp_regex_traits.cpp +117 -0
- data/ext/boost/libs/regex/src/cregex.cpp +660 -0
- data/ext/boost/libs/regex/src/instances.cpp +32 -0
- data/ext/boost/libs/regex/src/internals.hpp +35 -0
- data/ext/boost/libs/regex/src/posix_api.cpp +296 -0
- data/ext/boost/libs/regex/src/regex.cpp +227 -0
- data/ext/boost/libs/regex/src/regex_debug.cpp +59 -0
- data/ext/boost/libs/regex/src/regex_raw_buffer.cpp +72 -0
- data/ext/boost/libs/regex/src/regex_traits_defaults.cpp +692 -0
- data/ext/boost/libs/regex/src/static_mutex.cpp +179 -0
- data/ext/boost/libs/regex/src/wc_regex_traits.cpp +301 -0
- data/ext/boost/libs/regex/src/wide_posix_api.cpp +315 -0
- data/ext/boost/libs/regex/src/winstances.cpp +35 -0
- data/ext/boost/regex.h +100 -0
- data/ext/boost/regex.hpp +37 -0
- data/ext/boost/regex/concepts.hpp +1128 -0
- data/ext/boost/regex/config.hpp +435 -0
- data/ext/boost/regex/config/borland.hpp +72 -0
- data/ext/boost/regex/config/cwchar.hpp +207 -0
- data/ext/boost/regex/mfc.hpp +190 -0
- data/ext/boost/regex/pattern_except.hpp +100 -0
- data/ext/boost/regex/pending/object_cache.hpp +165 -0
- data/ext/boost/regex/pending/static_mutex.hpp +179 -0
- data/ext/boost/regex/pending/unicode_iterator.hpp +776 -0
- data/ext/boost/regex/regex_traits.hpp +35 -0
- data/ext/boost/regex/user.hpp +93 -0
- data/ext/boost/regex/v4/basic_regex.hpp +782 -0
- data/ext/boost/regex/v4/basic_regex_creator.hpp +1571 -0
- data/ext/boost/regex/v4/basic_regex_parser.hpp +2874 -0
- data/ext/boost/regex/v4/c_regex_traits.hpp +211 -0
- data/ext/boost/regex/v4/char_regex_traits.hpp +81 -0
- data/ext/boost/regex/v4/cpp_regex_traits.hpp +1099 -0
- data/ext/boost/regex/v4/cregex.hpp +330 -0
- data/ext/boost/regex/v4/error_type.hpp +59 -0
- data/ext/boost/regex/v4/fileiter.hpp +455 -0
- data/ext/boost/regex/v4/instances.hpp +222 -0
- data/ext/boost/regex/v4/iterator_category.hpp +91 -0
- data/ext/boost/regex/v4/iterator_traits.hpp +135 -0
- data/ext/boost/regex/v4/match_flags.hpp +138 -0
- data/ext/boost/regex/v4/match_results.hpp +702 -0
- data/ext/boost/regex/v4/mem_block_cache.hpp +99 -0
- data/ext/boost/regex/v4/perl_matcher.hpp +587 -0
- data/ext/boost/regex/v4/perl_matcher_common.hpp +996 -0
- data/ext/boost/regex/v4/perl_matcher_non_recursive.hpp +1642 -0
- data/ext/boost/regex/v4/perl_matcher_recursive.hpp +991 -0
- data/ext/boost/regex/v4/primary_transform.hpp +146 -0
- data/ext/boost/regex/v4/protected_call.hpp +81 -0
- data/ext/boost/regex/v4/regbase.hpp +180 -0
- data/ext/boost/regex/v4/regex.hpp +202 -0
- data/ext/boost/regex/v4/regex_format.hpp +1156 -0
- data/ext/boost/regex/v4/regex_fwd.hpp +73 -0
- data/ext/boost/regex/v4/regex_grep.hpp +155 -0
- data/ext/boost/regex/v4/regex_iterator.hpp +201 -0
- data/ext/boost/regex/v4/regex_match.hpp +382 -0
- data/ext/boost/regex/v4/regex_merge.hpp +93 -0
- data/ext/boost/regex/v4/regex_raw_buffer.hpp +210 -0
- data/ext/boost/regex/v4/regex_replace.hpp +99 -0
- data/ext/boost/regex/v4/regex_search.hpp +217 -0
- data/ext/boost/regex/v4/regex_split.hpp +172 -0
- data/ext/boost/regex/v4/regex_token_iterator.hpp +342 -0
- data/ext/boost/regex/v4/regex_traits.hpp +189 -0
- data/ext/boost/regex/v4/regex_traits_defaults.hpp +371 -0
- data/ext/boost/regex/v4/regex_workaround.hpp +232 -0
- data/ext/boost/regex/v4/states.hpp +301 -0
- data/ext/boost/regex/v4/sub_match.hpp +512 -0
- data/ext/boost/regex/v4/syntax_type.hpp +105 -0
- data/ext/boost/regex/v4/u32regex_iterator.hpp +193 -0
- data/ext/boost/regex/v4/u32regex_token_iterator.hpp +377 -0
- data/ext/boost/regex/v4/w32_regex_traits.hpp +741 -0
- data/ext/boost/regex_fwd.hpp +33 -0
- data/ext/common/AgentsStarter.h +0 -11
- data/ext/common/ApplicationPool2/Common.h +1 -7
- data/ext/common/ApplicationPool2/DirectSpawner.h +3 -3
- data/ext/common/ApplicationPool2/Group.h +166 -69
- data/ext/common/ApplicationPool2/Implementation.cpp +55 -10
- data/ext/common/ApplicationPool2/Options.h +45 -10
- data/ext/common/ApplicationPool2/PipeWatcher.h +1 -2
- data/ext/common/ApplicationPool2/Pool.h +29 -7
- data/ext/common/ApplicationPool2/Process.h +22 -3
- data/ext/common/ApplicationPool2/Session.h +1 -0
- data/ext/common/ApplicationPool2/SmartSpawner.h +5 -10
- data/ext/common/ApplicationPool2/Spawner.h +10 -15
- data/ext/common/ApplicationPool2/SuperGroup.h +10 -9
- data/ext/common/Constants.h +1 -3
- data/ext/common/Hooks.h +193 -0
- data/ext/common/Logging.cpp +67 -2
- data/ext/common/Logging.h +23 -1
- data/ext/common/Utils.cpp +0 -21
- data/ext/common/Utils.h +0 -42
- data/ext/common/Utils/CachedFileStat.hpp +1 -1
- data/ext/common/Utils/StrIntUtils.h +61 -14
- data/ext/common/Utils/StringMap.h +4 -0
- data/ext/common/agents/HelperAgent/AgentOptions.h +4 -4
- data/ext/common/agents/HelperAgent/Main.cpp +2 -3
- data/ext/common/agents/HelperAgent/RequestHandler.h +65 -2
- data/ext/common/agents/LoggingAgent/FilterSupport.h +3 -1
- data/ext/common/agents/Watchdog/Main.cpp +8 -72
- data/ext/nginx/CacheLocationConfig.c +29 -1
- data/ext/nginx/Configuration.c +0 -12
- data/ext/nginx/Configuration.h +0 -1
- data/ext/nginx/ConfigurationCommands.c +10 -0
- data/ext/nginx/ConfigurationFields.h +2 -0
- data/ext/nginx/CreateLocationConfig.c +4 -0
- data/ext/nginx/MergeLocationConfig.c +6 -0
- data/ext/oxt/system_calls.cpp +7 -1
- data/ext/oxt/system_calls.hpp +7 -7
- data/helper-scripts/node-loader.js +6 -2
- data/helper-scripts/rack-loader.rb +5 -2
- data/helper-scripts/rack-preloader.rb +5 -2
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/apache2/config_options.rb +8 -0
- data/lib/phusion_passenger/constants.rb +0 -1
- data/lib/phusion_passenger/nginx/config_options.rb +9 -2
- data/lib/phusion_passenger/platform_info/apache.rb +2 -1
- data/lib/phusion_passenger/platform_info/compiler.rb +15 -1
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +2 -0
- data/node_lib/phusion_passenger/httplib_emulation.js +85 -17
- data/node_lib/phusion_passenger/request_handler.js +10 -2
- data/rpm/Vagrantfile +32 -0
- data/rpm/get_distro_id.py +4 -0
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +2 -2
- data/test/cxx/ApplicationPool2/PoolTest.cpp +60 -9
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +2 -6
- data/test/cxx/CachedFileStatTest.cpp +5 -5
- data/test/cxx/RequestHandlerTest.cpp +3 -6
- data/test/cxx/UtilsTest.cpp +30 -0
- data/test/node/httplib_emulation_spec.js +491 -0
- data/test/node/spec_helper.js +25 -0
- metadata +78 -2
- metadata.gz.asc +7 -7
@@ -0,0 +1,172 @@
|
|
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_split.hpp
|
15
|
+
* VERSION see <boost/version.hpp>
|
16
|
+
* DESCRIPTION: Implements regex_split and associated functions.
|
17
|
+
* Note this is an internal header file included
|
18
|
+
* by regex.hpp, do not include on its own.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifndef BOOST_REGEX_SPLIT_HPP
|
22
|
+
#define BOOST_REGEX_SPLIT_HPP
|
23
|
+
|
24
|
+
namespace boost{
|
25
|
+
|
26
|
+
#ifdef BOOST_MSVC
|
27
|
+
#pragma warning(push)
|
28
|
+
#pragma warning(disable: 4103)
|
29
|
+
#endif
|
30
|
+
#ifdef BOOST_HAS_ABI_HEADERS
|
31
|
+
# include BOOST_ABI_PREFIX
|
32
|
+
#endif
|
33
|
+
#ifdef BOOST_MSVC
|
34
|
+
#pragma warning(pop)
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#ifdef BOOST_MSVC
|
38
|
+
# pragma warning(push)
|
39
|
+
# pragma warning(disable: 4800)
|
40
|
+
#endif
|
41
|
+
|
42
|
+
namespace re_detail{
|
43
|
+
|
44
|
+
template <class charT>
|
45
|
+
const basic_regex<charT>& get_default_expression(charT)
|
46
|
+
{
|
47
|
+
static const charT expression_text[4] = { '\\', 's', '+', '\00', };
|
48
|
+
static const basic_regex<charT> e(expression_text);
|
49
|
+
return e;
|
50
|
+
}
|
51
|
+
|
52
|
+
template <class OutputIterator, class charT, class Traits1, class Alloc1>
|
53
|
+
class split_pred
|
54
|
+
{
|
55
|
+
typedef std::basic_string<charT, Traits1, Alloc1> string_type;
|
56
|
+
typedef typename string_type::const_iterator iterator_type;
|
57
|
+
iterator_type* p_last;
|
58
|
+
OutputIterator* p_out;
|
59
|
+
std::size_t* p_max;
|
60
|
+
std::size_t initial_max;
|
61
|
+
public:
|
62
|
+
split_pred(iterator_type* a, OutputIterator* b, std::size_t* c)
|
63
|
+
: p_last(a), p_out(b), p_max(c), initial_max(*c) {}
|
64
|
+
|
65
|
+
bool operator()(const match_results<iterator_type>& what);
|
66
|
+
};
|
67
|
+
|
68
|
+
template <class OutputIterator, class charT, class Traits1, class Alloc1>
|
69
|
+
bool split_pred<OutputIterator, charT, Traits1, Alloc1>::operator()
|
70
|
+
(const match_results<iterator_type>& what)
|
71
|
+
{
|
72
|
+
*p_last = what[0].second;
|
73
|
+
if(what.size() > 1)
|
74
|
+
{
|
75
|
+
// output sub-expressions only:
|
76
|
+
for(unsigned i = 1; i < what.size(); ++i)
|
77
|
+
{
|
78
|
+
*(*p_out) = what.str(i);
|
79
|
+
++(*p_out);
|
80
|
+
if(0 == --*p_max) return false;
|
81
|
+
}
|
82
|
+
return *p_max != 0;
|
83
|
+
}
|
84
|
+
else
|
85
|
+
{
|
86
|
+
// output $` only if it's not-null or not at the start of the input:
|
87
|
+
const sub_match<iterator_type>& sub = what[-1];
|
88
|
+
if((sub.first != sub.second) || (*p_max != initial_max))
|
89
|
+
{
|
90
|
+
*(*p_out) = sub.str();
|
91
|
+
++(*p_out);
|
92
|
+
return --*p_max;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
//
|
96
|
+
// initial null, do nothing:
|
97
|
+
return true;
|
98
|
+
}
|
99
|
+
|
100
|
+
} // namespace re_detail
|
101
|
+
|
102
|
+
template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
103
|
+
std::size_t regex_split(OutputIterator out,
|
104
|
+
std::basic_string<charT, Traits1, Alloc1>& s,
|
105
|
+
const basic_regex<charT, Traits2>& e,
|
106
|
+
match_flag_type flags,
|
107
|
+
std::size_t max_split)
|
108
|
+
{
|
109
|
+
typedef typename std::basic_string<charT, Traits1, Alloc1>::const_iterator ci_t;
|
110
|
+
//typedef typename match_results<ci_t>::allocator_type match_allocator;
|
111
|
+
ci_t last = s.begin();
|
112
|
+
std::size_t init_size = max_split;
|
113
|
+
re_detail::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split);
|
114
|
+
ci_t i, j;
|
115
|
+
i = s.begin();
|
116
|
+
j = s.end();
|
117
|
+
regex_grep(pred, i, j, e, flags);
|
118
|
+
//
|
119
|
+
// if there is still input left, do a final push as long as max_split
|
120
|
+
// is not exhausted, and we're not splitting sub-expressions rather
|
121
|
+
// than whitespace:
|
122
|
+
if(max_split && (last != s.end()) && (e.mark_count() == 1))
|
123
|
+
{
|
124
|
+
*out = std::basic_string<charT, Traits1, Alloc1>((ci_t)last, (ci_t)s.end());
|
125
|
+
++out;
|
126
|
+
last = s.end();
|
127
|
+
--max_split;
|
128
|
+
}
|
129
|
+
//
|
130
|
+
// delete from the string everything that has been processed so far:
|
131
|
+
s.erase(0, last - s.begin());
|
132
|
+
//
|
133
|
+
// return the number of new records pushed:
|
134
|
+
return init_size - max_split;
|
135
|
+
}
|
136
|
+
|
137
|
+
template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
138
|
+
inline std::size_t regex_split(OutputIterator out,
|
139
|
+
std::basic_string<charT, Traits1, Alloc1>& s,
|
140
|
+
const basic_regex<charT, Traits2>& e,
|
141
|
+
match_flag_type flags = match_default)
|
142
|
+
{
|
143
|
+
return regex_split(out, s, e, flags, UINT_MAX);
|
144
|
+
}
|
145
|
+
|
146
|
+
template <class OutputIterator, class charT, class Traits1, class Alloc1>
|
147
|
+
inline std::size_t regex_split(OutputIterator out,
|
148
|
+
std::basic_string<charT, Traits1, Alloc1>& s)
|
149
|
+
{
|
150
|
+
return regex_split(out, s, re_detail::get_default_expression(charT(0)), match_default, UINT_MAX);
|
151
|
+
}
|
152
|
+
|
153
|
+
#ifdef BOOST_MSVC
|
154
|
+
# pragma warning(pop)
|
155
|
+
#endif
|
156
|
+
|
157
|
+
#ifdef BOOST_MSVC
|
158
|
+
#pragma warning(push)
|
159
|
+
#pragma warning(disable: 4103)
|
160
|
+
#endif
|
161
|
+
#ifdef BOOST_HAS_ABI_HEADERS
|
162
|
+
# include BOOST_ABI_SUFFIX
|
163
|
+
#endif
|
164
|
+
#ifdef BOOST_MSVC
|
165
|
+
#pragma warning(pop)
|
166
|
+
#endif
|
167
|
+
|
168
|
+
} // namespace boost
|
169
|
+
|
170
|
+
#endif
|
171
|
+
|
172
|
+
|
@@ -0,0 +1,342 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright (c) 2003
|
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_token_iterator.hpp
|
15
|
+
* VERSION see <boost/version.hpp>
|
16
|
+
* DESCRIPTION: Provides regex_token_iterator implementation.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP
|
20
|
+
#define BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP
|
21
|
+
|
22
|
+
#include <boost/shared_ptr.hpp>
|
23
|
+
#include <boost/detail/workaround.hpp>
|
24
|
+
#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
|
25
|
+
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|
26
|
+
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
27
|
+
//
|
28
|
+
// Borland C++ Builder 6, and Visual C++ 6,
|
29
|
+
// can't cope with the array template constructor
|
30
|
+
// so we have a template member that will accept any type as
|
31
|
+
// argument, and then assert that is really is an array:
|
32
|
+
//
|
33
|
+
#include <boost/static_assert.hpp>
|
34
|
+
#include <boost/type_traits/is_array.hpp>
|
35
|
+
#endif
|
36
|
+
|
37
|
+
namespace boost{
|
38
|
+
|
39
|
+
#ifdef BOOST_MSVC
|
40
|
+
#pragma warning(push)
|
41
|
+
#pragma warning(disable: 4103)
|
42
|
+
#endif
|
43
|
+
#ifdef BOOST_HAS_ABI_HEADERS
|
44
|
+
# include BOOST_ABI_PREFIX
|
45
|
+
#endif
|
46
|
+
#ifdef BOOST_MSVC
|
47
|
+
#pragma warning(pop)
|
48
|
+
#endif
|
49
|
+
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300)
|
50
|
+
# pragma warning(push)
|
51
|
+
# pragma warning(disable:4700)
|
52
|
+
#endif
|
53
|
+
|
54
|
+
template <class BidirectionalIterator,
|
55
|
+
class charT,
|
56
|
+
class traits>
|
57
|
+
class regex_token_iterator_implementation
|
58
|
+
{
|
59
|
+
typedef basic_regex<charT, traits> regex_type;
|
60
|
+
typedef sub_match<BidirectionalIterator> value_type;
|
61
|
+
|
62
|
+
match_results<BidirectionalIterator> what; // current match
|
63
|
+
BidirectionalIterator base; // start of search area
|
64
|
+
BidirectionalIterator end; // end of search area
|
65
|
+
const regex_type re; // the expression
|
66
|
+
match_flag_type flags; // match flags
|
67
|
+
value_type result; // the current string result
|
68
|
+
int N; // the current sub-expression being enumerated
|
69
|
+
std::vector<int> subs; // the sub-expressions to enumerate
|
70
|
+
|
71
|
+
public:
|
72
|
+
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f)
|
73
|
+
: end(last), re(*p), flags(f){ subs.push_back(sub); }
|
74
|
+
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f)
|
75
|
+
: end(last), re(*p), flags(f), subs(v){}
|
76
|
+
#if !BOOST_WORKAROUND(__HP_aCC, < 60700)
|
77
|
+
#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
|
78
|
+
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|
79
|
+
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \
|
80
|
+
|| BOOST_WORKAROUND(__HP_aCC, < 60700)
|
81
|
+
template <class T>
|
82
|
+
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f)
|
83
|
+
: end(last), re(*p), flags(f)
|
84
|
+
{
|
85
|
+
// assert that T really is an array:
|
86
|
+
BOOST_STATIC_ASSERT(::boost::is_array<T>::value);
|
87
|
+
const std::size_t array_size = sizeof(T) / sizeof(submatches[0]);
|
88
|
+
for(std::size_t i = 0; i < array_size; ++i)
|
89
|
+
{
|
90
|
+
subs.push_back(submatches[i]);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
#else
|
94
|
+
template <std::size_t CN>
|
95
|
+
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f)
|
96
|
+
: end(last), re(*p), flags(f)
|
97
|
+
{
|
98
|
+
for(std::size_t i = 0; i < CN; ++i)
|
99
|
+
{
|
100
|
+
subs.push_back(submatches[i]);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
#endif
|
104
|
+
#endif
|
105
|
+
bool init(BidirectionalIterator first)
|
106
|
+
{
|
107
|
+
N = 0;
|
108
|
+
base = first;
|
109
|
+
if(regex_search(first, end, what, re, flags, base) == true)
|
110
|
+
{
|
111
|
+
N = 0;
|
112
|
+
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
|
113
|
+
return true;
|
114
|
+
}
|
115
|
+
else if((subs[N] == -1) && (first != end))
|
116
|
+
{
|
117
|
+
result.first = first;
|
118
|
+
result.second = end;
|
119
|
+
result.matched = (first != end);
|
120
|
+
N = -1;
|
121
|
+
return true;
|
122
|
+
}
|
123
|
+
return false;
|
124
|
+
}
|
125
|
+
bool compare(const regex_token_iterator_implementation& that)
|
126
|
+
{
|
127
|
+
if(this == &that) return true;
|
128
|
+
return (&re.get_data() == &that.re.get_data())
|
129
|
+
&& (end == that.end)
|
130
|
+
&& (flags == that.flags)
|
131
|
+
&& (N == that.N)
|
132
|
+
&& (what[0].first == that.what[0].first)
|
133
|
+
&& (what[0].second == that.what[0].second);
|
134
|
+
}
|
135
|
+
const value_type& get()
|
136
|
+
{ return result; }
|
137
|
+
bool next()
|
138
|
+
{
|
139
|
+
if(N == -1)
|
140
|
+
return false;
|
141
|
+
if(N+1 < (int)subs.size())
|
142
|
+
{
|
143
|
+
++N;
|
144
|
+
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
145
|
+
return true;
|
146
|
+
}
|
147
|
+
//if(what.prefix().first != what[0].second)
|
148
|
+
// flags |= /*match_prev_avail |*/ regex_constants::match_not_bob;
|
149
|
+
BidirectionalIterator last_end(what[0].second);
|
150
|
+
if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base))
|
151
|
+
{
|
152
|
+
N =0;
|
153
|
+
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
154
|
+
return true;
|
155
|
+
}
|
156
|
+
else if((last_end != end) && (subs[0] == -1))
|
157
|
+
{
|
158
|
+
N =-1;
|
159
|
+
result.first = last_end;
|
160
|
+
result.second = end;
|
161
|
+
result.matched = (last_end != end);
|
162
|
+
return true;
|
163
|
+
}
|
164
|
+
return false;
|
165
|
+
}
|
166
|
+
private:
|
167
|
+
regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&);
|
168
|
+
};
|
169
|
+
|
170
|
+
template <class BidirectionalIterator,
|
171
|
+
class charT = BOOST_DEDUCED_TYPENAME re_detail::regex_iterator_traits<BidirectionalIterator>::value_type,
|
172
|
+
class traits = regex_traits<charT> >
|
173
|
+
class regex_token_iterator
|
174
|
+
#ifndef BOOST_NO_STD_ITERATOR
|
175
|
+
: public std::iterator<
|
176
|
+
std::forward_iterator_tag,
|
177
|
+
sub_match<BidirectionalIterator>,
|
178
|
+
typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type,
|
179
|
+
const sub_match<BidirectionalIterator>*,
|
180
|
+
const sub_match<BidirectionalIterator>& >
|
181
|
+
#endif
|
182
|
+
{
|
183
|
+
private:
|
184
|
+
typedef regex_token_iterator_implementation<BidirectionalIterator, charT, traits> impl;
|
185
|
+
typedef shared_ptr<impl> pimpl;
|
186
|
+
public:
|
187
|
+
typedef basic_regex<charT, traits> regex_type;
|
188
|
+
typedef sub_match<BidirectionalIterator> value_type;
|
189
|
+
typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type
|
190
|
+
difference_type;
|
191
|
+
typedef const value_type* pointer;
|
192
|
+
typedef const value_type& reference;
|
193
|
+
typedef std::forward_iterator_tag iterator_category;
|
194
|
+
|
195
|
+
regex_token_iterator(){}
|
196
|
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
197
|
+
int submatch = 0, match_flag_type m = match_default)
|
198
|
+
: pdata(new impl(&re, b, submatch, m))
|
199
|
+
{
|
200
|
+
if(!pdata->init(a))
|
201
|
+
pdata.reset();
|
202
|
+
}
|
203
|
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
204
|
+
const std::vector<int>& submatches, match_flag_type m = match_default)
|
205
|
+
: pdata(new impl(&re, b, submatches, m))
|
206
|
+
{
|
207
|
+
if(!pdata->init(a))
|
208
|
+
pdata.reset();
|
209
|
+
}
|
210
|
+
#if !BOOST_WORKAROUND(__HP_aCC, < 60700)
|
211
|
+
#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
|
212
|
+
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|
213
|
+
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \
|
214
|
+
|| BOOST_WORKAROUND(__HP_aCC, < 60700)
|
215
|
+
template <class T>
|
216
|
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
217
|
+
const T& submatches, match_flag_type m = match_default)
|
218
|
+
: pdata(new impl(&re, b, submatches, m))
|
219
|
+
{
|
220
|
+
if(!pdata->init(a))
|
221
|
+
pdata.reset();
|
222
|
+
}
|
223
|
+
#else
|
224
|
+
template <std::size_t N>
|
225
|
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
226
|
+
const int (&submatches)[N], match_flag_type m = match_default)
|
227
|
+
: pdata(new impl(&re, b, submatches, m))
|
228
|
+
{
|
229
|
+
if(!pdata->init(a))
|
230
|
+
pdata.reset();
|
231
|
+
}
|
232
|
+
#endif
|
233
|
+
#endif
|
234
|
+
regex_token_iterator(const regex_token_iterator& that)
|
235
|
+
: pdata(that.pdata) {}
|
236
|
+
regex_token_iterator& operator=(const regex_token_iterator& that)
|
237
|
+
{
|
238
|
+
pdata = that.pdata;
|
239
|
+
return *this;
|
240
|
+
}
|
241
|
+
bool operator==(const regex_token_iterator& that)const
|
242
|
+
{
|
243
|
+
if((pdata.get() == 0) || (that.pdata.get() == 0))
|
244
|
+
return pdata.get() == that.pdata.get();
|
245
|
+
return pdata->compare(*(that.pdata.get()));
|
246
|
+
}
|
247
|
+
bool operator!=(const regex_token_iterator& that)const
|
248
|
+
{ return !(*this == that); }
|
249
|
+
const value_type& operator*()const
|
250
|
+
{ return pdata->get(); }
|
251
|
+
const value_type* operator->()const
|
252
|
+
{ return &(pdata->get()); }
|
253
|
+
regex_token_iterator& operator++()
|
254
|
+
{
|
255
|
+
cow();
|
256
|
+
if(0 == pdata->next())
|
257
|
+
{
|
258
|
+
pdata.reset();
|
259
|
+
}
|
260
|
+
return *this;
|
261
|
+
}
|
262
|
+
regex_token_iterator operator++(int)
|
263
|
+
{
|
264
|
+
regex_token_iterator result(*this);
|
265
|
+
++(*this);
|
266
|
+
return result;
|
267
|
+
}
|
268
|
+
private:
|
269
|
+
|
270
|
+
pimpl pdata;
|
271
|
+
|
272
|
+
void cow()
|
273
|
+
{
|
274
|
+
// copy-on-write
|
275
|
+
if(pdata.get() && !pdata.unique())
|
276
|
+
{
|
277
|
+
pdata.reset(new impl(*(pdata.get())));
|
278
|
+
}
|
279
|
+
}
|
280
|
+
};
|
281
|
+
|
282
|
+
typedef regex_token_iterator<const char*> cregex_token_iterator;
|
283
|
+
typedef regex_token_iterator<std::string::const_iterator> sregex_token_iterator;
|
284
|
+
#ifndef BOOST_NO_WREGEX
|
285
|
+
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
|
286
|
+
typedef regex_token_iterator<std::wstring::const_iterator> wsregex_token_iterator;
|
287
|
+
#endif
|
288
|
+
|
289
|
+
template <class charT, class traits>
|
290
|
+
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
|
291
|
+
{
|
292
|
+
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
293
|
+
}
|
294
|
+
template <class charT, class traits, class ST, class SA>
|
295
|
+
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
|
296
|
+
{
|
297
|
+
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
298
|
+
}
|
299
|
+
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
300
|
+
template <class charT, class traits, std::size_t N>
|
301
|
+
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
302
|
+
{
|
303
|
+
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
304
|
+
}
|
305
|
+
template <class charT, class traits, class ST, class SA, std::size_t N>
|
306
|
+
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
307
|
+
{
|
308
|
+
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
309
|
+
}
|
310
|
+
#endif
|
311
|
+
template <class charT, class traits>
|
312
|
+
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
313
|
+
{
|
314
|
+
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
315
|
+
}
|
316
|
+
template <class charT, class traits, class ST, class SA>
|
317
|
+
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
318
|
+
{
|
319
|
+
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
320
|
+
}
|
321
|
+
|
322
|
+
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300)
|
323
|
+
# pragma warning(pop)
|
324
|
+
#endif
|
325
|
+
#ifdef BOOST_MSVC
|
326
|
+
#pragma warning(push)
|
327
|
+
#pragma warning(disable: 4103)
|
328
|
+
#endif
|
329
|
+
#ifdef BOOST_HAS_ABI_HEADERS
|
330
|
+
# include BOOST_ABI_SUFFIX
|
331
|
+
#endif
|
332
|
+
#ifdef BOOST_MSVC
|
333
|
+
#pragma warning(pop)
|
334
|
+
#endif
|
335
|
+
|
336
|
+
} // namespace boost
|
337
|
+
|
338
|
+
#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|