Exemplo n.º 1
0
void
settrace(wordlist *wl, int what, char *name)
{
    struct dbcomm *d, *td;
    char *s;

    while (wl) {
        s = cp_unquote(wl->wl_word);
        d = TMALLOC(struct dbcomm, 1);
        d->db_number = debugnumber++;
        d->db_analysis = name;
        if (eq(s, "all")) {
            switch (what) {
            case VF_PRINT:
                d->db_type = DB_TRACEALL;
                break;
 /*         case VF_PLOT:
                d->db_type = DB_IPLOTALL;
                break; */
            case VF_ACCUM:
                /* d->db_type = DB_SAVEALL; */
                d->db_nodename1 = copy(s);
                d->db_type = DB_SAVE;
                break;
            }
            /* wrd_chtrace(NULL, TRUE, what); */
        } else {
            switch (what) {
            case VF_PRINT:
                d->db_type = DB_TRACENODE;
                break;
/*          case VF_PLOT:
                d->db_type = DB_IPLOT;
                break; */
            case VF_ACCUM:
                d->db_type = DB_SAVE;
                break;
            }
            /* v(2) --> 2, i(vds) --> vds#branch */
            d->db_nodename1 = copynode(s);
            /* wrd_chtrace(s, TRUE, what); */
        }

        tfree(s);              /*DG avoid memoy leak */

        if (dbs) {
            for (td = dbs; td->db_next; td = td->db_next)
                ;
            td->db_next = d;
        } else {
            ft_curckt->ci_dbs = dbs = d;
        }

        wl = wl->wl_next;
    }
}
Exemplo n.º 2
0
void copy_(tree *a, tree *b)
{
  /* make a copy of a tree */
  long i, j=0;
  node *p, *q;

  for (i = 0; i < spp; i++) {
    copynode(a->nodep[i], b->nodep[i]);
    if (a->nodep[i]->back) {
      if (a->nodep[i]->back == a->nodep[a->nodep[i]->back->index - 1])
        b->nodep[i]->back = b->nodep[a->nodep[i]->back->index - 1];
      else if (a->nodep[i]->back
                 == a->nodep[a->nodep[i]->back->index - 1]->next)
        b->nodep[i]->back = b->nodep[a->nodep[i]->back->index - 1]->next;
      else
        b->nodep[i]->back
          = b->nodep[a->nodep[i]->back->index - 1]->next->next;
    }
    else b->nodep[i]->back = NULL;
  }
  for (i = spp; i < nonodes2; i++) {
    p = a->nodep[i];
    q = b->nodep[i];
    for (j = 1; j <= 3; j++) {
      copynode(p, q);
      if (p->back) {
        if (p->back == a->nodep[p->back->index - 1])
          q->back = b->nodep[p->back->index - 1];
        else if (p->back == a->nodep[p->back->index - 1]->next)
          q->back = b->nodep[p->back->index - 1]->next;
        else
          q->back = b->nodep[p->back->index - 1]->next->next;
      }
      else
        q->back = NULL;
      p = p->next;
      q = q->next;
    }
  }
  b->likelihood = a->likelihood;
  b->start = a->start;
}  /* copy_ */