X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_compile.c;h=f9a919a1bfcf7d83748d026e79ec8eb2dd278601;hb=5378c864f9c37f39d906f599285da25a7db0c9fe;hp=e66379f5e7fee45e9036a5cda09f664dac568b09;hpb=b61b4b2f2c257b6e776772794969ee8526e132a8;p=ccan diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index e66379f5..f9a919a1 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -122,6 +122,7 @@ static char *compile(const void *ctx, "", lib_list(m), file->compiled); if (errmsg) { talloc_free(file->compiled); + file->compiled = NULL; return errmsg; } return NULL; @@ -429,6 +430,7 @@ static struct ccan_file *mangle_example(struct manifest *m, } close(fd); f->contents = talloc_steal(f, contents); + list_add(&m->mangled_examples, &f->list); return f; } @@ -450,35 +452,35 @@ static void *build_examples(struct manifest *m, bool keep, examples_compile.total_score++; /* Simplify our dumb parsing. */ strip_leading_whitespace(get_ccan_file_lines(i)); - ret = compile(score, m, i, keep); + ret = compile(i, m, i, keep); if (!ret) { prev = get_ccan_file_lines(i); score->score++; continue; } + /* Try standalone. */ + mangle1 = mangle_example(m, i, get_ccan_file_lines(i), keep); + ret1 = compile(i, m, mangle1, keep); + if (!ret1) { + prev = get_ccan_file_lines(i); + score->score++; + continue; + } + /* Try combining with previous (successful) example... */ if (prev) { char **new = combine(i, get_ccan_file_lines(i), prev); - mangle1 = mangle_example(m, i, new, keep); - ret1 = compile(score, m, mangle1, keep); - if (!ret1) { + mangle2 = mangle_example(m, i, new, keep); + ret2 = compile(i, m, mangle1, keep); + if (!ret2) { prev = new; score->score++; continue; } } - /* Try standalone. */ - mangle2 = mangle_example(m, i, get_ccan_file_lines(i), keep); - ret2 = compile(score, m, mangle2, keep); - if (!ret2) { - prev = get_ccan_file_lines(i); - score->score++; - continue; - } - score->errors = talloc_asprintf_append(score->errors, "%s: tried standalone example:\n" "%s\n" @@ -486,23 +488,24 @@ static void *build_examples(struct manifest *m, bool keep, i->name, get_ccan_file_contents(i), ret); - if (mangle1) { - score->errors = talloc_asprintf_append(score->errors, - "%s: tried combining with" - " previous example:\n" - "%s\n" - "Errors: %s\n\n", - i->name, - get_ccan_file_contents(mangle1), - ret1); - } score->errors = talloc_asprintf_append(score->errors, "%s: tried adding headers, wrappers:\n" "%s\n" "Errors: %s\n\n", i->name, + get_ccan_file_contents(mangle1), + ret1); + + if (mangle2) { + score->errors = talloc_asprintf_append(score->errors, + "%s\n" + "%s: tried combining with" + " previous example:\n" + "Errors: %s\n\n", + i->name, get_ccan_file_contents(mangle2), ret2); + } /* This didn't work, so not a candidate for combining. */ prev = NULL; }