Save a completed ADR section into result, trimming whitespace. */
| 5664 | |
| 5665 | /* Save a completed ADR section into result, trimming whitespace. */ |
| 5666 | static void adr_save_section(cbm_adr_sections_t *result, char *section_name, char *buf, |
| 5667 | int buf_len) { |
| 5668 | if (!section_name || result->count >= ST_BUF_16) { |
| 5669 | return; |
| 5670 | } |
| 5671 | /* Trim trailing whitespace */ |
| 5672 | while (buf_len > 0 && (buf[buf_len - SKIP_ONE] == '\n' || buf[buf_len - SKIP_ONE] == ' ')) { |
| 5673 | buf[--buf_len] = '\0'; |
| 5674 | } |
| 5675 | /* Skip leading whitespace */ |
| 5676 | char *trimmed = buf; |
| 5677 | while (*trimmed == '\n' || *trimmed == ' ') { |
| 5678 | trimmed++; |
| 5679 | } |
| 5680 | result->keys[result->count] = section_name; |
| 5681 | result->values[result->count] = heap_strdup(trimmed); |
| 5682 | result->count++; |
| 5683 | } |
| 5684 | |
| 5685 | /* Try to extract a canonical section header from a "## Header" line. |
| 5686 | * Returns heap-allocated header string if canonical, NULL otherwise. */ |
no test coverage detected