Branch Coverage

src/pdfmake_interpreter.c
Criterion Covered Total %
branch 181 408 44.3


line true false branch
93 0 0 if (fabs(det) < 1e-10) return -1; /* Singular */
165 0 42 if (src->dash_array && src->dash_count > 0) {
0 0 if (src->dash_array && src->dash_count > 0) {
167 0 0 if (dst->dash_array) {
190 0 60 if (!interp) return NULL;
197 0 60 if (!interp->stack) {
210 0 60 if (!interp->operands) {
219 0 60 if (!interp->path) {
229 0 60 if (!interp->mc_stack) {
242 0 60 if (!interp) return;
245 60 60 for (i = 0; i < interp->stack_size; i++) {
257 60 0 if (interp) {
263 60 0 if (interp) {
269 60 0 if (interp) interp->reader = reader;
274 0 60 if (!interp) return;
277 60 60 for (i = 0; i < interp->stack_size; i++) {
301 0 0 return interp ? interp->errmsg : "";
305 0 0 return interp ? interp->erroffset : 0;
309 0 0 return interp ? interp->gs : NULL;
313 0 0 return interp ? interp->in_text_object : 0;
317 0 0 if (!interp || !interp->have_cur_point) return 0;
0 0 if (!interp || !interp->have_cur_point) return 0;
318 0 0 if (x) *x = interp->cur_x;
319 0 0 if (y) *y = interp->cur_y;
331 0 0 if (msg) {
342 0 6072 if (interp->op_count >= interp->op_cap) {
346 0 0 if (!new_ops) return 0;
355 0 6072 if (interp->op_count == 0) {
367 2687 5151 if (obj.kind == PDFMAKE_INT) return (double)obj.as.i;
368 5151 0 if (obj.kind == PDFMAKE_REAL) return obj.as.r;
378 0 42 if (interp->stack_size >= PDFMAKE_GSTATE_STACK_MAX) {
396 0 42 if (interp->stack_size <= 1) {
418 0 127 if (interp->path_size + need > interp->path_cap) {
420 0 0 while (new_cap < interp->path_size + need) new_cap *= 2;
423 0 0 if (!new_path) return 0;
431 127 0 if (path_ensure_cap(interp, 1)) {
450 380 0 if (!interp->resources || interp->resources->kind != PDFMAKE_DICT) {
0 380 if (!interp->resources || interp->resources->kind != PDFMAKE_DICT) {
457 380 0 if (!cat_dict || cat_dict->kind != PDFMAKE_DICT) {
0 380 if (!cat_dict || cat_dict->kind != PDFMAKE_DICT) {
471 0 160 if (interp->in_text_object) {
486 0 160 if (!interp->in_text_object) {
529 366 0 if (font.kind == PDFMAKE_NAME) {
542 6 0 if (mode >= 0 && mode <= 7) {
6 0 if (mode >= 0 && mode <= 7) {
633 3484 0 if (interp->visitor && interp->visitor->get_string_advance) {
3484 0 if (interp->visitor && interp->visitor->get_string_advance) {
638 0 3484 if (width <= 0) {
642 0 0 for (i = 0; i < len; i++) {
643 0 0 if (bytes[i] == ' ') space_count++;
655 3484 0 if (interp->visitor && interp->visitor->is_vertical_writing) {
3484 0 if (interp->visitor && interp->visitor->is_vertical_writing) {
660 1 3483 if (vertical) {
672 124 0 if (c >= '0' && c <= '9') return c - '0';
108 16 if (c >= '0' && c <= '9') return c - '0';
673 16 0 if (c >= 'a' && c <= 'f') return c - 'a' + 10;
16 0 if (c >= 'a' && c <= 'f') return c - 'a' + 10;
674 0 0 if (c >= 'A' && c <= 'F') return c - 'A' + 10;
0 0 if (c >= 'A' && c <= 'F') return c - 'A' + 10;
694 6 0 if (!str || str->kind != PDFMAKE_STR || !str->as.str.hex) return 0;
6 0 if (!str || str->kind != PDFMAKE_STR || !str->as.str.hex) return 0;
0 6 if (!str || str->kind != PDFMAKE_STR || !str->as.str.hex) return 0;
701 0 6 if (!out) return 0;
705 124 6 for (i = 0; i < in_len; i++) {
707 0 124 if (v < 0) continue; /* skip whitespace, ignore garbage */
708 62 62 if (nibble < 0) {
715 0 6 if (nibble >= 0) out[written++] = (uint8_t)(nibble << 4);
727 0 437 if (!interp->in_text_object) {
738 437 0 if (str.kind == PDFMAKE_STR) {
739 1 436 if (str.as.str.hex) {
741 0 1 if (!maybe_decode_hex_string(interp->arena, &str, &bytes, &len)) {
752 437 0 if (interp->visitor && interp->visitor->on_text_show && bytes) {
437 0 if (interp->visitor && interp->visitor->on_text_show && bytes) {
437 0 if (interp->visitor && interp->visitor->on_text_show && bytes) {
758 437 0 if (bytes && len > 0) {
437 0 if (bytes && len > 0) {
771 0 409 if (!interp->in_text_object) {
778 0 409 if (arr.kind != PDFMAKE_ARRAY) {
784 5685 409 for (i = 0; i < arr_len; i++) {
786 0 5685 if (!elem) continue;
788 3047 2638 if (elem->kind == PDFMAKE_STR) {
792 5 3042 if (elem->as.str.hex) {
793 0 5 if (!maybe_decode_hex_string(interp->arena, elem, &bytes, &len)) {
802 3047 0 if (interp->visitor && interp->visitor->on_text_show) {
3047 0 if (interp->visitor && interp->visitor->on_text_show) {
809 2488 150 } else if (elem->kind == PDFMAKE_INT || elem->kind == PDFMAKE_REAL) {
2488 0 } else if (elem->kind == PDFMAKE_INT || elem->kind == PDFMAKE_REAL) {
894 0 0 if (c >= 0 && c <= 2) {
0 0 if (c >= 0 && c <= 2) {
904 0 0 if (j >= 0 && j <= 2) {
0 0 if (j >= 0 && j <= 2) {
929 0 0 if (array.kind == PDFMAKE_ARRAY) {
931 0 0 if (n > 0) {
933 0 0 if (interp->gs->dash_array) {
935 0 0 for (i = 0; i < n; i++) {
937 0 0 interp->gs->dash_array[i] = v ? get_number(*v) : 0;
958 0 14 if (name.kind != PDFMAKE_NAME) {
964 14 0 if (!dict || dict->kind != PDFMAKE_DICT) {
14 0 if (!dict || dict->kind != PDFMAKE_DICT) {
1120 127 0 if (interp->visitor && interp->visitor->on_path && interp->path_size > 0) {
0 127 if (interp->visitor && interp->visitor->on_path && interp->path_size > 0) {
0 0 if (interp->visitor && interp->visitor->on_path && interp->path_size > 0) {
1297 21 0 if (!interp->resources || interp->resources->kind != PDFMAKE_DICT)
0 21 if (!interp->resources || interp->resources->kind != PDFMAKE_DICT)
1302 0 21 if (!cat) return NULL;
1304 0 21 if (cat->kind == PDFMAKE_REF && interp->reader) {
0 0 if (cat->kind == PDFMAKE_REF && interp->reader) {
1306 0 0 if (rd->parser) {
1310 21 0 if (!cat || cat->kind != PDFMAKE_DICT) return NULL;
0 21 if (!cat || cat->kind != PDFMAKE_DICT) return NULL;
1313 0 21 if (!entry) return NULL;
1314 21 0 if (entry->kind == PDFMAKE_REF) {
1318 21 0 if (interp->reader) {
1320 21 0 if (rd->parser)
1345 4 0 if (!form || form->kind != PDFMAKE_STREAM) return PDFMAKE_OK;
0 4 if (!form || form->kind != PDFMAKE_STREAM) return PDFMAKE_OK;
1347 0 4 if (interp->form_depth >= 32) {
1353 0 4 if (pdfmake_buf_init(&content) != PDFMAKE_OK) return PDFMAKE_ENOMEM;
1356 4 0 if (interp->reader && form_num > 0) {
4 0 if (interp->reader && form_num > 0) {
1365 4 0 if (err != PDFMAKE_OK || pdfmake_buf_len(&content) == 0) {
0 4 if (err != PDFMAKE_OK || pdfmake_buf_len(&content) == 0) {
1382 4 0 if (mat && mat->kind == PDFMAKE_ARRAY && pdfmake_array_len(mat) == 6) {
4 0 if (mat && mat->kind == PDFMAKE_ARRAY && pdfmake_array_len(mat) == 6) {
4 0 if (mat && mat->kind == PDFMAKE_ARRAY && pdfmake_array_len(mat) == 6) {
1384 24 4 for (i = 0; i < 6; i++) {
1386 0 24 if (!v) { m[i] = 0; continue; }
1387 24 0 if (v->kind == PDFMAKE_INT) m[i] = (double)v->as.i;
1388 0 0 else if (v->kind == PDFMAKE_REAL) m[i] = v->as.r;
1401 4 0 if (form_res && form_res->kind == PDFMAKE_REF && interp->reader) {
2 2 if (form_res && form_res->kind == PDFMAKE_REF && interp->reader) {
2 0 if (form_res && form_res->kind == PDFMAKE_REF && interp->reader) {
1403 2 0 if (rd->parser)
1406 4 0 if (form_res && form_res->kind == PDFMAKE_DICT) {
4 0 if (form_res && form_res->kind == PDFMAKE_DICT) {
1433 0 21 if (name.kind != PDFMAKE_NAME) {
1441 0 21 if (!xobj) {
1446 21 0 if (xobj->kind == PDFMAKE_STREAM) {
1455 21 0 if (subtype && subtype->kind == PDFMAKE_NAME) {
21 0 if (subtype && subtype->kind == PDFMAKE_NAME) {
1458 21 0 if (subtype_str) {
1459 17 4 if (strcmp(subtype_str, "Image") == 0) {
1461 17 0 if (interp->visitor && interp->visitor->on_image) {
0 17 if (interp->visitor && interp->visitor->on_image) {
1466 4 0 } else if (strcmp(subtype_str, "Form") == 0) {
1468 4 0 if (interp->visitor && interp->visitor->on_form_begin) {
0 4 if (interp->visitor && interp->visitor->on_form_begin) {
1476 4 0 if (interp->visitor && interp->visitor->on_form_end) {
0 4 if (interp->visitor && interp->visitor->on_form_end) {
1494 0 3 if (interp->mc_depth >= interp->mc_cap) {
1498 0 0 if (!new_stack) return 0;
1511 0 0 if (tag.kind == PDFMAKE_NAME) {
1517 0 0 if (interp->visitor && interp->visitor->on_marked_content_begin) {
0 0 if (interp->visitor && interp->visitor->on_marked_content_begin) {
1533 3 0 if (tag.kind == PDFMAKE_NAME) {
1538 3 0 if (props.kind == PDFMAKE_DICT) {
1540 0 0 } else if (props.kind == PDFMAKE_NAME) {
1547 3 0 if (interp->visitor && interp->visitor->on_marked_content_begin) {
3 0 if (interp->visitor && interp->visitor->on_marked_content_begin) {
1557 3 0 if (interp->mc_depth > 0) {
1561 3 0 if (interp->visitor && interp->visitor->on_marked_content_end) {
3 0 if (interp->visitor && interp->visitor->on_marked_content_end) {
1633 0 0 if (intent.kind == PDFMAKE_NAME) {
1774 75827 0 for (e = op_table; e->name; e++) {
1775 43178 32649 if (strlen(e->name) == len && memcmp(e->name, name, len) == 0) {
3438 39740 if (strlen(e->name) == len && memcmp(e->name, name, len) == 0) {
1838 0 0 if (t.kind == PDFMAKE_TOK_EOF || t.kind == PDFMAKE_TOK_ARR_CLOSE) break;
0 0 if (t.kind == PDFMAKE_TOK_EOF || t.kind == PDFMAKE_TOK_ARR_CLOSE) break;
1839 0 0 if (t.kind == PDFMAKE_TOK_ARR_OPEN) {
1841 0 0 } else if (t.kind == PDFMAKE_TOK_DICT_OPEN) {
1843 0 0 } else if (t.kind == PDFMAKE_TOK_NAME) {
1849 0 0 } else if (!token_to_primitive(bytes, t, &v)) {
1871 6 0 if (kt.kind == PDFMAKE_TOK_EOF || kt.kind == PDFMAKE_TOK_DICT_CLOSE) break;
3 3 if (kt.kind == PDFMAKE_TOK_EOF || kt.kind == PDFMAKE_TOK_DICT_CLOSE) break;
1872 0 3 if (kt.kind != PDFMAKE_TOK_NAME) continue; /* malformed — skip */
1878 3 0 if (vt.kind == PDFMAKE_TOK_EOF || vt.kind == PDFMAKE_TOK_DICT_CLOSE) break;
3 0 if (vt.kind == PDFMAKE_TOK_EOF || vt.kind == PDFMAKE_TOK_DICT_CLOSE) break;
1879 0 3 if (vt.kind == PDFMAKE_TOK_DICT_OPEN) {
1881 0 3 } else if (vt.kind == PDFMAKE_TOK_ARR_OPEN) {
1883 0 3 } else if (vt.kind == PDFMAKE_TOK_NAME) {
1889 0 3 } else if (!token_to_primitive(bytes, vt, &v)) {
1907 64 9510 if (t.kind == PDFMAKE_TOK_EOF) {
1914 0 2517 if (!push_operand(interp, obj)) {
1923 0 2302 if (!push_operand(interp, obj)) {
1938 0 404 if (!push_operand(interp, obj)) {
1951 0 436 if (!push_operand(interp, obj)) {
1964 0 1 if (!push_operand(interp, obj)) {
1976 6094 409 while (depth > 0) {
1978 0 6094 if (at.kind == PDFMAKE_TOK_EOF) {
1981 0 6094 if (at.kind == PDFMAKE_TOK_ARR_OPEN) {
1984 409 5685 } else if (at.kind == PDFMAKE_TOK_ARR_CLOSE) {
1986 150 5535 } else if (at.kind == PDFMAKE_TOK_INT) {
1989 2488 3047 } else if (at.kind == PDFMAKE_TOK_REAL) {
1992 3042 5 } else if (at.kind == PDFMAKE_TOK_LSTR) {
1999 5 0 } else if (at.kind == PDFMAKE_TOK_HSTR) {
2008 0 409 if (!push_operand(interp, arr)) {
2017 0 3 if (!push_operand(interp, dict)) {
2026 0 0 if (!push_operand(interp, obj)) {
2035 0 0 if (!push_operand(interp, obj)) {
2044 0 0 if (!push_operand(interp, obj)) {
2057 3438 0 if (handler) {
2059 0 3438 if (err != PDFMAKE_OK) {
2080 60 0 if (!interp || !bytes) {
0 60 if (!interp || !bytes) {