/* ------------------------------------------------------------------------- * GUIE3Collector::MyWrapper-methods * ----------------------------------------------------------------------- */ GUIE3Collector::MyWrapper::MyWrapper(GUIE3Collector& detector) : GUIDetectorWrapper("E3 detector", detector.getID()), myDetector(detector) { const CrossSectionVector& entries = detector.getEntries(); const CrossSectionVector& exits = detector.getExits(); CrossSectionVectorConstIt i; for (i = entries.begin(); i != entries.end(); ++i) { SingleCrossingDefinition def = buildDefinition(*i); myBoundary.add(def.myFGPosition); myEntryDefinitions.push_back(def); } for (i = exits.begin(); i != exits.end(); ++i) { SingleCrossingDefinition def = buildDefinition(*i); myBoundary.add(def.myFGPosition); myExitDefinitions.push_back(def); } }
/* * processFile */ static void processFile(char const * pzFile) { char* pzText = loadFile(pzFile); /* full text */ char* pzScan; /* Scanning Pointer */ char* pzDef; /* Def block start */ char* pzNext; /* start next search */ char* pzDta; /* data value */ int lineNo = 1; char* pzOut; regmatch_t matches[MAX_SUBMATCH+1]; if (pzText == NULL) fserr_die("read opening %s\n", pzFile); processEmbeddedOptions(pzText); pzNext = pzText; while (pzScan = pzNext, regexec(&define_re, pzScan, COUNT(matches), matches, 0) == 0) { static char const zNoEnd[] = "Error: definition in %s at line %d has no end\n"; static char const zNoSubexp[] = "Warning: entry type not found on line %d in %s:\n\t%s\n"; int linesInDef = 0; /* * Make sure there is a subexpression match!! */ if (matches[1].rm_so == -1) { char* pz = NULL; char ch = NUL; pzDef = pzScan + matches[0].rm_so; if (strlen(pzDef) > 30) { pz = pzDef + 30; ch = *pz; *pz = NUL; } fprintf(stderr, zNoSubexp, lineNo, pzFile, pzDef); if (pz != NULL) *pz = ch; continue; } pzDef = pzScan + matches[0].rm_so + sizeof("/*=") - 1; pzNext = strstr(pzDef, "=*/"); if (pzNext == NULL) die(zNoEnd, pzFile, lineNo); *pzNext = NUL; pzNext += 3; /* * Count the number of lines skipped to the start of the def. */ for (;;) { pzScan = strchr(pzScan, '\n'); if (pzScan++ == NULL) break; if (pzScan >= pzDef) break; lineNo++; } pzOut = pzDta = (char*)malloc(2 * strlen(pzDef) + 8000); /* * Count the number of lines in the definition itself. * It will find and stop on the "=* /\n" line. */ pzScan = pzDef; for (;;) { pzScan = strchr(pzScan, '\n'); if (pzScan++ == NULL) break; linesInDef++; } /* * OK. We are done figuring out where the boundaries of the * definition are and where we will resume our processing. */ buildDefinition(pzDef, pzFile, lineNo, pzOut); pzDta = (char*)realloc((void*)pzDta, strlen(pzDta) + 1); lineNo += linesInDef; if (++blkUseCt > blkAllocCt) { blkAllocCt += 32; papzBlocks = (char**)realloc((void*)papzBlocks, blkAllocCt * sizeof(char*)); if (papzBlocks == (char**)NULL) die("Realloc error for %d pointers\n", (int)blkAllocCt); } papzBlocks[ blkUseCt-1 ] = pzDta; } free((void*)pzText); }