Browse Source

Another Joey fix:
(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

Rusty Russell 17 years ago
parent
commit
0200562103
1 changed files with 7 additions and 2 deletions
  1. 7 2
      tools/ccanlint/trailing_whitespace.c

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