summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string-escape-util.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-11-06 01:47:26 +0800
committerGitHub <noreply@github.com>2024-11-05 09:47:26 -0800
commitb118451e301d734e3e783b3acdf871f3f6ea851c (patch)
tree277f160d31e2c442f724bc6a2d3c09fabff403ca /source/core/slang-string-escape-util.cpp
parent53dd5928c35d5a5cb1f7d2a563348fd1fa87d672 (diff)
Move switch statement bodies to their own lines (#5493)
* Move switch statement bodies to their own lines * format --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core/slang-string-escape-util.cpp')
-rw-r--r--source/core/slang-string-escape-util.cpp141
1 files changed, 94 insertions, 47 deletions
diff --git a/source/core/slang-string-escape-util.cpp b/source/core/slang-string-escape-util.cpp
index a6a70ce76..42e757b23 100644
--- a/source/core/slang-string-escape-util.cpp
+++ b/source/core/slang-string-escape-util.cpp
@@ -141,17 +141,28 @@ static char _getCppEscapedChar(char c)
{
switch (c)
{
- case '\b': return 'b';
- case '\f': return 'f';
- case '\n': return 'n';
- case '\r': return 'r';
- case '\a': return 'a';
- case '\t': return 't';
- case '\v': return 'v';
- case '\'': return '\'';
- case '\"': return '"';
- case '\\': return '\\';
- default: return 0;
+ case '\b':
+ return 'b';
+ case '\f':
+ return 'f';
+ case '\n':
+ return 'n';
+ case '\r':
+ return 'r';
+ case '\a':
+ return 'a';
+ case '\t':
+ return 't';
+ case '\v':
+ return 'v';
+ case '\'':
+ return '\'';
+ case '\"':
+ return '"';
+ case '\\':
+ return '\\';
+ default:
+ return 0;
}
}
@@ -159,17 +170,28 @@ static char _getCppUnescapedChar(char c)
{
switch (c)
{
- case 'b': return '\b';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 'a': return '\a';
- case 't': return '\t';
- case 'v': return '\v';
- case '\'': return '\'';
- case '\"': return '"';
- case '\\': return '\\';
- default: return 0;
+ case 'b':
+ return '\b';
+ case 'f':
+ return '\f';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ case 'a':
+ return '\a';
+ case 't':
+ return '\t';
+ case 'v':
+ return '\v';
+ case '\'':
+ return '\'';
+ case '\"':
+ return '"';
+ case '\\':
+ return '\\';
+ default:
+ return 0;
}
}
@@ -669,7 +691,8 @@ SlangResult JSONStringEscapeHandler::lexQuoted(const char* cursor, const char**
switch (c)
{
- case 0: return SLANG_FAIL;
+ case 0:
+ return SLANG_FAIL;
case '"':
{
*outCursor = cursor;
@@ -708,7 +731,8 @@ SlangResult JSONStringEscapeHandler::lexQuoted(const char* cursor, const char**
}
}
// Somewhat surprisingly it appears it's valid to have \r\n inside of quotes.
- default: break;
+ default:
+ break;
}
}
}
@@ -717,15 +741,24 @@ static char _getJSONEscapedChar(char c)
{
switch (c)
{
- case '\b': return 'b';
- case '\f': return 'f';
- case '\n': return 'n';
- case '\r': return 'r';
- case '\t': return 't';
- case '\\': return '\\';
- case '/': return '/';
- case '"': return '"';
- default: return 0;
+ case '\b':
+ return 'b';
+ case '\f':
+ return 'f';
+ case '\n':
+ return 'n';
+ case '\r':
+ return 'r';
+ case '\t':
+ return 't';
+ case '\\':
+ return '\\';
+ case '/':
+ return '/';
+ case '"':
+ return '"';
+ default:
+ return 0;
}
}
@@ -733,15 +766,24 @@ static char _getJSONUnescapedChar(char c)
{
switch (c)
{
- case 'b': return '\b';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 't': return '\t';
- case '\\': return '\\';
- case '/': return '/';
- case '"': return '"';
- default: return 0;
+ case 'b':
+ return '\b';
+ case 'f':
+ return '\f';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ case 't':
+ return '\t';
+ case '\\':
+ return '\\';
+ case '/':
+ return '/';
+ case '"':
+ return '"';
+ default:
+ return 0;
}
}
@@ -997,14 +1039,19 @@ StringEscapeUtil::Handler* StringEscapeUtil::getHandler(Style style)
{
switch (style)
{
- case Style::Cpp: return &g_cppHandler;
- case Style::Space: return &g_spaceHandler;
- case Style::JSON: return &g_jsonHandler;
+ case Style::Cpp:
+ return &g_cppHandler;
+ case Style::Space:
+ return &g_spaceHandler;
+ case Style::JSON:
+ return &g_jsonHandler;
// TODO(JS): For now we make Slang language string encoding/decoding the same as C++
// That may not be desirable because C++ has a variety of surprising edge cases (for example
// around \x)
- case Style::Slang: return &g_cppHandler;
- default: return nullptr;
+ case Style::Slang:
+ return &g_cppHandler;
+ default:
+ return nullptr;
}
}