Skip to content

Commit 21d3550

Browse files
committed
Merge origin/main into pr/windows-setenv-utf8
Signed-off-by: Martin Vogel <[email protected]>
2 parents e33f322 + 83109dd commit 21d3550

43 files changed

Lines changed: 1721 additions & 281 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,14 @@ overwrite user-modified agents.
695695
| Agent | Activation | MCP config | Durable context / augmentation |
696696
|-------|------------|------------|--------------------------------|
697697
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, and post-`Read` coverage |
698-
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart` |
698+
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart`, `PreToolUse` graph lookup for `Bash` searches |
699699
| Gemini CLI | Detected | `.gemini/settings.json` | `GEMINI.md`, three explicit read/graph-tool subagents; `BeforeTool`, `AfterTool` `read_file` coverage, and `SessionStart` |
700700
| Zed | Detected | platform `settings.json` (JSONC) | `AGENTS.md` + shared skill |
701701
| OpenCode | Detected | `$OPENCODE_CONFIG` or resolved global config | `AGENTS.md`, skill, three deny-by-default read-only agents; plugin adds grep/glob graph lookup, post-`read` coverage, first-tool-result session context, and post-compaction reinjection |
702702
| Antigravity | Detected | `.gemini/config/mcp_config.json` | `.gemini/GEMINI.md` |
703703
| Aider | Detected | none | `CONVENTIONS.md` via `.aider.conf.yml` |
704704
| KiloCode | Detected | `.config/kilo/kilo.jsonc` | Rule + three graph-tool subagents with deny-by-default permissions |
705-
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart` |
705+
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
706706
| Cursor | Detected | `.cursor/mcp.json` | Skill + three read-only parent-handoff agents; context hooks withheld because session injection races and `readonly` blocks MCP |
707707
| Windsurf | Detected | `~/.codeium/windsurf/mcp_config.json` | Always-on `global_rules.md` |
708708
| Augment / Auggie | Detected | `~/.augment/settings.json` | Rule, three read-only handoff subagents, `SessionStart` + post-`view` coverage |
@@ -714,7 +714,7 @@ overwrite user-modified agents.
714714
| Cline | Detected | `~/.cline/mcp.json` + `${CLINE_DATA_DIR:-~/.cline/data}/settings/cline_mcp_settings.json` | Rule + skill; automatic file hooks withheld because they auto-activate and their output is not reliably consumed; child agents cannot use MCP |
715715
| Warp | Detected, skill only | UI, Warp Drive, or per invocation (manual) | Shared `~/.agents/skills/codebase-memory/SKILL.md` |
716716
| Qwen Code | Detected | `.qwen/settings.json` | `QWEN.md`, skill, three explicit read/graph-tool agents; `SessionStart`, `SubagentStart`, and post-`ReadFile` coverage |
717-
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart` |
717+
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
718718
| Factory Droid | Detected | `.factory/mcp.json` | `AGENTS.md`, skill, three droids with exact per-tier graph-tool lists (without additive whole-server exposure); `SessionStart` + post-`Read` coverage on macOS/Linux, withheld on Windows |
719719
| Crush | Detected | `.config/crush/crush.json` | Managed context path with explicit parent-to-child handoff |
720720
| Goose | Detected | `.config/goose/config.yaml` | `.goosehints` |
@@ -751,7 +751,11 @@ Hooks installed by this project are fail-open and context-only. Claude Code's
751751
`PreToolUse` observes `Grep`/`Glob`/`Bash` and injects matching graph symbols as
752752
`additionalContext`; `PostToolUse` on `Read` adds targeted coverage context when
753753
the graph could not fully parse or index that file. It never denies or replaces
754-
the requested tool call.
754+
the requested tool call. Codex CLI's `PreToolUse` on `Bash` gives its shell
755+
searches the same context. GitHub Copilot CLI and VS Code's Copilot runtime get
756+
it after the search: their `preToolUse` can only decide permissions, so a
757+
`PostToolUse` entry for `Bash`, `Grep` and `Glob` appends the graph symbols to
758+
the tool result.
755759

756760
Claude Code, Codex CLI, Qwen Code, GitHub Copilot CLI, and VS Code's Copilot
757761
runtime receive paired session/subagent context where the vendor exposes a

‎internal/cbm/extract_channels.c‎

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,42 @@ static void elixir_emit_second_arg(CBMExtractCtx *ctx, TSNode call, TSNode args,
901901
}
902902
}
903903

