#include "ccanlint.h"
-#include "get_file_lines.h"
-#include <talloc/talloc.h>
-#include <string/string.h>
-#include <noerr/noerr.h>
+#include <ccan/talloc/talloc.h>
+#include <ccan/str/str.h>
+#include <ccan/str_talloc/str_talloc.h>
+#include <ccan/grab_file/grab_file.h>
+#include <ccan/noerr/noerr.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
char **get_ccan_file_lines(struct ccan_file *f)
{
- if (!f->lines)
- f->lines = get_file_lines(f, f->name, &f->num_lines);
+ if (!f->lines) {
+ char *buffer = grab_file(f, f->name, NULL);
+ if (!buffer)
+ err(1, "Getting file %s", f->name);
+ f->lines = strsplit(f, buffer, "\n", &f->num_lines);
+ }
return f->lines;
}
+struct list_head *get_ccan_file_docs(struct ccan_file *f)
+{
+ if (!f->doc_sections) {
+ get_ccan_file_lines(f);
+ f->doc_sections = extract_doc_sections(f->lines, f->num_lines);
+ }
+ return f->doc_sections;
+}
+
static void add_files(struct manifest *m, const char *dir)
{
DIR *d;
f = talloc(m, struct ccan_file);
f->lines = NULL;
+ f->doc_sections = NULL;
f->name = talloc_asprintf(f, "%s%s", dir, ent->d_name);
if (lstat(f->name, &st) != 0)
err(1, "lstat %s", f->name);
dest = &m->h_files;
} else if (strstarts(f->name, "test/")) {
if (is_c_src) {
- if (strstarts(f->name, "test/run"))
+ if (strstarts(f->name, "test/api"))
+ dest = &m->api_tests;
+ else if (strstarts(f->name, "test/run"))
dest = &m->run_tests;
else if (strstarts(f->name, "test/compile_ok"))
dest = &m->compile_ok_tests;
m->info_file = NULL;
list_head_init(&m->c_files);
list_head_init(&m->h_files);
+ list_head_init(&m->api_tests);
list_head_init(&m->run_tests);
list_head_init(&m->compile_ok_tests);
list_head_init(&m->compile_fail_tests);