Exemplo n.º 1
0
buffer::buffer(driver::Context const & context, std::string const & scalartype, unsigned int id, const tuple &shape, tuple const & strides) : array(context, scalartype, id), dim_(numgt1(shape))
{
  //Attributes
  attributes_["off"] = process("#name_off");
  for(unsigned int i = 0 ; i < dim_ ; ++i){
    std::string inc = "inc" + tools::to_string(i);
    attributes_[inc] = process("#name_" + inc);
  }

  //Access
  std::vector<std::string> args;
  for(unsigned int i = 0 ; i < dim_ ; ++i)
    args.push_back("x" + tools::to_string(i));

  std::string off = "#off";
  for(unsigned int i = 0 ; i < dim_ ; ++i)
  {
    std::string inc = "#inc" + tools::to_string(i);
    off += " + (" + args[i] + ")*" + inc;
  }
  macros_.insert("at(" + tools::join(args, ",") + "): #pointer[" + off + "]");

  //Broadcast
  if(numgt1(shape)==0)
    macros_.insert("at(i): at()");

  if(dim_!=shape.size())
    macros_.insert(make_broadcast(shape));

  add_base("buffer");
  add_load(strides[0]==1 && shape[0]>1);
}
Exemplo n.º 2
0
object::object(driver::Context const & context, std::string const & scalartype, std::string const & name): context_(context)
{
  add_base("object");

  //attributes
  attributes_["scalartype"] = scalartype;
  attributes_["name"]       = name;
}
Exemplo n.º 3
0
placeholder::placeholder(driver::Context const & context, unsigned int level) : leaf(context, "int", "sforidx" + tools::to_string(level))
{
  macros_.insert("at(): #name");
  macros_.insert("at(i): #name");
  macros_.insert("at(i,j): #name");

  add_base("placebolder");
  add_load(false);
}
Exemplo n.º 4
0
diag_vector::diag_vector(const std::string &scalartype, unsigned int id, size_t root, op_element op, const expression_tree &tree, const symbols_table &table) : index_modifier(scalartype, id, root, op, tree, table)
{
  add_base("diag_vector");

  macros_.insert("at(i,j): " + lhs_->evaluate({{"leaf","(i==j)?at(i):0"}}));
  tuple const & shape = tree[root].shape;
  if(numgt1(shape)!=shape.size())
    macros_.insert(make_broadcast(shape));
}
Exemplo n.º 5
0
host_scalar::host_scalar(driver::Context const & context, std::string const & scalartype, unsigned int id) : leaf(context, scalartype, id)
{
  macros_.insert("at(): #name_value");
  macros_.insert("at(i): #name_value");
  macros_.insert("at(i,j): #name_value");

  add_base("host_scalar");
  add_load(false);
}
Exemplo n.º 6
0
		DefaultLayout()
		{
			add_base(get_structlayout<CPipeDataSBase>());
			add_simple(_T("a1"),&CPipeDataS::m_a1);
			add_simple(_T("a2"),&CPipeDataS::m_a2);
			add_simple(_T("b"),&CPipeDataS::m_b);
			add_simple(_T("String"),&CPipeDataS::m_str);
			add_vector(_T("Vec"),&CPipeDataS::m_vec,get_primitivelayout<long>());
			add_struct(_T("Struct"),&CPipeDataS::m_struct,get_structlayout<CPipeDataSBase>());
		}
