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

Function pdf_parse_content_array

internal/cbm/pdf/pdf_obj.c:920–952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920pdf_val_t *pdf_parse_content_array(pdf_doc_t *d, const unsigned char *data, size_t len, size_t *pos,
921 int depth) {
922 if (depth > PDF_MAX_NESTING) {
923 return NULL;
924 }
925 val_list_t l = {0};
926 for (;;) {
927 pdf_tok_t a;
928 pdf_lex(d, data, len, pos, &a);
929 if (a.kind == PT_AE || a.kind == PT_EOF) {
930 break;
931 }
932 pdf_val_t *x = NULL;
933 if (a.kind == PT_NUM || a.kind == PT_STR || a.kind == PT_NAME) {
934 x = val_from_tok(d, &a);
935 } else if (a.kind == PT_AS) {
936 x = pdf_parse_content_array(d, data, len, pos, depth + 1);
937 } else if (a.kind == PT_DS) {
938 x = pdf_parse_value(d, data, len, pos, &a, depth + 1);
939 } else if (a.kind == PT_KW) {
940 *pos = (size_t)(a.s - data); /* the operator is the caller's */
941 break;
942 } else {
943 continue;
944 }
945 if (!x) {
946 cbm_free(CBM_MEM_CLASS_EXTRACT, (void *)l.v);
947 return NULL;
948 }
949 vl_push(&l, x);
950 }
951 return vl_finish_array(d, &l);
952}
953
954/* ── Dict access ─────────────────────────────────────────────────── */
955

Callers 2

cmap_parseFunction · 0.85
runFunction · 0.85

Calls 6

pdf_lexFunction · 0.85
val_from_tokFunction · 0.85
pdf_parse_valueFunction · 0.85
cbm_freeFunction · 0.85
vl_pushFunction · 0.85
vl_finish_arrayFunction · 0.85

Tested by

no test coverage detected