X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_exist.c;h=c42a2e4e9ff27c5f183b498e798c3ae10a1e238f;hb=682b594ddb13c44fac31c07caeb287dd6bbf707b;hp=02ddb486268f15e62b686e2b86c675166b728554;hpb=09d5cd70d7e8105a003ed9583eadb077de014f3b;p=ccan diff --git a/tools/ccanlint/tests/examples_exist.c b/tools/ccanlint/tests/examples_exist.c index 02ddb486..c42a2e4e 100644 --- a/tools/ccanlint/tests/examples_exist.c +++ b/tools/ccanlint/tests/examples_exist.c @@ -32,7 +32,8 @@ static char *add_example(struct manifest *m, struct ccan_file *source, *strchr(name, ' ') = '_'; name = temp_file(m, ".c", take(name)); - f = new_ccan_file(m, path_dirname(m, name), path_basename(m, name)); + f = new_ccan_file(m, take(path_dirname(m, name)), + take(path_basename(m, name))); tal_steal(f, name); list_add_tail(&m->examples, &f->list); @@ -78,13 +79,12 @@ static void extract_examples(struct manifest *m, } } - /* Check main header. */ + /* Check all headers for examples. */ list_for_each(&m->h_files, f, list) { - if (!strstarts(f->name, m->basename) - || strlen(f->name) != strlen(m->basename) + 2) - continue; + if (strstarts(f->name, m->basename) + && strlen(f->name) == strlen(m->basename) + 2) + mainh = f; - mainh = f; list_for_each(get_ccan_file_docs(f), d, list) { if (streq(d->type, "example")) { score->error = add_example(m, f, d); @@ -114,7 +114,7 @@ struct ccanlint examples_exist = { .key = "examples_exist", .name = "_info and main header file have Example: sections", .check = extract_examples, - .needs = "info_exists" + .needs = "info_exists main_header_exists" }; REGISTER_TEST(examples_exist);