Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Windows line endings #582

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/c_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
' ': \
case '\t': \
case '\v': \
case '\r': \
case '\f'

#define DIGIT_NON_ZERO \
Expand Down
7 changes: 3 additions & 4 deletions src/tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#define WHITESPACE \
' ': \
case '\n'
case '\n': \
case '\r'

#define DIGIT_NON_ZERO \
'1': \
Expand Down Expand Up @@ -440,9 +441,7 @@ 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)) {
if (isprint(c)) {
tokenize_error(t, "invalid character: '%c'", c);
} else {
const char *sh = get_escape_shorthand(c);
Expand Down