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

Function pl_plain_heading

internal/cbm/doclink_perl.c:876–902  ·  view source on GitHub ↗

A heading's text with formatting codes removed and newlines and tabs as * spaces (extract_defs.c's pod_plain_heading, byte for byte: the name it * yields decides which sub a section is stored on). */

Source from the content-addressed store, hash-verified

874 * spaces (extract_defs.c's pod_plain_heading, byte for byte: the name it
875 * yields decides which sub a section is stored on). */
876static char *pl_plain_heading(CBMArena *a, const char *src, uint32_t b, uint32_t e) {
877 char *buf = (char *)cbm_arena_alloc(a, (size_t)(e - b) + SKIP_ONE);
878 if (!buf) {
879 return NULL;
880 }
881 size_t w = 0;
882 for (uint32_t i = b; i < e; i++) {
883 char c = src[i];
884 if (pl_upper(c) && i + SKIP_ONE < e && src[i + SKIP_ONE] == '<') {
885 uint32_t j = i + SKIP_ONE;
886 while (j < e && src[j] == '<') {
887 j++;
888 }
889 if (j - i > PAIR_LEN && j < e && (src[j] == ' ' || src[j] == '\t')) {
890 j++; /* X<< text >> */
891 }
892 i = j - SKIP_ONE;
893 continue;
894 }
895 if (c == '>' && !(w > 0 && buf[w - SKIP_ONE] == '-')) {
896 continue;
897 }
898 buf[w++] = (c == '\n' || c == '\r' || c == '\t') ? ' ' : c;
899 }
900 buf[w] = '\0';
901 return buf;
902}
903
904static const char *pl_skip_spaces(const char *p) {
905 while (*p == ' ') {

Callers 1

pl_heading_nameFunction · 0.85

Calls 2

pl_upperFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected