Skip to content

Commit c393a39

Browse files
committedJul 18, 2018
fix invalid character test on windows
·
0.15.10.3.0
1 parent cd488c9 commit c393a39

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
 

‎src/tokenizer.cpp‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,21 @@ static const char* get_escape_shorthand(uint8_t c) {
460460
static void invalid_char_error(Tokenize *t, uint8_t c) {
461461
if (c == '\r') {
462462
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)) {
464473
tokenize_error(t, "invalid character: '%c'", c);
465-
} else {
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-
}
474+
return;
472475
}
476+
477+
tokenize_error(t, "invalid character: '\\x%02x'", c);
473478
}
474479

475480
void tokenize(Buf *buf, Tokenization *out) {

0 commit comments

Comments
 (0)
Please sign in to comment.