mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-03 04:03:23 +03:00
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.
This commit is contained in:
1 parent
8d478c0003
commit
b872f5b303
1 file changed
+3
-2
@@ -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...
|
||||
|
||||
Reference in new issue
Block a user