Skip to content

Commit 487d8ec

Browse files
authored
Merge pull request #163 from ChAoSUnItY/master
Support escaped NULL character in string and character literal
2 parents affa4fc + a4544c6 commit 487d8ec

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: src/lexer.c

+4
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ token_t lex_token_internal(bool aliasing)
304304
token_str[i - 1] = '\t';
305305
else if (next_char == '\\')
306306
token_str[i - 1] = '\\';
307+
else if (next_char == '0')
308+
token_str[i - 1] = '\0';
307309
else
308310
abort();
309311
} else {
@@ -334,6 +336,8 @@ token_t lex_token_internal(bool aliasing)
334336
token_str[0] = '\t';
335337
else if (next_char == '\\')
336338
token_str[0] = '\\';
339+
else if (next_char == '0')
340+
token_str[0] = '\0';
337341
else
338342
abort();
339343
} else {

Diff for: tests/driver.sh

+6
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ int main() {
630630
}
631631
EOF
632632

633+
try_ 0 << EOF
634+
int main() {
635+
return '\0';
636+
}
637+
EOF
638+
633639
# function-like macro
634640
try_ 1 << EOF
635641
#define MAX(a, b) ((a) > (b) ? (a) : (b))

0 commit comments

Comments
 (0)