|
51 | 51 | (s/ends-with? id "-only") :only
|
52 | 52 | (or (s/ends-with? id "+") (s/ends-with? id "-or-later")) :or-later)))
|
53 | 53 |
|
| 54 | +;####TODO: REMOVE THIS IF STANDARD REGEX MATCHING ISN'T NEEDED |
| 55 | +(comment |
54 | 56 | (defn- gnu-id-comparator
|
55 | 57 | "Compares GNU family ids, by putting the `-only` variants first. This order
|
56 | 58 | is important as there are certain license name values that both the -only and
|
|
68 | 70 | [:or-later :only] 1
|
69 | 71 | [:or-later :or-later] 0) ; This can occur due to +/-or-later being equivalent
|
70 | 72 | (compare id1 id2))))
|
| 73 | +) |
71 | 74 |
|
72 | 75 | ; All GNU family license ids, including deprecated ones - we report that we match all GPL ids so that they're removed from lice-comb.impl.substitutions.others matching
|
73 | 76 | (def ids-d (delay (set (filter #(or (lcisu/agpl-license? %) (lcisu/lgpl-license? %) (lcisu/gpl-license? %)) (map :id @lcis/full-license-list-d)))))
|
74 | 77 |
|
| 78 | +;####TODO: REMOVE THIS IF STANDARD REGEX MATCHING ISN'T NEEDED |
75 | 79 | ; Undeprecated GNU family license ids (these ones are used for matching)
|
76 |
| -(def ^:private agpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/agpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
77 |
| -(def ^:private lgpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/lgpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
78 |
| -(def ^:private gpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/gpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
| 80 | +;(def ^:private agpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/agpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
| 81 | +;(def ^:private lgpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/lgpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
| 82 | +;(def ^:private gpl-license-ids-d (delay (sort gnu-id-comparator (map :id (filter #(and (lcisu/gpl-license? (:id %)) (not (:deprecated? %))) @lcis/full-license-list-d))))) |
79 | 83 |
|
80 | 84 | (defn- match->ei
|
81 | 85 | "Construct an expression-info map from `m`, a map returned from a rencg regex
|
|
118 | 122 | (def ^:private gnu-words [#"\(?The" #"GNU" #"GPL" #"Genere?al" #"Pub?lic" #"Licen[cs]ed?(?:[\s\-–—]+Under)?" #"Open[\s\-–—]+Source" #"FOSS" #"OSS"])
|
119 | 123 |
|
120 | 124 | ; AGPL regexes
|
121 |
| -(def ^:private fre-agpl-words (re/grp (apply re/alt (concat gnu-words ["AGPL" "Affero"])))) |
| 125 | +(def ^:private fre-agpl-words (re/grp (apply re/alt (concat gnu-words [#"\(?AGPL[\s\-–—v\d\.]*\)?" "Affero"])))) |
122 | 126 | (def re-agpl (re/join #"(?iuUx)(?<!\w)" ; Only public for ease of testing
|
123 | 127 | "\n\n#### Leading word salad ####\n"
|
124 | 128 | (re/zom-grp fre-agpl-words lcir/fre-mws)
|
125 | 129 | "\n\n#### Matching words ####\n"
|
126 | 130 | (re/ncg "agpl" #"(?:A\s?GPL|Affero)")
|
127 |
| - "\n\n#### Trailing word salad ####\n" |
| 131 | + "\n\n#### Pre-version word salad ####\n" |
128 | 132 | (re/zom-grp lcir/fre-mws fre-agpl-words)
|
129 | 133 | "\n\n#### Version and version qualifier ####\n"
|
130 | 134 | (re/opt-grp lcir/fre-ows lcir/fre-version)
|
131 | 135 | (re/opt-grp lcir/fre-ows lcir/fre-only-or-later)
|
| 136 | + "\n\n#### Post-version word salad ####\n" |
| 137 | + (re/zom-grp lcir/fre-mws fre-agpl-words) |
132 | 138 | "\n\n#### Date ####\n"
|
133 | 139 | (re/opt-grp lcir/fre-mws lcir/fre-date)
|
134 | 140 | "\n\n#### Coda ####\n"
|
135 | 141 | #"(?!\w)"))
|
136 | 142 |
|
137 | 143 | ; LGPL regexes
|
138 | 144 | (def ^:private fre-lesser-or-library (re/or-grp "Lesser" "Library" (re/join lcir/fre-mws "or" lcir/fre-mws)))
|
139 |
| -(def ^:private fre-lgpl-words (re/grp (apply re/alt (concat gnu-words ["LGPL" fre-lesser-or-library])))) |
| 145 | +(def ^:private fre-lgpl-words (re/grp (apply re/alt (concat gnu-words [#"\(?LGPL[\s\-–—v\d\.]*\)?" fre-lesser-or-library])))) |
140 | 146 | (def re-lgpl (re/join #"(?iuUx)(?<!\w)" ; Only public for ease of testing
|
141 | 147 | "\n\n#### Leading word salad ####\n"
|
142 | 148 | (re/zom-grp fre-lgpl-words lcir/fre-mws)
|
|
145 | 151 | (re/alt #"L\s*GPL"
|
146 | 152 | (re/join #"(?:GNU|GPL)" lcir/fre-mws fre-lesser-or-library)
|
147 | 153 | (re/join fre-lesser-or-library lcir/fre-mws #"(?:GNU|GPL|General)")))
|
148 |
| - "\n\n#### Trailing word salad ####\n" |
| 154 | + "\n\n#### Pre-version word salad ####\n" |
149 | 155 | (re/zom-grp lcir/fre-mws fre-lgpl-words)
|
150 | 156 | "\n\n#### Version and version qualifier ####\n"
|
151 | 157 | (re/opt-grp lcir/fre-ows lcir/fre-version)
|
152 | 158 | (re/opt-grp lcir/fre-ows lcir/fre-only-or-later)
|
| 159 | + "\n\n#### Post-version word salad ####\n" |
| 160 | + (re/zom-grp lcir/fre-mws fre-lgpl-words) |
153 | 161 | "\n\n#### Date ####\n"
|
154 | 162 | (re/opt-grp lcir/fre-mws lcir/fre-date)
|
155 | 163 | "\n\n#### Coda ####\n"
|
156 | 164 | #"(?!\w)"))
|
157 | 165 |
|
158 | 166 | ; GPL regexes
|
159 |
| -(def ^:private fre-gpl-words (re/grp (apply re/alt gnu-words))) ; GPL has no extra words |
| 167 | +(def ^:private fre-gpl-words (re/grp (apply re/alt (concat gnu-words [#"\(?GPL[\s\-–—v\d\.]*\)?"])))) |
160 | 168 | (def re-gpl (re/join #"(?iuUx)(?<!\w)" ; Only public for ease of testing
|
161 | 169 | "\n\n#### Leading word salad ####\n"
|
162 | 170 | (re/zom-grp fre-gpl-words lcir/fre-mws)
|
163 | 171 | "\n\n#### Matching words ####\n"
|
164 | 172 | (re/ncg "gpl" #"(?:GNU|GPL|(?:Genere?al(?:[\s\-–—]+Pub?lic)?(?:[\s\-–—]+Licen[cs]e)?))")
|
165 |
| - "\n\n#### Trailing word salad ####\n" |
| 173 | + "\n\n#### Pre-version word salad ####\n" |
166 | 174 | (re/zom-grp lcir/fre-mws fre-gpl-words)
|
167 | 175 | "\n\n#### Version and version qualifier ####\n"
|
168 | 176 | (re/opt-grp lcir/fre-ows lcir/fre-version)
|
169 | 177 | (re/opt-grp lcir/fre-ows lcir/fre-only-or-later)
|
| 178 | + "\n\n#### Post-version word salad ####\n" |
| 179 | + (re/zom-grp lcir/fre-mws fre-gpl-words) |
170 | 180 | "\n\n#### Date ####\n"
|
171 | 181 | (re/opt-grp lcir/fre-mws lcir/fre-date)
|
172 | 182 | "\n\n#### Coda ####\n"
|
|
0 commit comments