aboutsummaryrefslogtreecommitdiffstats
path: root/source/Utility/RegularExpression.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
commit5f29bb8a675e8f96452b632e7129113f7dec850e (patch)
tree3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Utility/RegularExpression.cpp
parent88c643b6fec27eec436c8d138fee6346e92337d6 (diff)
downloadsrc-5f29bb8a675e8f96452b632e7129113f7dec850e.tar.gz
src-5f29bb8a675e8f96452b632e7129113f7dec850e.zip
Vendor import of stripped lldb trunk r366426 (just before the release_90
Notes
Notes: svn path=/vendor/lldb/dist/; revision=351290
Diffstat (limited to 'source/Utility/RegularExpression.cpp')
-rw-r--r--source/Utility/RegularExpression.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/source/Utility/RegularExpression.cpp b/source/Utility/RegularExpression.cpp
index 54f773365d99..0192e8b8a01a 100644
--- a/source/Utility/RegularExpression.cpp
+++ b/source/Utility/RegularExpression.cpp
@@ -1,9 +1,8 @@
//===-- RegularExpression.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,10 +12,8 @@
#include <string>
-//----------------------------------------------------------------------
// Enable enhanced mode if it is available. This allows for things like \d for
// digit, \s for space, and many more, but it isn't available everywhere.
-//----------------------------------------------------------------------
#if defined(REG_ENHANCED)
#define DEFAULT_COMPILE_FLAGS (REG_ENHANCED | REG_EXTENDED)
#else
@@ -29,18 +26,15 @@ RegularExpression::RegularExpression() : m_re(), m_comp_err(1), m_preg() {
memset(&m_preg, 0, sizeof(m_preg));
}
-//----------------------------------------------------------------------
// Constructor that compiles "re" using "flags" and stores the resulting
// compiled regular expression into this object.
-//----------------------------------------------------------------------
RegularExpression::RegularExpression(llvm::StringRef str)
- : m_re(), m_comp_err(1), m_preg() {
- memset(&m_preg, 0, sizeof(m_preg));
+ : RegularExpression() {
Compile(str);
}
-RegularExpression::RegularExpression(const RegularExpression &rhs) {
- memset(&m_preg, 0, sizeof(m_preg));
+RegularExpression::RegularExpression(const RegularExpression &rhs)
+ : RegularExpression() {
Compile(rhs.GetText());
}
@@ -51,15 +45,12 @@ operator=(const RegularExpression &rhs) {
return *this;
}
-//----------------------------------------------------------------------
// Destructor
//
// Any previously compiled regular expression contained in this object will be
// freed.
-//----------------------------------------------------------------------
RegularExpression::~RegularExpression() { Free(); }
-//----------------------------------------------------------------------
// Compile a regular expression using the supplied regular expression text and
// flags. The compiled regular expression lives in this object so that it can
// be readily used for regular expression matches. Execute() can be called
@@ -69,7 +60,6 @@ RegularExpression::~RegularExpression() { Free(); }
// RETURNS
// True if the regular expression compiles successfully, false
// otherwise.
-//----------------------------------------------------------------------
bool RegularExpression::Compile(llvm::StringRef str) {
Free();
@@ -80,13 +70,11 @@ bool RegularExpression::Compile(llvm::StringRef str) {
return m_comp_err == 0;
}
-//----------------------------------------------------------------------
// Execute a regular expression match using the compiled regular expression
// that is already in this object against the match string "s". If any parens
// are used for regular expression matches "match_count" should indicate the
// number of regmatch_t values that are present in "match_ptr". The regular
// expression will be executed using the "execute_flags".
-//---------------------------------------------------------------------
bool RegularExpression::Execute(llvm::StringRef str, Match *match) const {
int err = 1;
if (m_comp_err == 0) {
@@ -155,19 +143,13 @@ bool RegularExpression::Match::GetMatchSpanningIndices(
return false;
}
-//----------------------------------------------------------------------
// Returns true if the regular expression compiled and is ready for execution.
-//----------------------------------------------------------------------
bool RegularExpression::IsValid() const { return m_comp_err == 0; }
-//----------------------------------------------------------------------
// Returns the text that was used to compile the current regular expression.
-//----------------------------------------------------------------------
llvm::StringRef RegularExpression::GetText() const { return m_re; }
-//----------------------------------------------------------------------
// Free any contained compiled regular expressions.
-//----------------------------------------------------------------------
void RegularExpression::Free() {
if (m_comp_err == 0) {
m_re.clear();