X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=tools%2Fccanlint%2Ftrailing_whitespace.c;h=537e955ee69bed43dd62ac1e38fc6057966a6438;hb=914fa0bf6ec0bbe165ddf917e73a1e207743ba1d;hp=df1ce772b21939048bb7a97af34c5b8d8593c8b6;hpb=7beaa3448fa8e6015798c1609f33d96e8986063d;p=ccan diff --git a/tools/ccanlint/trailing_whitespace.c b/tools/ccanlint/trailing_whitespace.c index df1ce772..537e955e 100644 --- a/tools/ccanlint/trailing_whitespace.c +++ b/tools/ccanlint/trailing_whitespace.c @@ -5,8 +5,13 @@ 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'",