aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-22 22:10:40 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-22 22:12:20 +0100
commited5b7ea290242c2207b929bf836f60971c76e1f4 (patch)
tree205a41b6528231e57c970bfff0e63864dd8a780a
parent6e0588bd0ba3bbdda96412ea8f3d91191e681b20 (diff)
downloadpaludis-ed5b7ea290242c2207b929bf836f60971c76e1f4.tar.gz
paludis-ed5b7ea290242c2207b929bf836f60971c76e1f4.tar.xz
Use pcrecpp rather than pcre++.
pcre++ has threading issues. Fixes: ticket:743
-rw-r--r--configure.ac25
-rw-r--r--paludis/repositories/e/qa/Makefile.am4
-rw-r--r--paludis/repositories/e/qa/default_functions.cc44
-rw-r--r--paludis/repositories/e/qa/deprecated_functions.cc16
-rw-r--r--paludis/repositories/e/qa/function_keyword.cc6
-rw-r--r--paludis/repositories/e/qa/header.cc21
-rw-r--r--paludis/repositories/e/qa/kv_variables.cc12
-rw-r--r--paludis/repositories/e/qa/root_variable.cc16
-rw-r--r--paludis/repositories/e/qa/subshell_die.cc10
-rw-r--r--paludis/repositories/e/qa/variable_assigns.cc39
-rw-r--r--src/clients/inquisitio/Makefile.am6
-rw-r--r--src/clients/inquisitio/pcre_matcher.cc17
-rw-r--r--src/clients/inquisitio/pcre_matcher.hh9
-rw-r--r--src/clients/qualudis/Makefile.am4
14 files changed, 120 insertions, 109 deletions
diff --git a/configure.ac b/configure.ac
index 78ca74b..045e02d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -411,7 +411,7 @@ enum class C : long { c };
dnl }}}
need_xml_check=
-need_pcrepp_check=
+need_pcrecpp_check=
need_syck_check=
need_gem_check=
@@ -902,13 +902,13 @@ AM_CONDITIONAL([HAVE_HTMLTIDY], test "x$HAVE_HTMLTIDY" = "xyes")
dnl {{{ check for whether to build qa stuff
AC_MSG_CHECKING([whether to build QA tools])
AC_ARG_ENABLE([qa],
- AS_HELP_STRING([--enable-qa], [Build QA things (needs pcre++)]),
+ AS_HELP_STRING([--enable-qa], [Build QA things (needs pcrecpp)]),
[ENABLE_QA=$enableval
AC_MSG_RESULT([$enableval])],
[ENABLE_QA=no
AC_MSG_RESULT([no])])
if test x"$ENABLE_QA" = "xyes" ; then
- need_pcrepp_check=yes
+ need_pcrecpp_check=yes
AC_DEFINE([ENABLE_RUBY_QA], [1], [Enable QA support in ruby])
AC_DEFINE([ENABLE_QA], [1], [Build QA things])
fi
@@ -1405,7 +1405,7 @@ AC_SUBST([ALL_CLIENTS_HTML])
AC_SUBST([BUILD_CLIENTS])
if echo $clients | tr ' ' '\n' | grep '^inquisitio$' >/dev/null ; then
- need_pcrepp_check=yes
+ need_pcrecpp_check=yes
fi
dnl }}}
@@ -1421,17 +1421,12 @@ AC_SUBST([NEED_XML])
AM_CONDITIONAL([NEED_XML], test "x$NEED_XML" = "xyes")
dnl }}}
-dnl {{{ pcrepp check
-if test "x$need_pcrepp_check" = "xyes" ; then
- AC_CHECK_PROG(HAVE_PRCEPLUSPLUS, [pcre++-config], [yes], [no])
- if test x"$HAVE_PRCEPLUSPLUS" = "xyes" ; then
- PCREPLUSPLUS_CFLAGS=`pcre++-config --cflags`
- AC_SUBST(PCREPLUSPLUS_CFLAGS)
- PCREPLUSPLUS_LIBS=`pcre++-config --libs`
- AC_SUBST(PCREPLUSPLUS_LIBS)
- else
- AC_MSG_ERROR([pcre++ (http://www.daemon.de/PCRE) is required if --enable-qa or --with-clients=inquisitio is used])
- fi
+dnl {{{ pcrecpp check
+if test "x$need_pcrecpp_check" = "xyes" ; then
+ PKG_CHECK_MODULES(PCRECPPDEPS, [libpcrecpp >= 7.8], [],
+ [AC_MSG_ERROR([pcrecpp (http://www.pcre.org/) is required if --enable-qa or --with-clients=inquisitio is used])])
+ AC_SUBST(PCRECPPDEPS_CFLAGS)
+ AC_SUBST(PCRECPPDEPS_LIBS)
fi
dnl }}}
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 2473745..aae19ec 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -5,7 +5,7 @@ MAINTAINERCLEANFILES = Makefile.in
AM_CXXFLAGS = \
-I$(top_srcdir) -I$(top_builddir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ \
- $(PCREPLUSPLUS_CFLAGS)
+ $(PCRECPPDEPS_CFLAGS)
DEFS = \
-DSYSCONFDIR=\"$(sysconfdir)\" \
@@ -105,7 +105,7 @@ libpaludiserepositoryqa_@PALUDIS_PC_SLOT@_la_SOURCES = \
libpaludiserepositoryqa_@PALUDIS_PC_SLOT@_la_LDFLAGS = \
-version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 \
- $(PCREPLUSPLUS_LIBS)
+ $(PCRECPPDEPS_LIBS)
libpaludiserepositoryqa_@PALUDIS_PC_SLOT@_la_LIBADD = \
$(top_builddir)/paludis/repositories/e/libpaludiserepository_@PALUDIS_PC_SLOT@.la \
diff --git a/paludis/repositories/e/qa/default_functions.cc b/paludis/repositories/e/qa/default_functions.cc
index 5089d62..c4235be 100644
--- a/paludis/repositories/e/qa/default_functions.cc
+++ b/paludis/repositories/e/qa/default_functions.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,7 +20,7 @@
#include "default_functions.hh"
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <sstream>
using namespace paludis;
@@ -45,14 +45,14 @@ paludis::erepository::default_functions_check(
{
Context context("When performing check '" + name + "' using default_functions_check on '" + stringify(*id) + "':");
- pcrepp::Pcre::Pcre r_echo("^\\s*(echo|einfo|ewarn)[^|<>]*$");
- pcrepp::Pcre::Pcre r_colon("^\\s*:");
- pcrepp::Pcre::Pcre r_true("^\\s*true");
- pcrepp::Pcre::Pcre r_comment("^\\s*#");
- pcrepp::Pcre::Pcre r_econf("^\\s*econf( *\\|\\| *die.*)?$");
- pcrepp::Pcre::Pcre r_emake("^\\s*emake( *\\|\\| *die.*)?$");
- pcrepp::Pcre::Pcre r_unpack("^\\s*unpack *([$]A|[$][{]A[}]|\"[$][{]A[}]\"|[$][{]A[}])( *\\|\\| *die.*)?$");
- pcrepp::Pcre::Pcre r_cd_s("^\\s*cd *([$]S|[$][{]S[}]|\"[$][{]S[}]\"|[$][{]S[}])( *\\|\\| *die.*)?$");
+ pcrecpp::RE r_echo("^\\s*(echo|einfo|ewarn)[^|<>]*$");
+ pcrecpp::RE r_colon("^\\s*:");
+ pcrecpp::RE r_true("^\\s*true");
+ pcrecpp::RE r_comment("^\\s*#");
+ pcrecpp::RE r_econf("^\\s*econf( *\\|\\| *die.*)?$");
+ pcrecpp::RE r_emake("^\\s*emake( *\\|\\| *die.*)?$");
+ pcrecpp::RE r_unpack("^\\s*unpack *([$]A|[$][{]A[}]|\"[$][{]A[}]\"|[$][{]A[}])( *\\|\\| *die.*)?$");
+ pcrecpp::RE r_cd_s("^\\s*cd *([$]S|[$][{]S[}]|\"[$][{]S[}]\"|[$][{]S[}])( *\\|\\| *die.*)?$");
Log::get_instance()->message("e.qa.default_functions_check", ll_debug, lc_context) << "default_functions '"
<< entry << "', '" << *id << "', '" << name << "'";
@@ -87,17 +87,17 @@ paludis::erepository::default_functions_check(
}
else if (line.empty())
;
- else if (r_econf.search(line))
+ else if (r_econf.PartialMatch(line))
;
- else if (r_emake.search(line))
+ else if (r_emake.PartialMatch(line))
;
- else if (r_echo.search(line))
+ else if (r_echo.PartialMatch(line))
;
- else if (r_colon.search(line))
+ else if (r_colon.PartialMatch(line))
;
- else if (r_true.search(line))
+ else if (r_true.PartialMatch(line))
;
- else if (r_comment.search(line))
+ else if (r_comment.PartialMatch(line))
;
else
src_compile_changed = true;
@@ -115,17 +115,17 @@ paludis::erepository::default_functions_check(
}
else if (line.empty())
;
- else if (r_unpack.search(line))
+ else if (r_unpack.PartialMatch(line))
;
- else if (r_cd_s.search(line))
+ else if (r_cd_s.PartialMatch(line))
;
- else if (r_echo.search(line))
+ else if (r_echo.PartialMatch(line))
;
- else if (r_colon.search(line))
+ else if (r_colon.PartialMatch(line))
;
- else if (r_true.search(line))
+ else if (r_true.PartialMatch(line))
;
- else if (r_comment.search(line))
+ else if (r_comment.PartialMatch(line))
;
else
src_unpack_changed = true;
diff --git a/paludis/repositories/e/qa/deprecated_functions.cc b/paludis/repositories/e/qa/deprecated_functions.cc
index 28e0119..166f0a6 100644
--- a/paludis/repositories/e/qa/deprecated_functions.cc
+++ b/paludis/repositories/e/qa/deprecated_functions.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -33,7 +33,7 @@
#include <string>
#include <sstream>
#include <utility>
-#include <pcre++.h>
+#include <pcrecpp.h>
using namespace paludis;
using namespace paludis::erepository;
@@ -85,13 +85,13 @@ paludis::erepository::deprecated_functions_check(
{
Context context("When performing check '" + name + "' using deprecated_functions_check on '" + (id ? stringify(*id) : stringify(entry)) + "':");
- pcrepp::Pcre::Pcre r_comment("^\\s*#");
- std::list<std::pair<std::string, pcrepp::Pcre::Pcre> > deprecated_functions;
+ pcrecpp::RE r_comment("^\\s*#");
+ std::list<std::pair<std::string, pcrecpp::RE> > deprecated_functions;
for (std::list<std::string>::const_iterator
it(DeprecatedFunctions::get_instance()->deprecated_functions.begin()),
it_end(DeprecatedFunctions::get_instance()->deprecated_functions.end());
it_end != it; ++it)
- deprecated_functions.push_back(std::make_pair(*it, pcrepp::Pcre::Pcre(*it)));
+ deprecated_functions.push_back(std::make_pair(*it, pcrecpp::RE(*it)));
if (id)
Log::get_instance()->message("e.qa.deprecated_functions_check", ll_debug, lc_context) << "deprecated_functions '"
@@ -108,13 +108,13 @@ paludis::erepository::deprecated_functions_check(
{
++line_number;
- if (s.empty() || r_comment.search(s))
+ if (s.empty() || r_comment.PartialMatch(s))
continue;
- for (std::list<std::pair<std::string, pcrepp::Pcre::Pcre> >::iterator
+ for (std::list<std::pair<std::string, pcrecpp::RE> >::iterator
r(deprecated_functions.begin()), r_end(deprecated_functions.end()) ;
r != r_end ; ++r )
- if (r->second.search(s))
+ if (r->second.PartialMatch(s))
reporter.message(with_id(QAMessage(entry, qaml_normal, name,
"Deprecated call to '" + r->first + "' on line " + stringify(line_number)), id));
}
diff --git a/paludis/repositories/e/qa/function_keyword.cc b/paludis/repositories/e/qa/function_keyword.cc
index 4e2e6ec..c6c5def 100644
--- a/paludis/repositories/e/qa/function_keyword.cc
+++ b/paludis/repositories/e/qa/function_keyword.cc
@@ -20,7 +20,7 @@
#include "function_keyword.hh"
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <list>
#include <sstream>
@@ -45,7 +45,7 @@ paludis::erepository::function_keyword_check(
{
Context context("When performing check '" + name + "' using function_keyword_check on '" + (id ? stringify(*id) : stringify(entry)) + "':");
- pcrepp::Pcre::Pcre r_function("^function +[^ ]+ *(\\(\\))? *{?");
+ pcrecpp::RE r_function("^function +[^ ]+ *(\\(\\))? *{?");
if (id)
Log::get_instance()->message("e.qa.function_keyword_check", ll_debug, lc_context) << "function_keyword '"
@@ -65,7 +65,7 @@ paludis::erepository::function_keyword_check(
if (s.empty())
continue;
- if (r_function.search(s))
+ if (r_function.PartialMatch(s))
reporter.message(with_id(QAMessage(entry, qaml_minor, name, "Use of the keyword 'function' on line " + stringify(line_number)), id));
}
diff --git a/paludis/repositories/e/qa/header.cc b/paludis/repositories/e/qa/header.cc
index a37710f..02c5ed5 100644
--- a/paludis/repositories/e/qa/header.cc
+++ b/paludis/repositories/e/qa/header.cc
@@ -20,7 +20,7 @@
#include "header.hh"
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <time.h>
#include <vector>
#include <sstream>
@@ -53,10 +53,10 @@ paludis::erepository::header_check(
Log::get_instance()->message("e.qa.header_check", ll_debug, lc_context) << "header '"
<< entry << "', '" << name << "'";
- pcrepp::Pcre::Pcre r_licence("^# Distributed under the terms of the GNU General Public License v2$");
+ pcrecpp::RE r_licence("^# Distributed under the terms of the GNU General Public License v2$");
// Match both CVS tag and extract year.[0]
- pcrepp::Pcre::Pcre r_cvs_header("^#\\s*\\$Header.*\\s(\\d{4})/\\d{2}/\\d{2}\\s.*\\$$");
- pcrepp::Pcre::Pcre r_cvs_empty_header("^#\\s*\\$Header:\\s*\\$$");
+ pcrecpp::RE r_cvs_header("^#\\s*\\$Header.*\\s(\\d{4})/\\d{2}/\\d{2}\\s.*\\$$");
+ pcrecpp::RE r_cvs_empty_header("^#\\s*\\$Header:\\s*\\$$");
std::stringstream ff(content);
@@ -70,20 +70,21 @@ paludis::erepository::header_check(
do
{
- if (! r_licence.search(lines[1]))
+ if (! r_licence.PartialMatch(lines[1]))
reporter.message(with_id(QAMessage(entry, qaml_normal, name, "Wrong licence statement in line 2"), id));
std::string year;
// Check line 3 before line 1 to extract date of last commit
- if (r_cvs_empty_header.search(lines[2]))
+ if (r_cvs_empty_header.PartialMatch(lines[2]))
{
time_t now(time(NULL));
struct tm now_struct;
year = stringify(localtime_r(&now, &now_struct)->tm_year + 1900);
}
- else if (r_cvs_header.search(lines[2]))
- year = r_cvs_header[0];
+ else if (r_cvs_header.PartialMatch(lines[2], &year))
+ {
+ }
else
{
reporter.message(with_id(QAMessage(entry, qaml_minor, name, "Unknown CVS tag in line 3"), id));
@@ -91,9 +92,9 @@ paludis::erepository::header_check(
}
Log::get_instance()->message("e.qa.header_check.year", ll_debug, lc_context) << "Expected copyright year is " << year;
- pcrepp::Pcre::Pcre r_copyright("^# Copyright ((1999|200\\d)-)?" + year + " Gentoo Foundation$");
+ pcrecpp::RE r_copyright("^# Copyright ((1999|200\\d)-)?" + year + " Gentoo Foundation$");
- if (! r_copyright.search(lines[0]))
+ if (! r_copyright.PartialMatch(lines[0]))
reporter.message(with_id(QAMessage(entry, qaml_normal, name, "Wrong copyright assignment in line 1, possibly date related"), id));
} while (false);
diff --git a/paludis/repositories/e/qa/kv_variables.cc b/paludis/repositories/e/qa/kv_variables.cc
index 8860cdb..7083329 100644
--- a/paludis/repositories/e/qa/kv_variables.cc
+++ b/paludis/repositories/e/qa/kv_variables.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,7 @@
#include <paludis/qa.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <list>
#include <sstream>
@@ -37,8 +37,8 @@ paludis::erepository::kv_variables_check(
{
Context context("When performing check '" + name + "' using kv_variables on '" + stringify(*id) + "':");
- pcrepp::Pcre::Pcre r_global("^[a-zA-Z0-9\\_]+=.*\\$[{}]?KV");
- pcrepp::Pcre::Pcre r_detect_version("^detect_version$");
+ pcrecpp::RE r_global("^[a-zA-Z0-9\\_]+=.*\\$[{}]?KV");
+ pcrecpp::RE r_detect_version("^detect_version$");
Log::get_instance()->message("e.qa.kv_variables_check", ll_debug, lc_context) << "kv_variables '"
<< entry << "', '" << *id << "', '" << name << "'";
@@ -51,10 +51,10 @@ paludis::erepository::kv_variables_check(
{
++line_number;
- if (r_detect_version.search(line))
+ if (r_detect_version.PartialMatch(line))
break;
- if (r_global.search(line))
+ if (r_global.PartialMatch(line))
reporter.message(QAMessage(entry, qaml_normal, name, "KV variable with no detect_version on line "
+ stringify(line_number) + ": " + strip_leading(line, " \t")));
}
diff --git a/paludis/repositories/e/qa/root_variable.cc b/paludis/repositories/e/qa/root_variable.cc
index 62ea927..9462319 100644
--- a/paludis/repositories/e/qa/root_variable.cc
+++ b/paludis/repositories/e/qa/root_variable.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,7 @@
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
#include <paludis/util/strip.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <list>
#include <sstream>
@@ -46,9 +46,9 @@ paludis::erepository::root_variable_check(
{
Context context("When performing check '" + name + "' using root_variable_check on '" + stringify(*id) + "':");
- pcrepp::Pcre::Pcre r_root("\\$[{]?ROOT[}]?([^=a-zA-Z0-9]|$)");
- pcrepp::Pcre::Pcre r_start("^src_");
- pcrepp::Pcre::Pcre r_end("^}");
+ pcrecpp::RE r_root("\\$[{]?ROOT[}]?([^=a-zA-Z0-9]|$)");
+ pcrecpp::RE r_start("^src_");
+ pcrecpp::RE r_end("^}");
Log::get_instance()->message("e.qa.root_variable_check", ll_debug, lc_context) << "root_variable '"
<< entry << "', '" << *id << "', '" << name << "'";
@@ -67,7 +67,7 @@ paludis::erepository::root_variable_check(
{
case st_default:
{
- if (r_start.search(line))
+ if (r_start.PartialMatch(line))
{
state = st_in_src;
func = line;
@@ -79,9 +79,9 @@ paludis::erepository::root_variable_check(
case st_in_src:
{
- if (r_end.search(line))
+ if (r_end.PartialMatch(line))
state = st_default;
- else if (r_root.search(line))
+ else if (r_root.PartialMatch(line))
reporter.message(QAMessage(entry, qaml_maybe, name, "ROOT abuse in " + func + " on line "
+ stringify(line_number) + ": " + strip_leading(line, " \t"))
.with_associated_id(id));
diff --git a/paludis/repositories/e/qa/subshell_die.cc b/paludis/repositories/e/qa/subshell_die.cc
index e6a493d..36eee07 100644
--- a/paludis/repositories/e/qa/subshell_die.cc
+++ b/paludis/repositories/e/qa/subshell_die.cc
@@ -20,7 +20,7 @@
#include <paludis/repositories/e/qa/subshell_die.hh>
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <list>
#include <sstream>
@@ -45,8 +45,8 @@ paludis::erepository::subshell_die_check(
{
Context context("When performing check '" + name + "' using subshell_die_check on '" + (id ? stringify(*id) : stringify(entry)) + "':");
- pcrepp::Pcre::Pcre r_comment("^\\s*#");
- pcrepp::Pcre::Pcre r_subshell_die("\\([^\\)]*\\bdie\\b");
+ pcrecpp::RE r_comment("^\\s*#");
+ pcrecpp::RE r_subshell_die("\\([^\\)]*\\bdie\\b");
if (id)
Log::get_instance()->message("e.qa.subshell_die_check", ll_debug, lc_context) << "subshell_die '"
@@ -63,10 +63,10 @@ paludis::erepository::subshell_die_check(
{
++line;
- if (s.empty() || r_comment.search(s))
+ if (s.empty() || r_comment.PartialMatch(s))
continue;
- if (r_subshell_die.search(s))
+ if (r_subshell_die.PartialMatch(s))
{
reporter.message(with_id(QAMessage(entry, qaml_normal, name, "Invalid call of 'die' within subshell on line "
+ stringify(line)), id));
diff --git a/paludis/repositories/e/qa/variable_assigns.cc b/paludis/repositories/e/qa/variable_assigns.cc
index c1d852c..387d47b 100644
--- a/paludis/repositories/e/qa/variable_assigns.cc
+++ b/paludis/repositories/e/qa/variable_assigns.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,9 +20,10 @@
#include "variable_assigns.hh"
#include <paludis/qa.hh>
#include <paludis/util/log.hh>
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <list>
#include <sstream>
+#include <map>
using namespace paludis;
@@ -45,17 +46,17 @@ paludis::erepository::variable_assigns_check(
{
Context context("When performing check '" + name + "' using variable_assigns_check on '" + (id ? stringify(*id) : stringify(entry)) + "':");
- pcrepp::Pcre::Pcre r_comment("^\\s*#");
- pcrepp::Pcre::Pcre r_make_line("^\\s*e?make\\b");
- pcrepp::Pcre::Pcre r_make_continuation_line("\\\\\\s*$");
- pcrepp::Pcre::Pcre r_strip_quotes("(\"(\\\\.|[^\"])+\"|'(\\\\.|[^'])+')", "g");
+ pcrecpp::RE r_comment("^\\s*#");
+ pcrecpp::RE r_make_line("^\\s*e?make\\b");
+ pcrecpp::RE r_make_continuation_line("\\\\\\s*$");
+ pcrecpp::RE r_strip_quotes("(\"(\\\\.|[^\"])+\"|'(\\\\.|[^'])+')");
- std::map<std::string, pcrepp::Pcre::Pcre> r_vars;
- r_vars.insert(std::make_pair("CFLAGS", pcrepp::Pcre::Pcre("\\bCFLAGS=")));
- r_vars.insert(std::make_pair("CXXFLAGS", pcrepp::Pcre::Pcre("\\bCXXFLAGS=")));
- r_vars.insert(std::make_pair("CPPFLAGS", pcrepp::Pcre::Pcre("\\bCPPFLAGS=")));
- r_vars.insert(std::make_pair("LDFLAGS", pcrepp::Pcre::Pcre("\\bLDFLAGS=")));
- r_vars.insert(std::make_pair("ASFLAGS", pcrepp::Pcre::Pcre("\\bASFLAGS=")));
+ std::map<std::string, pcrecpp::RE> r_vars;
+ r_vars.insert(std::make_pair("CFLAGS", pcrecpp::RE("\\bCFLAGS=")));
+ r_vars.insert(std::make_pair("CXXFLAGS", pcrecpp::RE("\\bCXXFLAGS=")));
+ r_vars.insert(std::make_pair("CPPFLAGS", pcrecpp::RE("\\bCPPFLAGS=")));
+ r_vars.insert(std::make_pair("LDFLAGS", pcrecpp::RE("\\bLDFLAGS=")));
+ r_vars.insert(std::make_pair("ASFLAGS", pcrecpp::RE("\\bASFLAGS=")));
if (id)
Log::get_instance()->message("e.qa.variable_assigns_check", ll_debug, lc_context) << "variable_assigns '"
@@ -72,27 +73,27 @@ paludis::erepository::variable_assigns_check(
while (std::getline(ff, s))
{
++line_number;
- if (s.empty() || r_comment.search(s))
+ if (s.empty() || r_comment.PartialMatch(s))
continue;
- s = r_strip_quotes.replace(s, "");
+ r_strip_quotes.GlobalReplace("", &s);
- if (r_make_line.search(s))
+ if (r_make_line.PartialMatch(s))
{
- if (r_make_continuation_line.search(s))
+ if (r_make_continuation_line.PartialMatch(s))
in_make_continuation = true;
continue;
}
if (in_make_continuation)
{
- in_make_continuation = r_make_continuation_line.search(s);
+ in_make_continuation = r_make_continuation_line.PartialMatch(s);
continue;
}
- for (std::map<std::string, pcrepp::Pcre::Pcre>::iterator r(r_vars.begin()),
+ for (std::map<std::string, pcrecpp::RE>::iterator r(r_vars.begin()),
r_end(r_vars.end()) ; r != r_end ; ++r)
- if (r->second.search(s))
+ if (r->second.PartialMatch(s))
reporter.message(with_id(QAMessage(entry, qaml_normal, name, "Attempting to assign to " +
r->first + " on line " + stringify(line_number)), id));
}
diff --git a/src/clients/inquisitio/Makefile.am b/src/clients/inquisitio/Makefile.am
index 022c8de..921ccca 100644
--- a/src/clients/inquisitio/Makefile.am
+++ b/src/clients/inquisitio/Makefile.am
@@ -25,7 +25,7 @@ man_inquisitio_LDADD = \
$(top_builddir)/paludis/libpaludismanpagethings_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/src/output/liboutput.a \
$(DYNAMIC_LD_LIBS) \
- $(PCREPLUSPLUS_LIBS)
+ $(PCRECPPDEPS_LIBS)
inquisitio_SOURCES = \
command_line.hh command_line.cc \
@@ -46,9 +46,9 @@ inquisitio_LDADD = \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/src/output/liboutput.a \
$(DYNAMIC_LD_LIBS) \
- $(PCREPLUSPLUS_LIBS)
+ $(PCRECPPDEPS_LIBS)
-inquisitio_CXXFLAGS = $(AM_CXXFLAGS) $(PCREPLUSPLUS_CFLAGS)
+inquisitio_CXXFLAGS = $(AM_CXXFLAGS) $(PCRECPPDEPS_CFLAGS)
TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
diff --git a/src/clients/inquisitio/pcre_matcher.cc b/src/clients/inquisitio/pcre_matcher.cc
index 8bc1857..c7a210e 100644
--- a/src/clients/inquisitio/pcre_matcher.cc
+++ b/src/clients/inquisitio/pcre_matcher.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,7 +18,7 @@
*/
#include "pcre_matcher.hh"
-#include <pcre++.h>
+#include <pcrecpp.h>
#include <paludis/util/private_implementation_pattern-impl.hh>
using namespace paludis;
@@ -29,11 +29,13 @@ namespace paludis
template<>
struct Implementation<PCREMatcher>
{
- mutable pcrepp::Pcre::Pcre pattern;
+ const pcrecpp::RE pattern;
Implementation(const std::string & s) :
- pattern(s, "i")
+ pattern(s, pcrecpp::RE_Options().set_caseless(true))
{
+ if (! pattern.error().empty())
+ throw BadPCREPatternError(s, pattern.error());
}
};
}
@@ -46,10 +48,15 @@ PCREMatcher::PCREMatcher(const std::string & s) :
bool
PCREMatcher::operator() (const std::string & s) const
{
- return _imp->pattern.search(s);
+ return _imp->pattern.PartialMatch(s);
}
PCREMatcher::~PCREMatcher()
{
}
+BadPCREPatternError::BadPCREPatternError(const std::string & p, const std::string & m) throw () :
+ Exception("Bad PCRE pattern '" + p + "': " + m)
+{
+}
+
diff --git a/src/clients/inquisitio/pcre_matcher.hh b/src/clients/inquisitio/pcre_matcher.hh
index 92d8620..ba42ea8 100644
--- a/src/clients/inquisitio/pcre_matcher.hh
+++ b/src/clients/inquisitio/pcre_matcher.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -35,6 +35,13 @@ namespace inquisitio
bool operator() (const std::string &) const;
};
+
+ class PALUDIS_VISIBLE BadPCREPatternError :
+ public paludis::Exception
+ {
+ public:
+ BadPCREPatternError(const std::string &, const std::string &) throw ();
+ };
}
#endif
diff --git a/src/clients/qualudis/Makefile.am b/src/clients/qualudis/Makefile.am
index 64600fd..19e77d1 100644
--- a/src/clients/qualudis/Makefile.am
+++ b/src/clients/qualudis/Makefile.am
@@ -24,11 +24,11 @@ qualudis_LDADD = \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/selinux/libpaludisselinux_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/src/output/liboutput.a \
- $(PCREPLUSPLUS_LIBS) \
+ $(PCRECPPDEPS_LIBS) \
$(LIBXML2DEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
-INCLUDES = $(PCREPLUSPLUS_CFLAGS) $(LIBXML2DEPS_CFLAGS)
+INCLUDES = $(PCRECPPDEPS_CFLAGS) $(LIBXML2DEPS_CFLAGS)
TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \