X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftrailing_whitespace.c;h=537e955ee69bed43dd62ac1e38fc6057966a6438;hp=df1ce772b21939048bb7a97af34c5b8d8593c8b6;hb=02005621033206078929b388f13afc69a6688094;hpb=7c71ddab47d9b06aa140f305c956e454d711e66e 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'",