sc-virt/src/projects/compiler-rt/lib/profile/InstrProfilingFile.c
static int parseFilenamePattern(const char *FilenamePat) {
  int NumPids = 0, NumHosts = 0, I;
  char *PidChars = &lprofCurFilename.PidChars[0];
  char *Hostname = &lprofCurFilename.Hostname[0];
  int MergingEnabled = 0;

  lprofCurFilename.FilenamePat = FilenamePat;
  /* Check the filename for "%p", which indicates a pid-substitution. */
  for (I = 0; FilenamePat[I]; ++I)
    if (FilenamePat[I] == '%') {
      if (FilenamePat[++I] == 'p') {
        if (!NumPids++) {
          if (snprintf(PidChars, MAX_PID_SIZE, "%d", getpid()) <= 0) {
            PROF_WARN(
                "Unable to parse filename pattern %s. Using the default name.",
                FilenamePat);
            return -1;
          }
        }
      } else if (FilenamePat[I] == 'h') {
        if (!NumHosts++)
          if (COMPILER_RT_GETHOSTNAME(Hostname, COMPILER_RT_MAX_HOSTLEN)) {
            PROF_WARN(
                "Unable to parse filename pattern %s. Using the default name.",
                FilenamePat);
            return -1;
          }
      } else if (containsMergeSpecifier(FilenamePat, I)) {
        if (MergingEnabled) {
          PROF_WARN("%%m specifier can only be specified once in %s.\n",
                    FilenamePat);
          return -1;
        }
        MergingEnabled = 1;
        if (FilenamePat[I] == 'm')
          lprofCurFilename.MergePoolSize = 1;
        else {
          lprofCurFilename.MergePoolSize = FilenamePat[I] - '0';
          I++; /* advance to 'm' */
        }
      }
    }

  lprofCurFilename.NumPids = NumPids;
  lprofCurFilename.NumHosts = NumHosts;
  return 0;
}
/* Parses the pattern string \p FilenamePat and stores the result to
 * lprofcurFilename structure. */
Parses the pattern string \p FilenamePat and stores the result to
lprofcurFilename structure.
Parses the pattern string \ p FilenamePat and stores the result to lprofcurFilename structure .
static int parseFilenamePattern(const char *FilenamePat) {
  int NumPids = 0, NumHosts = 0, I;
  char *PidChars = &lprofCurFilename.PidChars[0];
  char *Hostname = &lprofCurFilename.Hostname[0];
  int MergingEnabled = 0;
  lprofCurFilename.FilenamePat = FilenamePat;
  for (I = 0; FilenamePat[I]; ++I)
    if (FilenamePat[I] == '%') {
      if (FilenamePat[++I] == 'p') {
        if (!NumPids++) {
          if (snprintf(PidChars, MAX_PID_SIZE, "%d", getpid()) <= 0) {
            PROF_WARN(
                "Unable to parse filename pattern %s. Using the default name.",
                FilenamePat);
            return -1;
          }
        }
      } else if (FilenamePat[I] == 'h') {
        if (!NumHosts++)
          if (COMPILER_RT_GETHOSTNAME(Hostname, COMPILER_RT_MAX_HOSTLEN)) {
            PROF_WARN(
                "Unable to parse filename pattern %s. Using the default name.",
                FilenamePat);
            return -1;
          }
      } else if (containsMergeSpecifier(FilenamePat, I)) {
        if (MergingEnabled) {
          PROF_WARN("%%m specifier can only be specified once in %s.\n",
                    FilenamePat);
          return -1;
        }
        MergingEnabled = 1;
        if (FilenamePat[I] == 'm')
          lprofCurFilename.MergePoolSize = 1;
        else {
          lprofCurFilename.MergePoolSize = FilenamePat[I] - '0';
          I++; 
        }
      }
    }
  lprofCurFilename.NumPids = NumPids;
  lprofCurFilename.NumHosts = NumHosts;
  return 0;
}
static int parseFilenamePattern ( const char * FilenamePat ) { int NumPids = 0 , NumHosts = 0 , I ; char * PidChars = & lprofCurFilename . PidChars [ 0 ] ; char * Hostname = & lprofCurFilename . Hostname [ 0 ] ; int MergingEnabled = 0 ; lprofCurFilename . FilenamePat = FilenamePat ; for ( I = 0 ; FilenamePat [ I ] ; ++ I ) if ( FilenamePat [ I ] == ' ' ) { if ( FilenamePat [ ++ I ] == ' ' ) { if ( ! NumPids ++ ) { if ( snprintf ( PidChars , MAX_PID_SIZE , " " , getpid ( ) ) <= 0 ) { PROF_WARN ( " " , FilenamePat ) ; return -1 ; } } } else if ( FilenamePat [ I ] == ' ' ) { if ( ! NumHosts ++ ) if ( COMPILER_RT_GETHOSTNAME ( Hostname , COMPILER_RT_MAX_HOSTLEN ) ) { PROF_WARN ( " " , FilenamePat ) ; return -1 ; } } else if ( containsMergeSpecifier ( FilenamePat , I ) ) { if ( MergingEnabled ) { PROF_WARN ( " \n " , FilenamePat ) ; return -1 ; } MergingEnabled = 1 ; if ( FilenamePat [ I ] == ' ' ) lprofCurFilename . MergePoolSize = 1 ; else { lprofCurFilename . MergePoolSize = FilenamePat [ I ] - ' ' ; I ++ ; } } } lprofCurFilename . NumPids = NumPids ; lprofCurFilename . NumHosts = NumHosts ; return 0 ; }
Parses the pattern string \p FilenamePat and stores the result to
 lprofcurFilename structure.
Parses the pattern string \ p FilenamePat and stores the result to lprofcurFilename structure .
/* Check the filename for "%p", which indicates a pid-substitution. */ /* advance to 'm' */