MCPcopy Create free account
hub / github.com/Kitware/CMake / compile

Method compile

Source/kwsys/RegularExpression.cxx:338–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336// for later pattern matching.
337
338bool RegularExpression::compile(char const* exp)
339{
340 char const* scan;
341 char const* longest;
342 int flags;
343
344 if (!exp) {
345 // RAISE Error, SYM(RegularExpression), SYM(No_Expr),
346 printf("RegularExpression::compile(): No expression supplied.\n");
347 return false;
348 }
349
350 // First pass: determine size, legality.
351 RegExpCompile comp;
352 comp.regparse = exp;
353 comp.regnpar = 1;
354 comp.regsize = 0L;
355 comp.regcode = regdummyptr;
356 comp.regc(static_cast<char>(MAGIC));
357 if (!comp.reg(0, &flags)) {
358 printf("RegularExpression::compile(): Error in compile.\n");
359 return false;
360 }
361 this->regmatch.clear();
362
363 // Small enough for pointer-storage convention?
364 if (comp.regsize >= 65535L) {
365 // RAISE Error, SYM(RegularExpression), SYM(Expr_Too_Big),
366 printf("RegularExpression::compile(): Expression too big.\n");
367 return false;
368 }
369
370 // Allocate space.
371 // #ifndef _WIN32
372 delete[] this->program;
373 // #endif
374 this->program = new char[comp.regsize];
375 this->progsize = static_cast<int>(comp.regsize);
376 this->regnpar = comp.regnpar;
377
378 if (!this->program) {
379 // RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
380 printf("RegularExpression::compile(): Out of memory.\n");
381 return false;
382 }
383
384#ifdef __clang_analyzer__ /* Convince it that the program is initialized. */
385 memset(this->program, 0, comp.regsize);
386#endif
387
388 // Second pass: emit code.
389 comp.regparse = exp;
390 comp.regnpar = 1;
391 comp.regcode = this->program;
392 comp.regc(static_cast<char>(MAGIC));
393 comp.reg(0, &flags);
394
395 // Dig out information for optimizations.

Callers 15

LLVMFuzzerTestOneInputFunction · 0.80
cmake.pyFile · 0.80
__init__Method · 0.80
CMakeReferenceRoleClass · 0.80
CMakeXRefRoleClass · 0.80
update_versions.pyFile · 0.80
HandleLevel2Method · 0.80
cmMakefileMethod · 0.80
EvaluateMethod · 0.80
MocSettingsTMethod · 0.80
UicSettingsTMethod · 0.80
SetLinkExtensionInfoMethod · 0.80

Calls 5

regnextFunction · 0.85
regcMethod · 0.80
regMethod · 0.80
strlenFunction · 0.50
clearMethod · 0.45

Tested by 15

IdentifyParserMethod · 0.64
StatusParserMethod · 0.64
cmCTestTestHandlerMethod · 0.64
GetListOfTestsMethod · 0.64
LoadScrapeRulesMethod · 0.64
IdentifyParserMethod · 0.64
ChangesParserMethod · 0.64
UserParserMethod · 0.64
DiffParserMethod · 0.64
DescribeParserMethod · 0.64
InfoParserMethod · 0.64
UpdateParserMethod · 0.64