コード例 #1
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static void set_map(const char *p)
{
  not_null(p);
  if (map != NULL) {
    fprintf(stderr, "-M cannot be used twice.\n");
    exit(1);
  }
  map = mstrdup(p);
}
コード例 #2
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static void set_target(const char *p)
{
  not_null(p);
  if (target != NULL) {
    fprintf(stderr, "-o cannot be used twice.\n");
    exit(1);
  }
  target = mstrdup(p);
}
コード例 #3
0
void WeakRefArray::oops_do(void do_oop(OopDesc**)) {
  if( not_null() ) {
    OopDesc** p = base();
    for( OopDesc** const max = p + length(); p < max; p++ ) {
      OopDesc* obj = *p;
      if (not_null_or_unused(obj)) {
        do_oop( p );
      }
    }
  }
}
コード例 #4
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static void set_cpu(const char *p)
{
  not_null(p);
  if (cpu != NULL) {
    fprintf(stderr, "-m cannot be used twice.\n");
    exit(1);
  }
  cpu = mstrdup(p);
  if (strcmp(cpu, "z80") && strcmp(cpu, "z180")) {
    fprintf(stderr,"fcc: only z80 and z180 targets currently handled.\n");
    exit(1);
  }
}
コード例 #5
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static struct arglist *arg_make(const char *p)
{
  struct arglist *x;

  not_null(p);  

  x = malloc(sizeof(struct arglist) + strlen(p) + 1);
  if (x == NULL) {
    fprintf(stderr, "Out of memory.\n");
    exit(1);
  }
  x->next = NULL;
  strcpy(x->p, p);
  return x;
}
コード例 #6
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static void set_platform(const char *p)
{
  char *n;
  not_null(p);
  if (*platform) {
    fprintf(stderr, "-t cannot be used twice.\n");
    exit(1);
  }
  n = malloc(strlen(p) + 2);
  if (n == NULL)
    oom();
  sprintf(n, "-%s", p);
  platform = n;
  if (strcmp(platform, "-zx128") == 0)
    progbase = 0x8000;
}
コード例 #7
0
ファイル: fcc.c プロジェクト: 8l/FUZIX
static void set_optimize(const char *p)
{
  not_null(p);
  if (opt != NULL) {
    fprintf(stderr, "fcc: -O cannot be used twice.\n");
    exit(1);
  }
  opt = mstrdup(p);
  if (*opt && sscanf(opt, "%d", &optcode) != 1) {
    fprintf(stderr, "fcc: -O requires a value\n");
    exit(1);
  }
  if (optcode > 4)
    optcode = 4;
  if (optcode < 0) {
    fprintf(stderr, "fcc: negative optimisation is silly.\n");
    exit(1);
  }
  if (*opt == 0)
    optcode = 1;
}
コード例 #8
0
ファイル: regex_algorithms.hpp プロジェクト: AlexS2172/IVRM
inline bool regex_search_impl
(
    state_type<BidiIter> &state
  , basic_regex<BidiIter> const &re
  , bool not_initial_null = false
)
{
    typedef core_access<BidiIter> access;
    typedef typename iterator_value<BidiIter>::type char_type;
    match_results<BidiIter> &what = *state.context_.results_ptr_;

    // an invlid regex matches nothing
    if(!access::invalid(re))
    {
        bool const partial_ok = state.flags_.match_partial_;
        save_restore<bool> not_null(state.flags_.match_not_null_, state.flags_.match_not_null_ || not_initial_null);
        state.flags_.match_prev_avail_ = state.flags_.match_prev_avail_ || !state.bos();

        regex_impl<BidiIter> const &impl = *access::get_regex_impl(re);
        BidiIter const begin = state.cur_, end = state.end_;
        BidiIter &sub0begin = state.sub_match(0).begin_;
        sub0begin = state.cur_;

        // If match_continuous is set, we only need to check for a match at the current position
        if(state.flags_.match_continuous_)
        {
            if(access::match(re, state))
            {
                access::set_prefix_suffix(what, begin, end);
                return true;
            }

            // handle partial matches
            else if(partial_ok && state.found_partial_match_)
            {
                state.set_partial_match();
                return true;
            }
        }

        // If we have a finder, use it to find where a potential match can start
        else if(impl.finder_)
        {
            finder<BidiIter> const &find = *impl.finder_;
            if(find(state))
            {
                if(state.cur_ != begin)
                {
                    not_null.restore();
                }

                do
                {
                    sub0begin = state.cur_;
                    if(access::match(re, state))
                    {
                        access::set_prefix_suffix(what, begin, end);
                        return true;
                    }

                    // handle partial matches
                    else if(partial_ok && state.found_partial_match_)
                    {
                        state.set_partial_match();
                        return true;
                    }

                    BOOST_ASSERT(state.cur_ == sub0begin);
                    not_null.restore();
                }
                while(state.cur_ != state.end_ && (++state.cur_, find(state)));
            }
        }

        // Otherwise, use brute force search at every position.
        else
        {
            for(;;)
            {
                if(access::match(re, state))
                {
                    access::set_prefix_suffix(what, begin, end);
                    return true;
                }

                // handle partial matches
                else if(partial_ok && state.found_partial_match_)
                {
                    state.set_partial_match();
                    return true;
                }

                else if(end == sub0begin)
                {
                    break;
                }

                BOOST_ASSERT(state.cur_ == sub0begin);
                state.cur_ = ++sub0begin;
                not_null.restore();
            }
        }
    }

    access::reset(what);
    return false;
}
コード例 #9
0
 static bool trigger_option(const char* option) {
     return not_null(option) && switch_char(option[0]) && trigger_char(option[1]) && eos(&option[2]);
 }