904-
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
904+
/* tree-sitter-elixir gives a call's arguments node NO field name — its whole
905+
* field set is key, left, operand, operator, quoted_start, quoted_end, right,
906+
* target and value — so the generic field lookup is always null here and every
907+
* channel below was silently skipped. extract_defs.c has carried the same
908+
* positional fallback for the definition side since Elixir was added. */
909+
static TSNode elixir_channel_call_args(TSNode call) {
910+
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
911+
if (ts_node_is_null(args) && ts_node_child_count(call) > 1) {
912+
args = ts_node_child(call, 1);
913+
}
914+
return args;
915+
}
916+
917+
/* The callee of an Elixir `call`. The grammar labels it `target`; child(0) is
918+
* the same node and is what extract_defs.c reads, so accept either. */
919+
static TSNode elixir_channel_call_target(TSNode call) {
905920
TSNode target = ts_node_child_by_field_name(call, TS_FIELD("target"));
921+
if (ts_node_is_null(target) && ts_node_child_count(call) > 0) {
922+
target = ts_node_child(call, 0);
923+
}
924+
return target;
925+
}
926+
927+
/* Elixir def* macros. `def`/`defp` cover Phoenix channel callbacks; the macro
928+
* forms are included because `handle_in` is generated by macros in some
929+
* libraries. */
930+
static bool elixir_channel_is_def_macro(const char *macro) {
931+
if (!macro) {
932+
return false;
933+
}
934+
return strcmp(macro, "def") == 0 || strcmp(macro, "defp") == 0 ||
935+
strcmp(macro, "defmacro") == 0 || strcmp(macro, "defmacrop") == 0;
936+
}
937+
938+
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
939+
TSNode target = elixir_channel_call_target(call);
906940
if (ts_node_is_null(target)) {
907941
return;
908942
}
@@ -911,7 +945,7 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
911945
return;
912946
}
913947

914-
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
948+
TSNode args = elixir_channel_call_args(call);
915949

916950
if (strstr(target_text, "PubSub.broadcast") || strstr(target_text, "PubSub.local_broadcast")) {
917951
elixir_emit_second_arg(ctx, call, args, "phoenix_pubsub", CBM_CHANNEL_EMIT);
@@ -927,18 +961,39 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
927961
}
928962
}
929963

930-
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener */
931-
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
932-
TSNode name_node = ts_node_child_by_field_name(func_def, TS_FIELD("name"));
933-
if (ts_node_is_null(name_node)) {
964+
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener.
965+
* `def_call` is the `call` node of a def* macro. Elixir has no `def` node type
966+
* and no `name`/`parameters` fields: a definition is a call whose first
967+
* argument is the head, itself a call of name(params) — wrapped in a `when`
968+
* binary_operator when the clause carries a guard. */
969+
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode def_call) {
970+
TSNode args = elixir_channel_call_args(def_call);
971+
if (ts_node_is_null(args) || ts_node_named_child_count(args) == 0) {
972+
return;
973+
}
974+
TSNode head = ts_node_named_child(args, 0);
975+
if (strcmp(ts_node_type(head), "binary_operator") == 0) {
976+
TSNode op = ts_node_child_by_field_name(head, TS_FIELD("operator"));
977+
TSNode left = ts_node_child_by_field_name(head, TS_FIELD("left"));
978+
if (!ts_node_is_null(op) && !ts_node_is_null(left) &&
979+
ts_node_end_byte(op) - ts_node_start_byte(op) == 4 &&
980+
strncmp(ctx->source + ts_node_start_byte(op), "when", 4) == 0) {
981+
head = left;
982+
}
983+
}
984+
if (strcmp(ts_node_type(head), "call") != 0 || ts_node_child_count(head) == 0) {
985+
return;
986+
}
987+
TSNode name_node = ts_node_child(head, 0);
988+
if (ts_node_is_null(name_node) || strcmp(ts_node_type(name_node), "identifier") != 0) {
934989
return;
935990
}
936991
char *name = cbm_node_text(ctx->arena, name_node, ctx->source);
937992
if (!name || strcmp(name, "handle_in") != 0) {
938993
return;
939994
}
940995
/* First parameter is the event name pattern */
941-
TSNode params = ts_node_child_by_field_name(func_def, TS_FIELD("parameters"));
996+
TSNode params = elixir_channel_call_args(head);
942997
if (ts_node_is_null(params)) {
943998
return;
944999
}
@@ -952,7 +1007,7 @@ static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
9521007
val = literal_from_first_child(ctx, first_param);
9531008
}
9541009
if (val) {
955-
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, func_def);
1010+
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, def_call);
9561011
}
9571012
}
9581013

