]> git.ozlabs.org Git - ccan/commitdiff
Another Joey fix:
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 29 Mar 2009 06:01:02 +0000 (16:31 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 29 Mar 2009 06:01:02 +0000 (16:31 +1030)
(15:30:58) joeyadams: Also, ccanlint detects "trailing newlines" on empty lines.  Is this a bug, or is
it policy?
(15:52:03) joeyadams: In my code, I like to keep blank lines in my routines indented to the associated
level so automatic indent will apply there

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'",