diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-04-27 12:36:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-26 21:36:59 -0700 |
| commit | 3acbe8145c60f4d1e7a180b4602a94269a489df5 (patch) | |
| tree | 8031e7ca897260ac3ab6d2a920864f3114bc8668 /source/slang/slang-ast-dump.cpp | |
| parent | a3da31c189a1cc9bdf85a42ac359b8c2777f3550 (diff) | |
Fix most of the disabled warnings on gcc/clang (#2839)
Diffstat (limited to 'source/slang/slang-ast-dump.cpp')
| -rw-r--r-- | source/slang/slang-ast-dump.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp index 2c98af65c..723608bb2 100644 --- a/source/slang/slang-ast-dump.cpp +++ b/source/slang/slang-ast-dump.cpp @@ -1,6 +1,7 @@ // slang-ast-dump.cpp #include "slang-ast-dump.h" #include <assert.h> +#include <limits> #include "slang-compiler.h" @@ -240,9 +241,10 @@ struct ASTDumpContext return (v < 10) ? char(v + '0') : char('a' + v - 10); } - static bool _isPrintableChar(char c) + static bool _charNeedsEscaping(char c) { - return c >= 0x20 && c < 0x80; + // Escape everything except the printable characters (except DEL) + return c < 0x20 || c >= 0x7F; } void dump(const UnownedStringSlice& slice) @@ -253,7 +255,7 @@ struct ASTDumpContext buf.appendChar('\"'); for (const char c : slice) { - if (_isPrintableChar(c)) + if (!_charNeedsEscaping(c)) { buf << c; } |
