aboutsummaryrefslogtreecommitdiffstats
path: root/prototypes/connections/edit-module.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-25 12:09:41 +0100
committereunhhu <[email protected]>2026-09-25 12:09:41 +0100
commita2a430f6c2d973232a4e995133b372ba877558cf (patch)
treef1e22521ba03ff4683737131eec0af05e6e0cbd4 /prototypes/connections/edit-module.c
parent08056bb65bb9d1cfa4ccb1cd0b9cb67554d560a3 (diff)
downloadpure-a2a430f6c2d973232a4e995133b372ba877558cf.tar.gz
pure-a2a430f6c2d973232a4e995133b372ba877558cf.zip
Add text states and cursors to Pure modules
Module format v3 adds text states, cursors, UTF-8 constants, text inputs and text views. A text state is a runtime-owned draft without a store, so a large text edits as an extent tree. Cursors are byte positions the runtime keeps on character boundaries: insertion pushes cursors at or after the point, removal gathers cursors inside the range, and a failed event returns every text draft and cursor to where it was. The verifier types a cursor by the text it belongs to and rejects editing one text with another's cursor. Operations cover constants, concatenation, shortest round-trip number text, character, line and byte counts, character and column-keeping line moves, insert, remove, line views, whole-text replacement and UTF-8 checked conversion from bytes. Replies of edited documents or texts are copied before they are finished. pure-run gains text input and text output. test-module covers typing Korean and emoji, moves that stop at the ends, line moves, views, rollback, invalid UTF-8 and replacement, text-specific verifier rules, and 20,000 damaged text modules whose cursors always stay on character boundaries under ASan/UBSan.
Diffstat (limited to 'prototypes/connections/edit-module.c')
-rw-r--r--prototypes/connections/edit-module.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/prototypes/connections/edit-module.c b/prototypes/connections/edit-module.c
index d934345..9305923 100644
--- a/prototypes/connections/edit-module.c
+++ b/prototypes/connections/edit-module.c
@@ -157,7 +157,10 @@ int main(int argc, char **argv) {
}
}
PureApp app;
- pure_app_start(&app, &module, pure_tree_data(store_path));
+ if (pure_app_start(&app, &module, pure_tree_data(store_path)) != PURE_OK) {
+ free(payload);
+ fputs("allocation\n", stderr); return 2;
+ }
PureResult status = pure_app_message(&app, (uint32_t)input, key, show ? -1 : (int64_t)expected,
(PureSpan){payload, prefix + length});
size_t reply = 0;
@@ -172,7 +175,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "{\"revision\":\"%" PRId64 "\",\"bytes\":%zu}\n", app.revision, reply);
} else if (printf("{\"revision\":\"%" PRId64 "\",\"reply_bytes\":%zu}\n", app.revision, reply) < 0) exit_code = 2;
if (fflush(stdout)) exit_code = 2;
- pure_app_finish(&app);
+ pure_app_stop(&app);
free(payload);
return exit_code;
usage: