|
6 | 6 | #include "derivations.hh"
|
7 | 7 | #include "affinity.hh"
|
8 | 8 | #include "progress-bar.hh"
|
9 |
| - |
10 |
| -#include <regex> |
| 9 | +#include "regex.hh" |
11 | 10 |
|
12 | 11 | using namespace nix;
|
13 | 12 |
|
@@ -64,42 +63,42 @@ BuildEnvironment readEnvironment(const Path & path)
|
64 | 63 | static std::string indexedArrayRegex =
|
65 | 64 | R"re((?:\(( *\[[0-9]+\]="(?:[^"\\]|\\.)*")*\)))re";
|
66 | 65 |
|
67 |
| - static std::regex declareRegex( |
| 66 | + static regex::regex declareRegex( |
68 | 67 | "^declare -a?x (" + varNameRegex + ")(=(" +
|
69 | 68 | dquotedStringRegex + "|" + indexedArrayRegex + "))?\n");
|
70 | 69 |
|
71 |
| - static std::regex varRegex( |
| 70 | + static regex::regex varRegex( |
72 | 71 | "^(" + varNameRegex + ")=(" + simpleStringRegex + "|" + squotedStringRegex + "|" + indexedArrayRegex + ")\n");
|
73 | 72 |
|
74 | 73 | /* Note: we distinguish between an indexed and associative array
|
75 | 74 | using the space before the closing parenthesis. Will
|
76 | 75 | undoubtedly regret this some day. */
|
77 |
| - static std::regex assocArrayRegex( |
| 76 | + static regex::regex assocArrayRegex( |
78 | 77 | "^(" + varNameRegex + ")=" + R"re((?:\(( *\[[^\]]+\]="(?:[^"\\]|\\.)*")* *\)))re" + "\n");
|
79 | 78 |
|
80 |
| - static std::regex functionRegex( |
| 79 | + static regex::regex functionRegex( |
81 | 80 | "^" + varNameRegex + " \\(\\) *\n");
|
82 | 81 |
|
83 | 82 | while (pos != file.end()) {
|
84 | 83 |
|
85 |
| - std::smatch match; |
| 84 | + regex::smatch match; |
86 | 85 |
|
87 |
| - if (std::regex_search(pos, file.cend(), match, declareRegex, std::regex_constants::match_continuous)) { |
| 86 | + if (regex::regex_search(pos, file.cend(), match, declareRegex, regex::regex_constants::match_continuous)) { |
88 | 87 | pos = match[0].second;
|
89 | 88 | exported.insert(match[1]);
|
90 | 89 | }
|
91 | 90 |
|
92 |
| - else if (std::regex_search(pos, file.cend(), match, varRegex, std::regex_constants::match_continuous)) { |
| 91 | + else if (regex::regex_search(pos, file.cend(), match, varRegex, regex::regex_constants::match_continuous)) { |
93 | 92 | pos = match[0].second;
|
94 | 93 | res.env.insert({match[1], Var { .exported = exported.count(match[1]) > 0, .quoted = match[2] }});
|
95 | 94 | }
|
96 | 95 |
|
97 |
| - else if (std::regex_search(pos, file.cend(), match, assocArrayRegex, std::regex_constants::match_continuous)) { |
| 96 | + else if (regex::regex_search(pos, file.cend(), match, assocArrayRegex, regex::regex_constants::match_continuous)) { |
98 | 97 | pos = match[0].second;
|
99 | 98 | res.env.insert({match[1], Var { .associative = true, .quoted = match[2] }});
|
100 | 99 | }
|
101 | 100 |
|
102 |
| - else if (std::regex_search(pos, file.cend(), match, functionRegex, std::regex_constants::match_continuous)) { |
| 101 | + else if (regex::regex_search(pos, file.cend(), match, functionRegex, regex::regex_constants::match_continuous)) { |
103 | 102 | res.bashFunctions = std::string(pos, file.cend());
|
104 | 103 | break;
|
105 | 104 | }
|
|
0 commit comments