authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-14 23:41:18+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-14 18:57:57-05:00
logb15958c557d3b29c8d4cee9951a8bfd30c215482
tree403355064937bdbeee0951074d89468184946ef2
parent9e1afdc23469e1dece4aea318eb8ad2f6c100a94

fix c tokenizer bug


2 files changed, 9 insertions(+), 0 deletions(-)

lib/std/c/tokenizer.zig+2
......@@ -616,6 +616,7 @@ pub const Tokenizer = struct {
616616 },
617617 .BackSlash => switch (c) {
618618 '\n' => {
619 result.start = self.index + 1;
619620 state = .Start;
620621 },
621622 '\r' => {
......@@ -631,6 +632,7 @@ pub const Tokenizer = struct {
631632 },
632633 .BackSlashCr => switch (c) {
633634 '\n' => {
635 result.start = self.index + 1;
634636 state = .Start;
635637 },
636638 else => {
test/translate_c.zig+7
......@@ -3,6 +3,13 @@ const builtin = @import("builtin");
33const Target = @import("std").Target;
44
55pub fn addCases(cases: *tests.TranslateCContext) void {
6 cases.add("macro line continuation",
7 \\#define FOO -\
8 \\BAR
9 , &[_][]const u8{
10 \\pub const FOO = -BAR;
11 });
12
613 cases.add("function prototype translated as optional",
714 \\typedef void (*fnptr_ty)(void);
815 \\typedef __attribute__((cdecl)) void (*fnptr_attr_ty)(void);