forked from boostorg/regex
Merge bug fixes from Trunk - see history for full details.
[SVN r58234]
This commit is contained in:
@ -28,7 +28,7 @@
|
||||
// Find out if *password* meets our password requirements,
|
||||
// as defined by the regular expression *requirements*.
|
||||
//
|
||||
bool is_valid_password(const UnicodeString& password, const UnicodeString& requirements)
|
||||
bool is_valid_password(const U_NAMESPACE_QUALIFIER UnicodeString& password, const U_NAMESPACE_QUALIFIER UnicodeString& requirements)
|
||||
{
|
||||
return boost::u32regex_match(password, boost::make_u32regex(requirements));
|
||||
}
|
||||
@ -52,7 +52,7 @@ std::string get_filename(const std::string& path)
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString extract_greek(const UnicodeString& text)
|
||||
U_NAMESPACE_QUALIFIER UnicodeString extract_greek(const U_NAMESPACE_QUALIFIER UnicodeString& text)
|
||||
{
|
||||
// searches through some UTF-16 encoded text for a block encoded in Greek,
|
||||
// this expression is imperfect, but the best we can do for now - searching
|
||||
@ -62,7 +62,7 @@ UnicodeString extract_greek(const UnicodeString& text)
|
||||
if(boost::u32regex_search(text, what, r))
|
||||
{
|
||||
// extract $0 as a UnicodeString:
|
||||
return UnicodeString(what[0].first, what.length(0));
|
||||
return U_NAMESPACE_QUALIFIER UnicodeString(what[0].first, what.length(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,7 +127,7 @@ void enumerate_currencies2(const std::string& text)
|
||||
const boost::u32regex e = boost::make_u32regex("\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z");
|
||||
const char* human_format = "$1-$2-$3-$4";
|
||||
|
||||
UnicodeString human_readable_card_number(const UnicodeString& s)
|
||||
U_NAMESPACE_QUALIFIER UnicodeString human_readable_card_number(const U_NAMESPACE_QUALIFIER UnicodeString& s)
|
||||
{
|
||||
return boost::u32regex_replace(s, e, human_format);
|
||||
}
|
||||
@ -136,8 +136,8 @@ UnicodeString human_readable_card_number(const UnicodeString& s)
|
||||
int main()
|
||||
{
|
||||
// password checks using u32regex_match:
|
||||
UnicodeString pwd = "abcDEF---";
|
||||
UnicodeString pwd_check = "(?=.*[[:lower:]])(?=.*[[:upper:]])(?=.*[[:punct:]]).{6,}";
|
||||
U_NAMESPACE_QUALIFIER UnicodeString pwd = "abcDEF---";
|
||||
U_NAMESPACE_QUALIFIER UnicodeString pwd_check = "(?=.*[[:lower:]])(?=.*[[:upper:]])(?=.*[[:punct:]]).{6,}";
|
||||
bool b = is_valid_password(pwd, pwd_check);
|
||||
assert(b);
|
||||
pwd = "abcD-";
|
||||
@ -152,8 +152,8 @@ int main()
|
||||
assert(file == "d.h");
|
||||
|
||||
// Greek text extraction with u32regex_search:
|
||||
UnicodeString text = L"Some where in \x0391\x039D\x0395\x0398\x0391 2004";
|
||||
UnicodeString greek = extract_greek(text);
|
||||
U_NAMESPACE_QUALIFIER UnicodeString text = L"Some where in \x0391\x039D\x0395\x0398\x0391 2004";
|
||||
U_NAMESPACE_QUALIFIER UnicodeString greek = extract_greek(text);
|
||||
assert(greek == L"\x0391\x039D\x0395\x0398\x0391 2004");
|
||||
|
||||
// extract currency symbols with associated value, use iterator interface:
|
||||
@ -161,7 +161,7 @@ int main()
|
||||
enumerate_currencies(text2);
|
||||
enumerate_currencies2(text2);
|
||||
|
||||
UnicodeString credit_card_number = "1234567887654321";
|
||||
U_NAMESPACE_QUALIFIER UnicodeString credit_card_number = "1234567887654321";
|
||||
credit_card_number = human_readable_card_number(credit_card_number);
|
||||
assert(credit_card_number == "1234-5678-8765-4321");
|
||||
return 0;
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
what[5].first - base;
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
IndexClassesPred& operator=(const IndexClassesPred&);
|
||||
};
|
||||
|
||||
void IndexClasses(map_type& m, const std::string& file)
|
||||
|
@ -55,11 +55,11 @@ int process_ftp(const char* response, std::string* msg)
|
||||
istream& getline(istream& is, std::string& s)
|
||||
{
|
||||
s.erase();
|
||||
char c = is.get();
|
||||
char c = static_cast<char>(is.get());
|
||||
while(c != '\n')
|
||||
{
|
||||
s.append(1, c);
|
||||
c = is.get();
|
||||
c = static_cast<char>(is.get());
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ int main(int argc, const char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern const char* pre_expression = "(<)|(>)|\\r";
|
||||
extern const char* pre_format = "(?1<)(?2>)";
|
||||
const char* pre_expression = "(<)|(>)|\\r";
|
||||
const char* pre_format = "(?1<)(?2>)";
|
||||
|
||||
|
||||
const char* expression_text = // preprocessor directives: index 1
|
||||
|
@ -86,8 +86,8 @@ int main(int argc, const char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern const char* pre_expression = "(<)|(>)|(&)|\\r";
|
||||
extern const char* pre_format = "(?1<)(?2>)(?3&)";
|
||||
const char* pre_expression = "(<)|(>)|(&)|\\r";
|
||||
const char* pre_format = "(?1<)(?2>)(?3&)";
|
||||
|
||||
|
||||
const char* expression_text = // preprocessor directives: index 1
|
||||
|
@ -36,11 +36,11 @@ using namespace std;
|
||||
istream& getline(istream& is, std::string& s)
|
||||
{
|
||||
s.erase();
|
||||
char c = is.get();
|
||||
char c = static_cast<char>(is.get());
|
||||
while(c != '\n')
|
||||
{
|
||||
s.append(1, c);
|
||||
c = is.get();
|
||||
c = static_cast<char>(is.get());
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ using namespace std;
|
||||
istream& getline(istream& is, std::string& s)
|
||||
{
|
||||
s.erase();
|
||||
char c = is.get();
|
||||
char c = static_cast<char>(is.get());
|
||||
while(c != '\n')
|
||||
{
|
||||
s.append(1, c);
|
||||
c = is.get();
|
||||
c = static_cast<char>(is.get());
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
@ -9,6 +9,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4996 4127)
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
@ -54,7 +58,7 @@ ostream& operator << (ostream& os, const std::wstring& s)
|
||||
j = s.end();
|
||||
while(i != j)
|
||||
{
|
||||
os.put(*i);
|
||||
os.put(static_cast<char>(*i));
|
||||
++i;
|
||||
}
|
||||
return os;
|
||||
@ -96,15 +100,15 @@ namespace boost{
|
||||
istream& getline(istream& is, std::string& s)
|
||||
{
|
||||
s.erase();
|
||||
char c = is.get();
|
||||
char c = static_cast<char>(is.get());
|
||||
while(c != '\n')
|
||||
{
|
||||
s.append(1, c);
|
||||
c = is.get();
|
||||
c = static_cast<char>(is.get());
|
||||
}
|
||||
return is;
|
||||
}
|
||||
#elif defined(__CYGWIN__)
|
||||
#else
|
||||
istream& getline(istream& is, std::string& s)
|
||||
{
|
||||
std::getline(is, s);
|
||||
@ -112,8 +116,6 @@ istream& getline(istream& is, std::string& s)
|
||||
s.erase(s.size() - 1);
|
||||
return is;
|
||||
}
|
||||
#else
|
||||
using std::getline;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -148,8 +150,8 @@ int main(int argc, char**argv)
|
||||
std::size_t nsubs;
|
||||
boost::timer t;
|
||||
double tim;
|
||||
bool result;
|
||||
int iters = 100;
|
||||
int result = 0;
|
||||
unsigned iters = 100;
|
||||
double wait_time = (std::min)(t.elapsed_min() * 1000, 1.0);
|
||||
|
||||
while(true)
|
||||
@ -202,7 +204,7 @@ int main(int argc, char**argv)
|
||||
ds.erase(ds.begin(), ds.end());
|
||||
std::copy(s2.begin(), s2.end(), std::back_inserter(ds));
|
||||
|
||||
int i;
|
||||
unsigned i;
|
||||
iters = 10;
|
||||
tim = 1.1;
|
||||
|
||||
@ -217,7 +219,7 @@ int main(int argc, char**argv)
|
||||
|
||||
// measure time interval for basic_regex<char>
|
||||
do{
|
||||
iters *= (tim > 0.001) ? (1.1/tim) : 100;
|
||||
iters *= static_cast<unsigned>((tim > 0.001) ? (1.1/tim) : 100);
|
||||
t.restart();
|
||||
for(i =0; i < iters; ++i)
|
||||
{
|
||||
@ -251,7 +253,7 @@ int main(int argc, char**argv)
|
||||
// cache load:
|
||||
regex_search(ws2, wsm, wex);
|
||||
do{
|
||||
iters *= (tim > 0.001) ? (1.1/tim) : 100;
|
||||
iters *= static_cast<unsigned>((tim > 0.001) ? (1.1/tim) : 100);
|
||||
t.restart();
|
||||
for(i = 0; i < iters; ++i)
|
||||
{
|
||||
@ -289,7 +291,7 @@ int main(int argc, char**argv)
|
||||
// cache load:
|
||||
regex_search(ds.begin(), ds.end(), dm, ex);
|
||||
do{
|
||||
iters *= (tim > 0.001) ? (1.1/tim) : 100;
|
||||
iters *= static_cast<unsigned>((tim > 0.001) ? (1.1/tim) : 100);
|
||||
t.restart();
|
||||
for(i = 0; i < iters; ++i)
|
||||
{
|
||||
@ -326,7 +328,7 @@ int main(int argc, char**argv)
|
||||
// cache load:
|
||||
regexecA(&r, s2.c_str(), nsubs, matches.get(), 0);
|
||||
do{
|
||||
iters *= (tim > 0.001) ? (1.1/tim) : 100;
|
||||
iters *= static_cast<unsigned>((tim > 0.001) ? (1.1/tim) : 100);
|
||||
t.restart();
|
||||
for(i = 0; i < iters; ++i)
|
||||
{
|
||||
@ -357,7 +359,7 @@ int main(int argc, char**argv)
|
||||
ts.erase();
|
||||
ts.assign(s2.begin() + matches[0].rm_eo, s2.end());
|
||||
cout << ts;
|
||||
cout << "\" (matched=" << (matches[0].rm_eo != s2.size()) << ")" << endl << endl;
|
||||
cout << "\" (matched=" << (matches[0].rm_eo != (int)s2.size()) << ")" << endl << endl;
|
||||
}
|
||||
}
|
||||
regfreeA(&r);
|
||||
|
Reference in New Issue
Block a user