From 97b1acbb27ca601435d64beaa3193b6625535761 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 2 Dec 2018 23:45:18 +0000 Subject: [PATCH 1/3] Add check for compiler verision as REGEX is not supported properly in GCC versions < 4.9 --- Makefile | 2 +- REGEX.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c13b5da..9354612 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc CXX = g++ -CFLAGS = -g -O3 -Wall -std=c++0x -pthread +CFLAGS = -g -O3 -Wall -std=c++0x -pthread -lrt LIBS = -lm -lpthread LDFLAGS = -g diff --git a/REGEX.cpp b/REGEX.cpp index 9653f27..498938a 100644 --- a/REGEX.cpp +++ b/REGEX.cpp @@ -24,6 +24,7 @@ #include #include + CREGEX::CREGEX(const std::string& regexFile) : m_regexFile(regexFile), m_regex() @@ -32,6 +33,13 @@ m_regex() bool CREGEX::load() { +#if defined(__GNUC__) && (__GNUC__ <= 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 9) + LogError("REGEX is not properly supported in GCC vesions below 4.9. Not loading REGEX"); + return false; +} +#else + + FILE* fp = ::fopen(m_regexFile.c_str(), "rt"); if (fp != NULL) { char buffer[100U]; @@ -68,6 +76,8 @@ bool CREGEX::load() return true; } +#endif + std::vector CREGEX::get() { return(m_regex); From 8186eff3df91c5600784ed76cde053ca65eefd3e Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 3 Dec 2018 09:58:17 +0000 Subject: [PATCH 2/3] Add comment in code to explain why we exclude REGEX for old GCC versions --- REGEX.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/REGEX.cpp b/REGEX.cpp index 498938a..b10168f 100644 --- a/REGEX.cpp +++ b/REGEX.cpp @@ -32,6 +32,11 @@ m_regex() } bool CREGEX::load() +/* Older versions of GCC appear to support REGEX but silently fail to match. Even + * though the headers exist and the code compiles and runs cleanly. The below #if block + * stops the REGEXs being loaded in these cases, effectively disabling REGEX functionality. + * The loading code is replaced with a log entry to show the user this has happened. +*/ { #if defined(__GNUC__) && (__GNUC__ <= 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 9) LogError("REGEX is not properly supported in GCC vesions below 4.9. Not loading REGEX"); From 2d499d90c168d8de6326917fd06dc7c5f521cc62 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 3 Dec 2018 11:26:40 +0000 Subject: [PATCH 3/3] Remove -lrt from makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9354612..c13b5da 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc CXX = g++ -CFLAGS = -g -O3 -Wall -std=c++0x -pthread -lrt +CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lm -lpthread LDFLAGS = -g