MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / match

Method match

lib/compiler-arguments.ts:156–198  ·  view source on GitHub ↗
(documentedOption: string, givenOption: string)

Source from the content-addressed store, hash-verified

154 }
155
156 match(documentedOption: string, givenOption: string): string | boolean {
157 if (
158 documentedOption.includes('<number>') ||
159 documentedOption.includes('<n>') ||
160 documentedOption.includes('=val')
161 ) {
162 const numre = /\d*$/i;
163 if (documentedOption.indexOf(givenOption.replace(numre, '')) === 0) {
164 return documentedOption;
165 }
166 }
167
168 if (documentedOption.includes('=')) {
169 const idx = documentedOption.indexOf('=');
170 if (givenOption.indexOf('=') === idx) {
171 if (documentedOption.substring(0, idx) === givenOption.substring(0, idx)) {
172 return documentedOption;
173 }
174 }
175 }
176
177 if (documentedOption.includes(':')) {
178 const idx = documentedOption.indexOf(':');
179 if (givenOption.indexOf(':') === idx) {
180 if (documentedOption.substring(0, idx) === givenOption.substring(0, idx)) {
181 return documentedOption;
182 }
183 }
184 }
185
186 if (documentedOption.includes('[')) {
187 const idx = documentedOption.indexOf('[') - 1;
188 if (documentedOption.indexOf(givenOption.substring(0, idx)) === 0) {
189 return documentedOption;
190 }
191 }
192
193 if (documentedOption.indexOf(givenOption) === 0) {
194 return documentedOption;
195 }
196
197 return false;
198 }
199
200 addOptionToStatistics(option: string, timesUsed: number | undefined) {
201 if (!timesUsed) timesUsed = 1;

Calls

no outgoing calls

Tested by

no test coverage detected