ccanlint: check all headers for examples.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 10 Nov 2014 04:30:06 +0000 (15:00 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 10 Nov 2014 04:30:06 +0000 (15:00 +1030)
pushpull module doesn't have examples in pushpull.h.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tools/ccanlint/tests/examples_exist.c

index e308be20ec76289bab821fe77c19f9413eab8f63..c42a2e4e9ff27c5f183b498e798c3ae10a1e238f 100644 (file)
@@ -79,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);
@@ -115,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);