summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-12-03 19:29:23 +1030
committerRusty Russell <rusty@rustcorp.com.au>2012-12-03 19:29:23 +1030
commit932d65dd6537250e617516749f03a00fea3b34f6 (patch)
treeb03086bb778f05ac9e6a9f566cf49b5f89e316b4
parent6a4d45337811b56d947e52f031b9ca0c955fcb6c (diff)
ccanlint: handle nested modules when mentioned in examples.
If we see an ccan include line in an example, we add that to the dependencies to try to build the example, but we didn't handle nested modules. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--tools/ccanlint/tests/depends_accurate.c2
-rw-r--r--tools/ccanlint/tests/examples_compile.c12
2 files changed, 6 insertions, 8 deletions
diff --git a/tools/ccanlint/tests/depends_accurate.c b/tools/ccanlint/tests/depends_accurate.c
index 83a19e2c..05ada48a 100644
--- a/tools/ccanlint/tests/depends_accurate.c
+++ b/tools/ccanlint/tests/depends_accurate.c
@@ -48,7 +48,7 @@ static bool check_dep_includes(struct manifest *m,
char *mod;
if (!strreg(f, lines[i],
"^[ \t]*#[ \t]*include[ \t]*[<\"]"
- "(ccan/+.+)/+[^/]+.h", &mod))
+ "(ccan/+.+)/+[^/]+\\.h", &mod))
continue;
if (has_dep(m, deps, used, mod))
diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c
index ce1d9769..7d8803c6 100644
--- a/tools/ccanlint/tests/examples_compile.c
+++ b/tools/ccanlint/tests/examples_compile.c
@@ -1,6 +1,7 @@
#include <tools/ccanlint/ccanlint.h>
#include <tools/tools.h>
#include <ccan/talloc/talloc.h>
+#include <ccan/str_talloc/str_talloc.h>
#include <ccan/cast/cast.h>
#include <ccan/str/str.h>
#include <sys/types.h>
@@ -83,13 +84,10 @@ static struct manifest **get_example_deps(struct manifest *m,
/* Other modules implied by includes. */
for (lines = get_ccan_file_lines(f); *lines; lines++) {
- unsigned preflen = strspn(*lines, " \t");
- if (strstarts(*lines + preflen, "#include <ccan/")) {
- char *modname;
-
- modname = talloc_strdup(f, *lines + preflen
- + strlen("#include <ccan/"));
- modname[strcspn(modname, "/")] = '\0';
+ char *modname;
+ if (strreg(f, *lines,
+ "^[ \t]*#[ \t]*include[ \t]*[<\"]"
+ "ccan/+(.+)/+[^/]+\\.h", &modname)) {
if (!have_mod(deps, modname))
add_dep(&deps, modname);
}