| ... | ... | @@ -281,8 +281,6 @@ pub const ArgIteratorWasi = struct { |
| 281 | 281 | pub const ArgIteratorWindows = struct { |
| 282 | 282 | index: usize, |
| 283 | 283 | cmd_line: [*]const u8, |
| 284 | | in_quote: bool, |
| 285 | | seen_quote_count: usize, |
| 286 | 284 | |
| 287 | 285 | pub const NextError = error{OutOfMemory}; |
| 288 | 286 | |
| ... | ... | @@ -294,8 +292,6 @@ pub const ArgIteratorWindows = struct { |
| 294 | 292 | return ArgIteratorWindows{ |
| 295 | 293 | .index = 0, |
| 296 | 294 | .cmd_line = cmd_line, |
| 297 | | .in_quote = false, |
| 298 | | .seen_quote_count = 0, |
| 299 | 295 | }; |
| 300 | 296 | } |
| 301 | 297 | |
| ... | ... | @@ -326,6 +322,7 @@ pub const ArgIteratorWindows = struct { |
| 326 | 322 | } |
| 327 | 323 | |
| 328 | 324 | var backslash_count: usize = 0; |
| 325 | var in_quote = false; |
| 329 | 326 | while (true) : (self.index += 1) { |
| 330 | 327 | const byte = self.cmd_line[self.index]; |
| 331 | 328 | switch (byte) { |
| ... | ... | @@ -333,14 +330,14 @@ pub const ArgIteratorWindows = struct { |
| 333 | 330 | '"' => { |
| 334 | 331 | const quote_is_real = backslash_count % 2 == 0; |
| 335 | 332 | if (quote_is_real) { |
| 336 | | self.seen_quote_count += 1; |
| 333 | in_quote = !in_quote; |
| 337 | 334 | } |
| 338 | 335 | }, |
| 339 | 336 | '\\' => { |
| 340 | 337 | backslash_count += 1; |
| 341 | 338 | }, |
| 342 | 339 | ' ', '\t' => { |
| 343 | | if (self.seen_quote_count % 2 == 0) { |
| 340 | if (!in_quote) { |
| 344 | 341 | return true; |
| 345 | 342 | } |
| 346 | 343 | backslash_count = 0; |
| ... | ... | @@ -358,6 +355,7 @@ pub const ArgIteratorWindows = struct { |
| 358 | 355 | defer buf.deinit(); |
| 359 | 356 | |
| 360 | 357 | var backslash_count: usize = 0; |
| 358 | var in_quote = false; |
| 361 | 359 | while (true) : (self.index += 1) { |
| 362 | 360 | const byte = self.cmd_line[self.index]; |
| 363 | 361 | switch (byte) { |
| ... | ... | @@ -368,7 +366,7 @@ pub const ArgIteratorWindows = struct { |
| 368 | 366 | backslash_count = 0; |
| 369 | 367 | |
| 370 | 368 | if (quote_is_real) { |
| 371 | | self.seen_quote_count += 1; |
| 369 | in_quote = !in_quote; |
| 372 | 370 | } else { |
| 373 | 371 | try buf.append('"'); |
| 374 | 372 | } |
| ... | ... | @@ -379,7 +377,7 @@ pub const ArgIteratorWindows = struct { |
| 379 | 377 | ' ', '\t' => { |
| 380 | 378 | try self.emitBackslashes(&buf, backslash_count); |
| 381 | 379 | backslash_count = 0; |
| 382 | | if (self.seen_quote_count % 2 == 1) { |
| 380 | if (in_quote) { |
| 383 | 381 | try buf.append(byte); |
| 384 | 382 | } else { |
| 385 | 383 | return buf.toOwnedSlice(); |