diff options
author | Devin Nakamura <devinn@ca.ibm.com> | 2018-07-09 18:39:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-07-10 17:57:07 (GMT) |
commit | b872f5b303efab154d740168fe9dd995850559d2 (patch) | |
tree | fe451dff5a44513846b1ab4a0129ed418226029c /Source/cmFileCommand.cxx | |
parent | 8d478c0003cc9bb4836038fc1a27d3bbd40348d2 (diff) | |
download | CMake-b872f5b303efab154d740168fe9dd995850559d2.zip CMake-b872f5b303efab154d740168fe9dd995850559d2.tar.gz CMake-b872f5b303efab154d740168fe9dd995850559d2.tar.bz2 |
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.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 5 |
1 files 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 <algorithm> #include <assert.h> +#include <ctype.h> #include <memory> // IWYU pragma: keep #include <sstream> #include <stdio.h> @@ -609,8 +610,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> 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... |