mirror of
https://github.com/boostorg/process.git
synced 2026-01-30 20:12:31 +00:00
Fixed wchar_t stuff on posix
This commit is contained in:
@@ -63,8 +63,22 @@ struct cmd_setter_ : handler_base_ext
|
||||
{
|
||||
exec.cmd_line = &_cmd_impl.front();
|
||||
}
|
||||
const string_type & str() const {return _cmd_line;}
|
||||
string_type str() const
|
||||
{
|
||||
string_type ret;
|
||||
std::size_t size = 0;
|
||||
for (auto & cmd : _cmd_line)
|
||||
size += cmd.size() + 1;
|
||||
ret.reserve(size -1);
|
||||
|
||||
for (auto & cmd : _cmd_line)
|
||||
{
|
||||
if (!ret.empty())
|
||||
ret += equal_sign<Char>();
|
||||
ret += cmd;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
static inline std::vector<Char*> make_cmd(std::vector<string_type> & args);
|
||||
std::vector<string_type> _cmd_line;
|
||||
|
||||
@@ -37,7 +37,7 @@ class native_environment_impl
|
||||
std::vector<Char*> val;
|
||||
val.resize(vec.size() + 1);
|
||||
std::transform(vec.begin(), vec.end(), val.begin(),
|
||||
[](auto & str)
|
||||
[](std::basic_string<Char> & str)
|
||||
{
|
||||
return &str.front();
|
||||
});
|
||||
@@ -185,8 +185,16 @@ public:
|
||||
explicit inline basic_environment_impl(
|
||||
const basic_environment_impl<CharR>& rhs,
|
||||
const ::boost::process::codecvt_type & cv = ::boost::process::codecvt())
|
||||
: _data(::boost::process::detail::convert(rhs._data, cv))
|
||||
: _data(rhs._data.size())
|
||||
{
|
||||
std::transform(rhs._data.begin(), rhs._data.end(), _data.begin(),
|
||||
[&](const std::basic_string<CharR> & st)
|
||||
{
|
||||
return ::boost::process::detail::convert(st, cv);
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
template<typename CharR>
|
||||
|
||||
@@ -462,7 +462,7 @@ child executor<Sequence>::invoke(boost::mpl::false_, boost::mpl::true_)
|
||||
|
||||
#endif
|
||||
|
||||
template<typename Tup>
|
||||
template<typename Char, typename Tup>
|
||||
inline executor<Tup> make_executor(Tup & tup)
|
||||
{
|
||||
return executor<Tup>(tup);
|
||||
|
||||
@@ -21,7 +21,7 @@ struct start_dir_init : handler_base_ext
|
||||
{
|
||||
typedef Char value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
explicit start_dir_init(const string_type &s) : s_(s) {}
|
||||
start_dir_init(const string_type &s) : s_(s) {}
|
||||
|
||||
template <class PosixExecutor>
|
||||
void on_exec_setup(PosixExecutor&) const
|
||||
|
||||
@@ -128,6 +128,14 @@ struct char_converter<wchar_t, std::string>
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct char_converter<char, std::wstring>
|
||||
{
|
||||
static std::string conv(const std::wstring & in)
|
||||
{
|
||||
return ::boost::process::detail::convert(in);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct char_converter<wchar_t, std::vector<std::string>>
|
||||
|
||||
@@ -639,15 +639,17 @@ inline std::vector<boost::filesystem::path> path()
|
||||
{
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
const ::boost::process::wnative_environment ne;
|
||||
typedef typename ::boost::process::wnative_environment::const_entry_type value_type;
|
||||
const auto id = L"PATH";
|
||||
#else
|
||||
const ::boost::process::native_environment ne;
|
||||
typedef typename ::boost::process::native_environment::const_entry_type value_type;
|
||||
const auto id = "path";
|
||||
#endif
|
||||
|
||||
auto itr = std::find_if(ne.cbegin(), ne.cend(),
|
||||
[&](const auto & e)
|
||||
{return id == ::boost::to_upper_copy(e.get_name());});
|
||||
[&](const value_type & e)
|
||||
{return id == ::boost::to_upper_copy(e.get_name(), ::boost::process::detail::process_locale());});
|
||||
|
||||
if (itr == ne.cend())
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user