Trailing line breaks, counting a "\r\n" PAIR as ONE break. Counting raw '\n' * characters gets the count right but loses the shape, and the separator that * is then appended has to match the ending it is continuing. */
| 11411 | * characters gets the count right but loses the shape, and the separator that |
| 11412 | * is then appended has to match the ending it is continuing. */ |
| 11413 | static size_t adr_trailing_breaks(const char *doc, size_t doc_len) { |
| 11414 | size_t idx = doc_len; |
| 11415 | size_t breaks = 0; |
| 11416 | while (idx > 0 && (doc[idx - SKIP_ONE] == '\n' || doc[idx - SKIP_ONE] == '\r')) { |
| 11417 | bool was_lf = doc[idx - SKIP_ONE] == '\n'; |
| 11418 | idx--; |
| 11419 | if (was_lf && idx > 0 && doc[idx - SKIP_ONE] == '\r') { |
| 11420 | idx--; |
| 11421 | } |
| 11422 | breaks++; |
| 11423 | } |
| 11424 | return breaks; |
| 11425 | } |
| 11426 | |
| 11427 | char *cbm_adr_splice_section(const char *content, const char *name, const char *body) { |
| 11428 | if (!name || !body) { |
no outgoing calls
no test coverage detected