aboutsummaryrefslogtreecommitdiff
path: root/src/lib/std.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 10:38:17 +0000
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 10:38:17 +0000
commit93340f97dce404a008f489729df144ace53528ab (patch)
treecbada309f3a4683d083d84484f11952418c8dd2b /src/lib/std.zc
parenttodo: handoff section with state, conventions, in-flight work and architectur... (diff)
fix std hover, full capture terminator, bare static calls, void main in run-only images
- hover: a symbol from an embedded library source (tinyvm:std.zc, tinyvm:icon.zc) was looked up only in the document; look it up by its qualified name in the library source (hover_embedded_sym), and render a method found that way by its line (bs_hover). - std.capture: allocate one word more than the 256 it holds, so end() terminates inside the buffer. - a bare call to a static function of the enclosing struct resolves like a bare struct constant (mstruct is set for every non-generic struct's methods); the struct's own wins over a global. - run.zc declares main untyped (fn main();), so a run-only image accepts int, void or untyped main with both compilers.
Diffstat (limited to 'src/lib/std.zc')
-rw-r--r--src/lib/std.zc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/std.zc b/src/lib/std.zc
index 33ab1e9..772b887 100644
--- a/src/lib/std.zc
+++ b/src/lib/std.zc
@@ -73,7 +73,8 @@ int libinit() {
// rt.put_s("hello world!"); // nothing on the terminal
// std.capture.end(buf);
// rt.put_s(buf); // hello world!
-// the buffer holds 256 characters, and output past that is dropped.
+// the buffer holds 256 characters, and output past that is dropped. it has one
+// more word for the 0 that end() writes, so a full capture is still a string.
// one capture at a time, and the buffer belongs to whoever holds it.
struct capture {
// starts a capture: output goes into a new buffer instead of the terminal.
@@ -81,7 +82,7 @@ struct capture {
static char* start() {
int cap = 256;
rt.outmode = 2; rt.outn = 0; rt.outcap = cap;
- rt.outbuf = rt.new(cap);
+ rt.outbuf = rt.new(cap + 1);
return rt.outbuf;
}
// stops the capture and ends the buffer with a 0.