File Revert-Replaced-Boost-regex-dependency-with-C-11-reg.patch of Package twinkle

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 86a80330f2df..170fea8e1bbc 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(Ucommon REQUIRED)
 find_package(Commoncpp REQUIRED)
 find_package(Ccrtp REQUIRED)
diff --git a/README.md b/README.md
index 6c1ea7a70133..0bce84bd3f0b 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ To compile Twinkle you need the following libraries:
 * ucommon [GNU uCommon 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 c2d135b17e27..df662bc341f3 100644
--- a/src/call_history.cpp
+++ b/src/call_history.cpp
@@ -295,9 +295,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 f20a0d9faece..978dd07ddea4 100644
--- a/src/gui/userprofileform.cpp
+++ b/src/gui/userprofileform.cpp
@@ -597,7 +597,7 @@ void UserProfileForm::populate()
     int j = 0;
     for (list<t_number_conversion>::iterator i = conversions.begin(); i != conversions.end(); 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);
@@ -711,7 +711,7 @@ list<t_number_conversion> UserProfileForm::get_number_conversions()
             item = conversionListView->item(i, 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 b42be6ac70f0..ab2a9fd510c0 100644
--- a/src/mwi/simple_msg_sum_body.cpp
+++ b/src/mwi/simple_msg_sum_body.cpp
@@ -19,7 +19,7 @@
 
 #include <iostream>
 #include <cstdlib>
-#include <regex>
+#include <boost/regex.hpp>
 
 #include "protocol.h"
 #include "util.h"
@@ -42,20 +42,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 464bd8823451..6a4731789b40 100644
--- a/src/user.cpp
+++ b/src/user.cpp
@@ -308,7 +308,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);
@@ -2831,7 +2831,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;
@@ -3100,10 +3100,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 df1fd0d8f6e4..eb6c2fdc7d63 100644
--- a/src/user.h
+++ b/src/user.h
@@ -29,7 +29,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;
@@ -90,10 +90,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.10.1

openSUSE Build Service is sponsored by