From: Mikko Rasa Date: Wed, 6 Aug 2008 19:34:49 +0000 (+0000) Subject: Add specialization for lexical_cast to avoid borking with spaces X-Git-Tag: strings-1.0~3 X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=5c8c0d5e52bbba8dc3f9c7c71b6e4c973216c600 Add specialization for lexical_cast to avoid borking with spaces Fix handling of parentheses inside bracker expressions in RegEx Update ignores --- diff --git a/source/lexicalcast.h b/source/lexicalcast.h index e67f361..a2bb439 100644 --- a/source/lexicalcast.h +++ b/source/lexicalcast.h @@ -36,6 +36,12 @@ T lexical_cast(const std::string &s) return tmp; } +template<> +inline std::string lexical_cast(const std::string &s) +{ + return s; +} + template std::string lexical_cast(const T &v, const Fmt &f=Fmt()) { diff --git a/source/regex.cpp b/source/regex.cpp index a1babf4..c2590f2 100644 --- a/source/regex.cpp +++ b/source/regex.cpp @@ -86,11 +86,21 @@ Regex::Code Regex::compile(const string &expr, string::const_iterator &iter, uns bool has_branches=false; unsigned level=0; bool escape=false; + unsigned bracket=0; string::const_iterator end; for(end=iter; end!=expr.end(); ++end) { if(escape) escape=false; + else if(bracket) + { + if(bracket==3 && *end==']') + bracket=0; + else if(bracket==1 && *end=='^') + bracket=2; + else + bracket=3; + } else if(*end=='\\') escape=true; else if(*end=='(') @@ -113,6 +123,8 @@ Regex::Code Regex::compile(const string &expr, string::const_iterator &iter, uns else if(level==0) has_branches=true; } + else if(*end=='[') + bracket=1; } if(level>0)