ww source: align UTF-8 BOM placement

This commit is contained in:
2026-08-21 20:34:10 +09:00
parent ee4573bf55
commit 9381f8fb8e
11 changed files with 764 additions and 5 deletions

View File

@@ -724,7 +724,12 @@ fn pkgskipspace(src: str, start: i32) i32 = {
};
fn pkgclause(src: str, out: *str) bool = {
let i: i32 = pkgskipspace(src, 0);
// Match the compiler readers: one UTF-8 BOM is invisible only at the
// first raw source position. The full stage driver owns later-BOM errors.
let start: i32 = 0;
if (src.len >= 3 && src[0] == 0xefu8 && src[1] == 0xbbu8
&& src[2] == 0xbfu8) { start = 3; };
let i: i32 = pkgskipspace(src, start);
let word: str = "package";
if (i + word.len >= src.len) { return false; };
let j: i32 = 0;