/[bison]/bison/lib/lbitset.c
ViewVC logotype

Diff of /bison/lib/lbitset.c

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

revision 1.6 by akim, Mon Sep 30 12:50:49 2002 UTC revision 1.7 by eggert, Wed Oct 2 08:00:19 2002 UTC
# Line 110  static int lbitset_copy_cmp PARAMS ((bit Line 110  static int lbitset_copy_cmp PARAMS ((bit
110  static void lbitset_set PARAMS ((bitset, bitset_bindex));  static void lbitset_set PARAMS ((bitset, bitset_bindex));
111  static void lbitset_reset PARAMS ((bitset, bitset_bindex));  static void lbitset_reset PARAMS ((bitset, bitset_bindex));
112  static int lbitset_test PARAMS ((bitset, bitset_bindex));  static int lbitset_test PARAMS ((bitset, bitset_bindex));
113  static int lbitset_size PARAMS ((bitset));  static bitset_bindex lbitset_size PARAMS ((bitset));
114  static int lbitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum bitset_ops));  static int lbitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum bitset_ops));
115  static int lbitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,  static bitset_bindex lbitset_list PARAMS ((bitset, bitset_bindex *,
116                                   bitset_bindex *));                                             bitset_bindex, bitset_bindex *));
117  static int lbitset_list_reverse  static bitset_bindex lbitset_list_reverse
118  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
119  static void lbitset_free PARAMS ((bitset));  static void lbitset_free PARAMS ((bitset));
120    
# Line 417  lbitset_elt_find (bset, windex, mode) Line 417  lbitset_elt_find (bset, windex, mode)
417        return 0;        return 0;
418    
419      case LBITSET_CREATE:      case LBITSET_CREATE:
420        windex = (windex / (unsigned) LBITSET_ELT_WORDS) * LBITSET_ELT_WORDS;        windex -= windex % LBITSET_ELT_WORDS;
421    
422        elt = lbitset_elt_calloc ();        elt = lbitset_elt_calloc ();
423        elt->index = windex;        elt->index = windex;
# Line 563  lbitset_copy_cmp (dst, src) Line 563  lbitset_copy_cmp (dst, src)
563    
564    
565  /* Return size in bits of bitset SRC.  */  /* Return size in bits of bitset SRC.  */
566  static int  static bitset_bindex
567  lbitset_size (src)  lbitset_size (src)
568       bitset src;       bitset src;
569  {  {
# Line 638  lbitset_free (bset) Line 638  lbitset_free (bset)
638  /* Find list of up to NUM bits set in BSET starting from and including  /* Find list of up to NUM bits set in BSET starting from and including
639   *NEXT and store in array LIST.  Return with actual number of bits   *NEXT and store in array LIST.  Return with actual number of bits
640   found and with *NEXT indicating where search stopped.  */   found and with *NEXT indicating where search stopped.  */
641  static int  static bitset_bindex
642  lbitset_list_reverse (bset, list, num, next)  lbitset_list_reverse (bset, list, num, next)
643       bitset bset;       bitset bset;
644       bitset_bindex *list;       bitset_bindex *list;
# Line 736  lbitset_list_reverse (bset, list, num, n Line 736  lbitset_list_reverse (bset, list, num, n
736  /* Find list of up to NUM bits set in BSET starting from and including  /* Find list of up to NUM bits set in BSET starting from and including
737   *NEXT and store in array LIST.  Return with actual number of bits   *NEXT and store in array LIST.  Return with actual number of bits
738   found and with *NEXT indicating where search stopped.  */   found and with *NEXT indicating where search stopped.  */
739  static int  static bitset_bindex
740  lbitset_list (bset, list, num, next)  lbitset_list (bset, list, num, next)
741       bitset bset;       bitset bset;
742       bitset_bindex *list;       bitset_bindex *list;
# Line 954  static void Line 954  static void
954  lbitset_ones (dst)  lbitset_ones (dst)
955       bitset dst;       bitset dst;
956  {  {
957    unsigned int i;    bitset_windex i;
958    bitset_windex windex;    bitset_windex windex;
959    lbitset_elt *elt;    lbitset_elt *elt;
960    
# Line 985  lbitset_not (dst, src) Line 985  lbitset_not (dst, src)
985    lbitset_elt *elt;    lbitset_elt *elt;
986    lbitset_elt *selt;    lbitset_elt *selt;
987    lbitset_elt *delt;    lbitset_elt *delt;
988    unsigned int i;    bitset_windex i;
989    unsigned int j;    unsigned int j;
990    bitset_windex windex;    bitset_windex windex;
991    
# Line 1114  lbitset_op3_cmp (dst, src1, src2, op) Line 1114  lbitset_op3_cmp (dst, src1, src2, op)
1114    LBITSET_HEAD (dst) = 0;    LBITSET_HEAD (dst) = 0;
1115    dst->b.csize = 0;    dst->b.csize = 0;
1116    
1117    windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;    windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
1118    windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;    windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
1119    
1120    while (selt1 || selt2)    while (selt1 || selt2)
1121      {      {
# Line 1127  lbitset_op3_cmp (dst, src1, src2, op) Line 1127  lbitset_op3_cmp (dst, src1, src2, op)
1127            stmp1 = selt1;            stmp1 = selt1;
1128            stmp2 = selt2;            stmp2 = selt2;
1129            selt1 = selt1->next;            selt1 = selt1->next;
1130            windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;            windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
1131            selt2 = selt2->next;            selt2 = selt2->next;
1132            windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;            windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
1133          }          }
1134        else if (windex1 < windex2)        else if (windex1 < windex2)
1135          {          {
# Line 1137  lbitset_op3_cmp (dst, src1, src2, op) Line 1137  lbitset_op3_cmp (dst, src1, src2, op)
1137            stmp1 = selt1;            stmp1 = selt1;
1138            stmp2 = &lbitset_zero_elts[0];            stmp2 = &lbitset_zero_elts[0];
1139            selt1 = selt1->next;            selt1 = selt1->next;
1140            windex1 = (selt1) ? selt1->index : BITSET_INDEX_MAX;            windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
1141          }          }
1142        else        else
1143          {          {
# Line 1145  lbitset_op3_cmp (dst, src1, src2, op) Line 1145  lbitset_op3_cmp (dst, src1, src2, op)
1145            stmp1 = &lbitset_zero_elts[0];            stmp1 = &lbitset_zero_elts[0];
1146            stmp2 = selt2;            stmp2 = selt2;
1147            selt2 = selt2->next;            selt2 = selt2->next;
1148            windex2 = (selt2) ? selt2->index : BITSET_INDEX_MAX;            windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
1149          }          }
1150    
1151        /* Find the appropriate element from DST.  Begin by discarding        /* Find the appropriate element from DST.  Begin by discarding
# Line 1385  struct bitset_vtable lbitset_vtable = { Line 1385  struct bitset_vtable lbitset_vtable = {
1385    
1386    
1387  /* Return size of initial structure.  */  /* Return size of initial structure.  */
1388  int  size_t
1389  lbitset_bytes (n_bits)  lbitset_bytes (n_bits)
1390       bitset_bindex n_bits ATTRIBUTE_UNUSED;       bitset_bindex n_bits ATTRIBUTE_UNUSED;
1391  {  {
# Line 1429  debug_lbitset (bset) Line 1429  debug_lbitset (bset)
1429        
1430    for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)    for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
1431      {      {
1432        fprintf (stderr, "Elt %d\n", elt->index);        fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
1433        for (i = 0; i < LBITSET_ELT_WORDS; i++)        for (i = 0; i < LBITSET_ELT_WORDS; i++)
1434          {          {
1435            unsigned int j;            unsigned int j;
# Line 1437  debug_lbitset (bset) Line 1437  debug_lbitset (bset)
1437                        
1438            word = elt->words[i];            word = elt->words[i];
1439                        
1440            fprintf (stderr, "  Word %d:", i);            fprintf (stderr, "  Word %u:", i);
1441            for (j = 0; j < LBITSET_WORD_BITS; j++)            for (j = 0; j < LBITSET_WORD_BITS; j++)
1442              if ((word & (1 << j)))              if ((word & (1 << j)))
1443                fprintf (stderr, " %d", j);                fprintf (stderr, " %u", j);
1444            fprintf (stderr, "\n");            fprintf (stderr, "\n");
1445          }          }
1446      }      }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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