mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
fix regressions in comments and string prefixes
This commit is contained in:
parent
35c40f0a70
commit
1f49460dcb
@ -1049,7 +1049,6 @@ pub const Tokenizer = struct {
|
||||
.LineComment => switch (c) {
|
||||
'\n' => {
|
||||
result.id = .LineComment;
|
||||
self.index += 1;
|
||||
break;
|
||||
},
|
||||
else => {},
|
||||
|
||||
@ -5129,7 +5129,14 @@ fn parseCNumLit(c: *Context, tok: *CToken, source: []const u8, source_loc: ZigCl
|
||||
} else unreachable;
|
||||
}
|
||||
|
||||
fn zigifyEscapeSequences(ctx: *Context, source: []const u8, name: []const u8, source_loc: ZigClangSourceLocation) ![]const u8 {
|
||||
fn zigifyEscapeSequences(ctx: *Context, source_bytes: []const u8, name: []const u8, source_loc: ZigClangSourceLocation) ![]const u8 {
|
||||
var source = source_bytes;
|
||||
for (source) |c, i| {
|
||||
if (c == '\"' or c == '\'') {
|
||||
source = source[i..];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (source) |c| {
|
||||
if (c == '\\') {
|
||||
break;
|
||||
|
||||
@ -626,6 +626,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
"pub const bar = @as(c_longdouble, 16.e-2);",
|
||||
});
|
||||
|
||||
cases.add("comments",
|
||||
\\#define foo 1 //foo
|
||||
\\#define bar /* bar */ 2
|
||||
, &[_][]const u8{
|
||||
"pub const foo = 1;",
|
||||
"pub const bar = 2;",
|
||||
});
|
||||
|
||||
cases.add("string prefix",
|
||||
\\#define foo L"hello"
|
||||
, &[_][]const u8{
|
||||
"pub const foo = \"hello\";",
|
||||
});
|
||||
|
||||
cases.add("null statements",
|
||||
\\void foo(void) {
|
||||
\\ ;;;;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user