示例#1
0
Bits
getflag(char *s)
{
	Bits flag;
	int c, f;
	char *fmt;

	fmt = fmtbuf;
	flag = zbits;
	nstar = 0;
	while(c = *s++) {
		*fmt++ = c;
		f = flagbits[c];
		switch(f) {
		case Fnone:
			argflag(c, Fverb);
			f = flagbits[c];
			break;
		case Fstar:
			nstar++;
		case Fignor:
			continue;
		case Fl:
			if(bset(flag, Fl))
				flag = bor(flag, blsh(Fvl));
		}
		flag = bor(flag, blsh(f));
		if(f >= Fverb)
			break;
	}
	*fmt = 0;
	return flag;
}
示例#2
0
文件: dpchk.c 项目: Ahmah2009/golang
Bits
getflag(char *s)
{
	Bits flag;
	int f;
	Fmt fmt;
	Rune c;

	flag = zbits;
	nstar = 0;
	fmtstrinit(&fmt);
	for(;;) {
		s += chartorune(&c, s);
		if(c == 0 || c >= nelem(flagbits))
			break;
		fmtrune(&fmt, c);
		f = flagbits[c];
		switch(f) {
		case Fnone:
			argflag(c, Fverb);
			f = flagbits[c];
			break;
		case Fstar:
			nstar++;
		case Fignor:
			continue;
		case Fl:
			if(bset(flag, Fl))
				flag = bor(flag, blsh(Fvl));
		}
		flag = bor(flag, blsh(f));
		if(f >= Fverb)
			break;
	}
	free(lastfmt);
	lastfmt = fmtstrflush(&fmt);
	return flag;
}
示例#3
0
文件: dpchk.c 项目: 8l/NxM
Bits
getflag(char *s)
{
	Bits flag;
	int f;
	char *fmt;
	Rune c;

	fmt = fmtbuf;
	flag = zbits;
	nstar = 0;
	for(;;) {
		s += chartorune(&c, s);
		fmt += runetochar(fmt, &c);
		if(c == 0 || c >= nelem(flagbits))
			break;
		f = flagbits[c];
		switch(f) {
		case Fnone:
			argflag(c, Fverb);
			f = flagbits[c];
			break;
		case Fstar:
			nstar++;
		case Fignor:
			continue;
		case Fl:
			if(bset(flag, Fl))
				flag = bor(flag, blsh(Fvl));
		}
		flag = bor(flag, blsh(f));
		if(f >= Fverb)
			break;
	}
	*fmt = 0;
	return flag;
}
示例#4
0
文件: fold3.C 项目: ChenBoTang/gcc
int main() {
  static_assert(add() == int(), "");
  static_assert(mul() == 1, "");
  static_assert(bor() == int(), "");
  static_assert(band() == -1, "");
  static_assert(land() == true, "");
  static_assert(lor() == false, "");
  comma(); // No value to theck

  // These are all errors, but the error is emitted at the point
  // of instantiation (line 10).
  sub();			// { dg-message "required from here" }
  div();			// { dg-message "required from here" }
  mod();			// { dg-message "required from here" }
  lsh();			// { dg-message "required from here" }
  rsh();			// { dg-message "required from here" }
  assign();			// { dg-message "required from here" }
  addi();			// { dg-message "required from here" }
  subi();			// { dg-message "required from here" }
  muli();			// { dg-message "required from here" }
  divi();			// { dg-message "required from here" }
  modi();			// { dg-message "required from here" }
  bxor();			// { dg-message "required from here" }
  bxori();			// { dg-message "required from here" }
  bori();			// { dg-message "required from here" }
  bandi();			// { dg-message "required from here" }
  lshi();			// { dg-message "required from here" }
  rshi();			// { dg-message "required from here" }
  eq();				// { dg-message "required from here" }
  ne();				// { dg-message "required from here" }
  lt();				// { dg-message "required from here" }
  gt();				// { dg-message "required from here" }
  le();				// { dg-message "required from here" }
  ge();				// { dg-message "required from here" }
  dot_star();			// { dg-message "required from here" }
  arrow_star();			// { dg-message "required from here" }
}
示例#5
0
文件: xor4.cpp 项目: polux/snippets
    return e1->eval(a, b, c, d) ^ e2->eval(a, b, c, d);
  }
};

Expr* const ba() { return new A(); }
Expr* const bb() { return new B(); }
Expr* const bc() { return new C(); }
Expr* const bd() { return new D(); }
Expr* bnot(Expr* const e) { return new Not(e); }
Expr* band(Expr* const e1, Expr* const e2) { return new And(e1, e2); }
Expr* bor(Expr* const e1, Expr* const e2) { return new Or(e1, e2); }
Expr* bxor(Expr* const e1, Expr* const e2) { return new Xor(e1, e2); }

Expr* const knownXor4 =
  band(
      bor(bxor(ba(), bb()), bxor(bc(), bd())),
      bxor(bor(ba(), bb()), bor(bc(), bd())));

bool isXor4(Expr* const e) {
  return !e->eval(true, true, true, true)
      && !e->eval(false, true, true, true)
      && !e->eval(true, false, true, true)
      && !e->eval(false, false, true, true)
      && !e->eval(true, true, false, true)
      && !e->eval(false, true, false, true)
      && !e->eval(true, false, false, true)
      && e->eval(false, false, false, true)
      && !e->eval(true, true, true, false)
      && !e->eval(false, true, true, false)
      && !e->eval(true, false, true, false)
      && e->eval(false, false, true, false)