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

Function pod_plain_heading

internal/cbm/extract_defs.c:2470–2496  ·  view source on GitHub ↗

A heading's text with POD formatting codes (X<..>, X<< .. >>) removed and * newlines and tabs as spaces. */

Source from the content-addressed store, hash-verified

2468/* A heading's text with POD formatting codes (X<..>, X<< .. >>) removed and
2469 * newlines and tabs as spaces. */
2470static char *pod_plain_heading(CBMArena *a, const char *src, uint32_t b, uint32_t e) {
2471 char *buf = (char *)cbm_arena_alloc(a, (size_t)(e - b) + SKIP_ONE);
2472 if (!buf) {
2473 return NULL;
2474 }
2475 size_t w = 0;
2476 for (uint32_t i = b; i < e; i++) {
2477 char c = src[i];
2478 if (c >= 'A' && c <= 'Z' && i + SKIP_ONE < e && src[i + SKIP_ONE] == '<') {
2479 uint32_t j = i + SKIP_ONE;
2480 while (j < e && src[j] == '<') {
2481 j++;
2482 }
2483 if (j - i > PAIR_LEN && j < e && (src[j] == ' ' || src[j] == '\t')) {
2484 j++; /* X<< text >> */
2485 }
2486 i = j - SKIP_ONE;
2487 continue;
2488 }
2489 if (c == '>' && !(w > 0 && buf[w - SKIP_ONE] == '-')) {
2490 continue;
2491 }
2492 buf[w++] = (c == '\n' || c == '\r' || c == '\t') ? ' ' : c;
2493 }
2494 buf[w] = '\0';
2495 return buf;
2496}
2497
2498static const char *pod_skip_spaces(const char *p) {
2499 while (*p == ' ') {

Callers 1

pod_heading_nameFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected