| ... | @@ -28,9 +28,9 @@ pub fn fatal(comptime format: []const u8, args: anytype) noreturn { | ... | @@ -28,9 +28,9 @@ pub fn fatal(comptime format: []const u8, args: anytype) noreturn { |
| 28 | pub const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB | 28 | pub const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB |
| 29 | | 29 | |
| 30 | pub const Color = enum { | 30 | pub const Color = enum { |
| 31 | Auto, | 31 | auto, |
| 32 | Off, | 32 | off, |
| 33 | On, | 33 | on, |
| 34 | }; | 34 | }; |
| 35 | | 35 | |
| 36 | const usage = | 36 | const usage = |
| ... | @@ -380,7 +380,7 @@ fn buildOutputType( | ... | @@ -380,7 +380,7 @@ fn buildOutputType( |
| 380 | run, | 380 | run, |
| 381 | }, | 381 | }, |
| 382 | ) !void { | 382 | ) !void { |
| 383 | var color: Color = .Auto; | 383 | var color: Color = .auto; |
| 384 | var optimize_mode: std.builtin.Mode = .Debug; | 384 | var optimize_mode: std.builtin.Mode = .Debug; |
| 385 | var provided_name: ?[]const u8 = null; | 385 | var provided_name: ?[]const u8 = null; |
| 386 | var link_mode: ?std.builtin.LinkMode = null; | 386 | var link_mode: ?std.builtin.LinkMode = null; |
| ... | @@ -585,15 +585,9 @@ fn buildOutputType( | ... | @@ -585,15 +585,9 @@ fn buildOutputType( |
| 585 | } | 585 | } |
| 586 | i += 1; | 586 | i += 1; |
| 587 | const next_arg = args[i]; | 587 | const next_arg = args[i]; |
| 588 | if (mem.eql(u8, next_arg, "auto")) { | 588 | color = std.meta.stringToEnum(Color, next_arg) orelse { |
| 589 | color = .Auto; | | |
| 590 | } else if (mem.eql(u8, next_arg, "on")) { | | |
| 591 | color = .On; | | |
| 592 | } else if (mem.eql(u8, next_arg, "off")) { | | |
| 593 | color = .Off; | | |
| 594 | } else { | | |
| 595 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); | 589 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); |
| 596 | } | 590 | }; |
| 597 | } else if (mem.eql(u8, arg, "--subsystem")) { | 591 | } else if (mem.eql(u8, arg, "--subsystem")) { |
| 598 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); | 592 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); |
| 599 | i += 1; | 593 | i += 1; |
| ... | @@ -2374,7 +2368,7 @@ const Fmt = struct { | ... | @@ -2374,7 +2368,7 @@ const Fmt = struct { |
| 2374 | | 2368 | |
| 2375 | pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | 2369 | pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2376 | const stderr_file = io.getStdErr(); | 2370 | const stderr_file = io.getStdErr(); |
| 2377 | var color: Color = .Auto; | 2371 | var color: Color = .auto; |
| 2378 | var stdin_flag: bool = false; | 2372 | var stdin_flag: bool = false; |
| 2379 | var check_flag: bool = false; | 2373 | var check_flag: bool = false; |
| 2380 | var input_files = ArrayList([]const u8).init(gpa); | 2374 | var input_files = ArrayList([]const u8).init(gpa); |
| ... | @@ -2394,15 +2388,9 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2394,15 +2388,9 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2394 | } | 2388 | } |
| 2395 | i += 1; | 2389 | i += 1; |
| 2396 | const next_arg = args[i]; | 2390 | const next_arg = args[i]; |
| 2397 | if (mem.eql(u8, next_arg, "auto")) { | 2391 | color = std.meta.stringToEnum(Color, next_arg) orelse { |
| 2398 | color = .Auto; | | |
| 2399 | } else if (mem.eql(u8, next_arg, "on")) { | | |
| 2400 | color = .On; | | |
| 2401 | } else if (mem.eql(u8, next_arg, "off")) { | | |
| 2402 | color = .Off; | | |
| 2403 | } else { | | |
| 2404 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); | 2392 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); |
| 2405 | } | 2393 | }; |
| 2406 | } else if (mem.eql(u8, arg, "--stdin")) { | 2394 | } else if (mem.eql(u8, arg, "--stdin")) { |
| 2407 | stdin_flag = true; | 2395 | stdin_flag = true; |
| 2408 | } else if (mem.eql(u8, arg, "--check")) { | 2396 | } else if (mem.eql(u8, arg, "--check")) { |
| ... | @@ -2626,9 +2614,9 @@ fn printErrMsgToFile( | ... | @@ -2626,9 +2614,9 @@ fn printErrMsgToFile( |
| 2626 | color: Color, | 2614 | color: Color, |
| 2627 | ) !void { | 2615 | ) !void { |
| 2628 | const color_on = switch (color) { | 2616 | const color_on = switch (color) { |
| 2629 | .Auto => file.isTty(), | 2617 | .auto => file.isTty(), |
| 2630 | .On => true, | 2618 | .on => true, |
| 2631 | .Off => false, | 2619 | .off => false, |
| 2632 | }; | 2620 | }; |
| 2633 | const lok_token = parse_error.loc(); | 2621 | const lok_token = parse_error.loc(); |
| 2634 | const span_first = lok_token; | 2622 | const span_first = lok_token; |