| ... | ... | @@ -317,7 +317,7 @@ static bool is_digit(uint8_t c) { |
| 317 | 317 | |
| 318 | 318 | static bool is_printable(uint8_t c) { |
| 319 | 319 | static const uint8_t printables[] = |
| 320 | | " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,"; |
| 320 | " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,:"; |
| 321 | 321 | for (size_t i = 0; i < array_length(printables); i += 1) { |
| 322 | 322 | if (c == printables[i]) return true; |
| 323 | 323 | } |
| ... | ... | @@ -328,9 +328,7 @@ static void string_literal_escape(Buf *source, Buf *dest) { |
| 328 | 328 | buf_resize(dest, 0); |
| 329 | 329 | for (size_t i = 0; i < buf_len(source); i += 1) { |
| 330 | 330 | 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 == '\'') { |
| 334 | 332 | buf_append_str(dest, "\\'"); |
| 335 | 333 | } else if (c == '"') { |
| 336 | 334 | buf_append_str(dest, "\\\""); |
| ... | ... | @@ -350,6 +348,8 @@ static void string_literal_escape(Buf *source, Buf *dest) { |
| 350 | 348 | buf_append_str(dest, "\\t"); |
| 351 | 349 | } else if (c == '\v') { |
| 352 | 350 | buf_append_str(dest, "\\v"); |
| 351 | } else if (is_printable(c)) { |
| 352 | buf_append_char(dest, c); |
| 353 | 353 | } else { |
| 354 | 354 | buf_appendf(dest, "\\x%x", (int)c); |
| 355 | 355 | } |