Skip to content

Commit bbf2a6b

Browse files
committed
boost regex until we are off of gcc4.8
1 parent c781835 commit bbf2a6b

File tree

3 files changed

+116
-4
lines changed

3 files changed

+116
-4
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ AX_BOOST_PROGRAM_OPTIONS
4141
AX_BOOST_SYSTEM
4242
AX_BOOST_THREAD
4343
AX_BOOST_FILESYSTEM
44+
AX_BOOST_REGEX
4445

4546
# check pkg-config dependencies
4647
PKG_CHECK_MODULES([DEPS], [protobuf >= 2.4.0 libprime_server >= 0.3.4])

m4/ax_boost_regex.m4

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_boost_regex.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_BOOST_REGEX
8+
#
9+
# DESCRIPTION
10+
#
11+
# Test for Regex library from the Boost C++ libraries. The macro requires
12+
# a preceding call to AX_BOOST_BASE. Further documentation is available at
13+
# <http://randspringer.de/boost/index.html>.
14+
#
15+
# This macro calls:
16+
#
17+
# AC_SUBST(BOOST_REGEX_LIB)
18+
#
19+
# And sets:
20+
#
21+
# HAVE_BOOST_REGEX
22+
#
23+
# LICENSE
24+
#
25+
# Copyright (c) 2008 Thomas Porschberg <[email protected]>
26+
# Copyright (c) 2008 Michael Tindal
27+
#
28+
# Copying and distribution of this file, with or without modification, are
29+
# permitted in any medium without royalty provided the copyright notice
30+
# and this notice are preserved. This file is offered as-is, without any
31+
# warranty.
32+
33+
#serial 22
34+
35+
AC_DEFUN([AX_BOOST_REGEX],
36+
[
37+
AC_ARG_WITH([boost-regex],
38+
AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@],
39+
[use the Regex library from boost - it is possible to specify a certain library for the linker
40+
e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]),
41+
[
42+
if test "$withval" = "no"; then
43+
want_boost="no"
44+
elif test "$withval" = "yes"; then
45+
want_boost="yes"
46+
ax_boost_user_regex_lib=""
47+
else
48+
want_boost="yes"
49+
ax_boost_user_regex_lib="$withval"
50+
fi
51+
],
52+
[want_boost="yes"]
53+
)
54+
55+
if test "x$want_boost" = "xyes"; then
56+
AC_REQUIRE([AC_PROG_CC])
57+
CPPFLAGS_SAVED="$CPPFLAGS"
58+
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
59+
export CPPFLAGS
60+
61+
LDFLAGS_SAVED="$LDFLAGS"
62+
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
63+
export LDFLAGS
64+
65+
AC_CACHE_CHECK(whether the Boost::Regex library is available,
66+
ax_cv_boost_regex,
67+
[AC_LANG_PUSH([C++])
68+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
69+
]],
70+
[[boost::regex r(); return 0;]])],
71+
ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
72+
AC_LANG_POP([C++])
73+
])
74+
if test "x$ax_cv_boost_regex" = "xyes"; then
75+
AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
76+
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
77+
if test "x$ax_boost_user_regex_lib" = "x"; then
78+
for libextension in `ls $BOOSTLIBDIR/libboost_regex*.so* $BOOSTLIBDIR/libboost_regex*.dylib* $BOOSTLIBDIR/libboost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.dylib.*;\1;' -e 's;^lib\(boost_regex.*\)\.a.*$;\1;'` ; do
79+
ax_lib=${libextension}
80+
AC_CHECK_LIB($ax_lib, exit,
81+
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
82+
[link_regex="no"])
83+
done
84+
if test "x$link_regex" != "xyes"; then
85+
for libextension in `ls $BOOSTLIBDIR/boost_regex*.dll* $BOOSTLIBDIR/boost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a.*$;\1;'` ; do
86+
ax_lib=${libextension}
87+
AC_CHECK_LIB($ax_lib, exit,
88+
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
89+
[link_regex="no"])
90+
done
91+
fi
92+
93+
else
94+
for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do
95+
AC_CHECK_LIB($ax_lib, main,
96+
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
97+
[link_regex="no"])
98+
done
99+
fi
100+
if test "x$ax_lib" = "x"; then
101+
AC_MSG_ERROR(Could not find a version of the Boost::Regex library!)
102+
fi
103+
if test "x$link_regex" != "xyes"; then
104+
AC_MSG_ERROR(Could not link against $ax_lib !)
105+
fi
106+
fi
107+
108+
CPPFLAGS="$CPPFLAGS_SAVED"
109+
LDFLAGS="$LDFLAGS_SAVED"
110+
fi
111+
])

test/util.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <set>
22
#include <locale>
33
#include <stdexcept>
4-
#include <regex>
4+
#include <boost/regex.hpp>
55
#include <boost/property_tree/json_parser.hpp>
66

77
#include <valhalla/midgard/logging.h>
@@ -187,9 +187,9 @@ void try_get_formatted_date(const std::string& date_time,
187187
for(const auto& phrase : instruction.second.get_child("phrases")) {
188188
const auto& other_phrase = other_inst.get<std::string>("phrases." + phrase.first);
189189
//parse out tags from phrase, and check for them
190-
std::smatch m;
191-
std::regex e("(<[A-Z_0-9]+>)");
192-
if(std::regex_search(phrase.second.get_value<std::string>(), m, e))
190+
boost::smatch m;
191+
boost::regex e("(<[A-Z_0-9]+>)");
192+
if(boost::regex_search(phrase.second.get_value<std::string>(), m, e))
193193
for(const auto& tag : m)
194194
if(other_phrase.find(tag.str()) == std::string::npos)
195195
throw std::runtime_error("Couldn't find " + tag.str() + " in " +

0 commit comments

Comments
 (0)