From a3efdcdfd910aabd3001467864eaf2990f6c57a2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 21 Oct 2016 18:06:26 +0200 Subject: [PATCH] Use std::regex --- src/hydra-queue-runner/build-result.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/hydra-queue-runner/build-result.cc b/src/hydra-queue-runner/build-result.cc index a39cf612..25e8c41a 100644 --- a/src/hydra-queue-runner/build-result.cc +++ b/src/hydra-queue-runner/build-result.cc @@ -1,9 +1,10 @@ #include "build-result.hh" #include "store-api.hh" #include "util.hh" -#include "regex.hh" #include "fs-accessor.hh" +#include + using namespace nix; @@ -28,14 +29,14 @@ BuildOutput getBuildOutput(nix::ref store, /* Get build products. */ bool explicitProducts = false; - Regex regex( - "(([a-zA-Z0-9_-]+)" // type (e.g. "doc") + std::regex regex( + "([a-zA-Z0-9_-]+)" // type (e.g. "doc") "[[:space:]]+" "([a-zA-Z0-9_-]+)" // subtype (e.g. "readme") "[[:space:]]+" - "(\"[^\"]+\"|[^[:space:]\"]+))" // path (may be quoted) + "(\"[^\"]+\"|[^[:space:]\"]+)" // path (may be quoted) "([[:space:]]+([^[:space:]]+))?" // entry point - , true); + , std::regex::extended); for (auto & output : outputs) { Path failedFile = output + "/nix-support/failed"; @@ -51,13 +52,14 @@ BuildOutput getBuildOutput(nix::ref store, for (auto & line : tokenizeString(accessor->readFile(productsFile), "\n")) { BuildProduct product; - Regex::Subs subs; - if (!regex.matches(line, subs)) continue; + std::smatch match; + if (!std::regex_match(line, match, regex)) continue; - product.type = subs[1]; - product.subtype = subs[2]; - product.path = subs[3][0] == '"' ? string(subs[3], 1, subs[3].size() - 2) : subs[3]; - product.defaultPath = subs[5]; + product.type = match[1]; + product.subtype = match[2]; + std::string s(match[3]); + product.path = s[0] == '"' ? string(s, 1, s.size() - 2) : s; + product.defaultPath = match[5]; /* Ensure that the path exists and points into the Nix store. */