diff -Naur a/boost/program_options/environment_iterator.hpp b/boost/program_options/environment_iterator.hpp
|
a
|
b
|
|
| 12 | 12 | #include <string> |
| 13 | 13 | #include <cassert> |
| 14 | 14 | |
| | 15 | #if defined(_WIN32) |
| | 16 | #include <windows.h> |
| | 17 | #endif |
| | 18 | |
| | 19 | #if defined(_WIN32) && defined(__MINGW32__) |
| | 20 | #define ENVIRON_IT_TYPE LPTCH |
| | 21 | #else |
| | 22 | #define ENVIRON_IT_TYPE char** |
| | 23 | #endif |
| | 24 | |
| 15 | 25 | namespace boost { |
| 16 | 26 | |
| 17 | 27 | class environment_iterator |
| … |
… |
|
| 19 | 29 | std::pair<std::string, std::string> > |
| 20 | 30 | { |
| 21 | 31 | public: |
| 22 | | environment_iterator(char** environment) |
| | 32 | environment_iterator(ENVIRON_IT_TYPE environment) |
| 23 | 33 | : m_environment(environment) |
| 24 | 34 | { |
| 25 | 35 | get(); |
| … |
… |
|
| 35 | 45 | if (*m_environment == 0) |
| 36 | 46 | found_eof(); |
| 37 | 47 | else { |
| | 48 | #if defined(_WIN32) && defined(__MINGW32__) |
| | 49 | std::string s(m_environment); |
| | 50 | #else |
| 38 | 51 | std::string s(*m_environment); |
| | 52 | #endif |
| 39 | 53 | std::string::size_type n = s.find('='); |
| 40 | 54 | assert(n != s.npos); |
| 41 | 55 | value().first = s.substr(0, n); |
| 42 | 56 | value().second = s.substr(n+1); |
| 43 | | } |
| 44 | | ++m_environment; |
| | 57 | #if defined(_WIN32) && defined(__MINGW32__) |
| | 58 | m_environment += s.length() + 1; |
| | 59 | #else |
| | 60 | ++m_environment; |
| | 61 | #endif |
| | 62 | } |
| 45 | 63 | } |
| 46 | 64 | |
| 47 | 65 | private: |
| 48 | | char** m_environment; |
| | 66 | ENVIRON_IT_TYPE m_environment; |
| 49 | 67 | }; |
| 50 | 68 | } |
| | 69 | |
| | 70 | #undef ENVIRON_IT_TYPE |
| | 71 | |
| 51 | 72 | #endif |
diff -Naur a/libs/program_options/src/parsers.cpp b/libs/program_options/src/parsers.cpp
|
a
|
b
|
|
| 30 | 30 | |
| 31 | 31 | #ifdef _WIN32 |
| 32 | 32 | #include <stdlib.h> |
| | 33 | #include <windows.h> |
| 33 | 34 | #else |
| 34 | 35 | #include <unistd.h> |
| 35 | 36 | #endif |
| … |
… |
|
| 190 | 191 | const function1<std::string, std::string>& name_mapper) |
| 191 | 192 | { |
| 192 | 193 | parsed_options result(&desc); |
| | 194 | |
| | 195 | #if defined(_WIN32) && defined(__MINGW32__) |
| | 196 | LPTCH environ = GetEnvironmentStrings(); |
| | 197 | #endif |
| 193 | 198 | |
| 194 | 199 | for(environment_iterator i(environ), e; i != e; ++i) { |
| 195 | 200 | string option_name = name_mapper(i->first); |
| … |
… |
|
| 201 | 206 | result.options.push_back(n); |
| 202 | 207 | } |
| 203 | 208 | } |
| | 209 | |
| | 210 | #if defined(_WIN32) && defined(__MINGW32__) |
| | 211 | FreeEnvironmentStrings(environ); |
| | 212 | #endif |
| 204 | 213 | |
| 205 | 214 | return result; |
| 206 | 215 | } |