summaryrefslogtreecommitdiff
path: root/src/regengine.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/regengine.cc')
-rw-r--r--src/regengine.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/regengine.cc b/src/regengine.cc
index f2f0e5e..491d7b1 100644
--- a/src/regengine.cc
+++ b/src/regengine.cc
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2017 by Hans-Peter Deifel *
+ * Copyright (C) 2015-2018 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,10 +32,29 @@
#include "output.h"
#include "pdfgrep.h"
-// regex(3)
-
using namespace std;
+bool PatternList::exec(const string &str, size_t offset, struct match &m) const
+{
+ struct match m_copy = m;
+
+ for (auto &r : patterns) {
+ if (r->exec(str, offset, m_copy)) {
+ m.start = m_copy.start;
+ m.end = m_copy.end;
+ return true;
+ }
+ }
+ return false;
+}
+
+
+void PatternList::add_pattern(unique_ptr<Regengine> pattern) {
+ patterns.push_back(move(pattern));
+}
+
+// regex(3)
+
PosixRegex::PosixRegex(const string &pattern, bool case_insensitive)
{
int regex_flags = REG_EXTENDED | (case_insensitive ? REG_ICASE : 0);