boostorg / process

Boost Process
https://www.boost.org/libs/process
115 stars 114 forks source link

v1.81: boost\process\detail\windows\environment.hpp reports a compilation error in Windows wide-byte environment #371

Open baikaishui-ks opened 4 months ago

baikaishui-ks commented 4 months ago

There are two errors in compilation, namely line 68 and line 248. I see that the compilation error on line 68 has been corrected, and the compilation error on line 248 has not been changed.

Statement error after if (itr == _data.end()).

template<typename Char>
inline auto basic_environment_impl<Char>::get(const string_type &id) -> string_type
{
    if (id.size() >= _data.size()) //ok, so it's impossible id is in there.
        return string_type(_data.data());

    if (std::equal(id.begin(), id.end(), _data.begin()) && (_data[id.size()] == equal_sign<Char>()))
        return string_type(_data.data()); //null-char is handled by the string.

    std::vector<Char> seq = {'\0'}; //using a vector, because strings might cause problems with nullchars
    seq.insert(seq.end(), id.begin(), id.end());
    seq.push_back('=');

    auto itr = std::search(_data.begin(), _data.end(), seq.begin(), seq.end());

    if (itr == _data.end()) //not found
        // The original statement is: return "";
        // I changed it locally to: return string_type{};
        return string_type{};

    itr += seq.size(); //advance to the value behind the '='; the std::string will take care of finding the null-char.

    return string_type(&*itr);
}