[cpp-sp] 02/02: Change namespace exp:: to regexp::

Rod Widdowson rdw at steadingsoftware.com
Tue Jan 7 11:00:45 UTC 2025


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=a01ba8c2b07dce56141b3a8c9483c55b7d38b5b0

commit a01ba8c2b07dce56141b3a8c9483c55b7d38b5b0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jan 7 10:58:14 2025 +0000

    Change namespace exp:: to regexp::
    
    For some reason Windows doesn't like have exp as a namespace
    
    "XMLRequestMapper.cpp(45,17): error C2386: 'exp': a symbol with this name already exists in the current scope"
    Even though it isn't used by the code
---
 shibsp/impl/XMLAccessControl.cpp | 22 ++++++++++----------
 shibsp/impl/XMLRequestMapper.cpp | 44 ++++++++++++++++++++--------------------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/shibsp/impl/XMLAccessControl.cpp b/shibsp/impl/XMLAccessControl.cpp
index 2b3debbd..74c057a5 100644
--- a/shibsp/impl/XMLAccessControl.cpp
+++ b/shibsp/impl/XMLAccessControl.cpp
@@ -37,10 +37,10 @@
 
 #ifdef SHIBSP_USE_BOOST_REGEX
 # include <boost/regex.hpp>
-namespace exp = boost;
+namespace regexp = boost;
 #else
 # include <regex>
-namespace exp = std;
+namespace regexp = std;
 #endif
 
 #ifndef HAVE_STRCASECMP
@@ -77,7 +77,7 @@ namespace {
     private:
         string m_alias;
         string m_exp;
-        exp::regex m_re;
+        regexp::regex m_re;
     };
 
     class Operator : public AccessControl, public NoOpSharedLockable
@@ -236,13 +236,13 @@ RuleRegex::RuleRegex(const ptree& pt)
     static string_to_bool_translator tr;
     bool caseSensitive = pt.get(CASE_SENSITIVE_PROP_PATH, true);
     try {
-        exp::regex_constants::syntax_option_type flags = exp::regex_constants::extended | exp::regex_constants::optimize;
+        regexp::regex_constants::syntax_option_type flags = regexp::regex_constants::extended | regexp::regex_constants::optimize;
         if (!caseSensitive) {
-            flags |= exp::regex_constants::icase;
+            flags |= regexp::regex_constants::icase;
         }
-        m_re = exp::regex(m_exp, flags);
+        m_re = regexp::regex(m_exp, flags);
     }
-    catch (const exp::regex_error&) {
+    catch (const regexp::regex_error&) {
         throw ConfigurationException("Caught exception while parsing RuleRegex regular expression.");
     }
 }
