authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-08 23:40:39-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-08 23:40:39-05:00
log85d23e68eecc8b2af89a3836296ac0689ec7a5b9
tree242fcbc0d84a0ba155a7b13833114948e21d893e
parent91955dee587214722daa09e6f3dbff059ac3752e

fix .d file parsing and string literal ast rendering


2 files changed, 6 insertions(+), 5 deletions(-)

src/ast_render.cpp+4-4
......@@ -317,7 +317,7 @@ static bool is_digit(uint8_t c) {
317317
318318static bool is_printable(uint8_t c) {
319319 static const uint8_t printables[] =
320 " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,";
320 " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,:";
321321 for (size_t i = 0; i < array_length(printables); i += 1) {
322322 if (c == printables[i]) return true;
323323 }
......@@ -328,9 +328,7 @@ static void string_literal_escape(Buf *source, Buf *dest) {
328328 buf_resize(dest, 0);
329329 for (size_t i = 0; i < buf_len(source); i += 1) {
330330 uint8_t c = *((uint8_t*)buf_ptr(source) + i);
331 if (is_printable(c)) {
332 buf_append_char(dest, c);
333 } else if (c == '\'') {
331 if (c == '\'') {
334332 buf_append_str(dest, "\\'");
335333 } else if (c == '"') {
336334 buf_append_str(dest, "\\\"");
......@@ -350,6 +348,8 @@ static void string_literal_escape(Buf *source, Buf *dest) {
350348 buf_append_str(dest, "\\t");
351349 } else if (c == '\v') {
352350 buf_append_str(dest, "\\v");
351 } else if (is_printable(c)) {
352 buf_append_char(dest, c);
353353 } else {
354354 buf_appendf(dest, "\\x%x", (int)c);
355355 }
src/cache_hash.cpp+2-1
......@@ -472,10 +472,11 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) {
472472 }
473473 } else {
474474 // sometimes there are multiple files on the same line; we actually need space tokenization.
475 SplitIterator line_it = memSplit(opt_line.value, str(" \t\\"));
475 SplitIterator line_it = memSplit(opt_line.value, str(" \t"));
476476 Slice<uint8_t> filename;
477477 while (SplitIterator_next(&line_it).unwrap(&filename)) {
478478 Buf *filename_buf = buf_create_from_slice(filename);
479 if (buf_eql_str(filename_buf, "\\")) continue;
479480 if ((err = cache_add_file(ch, filename_buf))) {
480481 if (verbose) {
481482 fprintf(stderr, "unable to add %s to cache: %s\n", buf_ptr(filename_buf), err_str(err));