Commit 41c9a8d6 authored by Rusty Russell's avatar Rusty Russell

tools/doc_extract: trim trailing blank lines on sections.

Makes things a bit neater.
parent 3c6506bd
......@@ -165,6 +165,7 @@ static void add_detabbed_line(struct doc_section *curr, const char *rawline)
static void trim_lines(struct doc_section *curr)
{
unsigned int i, trim = -1;
int last_non_empty = -1;
/* Get minimum whitespace prefix. */
for (i = 0; i < curr->num_lines; i++) {
......@@ -183,7 +184,14 @@ static void trim_lines(struct doc_section *curr)
curr->lines[i] += prefix;
else
curr->lines[i] += trim;
/* All blank? Potential to trim. */
if (curr->lines[i][strspn(curr->lines[i], " \t")] != '\0')
last_non_empty = i;
}
/* Remove trailing blank lines. */
curr->num_lines = last_non_empty + 1;
}
struct list_head *extract_doc_sections(char **rawlines)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment