| ... | @@ -664,7 +664,7 @@ pub const ArgIteratorWasi = struct { | ... | @@ -664,7 +664,7 @@ pub const ArgIteratorWasi = struct { |
| 664 | pub const ArgIteratorWindows = struct { | 664 | pub const ArgIteratorWindows = struct { |
| 665 | allocator: Allocator, | 665 | allocator: Allocator, |
| 666 | /// Encoded as WTF-16 LE. | 666 | /// Encoded as WTF-16 LE. |
| 667 | cmd_line: [:0]const u16, | 667 | cmd_line: []const u16, |
| 668 | index: usize = 0, | 668 | index: usize = 0, |
| 669 | /// Owned by the iterator. Long enough to hold contiguous NUL-terminated slices | 669 | /// Owned by the iterator. Long enough to hold contiguous NUL-terminated slices |
| 670 | /// of each argument encoded as WTF-8. | 670 | /// of each argument encoded as WTF-8. |
| ... | @@ -678,9 +678,8 @@ pub const ArgIteratorWindows = struct { | ... | @@ -678,9 +678,8 @@ pub const ArgIteratorWindows = struct { |
| 678 | /// | 678 | /// |
| 679 | /// The iterator stores and uses `cmd_line_w`, so its memory must be valid for | 679 | /// The iterator stores and uses `cmd_line_w`, so its memory must be valid for |
| 680 | /// at least as long as the returned ArgIteratorWindows. | 680 | /// at least as long as the returned ArgIteratorWindows. |
| 681 | pub fn init(allocator: Allocator, cmd_line_w: [*:0]const u16) InitError!ArgIteratorWindows { | 681 | pub fn init(allocator: Allocator, cmd_line_w: []const u16) InitError!ArgIteratorWindows { |
| 682 | const cmd_line = mem.sliceTo(cmd_line_w, 0); | 682 | const wtf8_len = unicode.calcWtf8Len(cmd_line_w); |
| 683 | const wtf8_len = unicode.calcWtf8Len(cmd_line); | | |
| 684 | | 683 | |
| 685 | // This buffer must be large enough to contain contiguous NUL-terminated slices | 684 | // This buffer must be large enough to contain contiguous NUL-terminated slices |
| 686 | // of each argument. | 685 | // of each argument. |
| ... | @@ -694,7 +693,7 @@ pub const ArgIteratorWindows = struct { | ... | @@ -694,7 +693,7 @@ pub const ArgIteratorWindows = struct { |
| 694 | | 693 | |
| 695 | return .{ | 694 | return .{ |
| 696 | .allocator = allocator, | 695 | .allocator = allocator, |
| 697 | .cmd_line = cmd_line, | 696 | .cmd_line = cmd_line_w, |
| 698 | .buffer = buffer, | 697 | .buffer = buffer, |
| 699 | }; | 698 | }; |
| 700 | } | 699 | } |
| ... | @@ -1151,8 +1150,8 @@ pub const ArgIterator = struct { | ... | @@ -1151,8 +1150,8 @@ pub const ArgIterator = struct { |
| 1151 | } | 1150 | } |
| 1152 | if (native_os == .windows) { | 1151 | if (native_os == .windows) { |
| 1153 | const cmd_line = std.os.windows.peb().ProcessParameters.CommandLine; | 1152 | const cmd_line = std.os.windows.peb().ProcessParameters.CommandLine; |
| 1154 | const cmd_line_w = cmd_line.Buffer.?[0 .. cmd_line.Length / 2 :0]; | 1153 | const cmd_line_w = cmd_line.Buffer.?[0 .. cmd_line.Length / 2]; |
| 1155 | return ArgIterator{ .inner = try InnerType.init(allocator, cmd_line_w.ptr) }; | 1154 | return ArgIterator{ .inner = try InnerType.init(allocator, cmd_line_w) }; |
| 1156 | } | 1155 | } |
| 1157 | | 1156 | |
| 1158 | return ArgIterator{ .inner = InnerType.init() }; | 1157 | return ArgIterator{ .inner = InnerType.init() }; |