| ... | @@ -460,16 +460,21 @@ static const char* get_escape_shorthand(uint8_t c) { | ... | @@ -460,16 +460,21 @@ static const char* get_escape_shorthand(uint8_t c) { |
| 460 | static void invalid_char_error(Tokenize *t, uint8_t c) { | 460 | static void invalid_char_error(Tokenize *t, uint8_t c) { |
| 461 | if (c == '\r') { | 461 | if (c == '\r') { |
| 462 | tokenize_error(t, "invalid carriage return, only '\\n' line endings are supported"); | 462 | tokenize_error(t, "invalid carriage return, only '\\n' line endings are supported"); |
| 463 | } else if (isprint(c)) { | 463 | return; |
| | 464 | } |
| | 465 | |
| | 466 | const char *sh = get_escape_shorthand(c); |
| | 467 | if (sh) { |
| | 468 | tokenize_error(t, "invalid character: '%s'", sh); |
| | 469 | return; |
| | 470 | } |
| | 471 | |
| | 472 | if (isprint(c)) { |
| 464 | tokenize_error(t, "invalid character: '%c'", c); | 473 | tokenize_error(t, "invalid character: '%c'", c); |
| 465 | } else { | 474 | return; |
| 466 | const char *sh = get_escape_shorthand(c); | | |
| 467 | if (sh) { | | |
| 468 | tokenize_error(t, "invalid character: '%s'", sh); | | |
| 469 | } else { | | |
| 470 | tokenize_error(t, "invalid character: '\\x%x'", c); | | |
| 471 | } | | |
| 472 | } | 475 | } |
| | 476 | |
| | 477 | tokenize_error(t, "invalid character: '\\x%02x'", c); |
| 473 | } | 478 | } |
| 474 | | 479 | |
| 475 | void tokenize(Buf *buf, Tokenization *out) { | 480 | void tokenize(Buf *buf, Tokenization *out) { |