コード例 #10
0
 static bool verbose_option(const char *option) {
   return not_null(option) && switch_char(option[0]) && verbose_char(option[1]) && eos(&option[2]);
 }
コード例 #11
0
ファイル: test2.cpp プロジェクト: xuyaocareer/CS440
int main() {
	atexit(count_check);
	{
		DP dp;
		assert(null(dp));
		DP dp2(std::move(dp));
		assert(null(dp2));
		dp = std::move(dp2);
		assert(null(dp));
		dp2.reset(nullptr);
		assert(null(dp2));
		assert(equal(dp, dp2));
	}
	{
		DP dp{new Derived};
		assert(not_null(dp));
		assert(val_equal(dp, 1, 1));
		dp.reset(new Derived{2});
		assert(not_null(dp));
		assert(val_equal(dp, 2, 2));
		dp.reset(nullptr);
		assert(null(dp));
		dp = DP{new Derived{3}};
		assert(not_null(dp));
		assert(val_equal(dp, 3, 3));
		dp = std::move(dp);
		dp = DP{new Derived};
		assert(not_null(dp));
		assert(val_equal(dp, 1, 1));
	}
	{
		BP bp{new Base}, dp{new Derived};
		assert(not_null(bp));
		assert(not_null(dp));
		assert(val_equal(bp));
		assert(val_equal(dp, 1, 1));
		assert(val_not_equal(bp, dp));
		{
			BP mp{std::move(bp)};
			assert(val_equal(mp));
			mp = std::move(dp);
			assert(val_equal(mp, 1, 1));
		}
		bp.reset(new Base);
		dp.reset(new Derived);
		DP dp2{new Derived};
		assert(val_not_equal(bp, dp));
		assert(val_not_equal(bp, dp2));
		assert(not_equal(dp, dp2));
	}
	{
		CP<0> cp0{new Chain<2>};
		assert(val_equal(cp0, 2, 2));
		cp0 = CP<3>{new Chain<5>};
		assert(val_equal(cp0, 5, 5));
		cp0 = CP<2>{CP<5>{CP<8>{new Chain<12>}}};
		assert(val_equal(cp0, 12, 12));
	}
	{
		CP<0> cp0;
		CP<2> cp2;
		CP<5> cp5;
		cp5.reset(new Chain<10>);
		assert(val_equal(cp5, 10, 10));
		cp2 = std::move(cp5);
		assert(val_equal(cp2, 10, 10));
		cp0 = std::move(cp2);
		assert(val_equal(cp0, 10, 10));
	}
	{
		GP<0, 0> gp00{GP<0,3>{GP<4,3>{GP<4,4>{GP<4,5>{new Grid<5, 5>}}}}};
		assert(val_equal(gp00, 5, 5));
	}
	{
		GP<0, 0> gp00; GP<1, 0> gp10;
		GP<1, 1> gp11;
		GP<1, 2> gp12;
        GP<2, 2> gp22;
		gp22.reset(new Grid<2, 5>);
		gp12 = std::move(gp22); 
		gp11 = std::move(gp12);
		gp10 = std::move(gp11);
		gp00 = std::move(gp10);
		assert(val_equal(gp00, 2, 5));
	}
}
コード例 #12
0
ファイル: test2.cpp プロジェクト: xuyaocareer/CS440
inline bool val_not_equal(const UP<T> &t, const UP<U> &u) {
	return
    not_null(t) && not_null(u) && not_equal(t, u) &&
    val_equal(t, t->n, t->m) && !val_equal(t, u->n, u->m) &&
    !val_equal(u, t->n, t->m) && val_equal(u, u->n, u->m);
}
コード例 #13
0
ファイル: test2.cpp プロジェクト: xuyaocareer/CS440
inline bool val_equal(const UP<T> &t, size_t n = 0, size_t m = 0) {
	return
    not_null(t) &&
    (t->n == n) && ((*t).n == n) && (t.get()->n == n) &&
    (t->m == m) && ((*t).m == m) && (t.get()->m == m);
}