Exemplo n.º 7
0
//Reshaping
reshape::reshape(std::string const & scalartype, unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) : index_modifier(scalartype, id, root, op, tree, table)
{
  add_base("reshape");

  tuple new_shape = tree[root].shape;
  tuple old_shape = tree[tree[root].binary_operator.lhs].shape;

  //Attributes
  for(unsigned int i = 1 ; i < new_shape.size() ; ++i)
    if(new_shape[i] > 1){
      std::string inc = "new_inc" + tools::to_string(i);
      attributes_[inc] = process("#name_" + inc);
    }

  for(unsigned int i = 1 ; i < old_shape.size() ; ++i)
    if(old_shape[i] > 1){
      std::string inc = "old_inc" + tools::to_string(i);
      attributes_[inc] = process("#name_" + inc);
    }

  //Index modification
  size_t new_gt1 = numgt1(new_shape);
  size_t old_gt1 = numgt1(old_shape);

  if(new_gt1==0 && old_gt1==0)
    macros_.insert("at(): " + lhs_->evaluate({{"leaf","at()"}}));
  if(new_gt1==0 && old_gt1==1)
    macros_.insert("at(): " + lhs_->evaluate({{"leaf","at(0)"}}));
  if(new_gt1==0 && old_gt1==2)
    macros_.insert("at(): " + lhs_->evaluate({{"leaf","at(0,0)"}}));

  if(new_gt1==1 && old_gt1==0)
    macros_.insert("at(i): " + lhs_->evaluate({{"leaf","at()"}}));
  if(new_gt1==1 && old_gt1==1)
    macros_.insert("at(i): " + lhs_->evaluate({{"leaf","at(i)"}}));
  if(new_gt1==1 && old_gt1==2)
    macros_.insert("at(i): " + lhs_->evaluate({{"leaf","at((i)%#old_inc1, (i)/#old_inc1)"}}));

  if(new_gt1==2 && old_gt1==0)
    macros_.insert("at(i,j): " + lhs_-> evaluate({{"leaf","at()"}}));
  if(new_gt1==2 && old_gt1==1)
    macros_.insert("at(i,j): " + lhs_-> evaluate({{"leaf","at((i) + (j)*#new_inc1)"}}));
  if(new_gt1==2 && old_gt1==2)
    macros_.insert("at(i,j): " + lhs_->evaluate({{"leaf","at(((i) + (j)*#new_inc1)%#old_inc1, ((i)+(j)*#new_inc1)/#old_inc1)"}}));

  //Broadcast
  if(numgt1(new_shape)==0)
    macros_.insert("at(i): at()");

  if(new_gt1!=new_shape.size())
    macros_.insert(make_broadcast(new_shape));
}
Exemplo n.º 8
0
//Transposition
trans::trans(std::string const & scalartype, unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) : index_modifier(scalartype, id, root, op, tree, table)
{
  add_base("trans");
  tuple shape = tree[root].shape;
  std::vector<std::string> args;
  for(unsigned int i = 0 ; i < numgt1(shape) ; ++i)
    args.push_back("x" + tools::to_string(i));

  std::vector<std::string> rotated = args;
  if(rotated.size()>1)
    std::rotate(rotated.begin(), rotated.end()-1, rotated.end());

  macros_.insert("at(" + tools::join(args, ",") + "): " + lhs_->evaluate({{"leaf", "at(" + tools::join(rotated, ",") + ")"}}));
  //Broadcast
  if(numgt1(shape)==0)
    macros_.insert("at(i): at()");

  if(numgt1(shape)!=shape.size())
    macros_.insert(make_broadcast(shape));
}
Exemplo n.º 9
0
index_modifier::index_modifier(const std::string &scalartype, unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) : array(tree.context(), scalartype, id), node(root, op, tree, table)
{
  add_base("index_modifier");
  add_load(false);
}
Exemplo n.º 10
0
/* For a given region, defined by reg_start and reg_end, show
 the refence sequence, the consensus sequence, 
 and the sequence of all the fragments that overlap this
 region at all.
 */
