|
14 | 14 | (locate-dominating-file dir "_prepare.el")) |
15 | 15 | nil t)) |
16 | 16 |
|
| 17 | +;; |
| 18 | +;;; Externals |
| 19 | + |
| 20 | +(require 'whitespace nil t) |
| 21 | + |
17 | 22 | ;; |
18 | 23 | ;;; Flags |
19 | 24 |
|
|
22 | 27 | ;; |
23 | 28 | ;;; Core |
24 | 29 |
|
25 | | -(defun eask--string-match-all (regexps) |
26 | | - "Return t when every REGEXPS match the `buffer-string'." |
27 | | - (cl-every (lambda (regexp) |
28 | | - (string-match-p regexp (buffer-string))) |
29 | | - regexps)) |
| 30 | +(defun eask--string-match-all (contents) |
| 31 | + "Return t when every CONTENTS match the `buffer-string'." |
| 32 | + (cl-every (lambda (content) |
| 33 | + (string-match-p (eask-s-replace "\n" " " content) (buffer-string))) |
| 34 | + contents)) |
30 | 35 |
|
31 | 36 | (defun eask--scan-license (file) |
32 | 37 | "Scan the license FILE." |
33 | | - (with-current-buffer (find-file file) |
| 38 | + (with-temp-buffer |
| 39 | + (insert-file-contents file) |
| 40 | + (let ((whitespace-style '(trailing))) |
| 41 | + (whitespace-cleanup)) |
| 42 | + (let ((content (eask-s-replace "\n" " " (buffer-string)))) |
| 43 | + (erase-buffer) |
| 44 | + (insert content)) |
34 | 45 | ;; See https://api.github.com/licenses |
35 | 46 | (cond |
36 | | - ((eask--string-match-all '("GNU AFFERO GENERAL PUBLIC LICENSE" |
37 | | - "Version 3" |
38 | | - "You should have received a copy of the GNU Affero General Public License")) |
| 47 | + ((eask--string-match-all |
| 48 | + '("You should have received a copy of the GNU Affero General Public License")) |
39 | 49 | '("agpl-3.0" "GNU Affero General Public License v3.0" "AGPL-3.0")) |
40 | | - ((eask--string-match-all '("Apache" |
41 | | - "http://www.apache.org/licenses/")) |
| 50 | + ((eask--string-match-all |
| 51 | + '("Licensed under the Apache License, Version 2.0")) |
42 | 52 | '("apache-2.0" "Apache License 2.0" "Apache-2.0")) |
43 | | - ((eask--string-match-all '("BSD 2-Clause")) |
| 53 | + ((eask--string-match-all |
| 54 | + '("Redistribution and use in source and binary forms" |
| 55 | + "Redistributions in binary form must reproduce")) |
44 | 56 | '("bsd-2-clause" "BSD 2-Clause \"Simplified\" License" "BSD-2-Clause")) |
45 | | - ((eask--string-match-all '("BSD 3-Clause")) |
| 57 | + ((eask--string-match-all |
| 58 | + '("Redistribution and use in source and binary forms" |
| 59 | + "Neither the name of the copyright holder nor")) |
46 | 60 | '("bsd-3-clause" "BSD 3-Clause \"New\" or \"Revised\" License" "BSD-3-Clause")) |
47 | | - ((eask--string-match-all '("Boost Software License - Version 1.0")) |
| 61 | + ((eask--string-match-all |
| 62 | + '("Permission is hereby granted, free of charge, to any person or organization")) |
48 | 63 | '("bsl-1.0" "Boost Software License 1.0" "BSL-1.0")) |
49 | 64 | ((eask--string-match-all '("CC0 1.0")) |
50 | 65 | '("cc0-1.0" "Creative Commons Zero v1.0 Universal" "CC0-1.0")) |
51 | | - ((eask--string-match-all '("Eclipse Public License - v 2.0" |
52 | | - "Eclipse Foundation")) |
| 66 | + ((eask--string-match-all |
| 67 | + '("Eclipse Public License - v 2.0" |
| 68 | + "Eclipse Foundation")) |
53 | 69 | '("epl-2.0" "Eclipse Public License 2.0" "EPL-2.0")) |
54 | | - ((eask--string-match-all '("GNU General Public License" |
55 | | - "Version 2")) |
| 70 | + ((eask--string-match-all |
| 71 | + '("Copying and distribution of this file, with or without")) |
| 72 | + '("fsfap" "FSF All Permissive License" "FSFAP")) |
| 73 | + ((eask--string-match-all |
| 74 | + '("is free software." "you can redistribute it" |
| 75 | + "version 2 of the")) |
56 | 76 | '("gpl-2.0" "GNU General Public License v2.0" "GPL-2.0")) |
57 | | - ((eask--string-match-all '("GNU General Public License" |
58 | | - "version 3" |
59 | | - "You should have received a copy of the GNU General Public License")) |
| 77 | + ((eask--string-match-all |
| 78 | + '("is free software." "you can redistribute it" |
| 79 | + "version 3 of the")) |
60 | 80 | '("gpl-3.0" "GNU General Public License v3.0" "GPL-3.0")) |
| 81 | + ((eask--string-match-all |
| 82 | + '("Permission to use, copy, modify, and/or distribute this")) |
| 83 | + '("isc" " Internet Systems Consortium" "ISC")) |
61 | 84 | ((eask--string-match-all '("Lesser GPL" |
62 | 85 | "Version 2.1")) |
63 | 86 | '("lgpl-2.1" "GNU Lesser General Public License v2.1" "LGPL-2.1")) |
64 | | - ((eask--string-match-all '("Permission is hereby granted, free of charge, to any person obtaining a copy")) |
| 87 | + ((eask--string-match-all |
| 88 | + '("Permission is hereby granted, free of charge, to any person")) |
65 | 89 | '("mit" "MIT License" "MIT")) |
66 | | - ((eask--string-match-all '("Mozilla Public License Version 2.0" |
67 | | - "http://mozilla.org/MPL/2.0/")) |
| 90 | + ((eask--string-match-all |
| 91 | + '("http://mozilla.org/MPL/2.0/")) |
68 | 92 | '("mpl-2.0" "Mozilla Public License 2.0" "MPL-2.0")) |
69 | | - ((eask--string-match-all '("This is free and unencumbered software released into the public domain" |
70 | | - "https://unlicense.org")) |
| 93 | + ((eask--string-match-all |
| 94 | + '("This is free and unencumbered software released into")) |
71 | 95 | '("unlicense" "The Unlicense" "Unlicense")) |
72 | 96 | (t |
73 | 97 | '("unknown" "Unknown license" "unknown"))))) |
|
0 commit comments