diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
| commit | 23629167fefb8117a4d2cc9213c8a29d5b4a1197 (patch) | |
| tree | c410512ef1b5e0f0e81b7f333cafabc3ad716f5d /tools/debugserver/source/RNBContext.cpp | |
| parent | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (diff) | |
Notes
Diffstat (limited to 'tools/debugserver/source/RNBContext.cpp')
| -rw-r--r-- | tools/debugserver/source/RNBContext.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/debugserver/source/RNBContext.cpp b/tools/debugserver/source/RNBContext.cpp index c1319af02322..c86511c6e226 100644 --- a/tools/debugserver/source/RNBContext.cpp +++ b/tools/debugserver/source/RNBContext.cpp @@ -42,6 +42,25 @@ const char *RNBContext::EnvironmentAtIndex(size_t index) { return NULL; } +static std::string GetEnvironmentKey(const std::string &env) { + std::string key = env.substr(0, env.find('=')); + if (!key.empty() && key.back() == '=') + key.pop_back(); + return key; +} + +void RNBContext::PushEnvironmentIfNeeded(const char *arg) { + if (!arg) + return; + std::string arg_key = GetEnvironmentKey(arg); + + for (const std::string &entry: m_env_vec) { + if (arg_key == GetEnvironmentKey(entry)) + return; + } + m_env_vec.push_back(arg); +} + const char *RNBContext::ArgumentAtIndex(size_t index) { if (index < m_arg_vec.size()) return m_arg_vec[index].c_str(); |
