MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / page_doc

Function page_doc

internal/cbm/doc_pdf.c:1329–1340  ·  view source on GitHub ↗

A page's docstring (its snippet): the page text, up to PDF_PAGE_DOC_MAX bytes * cut on a character boundary and then said so. A page holds a few kilobytes; * only a crafted text layer reaches the bound, and the mentions are still read * from the whole text. */

Source from the content-addressed store, hash-verified

1327 * only a crafted text layer reaches the bound, and the mentions are still read
1328 * from the whole text. */
1329static const char *page_doc(CBMArena *a, const cbm_pdf_page_t *pg) {
1330 if (pg->len <= PDF_PAGE_DOC_MAX) {
1331 return pg->text;
1332 }
1333 size_t cut = PDF_PAGE_DOC_MAX;
1334 while (cut > 0 && ((unsigned char)pg->text[cut] & 0xC0U) == 0x80U) {
1335 cut--; /* not inside a UTF-8 sequence */
1336 }
1337 const char *doc = cbm_arena_sprintf(a, "%.*s\n[page text cut at %zu of %zu bytes]", (int)cut,
1338 pg->text, cut, pg->len);
1339 return doc ? doc : pg->text;
1340}
1341
1342void cbm_pdf_extract_document(CBMExtractCtx *ctx) {
1343 CBMFileResult *result = ctx->result;

Callers 1

cbm_pdf_extract_documentFunction · 0.85

Calls 1

cbm_arena_sprintfFunction · 0.70

Tested by

no test coverage detected