Merge topic 'fix-isspace-usage-for-signed-char'

5e8c176e2a cmExecuteProcessCommand: Cast c to unsigned char before cast to int

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9132
This commit is contained in:
Brad King
2024-01-08 14:44:10 +00:00
committed by Kitware Robot

View File

@@ -35,7 +35,11 @@
namespace {
bool cmExecuteProcessCommandIsWhitespace(char c)
{
return (isspace(static_cast<int>(c)) || c == '\n' || c == '\r');
// isspace takes 'int' but documents that the value must be representable
// by 'unsigned char', or EOF. Cast to 'unsigned char' to avoid sign
// extension while casting to 'int'.
return (isspace(static_cast<int>(static_cast<unsigned char>(c))) ||
c == '\n' || c == '\r');
}
void cmExecuteProcessCommandFixText(std::vector<char>& output,