utf8: don't allow NUL in decoded strings.
[ccan] / tools / ccanlint / tests / info_summary_single_line.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <stdio.h>
4 #include <ccan/str/str.h>
5
6 static void check_info_summary_single_line(struct manifest *m,
7                                            unsigned int *timeleft UNNEEDED,
8                                            struct score *score)
9 {
10         struct list_head *infodocs = get_ccan_file_docs(m->info_file);
11         struct doc_section *d;
12
13         score->pass = true;
14         score->score = 1;
15
16         list_for_each(infodocs, d, list) {
17                 const char *after;
18
19                 if (!streq(d->type, "summary"))
20                         continue;
21
22                 /* line following summary line should be empty */
23                 after = m->info_file->lines[d->srcline+1];
24                 if (after && strspn(after, " *") != strlen(after)) {
25                         score->pass = false;
26                         score->score = 0;
27                         score_file_error(score, m->info_file, d->srcline+1,
28                                          "%s\n%s",
29                                          m->info_file->lines[d->srcline],
30                                          m->info_file->lines[d->srcline+1]);
31                 }
32         }
33 }
34
35 struct ccanlint info_summary_single_line = {
36         .key = "info_summary_single_line",
37         .name = "Module has a single line summary in _info",
38         .check = check_info_summary_single_line,
39         .needs = "info_exists"
40 };
41
42 REGISTER_TEST(info_summary_single_line);