A heading's text with POD formatting codes (X<..>, X<< .. >>) removed and * newlines and tabs as spaces. */
| 2468 | /* A heading's text with POD formatting codes (X<..>, X<< .. >>) removed and |
| 2469 | * newlines and tabs as spaces. */ |
| 2470 | static 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 | |
| 2498 | static const char *pod_skip_spaces(const char *p) { |
| 2499 | while (*p == ' ') { |
no test coverage detected