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