| ... | ... | @@ -758,37 +758,36 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1 |
| 758 | 758 | |
| 759 | 759 | /// Caller must dealloc. |
| 760 | 760 | /// Guarantees a null byte at result[result.len]. |
| 761 | | fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![]u8 { |
| 761 | fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![:0]u8 { |
| 762 | 762 | var buf = try Buffer.initSize(allocator, 0); |
| 763 | 763 | defer buf.deinit(); |
| 764 | | |
| 765 | | var buf_stream = buf.outStream(); |
| 764 | const buf_stream = buf.outStream(); |
| 766 | 765 | |
| 767 | 766 | for (argv) |arg, arg_i| { |
| 768 | | if (arg_i != 0) try buf.appendByte(' '); |
| 767 | if (arg_i != 0) try buf_stream.writeByte(' '); |
| 769 | 768 | if (mem.indexOfAny(u8, arg, " \t\n\"") == null) { |
| 770 | | try buf.append(arg); |
| 769 | try buf_stream.writeAll(arg); |
| 771 | 770 | continue; |
| 772 | 771 | } |
| 773 | | try buf.appendByte('"'); |
| 772 | try buf_stream.writeByte('"'); |
| 774 | 773 | var backslash_count: usize = 0; |
| 775 | 774 | for (arg) |byte| { |
| 776 | 775 | switch (byte) { |
| 777 | 776 | '\\' => backslash_count += 1, |
| 778 | 777 | '"' => { |
| 779 | 778 | try buf_stream.writeByteNTimes('\\', backslash_count * 2 + 1); |
| 780 | | try buf.appendByte('"'); |
| 779 | try buf_stream.writeByte('"'); |
| 781 | 780 | backslash_count = 0; |
| 782 | 781 | }, |
| 783 | 782 | else => { |
| 784 | 783 | try buf_stream.writeByteNTimes('\\', backslash_count); |
| 785 | | try buf.appendByte(byte); |
| 784 | try buf_stream.writeByte(byte); |
| 786 | 785 | backslash_count = 0; |
| 787 | 786 | }, |
| 788 | 787 | } |
| 789 | 788 | } |
| 790 | 789 | try buf_stream.writeByteNTimes('\\', backslash_count * 2); |
| 791 | | try buf.appendByte('"'); |
| 790 | try buf_stream.writeByte('"'); |
| 792 | 791 | } |
| 793 | 792 | |
| 794 | 793 | return buf.toOwnedSlice(); |