@@ -964,10 +1019,18 @@ static void extract_channels_elixir(CBMExtractCtx *ctx) {
9641019
while (stack.count > 0) {
9651020
TSNode node = ts_nstack_pop(&stack);
9661021
const char *kind = ts_node_type(node);
1022+
/* Everything in Elixir is a `call`, including `def`. The old dispatch
1023+
* tested for a "def" node type the grammar does not have, so the
1024+
* handle_in listener branch was unreachable. */
9671025
if (strcmp(kind, "call") == 0) {
968-
elixir_process_call(ctx, node);
969-
} else if (strcmp(kind, "def") == 0) {
970-
elixir_process_function_def(ctx, node);
1026+
TSNode target = elixir_channel_call_target(node);
1027+
char *macro =
1028+
ts_node_is_null(target) ? NULL : cbm_node_text(ctx->arena, target, ctx->source);
1029+
if (elixir_channel_is_def_macro(macro)) {
1030+
elixir_process_function_def(ctx, node);
1031+
} else {
1032+
elixir_process_call(ctx, node);
1033+
}
9711034
}
9721035
uint32_t count = ts_node_child_count(node);
9731036
for (int i = (int)count - SKIP_ONE; i >= 0; i--) {

‎internal/cbm/lsp/py_lsp.c‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void py_register_instance_field(PyLSPContext *ctx, const char *class_qn,
245245
static void py_bind_for_target(PyLSPContext *ctx, TSNode left, const CBMType *elem_type);
246246
static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambda_node);
247247
static void py_register_dict_literal(PyLSPContext *ctx, const char *name, TSNode dict_node);
248-
static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name);
248+
static int py_lookup_lambda(PyLSPContext *ctx, const char *name);
249249
static const char *py_lookup_dict_dispatch(PyLSPContext *ctx, const char *var, const char *key);
250250
static void py_process_function(PyLSPContext *ctx, TSNode func_node, const char *container_qn);
251251
static void py_process_class(PyLSPContext *ctx, TSNode class_node);
@@ -895,19 +895,21 @@ static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambd
895895
}
896896
ctx->lambdas[ctx->lambda_count].name = cbm_arena_strdup(ctx->arena, name);
897897
ctx->lambdas[ctx->lambda_count].lambda_node = lambda_node;
898+
ctx->lambdas[ctx->lambda_count].expanding = false;
898899
ctx->lambda_count++;
899900
}
900901

