| 918 | } |
| 919 | |
| 920 | pdf_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 |
no test coverage detected