void print_region( MapAlignmentP maln, int reg_start, int reg_end,
		   int out_format, int in_color ) {
  int i, ref_pos, ref_gaps, j, cons_pos, ins_len;
  int num_gaps = 0;
  int ins_seq_len;
  int read_out_pos;
  char* consensus;
  char* aln_ref;
  char* read_reg;
  char* ins_cons;
  char* read_str;
  char* read_id;
  char* ins_seq;
  int* ins_cov;
  BaseCountsP bcs;
  AlnSeqP aln_seq;
  PSSMP psm;
  
  /* Make sure region doesn't go off edge */
  if (reg_start < 1) {
    reg_start = 1;
  }
  if (reg_end > maln->ref->seq_len) {
    reg_end = maln->ref->seq_len;
  }
  
  bcs = (BaseCountsP)save_malloc(sizeof(BaseCounts));
  reset_base_counts(bcs);
  
  /* Find how many gaps are in this region */
  for (i = reg_start-1; i <= reg_end; i++) {
    num_gaps += maln->ref->gaps[i];
  }
  
  /* Make char arrays long enough for the sequence plus
     gaps for the reference, the consensus, and a single 
     read. These will be populated and output by the rest
     of this function.
  */
  consensus = (char*)save_malloc((num_gaps + (reg_end-reg_start+1) + 10)
				 * sizeof(char));
  aln_ref = (char*)save_malloc((num_gaps + (reg_end-reg_start+1) + 10)
			       * sizeof(char));
  read_reg = (char*)save_malloc((num_gaps + (reg_end-reg_start+1) + 10)
				* sizeof(char));
	
  /* Make char and int array for insert consensus and
     insert coverage to be used whenever needed */
  ins_cons = (char*)save_malloc(MAX_INS_LEN * sizeof(char));
  ins_cov = (int* )save_malloc(MAX_INS_LEN * sizeof(int));
  
  cons_pos = 0;
  for (ref_pos = reg_start - 1; ref_pos < reg_end; ref_pos++) {
    ref_gaps = maln->ref->gaps[ref_pos];
    /* Add these gaps to the reference aligned string and the inserted
       sequence to the consensus[] */
    if (ref_gaps > 0) {
      find_ins_cons(maln, ref_pos, ins_cons, ins_cov, out_format);
      for (j = 0; j < ref_gaps; j++) {
	aln_ref[cons_pos] = '-';
	consensus[cons_pos] = ins_cons[j];
	cons_pos++;
      }
    }
    /* Re-zero all the base counts */
    reset_base_counts(bcs);
    
    /* Find all the aligned fragments that include this
       position and make a consensus from it */
    for (j = 0; j < maln->num_aln_seqs; j++) {
      aln_seq = maln->AlnSeqArray[j];
      /* Does this aligned fragment cover this position? */
      if ( (aln_seq->start <= ref_pos) && // checked
	   (aln_seq->end >= ref_pos)) {
	if (aln_seq->revcom) {
	  psm = maln->rpsm;
	} else {
	  psm = maln->fpsm;
	}
	add_base(aln_seq->seq[ref_pos - aln_seq->start], bcs, psm,
		 aln_seq->smp[ref_pos - aln_seq->start]);
      }
    }
    
    consensus[cons_pos] = find_consensus(bcs, maln->cons_code);
    aln_ref[cons_pos] = maln->ref->seq[ref_pos];
    cons_pos++;
  }
  
  consensus[cons_pos] = '\0';
  aln_ref[cons_pos] = '\0';
  
  /* Now print the reference and the consensus */
  if (out_format == 61) {
    fasta_aln_print(aln_ref, maln->ref->id);
    fasta_aln_print(consensus, "Consensus");
  } else {
    if (in_color) {
      printf("%-20.20s ", maln->ref->id);
      color_print(aln_ref);
      printf("%-20.20s ", "Consensus");
      color_print(consensus);
    } else
      printf("%-20.20s %s\n%-20s %s\n", maln->ref->id, aln_ref,
	     "Consensus", consensus);
  }
  
  /* 
     Alloc memories for the string to hold each read (plus .'s outside)
     and alloc memories for the special id which is the regular ID
     plus the code for whether it's truncated, reverse complemented,
     and the number of input sequence
  */
  read_str = (char*)save_malloc(strlen(aln_ref) * sizeof(char) + 1);
  read_id  = (char*)save_malloc((MAX_ID_LEN + 4) * sizeof(char) + 1);
  /* Find every sequence that overlaps this region and print
     the overlapping segment */
  for (j = 0; j < maln->num_aln_seqs; j++) {
    aln_seq = maln->AlnSeqArray[j];
    if (alnseq_ol_reg(aln_seq, (reg_start-1), (reg_end-1)) ) {
      read_out_pos = 0;
      if (aln_seq->trimmed) {
	read_id[0] = 't';
      } else {
	read_id[0] = '_';
      }
      
      if (aln_seq->revcom) {
	read_id[1] = 'r';
      } else {
	read_id[1] = '_';
      }
      sprintf( &read_id[2], "%0.2d", aln_seq->num_inputs );
      read_id[4] = '\0';

      strcat(read_id, aln_seq->id);
      if (out_format == 6) {
	printf("%-20.20s ", read_id);
      }
      for (ref_pos = reg_start - 1; ref_pos < reg_end; ref_pos++) {
	ref_gaps = maln->ref->gaps[ref_pos];
	/* Check to make sure that this fragment has started and
	   not ended by this ref_pos */
	if ( (aln_seq->start <= ref_pos) && // checked
	     (aln_seq->end >= ref_pos)) {
	  if (ref_gaps > 0) {
	    if (aln_seq->ins[ref_pos - aln_seq->start] == NULL) {
	      ins_len = 0;
	    } else {
	      ins_len
		= strlen(aln_seq->ins[ref_pos - aln_seq->start]);
	    }
	    if (aln_seq->start == ref_pos) {
	      // Exactly at the beginning of this frag
	      for (i = 0; i < ref_gaps; i++) {
		read_str[read_out_pos++] = '.';
		//		printf( "." );
	      }
	    } else {
	      // Just a normal, interior gapped position
	      if (ins_len > 0) {
		ins_seq
		  = aln_seq->ins[ref_pos - aln_seq->start];
		ins_seq_len = strlen(ins_seq);
		for (i = 0; i < ins_seq_len; i++) {
		  read_str[read_out_pos++] = ins_seq[i];
		}
		//		printf( "%s", aln_seq->ins[ref_pos - aln_seq->start] );
	      }
	      for (i = 0; i < (ref_gaps - ins_len); i++) {
		read_str[read_out_pos++] = '-';
		//		printf( "-" );
	      }
	    }
	  }
	  read_str[read_out_pos++]
	    = aln_seq->seq[ref_pos - aln_seq->start];
	  //printf( "%c", aln_seq->seq[ref_pos - aln_seq->start] );
	} else {
	  // This fragment doesn't actually cover this base
	  for (i = 0; i < ref_gaps; i++) {
	    // print this . for all ref gaps
	    read_str[read_out_pos++] = '.';
	    // printf( "." );
	  }
	  read_str[read_out_pos++] = '.';
	  //printf( "." );
	}
      }
      read_str[read_out_pos] = '\0';
      if (out_format == 61) {
	fasta_aln_print(read_str, read_id);
      } else {
	
	if (in_color) {
	  color_print(read_str);
	} else
	  printf("%s\n", read_str);
      }
    }
  }
  free(bcs);
  free(consensus);
  free(aln_ref);
  free(read_reg);
  free(ins_cons);
  free(ins_cov);
  free(read_str);
  free(read_id);
}
Exemplo n.º 11
0
array::array(driver::Context const & context, std::string const & scalartype, unsigned int id) : leaf(context, scalartype, id)
{
  attributes_["pointer"] = process("#name_pointer");

  add_base("array");
}
Exemplo n.º 12
0
reduce_2d::reduce_2d(unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) : reduction(id, root, op, tree, table)
{ add_base("reduce_2d"); }
Exemplo n.º 13
0
/* Takes a MapAlignmentP and a position where some of
 the aligned fragments have an insert relative to the
 reference. That is, maln->ref->gaps[position] > 0.
 Populates the char* ins_cons and int* cons_cov
 arrays with the consensus sequence and consensus
 coverage, respectively. These must be appropriately
 sized elsewhere. If out_format is the special value
 of 4, then we just show these differences now and
 do not return anything.
 */
