MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / expandPattern

Method expandPattern

src/utilities/ntrace/TraceConfiguration.cpp:270–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void TraceCfgReader::expandPattern(const ConfigFile::Parameter* el, PathName& valueToExpand)
271{
272 valueToExpand = el->value.ToPathName();
273
274 // strip quotes around value, if any
275 valueToExpand.alltrim(" '\"");
276
277 PathName::size_type pos = 0;
278 while (pos < valueToExpand.length())
279 {
280 string::char_type c = valueToExpand[pos];
281 if (c == '\\')
282 {
283 if (pos + 1 >= valueToExpand.length())
284 {
285 fatal_exception::raiseFmt(ERROR_PREFIX
286 "line %d, element \"%s\": pattern is invalid\n\t %s",
287 el->line, el->name.c_str(), el->value.c_str());
288 }
289
290 c = valueToExpand[pos + 1];
291 if (c == '\\')
292 {
293 // Kill one of the backslash signs and loop again
294 valueToExpand.erase(pos, 1);
295 pos++;
296 continue;
297 }
298
299 if (c >= '0' && c <= '9')
300 {
301 const MatchPos* subpattern = m_subpatterns + (c - '0');
302 // Replace value with piece of database name
303 valueToExpand.erase(pos, 2);
304 if (subpattern->end != -1 && subpattern->start != -1)
305 {
306 const off_t subpattern_len = subpattern->end - subpattern->start;
307 valueToExpand.insert(pos,
308 m_databaseName.substr(subpattern->start, subpattern_len).c_str(),
309 subpattern_len);
310 pos += subpattern_len;
311 }
312 continue;
313 }
314
315 fatal_exception::raiseFmt(ERROR_PREFIX
316 "line %d, element \"%s\": pattern is invalid\n\t %s",
317 el->line, el->name.c_str(), el->value.c_str());
318 }
319
320 pos++;
321 }
322}

Callers

nothing calls this directly

Calls 7

ToPathNameMethod · 0.80
alltrimMethod · 0.80
lengthMethod · 0.45
c_strMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected