From: Alex Rousskov Date: Thu, 3 Oct 2013 18:21:21 +0000 (-0600) Subject: Check whether there is another license _after_ we removed an old boilerplate X-Git-Tag: SQUID_3_5_0_1~98^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ce0afb16ebe0faa39b02c2c7c61febe9dff2116;p=thirdparty%2Fsquid.git Check whether there is another license _after_ we removed an old boilerplate and skip such files as special cases. --- diff --git a/scripts/boiler-mgr.pl b/scripts/boiler-mgr.pl index 1ea77c536a..a6fa29b2af 100755 --- a/scripts/boiler-mgr.pl +++ b/scripts/boiler-mgr.pl @@ -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;