| ... | ... | @@ -520,8 +520,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 520 | 520 | // - or / on its own is an error |
| 521 | 521 | else => { |
| 522 | 522 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 523 | | var msg_writer = err_details.msg.writer(allocator); |
| 524 | | try msg_writer.print("invalid option: {s}", .{arg.prefixSlice()}); |
| 523 | try err_details.msg.print(allocator, "invalid option: {s}", .{arg.prefixSlice()}); |
| 525 | 524 | try diagnostics.append(err_details); |
| 526 | 525 | arg_i += 1; |
| 527 | 526 | continue :next_arg; |
| ... | ... | @@ -532,8 +531,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 532 | 531 | const args_remaining = args.len - arg_i; |
| 533 | 532 | if (args_remaining <= 2 and arg.looksLikeFilepath()) { |
| 534 | 533 | var err_details = Diagnostics.ErrorDetails{ .type = .note, .print_args = true, .arg_index = arg_i }; |
| 535 | | var msg_writer = err_details.msg.writer(allocator); |
| 536 | | try msg_writer.writeAll("this argument was inferred to be a filepath, so argument parsing was terminated"); |
| 534 | try err_details.msg.appendSlice(allocator, "this argument was inferred to be a filepath, so argument parsing was terminated"); |
| 537 | 535 | try diagnostics.append(err_details); |
| 538 | 536 | |
| 539 | 537 | break; |
| ... | ... | @@ -550,16 +548,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 550 | 548 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":output-format")) { |
| 551 | 549 | const value = arg.value(":output-format".len, arg_i, args) catch { |
| 552 | 550 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 553 | | var msg_writer = err_details.msg.writer(allocator); |
| 554 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":output-format".len) }); |
| 551 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":output-format".len) }); |
| 555 | 552 | try diagnostics.append(err_details); |
| 556 | 553 | arg_i += 1; |
| 557 | 554 | break :next_arg; |
| 558 | 555 | }; |
| 559 | 556 | output_format = std.meta.stringToEnum(Options.OutputFormat, value.slice) orelse blk: { |
| 560 | 557 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 561 | | var msg_writer = err_details.msg.writer(allocator); |
| 562 | | try msg_writer.print("invalid output format setting: {s} ", .{value.slice}); |
| 558 | try err_details.msg.print(allocator, "invalid output format setting: {s} ", .{value.slice}); |
| 563 | 559 | try diagnostics.append(err_details); |
| 564 | 560 | break :blk output_format; |
| 565 | 561 | }; |
| ... | ... | @@ -569,16 +565,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 569 | 565 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":auto-includes")) { |
| 570 | 566 | const value = arg.value(":auto-includes".len, arg_i, args) catch { |
| 571 | 567 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 572 | | var msg_writer = err_details.msg.writer(allocator); |
| 573 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":auto-includes".len) }); |
| 568 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":auto-includes".len) }); |
| 574 | 569 | try diagnostics.append(err_details); |
| 575 | 570 | arg_i += 1; |
| 576 | 571 | break :next_arg; |
| 577 | 572 | }; |
| 578 | 573 | options.auto_includes = std.meta.stringToEnum(Options.AutoIncludes, value.slice) orelse blk: { |
| 579 | 574 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 580 | | var msg_writer = err_details.msg.writer(allocator); |
| 581 | | try msg_writer.print("invalid auto includes setting: {s} ", .{value.slice}); |
| 575 | try err_details.msg.print(allocator, "invalid auto includes setting: {s} ", .{value.slice}); |
| 582 | 576 | try diagnostics.append(err_details); |
| 583 | 577 | break :blk options.auto_includes; |
| 584 | 578 | }; |
| ... | ... | @@ -587,16 +581,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 587 | 581 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":input-format")) { |
| 588 | 582 | const value = arg.value(":input-format".len, arg_i, args) catch { |
| 589 | 583 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 590 | | var msg_writer = err_details.msg.writer(allocator); |
| 591 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":input-format".len) }); |
| 584 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":input-format".len) }); |
| 592 | 585 | try diagnostics.append(err_details); |
| 593 | 586 | arg_i += 1; |
| 594 | 587 | break :next_arg; |
| 595 | 588 | }; |
| 596 | 589 | input_format = std.meta.stringToEnum(Options.InputFormat, value.slice) orelse blk: { |
| 597 | 590 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 598 | | var msg_writer = err_details.msg.writer(allocator); |
| 599 | | try msg_writer.print("invalid input format setting: {s} ", .{value.slice}); |
| 591 | try err_details.msg.print(allocator, "invalid input format setting: {s} ", .{value.slice}); |
| 600 | 592 | try diagnostics.append(err_details); |
| 601 | 593 | break :blk input_format; |
| 602 | 594 | }; |
| ... | ... | @@ -606,16 +598,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 606 | 598 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":depfile-fmt")) { |
| 607 | 599 | const value = arg.value(":depfile-fmt".len, arg_i, args) catch { |
| 608 | 600 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 609 | | var msg_writer = err_details.msg.writer(allocator); |
| 610 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":depfile-fmt".len) }); |
| 601 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":depfile-fmt".len) }); |
| 611 | 602 | try diagnostics.append(err_details); |
| 612 | 603 | arg_i += 1; |
| 613 | 604 | break :next_arg; |
| 614 | 605 | }; |
| 615 | 606 | options.depfile_fmt = std.meta.stringToEnum(Options.DepfileFormat, value.slice) orelse blk: { |
| 616 | 607 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 617 | | var msg_writer = err_details.msg.writer(allocator); |
| 618 | | try msg_writer.print("invalid depfile format setting: {s} ", .{value.slice}); |
| 608 | try err_details.msg.print(allocator, "invalid depfile format setting: {s} ", .{value.slice}); |
| 619 | 609 | try diagnostics.append(err_details); |
| 620 | 610 | break :blk options.depfile_fmt; |
| 621 | 611 | }; |
| ... | ... | @@ -624,8 +614,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 624 | 614 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":depfile")) { |
| 625 | 615 | const value = arg.value(":depfile".len, arg_i, args) catch { |
| 626 | 616 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 627 | | var msg_writer = err_details.msg.writer(allocator); |
| 628 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":depfile".len) }); |
| 617 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":depfile".len) }); |
| 629 | 618 | try diagnostics.append(err_details); |
| 630 | 619 | arg_i += 1; |
| 631 | 620 | break :next_arg; |
| ... | ... | @@ -643,8 +632,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 643 | 632 | } else if (std.ascii.startsWithIgnoreCase(arg_name, ":target")) { |
| 644 | 633 | const value = arg.value(":target".len, arg_i, args) catch { |
| 645 | 634 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 646 | | var msg_writer = err_details.msg.writer(allocator); |
| 647 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":target".len) }); |
| 635 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(":target".len) }); |
| 648 | 636 | try diagnostics.append(err_details); |
| 649 | 637 | arg_i += 1; |
| 650 | 638 | break :next_arg; |
| ... | ... | @@ -655,8 +643,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 655 | 643 | const arch_str = target_it.first(); |
| 656 | 644 | const arch = cvtres.supported_targets.Arch.fromStringIgnoreCase(arch_str) orelse { |
| 657 | 645 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 658 | | var msg_writer = err_details.msg.writer(allocator); |
| 659 | | try msg_writer.print("invalid or unsupported target architecture: {s}", .{arch_str}); |
| 646 | try err_details.msg.print(allocator, "invalid or unsupported target architecture: {s}", .{arch_str}); |
| 660 | 647 | try diagnostics.append(err_details); |
| 661 | 648 | arg_i += value.index_increment; |
| 662 | 649 | continue :next_arg; |
| ... | ... | @@ -680,13 +667,11 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 680 | 667 | .prefix_len = arg.prefixSlice().len, |
| 681 | 668 | .value_offset = arg.name_offset + 3, |
| 682 | 669 | } }; |
| 683 | | var msg_writer = err_details.msg.writer(allocator); |
| 684 | | try msg_writer.print("missing value for {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(3) }); |
| 670 | try err_details.msg.print(allocator, "missing value for {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(3) }); |
| 685 | 671 | try diagnostics.append(err_details); |
| 686 | 672 | } |
| 687 | 673 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 688 | | var msg_writer = err_details.msg.writer(allocator); |
| 689 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(3) }); |
| 674 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(3) }); |
| 690 | 675 | try diagnostics.append(err_details); |
| 691 | 676 | arg_i += 1; |
| 692 | 677 | continue :next_arg; |
| ... | ... | @@ -695,16 +680,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 695 | 680 | else if (std.ascii.startsWithIgnoreCase(arg_name, "tn")) { |
| 696 | 681 | const value = arg.value(2, arg_i, args) catch no_value: { |
| 697 | 682 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 698 | | var msg_writer = err_details.msg.writer(allocator); |
| 699 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 683 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 700 | 684 | try diagnostics.append(err_details); |
| 701 | 685 | // dummy zero-length slice starting where the value would have been |
| 702 | 686 | const value_start = arg.name_offset + 2; |
| 703 | 687 | break :no_value Arg.Value{ .slice = arg.full[value_start..value_start] }; |
| 704 | 688 | }; |
| 705 | 689 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 706 | | var msg_writer = err_details.msg.writer(allocator); |
| 707 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 690 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 708 | 691 | try diagnostics.append(err_details); |
| 709 | 692 | arg_i += value.index_increment; |
| 710 | 693 | continue :next_arg; |
| ... | ... | @@ -716,16 +699,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 716 | 699 | { |
| 717 | 700 | const value = arg.value(2, arg_i, args) catch no_value: { |
| 718 | 701 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 719 | | var msg_writer = err_details.msg.writer(allocator); |
| 720 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 702 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 721 | 703 | try diagnostics.append(err_details); |
| 722 | 704 | // dummy zero-length slice starting where the value would have been |
| 723 | 705 | const value_start = arg.name_offset + 2; |
| 724 | 706 | break :no_value Arg.Value{ .slice = arg.full[value_start..value_start] }; |
| 725 | 707 | }; |
| 726 | 708 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 727 | | var msg_writer = err_details.msg.writer(allocator); |
| 728 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 709 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 729 | 710 | try diagnostics.append(err_details); |
| 730 | 711 | arg_i += value.index_increment; |
| 731 | 712 | continue :next_arg; |
| ... | ... | @@ -733,8 +714,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 733 | 714 | // Unsupported MUI options that do not need a value |
| 734 | 715 | else if (std.ascii.startsWithIgnoreCase(arg_name, "g1")) { |
| 735 | 716 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionSpan(2) }; |
| 736 | | var msg_writer = err_details.msg.writer(allocator); |
| 737 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 717 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 738 | 718 | try diagnostics.append(err_details); |
| 739 | 719 | arg.name_offset += 2; |
| 740 | 720 | } |
| ... | ... | @@ -747,15 +727,13 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 747 | 727 | std.ascii.startsWithIgnoreCase(arg_name, "ta")) |
| 748 | 728 | { |
| 749 | 729 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionSpan(2) }; |
| 750 | | var msg_writer = err_details.msg.writer(allocator); |
| 751 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 730 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 752 | 731 | try diagnostics.append(err_details); |
| 753 | 732 | arg.name_offset += 2; |
| 754 | 733 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "fo")) { |
| 755 | 734 | const value = arg.value(2, arg_i, args) catch { |
| 756 | 735 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 757 | | var msg_writer = err_details.msg.writer(allocator); |
| 758 | | try msg_writer.print("missing output path after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 736 | try err_details.msg.print(allocator, "missing output path after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 759 | 737 | try diagnostics.append(err_details); |
| 760 | 738 | arg_i += 1; |
| 761 | 739 | break :next_arg; |
| ... | ... | @@ -767,8 +745,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 767 | 745 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "sl")) { |
| 768 | 746 | const value = arg.value(2, arg_i, args) catch { |
| 769 | 747 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 770 | | var msg_writer = err_details.msg.writer(allocator); |
| 771 | | try msg_writer.print("missing language tag after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 748 | try err_details.msg.print(allocator, "missing language tag after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 772 | 749 | try diagnostics.append(err_details); |
| 773 | 750 | arg_i += 1; |
| 774 | 751 | break :next_arg; |
| ... | ... | @@ -776,24 +753,20 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 776 | 753 | const percent_str = value.slice; |
| 777 | 754 | const percent: u32 = parsePercent(percent_str) catch { |
| 778 | 755 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 779 | | var msg_writer = err_details.msg.writer(allocator); |
| 780 | | try msg_writer.print("invalid percent format '{s}'", .{percent_str}); |
| 756 | try err_details.msg.print(allocator, "invalid percent format '{s}'", .{percent_str}); |
| 781 | 757 | try diagnostics.append(err_details); |
| 782 | 758 | var note_details = Diagnostics.ErrorDetails{ .type = .note, .print_args = false, .arg_index = arg_i }; |
| 783 | | var note_writer = note_details.msg.writer(allocator); |
| 784 | | try note_writer.writeAll("string length percent must be an integer between 1 and 100 (inclusive)"); |
| 759 | try note_details.msg.appendSlice(allocator, "string length percent must be an integer between 1 and 100 (inclusive)"); |
| 785 | 760 | try diagnostics.append(note_details); |
| 786 | 761 | arg_i += value.index_increment; |
| 787 | 762 | continue :next_arg; |
| 788 | 763 | }; |
| 789 | 764 | if (percent == 0 or percent > 100) { |
| 790 | 765 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 791 | | var msg_writer = err_details.msg.writer(allocator); |
| 792 | | try msg_writer.print("percent out of range: {} (parsed from '{s}')", .{ percent, percent_str }); |
| 766 | try err_details.msg.print(allocator, "percent out of range: {} (parsed from '{s}')", .{ percent, percent_str }); |
| 793 | 767 | try diagnostics.append(err_details); |
| 794 | 768 | var note_details = Diagnostics.ErrorDetails{ .type = .note, .print_args = false, .arg_index = arg_i }; |
| 795 | | var note_writer = note_details.msg.writer(allocator); |
| 796 | | try note_writer.writeAll("string length percent must be an integer between 1 and 100 (inclusive)"); |
| 769 | try note_details.msg.appendSlice(allocator, "string length percent must be an integer between 1 and 100 (inclusive)"); |
| 797 | 770 | try diagnostics.append(note_details); |
| 798 | 771 | arg_i += value.index_increment; |
| 799 | 772 | continue :next_arg; |
| ... | ... | @@ -805,8 +778,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 805 | 778 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "ln")) { |
| 806 | 779 | const value = arg.value(2, arg_i, args) catch { |
| 807 | 780 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 808 | | var msg_writer = err_details.msg.writer(allocator); |
| 809 | | try msg_writer.print("missing language tag after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 781 | try err_details.msg.print(allocator, "missing language tag after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(2) }); |
| 810 | 782 | try diagnostics.append(err_details); |
| 811 | 783 | arg_i += 1; |
| 812 | 784 | break :next_arg; |
| ... | ... | @@ -814,16 +786,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 814 | 786 | const tag = value.slice; |
| 815 | 787 | options.default_language_id = lang.tagToInt(tag) catch { |
| 816 | 788 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 817 | | var msg_writer = err_details.msg.writer(allocator); |
| 818 | | try msg_writer.print("invalid language tag: {s}", .{tag}); |
| 789 | try err_details.msg.print(allocator, "invalid language tag: {s}", .{tag}); |
| 819 | 790 | try diagnostics.append(err_details); |
| 820 | 791 | arg_i += value.index_increment; |
| 821 | 792 | continue :next_arg; |
| 822 | 793 | }; |
| 823 | 794 | if (options.default_language_id.? == lang.LOCALE_CUSTOM_UNSPECIFIED) { |
| 824 | 795 | var err_details = Diagnostics.ErrorDetails{ .type = .warning, .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 825 | | var msg_writer = err_details.msg.writer(allocator); |
| 826 | | try msg_writer.print("language tag '{s}' does not have an assigned ID so it will be resolved to LOCALE_CUSTOM_UNSPECIFIED (id=0x{x})", .{ tag, lang.LOCALE_CUSTOM_UNSPECIFIED }); |
| 796 | try err_details.msg.print(allocator, "language tag '{s}' does not have an assigned ID so it will be resolved to LOCALE_CUSTOM_UNSPECIFIED (id=0x{x})", .{ tag, lang.LOCALE_CUSTOM_UNSPECIFIED }); |
| 827 | 797 | try diagnostics.append(err_details); |
| 828 | 798 | } |
| 829 | 799 | arg_i += value.index_increment; |
| ... | ... | @@ -831,8 +801,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 831 | 801 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "l")) { |
| 832 | 802 | const value = arg.value(1, arg_i, args) catch { |
| 833 | 803 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 834 | | var msg_writer = err_details.msg.writer(allocator); |
| 835 | | try msg_writer.print("missing language ID after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 804 | try err_details.msg.print(allocator, "missing language ID after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 836 | 805 | try diagnostics.append(err_details); |
| 837 | 806 | arg_i += 1; |
| 838 | 807 | break :next_arg; |
| ... | ... | @@ -840,8 +809,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 840 | 809 | const num_str = value.slice; |
| 841 | 810 | options.default_language_id = lang.parseInt(num_str) catch { |
| 842 | 811 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 843 | | var msg_writer = err_details.msg.writer(allocator); |
| 844 | | try msg_writer.print("invalid language ID: {s}", .{num_str}); |
| 812 | try err_details.msg.print(allocator, "invalid language ID: {s}", .{num_str}); |
| 845 | 813 | try diagnostics.append(err_details); |
| 846 | 814 | arg_i += value.index_increment; |
| 847 | 815 | continue :next_arg; |
| ... | ... | @@ -860,16 +828,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 860 | 828 | { |
| 861 | 829 | const value = arg.value(1, arg_i, args) catch no_value: { |
| 862 | 830 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 863 | | var msg_writer = err_details.msg.writer(allocator); |
| 864 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 831 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 865 | 832 | try diagnostics.append(err_details); |
| 866 | 833 | // dummy zero-length slice starting where the value would have been |
| 867 | 834 | const value_start = arg.name_offset + 1; |
| 868 | 835 | break :no_value Arg.Value{ .slice = arg.full[value_start..value_start] }; |
| 869 | 836 | }; |
| 870 | 837 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 871 | | var msg_writer = err_details.msg.writer(allocator); |
| 872 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 838 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 873 | 839 | try diagnostics.append(err_details); |
| 874 | 840 | arg_i += value.index_increment; |
| 875 | 841 | continue :next_arg; |
| ... | ... | @@ -882,16 +848,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 882 | 848 | { |
| 883 | 849 | const value = arg.value(1, arg_i, args) catch no_value: { |
| 884 | 850 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 885 | | var msg_writer = err_details.msg.writer(allocator); |
| 886 | | try msg_writer.print("missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 851 | try err_details.msg.print(allocator, "missing value after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 887 | 852 | try diagnostics.append(err_details); |
| 888 | 853 | // dummy zero-length slice starting where the value would have been |
| 889 | 854 | const value_start = arg.name_offset + 1; |
| 890 | 855 | break :no_value Arg.Value{ .slice = arg.full[value_start..value_start] }; |
| 891 | 856 | }; |
| 892 | 857 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 893 | | var msg_writer = err_details.msg.writer(allocator); |
| 894 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 858 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 895 | 859 | try diagnostics.append(err_details); |
| 896 | 860 | arg_i += value.index_increment; |
| 897 | 861 | continue :next_arg; |
| ... | ... | @@ -899,15 +863,13 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 899 | 863 | // 1 char unsupported LCX/LCE options that do not need a value |
| 900 | 864 | else if (std.ascii.startsWithIgnoreCase(arg_name, "t")) { |
| 901 | 865 | var err_details = Diagnostics.ErrorDetails{ .type = .err, .arg_index = arg_i, .arg_span = arg.optionSpan(1) }; |
| 902 | | var msg_writer = err_details.msg.writer(allocator); |
| 903 | | try msg_writer.print("the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 866 | try err_details.msg.print(allocator, "the {s}{s} option is unsupported", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 904 | 867 | try diagnostics.append(err_details); |
| 905 | 868 | arg.name_offset += 1; |
| 906 | 869 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "c")) { |
| 907 | 870 | const value = arg.value(1, arg_i, args) catch { |
| 908 | 871 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 909 | | var msg_writer = err_details.msg.writer(allocator); |
| 910 | | try msg_writer.print("missing code page ID after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 872 | try err_details.msg.print(allocator, "missing code page ID after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 911 | 873 | try diagnostics.append(err_details); |
| 912 | 874 | arg_i += 1; |
| 913 | 875 | break :next_arg; |
| ... | ... | @@ -915,8 +877,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 915 | 877 | const num_str = value.slice; |
| 916 | 878 | const code_page_id = std.fmt.parseUnsigned(u16, num_str, 10) catch { |
| 917 | 879 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 918 | | var msg_writer = err_details.msg.writer(allocator); |
| 919 | | try msg_writer.print("invalid code page ID: {s}", .{num_str}); |
| 880 | try err_details.msg.print(allocator, "invalid code page ID: {s}", .{num_str}); |
| 920 | 881 | try diagnostics.append(err_details); |
| 921 | 882 | arg_i += value.index_increment; |
| 922 | 883 | continue :next_arg; |
| ... | ... | @@ -924,16 +885,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 924 | 885 | options.default_code_page = code_pages.getByIdentifierEnsureSupported(code_page_id) catch |err| switch (err) { |
| 925 | 886 | error.InvalidCodePage => { |
| 926 | 887 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 927 | | var msg_writer = err_details.msg.writer(allocator); |
| 928 | | try msg_writer.print("invalid or unknown code page ID: {}", .{code_page_id}); |
| 888 | try err_details.msg.print(allocator, "invalid or unknown code page ID: {}", .{code_page_id}); |
| 929 | 889 | try diagnostics.append(err_details); |
| 930 | 890 | arg_i += value.index_increment; |
| 931 | 891 | continue :next_arg; |
| 932 | 892 | }, |
| 933 | 893 | error.UnsupportedCodePage => { |
| 934 | 894 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 935 | | var msg_writer = err_details.msg.writer(allocator); |
| 936 | | try msg_writer.print("unsupported code page: {s} (id={})", .{ |
| 895 | try err_details.msg.print(allocator, "unsupported code page: {s} (id={})", .{ |
| 937 | 896 | @tagName(code_pages.getByIdentifier(code_page_id) catch unreachable), |
| 938 | 897 | code_page_id, |
| 939 | 898 | }); |
| ... | ... | @@ -957,8 +916,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 957 | 916 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "i")) { |
| 958 | 917 | const value = arg.value(1, arg_i, args) catch { |
| 959 | 918 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 960 | | var msg_writer = err_details.msg.writer(allocator); |
| 961 | | try msg_writer.print("missing include path after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 919 | try err_details.msg.print(allocator, "missing include path after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 962 | 920 | try diagnostics.append(err_details); |
| 963 | 921 | arg_i += 1; |
| 964 | 922 | break :next_arg; |
| ... | ... | @@ -986,15 +944,13 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 986 | 944 | // Undocumented option with unknown function |
| 987 | 945 | // TODO: More investigation to figure out what it does (if anything) |
| 988 | 946 | var err_details = Diagnostics.ErrorDetails{ .type = .warning, .arg_index = arg_i, .arg_span = arg.optionSpan(1) }; |
| 989 | | var msg_writer = err_details.msg.writer(allocator); |
| 990 | | try msg_writer.print("option {s}{s} has no effect (it is undocumented and its function is unknown in the Win32 RC compiler)", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 947 | try err_details.msg.print(allocator, "option {s}{s} has no effect (it is undocumented and its function is unknown in the Win32 RC compiler)", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 991 | 948 | try diagnostics.append(err_details); |
| 992 | 949 | arg.name_offset += 1; |
| 993 | 950 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "d")) { |
| 994 | 951 | const value = arg.value(1, arg_i, args) catch { |
| 995 | 952 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 996 | | var msg_writer = err_details.msg.writer(allocator); |
| 997 | | try msg_writer.print("missing symbol to define after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 953 | try err_details.msg.print(allocator, "missing symbol to define after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 998 | 954 | try diagnostics.append(err_details); |
| 999 | 955 | arg_i += 1; |
| 1000 | 956 | break :next_arg; |
| ... | ... | @@ -1009,8 +965,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1009 | 965 | try options.define(symbol, symbol_value); |
| 1010 | 966 | } else { |
| 1011 | 967 | var err_details = Diagnostics.ErrorDetails{ .type = .warning, .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 1012 | | var msg_writer = err_details.msg.writer(allocator); |
| 1013 | | try msg_writer.print("symbol \"{s}\" is not a valid identifier and therefore cannot be defined", .{symbol}); |
| 968 | try err_details.msg.print(allocator, "symbol \"{s}\" is not a valid identifier and therefore cannot be defined", .{symbol}); |
| 1014 | 969 | try diagnostics.append(err_details); |
| 1015 | 970 | } |
| 1016 | 971 | arg_i += value.index_increment; |
| ... | ... | @@ -1018,8 +973,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1018 | 973 | } else if (std.ascii.startsWithIgnoreCase(arg_name, "u")) { |
| 1019 | 974 | const value = arg.value(1, arg_i, args) catch { |
| 1020 | 975 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.missingSpan() }; |
| 1021 | | var msg_writer = err_details.msg.writer(allocator); |
| 1022 | | try msg_writer.print("missing symbol to undefine after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 976 | try err_details.msg.print(allocator, "missing symbol to undefine after {s}{s} option", .{ arg.prefixSlice(), arg.optionWithoutPrefix(1) }); |
| 1023 | 977 | try diagnostics.append(err_details); |
| 1024 | 978 | arg_i += 1; |
| 1025 | 979 | break :next_arg; |
| ... | ... | @@ -1029,16 +983,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1029 | 983 | try options.undefine(symbol); |
| 1030 | 984 | } else { |
| 1031 | 985 | var err_details = Diagnostics.ErrorDetails{ .type = .warning, .arg_index = arg_i, .arg_span = value.argSpan(arg) }; |
| 1032 | | var msg_writer = err_details.msg.writer(allocator); |
| 1033 | | try msg_writer.print("symbol \"{s}\" is not a valid identifier and therefore cannot be undefined", .{symbol}); |
| 986 | try err_details.msg.print(allocator, "symbol \"{s}\" is not a valid identifier and therefore cannot be undefined", .{symbol}); |
| 1034 | 987 | try diagnostics.append(err_details); |
| 1035 | 988 | } |
| 1036 | 989 | arg_i += value.index_increment; |
| 1037 | 990 | continue :next_arg; |
| 1038 | 991 | } else { |
| 1039 | 992 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i, .arg_span = arg.optionAndAfterSpan() }; |
| 1040 | | var msg_writer = err_details.msg.writer(allocator); |
| 1041 | | try msg_writer.print("invalid option: {s}{s}", .{ arg.prefixSlice(), arg.name() }); |
| 993 | try err_details.msg.print(allocator, "invalid option: {s}{s}", .{ arg.prefixSlice(), arg.name() }); |
| 1042 | 994 | try diagnostics.append(err_details); |
| 1043 | 995 | arg_i += 1; |
| 1044 | 996 | continue :next_arg; |
| ... | ... | @@ -1055,16 +1007,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1055 | 1007 | |
| 1056 | 1008 | if (positionals.len == 0) { |
| 1057 | 1009 | var err_details = Diagnostics.ErrorDetails{ .print_args = false, .arg_index = arg_i }; |
| 1058 | | var msg_writer = err_details.msg.writer(allocator); |
| 1059 | | try msg_writer.writeAll("missing input filename"); |
| 1010 | try err_details.msg.appendSlice(allocator, "missing input filename"); |
| 1060 | 1011 | try diagnostics.append(err_details); |
| 1061 | 1012 | |
| 1062 | 1013 | if (args.len > 0) { |
| 1063 | 1014 | const last_arg = args[args.len - 1]; |
| 1064 | 1015 | if (arg_i > 0 and last_arg.len > 0 and last_arg[0] == '/' and isSupportedInputExtension(std.fs.path.extension(last_arg))) { |
| 1065 | 1016 | var note_details = Diagnostics.ErrorDetails{ .type = .note, .print_args = true, .arg_index = arg_i - 1 }; |
| 1066 | | var note_writer = note_details.msg.writer(allocator); |
| 1067 | | try note_writer.writeAll("if this argument was intended to be the input filename, adding -- in front of it will exclude it from option parsing"); |
| 1017 | try note_details.msg.appendSlice(allocator, "if this argument was intended to be the input filename, adding -- in front of it will exclude it from option parsing"); |
| 1068 | 1018 | try diagnostics.append(note_details); |
| 1069 | 1019 | } |
| 1070 | 1020 | } |
| ... | ... | @@ -1099,16 +1049,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1099 | 1049 | if (positionals.len > 1) { |
| 1100 | 1050 | if (output_filename != null) { |
| 1101 | 1051 | var err_details = Diagnostics.ErrorDetails{ .arg_index = arg_i + 1 }; |
| 1102 | | var msg_writer = err_details.msg.writer(allocator); |
| 1103 | | try msg_writer.writeAll("output filename already specified"); |
| 1052 | try err_details.msg.appendSlice(allocator, "output filename already specified"); |
| 1104 | 1053 | try diagnostics.append(err_details); |
| 1105 | 1054 | var note_details = Diagnostics.ErrorDetails{ |
| 1106 | 1055 | .type = .note, |
| 1107 | 1056 | .arg_index = output_filename_context.arg.index, |
| 1108 | 1057 | .arg_span = output_filename_context.arg.value.argSpan(output_filename_context.arg.arg), |
| 1109 | 1058 | }; |
| 1110 | | var note_writer = note_details.msg.writer(allocator); |
| 1111 | | try note_writer.writeAll("output filename previously specified here"); |
| 1059 | try note_details.msg.appendSlice(allocator, "output filename previously specified here"); |
| 1112 | 1060 | try diagnostics.append(note_details); |
| 1113 | 1061 | } else { |
| 1114 | 1062 | output_filename = positionals[1]; |
| ... | ... | @@ -1173,16 +1121,15 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1173 | 1121 | var print_output_format_source_note: bool = false; |
| 1174 | 1122 | if (options.depfile_path != null and (options.input_format == .res or options.output_format == .rcpp)) { |
| 1175 | 1123 | var err_details = Diagnostics.ErrorDetails{ .type = .warning, .arg_index = depfile_context.index, .arg_span = depfile_context.value.argSpan(depfile_context.arg) }; |
| 1176 | | var msg_writer = err_details.msg.writer(allocator); |
| 1177 | 1124 | if (options.input_format == .res) { |
| 1178 | | try msg_writer.print("the {s}{s} option was ignored because the input format is '{s}'", .{ |
| 1125 | try err_details.msg.print(allocator, "the {s}{s} option was ignored because the input format is '{s}'", .{ |
| 1179 | 1126 | depfile_context.arg.prefixSlice(), |
| 1180 | 1127 | depfile_context.arg.optionWithoutPrefix(depfile_context.option_len), |
| 1181 | 1128 | @tagName(options.input_format), |
| 1182 | 1129 | }); |
| 1183 | 1130 | print_input_format_source_note = true; |
| 1184 | 1131 | } else if (options.output_format == .rcpp) { |
| 1185 | | try msg_writer.print("the {s}{s} option was ignored because the output format is '{s}'", .{ |
| 1132 | try err_details.msg.print(allocator, "the {s}{s} option was ignored because the output format is '{s}'", .{ |
| 1186 | 1133 | depfile_context.arg.prefixSlice(), |
| 1187 | 1134 | depfile_context.arg.optionWithoutPrefix(depfile_context.option_len), |
| 1188 | 1135 | @tagName(options.output_format), |
| ... | ... | @@ -1193,16 +1140,14 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1193 | 1140 | } |
| 1194 | 1141 | if (!isSupportedTransformation(options.input_format, options.output_format)) { |
| 1195 | 1142 | var err_details = Diagnostics.ErrorDetails{ .arg_index = input_filename_arg_i, .print_args = false }; |
| 1196 | | var msg_writer = err_details.msg.writer(allocator); |
| 1197 | | try msg_writer.print("input format '{s}' cannot be converted to output format '{s}'", .{ @tagName(options.input_format), @tagName(options.output_format) }); |
| 1143 | try err_details.msg.print(allocator, "input format '{s}' cannot be converted to output format '{s}'", .{ @tagName(options.input_format), @tagName(options.output_format) }); |
| 1198 | 1144 | try diagnostics.append(err_details); |
| 1199 | 1145 | print_input_format_source_note = true; |
| 1200 | 1146 | print_output_format_source_note = true; |
| 1201 | 1147 | } |
| 1202 | 1148 | if (options.preprocess == .only and options.output_format != .rcpp) { |
| 1203 | 1149 | var err_details = Diagnostics.ErrorDetails{ .arg_index = preprocess_only_context.index }; |
| 1204 | | var msg_writer = err_details.msg.writer(allocator); |
| 1205 | | try msg_writer.print("the {s}{s} option cannot be used with output format '{s}'", .{ |
| 1150 | try err_details.msg.print(allocator, "the {s}{s} option cannot be used with output format '{s}'", .{ |
| 1206 | 1151 | preprocess_only_context.arg.prefixSlice(), |
| 1207 | 1152 | preprocess_only_context.arg.optionWithoutPrefix(preprocess_only_context.option_len), |
| 1208 | 1153 | @tagName(options.output_format), |
| ... | ... | @@ -1214,8 +1159,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1214 | 1159 | switch (input_format_source) { |
| 1215 | 1160 | .inferred_from_input_filename => { |
| 1216 | 1161 | var err_details = Diagnostics.ErrorDetails{ .type = .note, .arg_index = input_filename_arg_i }; |
| 1217 | | var msg_writer = err_details.msg.writer(allocator); |
| 1218 | | try msg_writer.writeAll("the input format was inferred from the input filename"); |
| 1162 | try err_details.msg.appendSlice(allocator, "the input format was inferred from the input filename"); |
| 1219 | 1163 | try diagnostics.append(err_details); |
| 1220 | 1164 | }, |
| 1221 | 1165 | .input_format_arg => { |
| ... | ... | @@ -1224,8 +1168,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1224 | 1168 | .arg_index = input_format_context.index, |
| 1225 | 1169 | .arg_span = input_format_context.value.argSpan(input_format_context.arg), |
| 1226 | 1170 | }; |
| 1227 | | var msg_writer = err_details.msg.writer(allocator); |
| 1228 | | try msg_writer.writeAll("the input format was specified here"); |
| 1171 | try err_details.msg.appendSlice(allocator, "the input format was specified here"); |
| 1229 | 1172 | try diagnostics.append(err_details); |
| 1230 | 1173 | }, |
| 1231 | 1174 | } |
| ... | ... | @@ -1234,11 +1177,10 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1234 | 1177 | switch (output_format_source) { |
| 1235 | 1178 | .inferred_from_input_filename, .unable_to_infer_from_input_filename => { |
| 1236 | 1179 | var err_details = Diagnostics.ErrorDetails{ .type = .note, .arg_index = input_filename_arg_i }; |
| 1237 | | var msg_writer = err_details.msg.writer(allocator); |
| 1238 | 1180 | if (output_format_source == .inferred_from_input_filename) { |
| 1239 | | try msg_writer.writeAll("the output format was inferred from the input filename"); |
| 1181 | try err_details.msg.appendSlice(allocator, "the output format was inferred from the input filename"); |
| 1240 | 1182 | } else { |
| 1241 | | try msg_writer.writeAll("the output format was unable to be inferred from the input filename, so the default was used"); |
| 1183 | try err_details.msg.appendSlice(allocator, "the output format was unable to be inferred from the input filename, so the default was used"); |
| 1242 | 1184 | } |
| 1243 | 1185 | try diagnostics.append(err_details); |
| 1244 | 1186 | }, |
| ... | ... | @@ -1248,11 +1190,10 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1248 | 1190 | .arg => |ctx| .{ .type = .note, .arg_index = ctx.index, .arg_span = ctx.value.argSpan(ctx.arg) }, |
| 1249 | 1191 | .unspecified => unreachable, |
| 1250 | 1192 | }; |
| 1251 | | var msg_writer = err_details.msg.writer(allocator); |
| 1252 | 1193 | if (output_format_source == .inferred_from_output_filename) { |
| 1253 | | try msg_writer.writeAll("the output format was inferred from the output filename"); |
| 1194 | try err_details.msg.appendSlice(allocator, "the output format was inferred from the output filename"); |
| 1254 | 1195 | } else { |
| 1255 | | try msg_writer.writeAll("the output format was unable to be inferred from the output filename, so the default was used"); |
| 1196 | try err_details.msg.appendSlice(allocator, "the output format was unable to be inferred from the output filename, so the default was used"); |
| 1256 | 1197 | } |
| 1257 | 1198 | try diagnostics.append(err_details); |
| 1258 | 1199 | }, |
| ... | ... | @@ -1262,14 +1203,12 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 1262 | 1203 | .arg_index = output_format_context.index, |
| 1263 | 1204 | .arg_span = output_format_context.value.argSpan(output_format_context.arg), |
| 1264 | 1205 | }; |
| 1265 | | var msg_writer = err_details.msg.writer(allocator); |
| 1266 | | try msg_writer.writeAll("the output format was specified here"); |
| 1206 | try err_details.msg.appendSlice(allocator, "the output format was specified here"); |
| 1267 | 1207 | try diagnostics.append(err_details); |
| 1268 | 1208 | }, |
| 1269 | 1209 | .inferred_from_preprocess_only => { |
| 1270 | 1210 | var err_details = Diagnostics.ErrorDetails{ .type = .note, .arg_index = preprocess_only_context.index }; |
| 1271 | | var msg_writer = err_details.msg.writer(allocator); |
| 1272 | | try msg_writer.print("the output format was inferred from the usage of the {s}{s} option", .{ |
| 1211 | try err_details.msg.print(allocator, "the output format was inferred from the usage of the {s}{s} option", .{ |
| 1273 | 1212 | preprocess_only_context.arg.prefixSlice(), |
| 1274 | 1213 | preprocess_only_context.arg.optionWithoutPrefix(preprocess_only_context.option_len), |
| 1275 | 1214 | }); |