X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftrailing_whitespace.c;h=537e955ee69bed43dd62ac1e38fc6057966a6438;hb=914fa0bf6ec0bbe165ddf917e73a1e207743ba1d;hp=35f37380c0e2f331f3ec37b7777e674a7a18df73;hpb=9965fc25fcc92dc76d1cd4cf9595dc3dc9ebc586;p=ccan diff --git a/tools/ccanlint/trailing_whitespace.c b/tools/ccanlint/trailing_whitespace.c index 35f37380..537e955e 100644 --- a/tools/ccanlint/trailing_whitespace.c +++ b/tools/ccanlint/trailing_whitespace.c @@ -1,12 +1,17 @@ /* Trailing whitespace test. Almost embarrassing, but trivial. */ #include "ccanlint.h" -#include -#include +#include +#include static char *report_on_trailing_whitespace(const char *line) { - if (!strends(line, " ") && !strends(line, "\t")) - return NULL; + 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'",