Skip to content

Commit

Permalink
Merge pull request #163 from ChAoSUnItY/master
Browse files Browse the repository at this point in the history
Support escaped NULL character in string and character literal
  • Loading branch information
jserv authored Nov 9, 2024
2 parents affa4fc + a4544c6 commit 487d8ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ token_t lex_token_internal(bool aliasing)
token_str[i - 1] = '\t';
else if (next_char == '\\')
token_str[i - 1] = '\\';
else if (next_char == '0')
token_str[i - 1] = '\0';
else
abort();
} else {
Expand Down Expand Up @@ -334,6 +336,8 @@ token_t lex_token_internal(bool aliasing)
token_str[0] = '\t';
else if (next_char == '\\')
token_str[0] = '\\';
else if (next_char == '0')
token_str[0] = '\0';
else
abort();
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ int main() {
}
EOF

try_ 0 << EOF
int main() {
return '\0';
}
EOF

# function-like macro
try_ 1 << EOF
#define MAX(a, b) ((a) > (b) ? (a) : (b))
Expand Down

0 comments on commit 487d8ec

Please sign in to comment.