lib: fmt fprint family over io.handle; remove the fdsink workaround (#5)
Graduates the fmt fprint family (fprint/fprintf/fprintln/fprintfln + internal putbytes/writeone/format*) from io.stream to io.handle, so a file (fd) prints directly through io.write's file-arm (commit-1). Removes the fdsink placeholder -- the fake-stream-vtable-over-os.write shim that stood in for the missing handle. The 8 stdio wrappers route over os.STD{OUT,ERR}_FILENO (new i32 filenos in lib/os; os is the import floor, so it can't hold an io.file-typed handle like Hare's os::stdout_file -- consumers cast i32 to io.file). Migrates the fd-shim sentinel tests 777/780/781 to fprint-over-handle as their headers designed, cstage-only per the pre-existing #209 (fmt is wwstage-uncompilable). Regenerates the 6 os-embedding combined.ww.
This commit is contained in:
11
lib/os/os.ww
11
lib/os/os.ww
@@ -91,6 +91,17 @@ export fn exit(code: i32) void = {
|
||||
export def PATH_MAX: i32 = 4096;
|
||||
let pathbuf: [4096]u8;
|
||||
|
||||
// ref/hare/sys/+linux/types.ha:886-888. ww folds `sys` into `os`, so the
|
||||
// std fd NUMBERS live here (the sys role). Typed i32, NOT io.file as in
|
||||
// Hare's os::stdout_file (ref/hare/os/+linux/stdfd.ha:28): Hare's `os`
|
||||
// imports `io`, but ww's `os` is the import floor and must never import
|
||||
// io (lib/CLAUDE.md) — so the io.file/io.handle binding can't live here.
|
||||
// Consumers (lib/fmt's stdio wrappers) cast i32→io.file at the use site,
|
||||
// where the handle layer is already in scope.
|
||||
export def STDIN_FILENO: i32 = 0;
|
||||
export def STDOUT_FILENO: i32 = 1;
|
||||
export def STDERR_FILENO: i32 = 2;
|
||||
|
||||
fn kpath(p: str) *u8 = {
|
||||
if (p.len + 1 >= PATH_MAX) { return nil: *u8; }; // ENAMETOOLONG
|
||||
let i: i32 = 0;
|
||||
|
||||
Reference in New Issue
Block a user