Repository navigation
Commit 4bd9545
authored
Leave a byte that starts no UTF-8 sequence at the end of a console write (#8621)
* Leave a byte that starts no UTF-8 sequence at the end of a console write
`find_last_utf8_boundary` read every byte at or above 0xc0 as the start of a
sequence, giving 0xf8..=0xff an expected length of 4 and cutting the tail back
to before it. `_find_last_utf8_boundary` stops the four-byte range at 0xf8 and
returns the full length for anything above it, leaving the byte for
MultiByteToWideChar to answer with U+FFFD.
`write_console_utf8` therefore reported fewer bytes written than it was given
whenever one of those bytes fell in the last three, and for a buffer that began
with one it cut the length to 0, converted nothing and returned Ok(0) -- a
write that never advances.
The scan also ran a fourth iteration the C loop does not; the arms happen to
answer the same there, but the bound is now the same 3.
* Drop the expectedFailure on test_winconsoleio's test_write
The marker went stale with the boundary fix in the parent commit. The test
writes `b'\xff'*10` and `data + b'\xff'` to CONOUT$ and asserts the returned
count, which is the case `find_last_utf8_boundary` was answering wrong, so
regrtest now reports it as an unexpected success.1 parent a783ae8 commit 4bd9545
2 files changed
Lines changed: 59 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1724 | 1724 | | |
1725 | 1725 | | |
1726 | 1726 | | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
1727 | 1735 | | |
1728 | 1736 | | |
1729 | | - | |
| 1737 | + | |
1730 | 1738 | | |
1731 | 1739 | | |
| 1740 | + | |
1732 | 1741 | | |
1733 | 1742 | | |
1734 | 1743 | | |
1735 | | - | |
1736 | | - | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
1737 | 1747 | | |
1738 | | - | |
| 1748 | + | |
| 1749 | + | |
1739 | 1750 | | |
1740 | | - | |
| 1751 | + | |
| 1752 | + | |
1741 | 1753 | | |
1742 | | - | |
| 1754 | + | |
1743 | 1755 | | |
1744 | 1756 | | |
| 1757 | + | |
1745 | 1758 | | |
1746 | 1759 | | |
1747 | 1760 | | |
| 1761 | + | |
1748 | 1762 | | |
1749 | 1763 | | |
1750 | 1764 | | |
| |||
2157 | 2171 | | |
2158 | 2172 | | |
2159 | 2173 | | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
0 commit comments