void find_ins_cons(MapAlignmentP maln, int pos, char* ins_cons, int* cons_cov,
		int out_format) {
	int i, j, ins_len, this_frag_ins_len;
	char* ins_seq;
	AlnSeqP aln_seq;
	BaseCountsP* bcs_array;
	BaseCountsP first_bcs;
	PSSMP psm;

	ins_len = maln->ref->gaps[pos];

	bcs_array = (BaseCountsP*)save_malloc(ins_len * sizeof(BaseCountsP));
	first_bcs = (BaseCountsP)save_malloc(ins_len * sizeof(BaseCounts));

	for (i = 0; i < ins_len; i++) {
		bcs_array[i] = &first_bcs[i];
		reset_base_counts(bcs_array[i]);
	}

	for (i = 0; i < maln->num_aln_seqs; i++) {
		aln_seq = maln->AlnSeqArray[i];
		/* Does this aligned fragment cover this position? */
		if ( (aln_seq->start < pos) && // It does not cover this position
				//if it starts exactly here because the gap is, by convention,
				//just upstream of this position
				(aln_seq->end >= pos)) {
			if (aln_seq->revcom) {
				psm = maln->rpsm;
			} else {
				psm = maln->fpsm;
			}
			/* Does it have some actual inserted sequence? */
			ins_seq = aln_seq->ins[pos - aln_seq->start];
			if (ins_seq == NULL) {
				for (j = 0; j < ins_len; j++) {
					add_base( '-', bcs_array[j], psm,
							aln_seq->smp[pos - aln_seq->start]);
				}
			} else {
				this_frag_ins_len = strlen(ins_seq);
				for (j = 0; j < ins_len; j++) {
					if (j < this_frag_ins_len) {
						add_base(ins_seq[j], bcs_array[j], psm,
								aln_seq->smp[pos - aln_seq->start]);
					} else {
						add_base( '-', bcs_array[j], psm,
								aln_seq->smp[pos - aln_seq->start]);
					}
				}
			}
		}
	}

	for (j = 0; j < ins_len; j++) {
		ins_cons[j] = find_consensus(bcs_array[j], maln->cons_code);
		cons_cov[j] = bcs_array[j]->cov;
		if ( (out_format == 4) && !(ins_cons[j] == '-')) {
			show_single_pos(pos, '-', ins_cons[j], bcs_array[j]);
		}
		if (out_format == 41) {
			show_single_pos(pos, '-', ins_cons[j], bcs_array[j]);
		}
	}

	free(first_bcs);
	free(bcs_array);
}
Exemplo n.º 14
0
reduction::reduction(unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) :
  object(tree.context(), to_string(tree[root].dtype), id), node(root, op, tree, table)
{ add_base("reduction"); }
Exemplo n.º 15
0
unary_arithmetic_node::unary_arithmetic_node(unsigned int id, size_t root, op_element op, expression_tree const & tree, symbols_table const & table) :
    arithmetic_node(id, root, op, tree, table)
{ add_base("unary_arithmetic_node"); }
Exemplo n.º 16
0
leaf::leaf(driver::Context const & context, std::string const & scalartype, std::string const & name): object(context, scalartype, name)
{ add_base("leaf"); }
Exemplo n.º 17
0
leaf::leaf(driver::Context const & context, std::string const & scalartype, unsigned int id): object(context, scalartype, id)
{ add_base("leaf"); }
Exemplo n.º 18
0
/*
 * routine:
 *	main
 *
 * purpose:
 *	argument processing and primary dispatch
 *
 * returns:
 *	error codes per filesync.1 (ERR_* in filesync.h)
 *
 * notes:
 *	read filesync.1 in order to understand the argument processing
 *
 *	most of the command line options just set some opt_ global
 *	variable that is later looked at by the code that actually
 *	implements the features.  Only file names are really processed
 *	in this routine.
 */
