diff options
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; } |
