- char *file;
- char **lines, **ret;
- unsigned int i, num;
- bool printing = false, printed = false;
-
- file = grab_file(NULL, fname, NULL);
- if (!file)
- err(1, "Reading file %s", fname);
- lines = strsplit(file, file, "\n", &num);
- ret = talloc_array(NULL, char *, num+1);
-
- num = 0;
- for (i = 0; lines[i]; i++) {
- if (streq(lines[i], "/**")) {
- printing = true;
- if (printed++)
- talloc_append_string(ret[num], "\n");
- } else if (streq(lines[i], " */"))
- printing = false;
- else if (printing) {
- if (strstarts(lines[i], " * "))
- ret[num++] = talloc_strdup(ret, lines[i]+3);
- else if (strstarts(lines[i], " *"))
- ret[num++] = talloc_strdup(ret, lines[i]+2);
- else
- errx(1, "Malformed line %s:%u", fname, i);