diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-18 10:51:18 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-18 10:51:42 -0400 |
| commit | c393a399fb4b463f095a8510595263759fd82cd6 (patch) | |
| tree | ae8b4d467362ceb049728d8faa39ee5d68b6889e /src/tokenizer.cpp | |
| parent | cd488c9da56a03d2244a67629612445c451441da (diff) | |
| download | zig-c393a399fb4b463f095a8510595263759fd82cd6.tar.gz zig-c393a399fb4b463f095a8510595263759fd82cd6.zip | |
fix invalid character test on windows
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) { |
