mecab-variable-param.patch
1 | From 2396e90056706ef897acab3aaa081289c7336483 Mon Sep 17 00:00:00 2001 |
2 | From: LEPILLER Julien <julien.lepiller@irisa.fr> |
3 | Date: Fri, 19 Apr 2019 11:48:39 +0200 |
4 | Subject: [PATCH] Allow variable parameters |
5 | |
6 | --- |
7 | src/param.cpp | 6 +++++- |
8 | 1 file changed, 5 insertions(+), 1 deletion(-) |
9 | |
10 | diff --git a/src/param.cpp b/src/param.cpp |
11 | index 65328a2..006b1b5 100644 |
12 | --- a/src/param.cpp |
13 | +++ b/src/param.cpp |
14 | @@ -79,8 +79,12 @@ bool Param::load(const char *filename) { |
15 | size_t s1, s2; |
16 | for (s1 = pos+1; s1 < line.size() && isspace(line[s1]); s1++); |
17 | for (s2 = pos-1; static_cast<long>(s2) >= 0 && isspace(line[s2]); s2--); |
18 | - const std::string value = line.substr(s1, line.size() - s1); |
19 | + std::string value = line.substr(s1, line.size() - s1); |
20 | const std::string key = line.substr(0, s2 + 1); |
21 | + |
22 | + if(value.find('$') == 0) { |
23 | + value = std::getenv(value.substr(1).c_str()); |
24 | + } |
25 | set<std::string>(key.c_str(), value, false); |
26 | } |
27 | |
28 | -- |
29 | 2.20.1 |
30 | |
31 |