File: eclipse.pas

package info (click to toggle)
licenserecon 11.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: pascal: 1,386; makefile: 33; perl: 31; xml: 9; sh: 2
file content (69 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
// Reconcile DEP-5 debian/copyright to licensecheck
//
// Copyright : 2024 P Blackman
// License   : BSD-2-clause
//
// Test for false detection of Eclipse license

unit eclipse;
{$mode delphi}

interface

function CheckEclipse (Fname : AnsiString; Dep5, Actual: String) : Boolean;


implementation uses StrUtils, Support;

// test for GPL+ style license
function CheckLicense (Fname : AnsiString) : Boolean;
const Max1 : Integer = 200; // Arbitrary, license usually at start of file

var Lines : Integer;
    E,EPL : Boolean;
    Line : AnsiString;
    Lfile : Text;

begin
    result  := false;
    E       := false;
    EPL     := false;
    Lines := 0;

    if OpenFile (FName, Lfile) then
    begin
        while not EOF (Lfile) and (Lines < Max1) do
        begin
            readln (Lfile, Line);

            E := E or (NPos ('Eclipse', Line, 1) > 0);

            If E then
                EPL := EPL or (NPos ('Eclipse Public License', Line, 1) > 0);

            if EPL then
                // Found 'Eclipse Public License'
                Lines  := Max1 // terminate loop
            else
                inc (Lines);
        end;

        if E and not EPL then
            // Found 'Eclipse' but not 'Eclipse Public License'
            result := true;

        Close (Lfile);
    end;
end;

// Return true if probable false detection of Eclipse license
function CheckEclipse (Fname : AnsiString; Dep5, Actual: String) : Boolean;
begin
    if    ContainsStr (Actual, 'EPL')
    and not ContainsStr (Dep5, 'EPL') then
        result := CheckLicense (FName)
    else
        result := false;
end;

end.