From b872f5b303efab154d740168fe9dd995850559d2 Mon Sep 17 00:00:00 2001 From: Devin Nakamura Date: Mon, 9 Jul 2018 14:39:25 -0400 Subject: file(STRINGS): Use isprint() to test character type Use the more portable `isprint()` function to test characters rather than using hard-coded hex values. The function is documented by the C++ standard to return non-zero for the exact range of hex values we previously hard-coded, so this should not change behavior. --- Source/cmFileCommand.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e39630e..4c288f5 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -10,6 +10,7 @@ #include #include +#include #include // IWYU pragma: keep #include #include @@ -609,8 +610,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) continue; } - if ((c >= 0x20 && c < 0x7F) || c == '\t' || - (c == '\n' && newline_consume)) { + if (c >= 0 && c <= 0xFF && + (isprint(c) || c == '\t' || (c == '\n' && newline_consume))) { // This is an ASCII character that may be part of a string. // Cast added to avoid compiler warning. Cast is ok because // c is guaranteed to fit in char by the above if... -- cgit v0.12