X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftrailing_whitespace.c;fp=tools%2Fccanlint%2Ftrailing_whitespace.c;h=0000000000000000000000000000000000000000;hb=8f61c0bccb152b2365baf70deac1e59264d7feb7;hp=96ab0d9dcfe3e7a60e27eccad66c96c4834c7e45;hpb=15290c3feb9b61967311659a865fb3b5d05b1a49;p=ccan diff --git a/tools/ccanlint/trailing_whitespace.c b/tools/ccanlint/trailing_whitespace.c deleted file mode 100644 index 96ab0d9d..00000000 --- a/tools/ccanlint/trailing_whitespace.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Trailing whitespace test. Almost embarrassing, but trivial. */ -#include "ccanlint.h" -#include -#include - -static char *report_on_trailing_whitespace(const char *line) -{ - const char *e = strchr(line, 0); - while (e>line && (e[-1]==' ' || e[-1]=='\t')) - e--; - if (*e == 0) - return NULL; //there were no trailing spaces - if (e == 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); -} - -static void *check_trailing_whitespace(struct manifest *m) -{ - char *report; - - report = report_on_lines(&m->c_files, report_on_trailing_whitespace, - NULL); - report = report_on_lines(&m->h_files, report_on_trailing_whitespace, - report); - - return report; -} - -static const char *describe_trailing_whitespace(struct manifest *m, - void *check_result) -{ - return talloc_asprintf(check_result, - "Some source files have trailing whitespace:\n" - "%s", (char *)check_result); -} - -struct ccanlint trailing_whitespace = { - .name = "No lines with unnecessary trailing whitespace", - .total_score = 1, - .check = check_trailing_whitespace, - .describe = describe_trailing_whitespace, -};