diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-08 23:40:39 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-08 23:40:39 -0500 |
| commit | 85d23e68eecc8b2af89a3836296ac0689ec7a5b9 (patch) | |
| tree | 242fcbc0d84a0ba155a7b13833114948e21d893e /src/ast_render.cpp | |
| parent | 91955dee587214722daa09e6f3dbff059ac3752e (diff) | |
| download | zig-85d23e68eecc8b2af89a3836296ac0689ec7a5b9.tar.gz zig-85d23e68eecc8b2af89a3836296ac0689ec7a5b9.zip | |
fix .d file parsing and string literal ast rendering
Diffstat (limited to 'src/ast_render.cpp')
| -rw-r--r-- | src/ast_render.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 76a0622058..84a952fa99 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -317,7 +317,7 @@ static bool is_digit(uint8_t c) { static bool is_printable(uint8_t c) { static const uint8_t printables[] = - " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,"; + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,:"; for (size_t i = 0; i < array_length(printables); i += 1) { if (c == printables[i]) return true; } @@ -328,9 +328,7 @@ static void string_literal_escape(Buf *source, Buf *dest) { buf_resize(dest, 0); for (size_t i = 0; i < buf_len(source); i += 1) { uint8_t c = *((uint8_t*)buf_ptr(source) + i); - if (is_printable(c)) { - buf_append_char(dest, c); - } else if (c == '\'') { + if (c == '\'') { buf_append_str(dest, "\\'"); } else if (c == '"') { buf_append_str(dest, "\\\""); @@ -350,6 +348,8 @@ static void string_literal_escape(Buf *source, Buf *dest) { buf_append_str(dest, "\\t"); } else if (c == '\v') { buf_append_str(dest, "\\v"); + } else if (is_printable(c)) { + buf_append_char(dest, c); } else { buf_appendf(dest, "\\x%x", (int)c); } |
