From 2d3392f22c894957d17dd13486e0565c4ecea89c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 27 May 2022 17:28:05 -0400 Subject: Added NativeStringType (#2252) * #include an absolute path didn't work - because paths were taken to always be relative. * Use TerminatedUnownedStringSlice for literals in output C++. * Remove Escape/Unescape functions used in slang-token-reader.cpp Add target type of 'host-cpp' etc to map to the target types. * Fix some corner cases around string encoding. * Added unit test for string escaping. Fixed some assorted escaping bugs. * Updated test output. * Added decode test. * Stop using hex output, to get around 'greedy' aspect. Use octal instead. --- source/core/slang-hex-dump-util.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'source/core/slang-hex-dump-util.cpp') diff --git a/source/core/slang-hex-dump-util.cpp b/source/core/slang-hex-dump-util.cpp index b493141a1..1279dc237 100644 --- a/source/core/slang-hex-dump-util.cpp +++ b/source/core/slang-hex-dump-util.cpp @@ -5,6 +5,8 @@ #include "slang-string-util.h" #include "slang-writer.h" +#include "slang-char-util.h" + #include "../../slang-com-helper.h" #include "slang-hash.h" @@ -152,23 +154,6 @@ SlangResult HexDumpUtil::dumpSourceBytes(const uint8_t* data, size_t dataCount, return SLANG_OK; } -static int _parseHexDigit(char c) -{ - if (c >= '0' && c <= '9') - { - return c -'0'; - } - else if (c >= 'a' && c <= 'f') - { - return c - 'a' + 10; - } - else if (c >= 'A' && c <= 'F') - { - return c - 'A' + 10; - } - return -1; -} - /* static */SlangResult HexDumpUtil::parse(const UnownedStringSlice& lines, List& outBytes) { outBytes.clear(); @@ -188,8 +173,8 @@ static int _parseHexDigit(char c) break; } - const int hi = _parseHexDigit(c); - const int lo = _parseHexDigit(cur[1]); + const int hi = CharUtil::getHexDigitValue(c); + const int lo = CharUtil::getHexDigitValue(cur[1]); cur += 2; if (hi < 0 || lo < 0) -- cgit v1.2.3