int
main(int argc, char **argv)
{	int i;
	int c;
	errmask_t errs = ERR_OK;
	int do_prune = 0;
	char *srcname = 0;
	char *dstname = 0;
	struct base *bp;

	/* keep the error messages simple	*/
	argv[0] = "filesync";

	/* gather together all of the options	*/
	while ((c = getopt(argc, argv, "AaehmnqvyD:E:r:s:d:f:o:")) != EOF)
		switch (c) {
			case 'a':	/* always scan for acls	*/
				opt_acls = TRUE;
				break;
			case 'e':	/* everything agrees	*/
				opt_everything = TRUE;
				break;
			case 'h':	/* halt on error	*/
				opt_halt = TRUE;
				break;
			case 'm':	/* preserve modtimes	*/
				opt_mtime = TRUE;
				break;
			case 'n':	/* notouch		*/
				opt_notouch = TRUE;
				break;
			case 'q':	/* quiet		*/
				opt_quiet = TRUE;
				break;
			case 'v':	/* verbose		*/
				opt_verbose = TRUE;
				break;
			case 'y':	/* yes			*/
				opt_yes = TRUE;
				break;
			case 'D':	/* debug options	*/
				if (!isdigit(optarg[0])) {
					dbg_usage();
					exit(ERR_INVAL);
				}
				opt_debug |= strtol(optarg, (char **)NULL, 0);
				break;

			case 'E':	/* error simulation	*/
				if (dbg_set_error(optarg)) {
					err_usage();
					exit(ERR_INVAL);
				}
				opt_errors = TRUE;
				break;

			case 'f':	/* force conflict resolution	*/
				switch (optarg[0]) {
					case 's':
						opt_force = OPT_SRC;
						break;
					case 'd':
						opt_force = OPT_DST;
						break;
					case 'o':
						opt_force = OPT_OLD;
						break;
					case 'n':
						opt_force = OPT_NEW;
						break;
					default:
						fprintf(stderr,
							gettext(ERR_badopt),
							c, optarg);
						errs |= ERR_INVAL;
						break;
				}
				break;

			case 'o':	/* one way propagation		*/
				switch (optarg[0]) {
					case 's':
						opt_oneway = OPT_SRC;
						break;
					case 'd':
						opt_oneway = OPT_DST;
						break;
					default:
						fprintf(stderr,
							gettext(ERR_badopt),
							c, optarg);
						errs |= ERR_INVAL;
						break;
				}
				break;

			case 'r':	/* restricted reconciliation	*/
				if (num_restrs < MAX_RLIST)
					rlist[ num_restrs++ ] = optarg;
				else {
					fprintf(stderr, gettext(ERR_tomany),
						MAX_RLIST);
					errs |= ERR_INVAL;
				}
				break;

			case 's':
				if ((srcname = qualify(optarg)) == 0)
					errs |= ERR_MISSING;
				break;

			case 'd':
				if ((dstname = qualify(optarg)) == 0)
					errs |= ERR_MISSING;
				break;

			default:
			case '?':
				errs |= ERR_INVAL;
				break;
		}

	if (opt_debug & DBG_MISC)
		fprintf(stderr, "MISC: DBG=%s\n", showflags(dbgmap, opt_debug));

	/* if we have file names, we need a source and destination */
	if (optind < argc) {
		if (srcname == 0) {
			fprintf(stderr, gettext(ERR_nosrc));
			errs |= ERR_INVAL;
		}
		if (dstname == 0) {
			fprintf(stderr, gettext(ERR_nodst));
			errs |= ERR_INVAL;
		}
	}

	/* check for simple usage errors	*/
	if (errs & ERR_INVAL) {
		usage();
		exit(errs);
	}

	/* locate our baseline and rules files	*/
	if (c = findfiles())
		exit(c);

	/* figure out file creation defaults	*/
	whoami();

	/* read in our initial baseline		*/
	if (!new_baseline && (c = read_baseline(file_base)))
		errs |= c;

	/* read in the rules file if we need or have rules	*/
	if (optind >= argc && new_rules) {
		fprintf(stderr, ERR_nonames);
		errs |= ERR_INVAL;
	} else if (!new_rules)
		errs |= read_rules(file_rules);

	/* if anything has failed with our setup, go no further	*/
	if (errs) {
		cleanup(errs);
		exit(errs);
	}

	/*
	 * figure out whether or not we are willing to do a one-sided
	 * analysis (where we don't even look at the other side.  This
	 * is an "I'm just curious what has changed" query, and we are
	 * only willing to do it if:
	 *	we aren't actually going to do anything
	 *	we have a baseline we can compare against
	 * otherwise, we are going to insist on being able to access
	 * both the source and destination.
	 */
	if (opt_notouch && !new_baseline)
		opt_onesided = opt_oneway;

	/*
	 * there are two interested usage scenarios:
	 *	file names specified
	 *		create new rules for the specified files
	 *		evaulate and reconcile only the specified files
	 *	no file names specified
	 *		use already existing rules
	 *		consider restricting them to specified subdirs/files
	 */
	if (optind < argc) {
		/* figure out what base pair we're working on	*/
		bp = add_base(srcname, dstname);

		/* perverse default rules to avoid trouble	*/
		if (new_rules) {
			errs |= add_ignore(0, SUFX_RULES);
			errs |= add_ignore(0, SUFX_BASE);
		}

		/* create include rules for each file/dir arg	*/
		while (optind < argc)
			errs |= add_include(bp, argv[ optind++ ]);

		/*
		 * evaluate the specified base on each side,
		 * being careful to limit evaulation to new rules
		 */
		errs |= evaluate(bp, OPT_SRC, TRUE);
		errs |= evaluate(bp, OPT_DST, TRUE);
	} else {
		/* note any possible evaluation restrictions	*/
		for (i = 0; i < num_restrs; i++)
			errs |= add_restr(rlist[i]);

		/*
		 * we can only prune the baseline file if we have done
		 * a complete (unrestricted) analysis.
		 */
		if (i == 0)
			do_prune = 1;

		/* evaulate each base on each side		*/
		for (bp = bases; bp; bp = bp->b_next) {
			errs |= evaluate(bp, OPT_SRC, FALSE);
			errs |= evaluate(bp, OPT_DST, FALSE);
		}
	}

	/* if anything serious happened, skip reconciliation	*/
	if (errs & ERR_FATAL) {
		cleanup(errs);
		exit(errs);
	}

	/* analyze and deal with the differenecs		*/
	errs |= analyze();

	/* see if there is any dead-wood in the baseline	*/
	if (do_prune) {
		c = prune();

		if (c > 0 && opt_verbose)
			fprintf(stdout, V_prunes, c);
	}

	/* print out a final summary				*/
	summary();

	/* update the rules and baseline files (if needed)	*/
	(void) umask(my_umask);
	errs |= write_baseline(file_base);
	errs |= write_rules(file_rules);

	if (opt_debug & DBG_MISC)
		fprintf(stderr, "MISC: EXIT=%s\n", showflags(errmap, errs));

	/* just returning ERR_RESOLVABLE upsets some people	*/
	if (errs == ERR_RESOLVABLE && !opt_notouch)
		errs = 0;

	/* all done	*/
	cleanup(0);
	return (errs);
}