diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 22:58:58 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 00:57:13 -0300 |
| commit | 243ad6686a7ca5ae31cc8df366a0c9928414732f (patch) | |
| tree | 900e85dfe32c281e27f7eb2461ea1be3a7b0cba3 /src/ninep | |
| parent | 294ad7818adc55d85767ff7a52106deedaa4618a (diff) | |
| download | pardes-243ad6686a7ca5ae31cc8df366a0c9928414732f.tar.gz pardes-243ad6686a7ca5ae31cc8df366a0c9928414732f.zip | |
pane: a PDF's body read from an offset answered its text from twice that offset, so /n/self's 8 KiB reads (fs.readNode) and a mount's reads past the first Rread lost the rest: the text is staged whole and windowed once, by stagedReply; the PDF body test reads at offset 3 too
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 4 | ||||
| -rw-r--r-- | src/ninep/pane.zig | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 2a2131e3..c3658df4 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2264,6 +2264,10 @@ test "a PDF's body reads its page's text layer, and takes no write" { try testing.expect(doc.hasPdf()); const body = Node.of(doc.serial, .body); try testing.expect(std.mem.indexOf(u8, rd(p, body, 0, 4096).bytes, "target.txt") != null); + // Read from an offset, as a mount's chunked reads ask: the text from there. + const whole = try testing.allocator.dupe(u8, rd(p, body, 0, 4096).bytes); + defer testing.allocator.free(whole); + try testing.expectEqualStrings(whole[3..], rd(p, body, 3, 4096).bytes); try testing.expectEqual(E.INVAL, wr(p, body, "more\n").errno()); } diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index d0b368ea..d1668dd7 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -476,9 +476,7 @@ fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { } // A PDF's body is its text layer, the page shown's: read-only. if (pdfText(p, pane)) |text| { - const off = @min(req.off, text.len); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text[off..][0..@min(text.len - off, req.size)]) catch return Reply.fail(req.tag, E.NOMEM); + p.fs.stage(p.gpa).appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } if (req.handle != 0 and pane.isTerminal()) return screen.readSnapshot(p, req, pane); |
