Skip to content

Commit

Permalink
fix invalid character test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 18, 2018
1 parent cd488c9 commit c393a39
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/tokenizer.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit c393a39

Please sign in to comment.