diff --git a/src/posix_api.cpp b/src/posix_api.cpp index eb351561..3711a9a0 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -68,23 +68,20 @@ typedef boost::basic_regex > c_regex_type; BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f) { - if(expression->re_magic != magic_value) - { - expression->guts = 0; #ifndef BOOST_NO_EXCEPTIONS - try{ + try{ #endif expression->guts = new c_regex_type(); #ifndef BOOST_NO_EXCEPTIONS - } catch(...) - { - return REG_ESPACE; - } -#else - if(0 == expression->guts) - return REG_E_MEMORY; -#endif + } catch(...) + { + expression->guts = 0; + return REG_ESPACE; } +#else + if(0 == expression->guts) + return REG_E_MEMORY; +#endif // set default flags: boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index c0144bbe..bc1c0af2 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -78,23 +78,20 @@ typedef boost::basic_regex > wc_regex_type; BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f) { - if(expression->re_magic != wmagic_value) - { - expression->guts = 0; #ifndef BOOST_NO_EXCEPTIONS - try{ + try{ #endif expression->guts = new wc_regex_type(); #ifndef BOOST_NO_EXCEPTIONS - } catch(...) - { - return REG_ESPACE; - } -#else - if(0 == expression->guts) - return REG_E_MEMORY; -#endif + } catch(...) + { + expression->guts = 0; + return REG_ESPACE; } +#else + if(0 == expression->guts) + return REG_E_MEMORY; +#endif // set default flags: boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;