check-namespace-bug.pl 377 B

123456789101112131415161718192021222324
  1. #!/usr/bin/perl -w
  2. for my $file ( @ARGV )
  3. {
  4. my $namespace_found = 0;
  5. open ( FILE, "<$file" ) or die ("$file: $!\n");
  6. while (<FILE>)
  7. {
  8. chomp;
  9. if ( /^ *namespace +/ ) {
  10. $namespace_found = 1;
  11. }
  12. if ( /^ *#include/ && ! /\.tcc/ ) {
  13. if ( $namespace_found ) {
  14. warn("$file: wrong order of namespace and includes!\n");
  15. last;
  16. }
  17. }
  18. }
  19. close ( FILE );
  20. }