Push a token; returns its index in the file's token array, or -1. */
| 983 | |
| 984 | /* Push a token; returns its index in the file's token array, or -1. */ |
| 985 | static int emit(pdf_emit_t *e, int syntax, const char *raw, uint32_t line, uint16_t flags) { |
| 986 | CBMArena *a = e->ctx->arena; |
| 987 | char *r = cbm_arena_strdup(a, raw); |
| 988 | if (!r) { |
| 989 | e->failed = true; |
| 990 | return -1; |
| 991 | } |
| 992 | CBMDocLink link = { |
| 993 | .source_qn = e->page_qn, |
| 994 | .raw = r, |
| 995 | .line = line, |
| 996 | .def_line = e->page, |
| 997 | .syntax = (uint16_t)syntax, |
| 998 | .flags = flags, |
| 999 | }; |
| 1000 | int idx = e->ctx->result->doc_links.count; |
| 1001 | cbm_doclinks_push(&e->ctx->result->doc_links, a, link); |
| 1002 | if (e->ctx->result->doc_links.count != idx + 1) { |
| 1003 | e->failed = true; |
| 1004 | return -1; |
| 1005 | } |
| 1006 | return idx; |
| 1007 | } |
| 1008 | |
| 1009 | typedef struct { |
| 1010 | char *p; |
no test coverage detected