ww source: align UTF-8 BOM placement
This commit is contained in:
@@ -5594,7 +5594,19 @@ fn sepemitbody(fd: i32, path: *u8, modpath: *u8) i32 = {
|
||||
return -1;
|
||||
};
|
||||
};
|
||||
if (!sepwriteall(fd, bufp, blen)
|
||||
// Each physical source owns its own first-codepoint position. The compiler
|
||||
// sees one synthetic aggregate, so replace the optional UTF-8 BOM with
|
||||
// position-preserving whitespace rather than making it a mid-unit BOM.
|
||||
let off: u64 = 0u64;
|
||||
if (blen >= 3u64 && bufp[0] == 0xefu8
|
||||
&& bufp[1] == 0xbbu8 && bufp[2] == 0xbfu8) {
|
||||
off = 3u64;
|
||||
};
|
||||
if (off != 0u64 && !sepwriteall(fd, " ".ptr, 3u64)) {
|
||||
cerr("ww: cannot write package unit\n");
|
||||
return -1;
|
||||
};
|
||||
if (!sepwriteall(fd, bufp + off, blen - off)
|
||||
|| !sepwriteall(fd, "\n".ptr, 1u64)) {
|
||||
cerr("ww: cannot write package unit\n");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user