]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/trailing_whitespace.c
Another Joey fix:
[ccan] / tools / ccanlint / trailing_whitespace.c
index 35f37380c0e2f331f3ec37b7777e674a7a18df73..537e955ee69bed43dd62ac1e38fc6057966a6438 100644 (file)
@@ -1,12 +1,17 @@
 /* Trailing whitespace test.  Almost embarrassing, but trivial. */
 #include "ccanlint.h"
-#include <talloc/talloc.h>
-#include <str/str.h>
+#include <ccan/talloc/talloc.h>
+#include <ccan/str/str.h>
 
 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'",