/[gnugo]/gnugo/patterns/dfa.c
ViewVC logotype

Diff of /gnugo/patterns/dfa.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38 by arend, Mon Sep 13 09:24:13 2004 UTC revision 1.39 by arend, Sun Oct 24 03:14:50 2004 UTC
# Line 113  member_att(dfa_t *pdfa, int att, int val Line 113  member_att(dfa_t *pdfa, int att, int val
113  static int  static int
114  union_att(dfa_t *pdfa, dfa_t *pdfa1, int att1, dfa_t *pdfa2, int att2)  union_att(dfa_t *pdfa, dfa_t *pdfa1, int att1, dfa_t *pdfa2, int att2)
115  {  {
116    int att_aux = 0;    int att;
117    int att = 0;    int att_aux;
   int save1 = att1;  
   int save2 = att2;  
118    
   if (att1 == 0 && att2 == 0)  
     return 0;  
119    /* copy att1 in att */    /* copy att1 in att */
120      att = 0;
121    while (att1 != 0) {    while (att1 != 0) {
122      pdfa->last_index++;      pdfa->last_index++;
123      if (pdfa->last_index >= pdfa->max_indexes)      if (pdfa->last_index >= pdfa->max_indexes)
124        resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);        resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);
125      att_aux = pdfa->last_index;      att_aux = pdfa->last_index;
     if (!att)  
       att = att_aux;  
126            
127      pdfa->indexes[att_aux].val = pdfa1->indexes[att1].val;      pdfa->indexes[att_aux].val = pdfa1->indexes[att1].val;
128      pdfa->indexes[att_aux].next = att_aux + 1;      pdfa->indexes[att_aux].next = att;
129        att = att_aux;
130      att1 = pdfa1->indexes[att1].next;      att1 = pdfa1->indexes[att1].next;
131    }    }
132    
# Line 141  union_att(dfa_t *pdfa, dfa_t *pdfa1, int Line 137  union_att(dfa_t *pdfa, dfa_t *pdfa1, int
137        if (pdfa->last_index >= pdfa->max_indexes)        if (pdfa->last_index >= pdfa->max_indexes)
138          resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);          resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);
139        att_aux = pdfa->last_index;        att_aux = pdfa->last_index;
       if (!att)  
         att = att_aux;  
140    
141        pdfa->indexes[att_aux].val = pdfa2->indexes[att2].val;        pdfa->indexes[att_aux].val = pdfa2->indexes[att2].val;
142        pdfa->indexes[att_aux].next = att_aux + 1;        pdfa->indexes[att_aux].next = att;
143          att = att_aux;
144      }      }
145      att2 = pdfa2->indexes[att2].next;      att2 = pdfa2->indexes[att2].next;
146    }    }
   pdfa->indexes[att_aux].next = 0;  
   if (0 && save1 != 0 && save2 != 0) {  
     fprintf(stderr, "Made union of %d and %d at %d.\n", save1, save2, att);  
     dump_dfa(stderr, pdfa);  
     dump_dfa(stderr, pdfa1);  
     dump_dfa(stderr, pdfa2);  
   }  
147    
148    return att;    return att;
149  }  }

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26