aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/bison/lib/bitset.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-06-29 11:45:54 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-06-29 11:54:41 +0300
commit9158d9115725ca7f4ada745ec55eddd5747bc61e (patch)
treef262cd6d7a98bb367943a4918b6963a7800f3937 /contrib/tools/bison/lib/bitset.c
parent632b3cedb8e12fbbb0bcd1bdbf7ec5686725b7e9 (diff)
downloadydb-9158d9115725ca7f4ada745ec55eddd5747bc61e.tar.gz
Update contrib/tools/bison to 3.2.4
78e59a97f3fde03511ddb9969cd1daabbaf998bd
Diffstat (limited to 'contrib/tools/bison/lib/bitset.c')
-rw-r--r--contrib/tools/bison/lib/bitset.c90
1 files changed, 33 insertions, 57 deletions
diff --git a/contrib/tools/bison/lib/bitset.c b/contrib/tools/bison/lib/bitset.c
index 97a60ef4e3..325213777b 100644
--- a/contrib/tools/bison/lib/bitset.c
+++ b/contrib/tools/bison/lib/bitset.c
@@ -24,12 +24,14 @@
#include <stdlib.h>
#include <string.h>
+
+#include "obstack.h"
+
#include "abitset.h"
#include "lbitset.h"
#include "ebitset.h"
#include "vbitset.h"
#include "bitset_stats.h"
-#include "obstack.h"
const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
@@ -39,8 +41,6 @@ const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
size_t
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
{
- size_t bytes;
-
if (bitset_stats_enabled)
return bitset_stats_bytes ();
@@ -50,23 +50,17 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
abort ();
case BITSET_ARRAY:
- bytes = abitset_bytes (n_bits);
- break;
+ return abitset_bytes (n_bits);
case BITSET_LIST:
- bytes = lbitset_bytes (n_bits);
- break;
+ return lbitset_bytes (n_bits);
case BITSET_TABLE:
- bytes = ebitset_bytes (n_bits);
- break;
+ return ebitset_bytes (n_bits);
case BITSET_VARRAY:
- bytes = vbitset_bytes (n_bits);
- break;
+ return vbitset_bytes (n_bits);
}
-
- return bytes;
}
@@ -134,12 +128,9 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
bitset
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
{
- size_t bytes;
- bitset bset;
-
- bytes = bitset_bytes (type, n_bits);
+ size_t bytes = bitset_bytes (type, n_bits);
- bset = xcalloc (1, bytes);
+ bitset bset = xcalloc (1, bytes);
/* The cache is disabled until some elements are allocated. If we
have variable length arrays, then we may need to allocate a dummy
@@ -154,12 +145,9 @@ bitset
bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex n_bits, enum bitset_type type)
{
- size_t bytes;
- bitset bset;
+ size_t bytes = bitset_bytes (type, n_bits);
- bytes = bitset_bytes (type, n_bits);
-
- bset = obstack_alloc (bobstack, bytes);
+ bitset bset = obstack_alloc (bobstack, bytes);
memset (bset, 0, bytes);
return bitset_init (bset, n_bits, type);
@@ -171,9 +159,7 @@ bitset_obstack_alloc (struct obstack *bobstack,
bitset
bitset_create (bitset_bindex n_bits, unsigned attr)
{
- enum bitset_type type;
-
- type = bitset_type_choose (n_bits, attr);
+ enum bitset_type type = bitset_type_choose (n_bits, attr);
return bitset_alloc (n_bits, type);
}
@@ -200,11 +186,9 @@ bitset_obstack_free (bitset bset)
enum bitset_type
bitset_type_get (bitset bset)
{
- enum bitset_type type;
-
- type = BITSET_TYPE_ (bset);
+ enum bitset_type type = BITSET_TYPE_ (bset);
if (type != BITSET_STATS)
- return type;
+ return type;
return bitset_stats_type_get (bset);
}
@@ -214,9 +198,7 @@ bitset_type_get (bitset bset)
const char *
bitset_type_name_get (bitset bset)
{
- enum bitset_type type;
-
- type = bitset_type_get (bset);
+ enum bitset_type type = bitset_type_get (bset);
return bitset_type_names[type];
}
@@ -227,9 +209,8 @@ bitset_type_name_get (bitset bset)
bitset_bindex
bitset_next (bitset src, bitset_bindex bitno)
{
- bitset_bindex val;
bitset_bindex next = bitno;
-
+ bitset_bindex val;
if (!bitset_list (src, &val, 1, &next))
return BITSET_BINDEX_MAX;
return val;
@@ -240,7 +221,7 @@ bitset_next (bitset src, bitset_bindex bitno)
extern bool
bitset_compatible_p (bitset bset1, bitset bset2)
{
- return BITSET_COMPATIBLE_ (bset1, bset2);
+ return BITSET_COMPATIBLE_ (bset1, bset2);
}
@@ -249,9 +230,8 @@ bitset_compatible_p (bitset bset1, bitset bset2)
bitset_bindex
bitset_prev (bitset src, bitset_bindex bitno)
{
- bitset_bindex val;
bitset_bindex next = bitno;
-
+ bitset_bindex val;
if (!bitset_list_reverse (src, &val, 1, &next))
return BITSET_BINDEX_MAX;
return val;
@@ -291,15 +271,13 @@ bitset_only_set_p (bitset src, bitset_bindex bitno)
static void
bitset_print (FILE *file, bitset bset, bool verbose)
{
- unsigned pos;
- bitset_bindex i;
- bitset_iterator iter;
-
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long) bitset_size (bset));
- pos = 30;
+ unsigned pos = 30;
+ bitset_bindex i;
+ bitset_iterator iter;
BITSET_FOR_EACH (iter, bset, i, 0)
{
if (pos > 70)
@@ -310,7 +288,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
fprintf (file, "%lu ", (unsigned long) i);
pos += 1 + (i >= 10) + (i >= 100);
- };
+ }
if (verbose)
fprintf (file, "}\n");
@@ -357,7 +335,7 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
bitset_bindex
bitset_size_ (bitset src)
{
- return BITSET_NBITS_ (src);
+ return BITSET_NBITS_ (src);
}
@@ -366,18 +344,18 @@ bitset_bindex
bitset_count_ (bitset src)
{
bitset_bindex list[BITSET_LIST_SIZE];
- bitset_bindex next;
- bitset_bindex num;
- bitset_bindex count;
+ bitset_bindex count = 0;
/* This could be greatly sped up by adding a count method for each
bitset implementation that uses a direct technique (based on
masks) for counting the number of bits set in a word. */
- next = 0;
- for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
- count += num)
- continue;
+ {
+ bitset_bindex next = 0;
+ bitset_bindex num;
+ while ((num = bitset_list (src, list, BITSET_LIST_SIZE, &next)))
+ count += num;
+ }
return count;
}
@@ -398,7 +376,7 @@ bitset_copy_ (bitset dst, bitset src)
BITSET_FOR_EACH (iter, src, i, 0)
{
bitset_set (dst, i);
- };
+ }
return true;
}
@@ -411,13 +389,11 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
enum bitset_ops op)
{
bool changed = false;
- bool stats_enabled_save;
- bitset tmp;
/* Create temporary bitset. */
- stats_enabled_save = bitset_stats_enabled;
+ bool stats_enabled_save = bitset_stats_enabled;
bitset_stats_enabled = false;
- tmp = bitset_alloc (0, bitset_type_get (dst));
+ bitset tmp = bitset_alloc (0, bitset_type_get (dst));
bitset_stats_enabled = stats_enabled_save;
switch (op)