@@ -250,7 +250,7 @@ RuleRegex::RuleRegex(const ptree& pt)
 AccessControl::aclresult_t RuleRegex::authorized(const SPRequest& request, const Session* session) const
 {
 
-    static exp::regex_constants::match_flag_type match_flags = exp::regex_constants::match_any | exp::regex_constants::match_not_null;
+    static regexp::regex_constants::match_flag_type match_flags = regexp::regex_constants::match_any | regexp::regex_constants::match_not_null;
 
     if (!session) {
         request.log(Priority::SHIB_WARN, "AccessControl plugin not given a valid session to evaluate, are you using lazy sessions?");
@@ -266,14 +266,14 @@ AccessControl::aclresult_t RuleRegex::authorized(const SPRequest& request, const
     }
 
     if (m_alias == "user") {
-        if (exp::regex_match(request.getRemoteUser(), m_re, match_flags)) {
+        if (regexp::regex_match(request.getRemoteUser(), m_re, match_flags)) {
             request.log(Priority::SHIB_DEBUG, string("AccessControl rule expecting REMOTE_USER regex (") + m_exp + "), authz granted");
             return shib_acl_true;
         }
         return shib_acl_false;
     }
     else if (m_alias == "authnContextClassRef") {
-        if (session->getAuthnContextClassRef() && exp::regex_match(session->getAuthnContextClassRef(), m_re, match_flags)) {
+        if (session->getAuthnContextClassRef() && regexp::regex_match(session->getAuthnContextClassRef(), m_re, match_flags)) {
             request.log(Priority::SHIB_DEBUG, string("AccessControl rule expecting authnContextClassRef regex (") + m_exp + "), authz granted");
             return shib_acl_true;
         }
@@ -290,7 +290,7 @@ AccessControl::aclresult_t RuleRegex::authorized(const SPRequest& request, const
     for (; attrs.first != attrs.second; ++attrs.first) {
         // Now we have to intersect the attribute's values against the regular expression.
         for (const string& v : attrs.first->second->getSerializedValues()) {
-            if (exp::regex_match(v, m_re, match_flags)) {
+            if (regexp::regex_match(v, m_re, match_flags)) {
                 request.log(Priority::SHIB_DEBUG, string("AccessControl rule expecting regex (") + m_exp + "), authz granted");
                 return shib_acl_true;
             }
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index ceb925d6..b476a9df 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -42,10 +42,10 @@
 
 #ifdef SHIBSP_USE_BOOST_REGEX
 # include <boost/regex.hpp>
-namespace exp = boost;
+namespace regexp = boost;
 #else
 # include <regex>
-namespace exp = std;
+namespace regexpp = std;
 #endif
 
 using namespace shibsp;
@@ -82,8 +82,8 @@ namespace {
         // This uses shared_ptr to support multiple mappings for a given Override for Host.
         // For Path, it's just overhead.
         map< string,shared_ptr<Override> > m_map;
-        vector< pair< exp::regex,unique_ptr<Override> > > m_regexps;
-        vector< tuple< string,boost::optional<exp::regex>,unique_ptr<Override> > > m_queries;
+        vector< pair< regexp::regex,unique_ptr<Override> > > m_regexps;
+        vector< tuple< string,boost::optional<regexp::regex>,unique_ptr<Override> > > m_queries;
 
     private:
         unique_ptr<AccessControl> m_acl;
@@ -144,8 +144,8 @@ namespace {
         return new XMLRequestMapper(pt);
     }
 
-    static exp::regex_constants::match_flag_type match_flags =
-        exp::regex_constants::match_any | exp::regex_constants::match_not_null;
+    static regexp::regex_constants::match_flag_type match_flags =
+        regexp::regex_constants::match_any | regexp::regex_constants::match_not_null;
 }
 
 void SHIBSP_API shibsp::registerRequestMappers()
@@ -322,15 +322,15 @@ Override::Override(bool unicodeAware, ptree& pt, Category& log, const Override*
 
             try {
                 // TODO: more flag options, particular for dialect.
-                exp::regex::flag_type flags = exp::regex_constants::extended | exp::regex_constants::optimize;
+                regexp::regex::flag_type flags = regexp::regex_constants::extended | regexp::regex_constants::optimize;
                 if (!o->getBool("caseSensitive", false)) {
-                    flags |= exp::regex_constants::icase;
+                    flags |= regexp::regex_constants::icase;
                 }
-                exp::regex exp(regexpprop, flags);
+                regexp::regex exp(regexpprop, flags);
                 m_regexps.push_back(make_pair(exp, std::move(o)));
                 log.debug("added <PathRegex> mapping (%s)", regexpprop.c_str());
             }
-            catch (const exp::regex_error& e) {
+            catch (const regexp::regex_error& e) {
                 log.error("error parsing PathRegex regular expression: %s", e.what());
                 throw ConfigurationException("Invalid regular expression in PathRegex element.");
             }
@@ -347,21 +347,21 @@ Override::Override(bool unicodeAware, ptree& pt, Category& log, const Override*
             string regexpprop(o->getString("regex", ""));
 
             if (regexpprop.empty()) {
-                m_queries.push_back(make_tuple(nameprop, boost::optional<exp::regex>(), std::move(o)));
+                m_queries.push_back(make_tuple(nameprop, boost::optional<regexp::regex>(), std::move(o)));
             }
             else {
                 try {
                     // TODO: more flag options, particular for dialect.
-                    exp::regex::flag_type flags = exp::regex_constants::extended | exp::regex_constants::optimize;
+                    regexp::regex::flag_type flags = regexp::regex_constants::extended | regexp::regex_constants::optimize;
                     if (!o->getBool("caseSensitive", false)) {
-                        flags |= exp::regex_constants::icase;
+                        flags |= regexp::regex_constants::icase;
                     }
-                    exp::regex expr(regexpprop, flags);
+                    regexp::regex expr(regexpprop, flags);
 
-                    m_queries.push_back(make_tuple(nameprop, boost::optional<exp::regex>(expr), std::move(o)));
+                    m_queries.push_back(make_tuple(nameprop, boost::optional<regexp::regex>(expr), std::move(o)));
                     log.debug("added <Query> mapping (%s)", nameprop.c_str());
                 }
-                catch (const exp::regex_error& e) {
+                catch (const regexp::regex_error& e) {
                     log.error("caught exception while parsing Query regular expression: %s", e.what());
                     throw ConfigurationException("Invalid regular expression in Query element.");
                 }
@@ -461,7 +461,7 @@ const Override* Override::locate(const HTTPRequest& request) const
                     if (get<1>(*q)) {
                         // We have to match one of the values.
                         while (vals.first != vals.second) {
-                            if (exp::regex_match(vals.first->second, get<1>(*q).get(), match_flags)) {
+                            if (regexp::regex_match(vals.first->second, get<1>(*q).get(), match_flags)) {
                                 o = get<2>(*q).get();
                                 descended = true;
                                 break;
@@ -516,14 +516,14 @@ XMLRequestMapperImpl::XMLRequestMapperImpl(ptree& pt, Category& log)
             unique_ptr<Override> o(new Override(m_unicodeAware, child.second, log, this));
 
             try {
-                exp::regex::flag_type flags = exp::regex_constants::extended | exp::regex_constants::optimize;
+                regexp::regex::flag_type flags = regexp::regex_constants::extended | regexp::regex_constants::optimize;
                 if (!o->getBool("caseSensitive", false)) {
-                    flags |= exp::regex_constants::icase;
+                    flags |= regexp::regex_constants::icase;
                 }
-                exp::regex expr(regexprop, flags);
+                regexp::regex expr(regexprop, flags);
                 m_regexps.push_back(make_pair(expr, std::move(o)));
             }
-            catch (const exp::regex_error& e) {
+            catch (const regexp::regex_error& e) {
                 log.error("caught exception while parsing HostRegex regular expression: %s", e.what());
             }
 
@@ -642,7 +642,7 @@ const Override* XMLRequestMapperImpl::findOverride(const char* vhost, const HTTP
     }
     else {
         for (const auto& re : m_regexps) {
-            if (exp::regex_match(vhost, re.first, match_flags)) {
+            if (regexp::regex_match(vhost, re.first, match_flags)) {
                 o = re.second.get();
             }
         }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list