From 37d3a1e152707d2da587440c4cea8601b9ef0fd2 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 27 Sep 2026 13:14:38 +0100 Subject: Lay Pure out as a core with the parts selected around it The app model, the tree store and the HTTP host lived in prototypes/connections among the earlier document runtime, the store was known only by its format's name, and Vega compiled six Pure sources by path. Now, as the README's principle has it: core/ runtime, flow and the app model (module*.c), with what the core asks of storage (state.h, store.h) store/ the tree store (PURETRE3, PUREREC1) serve/ pure-serve: HTTP host, outbound delivery, JSON in place cli/ pure-run, pure-edit-module A top-level make builds libpure.a (app model and store, for hosts to link) and the hosts; make check runs the store's and the app model's tests. The earlier runtime still builds from prototypes/connections against core/ and store/ (check, check-tree and check-core pass). Design 009 records the rule: parts by role behind libraries; git repositories split by coupling, so the store stays here while its contract moves with the core, and Vega stays apart. --- core/module-text.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 core/module-text.h (limited to 'core/module-text.h') diff --git a/core/module-text.h b/core/module-text.h new file mode 100644 index 0000000..4843928 --- /dev/null +++ b/core/module-text.h @@ -0,0 +1,34 @@ +#ifndef PURE_MODULE_TEXT_H +#define PURE_MODULE_TEXT_H +#include "flow.h" +#include "state.h" +#include +#include + +/* Text helpers of the module executor. Text is valid UTF-8; a character is a + * Unicode scalar value, so every position these return is a scalar boundary. */ + +/* Strict UTF-8: no overlongs, surrogates or values past U+10FFFF. state + * carries a sequence split across spans; start it at 0 and finish with + * pure_utf8_complete. */ +bool pure_utf8_step(unsigned *state, PureSpan span); +bool pure_utf8_complete(unsigned state); +bool pure_utf8_valid(PureSpan span); + +/* Scalars (bytes that are not 10xxxxxx) and newlines in a span. */ +size_t pure_utf8_scalars(PureSpan span); +size_t pure_utf8_newlines(PureSpan span); + +/* Shortest decimal that reads back to the same finite double: integers + * below 1e15 without a point or exponent, otherwise %g form with a trimmed + * exponent. -0 prints as 0. Returns the length written (at most 32). */ +size_t pure_format_number(double value, char out[32]); + +/* Positions in one version of a text draft (size is version.bytes). */ +size_t pure_text_step(const PureDraft *, PureVersion, size_t position, double count); +size_t pure_text_line_step(const PureDraft *, PureVersion, size_t position, double count); +size_t pure_text_line_start(const PureDraft *, PureVersion, size_t position); +size_t pure_text_line_end(const PureDraft *, PureVersion, size_t position); +/* Scalars (unit 0) or line number counting from 1 (unit 1) before position. */ +size_t pure_text_count(const PureDraft *, PureVersion, size_t position, unsigned unit); +#endif -- cgit v1.2.3