+/* Not very efficient: we could track prefix length while doing
+ * add_detabbed_line */
+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++) {
+ unsigned int prefix = strspn(curr->lines[i], " ");
+ /* Ignore blank lines */
+ if (curr->lines[i][prefix] == '\0')
+ continue;
+ if (prefix < trim)
+ trim = prefix;
+ }
+
+ /* Now trim it. */
+ for (i = 0; i < curr->num_lines; i++) {
+ unsigned int prefix = strspn(curr->lines[i], " ");
+ if (prefix < trim)
+ 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, const char *file)