diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-24 00:43:12 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-24 00:43:12 -0400 |
| commit | dd9728c5a03844267bc378c326c353fd2b0e084e (patch) | |
| tree | 5786bd228312976ee482a58463a798bc426d64af /src/tokenizer.cpp | |
| parent | 558b0b87913dfb6e6b76f5dbe2c36b920302faab (diff) | |
| parent | 10bdf73a02c90dc375985e49b08b5020cfc20b93 (diff) | |
| download | zig-dd9728c5a03844267bc378c326c353fd2b0e084e.tar.gz zig-dd9728c5a03844267bc378c326c353fd2b0e084e.zip | |
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'src/tokenizer.cpp')
| -rw-r--r-- | src/tokenizer.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index f7f41af8a6..1d3db5567a 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -460,16 +460,21 @@ static const char* get_escape_shorthand(uint8_t c) { static void invalid_char_error(Tokenize *t, uint8_t c) { if (c == '\r') { tokenize_error(t, "invalid carriage return, only '\\n' line endings are supported"); - } else if (isprint(c)) { + return; + } + + const char *sh = get_escape_shorthand(c); + if (sh) { + tokenize_error(t, "invalid character: '%s'", sh); + return; + } + + if (isprint(c)) { tokenize_error(t, "invalid character: '%c'", c); - } else { - const char *sh = get_escape_shorthand(c); - if (sh) { - tokenize_error(t, "invalid character: '%s'", sh); - } else { - tokenize_error(t, "invalid character: '\\x%x'", c); - } + return; } + + tokenize_error(t, "invalid character: '\\x%02x'", c); } void tokenize(Buf *buf, Tokenization *out) { |
