| ... | ... | @@ -3,7 +3,6 @@ const builtin = std.builtin; |
| 3 | 3 | const os = std.os; |
| 4 | 4 | const fs = std.fs; |
| 5 | 5 | const BufMap = std.BufMap; |
| 6 | | const Buffer = std.Buffer; |
| 7 | 6 | const mem = std.mem; |
| 8 | 7 | const math = std.math; |
| 9 | 8 | const Allocator = mem.Allocator; |
| ... | ... | @@ -266,7 +265,7 @@ pub const ArgIteratorWindows = struct { |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | 267 | fn internalNext(self: *ArgIteratorWindows, allocator: *Allocator) NextError![]u8 { |
| 269 | | var buf = try Buffer.initSize(allocator, 0); |
| 268 | var buf = std.ArrayList(u8).init(allocator); |
| 270 | 269 | defer buf.deinit(); |
| 271 | 270 | |
| 272 | 271 | var backslash_count: usize = 0; |
| ... | ... | @@ -282,10 +281,10 @@ pub const ArgIteratorWindows = struct { |
| 282 | 281 | if (quote_is_real) { |
| 283 | 282 | self.seen_quote_count += 1; |
| 284 | 283 | if (self.seen_quote_count == self.quote_count and self.seen_quote_count % 2 == 1) { |
| 285 | | try buf.appendByte('"'); |
| 284 | try buf.append('"'); |
| 286 | 285 | } |
| 287 | 286 | } else { |
| 288 | | try buf.appendByte('"'); |
| 287 | try buf.append('"'); |
| 289 | 288 | } |
| 290 | 289 | }, |
| 291 | 290 | '\\' => { |
| ... | ... | @@ -295,7 +294,7 @@ pub const ArgIteratorWindows = struct { |
| 295 | 294 | try self.emitBackslashes(&buf, backslash_count); |
| 296 | 295 | backslash_count = 0; |
| 297 | 296 | if (self.seen_quote_count % 2 == 1 and self.seen_quote_count != self.quote_count) { |
| 298 | | try buf.appendByte(byte); |
| 297 | try buf.append(byte); |
| 299 | 298 | } else { |
| 300 | 299 | return buf.toOwnedSlice(); |
| 301 | 300 | } |
| ... | ... | @@ -303,16 +302,16 @@ pub const ArgIteratorWindows = struct { |
| 303 | 302 | else => { |
| 304 | 303 | try self.emitBackslashes(&buf, backslash_count); |
| 305 | 304 | backslash_count = 0; |
| 306 | | try buf.appendByte(byte); |
| 305 | try buf.append(byte); |
| 307 | 306 | }, |
| 308 | 307 | } |
| 309 | 308 | } |
| 310 | 309 | } |
| 311 | 310 | |
| 312 | | fn emitBackslashes(self: *ArgIteratorWindows, buf: *Buffer, emit_count: usize) !void { |
| 311 | fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u8), emit_count: usize) !void { |
| 313 | 312 | var i: usize = 0; |
| 314 | 313 | while (i < emit_count) : (i += 1) { |
| 315 | | try buf.appendByte('\\'); |
| 314 | try buf.append('\\'); |
| 316 | 315 | } |
| 317 | 316 | } |
| 318 | 317 | |
| ... | ... | @@ -410,7 +409,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 { |
| 410 | 409 | |
| 411 | 410 | // TODO refactor to only make 1 allocation. |
| 412 | 411 | var it = args(); |
| 413 | | var contents = try Buffer.initSize(allocator, 0); |
| 412 | var contents = std.ArrayList(u8).init(allocator); |
| 414 | 413 | defer contents.deinit(); |
| 415 | 414 | |
| 416 | 415 | var slice_list = std.ArrayList(usize).init(allocator); |
| ... | ... | @@ -419,7 +418,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 { |
| 419 | 418 | while (it.next(allocator)) |arg_or_err| { |
| 420 | 419 | const arg = try arg_or_err; |
| 421 | 420 | defer allocator.free(arg); |
| 422 | | try contents.append(arg); |
| 421 | try contents.appendSlice(arg); |
| 423 | 422 | try slice_list.append(arg.len); |
| 424 | 423 | } |
| 425 | 424 | |