X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fhas_examples.c;h=bfb298f2773c390dc8f7088f074a5e3d82051ad6;hp=22d18e9d5a1440004c341d2bde93f3b735707a7b;hb=09fde153ba7a68715dcad3b53cbbb8804c3d2356;hpb=f3305bc06847d022831f8ffd7beaccab316d8143 diff --git a/tools/ccanlint/tests/has_examples.c b/tools/ccanlint/tests/has_examples.c index 22d18e9d..bfb298f2 100644 --- a/tools/ccanlint/tests/has_examples.c +++ b/tools/ccanlint/tests/has_examples.c @@ -24,15 +24,19 @@ static char *add_example(struct manifest *m, struct ccan_file *source, int fd; struct ccan_file *f; - name = maybe_temp_file(m, ".c", keep, - talloc_asprintf(m, "%s/example-%s-%s.c", - talloc_dirname(m, - source->fullname), - source->name, - example->function)); + name = talloc_asprintf(m, "%s/example-%s-%s.c", + talloc_dirname(m, + source->fullname), + source->name, + example->function); + /* example->function == 'struct foo' */ + while (strchr(name, ' ')) + *strchr(name, ' ') = '_'; + + name = maybe_temp_file(m, ".c", keep, name); f = new_ccan_file(m, talloc_dirname(m, name), talloc_basename(m, name)); talloc_steal(f, name); - list_add(&m->examples, &f->list); + list_add_tail(&m->examples, &f->list); fd = open(f->fullname, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fd < 0)