From: Michal Kubecek <mkubecek@suse.cz>
Date: Tue, 14 Jul 2015 08:45:28 +0200
Subject: Revert "Replaced Boost regex dependency with C++11 regex"
Patch-mainline: Never, workaround for gcc 4.8 bug

This reverts commit 4ec69237e6b777df818bc95bd46a58448340b30d.

As std::regex is broken in gcc < 4.9, we need to stick with boost regex
for gcc 4.8 builds.
---
 CMakeLists.txt                   |  1 +
 README.md                        |  1 +
 src/CMakeLists.txt               |  1 +
 src/call_history.cpp             |  6 +++---
 src/gui/numberconversionform.cpp |  4 ++--
 src/gui/userprofileform.cpp      |  4 ++--
 src/mwi/simple_msg_sum_body.cpp  | 20 ++++++++++----------
 src/user.cpp                     |  8 ++++----
 src/user.h                       |  8 ++++----
 9 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8841729dcf6..b6e2f92f0409 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,7 @@ find_package(LibSndfile REQUIRED)
 find_package(Readline REQUIRED)
 find_package(BISON REQUIRED)
 find_package(FLEX REQUIRED)
+find_package(Boost REQUIRED COMPONENTS regex)
 find_package(Commoncpp REQUIRED)
 find_package(Ccrtp REQUIRED)
 find_package(Ucommon REQUIRED)
