]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Check whether there is another license _after_ we removed an old boilerplate
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Oct 2013 18:21:21 +0000 (12:21 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Oct 2013 18:21:21 +0000 (12:21 -0600)
and skip such files as special cases.

scripts/boiler-mgr.pl

index 1ea77c536aaf392fa26c5b1d6812400a026da9ff..a6fa29b2af202a61c911b924054f919934c5efef 100755 (executable)
@@ -153,20 +153,25 @@ foreach my $fname (@FileNames) {
                        die("internal error: unsafe comment removal, stopped");
 
        } else { # no boilerplate found
-
-               # Some files have license declarations way down in the code.
-               my $license =
-                       "Copyright|".
-                       "This program is free software|".
-                       "Permission to use|".
-                       "Redistribution and use";
-               if ($code =~ m@/\*.*?($license).*?\*/@is) {
-                       &Warn("Suspected boilerplate in an unusual location, skipping.", $`.$&);
-                       next;
-               }
                #&Warn("Cannot find old boilerplate, adding new boilerplate.", $code);
        }
 
+       # Some files have license declarations way down in the code so we may not
+       # find a boilerplate at all or find an "empty" boilerplate preceeding them.
+       my $license =
+               "Copyright|".
+               "This program is free software|".
+               "Permission to use|".
+               "Redistribution and use";
+       if ($code =~ m@/\*.*?($license).*?\*/@is) {
+               # If we replaced what we thought is an old boiler, do not use $` for
+               # context because it is based on modified $code and will often mislead.
+               my $context = defined $boiler ? $& : ($` . $&);
+               &Warn("Suspected boilerplate in an unusual location, skipping.",
+                         $context);
+               next;
+       }
+
        $code = $CorrectBoiler . $extras . &trimL($code);
        &writeFile($fname, $code) unless $code eq $virginCode;
        undef $FileName;