projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Private info (buf) moved from struct rset_control to struct rset.
[idzebra-moved-to-github.git]
/
dfa
/
bset.c
diff --git
a/dfa/bset.c
b/dfa/bset.c
index
db02832
..
e514b4f
100644
(file)
--- a/
dfa/bset.c
+++ b/
dfa/bset.c
@@
-4,7
+4,14
@@
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: bset.c,v $
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: bset.c,v $
- * Revision 1.1 1994-09-26 10:16:53 adam
+ * Revision 1.3 1995-09-04 12:33:25 adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.2 1995/01/24 16:00:21 adam
+ * Added -ansi to CFLAGS.
+ * Some changes to the dfa module.
+ *
+ * Revision 1.1 1994/09/26 10:16:53 adam
* First version of dfa module in alex. This version uses yacc to parse
* regular expressions. This should be hand-made instead.
*
* First version of dfa module in alex. This version uses yacc to parse
* regular expressions. This should be hand-made instead.
*
@@
-15,7
+22,7
@@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
-#include <util.h>
+#include <alexutil.h>
#include <bset.h>
#include "imalloc.h"
#include <bset.h>
#include "imalloc.h"
@@
-27,10
+34,10
@@
BSetHandle *mk_BSetHandle (int size, int chunk)
int wsize = 1+size/(sizeof(BSetWord)*8);
BSetHandle *sh;
int wsize = 1+size/(sizeof(BSetWord)*8);
BSetHandle *sh;
- if( chunk <= 1 )
+ if (chunk <= 1)
chunk = 32;
chunk = 32;
- sh = (BSetHandle *) imalloc( sizeof(BSetHandle) +
- chunk*sizeof(BSetWord)*wsize );
+ sh = (BSetHandle *) imalloc (sizeof(BSetHandle) +
+ chunk*sizeof(BSetWord)*wsize);
sh->size = size;
sh->wsize = wsize;
sh->size = size;
sh->wsize = wsize;
@@
-44,13
+51,13
@@
void rm_BSetHandle (BSetHandle **shp)
{
BSetHandle *sh, *sh1;
{
BSetHandle *sh, *sh1;
- assert( shp );
+ assert (shp);
sh = *shp;
sh = *shp;
- assert( sh );
- while( sh )
+ assert (sh);
+ while (sh)
{
sh1 = sh->setchain;
{
sh1 = sh->setchain;
- ifree( sh );
+ ifree (sh);
sh = sh1;
}
}
sh = sh1;
}
}
@@
-59,7
+66,7
@@
int inf_BSetHandle (BSetHandle *sh, long *used, long *allocated)
{
int wsize;
{
int wsize;
- assert( sh );
+ assert (sh);
*used = 0;
*allocated = 0;
wsize = sh->wsize;
*used = 0;
*allocated = 0;
wsize = sh->wsize;
@@
-67,7
+74,7
@@
int inf_BSetHandle (BSetHandle *sh, long *used, long *allocated)
{
*used += sh->offset;
*allocated += sh->chunk;
{
*used += sh->offset;
*allocated += sh->chunk;
- } while( (sh = sh->setchain) );
+ } while ((sh = sh->setchain));
return wsize;
}
return wsize;
}
@@
-75,15
+82,15
@@
BSet mk_BSet (BSetHandle **shp)
{
BSetHandle *sh, *sh1;
unsigned off;
{
BSetHandle *sh, *sh1;
unsigned off;
- assert( shp );
+ assert (shp);
sh = *shp;
sh = *shp;
- assert( sh );
+ assert (sh);
off = sh->offset;
off = sh->offset;
- if( (off + sh->wsize) > sh->chunk )
+ if ((off + sh->wsize) > sh->chunk)
{
{
- sh1 = (BSetHandle *) imalloc( sizeof(BSetHandle ) +
- sh->chunk*sizeof(BSetWord) );
+ sh1 = (BSetHandle *) imalloc (sizeof(BSetHandle) +
+ sh->chunk*sizeof(BSetWord));
sh1->size = sh->size;
sh1->wsize = sh->wsize;
sh1->chunk = sh->chunk;
sh1->size = sh->size;
sh1->wsize = sh->wsize;
sh1->chunk = sh->chunk;
@@
-97,42
+104,42
@@
BSet mk_BSet (BSetHandle **shp)
void add_BSet (BSetHandle *sh, BSet dst, unsigned member)
{
void add_BSet (BSetHandle *sh, BSet dst, unsigned member)
{
- assert( dst );
- assert( sh );
- assert( member <= sh->size );
+ assert (dst);
+ assert (sh);
+ assert (member <= sh->size);
SET_BIT(dst, member);
}
unsigned test_BSet (BSetHandle *sh, BSet src, unsigned member)
{
SET_BIT(dst, member);
}
unsigned test_BSet (BSetHandle *sh, BSet src, unsigned member)
{
- assert( src );
- assert( sh );
- assert( member <= sh->size );
- return GET_BIT( src , member) != 0;
+ assert (src);
+ assert (sh);
+ assert (member <= sh->size);
+ return GET_BIT (src , member) != 0;
}
BSet cp_BSet (BSetHandle *sh, BSet dst, BSet src)
{
}
BSet cp_BSet (BSetHandle *sh, BSet dst, BSet src)
{
- assert( sh );
- assert( dst );
- assert( src );
- memcpy( dst, src, sh->wsize * sizeof(BSetWord));
+ assert (sh);
+ assert (dst);
+ assert (src);
+ memcpy (dst, src, sh->wsize * sizeof(BSetWord));
return dst;
}
void res_BSet (BSetHandle *sh, BSet dst)
{
return dst;
}
void res_BSet (BSetHandle *sh, BSet dst)
{
- assert( dst );
- memset( dst, 0, sh->wsize * sizeof(BSetWord));
+ assert (dst);
+ memset (dst, 0, sh->wsize * sizeof(BSetWord));
}
void union_BSet (BSetHandle *sh, BSet dst, BSet src)
{
int i;
}
void union_BSet (BSetHandle *sh, BSet dst, BSet src)
{
int i;
- assert( sh );
- assert( dst );
- assert( src );
- for( i=sh->wsize; --i >= 0; )
+ assert (sh);
+ assert (dst);
+ assert (src);
+ for (i=sh->wsize; --i >= 0;)
*dst++ |= *src++;
}
*dst++ |= *src++;
}
@@
-140,9
+147,9
@@
unsigned hash_BSet (BSetHandle *sh, BSet src)
{
int i;
unsigned s = 0;
{
int i;
unsigned s = 0;
- assert( sh );
- assert( src );
- for( i=sh->wsize; --i >= 0; )
+ assert (sh);
+ assert (src);
+ for (i=sh->wsize; --i >= 0;)
s += *src++;
return s;
}
s += *src++;
return s;
}
@@
-150,20
+157,20
@@
unsigned hash_BSet (BSetHandle *sh, BSet src)
void com_BSet (BSetHandle *sh, BSet dst)
{
int i;
void com_BSet (BSetHandle *sh, BSet dst)
{
int i;
- assert( sh );
- assert( dst );
- for( i=sh->wsize; --i >= 0; dst++ )
+ assert (sh);
+ assert (dst);
+ for (i=sh->wsize; --i >= 0; dst++)
*dst = ~*dst;
}
int eq_BSet (BSetHandle *sh, BSet dst, BSet src)
{
int i;
*dst = ~*dst;
}
int eq_BSet (BSetHandle *sh, BSet dst, BSet src)
{
int i;
- assert( sh );
- assert( dst );
- assert( src );
- for( i=sh->wsize; --i >= 0; )
- if( *dst++ != *src++ )
+ assert (sh);
+ assert (dst);
+ assert (src);
+ for (i=sh->wsize; --i >= 0;)
+ if (*dst++ != *src++)
return 0;
return 1;
}
return 0;
return 1;
}
@@
-174,19
+181,19
@@
int trav_BSet (BSetHandle *sh, BSet src, unsigned member)
BSetWord *sw = src+member/(sizeof(BSetWord)*8);
unsigned b = member & (sizeof(BSetWord)*8-1);
while(i >= 0)
BSetWord *sw = src+member/(sizeof(BSetWord)*8);
unsigned b = member & (sizeof(BSetWord)*8-1);
while(i >= 0)
- if( b == 0 && *sw == 0 )
+ if (b == 0 && *sw == 0)
{
member += sizeof(BSetWord)*8;
++sw;
i -= sizeof(BSetWord)*8;
}
{
member += sizeof(BSetWord)*8;
++sw;
i -= sizeof(BSetWord)*8;
}
- else if( *sw & (1<<b) )
+ else if (*sw & (1<<b))
return member;
else
{
++member;
--i;
return member;
else
{
++member;
--i;
- if( ++b == sizeof(BSetWord)*8 )
+ if (++b == sizeof(BSetWord)*8)
{
b = 0;
++sw;
{
b = 0;
++sw;
@@
-201,19
+208,19
@@
int travi_BSet (BSetHandle *sh, BSet src, unsigned member)
BSetWord *sw = src+member/(sizeof(BSetWord)*8);
unsigned b = member & (sizeof(BSetWord)*8-1);
while(i >= 0)
BSetWord *sw = src+member/(sizeof(BSetWord)*8);
unsigned b = member & (sizeof(BSetWord)*8-1);
while(i >= 0)
- if( b == 0 && *sw == (BSetWord) ~ 0 )
+ if (b == 0 && *sw == (BSetWord) ~ 0)
{
member += sizeof(BSetWord)*8;
++sw;
i -= sizeof(BSetWord)*8;
}
{
member += sizeof(BSetWord)*8;
++sw;
i -= sizeof(BSetWord)*8;
}
- else if( (*sw & (1<<b)) == 0 )
+ else if ((*sw & (1<<b)) == 0)
return member;
else
{
++member;
--i;
return member;
else
{
++member;
--i;
- if( ++b == sizeof(BSetWord)*8 )
+ if (++b == sizeof(BSetWord)*8)
{
b = 0;
++sw;
{
b = 0;
++sw;
@@
-226,35
+233,35
@@
int travi_BSet (BSetHandle *sh, BSet src, unsigned member)
void pr_BSet (BSetHandle *sh, BSet src)
{
int i;
void pr_BSet (BSetHandle *sh, BSet src)
{
int i;
- assert( sh );
- assert( src );
- for( i=0; (i=trav_BSet(sh,src,i)) != -1; i++ )
- printf( " %d", i );
- putchar( '\n' );
+ assert (sh);
+ assert (src);
+ for (i=0; (i=trav_BSet(sh,src,i)) != -1; i++)
+ printf (" %d", i);
+ putchar ('\n');
}
void pr_charBSet (BSetHandle *sh, BSet src, void (*f) (int))
{
int i0, i1, i;
}
void pr_charBSet (BSetHandle *sh, BSet src, void (*f) (int))
{
int i0, i1, i;
- assert( sh );
- assert( src );
- i = trav_BSet( sh, src, 0 );
- while( i != -1 )
+ assert (sh);
+ assert (src);
+ i = trav_BSet (sh, src, 0);
+ while (i != -1)
{
i0 = i;
{
i0 = i;
- if( i == '-' )
- f( '\\' );
+ if (i == '-')
+ f ('\\');
f(i);
f(i);
- i1 = trav_BSet( sh, src, ++i );
- if( i1 == i )
+ i1 = trav_BSet (sh, src, ++i);
+ if (i1 == i)
{
{
- while( (i1=trav_BSet( sh, src, ++i )) == i )
+ while ((i1=trav_BSet (sh, src, ++i)) == i)
;
;
- if( i != i0+2 )
- f( '-' );
- if( i-1 == '-' )
- f( '\\' );
+ if (i != i0+2)
+ f ('-');
+ if (i-1 == '-')
+ f ('\\');
f(i-1);
}
i = i1;
f(i-1);
}
i = i1;