summaryrefslogtreecommitdiffstats
path: root/src/pcrepp/pcre2pp.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/pcrepp/pcre2pp.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/pcrepp/pcre2pp.cc b/src/pcrepp/pcre2pp.cc
index c7429d1..1249876 100644
--- a/src/pcrepp/pcre2pp.cc
+++ b/src/pcrepp/pcre2pp.cc
@@ -32,23 +32,28 @@
#include "pcre2pp.hh"
#include "config.h"
+#include "ww898/cp_utf8.hpp"
namespace lnav {
namespace pcre2pp {
std::string
-quote(const char* unquoted)
+match_data::to_string() const
{
std::string retval;
- for (int lpc = 0; unquoted[lpc]; lpc++) {
- if (isalnum(unquoted[lpc]) || unquoted[lpc] == '_'
- || unquoted[lpc] & 0x80)
- {
- retval.push_back(unquoted[lpc]);
- } else {
- retval.push_back('\\');
- retval.push_back(unquoted[lpc]);
+ if (this->get_count() == 1) {
+ auto cap = (*this)[0];
+ retval.append(cap->data(), cap->length());
+ } else {
+ for (size_t lpc = 1; lpc < this->get_count(); lpc++) {
+ auto cap = (*this)[lpc];
+
+ if (!cap) {
+ continue;
+ }
+
+ retval.append(cap->data(), cap->length());
}
}
@@ -321,7 +326,7 @@ code::replace(string_fragment str, const char* repl) const
}
}
if (remaining.is_valid()) {
- retval.append(str.data(), remaining.sf_begin, std::string::npos);
+ retval.append(remaining.data(), 0, remaining.length());
}
return retval;