Added copyright and license
[libcds.git] / tools / brush_cds.pl
index a53090bb8c2e578f7e16d30a418c6ec14a76dab5..a8ca3862021d746d6388f0c05d028ac585e2832f 100644 (file)
@@ -2,7 +2,10 @@
 \r
 my $nTabsFound = 0;\r
 \r
-brush()        ;\r
+my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);\r
+$year += 1900;\r
+\r
+brush();\r
 \r
 print "Tabs found: $nTabsFound\n" ;\r
 print "Done\n" ;\r
@@ -29,35 +32,68 @@ sub processDir( $ )
        \r
        foreach my $file ( @files ) {\r
                if ( -d "$dirName/$file" ) {\r
-                       processDir("$dirName/$file")    ;\r
+                       processDir("$dirName/$file");\r
                }\r
                elsif ( $file =~ /\.(h|cpp)$/ ) {\r
-                       processFile( "$dirName/$file" ) ;\r
+                       processFile( "$dirName/$file" );\r
                }\r
        }\r
 }\r
 \r
 sub processFile( $ ) \r
 {\r
-       my $file = shift        ;\r
+       my $file = shift;\r
 \r
-       \r
        if ( open( my $fh, $file )) {\r
                binmode $fh     ;\r
-               my $str = ''            ;\r
+               my $str = '';\r
                while (<$fh>) {\r
-                       $nTabsFound += $_ =~ s/\t/    /g;\r
-                       $_ =~ s/\s+$//  ;\r
-                       $_ =~ s/\s+;$/;/;\r
-                       $str .= $_      ;\r
-                       $str .= "\n"    ;\r
+            if ( /^\/\/\$\$CDS-header\$\$/ ) {\r
+                $str .= \r
+"/*\r
+    This file is a part of libcds - Concurrent Data Structures library\r
+\r
+    (C) Copyright Maxim Khizhinsky (libcds.dev\@gmail.com) 2006-$year\r
+\r
+    Source code repo: http://github.com/khizmax/libcds/\r
+    Download: http://sourceforge.net/projects/libcds/files/\r
+    \r
+    Redistribution and use in source and binary forms, with or without\r
+    modification, are permitted provided that the following conditions are met:\r
+\r
+    * Redistributions of source code must retain the above copyright notice, this\r
+      list of conditions and the following disclaimer.\r
+\r
+    * Redistributions in binary form must reproduce the above copyright notice,\r
+      this list of conditions and the following disclaimer in the documentation\r
+      and/or other materials provided with the distribution.\r
+\r
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     \r
+*/\n" ;\r
+            }\r
+            else {\r
+                $nTabsFound += $_ =~ s/\t/    /g;\r
+                $_ =~ s/\s+$//  ;\r
+                $_ =~ s/\s+;$/;/;\r
+                $str .= $_      ;\r
+                $str .= "\n"    ;\r
+            }\r
                }\r
-               close $fh       ;\r
+               close $fh;\r
                \r
                if ( open( my $fh, ">$file" )) {\r
-                       binmode $fh     ;\r
-                       print $fh $str  ;\r
-                       close $fh               ;\r
+                       binmode $fh;\r
+                       print $fh $str;\r
+                       close $fh;\r
                }\r
        }\r
 }\r