]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/trailing_whitespace.c
Another Joey fix:
[ccan] / tools / ccanlint / trailing_whitespace.c
index df1ce772b21939048bb7a97af34c5b8d8593c8b6..537e955ee69bed43dd62ac1e38fc6057966a6438 100644 (file)
@@ -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'",