Skip to content

Commit

Permalink
Merge pull request #61 from rdumusc/master
Browse files Browse the repository at this point in the history
Fix Servus build without boost after #47 (fix #60)
  • Loading branch information
Raphael Dumusc authored Jun 27, 2016
2 parents eea68e0 + d9bea64 commit 5d81fec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions servus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ set(SERVUS_SOURCES
uri.cpp
)

list(APPEND SERVUS_LINK_LIBRARIES PRIVATE ${CMAKE_THREAD_LIBS_INIT}
${Boost_REGEX_LIBRARY})
list(APPEND SERVUS_LINK_LIBRARIES PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(MSVC)
list(APPEND SERVUS_LINK_LIBRARIES ws2_32)
endif()
Expand All @@ -55,6 +54,9 @@ if(COMMON_USE_CXX03)
list(APPEND SERVUS_LINK_LIBRARIES ${Boost_SYSTEM_LIBRARY}
${Boost_CHRONO_LIBRARY})
endif()
if(BOOST_FOUND)
list(APPEND SERVUS_LINK_LIBRARIES PRIVATE ${Boost_REGEX_LIBRARY})
endif()

set(SERVUS_OMIT_LIBRARY_HEADER ON)
common_library(Servus)
Expand Down
6 changes: 6 additions & 0 deletions servus/uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include <sstream>
#include <stdexcept>

#ifdef SERVUS_USE_BOOST
#include <boost/regex.hpp>
#endif

namespace servus
{
Expand Down Expand Up @@ -149,21 +151,25 @@ void _parseAuthority( URIData& data, const std::string& auth )
throw std::invalid_argument("");
}

#ifdef SERVUS_USE_BOOST
void _warnAboutLegacySeparator( const std::string& query )
{
const boost::regex legacySeparator( "[^&]*,[^&]*=" );
if( boost::regex_search( query, legacySeparator ))
std::cerr << "servus::URI: Detected legacy ',' separator in query: \""
<< query << "\". Use '&' separator instead." << std::endl;
}
#endif

void _parseQueryMap( URIData& data )
{
// parse query data into key-value pairs
std::string query = data.query;

#ifdef SERVUS_USE_BOOST
// warn if a query uses the legacy ',' separator instead of '&'
_warnAboutLegacySeparator( query );
#endif

data.queryMap.clear();
while( !query.empty( ))
Expand Down

0 comments on commit 5d81fec

Please sign in to comment.