/* * Remove less1-connected-components located to the right of * the less1-connected-component containing p->point. * * Undefined behavior if p is the pattern with only one node. */ static pattern *remove_end_clumps( pattern *p ) { node *n, *n_next; pattern *q; /* * Search for the first node (if any) that lies further right * than every circle containing p->point. */ n = p->first_node->next; while ( n->position <= p->point->position ) { n = n->less1->next; if ( !n ) return p; } /* * Having found such a node, n, we make a copy of p, * and in the copy, kill everything from n onward. */ q = copy_pattern(p); q->nodes = n->position; for ( n = isom(n,q); n; n = n_next ) { n_next = n->next; UNLINK( n, q->first_node, q->last_node, next, prev ); kill_node( n ); } return q; }
/* * Having successfully marked some points for removal ("successfully" here * means that doing so did not force us to mark p->point), make a copy of * the pattern, and remove the marked points from it. */ static pattern *execute_removal(pattern *p) { node *n, *m, *m_next; pattern *q; int i; q = copy_pattern(p); for ( i=0, n=p->first_node, m=q->first_node; n; n = n->next, m = m_next ) { m_next = m->next; if ( n->simplify_data == SIMPL_MARKED ) { UNLINK( m, q->first_node, q->last_node, next, prev ); kill_node( m ); } else { /* * Maintain a running count of how many nodes we DON'T remove, * so we can fix the nodecount after the dust settles. */ i++; } } q->nodes = i; for ( i = 0, m = q->first_node; m; m = m->next ) m->position = i++; return q; }
TRegexp & TRegexp::operator = ( const TRegexp & r ) { if(this != &r) { delete the_pattern; copy_pattern( r ); } return *this; }
TRegexp::TRegexp(const TRegexp & r) { copy_pattern( r ); }
/* * Check whether pointed patterns p and q notate the same ordinal. * Assumes working in scratch-space (see core.c) */ int same_point( pattern *p, pattern *q ) { amal *a = amalgamate( copy_pattern(p), copy_pattern(q) ); return ( a->p1_in_p->position == a->p2_in_p->position ); }