Save a completed ADR section into result, trimming whitespace. */
| 10992 | |
| 10993 | /* Save a completed ADR section into result, trimming whitespace. */ |
| 10994 | static void adr_save_section(cbm_adr_sections_t *result, char *section_name, char *buf, |
| 10995 | int buf_len) { |
| 10996 | if (!section_name || result->count >= ST_BUF_16) { |
| 10997 | return; |
| 10998 | } |
| 10999 | /* Trim trailing whitespace */ |
| 11000 | while (buf_len > 0 && (buf[buf_len - SKIP_ONE] == '\n' || buf[buf_len - SKIP_ONE] == ' ')) { |
| 11001 | buf[--buf_len] = '\0'; |
| 11002 | } |
| 11003 | /* Skip leading whitespace */ |
| 11004 | char *trimmed = buf; |
| 11005 | while (*trimmed == '\n' || *trimmed == ' ') { |
| 11006 | trimmed++; |
| 11007 | } |
| 11008 | result->keys[result->count] = section_name; |
| 11009 | result->values[result->count] = heap_strdup(trimmed); |
| 11010 | result->count++; |
| 11011 | } |
| 11012 | |
| 11013 | /* Try to extract a canonical section header from a "## Header" line. |
| 11014 | * Returns heap-allocated header string if canonical, NULL otherwise. */ |
no test coverage detected