comparison tools/bsd_license.ml @ 546:306539f29eea

Make specially licensed versions of lib files for cpdtlib.tgz. This adds an ocaml tool and calls to it in the Makefile.
author Arthur Peters <amp@singingwizard.org>
date Thu, 12 May 2016 18:09:36 -0500
parents
children 3fc43e261f67
comparison
equal deleted inserted replaced
545:4f6e7bab0d45 546:306539f29eea
1 let read_line () =
2 try
3 Some (read_line ())
4 with End_of_file -> None
5
6 let print_bsd_licence () = begin
7 print_endline " * Three-clause BSD Licence";
8 print_endline " *";
9 print_endline " * All rights reserved.";
10 print_endline " *";
11 print_endline " * Redistribution and use in source and binary forms, with or without";
12 print_endline " * modification, are permitted provided that the following conditions are met:";
13 print_endline " *";
14 print_endline " * - Redistributions of source code must retain the above copyright notice,";
15 print_endline " * this list of conditions and the following disclaimer.";
16 print_endline " * - Redistributions in binary form must reproduce the above copyright notice,";
17 print_endline " * this list of conditions and the following disclaimer in the documentation";
18 print_endline " * and/or other materials provided with the distribution.";
19 print_endline " * - The names of contributors may not be used to endorse or promote products";
20 print_endline " * derived from this software without specific prior written permission.";
21 print_endline " *";
22 print_endline " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"";
23 print_endline " * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE";
24 print_endline " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE";
25 print_endline " * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE";
26 print_endline " * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ";
27 print_endline " * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF";
28 print_endline " * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS";
29 print_endline " * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN";
30 print_endline " * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)";
31 print_endline " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE";
32 print_endline " * POSSIBILITY OF SUCH DAMAGE."
33 end
34
35 let rec initial () =
36 match read_line () with
37 | None -> ()
38 | Some line ->
39 let trimmed = String.trim line in
40 if String.length trimmed >= 12 && String.sub trimmed 0 12 = "(* Copyright" then begin
41 print_endline line;
42 copyright_block ()
43 end else
44 print_endline line;
45 initial ()
46
47 and copyright_block () =
48 match read_line () with
49 | None -> ()
50 | Some line ->
51 let trimmed = String.trim line in
52 if String.length trimmed >= 2 && String.sub trimmed 0 2 = "*)" then begin
53 print_endline line;
54 initial ()
55 end else if String.length trimmed >= 31 && String.sub trimmed 0 31 = "* This work is licensed under a" then begin
56 print_endline line;
57 print_bsd_licence ();
58 drop_to_end_comment ()
59 end else
60 print_endline line;
61 copyright_block ()
62
63 and drop_to_end_comment () =
64 match read_line () with
65 | None -> ()
66 | Some line ->
67 let trimmed = String.trim line in
68 if String.length trimmed >= 2 && String.sub trimmed 0 2 = "*)" then begin
69 print_endline line;
70 initial ()
71 end else
72 drop_to_end_comment ()
73
74 let () = initial ()