diff --git a/README.md b/README.md
index 34d690865f8c..c539cf76b8d0 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ To compile Twinkle you need the following libraries:
 * commoncpp2 and ucommon (version >= 1.4.2) - [GNU Common C++](http://www.gnu.org/software/commoncpp/)
 * ccRTP (version >= 1.5.0) [GNU RTP Stack](http://www.gnu.org/software/ccrtp/)
 * libxml2
+* Boost regex
 * libsndfile
 * Qt 5
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 01f4997e7900..036208074396 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -93,6 +93,7 @@ set(twinkle_LIBS
 	${COMMONCPP_LIBRARIES}
 	${UCOMMON_LIBRARIES}
 	${LIBSNDFILE_LIBRARY}
+	${Boost_LIBRARIES}
 	${ALSA_LIBRARY}
 	${G729_LIBRARY}
 )
diff --git a/src/call_history.cpp b/src/call_history.cpp
index cf9ff5cbebd4..4fa4af789f11 100644
--- a/src/call_history.cpp
+++ b/src/call_history.cpp
@@ -296,9 +296,9 @@ bool t_call_record::populate_from_file_record(const vector<string> &v) {
 	// Check number of fields
 	if (v.size() != 20) return false;
 	
-    time_start = std::stoul(v[0], NULL, 10);
-    time_answer = std::stoul(v[1], NULL, 10);
-    time_end = std::stoul(v[2], NULL, 10);
+	time_start = strtoul(v[0].c_str(), NULL, 10);
+	time_answer = strtoul(v[1].c_str(), NULL, 10);
+	time_end = strtoul(v[2].c_str(), NULL, 10);
 	
 	if (!set_direction(v[3])) return false;
 	
diff --git a/src/gui/numberconversionform.cpp b/src/gui/numberconversionform.cpp
index f8ae64c59a30..af95dd2ff1a8 100644
--- a/src/gui/numberconversionform.cpp
+++ b/src/gui/numberconversionform.cpp
@@ -67,8 +67,8 @@ void NumberConversionForm::validate()
 	}
 
 	try {
-        std::regex re(expr.toStdString());
-    } catch (std::regex_error) {
+        boost::regex re(expr.toStdString());
+	} catch (boost::bad_expression) {
 		((t_gui *)ui)->cb_show_msg(this,
             tr("Invalid regular expression.").toStdString(), MSG_CRITICAL);
 		exprLineEdit->setFocus();
diff --git a/src/gui/userprofileform.cpp b/src/gui/userprofileform.cpp
index 788d87b1b983..d7f39a0091ac 100644
--- a/src/gui/userprofileform.cpp
+++ b/src/gui/userprofileform.cpp
@@ -598,7 +598,7 @@ void UserProfileForm::populate()
     int j = 0;
     for (list<t_number_conversion>::reverse_iterator i = conversions.rbegin(); i != conversions.rend(); i++, j++)
 	{
-        QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(i->re));
+        QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(i->re.str()));
         conversionListView->setItem(j, 0, item);
         item = new QTableWidgetItem(QString::fromStdString(i->fmt));
         conversionListView->setItem(j, 1, item);
@@ -712,7 +712,7 @@ list<t_number_conversion> UserProfileForm::get_number_conversions()
             item = conversionListView->item(0, 1);
             c.fmt = item->text().toStdString();
 			conversions.push_back(c);
-        } catch (std::regex_error) {
+		} catch (boost::bad_expression) {
 			// Should never happen as validity has been
 			// checked already. Just being defensive here.
 		}
diff --git a/src/mwi/simple_msg_sum_body.cpp b/src/mwi/simple_msg_sum_body.cpp
index 1d206092009e..33683f7a07ee 100644
--- a/src/mwi/simple_msg_sum_body.cpp
+++ b/src/mwi/simple_msg_sum_body.cpp
@@ -20,7 +20,7 @@
 
 #include <iostream>
 #include <cstdlib>
-#include <regex>
+#include <boost/regex.hpp>
 
 #include "protocol.h"
 #include "util.h"
@@ -43,20 +43,20 @@ bool t_msg_summary::parse(const string &s) {
 	// msg-summary-line = message-context-class HCOLON newmsgs SLASH oldmsgs
         //                    [ LPAREN new-urgentmsgs SLASH old-urgentmsgs RPAREN ]
         // This regex matches the part after HCOLON
-    std::regex re("(\\d+)\\s*/\\s*(\\d+)(?:\\s*\\((\\d+)\\s*/\\s*(\\d+)\\s*\\))?");
+	boost::regex re("(\\d+)\\s*/\\s*(\\d+)(?:\\s*\\((\\d+)\\s*/\\s*(\\d+)\\s*\\))?");
 	
-    std::smatch m;
-    if (!std::regex_match(s, m, re)) return false;
+	boost::smatch m;
+	if (!boost::regex_match(s, m, re)) return false;
 	
 	if (m.size() == 3) {
-        newmsgs = std::stoul(m.str(1), NULL, 10);
-        oldmsgs = std::stoul(m.str(2), NULL, 10);
+		newmsgs = strtoul(m.str(1).c_str(), NULL, 10);
+		oldmsgs = strtoul(m.str(2).c_str(), NULL, 10);
 		return true;
 	} else if (m.size() == 5) {
-        newmsgs = std::stoul(m.str(1), NULL, 10);
-        oldmsgs = std::stoul(m.str(2), NULL, 10);
-        newmsgs_urgent = std::stoul(m.str(3), NULL, 10);
-        oldmsgs_urgent = std::stoul(m.str(4), NULL, 10);
+		newmsgs = strtoul(m.str(1).c_str(), NULL, 10);
+		oldmsgs = strtoul(m.str(2).c_str(), NULL, 10);
+		newmsgs_urgent = strtoul(m.str(3).c_str(), NULL, 10);
+		oldmsgs_urgent = strtoul(m.str(4).c_str(), NULL, 10);
 		return true;
 	}
 	
diff --git a/src/user.cpp b/src/user.cpp
index 206cf7ef1719..a6a2a95a7c5e 100644
--- a/src/user.cpp
+++ b/src/user.cpp
@@ -309,7 +309,7 @@ bool t_user::parse_num_conversion(const string &value, t_number_conversion &c) {
 	try {
 		c.re.assign(l[0]);
 		c.fmt = l[1];
-    } catch (std::regex_error) {
+	} catch (boost::bad_expression) {
 		// Invalid regular expression
 		log_file->write_header("t_user::parse_num_conversion", 
 				LOG_NORMAL, LOG_WARNING);
@@ -2832,7 +2832,7 @@ bool t_user::write_config(const string &filename, string &error_msg) {
 	     i != number_conversions.end(); i++)
 	{
 		config << FLD_NUMBER_CONVERSION << '=';
-        config << escape(i->re, ',');
+		config << escape(i->re.str(), ',');
 		config << ',';
 		config << escape(i->fmt, ',');
 		config << endl;
@@ -3101,10 +3101,10 @@ string t_user::convert_number(const string &number, const list<t_number_conversi
 	for (list<t_number_conversion>::const_iterator i = l.begin();
 	     i != l.end(); i++)
 	{
-        std::smatch m;
+		boost::smatch m;
 		
 		try {
-            if (std::regex_match(number, m, std::regex(i->re))) {
+			if (boost::regex_match(number, m, i->re)) {
 				string result = m.format(i->fmt);
 			
 				log_file->write_header("t_user::convert_number", 
diff --git a/src/user.h b/src/user.h
index 2e9c2ca9b2a6..f78652d4a35b 100644
--- a/src/user.h
+++ b/src/user.h
@@ -30,7 +30,7 @@
 #include "audio/audio_codecs.h"
 #include "sockets/url.h"
 #include "threads/mutex.h"
-#include <regex>
+#include "boost/regex.hpp"
 
 // Forward declaration
 class t_request;
@@ -91,10 +91,10 @@ enum t_g726_packing {
 };
 
 struct t_number_conversion {
-    string re;
-    string fmt;
+	boost::regex	re;
+	string		fmt;
 	
-    string str(void) const { return re + " --> " + fmt; }
+	string str(void) const { return re.str() + " --> " + fmt; }
 };
 
 
-- 
2.8.2

