1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Reconcile DEP-5 debian/copyright to licensecheck
//
// Copyright : 2025 P Blackman
// License : BSD-2-clause
//
// Test for false positive on PSF-2 licence
//
unit psf;
{$mode delphi}
interface
function CheckPSF2 (Fname : AnsiString; Dep5, Actual : String) : Boolean;
implementation uses StrUtils, support;
const P2 : string = 'PSF-2';
P2txt : string = 'Python Software Foundation License Version 2';
function GetFileLicense (Fname : AnsiString) : String;
const MaxLines : Integer = 120;
var Lines : Integer;
Line : AnsiString;
Lfile : Text;
begin
result := '';
Lines := 0;
if OpenFile (FName, Lfile) then
begin
while not EOF (Lfile) and (Lines < MaxLines) do
begin
ReadLn (Lfile, Line);
if (NPos (p2txt, Line, 1) > 0) then
begin
result := P2;
Lines := MaxLines; // terminate loop
end;
end;
end;
end;
// Return true if Actual is a match for d/copyright
function CheckPSF2 (Fname : AnsiString; Dep5, Actual : String) : Boolean;
begin
result := False;
if (Dep5 = Actual) then
result := True
else
if (Dep5 = P2) and (Actual <> P2) then
if GetFileLicense (FName) = P2 then
result := True;
end;
end.
|