From 3acbe8145c60f4d1e7a180b4602a94269a489df5 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 27 Apr 2023 12:36:59 +0800 Subject: Fix most of the disabled warnings on gcc/clang (#2839) --- source/slang/slang-ast-dump.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-ast-dump.cpp') 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 +#include #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; } -- cgit v1.2.3