@@ -152,21 +152,8 @@ struct Platform <: AbstractPlatform
152
152
value = normver (value)
153
153
end
154
154
155
- # I know we said only alphanumeric and dots, but let's be generous so that we can expand
156
- # our support in the future while remaining as backwards-compatible as possible. The
157
- # only characters that are absolutely disallowed right now are `-`, `+`, ` ` and things
158
- # that are illegal in filenames:
159
- nonos = raw """ +- /<>:"'\| ?*"""
160
- if any (occursin (nono, tag) for nono in nonos)
161
- throw (ArgumentError (" Invalid character in tag name \" $(tag) \" !" ))
162
- end
163
-
164
- # Normalize and reject nonos
165
- value = lowercase (string (value))
166
- if any (occursin (nono, value) for nono in nonos)
167
- throw (ArgumentError (" Invalid character in tag value \" $(value) \" !" ))
168
- end
169
- tags[tag] = value
155
+ # Use `add_tag!()` to add the tag to our collection of tags
156
+ add_tag! (tags, tag, string (value):: String )
170
157
end
171
158
172
159
# Auto-map call_abi and libc where necessary:
@@ -197,13 +184,36 @@ struct Platform <: AbstractPlatform
197
184
end
198
185
end
199
186
187
+ # Simple tag insertion that performs a little bit of validation
188
+ function add_tag! (tags:: Dict{String,String} , tag:: String , value:: String )
189
+ # I know we said only alphanumeric and dots, but let's be generous so that we can expand
190
+ # our support in the future while remaining as backwards-compatible as possible. The
191
+ # only characters that are absolutely disallowed right now are `-`, `+`, ` ` and things
192
+ # that are illegal in filenames:
193
+ nonos = raw """ +- /<>:"'\| ?*"""
194
+ if any (occursin (nono, tag) for nono in nonos)
195
+ throw (ArgumentError (" Invalid character in tag name \" $(tag) \" !" ))
196
+ end
197
+
198
+ # Normalize and reject nonos
199
+ value = lowercase (value)
200
+ if any (occursin (nono, value) for nono in nonos)
201
+ throw (ArgumentError (" Invalid character in tag value \" $(value) \" !" ))
202
+ end
203
+ tags[tag] = value
204
+ return value
205
+ end
206
+
200
207
# Other `Platform` types can override this (I'm looking at you, `AnyPlatform`)
201
208
tags (p:: Platform ) = p. tags
202
209
203
210
# Make it act more like a dict
204
211
Base. getindex (p:: AbstractPlatform , k:: String ) = getindex (tags (p), k)
205
212
Base. haskey (p:: AbstractPlatform , k:: String ) = haskey (tags (p), k)
206
- Base. setindex! (p:: AbstractPlatform , v:: String , k:: String ) = (setindex! (tags (p), v, k); p)
213
+ function Base. setindex! (p:: AbstractPlatform , v:: String , k:: String )
214
+ add_tag! (tags (p), k, v)
215
+ return p
216
+ end
207
217
208
218
# Allow us to easily serialize Platform objects
209
219
function Base. repr (p:: Platform ; context= nothing )
0 commit comments