Example #1
0
static void
procfile(char *fnam)
{
  FILE *fp = 0;
  char str[120], lasttag[3] = "  ";
  int firstsample = 1;
  printf("processing %s\n", fnam);
  fp = fopen(fnam, "r");
  assert(fp != 0);
  while ((0 != fgets(str, sizeof(str), fp)) && (0 != str[0])) {
    assert(strlen(str) > 2);
    assert(str[2] == ' ');
    str[2] = 0;
    if (!strcmp(lasttag, "DA") && strcmp(str, "DA")) {
      sb1();  /* Over, transfer temporary content into permanent one */
    }
    if (!strcmp(str, "NS")) {
      if (!firstsample) ns1();
      firstsample = 0;
      assert(10 == sscanf(str+3, "%d %d/%d/%d %d:%d:%d %d %d (%d)",
			&nsamp, &yyyy, &mm, &dd, &hh, &nn, &ss, 
			&nevsc, &llock, &nevhf));
      ns0();
    }
    else if (!strcmp(str, "RC")) {
      assert(4 == sscanf(str+3, "%d %s %d %f",
		       &partition, rcstate, &rcevents, &trigrate));
      rc();   /* Debug printout only */
    }
    else if (!strcmp(str, "SB")) {
      char plus[2];
      int nscan;
      nscan = sscanf(str+3, "%s %d %s %s %d %d%s",
		     cratename, &slot, boardname, bufname, &nread, &nspy, plus);
      assert(nscan == 6 || (nscan == 7 && !strcmp(plus, "+")));
      wrap = (nscan == 7);
      ndata = 0;
      if (data) free(data);
      data = (void *) malloc(nread*sizeof(data[0]));
      sb0();   /* Debug printout only */
    }
    else if (!strcmp(str, "DA")) {
      int nscan, i;
      uint4 d[10];
      nscan = sscanf(str+3, "%x %x %x %x %x %x %x %x %x %x",
		     d+0, d+1, d+2, d+3, d+4, d+5, d+6, d+7, d+8, d+9);
      assert(data != 0 && ndata+nscan <= nread);
      for (i = 0; i < nscan; i++)
	data[ndata++] = d[i];
    }
    else {
      assert(0); /* unrecognized tag */
    }
    strcpy(lasttag, str);
  }
  if (fp) fclose(fp);
  if (!strcmp(lasttag, "DA"))
    sb1();
  if (!firstsample) ns1();
}
Example #2
0
/**
 * Case insensitive std::string comparison
 */
bool stdStringIsEqualCI(const std::string &s1, const std::string &s2)
{
	std::string ns1(s1);
	std::string ns2(s2);
	std::transform(ns1.begin(), ns1.end(), ns1.begin(), tolower);
	std::transform(ns2.begin(), ns2.end(), ns2.begin(), tolower);
	return ns1 == ns2;
}
int main()
{
    {
    std::chrono::nanoseconds ns1(15);
    std::chrono::nanoseconds ns2(5);
    assert(ns1 / ns2 == 3);
    }
    {
    std::chrono::microseconds us1(15);
    std::chrono::nanoseconds ns2(5);
    assert(us1 / ns2 == 3000);
    }
    {
    std::chrono::duration<int, std::ratio<2, 3> > s1(30);
    std::chrono::duration<int, std::ratio<3, 5> > s2(5);
    assert(s1 / s2 == 6);
    }
    {
    std::chrono::duration<int, std::ratio<2, 3> > s1(30);
    std::chrono::duration<double, std::ratio<3, 5> > s2(5);
    assert(s1 / s2 == 20./3);
    }
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
    {
    constexpr std::chrono::nanoseconds ns1(15);
    constexpr std::chrono::nanoseconds ns2(5);
    static_assert(ns1 / ns2 == 3, "");
    }
    {
    constexpr std::chrono::microseconds us1(15);
    constexpr std::chrono::nanoseconds ns2(5);
    static_assert(us1 / ns2 == 3000, "");
    }
    {
    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
    static_assert(s1 / s2 == 6, "");
    }
    {
    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
    static_assert(s1 / s2 == 20./3, "");
    }
#endif
}