1 /* Trailing whitespace test. Almost embarrassing, but trivial. */
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
6 static char *report_on_trailing_whitespace(const char *line)
8 if (!strends(line, " ") && !strends(line, "\t"))
11 if (strlen(line) > 20)
12 return talloc_asprintf(line, "...'%s'",
13 line + strlen(line) - 20);
14 return talloc_asprintf(line, "'%s'", line);
17 static void *check_trailing_whitespace(struct manifest *m)
21 report = report_on_lines(&m->c_files, report_on_trailing_whitespace,
23 report = report_on_lines(&m->h_files, report_on_trailing_whitespace,
29 static const char *describe_trailing_whitespace(struct manifest *m,
32 return talloc_asprintf(check_result,
33 "Some source files have trailing whitespace:\n"
34 "%s", (char *)check_result);
37 struct ccanlint trailing_whitespace = {
38 .name = "Lines with unnecessary trailing whitespace",
40 .check = check_trailing_whitespace,
41 .describe = describe_trailing_whitespace,