X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_compile.c;h=3cbb23fd024db87249408ea5950bf3e753b85af1;hb=60824f8a0f758dc7808eb31cc83434ea78f44ed1;hp=35e45ca03f26116b5584a34c5486cbc0a5d387a3;hpb=b931f4765272d68de3b5e35d70c1933c27bcdea4;p=ccan diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index 35e45ca0..3cbb23fd 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -12,7 +12,7 @@ #include #include #include -#include "../compulsory_tests/build.h" +#include "build.h" static const char *can_run(struct manifest *m) { @@ -199,6 +199,8 @@ static bool looks_internal(char **lines, char **why) if (!line[0] || cisspace(line[0]) || strstarts(line, "//")) continue; + assert(line[strlen(line)-1] != '\n'); + /* The winners. */ if (strstarts(line, "if") && len == 2) { *why = cast_const(char *, "starts with if"); @@ -237,6 +239,12 @@ static bool looks_internal(char **lines, char **why) } } + /* Previously prepended. */ + if (strstr(line, "didn't seem to belong inside a function")) { + *why = cast_const(char *, "Comment said so"); + return false; + } + /* Single identifier then operator == inside function. */ if (last_ended && len && cispunct(line[len+strspn(line+len, " ")])) { @@ -247,6 +255,7 @@ static bool looks_internal(char **lines, char **why) last_ended = (strends(line, "}") || strends(line, ";") + || strends(line, "*/") || streq(line, "...")); } @@ -298,7 +307,7 @@ static char **combine(const void *ctx, char **lines, char **prev) prev_total = i; ret = talloc_array(ctx, char *, 1 +lines_total + prev_total + 1); - ret[0] = talloc_asprintf(ret, "/* The example %s, thus %s */\n", + ret[0] = talloc_asprintf(ret, "/* The example %s, thus %s */", why, reasoning); memcpy(ret+1, lines, count * sizeof(ret[0])); memcpy(ret+1 + count, prev, prev_total * sizeof(ret[0]));