Runs fewer elimination stack test cases
[libcds.git] / tools / brush_cds.pl
1 #!/usr/bin/perl\r
2 \r
3 my $nTabsFound = 0;\r
4 \r
5 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);\r
6 $year += 1900;\r
7 \r
8 brush();\r
9 \r
10 print "Tabs found: $nTabsFound\n" ;\r
11 print "Done\n" ;\r
12 \r
13 exit ;\r
14 \r
15 sub brush() \r
16 {\r
17         processDir( "../cds" ) ;\r
18         processDir( "../src" ) ;\r
19         processDir( "../test" ) ;\r
20 }\r
21 \r
22 sub processDir( $ )\r
23 {\r
24         my $dirName = shift ;\r
25         print "Process $dirName directory...\n";\r
26         \r
27         opendir(my $dh, $dirName) || die "can't opendir $dirName: $!";\r
28     my @files = grep { /^[^\.]/ } readdir($dh);\r
29     closedir $dh;\r
30         \r
31         foreach my $file ( @files ) {\r
32                 if ( -d "$dirName/$file" ) {\r
33                         processDir("$dirName/$file");\r
34                 }\r
35                 elsif ( $file =~ /\.(h|cpp)$/ ) {\r
36                         processFile( "$dirName/$file" );\r
37                 }\r
38         }\r
39 }\r
40 \r
41 sub processFile( $ ) \r
42 {\r
43         my $file = shift;\r
44 \r
45         if ( open( my $fh, $file )) {\r
46                 #binmode $fh    ;\r
47                 my $str = '';\r
48                 while (<$fh>) {\r
49             $nTabsFound += $_ =~ s/\t/    /g;\r
50             $_ =~ s/\s+$//;\r
51             $_ =~ s/\s+;$/;/;\r
52             $_ =~ s/\)\s+\)/\)\)/g;\r
53             $str .= $_      ;\r
54             $str .= "\n"    ;\r
55                 }\r
56                 close $fh;\r
57                 \r
58                 if ( open( my $fh, ">$file" )) {\r
59                         #binmode $fh;\r
60                         print $fh $str;\r
61                         close $fh;\r
62                 }\r
63         }\r
64 }\r
65 \r
66 \r
67 \r