@@ -84,21 +84,8 @@ struct Platform <: AbstractPlatform
84
84
value = normver (value)
85
85
end
86
86
87
- # I know we said only alphanumeric and dots, but let's be generous so that we can expand
88
- # our support in the future while remaining as backwards-compatible as possible. The
89
- # only characters that are absolutely disallowed right now are `-`, `+`, ` ` and things
90
- # that are illegal in filenames:
91
- nonos = raw """ +- /<>:"'\| ?*"""
92
- if any (occursin (nono, tag) for nono in nonos)
93
- throw (ArgumentError (" Invalid character in tag name \" $(tag) \" !" ))
94
- end
95
-
96
- # Normalize and reject nonos
97
- value = lowercase (string (value))
98
- if any (occursin (nono, value) for nono in nonos)
99
- throw (ArgumentError (" Invalid character in tag value \" $(value) \" !" ))
100
- end
101
- tags[tag] = value
87
+ # Use `add_tag!()` to add the tag to our collection of tags
88
+ add_tag! (tags, tag, string (value):: String )
102
89
end
103
90
104
91
# Auto-map call_abi and libc where necessary:
@@ -129,13 +116,36 @@ struct Platform <: AbstractPlatform
129
116
end
130
117
end
131
118
119
+ # Simple tag insertion that performs a little bit of validation
120
+ function add_tag! (tags:: Dict{String,String} , tag:: String , value:: String )
121
+ # I know we said only alphanumeric and dots, but let's be generous so that we can expand
122
+ # our support in the future while remaining as backwards-compatible as possible. The
123
+ # only characters that are absolutely disallowed right now are `-`, `+`, ` ` and things
124
+ # that are illegal in filenames:
125
+ nonos = raw """ +- /<>:"'\| ?*"""
126
+ if any (occursin (nono, tag) for nono in nonos)
127
+ throw (ArgumentError (" Invalid character in tag name \" $(tag) \" !" ))
128
+ end
129
+
130
+ # Normalize and reject nonos
131
+ value = lowercase (value)
132
+ if any (occursin (nono, value) for nono in nonos)
133
+ throw (ArgumentError (" Invalid character in tag value \" $(value) \" !" ))
134
+ end
135
+ tags[tag] = value
136
+ return value
137
+ end
138
+
132
139
# Other `Platform` types can override this (I'm looking at you, `AnyPlatform`)
133
140
tags (p:: Platform ) = p. tags
134
141
135
142
# Make it act more like a dict
136
143
Base. getindex (p:: AbstractPlatform , k:: String ) = getindex (tags (p), k)
137
144
Base. haskey (p:: AbstractPlatform , k:: String ) = haskey (tags (p), k)
138
- Base. setindex! (p:: AbstractPlatform , v:: String , k:: String ) = (setindex! (tags (p), v, k); p)
145
+ function Base. setindex! (p:: AbstractPlatform , v:: String , k:: String )
146
+ add_tag! (tags (p), k, v)
147
+ return p
148
+ end
139
149
140
150
# Allow us to easily serialize Platform objects
141
151
function Base. repr (p:: Platform ; context= nothing )
0 commit comments