| ... | @@ -2940,7 +2940,6 @@ const Fmt = struct { | ... | @@ -2940,7 +2940,6 @@ const Fmt = struct { |
| 2940 | }; | 2940 | }; |
| 2941 | | 2941 | |
| 2942 | pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | 2942 | pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2943 | const stderr_file = io.getStdErr(); | | |
| 2944 | var color: Color = .auto; | 2943 | var color: Color = .auto; |
| 2945 | var stdin_flag: bool = false; | 2944 | var stdin_flag: bool = false; |
| 2946 | var check_flag: bool = false; | 2945 | var check_flag: bool = false; |
| ... | @@ -2998,7 +2997,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -2998,7 +2997,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2998 | defer tree.deinit(gpa); | 2997 | defer tree.deinit(gpa); |
| 2999 | | 2998 | |
| 3000 | for (tree.errors) |parse_error| { | 2999 | for (tree.errors) |parse_error| { |
| 3001 | try printErrMsgToFile(gpa, parse_error, tree, "<stdin>", stderr_file, color); | 3000 | try printErrMsgToStdErr(gpa, parse_error, tree, "<stdin>", color); |
| 3002 | } | 3001 | } |
| 3003 | if (tree.errors.len != 0) { | 3002 | if (tree.errors.len != 0) { |
| 3004 | process.exit(1); | 3003 | process.exit(1); |
| ... | @@ -3143,7 +3142,7 @@ fn fmtPathFile( | ... | @@ -3143,7 +3142,7 @@ fn fmtPathFile( |
| 3143 | defer tree.deinit(fmt.gpa); | 3142 | defer tree.deinit(fmt.gpa); |
| 3144 | | 3143 | |
| 3145 | for (tree.errors) |parse_error| { | 3144 | for (tree.errors) |parse_error| { |
| 3146 | try printErrMsgToFile(fmt.gpa, parse_error, tree, file_path, std.io.getStdErr(), fmt.color); | 3145 | try printErrMsgToStdErr(fmt.gpa, parse_error, tree, file_path, fmt.color); |
| 3147 | } | 3146 | } |
| 3148 | if (tree.errors.len != 0) { | 3147 | if (tree.errors.len != 0) { |
| 3149 | fmt.any_error = true; | 3148 | fmt.any_error = true; |
| ... | @@ -3219,12 +3218,11 @@ fn fmtPathFile( | ... | @@ -3219,12 +3218,11 @@ fn fmtPathFile( |
| 3219 | } | 3218 | } |
| 3220 | } | 3219 | } |
| 3221 | | 3220 | |
| 3222 | fn printErrMsgToFile( | 3221 | fn printErrMsgToStdErr( |
| 3223 | gpa: *mem.Allocator, | 3222 | gpa: *mem.Allocator, |
| 3224 | parse_error: ast.Error, | 3223 | parse_error: ast.Error, |
| 3225 | tree: ast.Tree, | 3224 | tree: ast.Tree, |
| 3226 | path: []const u8, | 3225 | path: []const u8, |
| 3227 | file: fs.File, | | |
| 3228 | color: Color, | 3226 | color: Color, |
| 3229 | ) !void { | 3227 | ) !void { |
| 3230 | const lok_token = parse_error.token; | 3228 | const lok_token = parse_error.token; |
| ... | @@ -3770,7 +3768,7 @@ pub fn cmdAstCheck( | ... | @@ -3770,7 +3768,7 @@ pub fn cmdAstCheck( |
| 3770 | defer file.tree.deinit(gpa); | 3768 | defer file.tree.deinit(gpa); |
| 3771 | | 3769 | |
| 3772 | for (file.tree.errors) |parse_error| { | 3770 | for (file.tree.errors) |parse_error| { |
| 3773 | try printErrMsgToFile(gpa, parse_error, file.tree, file.sub_file_path, io.getStdErr(), color); | 3771 | try printErrMsgToStdErr(gpa, parse_error, file.tree, file.sub_file_path, color); |
| 3774 | } | 3772 | } |
| 3775 | if (file.tree.errors.len != 0) { | 3773 | if (file.tree.errors.len != 0) { |
| 3776 | process.exit(1); | 3774 | process.exit(1); |
| ... | @@ -3891,7 +3889,7 @@ pub fn cmdChangelist( | ... | @@ -3891,7 +3889,7 @@ pub fn cmdChangelist( |
| 3891 | defer file.tree.deinit(gpa); | 3889 | defer file.tree.deinit(gpa); |
| 3892 | | 3890 | |
| 3893 | for (file.tree.errors) |parse_error| { | 3891 | for (file.tree.errors) |parse_error| { |
| 3894 | try printErrMsgToFile(gpa, parse_error, file.tree, old_source_file, io.getStdErr(), .auto); | 3892 | try printErrMsgToStdErr(gpa, parse_error, file.tree, old_source_file, .auto); |
| 3895 | } | 3893 | } |
| 3896 | if (file.tree.errors.len != 0) { | 3894 | if (file.tree.errors.len != 0) { |
| 3897 | process.exit(1); | 3895 | process.exit(1); |
| ... | @@ -3928,7 +3926,7 @@ pub fn cmdChangelist( | ... | @@ -3928,7 +3926,7 @@ pub fn cmdChangelist( |
| 3928 | defer new_tree.deinit(gpa); | 3926 | defer new_tree.deinit(gpa); |
| 3929 | | 3927 | |
| 3930 | for (new_tree.errors) |parse_error| { | 3928 | for (new_tree.errors) |parse_error| { |
| 3931 | try printErrMsgToFile(gpa, parse_error, new_tree, new_source_file, io.getStdErr(), .auto); | 3929 | try printErrMsgToStdErr(gpa, parse_error, new_tree, new_source_file, .auto); |
| 3932 | } | 3930 | } |
| 3933 | if (new_tree.errors.len != 0) { | 3931 | if (new_tree.errors.len != 0) { |
| 3934 | process.exit(1); | 3932 | process.exit(1); |