mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
parent
5b42c76951
commit
4f43a4b30f
@ -375,28 +375,21 @@ fn printErrMsgToFile(
|
||||
const text = text_buf.toOwnedSlice();
|
||||
|
||||
const stream = &file.outStream().stream;
|
||||
if (!color_on) {
|
||||
try stream.print(
|
||||
"{}:{}:{}: error: {}\n",
|
||||
path,
|
||||
start_loc.line + 1,
|
||||
start_loc.column + 1,
|
||||
text,
|
||||
);
|
||||
return;
|
||||
}
|
||||
try stream.print( "{}:{}:{}: error: {}\n", path, start_loc.line + 1, start_loc.column + 1, text);
|
||||
|
||||
try stream.print(
|
||||
"{}:{}:{}: error: {}\n{}\n",
|
||||
path,
|
||||
start_loc.line + 1,
|
||||
start_loc.column + 1,
|
||||
text,
|
||||
tree.source[start_loc.line_start..start_loc.line_end],
|
||||
);
|
||||
if (!color_on) return;
|
||||
|
||||
// Print \r and \t as one space each so that column counts line up
|
||||
for (tree.source[start_loc.line_start..start_loc.line_end]) |byte| {
|
||||
try stream.writeByte(switch (byte) {
|
||||
'\r', '\t' => ' ',
|
||||
else => byte,
|
||||
});
|
||||
}
|
||||
try stream.writeByte('\n');
|
||||
try stream.writeByteNTimes(' ', start_loc.column);
|
||||
try stream.writeByteNTimes('~', last_token.end - first_token.start);
|
||||
try stream.write("\n");
|
||||
try stream.writeByte('\n');
|
||||
}
|
||||
|
||||
export fn stage2_DepTokenizer_init(input: [*]const u8, len: usize) stage2_DepTokenizer {
|
||||
|
||||
@ -8,6 +8,15 @@ test "zig fmt: change use to usingnamespace" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: whitespace fixes" {
|
||||
try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}",
|
||||
\\test "" {
|
||||
\\ const hi = x;
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: while else err prong with no block" {
|
||||
try testCanonical(
|
||||
\\test "" {
|
||||
|
||||
@ -301,10 +301,7 @@ pub const Tokenizer = struct {
|
||||
const c = self.buffer[self.index];
|
||||
switch (state) {
|
||||
State.Start => switch (c) {
|
||||
' ' => {
|
||||
result.start = self.index + 1;
|
||||
},
|
||||
'\n' => {
|
||||
' ', '\n', '\t', '\r' => {
|
||||
result.start = self.index + 1;
|
||||
},
|
||||
'c' => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user