Skip to content

Commit

Permalink
Make C/C++/ObjC include directive scanning pattern more strict.
Browse files Browse the repository at this point in the history
1. Require that the directive is at the beginning of a line, sans
   leading spaces.
2. Require that the header name is not empty.

This eliminates majority of comments that look like #include directives.
One practical example is a comment in Boost.Wave that has "#include <>"
and "#include """ in its body.
  • Loading branch information
Lastique committed Feb 23, 2024
1 parent b0311a0 commit 7220f5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tools/types/cpp.jam
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class c-scanner : scanner

rule pattern ( )
{
return "#[ \t]*include[ \t]*(<(.*)>|\"(.*)\")" ;
return "^[ \t]*#[ \t]*include[ \t]*(<(.+)>|\"(.+)\")" ;
}

rule process ( target : matches * : binding )
Expand Down
2 changes: 1 addition & 1 deletion src/tools/types/objc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class objc-scanner : c-scanner

rule pattern ( )
{
return "#[ \t]*include|import[ ]*(<(.*)>|\"(.*)\")" ;
return "^[ \t]*#[ \t]*include|import[ ]*(<(.+)>|\"(.+)\")" ;
}
}

Expand Down

0 comments on commit 7220f5b

Please sign in to comment.