SIGN IN SIGN UP

Fix Windows argument quoting for backslash runs before quotes (#101)

* Fix Windows argument quoting for backslash runs before quotes

The command line builder doubles a backslash only when the next source
character is a quote. Per the CRT parsing rules, every backslash in a
run preceding a double quote must be doubled, and this includes a run
that ends up before the generated closing quote of a quoted argument.

As a result, a quoted argument ending in a backslash swallows its
closing quote and merges with every following argument, a run of two
or more backslashes before an embedded quote is under-escaped, and a
quoted argument ending in several backslashes loses half of them.

Count backslash runs in the length and emit passes and double the
whole run before an escaped quote or before the closing quote. Extend
the special argv test with the three cases plus a merge canary.

* Simplify Windows argument quoting passes

Rework the two command line builder passes without changing the
emitted bytes. The length pass becomes a linear scan that carries
the current backslash run, and the emit pass folds the duplicated
write loops into the explicit 2n + 1 and 2n CRT formulas.

Extend the special argv test with a quoted argument combining a
space and a backslash run before an embedded quote.

* Add mixed Windows backslash quoting test

🧙 Conjured by AI via [pi.dev](https://pi.dev/) using gpt-5.6-sol

---------

Co-authored-by: Neil Henning <me@neilhenning.dev>
P
Pascal committed
fa43b5b5075b625b23044dd412622a0d051dd64e
Parent: f455031
Committed by GitHub <noreply@github.com> on 8/9/2026, 1:25:56 PM