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

Function lex_name

internal/cbm/pdf/pdf_obj.c:385–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385static void lex_name(pdf_doc_t *d, const unsigned char *s, size_t n, pdf_tok_t *t) {
386 t->kind = PT_NAME;
387 if (d->peek) {
388 t->s = s;
389 t->n = n;
390 return;
391 }
392 unsigned char *o = (unsigned char *)pdf_alloc(d, n + 1);
393 if (!o) {
394 t->s = (const unsigned char *)"";
395 t->n = 0;
396 return;
397 }
398 size_t k = 0;
399 for (size_t i = 0; i < n;) {
400 if (s[i] == '#' && i + 2 < n && hex_val(s[i + 1]) >= 0 && hex_val(s[i + 2]) >= 0) {
401 o[k++] = (unsigned char)(hex_val(s[i + 1]) * PDF_HEX_BASE + hex_val(s[i + 2]));
402 i += 3;
403 } else {
404 o[k++] = s[i++];
405 }
406 }
407 o[k] = '\0';
408 t->s = o;
409 t->n = k;
410}
411
412static bool lstr_special(unsigned char c) {
413 return c == '(' || c == ')' || c == '\\' || c == '\r';

Callers 1

pdf_lexFunction · 0.85

Calls 2

pdf_allocFunction · 0.85
hex_valFunction · 0.70

Tested by

no test coverage detected