X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fno_trailing_whitespace.c;h=74f759e7b30c2189e465c920046751ebf356fe3c;hp=f046a248cc3e8bcfa818c9f213ca022efa2ad397;hb=HEAD;hpb=678cd10db6d6b81d97f3b98ea0a54657141632ad;ds=sidebyside diff --git a/tools/ccanlint/tests/no_trailing_whitespace.c b/tools/ccanlint/tests/no_trailing_whitespace.c index f046a248..74f759e7 100644 --- a/tools/ccanlint/tests/no_trailing_whitespace.c +++ b/tools/ccanlint/tests/no_trailing_whitespace.c @@ -1,11 +1,11 @@ /* Trailing whitespace test. Almost embarrassing, but trivial. */ #include -#include #include #include +#include /* FIXME: only print full analysis if verbose >= 2. */ -static char *get_trailing_whitespace(const char *line) +static char *get_trailing_whitespace(const tal_t *ctx, const char *line) { const char *e = strchr(line, 0); while (e>line && (e[-1]==' ' || e[-1]=='\t')) @@ -16,14 +16,12 @@ static char *get_trailing_whitespace(const char *line) return NULL; //the line only consists of spaces if (strlen(line) > 20) - return talloc_asprintf(line, "...'%s'", - line + strlen(line) - 20); - return talloc_asprintf(line, "'%s'", line); + return tal_fmt(ctx, "...'%s'", line + strlen(line) - 20); + return tal_fmt(ctx, "'%s'", line); } static void check_trailing_whitespace(struct manifest *m, - bool keep, - unsigned int *timeleft, + unsigned int *timeleft UNNEEDED, struct score *score) { struct list_head *list; @@ -36,8 +34,9 @@ static void check_trailing_whitespace(struct manifest *m, foreach_ptr(list, &m->c_files, &m->h_files) { list_for_each(list, f, list) { char **lines = get_ccan_file_lines(f); - for (i = 0; i < f->num_lines; i++) { - char *err = get_trailing_whitespace(lines[i]); + for (i = 0; f->lines[i]; i++) { + char *err = get_trailing_whitespace(score, + lines[i]); if (err) score_file_error(score, f, i+1, "%s", err); @@ -53,7 +52,7 @@ struct ccanlint no_trailing_whitespace = { .key = "no_trailing_whitespace", .name = "Module's source code has no trailing whitespace", .check = check_trailing_whitespace, - .needs = "" + .needs = "info_exists" };