checkpatch: look for c99 comments in ctx_locate_comment
[linux-2.6-microblaze.git] / scripts / checkpatch.pl
index 10d75da..880fe86 100755 (executable)
@@ -1676,8 +1676,16 @@ sub ctx_statement_level {
 sub ctx_locate_comment {
        my ($first_line, $end_line) = @_;
 
+       # If c99 comment on the current line, or the line before or after
+       my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@);
+       return $current_comment if (defined $current_comment);
+       ($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@);
+       return $current_comment if (defined $current_comment);
+       ($current_comment) = ($rawlines[$end_line] =~ m@^[\+ ].*(//.*$)@);
+       return $current_comment if (defined $current_comment);
+
        # Catch a comment on the end of the line itself.
-       my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
+       ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
        return $current_comment if (defined $current_comment);
 
        # Look through the context and try and figure out if there is a