901-
static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name) {
902-
TSNode null_node = {0};
902+
/* Registry index of the lambda bound to `name`, or -1. An index, not a
903+
* pointer: the registry array is replaced when it grows. */
904+
static int py_lookup_lambda(PyLSPContext *ctx, const char *name) {
903905
if (!ctx || !name)
904-
return null_node;
906+
return -1;
905907
for (int i = 0; i < ctx->lambda_count; i++) {
906908
if (ctx->lambdas[i].name && strcmp(ctx->lambdas[i].name, name) == 0) {
907-
return ctx->lambdas[i].lambda_node;
909+
return i;
908910
}
909911
}
910-
return null_node;
912+
return -1;
911913
}
912914

913915
/* Helper for stripping quotes from a tree-sitter `string` node text. */
@@ -3157,12 +3159,18 @@ static void py_emit_call_for(PyLSPContext *ctx, TSNode call_node) {
31573159
/* These legacy entries have no lexical frame identity. During class
31583160
* execution, leave lambda replay unresolved instead of bypassing a
31593161
* local shadow or running the lambda against class locals. */
3160-
TSNode lambda_node =
3161-
ctx->class_body_outer_scope ? (TSNode){0} : py_lookup_lambda(ctx, fname);
3162-
if (!ts_node_is_null(lambda_node)) {
3162+
int lambda_idx = ctx->class_body_outer_scope ? -1 : py_lookup_lambda(ctx, fname);
3163+
if (lambda_idx >= 0) {
3164+
TSNode lambda_node = ctx->lambdas[lambda_idx].lambda_node;
31633165
TSNode params = ts_node_child_by_field_name(lambda_node, "parameters", 10);
31643166
TSNode body = ts_node_child_by_field_name(lambda_node, "body", 4);
31653167
TSNode args = ts_node_child_by_field_name(call_node, "arguments", 9);
3168+
// A lambda that reaches itself again (directly or through another
3169+
// lambda) would re-walk its body once per nesting level up to the
3170+
// walk-depth cap, and two such calls in one body double the work
3171+
// per level. Walk each body at most once per chain.
3172+
if (ctx->lambdas[lambda_idx].expanding)
3173+
return;
31663174
CBMScope *saved = ctx->current_scope;
31673175
ctx->current_scope = py_scope_push_checked(ctx);
31683176
// Bind each lambda param to the call-site arg's type.
@@ -3195,7 +3203,9 @@ static void py_emit_call_for(PyLSPContext *ctx, TSNode call_node) {
31953203
ctx->enclosing_func_qn = cbm_arena_sprintf(ctx->arena, "%s.<lambda>",
31963204
prev_func ? prev_func : ctx->module_qn);
31973205
if (!ts_node_is_null(body)) {
3206+
ctx->lambdas[lambda_idx].expanding = true;
31983207
py_resolve_calls_in(ctx, body);
3208+
ctx->lambdas[lambda_idx].expanding = false;
31993209
}
32003210
ctx->enclosing_func_qn = prev_func;
32013211
py_scope_restore(ctx, saved);

‎internal/cbm/lsp/py_lsp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
typedef struct {
1414
const char *name; // bound name, e.g. "fn"
1515
TSNode lambda_node; // the lambda AST node
16+
bool expanding; // body is being re-walked for a call site right now
1617
} CBMLambdaEntry;
1718

1819
// Function-as-dict-value entry. When `funcs = {"a": foo, "b": bar}` is

‎internal/cbm/sqlite_writer.c‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@
3535
#include <process.h>
3636
#include <windows.h>
3737
#define cbm_writer_getpid _getpid
38+
/* long is 32 bits on Windows, so fseek/ftell cannot address past 2 GiB there. */
39+
#define cbm_writer_seek(fp, off, whence) _fseeki64((fp), (long long)(off), (whence))
40+
#define cbm_writer_tell(fp) ((int64_t)_ftelli64(fp))
3841
#else
3942
#include <unistd.h>
4043
#define cbm_writer_getpid getpid
44+
#define cbm_writer_seek(fp, off, whence) fseeko((fp), (off_t)(off), (whence))
45+
#define cbm_writer_tell(fp) ((int64_t)ftello(fp))
4146
#endif
4247

4348
#define CBM_PAGE_SIZE 65536
4449

50+
int64_t cbm_writer_page_offset(uint32_t page_num) {
51+
return (int64_t)(page_num - SKIP_ONE) * CBM_PAGE_SIZE;
52+
}
53+
4554
/* SQLite reserves the page containing the 1 GiB file offset (the "pending byte"
4655
* used for file locking on Windows). This page MUST be skipped during allocation
4756
* otherwise integrity_check reports "2nd reference to page N" because it marks
@@ -601,8 +610,8 @@ static void pb_flush_leaf(PageBuilder *pb) {
601610
// Write page to file. Skip the pending byte page (SQLite reserved).
602611
pb->next_page = cbm_skip_pending_byte(pb->next_page);
603612
uint32_t page_num = pb->next_page;
604-
long offset = (long)(page_num - SKIP_ONE) * CBM_PAGE_SIZE;
605-
(void)fseek(pb->fp, offset, SEEK_SET);
613+
int64_t offset = cbm_writer_page_offset(page_num);
614+
(void)cbm_writer_seek(pb->fp, offset, SEEK_SET);
606615
(void)fwrite(pb->page, SKIP_ONE, CBM_PAGE_SIZE, pb->fp);
607616

608617
// Record this leaf for interior page building
@@ -707,7 +716,7 @@ static int write_interior_page(PageBuilder *pb, uint8_t *page, int cell_count, i
707716
page[HDR_FRAGBYTES_OFF] = 0;
708717
put_u32(page + HDR_RIGHTCHILD_OFF, right_child_page);
709718

710-
(void)fseek(pb->fp, (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE, SEEK_SET);
719+
(void)cbm_writer_seek(pb->fp, cbm_writer_page_offset(pnum), SEEK_SET);
711720
(void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, pb->fp);
712721

713722
if (parent_count >= *parent_cap) {
@@ -970,7 +979,7 @@ static uint32_t write_overflow_pages(FILE *fp, uint32_t *next_page, const uint8_
970979
int data_len) {
971980
int per_page = CBM_PAGE_SIZE - BTREE_PTR_SIZE;
972981
uint32_t first_page = 0;
973-
long prev_next_ptr_offset = -SKIP_ONE;
982+
int64_t prev_next_ptr_offset = -SKIP_ONE;
974983

975984
int offset = 0;
976985
while (offset < data_len) {
@@ -983,7 +992,7 @@ static uint32_t write_overflow_pages(FILE *fp, uint32_t *next_page, const uint8_
983992
if (prev_next_ptr_offset >= 0) {
984993
uint8_t ptr[BTREE_PTR_SIZE];
985994
put_u32(ptr, pnum);
986-
(void)fseek(fp, prev_next_ptr_offset, SEEK_SET);
995+
(void)cbm_writer_seek(fp, prev_next_ptr_offset, SEEK_SET);
987996
(void)fwrite(ptr, SKIP_ONE, BTREE_PTR_SIZE, fp);
988997
}
989998

@@ -997,9 +1006,9 @@ static uint32_t write_overflow_pages(FILE *fp, uint32_t *next_page, const uint8_
9971006
put_u32(page, 0); // next-page pointer — 0 for now, backpatched on next iteration
9981007
memcpy(page + BTREE_PTR_SIZE, data + offset, chunk);
9991008

1000-
long page_offset = (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE;
1009+
int64_t page_offset = cbm_writer_page_offset(pnum);
10011010
prev_next_ptr_offset = page_offset;
1002-
(void)fseek(fp, page_offset, SEEK_SET);
1011+
(void)cbm_writer_seek(fp, page_offset, SEEK_SET);
10031012
(void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, fp);
10041013

10051014
offset += chunk;
@@ -1276,7 +1285,7 @@ static uint32_t write_table_btree(FILE *fp, uint32_t *next_page, const uint8_t *
12761285
put_u16(page + hdr + HDR_CELLCOUNT_OFF, 0); // 0 cells
12771286
put_u16(page + hdr + HDR_CONTENT_OFF, (uint16_t)CBM_PAGE_SIZE); // content at end of page
12781287
page[hdr + HDR_FRAGBYTES_OFF] = 0; // 0 fragmented bytes
1279-
(void)fseek(fp, (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE, SEEK_SET);
1288+
(void)cbm_writer_seek(fp, cbm_writer_page_offset(pnum), SEEK_SET);
12801289
(void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, fp);
12811290
return pnum;
12821291
}
@@ -1326,7 +1335,7 @@ static uint32_t write_empty_index_leaf(FILE *fp, uint32_t *next_page) {
13261335
put_u16(page + HDR_CELLCOUNT_OFF, 0);
13271336
put_u16(page + HDR_CONTENT_OFF, (uint16_t)CBM_PAGE_SIZE);
13281337
page[HDR_FRAGBYTES_OFF] = 0;
1329-
(void)fseek(fp, (long)(pnum - SKIP_ONE) * CBM_PAGE_SIZE, SEEK_SET);
1338+
(void)cbm_writer_seek(fp, cbm_writer_page_offset(pnum), SEEK_SET);
13301339
(void)fwrite(page, SKIP_ONE, CBM_PAGE_SIZE, fp);
13311340
return pnum;
13321341
}
@@ -2020,7 +2029,7 @@ static int write_master_page1(FILE *fp, MasterEntry *master, int master_count, u
20202029

20212030
write_sqlite_file_header(page1, next_page - SKIP_ONE);
20222031

2023-
(void)fseek(fp, 0, SEEK_SET);
2032+
(void)cbm_writer_seek(fp, 0, SEEK_SET);
20242033
(void)fwrite(page1, SKIP_ONE, CBM_PAGE_SIZE, fp);
20252034

20262035
for (int i = 0; i < master_count; i++) {
@@ -2034,12 +2043,12 @@ static int write_master_page1(FILE *fp, MasterEntry *master, int master_count, u
20342043

20352044
/* Pad file to exact page boundary. */
20362045
static void pad_file_to_page_boundary(FILE *fp, uint32_t next_page) {
2037-
(void)fseek(fp, 0, SEEK_END);
2038-
long file_size = ftell(fp);
2039-
long expected_size = (long)(next_page - SKIP_ONE) * CBM_PAGE_SIZE;
2046+
(void)cbm_writer_seek(fp, 0, SEEK_END);
2047+
int64_t file_size = cbm_writer_tell(fp);
2048+
int64_t expected_size = cbm_writer_page_offset(next_page);
20402049
if (file_size < expected_size) {
20412050
uint8_t zero = 0;
2042-
(void)fseek(fp, expected_size - SKIP_ONE, SEEK_SET);
2051+
(void)cbm_writer_seek(fp, expected_size - SKIP_ONE, SEEK_SET);
20432052
(void)fwrite(&zero, SKIP_ONE, SKIP_ONE, fp);
20442053
}
20452054
}

0 commit comments

Comments
 (0)