mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmExecuteProcessCommand: Explicitly ignore unknown ENCODING values
The logic did this implicitly before. Make it easier to follow.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
#include <cm/string_view>
|
||||
#include <cmext/algorithm>
|
||||
#include <cmext/string_view>
|
||||
@@ -69,7 +70,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
|
||||
bool ErrorStripTrailingWhitespace = false;
|
||||
bool EchoOutputVariable = false;
|
||||
bool EchoErrorVariable = false;
|
||||
std::string Encoding;
|
||||
cm::optional<std::string> Encoding;
|
||||
std::string CommandErrorIsFatal;
|
||||
};
|
||||
|
||||
@@ -296,8 +297,14 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
|
||||
};
|
||||
ReadData outputData;
|
||||
ReadData errorData;
|
||||
cmProcessOutput processOutput(
|
||||
cmProcessOutput::FindEncoding(arguments.Encoding));
|
||||
cmProcessOutput::Encoding encoding = cmProcessOutput::Auto;
|
||||
if (arguments.Encoding) {
|
||||
if (cm::optional<cmProcessOutput::Encoding> maybeEncoding =
|
||||
cmProcessOutput::FindEncoding(*arguments.Encoding)) {
|
||||
encoding = *maybeEncoding;
|
||||
}
|
||||
}
|
||||
cmProcessOutput processOutput(encoding);
|
||||
std::string strdata;
|
||||
|
||||
std::unique_ptr<cmUVStreamReadHandle> outputHandle;
|
||||
|
||||
@@ -12,16 +12,18 @@ unsigned int cmProcessOutput::defaultCodepage =
|
||||
KWSYS_ENCODING_DEFAULT_CODEPAGE;
|
||||
#endif
|
||||
|
||||
cmProcessOutput::Encoding cmProcessOutput::FindEncoding(
|
||||
cm::optional<cmProcessOutput::Encoding> cmProcessOutput::FindEncoding(
|
||||
std::string const& name)
|
||||
{
|
||||
Encoding encoding = Auto;
|
||||
cm::optional<Encoding> encoding;
|
||||
if ((name == "UTF8") || (name == "UTF-8")) {
|
||||
encoding = UTF8;
|
||||
} else if (name == "NONE") {
|
||||
encoding = None;
|
||||
} else if (name == "ANSI") {
|
||||
encoding = ANSI;
|
||||
} else if (name == "AUTO") {
|
||||
encoding = Auto;
|
||||
} else if (name == "OEM") {
|
||||
encoding = OEM;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
|
||||
/** \class cmProcessOutput
|
||||
* \brief Decode text data to internal encoding.
|
||||
*
|
||||
@@ -31,7 +33,7 @@ public:
|
||||
* \param name a encoding name.
|
||||
* \return encoding enum value or Auto if \a name was not found.
|
||||
*/
|
||||
static Encoding FindEncoding(std::string const& name);
|
||||
static cm::optional<Encoding> FindEncoding(std::string const& name);
|
||||
|
||||
/// The code page that is used as internal encoding to which we will encode.
|
||||
static unsigned int defaultCodepage;
|
||||
|
||||
Reference in New Issue
Block a user