Switch from 'int' to 'bool' where that makes sense.

This commit is contained in:
Paul Eggert
2003-05-24 19:16:02 +00:00
parent 637fa3f83e
commit d08290769c
25 changed files with 376 additions and 295 deletions

View File

@@ -1,3 +1,68 @@
2003-05-24 Paul Eggert <eggert@twinsun.com>
Switch from 'int' to 'bool' where that makes sense.
* lib/abitset.c (abitset_test, abitset_empty_p, abitset_equal_p,
abitset_subset_p, abitset_disjoint_p, abitset_and_cmp,
abitset_andn_cmp, abitset_or_cmp, abitset_xor_cmp, abitset_and_or,
abitset_and_or_cmp, abitset_andn_or_cmp, abitset_or_and_cmp):
Return or accept bool, not int. All callers changed.
* lib/bbitset.h: (bitset_toggle_, bitset_copy_, bitset_and_or_cmp_,
bitset_andn_or_cmp_, bitset_or_and_cmp_): Likewise.
* lib/bitset.c (bitset_only_set_p, bitset_print, bitset_toggle_,
bitset_copy_, bitset_op4_cmp, bitset_and_or_cmp_, bitset_andn_or_cmp_,
bitset_or_and_cmp_): Likewise.
* lib/bitset.h (bitset_test, bitset_only_set_p): Likewise.
* lib/bitset_stats.c (bitset_stats_print, bitset_stats_toggle,
bitset_stats_test, bitset_stats_empty_p, bitset_stats_disjoint_p,
bitset_stats_equal_p, bitset_stats_subset_p, bitset_stats_and_cmp,
bitset_stats_andn_cmp, bitset_stats_or_cmp, bitset_stats_xor_cmp,
bitset_stats_and_or_cmp, bitset_stats_andn_or_cmp,
bitset_stats_or_and_cmp): Likewise.
* lib/ebitset.c (ebitset_elt_zero_p, ebitset_equal_p, ebitset_copy_cmp,
ebitset_test, ebitset_empty_p, ebitset_subset_p, ebitset_disjoint_p,
ebitset_op3_cmp, ebitset_and_cmp, ebitset_andn_cmp, ebitset_or_cmp,
ebitset_xor_cmp): Likewise.
* lib/lbitset.c (lbitset_elt_zero_p, lbitset_equal_p, lbitset_copy_cmp,
lbitset_test, lbitset_empty_p, lbitset_subset_p, lbitset_disjoint_p,
lbitset_op3_cmp, lbitset_and_cmp, lbitset_andn_cmp, lbitset_or_cmp,
lbitset_xor_cmp): Likewise.
* lib/bbitset.h: Include <stdbool.h>.
(struct bitset_vtable): The following members now return bool, not
int: toggle, test, empty_p, disjoint_p, equal_p, subset_p,
and_cmp, andn_cmp, or_cmp, xor_cmp, and_or_cmp, andn_or_cmp,
or_and_cmp).
* src/conflicts.c (count_rr_conflicts): Likewise.
* lib/bitset_stats.h (bitset_stats_enabled): Now bool, not int.
All uses changed.
* lib/ebitset.c (ebitset_obstack_init): Likewise.
* lib/lbitset.c (lbitset_obstack_init): Likewise.
* src/getargs.c (debug_flag, defines_flag, locations_flag,
no_lines_flag, no_parser_flag, token_table_flag, yacc_flag,
graph_flag): Likewise.
* src/getargs.h (debug_flag, defines_flag, locations_flag,
no_lines_flag, no_parser_flag, token_table_flag, yacc_flag,
graph_flag): Likewise.
* src/output.c (error_verbose): Likewise.
* src/output.h (error_verbose): Likewise.
* src/reader.c (start_flag, typed): Likewise.
* src/reader.h (typed): Likewise.
* src/getargs.c (LOCATIONS_OPTION): New constant.
(long_options, getargs): Use it.
* src/lalr.c (build_relations): Use bool, not int.
* src/nullable.c (nullable_compute): Likewise.
* src/print.c (print_reductions): Likewise.
* src/tables.c (action_row, pack_vector): Likewise.
* src/muscle_tab.h (MUSCLE_INSERT_BOOL): New macro.
* src/output.c (prepare): Use it.
* src/output.c (token_definitions_output,
symbol_destructors_output, symbol_destructors_output): Use string,
not boolean integer, to keep track of whether to output separator.
* src/print_graph.c (print_core): Likewise.
* src/state.c (state_rule_lookaheads_print): Likewise.
* config/install-sh: Sync from automake 1.7.5.
2003-05-14 Paul Eggert <eggert@twinsun.com> 2003-05-14 Paul Eggert <eggert@twinsun.com>
* src/parse-gram.y (rules_or_grammar_declaration): Require a * src/parse-gram.y (rules_or_grammar_declaration): Require a

View File

@@ -1,5 +1,5 @@
/* Array bitsets. /* Array bitsets.
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -123,14 +123,14 @@ abitset_reset (bitset dst ATTRIBUTE_UNUSED,
/* Test bit BITNO in bitset SRC. */ /* Test bit BITNO in bitset SRC. */
static int static bool
abitset_test (bitset src ATTRIBUTE_UNUSED, abitset_test (bitset src ATTRIBUTE_UNUSED,
bitset_bindex bitno ATTRIBUTE_UNUSED) bitset_bindex bitno ATTRIBUTE_UNUSED)
{ {
/* This should never occur for abitsets since we should always /* This should never occur for abitsets since we should always
hit the cache. */ hit the cache. */
abort (); abort ();
return 0; return false;
} }
@@ -336,7 +336,7 @@ abitset_zero (bitset dst)
} }
static int static bool
abitset_empty_p (bitset dst) abitset_empty_p (bitset dst)
{ {
bitset_windex i; bitset_windex i;
@@ -344,9 +344,9 @@ abitset_empty_p (bitset dst)
for (i = 0; i < dst->b.csize; i++) for (i = 0; i < dst->b.csize; i++)
if (dstp[i]) if (dstp[i])
return 0; return false;
return 1; return true;
} }
@@ -377,7 +377,7 @@ abitset_not (bitset dst, bitset src)
} }
static int static bool
abitset_equal_p (bitset dst, bitset src) abitset_equal_p (bitset dst, bitset src)
{ {
bitset_windex i; bitset_windex i;
@@ -387,12 +387,12 @@ abitset_equal_p (bitset dst, bitset src)
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
if (*srcp++ != *dstp++) if (*srcp++ != *dstp++)
return 0; return false;
return 1; return true;
} }
static int static bool
abitset_subset_p (bitset dst, bitset src) abitset_subset_p (bitset dst, bitset src)
{ {
bitset_windex i; bitset_windex i;
@@ -402,12 +402,12 @@ abitset_subset_p (bitset dst, bitset src)
for (i = 0; i < size; i++, dstp++, srcp++) for (i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp)) if (*dstp != (*srcp | *dstp))
return 0; return false;
return 1; return true;
} }
static int static bool
abitset_disjoint_p (bitset dst, bitset src) abitset_disjoint_p (bitset dst, bitset src)
{ {
bitset_windex i; bitset_windex i;
@@ -417,9 +417,9 @@ abitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
if (*srcp++ & *dstp++) if (*srcp++ & *dstp++)
return 0; return false;
return 1; return true;
} }
@@ -437,11 +437,11 @@ abitset_and (bitset dst, bitset src1, bitset src2)
} }
static int static bool
abitset_and_cmp (bitset dst, bitset src1, bitset src2) abitset_and_cmp (bitset dst, bitset src1, bitset src2)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst); bitset_word *dstp = ABITSET_WORDS (dst);
@@ -453,7 +453,7 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -475,11 +475,11 @@ abitset_andn (bitset dst, bitset src1, bitset src2)
} }
static int static bool
abitset_andn_cmp (bitset dst, bitset src1, bitset src2) abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst); bitset_word *dstp = ABITSET_WORDS (dst);
@@ -491,7 +491,7 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -513,11 +513,11 @@ abitset_or (bitset dst, bitset src1, bitset src2)
} }
static int static bool
abitset_or_cmp (bitset dst, bitset src1, bitset src2) abitset_or_cmp (bitset dst, bitset src1, bitset src2)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst); bitset_word *dstp = ABITSET_WORDS (dst);
@@ -529,7 +529,7 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -551,11 +551,11 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
} }
static int static bool
abitset_xor_cmp (bitset dst, bitset src1, bitset src2) abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *dstp = ABITSET_WORDS (dst); bitset_word *dstp = ABITSET_WORDS (dst);
@@ -567,7 +567,7 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -590,11 +590,11 @@ abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3); bitset_word *src3p = ABITSET_WORDS (src3);
@@ -607,7 +607,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -630,11 +630,11 @@ abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3); bitset_word *src3p = ABITSET_WORDS (src3);
@@ -647,7 +647,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -670,11 +670,11 @@ abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
bitset_windex i; bitset_windex i;
int changed = 0; bool changed = false;
bitset_word *src1p = ABITSET_WORDS (src1); bitset_word *src1p = ABITSET_WORDS (src1);
bitset_word *src2p = ABITSET_WORDS (src2); bitset_word *src2p = ABITSET_WORDS (src2);
bitset_word *src3p = ABITSET_WORDS (src3); bitset_word *src3p = ABITSET_WORDS (src3);
@@ -687,7 +687,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }

View File

@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "libiberty.h" #include "libiberty.h"
#include <stdbool.h>
#include <limits.h> #include <limits.h>
/* Currently we support three flavours of bitsets: /* Currently we support three flavours of bitsets:
@@ -97,36 +98,36 @@ struct bitset_vtable
{ {
void (*set) PARAMS ((bitset, bitset_bindex)); void (*set) PARAMS ((bitset, bitset_bindex));
void (*reset) PARAMS ((bitset, bitset_bindex)); void (*reset) PARAMS ((bitset, bitset_bindex));
int (*toggle) PARAMS ((bitset, bitset_bindex)); bool (*toggle) PARAMS ((bitset, bitset_bindex));
int (*test) PARAMS ((bitset, bitset_bindex)); bool (*test) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*size) PARAMS ((bitset)); bitset_bindex (*size) PARAMS ((bitset));
bitset_bindex (*count) PARAMS ((bitset)); bitset_bindex (*count) PARAMS ((bitset));
int (*empty_p) PARAMS ((bitset)); bool (*empty_p) PARAMS ((bitset));
void (*ones) PARAMS ((bitset)); void (*ones) PARAMS ((bitset));
void (*zero) PARAMS ((bitset)); void (*zero) PARAMS ((bitset));
void (*copy) PARAMS ((bitset, bitset)); void (*copy) PARAMS ((bitset, bitset));
int (*disjoint_p) PARAMS ((bitset, bitset)); bool (*disjoint_p) PARAMS ((bitset, bitset));
int (*equal_p) PARAMS ((bitset, bitset)); bool (*equal_p) PARAMS ((bitset, bitset));
void (*not) PARAMS ((bitset, bitset)); void (*not) PARAMS ((bitset, bitset));
int (*subset_p) PARAMS ((bitset, bitset)); bool (*subset_p) PARAMS ((bitset, bitset));
void (*and) PARAMS ((bitset, bitset, bitset)); void (*and) PARAMS ((bitset, bitset, bitset));
int (*and_cmp) PARAMS ((bitset, bitset, bitset)); bool (*and_cmp) PARAMS ((bitset, bitset, bitset));
void (*andn) PARAMS ((bitset, bitset, bitset)); void (*andn) PARAMS ((bitset, bitset, bitset));
int (*andn_cmp) PARAMS ((bitset, bitset, bitset)); bool (*andn_cmp) PARAMS ((bitset, bitset, bitset));
void (*or) PARAMS ((bitset, bitset, bitset)); void (*or) PARAMS ((bitset, bitset, bitset));
int (*or_cmp) PARAMS ((bitset, bitset, bitset)); bool (*or_cmp) PARAMS ((bitset, bitset, bitset));
void (*xor) PARAMS ((bitset, bitset, bitset)); void (*xor) PARAMS ((bitset, bitset, bitset));
int (*xor_cmp) PARAMS ((bitset, bitset, bitset)); bool (*xor_cmp) PARAMS ((bitset, bitset, bitset));
void (*and_or) PARAMS ((bitset, bitset, bitset, bitset)); void (*and_or) PARAMS ((bitset, bitset, bitset, bitset));
int (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset)); bool (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset)); void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset));
int (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset)); bool (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*or_and) PARAMS ((bitset, bitset, bitset, bitset)); void (*or_and) PARAMS ((bitset, bitset, bitset, bitset));
int (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset)); bool (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset));
bitset_bindex (*list) PARAMS ((bitset, bitset_bindex *, bitset_bindex (*list) PARAMS ((bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *)); bitset_bindex, bitset_bindex *));
@@ -259,22 +260,22 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
/* Private functions for bitset implementations. */ /* Private functions for bitset implementations. */
extern int bitset_toggle_ PARAMS ((bitset, bitset_bindex)); extern bool bitset_toggle_ PARAMS ((bitset, bitset_bindex));
extern bitset_bindex bitset_count_ PARAMS ((bitset)); extern bitset_bindex bitset_count_ PARAMS ((bitset));
extern int bitset_copy_ PARAMS ((bitset, bitset)); extern bool bitset_copy_ PARAMS ((bitset, bitset));
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset)); extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset)); extern bool bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset)); extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset)); extern bool bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset)); extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
extern int bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset)); extern bool bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
#endif /* _BBITSET_H */ #endif /* _BBITSET_H */

View File

@@ -1,5 +1,5 @@
/* General bitsets. /* General bitsets.
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -253,22 +253,22 @@ bitset_last (bitset src)
} }
/* Return non-zero if BITNO in SRC is the only set bit. */ /* Is BITNO in SRC the only set bit? */
int bool
bitset_only_set_p (bitset src, bitset_bindex bitno) bitset_only_set_p (bitset src, bitset_bindex bitno)
{ {
bitset_bindex val[2]; bitset_bindex val[2];
bitset_bindex next = 0; bitset_bindex next = 0;
if (bitset_list (src, val, 2, &next) != 1) if (bitset_list (src, val, 2, &next) != 1)
return 0; return false;
return val[0] == bitno; return val[0] == bitno;
} }
/* Print contents of bitset BSET to FILE. */ /* Print contents of bitset BSET to FILE. */
static void static void
bitset_print (FILE *file, bitset bset, int verbose) bitset_print (FILE *file, bitset bset, bool verbose)
{ {
unsigned int pos; unsigned int pos;
bitset_bindex i; bitset_bindex i;
@@ -300,7 +300,7 @@ bitset_print (FILE *file, bitset bset, int verbose)
void void
bitset_dump (FILE *file, bitset bset) bitset_dump (FILE *file, bitset bset)
{ {
bitset_print (file, bset, 0); bitset_print (file, bset, false);
} }
@@ -315,8 +315,8 @@ bitset_release_memory (void)
/* Toggle bit BITNO in bitset BSET and return non-zero if not set. */ /* Toggle bit BITNO in bitset BSET and the new value of the bit. */
int bool
bitset_toggle_ (bitset bset, bitset_bindex bitno) bitset_toggle_ (bitset bset, bitset_bindex bitno)
{ {
/* This routine is for completeness. It could be optimized if /* This routine is for completeness. It could be optimized if
@@ -324,12 +324,12 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
if (bitset_test (bset, bitno)) if (bitset_test (bset, bitno))
{ {
bitset_reset (bset, bitno); bitset_reset (bset, bitno);
return 0; return false;
} }
else else
{ {
bitset_set (bset, bitno); bitset_set (bset, bitno);
return 1; return true;
} }
} }
@@ -356,10 +356,10 @@ bitset_count_ (bitset src)
} }
/* DST = SRC. Return non-zero if DST != SRC. /* DST = SRC. Return true if DST != SRC.
This is a fallback for the case where SRC and DST are different This is a fallback for the case where SRC and DST are different
bitset types. */ bitset types. */
int bool
bitset_copy_ (bitset dst, bitset src) bitset_copy_ (bitset dst, bitset src)
{ {
bitset_bindex i; bitset_bindex i;
@@ -373,23 +373,23 @@ bitset_copy_ (bitset dst, bitset src)
bitset_set (dst, i); bitset_set (dst, i);
}; };
return 1; return true;
} }
/* This is a fallback for implementations that do not support /* This is a fallback for implementations that do not support
four operand operations. */ four operand operations. */
static inline int static inline bool
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3, bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
enum bitset_ops op) enum bitset_ops op)
{ {
int changed = 0; bool changed = false;
int stats_enabled_save; bool stats_enabled_save;
bitset tmp; bitset tmp;
/* Create temporary bitset. */ /* Create temporary bitset. */
stats_enabled_save = bitset_stats_enabled; stats_enabled_save = bitset_stats_enabled;
bitset_stats_enabled = 0; bitset_stats_enabled = false;
tmp = bitset_alloc (0, bitset_type_get (dst)); tmp = bitset_alloc (0, bitset_type_get (dst));
bitset_stats_enabled = stats_enabled_save; bitset_stats_enabled = stats_enabled_save;
@@ -429,7 +429,7 @@ bitset_and_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if /* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
DST != (SRC1 & SRC2) | SRC3. */ DST != (SRC1 & SRC2) | SRC3. */
int bool
bitset_and_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3) bitset_and_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_AND_OR); return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_AND_OR);
@@ -446,7 +446,7 @@ bitset_andn_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if /* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
DST != (SRC1 & ~SRC2) | SRC3. */ DST != (SRC1 & ~SRC2) | SRC3. */
int bool
bitset_andn_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3) bitset_andn_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_ANDN_OR); return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_ANDN_OR);
@@ -463,7 +463,7 @@ bitset_or_and_ (bitset dst, bitset src1, bitset src2, bitset src3)
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if /* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
DST != (SRC1 | SRC2) & SRC3. */ DST != (SRC1 | SRC2) & SRC3. */
int bool
bitset_or_and_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3) bitset_or_and_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_OR_AND); return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_OR_AND);
@@ -475,5 +475,5 @@ void
debug_bitset (bitset bset) debug_bitset (bitset bset)
{ {
if (bset) if (bset)
bitset_print (stderr, bset, 1); bitset_print (stderr, bset, true);
} }

View File

@@ -160,7 +160,7 @@ bitset_reset (bitset bset, bitset_bindex bitno)
/* Test bit BITNO in bitset BSET. */ /* Test bit BITNO in bitset BSET. */
static inline int static inline bool
bitset_test (bitset bset, bitset_bindex bitno) bitset_test (bitset bset, bitset_bindex bitno)
{ {
bitset_windex windex = bitno / BITSET_WORD_BITS; bitset_windex windex = bitno / BITSET_WORD_BITS;
@@ -290,7 +290,7 @@ extern bitset_bindex bitset_first PARAMS ((bitset));
extern bitset_bindex bitset_last PARAMS ((bitset)); extern bitset_bindex bitset_last PARAMS ((bitset));
/* Return nonzero if this is the only set bit. */ /* Return nonzero if this is the only set bit. */
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex)); extern bool bitset_only_set_p PARAMS ((bitset, bitset_bindex));
/* Dump bitset. */ /* Dump bitset. */
extern void bitset_dump PARAMS ((FILE *, bitset)); extern void bitset_dump PARAMS ((FILE *, bitset));

View File

@@ -100,7 +100,7 @@ struct bitset_stats_info_struct
struct bitset_stats_info_struct bitset_stats_info_data; struct bitset_stats_info_struct bitset_stats_info_data;
struct bitset_stats_info_struct *bitset_stats_info; struct bitset_stats_info_struct *bitset_stats_info;
int bitset_stats_enabled = 0; bool bitset_stats_enabled = false;
/* Print a percentage histogram with message MSG to FILE. */ /* Print a percentage histogram with message MSG to FILE. */
@@ -203,7 +203,7 @@ bitset_stats_print_1 (FILE *file, const char *name,
/* Print all bitset statistics to FILE. */ /* Print all bitset statistics to FILE. */
static void static void
bitset_stats_print (FILE *file, int verbose ATTRIBUTE_UNUSED) bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
{ {
int i; int i;
@@ -227,14 +227,14 @@ bitset_stats_enable (void)
{ {
if (!bitset_stats_info) if (!bitset_stats_info)
bitset_stats_info = &bitset_stats_info_data; bitset_stats_info = &bitset_stats_info_data;
bitset_stats_enabled = 1; bitset_stats_enabled = true;
} }
void void
bitset_stats_disable (void) bitset_stats_disable (void)
{ {
bitset_stats_enabled = 0; bitset_stats_enabled = false;
} }
@@ -298,7 +298,7 @@ bitset_stats_write (const char *filename)
void void
bitset_stats_dump (FILE *file) bitset_stats_dump (FILE *file)
{ {
bitset_stats_print (file, 0); bitset_stats_print (file, false);
} }
@@ -306,7 +306,7 @@ bitset_stats_dump (FILE *file)
void void
debug_bitset_stats (void) debug_bitset_stats (void)
{ {
bitset_stats_print (stderr, 1); bitset_stats_print (stderr, true);
} }
@@ -349,14 +349,14 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
} }
static int static bool
bitset_stats_toggle (bitset src, bitset_bindex bitno) bitset_stats_toggle (bitset src, bitset_bindex bitno)
{ {
return BITSET_TOGGLE_ (src->s.bset, bitno); return BITSET_TOGGLE_ (src->s.bset, bitno);
} }
static int static bool
bitset_stats_test (bitset src, bitset_bindex bitno) bitset_stats_test (bitset src, bitset_bindex bitno)
{ {
bitset bset = src->s.bset; bitset bset = src->s.bset;
@@ -389,7 +389,7 @@ bitset_stats_count (bitset src)
} }
static int static bool
bitset_stats_empty_p (bitset dst) bitset_stats_empty_p (bitset dst)
{ {
return BITSET_EMPTY_P_ (dst->s.bset); return BITSET_EMPTY_P_ (dst->s.bset);
@@ -418,7 +418,7 @@ bitset_stats_copy (bitset dst, bitset src)
} }
static int static bool
bitset_stats_disjoint_p (bitset dst, bitset src) bitset_stats_disjoint_p (bitset dst, bitset src)
{ {
BITSET_CHECK2_ (dst, src); BITSET_CHECK2_ (dst, src);
@@ -426,7 +426,7 @@ bitset_stats_disjoint_p (bitset dst, bitset src)
} }
static int static bool
bitset_stats_equal_p (bitset dst, bitset src) bitset_stats_equal_p (bitset dst, bitset src)
{ {
BITSET_CHECK2_ (dst, src); BITSET_CHECK2_ (dst, src);
@@ -442,7 +442,7 @@ bitset_stats_not (bitset dst, bitset src)
} }
static int static bool
bitset_stats_subset_p (bitset dst, bitset src) bitset_stats_subset_p (bitset dst, bitset src)
{ {
BITSET_CHECK2_ (dst, src); BITSET_CHECK2_ (dst, src);
@@ -458,7 +458,7 @@ bitset_stats_and (bitset dst, bitset src1, bitset src2)
} }
static int static bool
bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2) bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2)
{ {
BITSET_CHECK3_ (dst, src1, src2); BITSET_CHECK3_ (dst, src1, src2);
@@ -474,7 +474,7 @@ bitset_stats_andn (bitset dst, bitset src1, bitset src2)
} }
static int static bool
bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2) bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2)
{ {
BITSET_CHECK3_ (dst, src1, src2); BITSET_CHECK3_ (dst, src1, src2);
@@ -490,7 +490,7 @@ bitset_stats_or (bitset dst, bitset src1, bitset src2)
} }
static int static bool
bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2) bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2)
{ {
BITSET_CHECK3_ (dst, src1, src2); BITSET_CHECK3_ (dst, src1, src2);
@@ -506,7 +506,7 @@ bitset_stats_xor (bitset dst, bitset src1, bitset src2)
} }
static int static bool
bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2) bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2)
{ {
BITSET_CHECK3_ (dst, src1, src2); BITSET_CHECK3_ (dst, src1, src2);
@@ -523,7 +523,7 @@ bitset_stats_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
bitset_stats_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) bitset_stats_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
BITSET_CHECK4_ (dst, src1, src2, src3); BITSET_CHECK4_ (dst, src1, src2, src3);
@@ -541,7 +541,7 @@ bitset_stats_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
bitset_stats_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) bitset_stats_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
BITSET_CHECK4_ (dst, src1, src2, src3); BITSET_CHECK4_ (dst, src1, src2, src3);
@@ -559,7 +559,7 @@ bitset_stats_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
} }
static int static bool
bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{ {
BITSET_CHECK4_ (dst, src1, src2, src3); BITSET_CHECK4_ (dst, src1, src2, src3);

View File

@@ -1,5 +1,5 @@
/* Functions to support bitset statistics. /* Functions to support bitset statistics.
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bbitset.h" #include "bbitset.h"
extern int bitset_stats_enabled; extern bool bitset_stats_enabled;
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset)); extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));

View File

@@ -1,5 +1,5 @@
/* Functions to support expandable bitsets. /* Functions to support expandable bitsets.
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -88,7 +88,7 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */ /* Obstack to allocate bitset elements from. */
static struct obstack ebitset_obstack; static struct obstack ebitset_obstack;
static int ebitset_obstack_init = 0; static bool ebitset_obstack_init = false;
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
#define EBITSET_ELTS(BSET) ((BSET)->e.elts) #define EBITSET_ELTS(BSET) ((BSET)->e.elts)
@@ -154,7 +154,7 @@ ebitset_elt_alloc (void)
{ {
if (!ebitset_obstack_init) if (!ebitset_obstack_init)
{ {
ebitset_obstack_init = 1; ebitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */ /* Let particular systems override the size of a chunk. */
@@ -242,17 +242,17 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
} }
/* Return nonzero if all bits in an element are zero. */ /* Are all bits in an element zero? */
static inline int static inline bool
ebitset_elt_zero_p (ebitset_elt *elt) ebitset_elt_zero_p (ebitset_elt *elt)
{ {
int i; int i;
for (i = 0; i < EBITSET_ELT_WORDS; i++) for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (elt)[i]) if (EBITSET_WORDS (elt)[i])
return 0; return false;
return 1; return true;
} }
@@ -402,7 +402,7 @@ ebitset_zero (bitset bset)
} }
static inline int static inline bool
ebitset_equal_p (bitset dst, bitset src) ebitset_equal_p (bitset dst, bitset src)
{ {
ebitset_elts *selts; ebitset_elts *selts;
@@ -410,13 +410,13 @@ ebitset_equal_p (bitset dst, bitset src)
bitset_windex j; bitset_windex j;
if (src == dst) if (src == dst)
return 1; return true;
ebitset_weed (dst); ebitset_weed (dst);
ebitset_weed (src); ebitset_weed (src);
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst)) if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
return 0; return false;
selts = EBITSET_ELTS (src); selts = EBITSET_ELTS (src);
delts = EBITSET_ELTS (dst); delts = EBITSET_ELTS (dst);
@@ -430,13 +430,13 @@ ebitset_equal_p (bitset dst, bitset src)
if (!selt && !delt) if (!selt && !delt)
continue; continue;
if ((selt && !delt) || (!selt && delt)) if ((selt && !delt) || (!selt && delt))
return 0; return false;
for (i = 0; i < EBITSET_ELT_WORDS; i++) for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i]) if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
return 0; return false;
} }
return 1; return true;
} }
@@ -476,13 +476,13 @@ ebitset_copy_ (bitset dst, bitset src)
} }
/* Copy bits from bitset SRC to bitset DST. Return non-zero if /* Copy bits from bitset SRC to bitset DST. Return true if
bitsets different. */ bitsets different. */
static inline int static inline bool
ebitset_copy_cmp (bitset dst, bitset src) ebitset_copy_cmp (bitset dst, bitset src)
{ {
if (src == dst) if (src == dst)
return 0; return false;
if (EBITSET_ZERO_P (dst)) if (EBITSET_ZERO_P (dst))
{ {
@@ -491,10 +491,10 @@ ebitset_copy_cmp (bitset dst, bitset src)
} }
if (ebitset_equal_p (dst, src)) if (ebitset_equal_p (dst, src))
return 0; return false;
ebitset_copy_ (dst, src); ebitset_copy_ (dst, src);
return 1; return true;
} }
@@ -539,16 +539,15 @@ ebitset_reset (bitset dst, bitset_bindex bitno)
/* Test bit BITNO in bitset SRC. */ /* Test bit BITNO in bitset SRC. */
static int static bool
ebitset_test (bitset src, bitset_bindex bitno) ebitset_test (bitset src, bitset_bindex bitno)
{ {
bitset_windex windex = bitno / BITSET_WORD_BITS; bitset_windex windex = bitno / BITSET_WORD_BITS;
if (!ebitset_elt_find (src, windex, EBITSET_FIND)) return (ebitset_elt_find (src, windex, EBITSET_FIND)
return 0; && ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
return (src->b. & 1));
cdata[windex - src->b.cindex] >> (bitno % BITSET_WORD_BITS)) & 1;
} }
@@ -808,7 +807,7 @@ ebitset_ones (bitset dst)
} }
static int static bool
ebitset_empty_p (bitset dst) ebitset_empty_p (bitset dst)
{ {
return !ebitset_weed (dst); return !ebitset_weed (dst);
@@ -839,8 +838,8 @@ ebitset_not (bitset dst, bitset src)
} }
/* Return 1 if DST == DST | SRC. */ /* Is DST == DST | SRC? */
static int static bool
ebitset_subset_p (bitset dst, bitset src) ebitset_subset_p (bitset dst, bitset src)
{ {
bitset_windex j; bitset_windex j;
@@ -875,14 +874,14 @@ ebitset_subset_p (bitset dst, bitset src)
for (i = 0; i < EBITSET_ELT_WORDS; i++) for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (delt)[i] if (EBITSET_WORDS (delt)[i]
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i])) != (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
return 0; return false;
} }
return 1; return true;
} }
/* Return 1 if DST & SRC == 0. */ /* Is DST & SRC == 0? */
static int static bool
ebitset_disjoint_p (bitset dst, bitset src) ebitset_disjoint_p (bitset dst, bitset src)
{ {
bitset_windex j; bitset_windex j;
@@ -911,14 +910,14 @@ ebitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < EBITSET_ELT_WORDS; i++) for (i = 0; i < EBITSET_ELT_WORDS; i++)
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i])) if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
return 0; return false;
} }
return 1; return true;
} }
static int static bool
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{ {
bitset_windex ssize1; bitset_windex ssize1;
@@ -931,7 +930,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
bitset_word *srcp1; bitset_word *srcp1;
bitset_word *srcp2; bitset_word *srcp2;
bitset_word *dstp; bitset_word *dstp;
int changed = 0; bool changed = false;
unsigned int i; unsigned int i;
bitset_windex j; bitset_windex j;
@@ -963,7 +962,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{ {
if (delt) if (delt)
{ {
changed = 1; changed = true;
ebitset_elt_remove (dst, j); ebitset_elt_remove (dst, j);
} }
continue; continue;
@@ -990,7 +989,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1003,7 +1002,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1016,7 +1015,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1029,7 +1028,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1054,7 +1053,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{ {
ebitset_elt *delt; ebitset_elt *delt;
changed = 1; changed = true;
delt = delts[j]; delt = delts[j];
@@ -1067,10 +1066,10 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
} }
static int static bool
ebitset_and_cmp (bitset dst, bitset src1, bitset src2) ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
{ {
int changed; bool changed;
if (EBITSET_ZERO_P (src2)) if (EBITSET_ZERO_P (src2))
{ {
@@ -1097,10 +1096,10 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
} }
static int static bool
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2) ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{ {
int changed; bool changed;
if (EBITSET_ZERO_P (src2)) if (EBITSET_ZERO_P (src2))
{ {
@@ -1124,7 +1123,7 @@ ebitset_andn (bitset dst, bitset src1, bitset src2)
} }
static int static bool
ebitset_or_cmp (bitset dst, bitset src1, bitset src2) ebitset_or_cmp (bitset dst, bitset src1, bitset src2)
{ {
if (EBITSET_ZERO_P (src2)) if (EBITSET_ZERO_P (src2))
@@ -1146,7 +1145,7 @@ ebitset_or (bitset dst, bitset src1, bitset src2)
} }
static int static bool
ebitset_xor_cmp (bitset dst, bitset src1, bitset src2) ebitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{ {
if (EBITSET_ZERO_P (src2)) if (EBITSET_ZERO_P (src2))
@@ -1253,7 +1252,7 @@ ebitset_release_memory (void)
ebitset_free_list = 0; ebitset_free_list = 0;
if (ebitset_obstack_init) if (ebitset_obstack_init)
{ {
ebitset_obstack_init = 0; ebitset_obstack_init = false;
obstack_free (&ebitset_obstack, NULL); obstack_free (&ebitset_obstack, NULL);
} }
} }

View File

@@ -1,5 +1,5 @@
/* Functions to support link list bitsets. /* Functions to support link list bitsets.
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -71,7 +71,7 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */ /* Obstack to allocate bitset elements from. */
static struct obstack lbitset_obstack; static struct obstack lbitset_obstack;
static int lbitset_obstack_init = 0; static bool lbitset_obstack_init = false;
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */ static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset PARAMS ((bitset)); extern void debug_lbitset PARAMS ((bitset));
@@ -99,7 +99,7 @@ lbitset_elt_alloc (void)
{ {
if (!lbitset_obstack_init) if (!lbitset_obstack_init)
{ {
lbitset_obstack_init = 1; lbitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */ /* Let particular systems override the size of a chunk. */
@@ -236,17 +236,17 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
} }
/* Return nonzero if all bits in an element are zero. */ /* Are all bits in an element zero? */
static inline int static inline bool
lbitset_elt_zero_p (lbitset_elt *elt) lbitset_elt_zero_p (lbitset_elt *elt)
{ {
int i; int i;
for (i = 0; i < LBITSET_ELT_WORDS; i++) for (i = 0; i < LBITSET_ELT_WORDS; i++)
if (elt->words[i]) if (elt->words[i])
return 0; return false;
return 1; return true;
} }
@@ -412,8 +412,8 @@ lbitset_zero (bitset bset)
} }
/* Return 1 if DST == SRC. */ /* Is DST == SRC? */
static inline int static inline bool
lbitset_equal_p (bitset dst, bitset src) lbitset_equal_p (bitset dst, bitset src)
{ {
lbitset_elt *selt; lbitset_elt *selt;
@@ -421,7 +421,7 @@ lbitset_equal_p (bitset dst, bitset src)
int j; int j;
if (src == dst) if (src == dst)
return 1; return true;
lbitset_weed (src); lbitset_weed (src);
lbitset_weed (dst); lbitset_weed (dst);
@@ -429,11 +429,11 @@ lbitset_equal_p (bitset dst, bitset src)
selt && delt; selt = selt->next, delt = delt->next) selt && delt; selt = selt->next, delt = delt->next)
{ {
if (selt->index != delt->index) if (selt->index != delt->index)
return 0; return false;
for (j = 0; j < LBITSET_ELT_WORDS; j++) for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != selt->words[j]) if (delt->words[j] != selt->words[j])
return 0; return false;
} }
return !selt && !delt; return !selt && !delt;
} }
@@ -480,13 +480,13 @@ lbitset_copy (bitset dst, bitset src)
} }
/* Copy bits from bitset SRC to bitset DST. Return non-zero if /* Copy bits from bitset SRC to bitset DST. Return true if
bitsets different. */ bitsets different. */
static inline int static inline bool
lbitset_copy_cmp (bitset dst, bitset src) lbitset_copy_cmp (bitset dst, bitset src)
{ {
if (src == dst) if (src == dst)
return 0; return false;
if (!LBITSET_HEAD (dst)) if (!LBITSET_HEAD (dst))
{ {
@@ -495,10 +495,10 @@ lbitset_copy_cmp (bitset dst, bitset src)
} }
if (lbitset_equal_p (dst, src)) if (lbitset_equal_p (dst, src))
return 0; return false;
lbitset_copy (dst, src); lbitset_copy (dst, src);
return 1; return true;
} }
@@ -547,16 +547,15 @@ lbitset_reset (bitset dst, bitset_bindex bitno)
/* Test bit BITNO in bitset SRC. */ /* Test bit BITNO in bitset SRC. */
static int static bool
lbitset_test (bitset src, bitset_bindex bitno) lbitset_test (bitset src, bitset_bindex bitno)
{ {
bitset_windex windex = bitno / BITSET_WORD_BITS; bitset_windex windex = bitno / BITSET_WORD_BITS;
if (!lbitset_elt_find (src, windex, LBITSET_FIND)) return (lbitset_elt_find (src, windex, LBITSET_FIND)
return 0; && ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
return (src->b.cdata[windex - src->b.cindex] & 1));
>> (bitno % BITSET_WORD_BITS)) & 1;
} }
@@ -865,13 +864,11 @@ lbitset_list (bitset bset, bitset_bindex *list,
} }
static int static bool
lbitset_empty_p (bitset dst) lbitset_empty_p (bitset dst)
{ {
lbitset_weed (dst); lbitset_weed (dst);
if (LBITSET_HEAD (dst)) return !LBITSET_HEAD (dst);
return 0;
return 1;
} }
@@ -934,8 +931,8 @@ lbitset_not (bitset dst, bitset src)
} }
/* Return 1 if DST == DST | SRC. */ /* Is DST == DST | SRC? */
static int static bool
lbitset_subset_p (bitset dst, bitset src) lbitset_subset_p (bitset dst, bitset src)
{ {
lbitset_elt *selt; lbitset_elt *selt;
@@ -965,14 +962,14 @@ lbitset_subset_p (bitset dst, bitset src)
for (j = 0; j < LBITSET_ELT_WORDS; j++) for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != (selt->words[j] | delt->words[j])) if (delt->words[j] != (selt->words[j] | delt->words[j]))
return 0; return false;
} }
return 1; return true;
} }
/* Return 1 if DST & SRC == 0. */ /* Is DST & SRC == 0? */
static int static bool
lbitset_disjoint_p (bitset dst, bitset src) lbitset_disjoint_p (bitset dst, bitset src)
{ {
lbitset_elt *selt; lbitset_elt *selt;
@@ -1001,13 +998,13 @@ lbitset_disjoint_p (bitset dst, bitset src)
for (j = 0; j < LBITSET_ELT_WORDS; j++) for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (selt->words[j] & delt->words[j]) if (selt->words[j] & delt->words[j])
return 0; return false;
} }
return 1; return true;
} }
static int static bool
lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{ {
lbitset_elt *selt1 = LBITSET_HEAD (src1); lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1022,7 +1019,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
bitset_word *srcp1; bitset_word *srcp1;
bitset_word *srcp2; bitset_word *srcp2;
bitset_word *dstp; bitset_word *dstp;
int changed = 0; bool changed = false;
unsigned int i; unsigned int i;
LBITSET_HEAD (dst) = 0; LBITSET_HEAD (dst) = 0;
@@ -1066,7 +1063,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
elements that we've skipped. */ elements that we've skipped. */
while (delt && delt->index < windex) while (delt && delt->index < windex)
{ {
changed = 1; changed = true;
dtmp = delt; dtmp = delt;
delt = delt->next; delt = delt->next;
lbitset_elt_free (dtmp); lbitset_elt_free (dtmp);
@@ -1093,7 +1090,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1106,7 +1103,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1119,7 +1116,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1132,7 +1129,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (*dstp != tmp) if (*dstp != tmp)
{ {
changed = 1; changed = true;
*dstp = tmp; *dstp = tmp;
} }
} }
@@ -1157,7 +1154,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
/* If we have elements of DST left over, free them all. */ /* If we have elements of DST left over, free them all. */
if (delt) if (delt)
{ {
changed = 1; changed = true;
lbitset_prune (dst, delt); lbitset_prune (dst, delt);
} }
@@ -1165,12 +1162,12 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
} }
static int static bool
lbitset_and_cmp (bitset dst, bitset src1, bitset src2) lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{ {
lbitset_elt *selt1 = LBITSET_HEAD (src1); lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2); lbitset_elt *selt2 = LBITSET_HEAD (src2);
int changed; bool changed;
if (!selt2) if (!selt2)
{ {
@@ -1197,12 +1194,12 @@ lbitset_and (bitset dst, bitset src1, bitset src2)
} }
static int static bool
lbitset_andn_cmp (bitset dst, bitset src1, bitset src2) lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{ {
lbitset_elt *selt1 = LBITSET_HEAD (src1); lbitset_elt *selt1 = LBITSET_HEAD (src1);
lbitset_elt *selt2 = LBITSET_HEAD (src2); lbitset_elt *selt2 = LBITSET_HEAD (src2);
int changed; bool changed;
if (!selt2) if (!selt2)
{ {
@@ -1226,7 +1223,7 @@ lbitset_andn (bitset dst, bitset src1, bitset src2)
} }
static int static bool
lbitset_or_cmp (bitset dst, bitset src1, bitset src2) lbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{ {
lbitset_elt *selt1 = LBITSET_HEAD (src1); lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1251,7 +1248,7 @@ lbitset_or (bitset dst, bitset src1, bitset src2)
} }
static int static bool
lbitset_xor_cmp (bitset dst, bitset src1, bitset src2) lbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{ {
lbitset_elt *selt1 = LBITSET_HEAD (src1); lbitset_elt *selt1 = LBITSET_HEAD (src1);
@@ -1337,7 +1334,7 @@ lbitset_release_memory (void)
lbitset_free_list = 0; lbitset_free_list = 0;
if (lbitset_obstack_init) if (lbitset_obstack_init)
{ {
lbitset_obstack_init = 0; lbitset_obstack_init = false;
obstack_free (&lbitset_obstack, NULL); obstack_free (&lbitset_obstack, NULL);
} }
} }

View File

@@ -365,7 +365,7 @@ count_sr_conflicts (state *s)
+`----------------------------------------------------------------*/ +`----------------------------------------------------------------*/
static int static int
count_rr_conflicts (state *s, int one_per_token) count_rr_conflicts (state *s, bool one_per_token)
{ {
int i; int i;
reductions *reds = s->reductions; reductions *reds = s->reductions;
@@ -463,7 +463,7 @@ conflicts_print (void)
/* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is /* Is the number of SR conflicts OK? Either EXPECTED_CONFLICTS is
not set, and then we want 0 SR, or else it is specified, in which not set, and then we want 0 SR, or else it is specified, in which
case we want equality. */ case we want equality. */
int src_ok = 0; bool src_ok = false;
int src_total = 0; int src_total = 0;
int rrc_total = 0; int rrc_total = 0;

View File

@@ -43,15 +43,15 @@
#include "getargs.h" #include "getargs.h"
#include "uniqstr.h" #include "uniqstr.h"
int debug_flag = 0; bool debug_flag;
int defines_flag = 0; bool defines_flag;
int locations_flag = 0; bool locations_flag;
int no_lines_flag = 0; bool no_lines_flag;
int no_parser_flag = 0; bool no_parser_flag;
int report_flag = report_none; int report_flag = report_none;
int token_table_flag = 0; bool token_table_flag;
int yacc_flag = 0; /* for -y */ bool yacc_flag; /* for -y */
int graph_flag = 0; bool graph_flag;
int trace_flag = trace_none; int trace_flag = trace_none;
bool nondeterministic_parser = false; bool nondeterministic_parser = false;
@@ -284,6 +284,12 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
/* Shorts options. */ /* Shorts options. */
const char *short_options = "yvegdhr:ltknVo:b:p:S:T::"; const char *short_options = "yvegdhr:ltknVo:b:p:S:T::";
/* Values for long options that do not have single-letter equivalents. */
enum
{
LOCATIONS_OPTION = CHAR_MAX + 1
};
static struct option const long_options[] = static struct option const long_options[] =
{ {
/* Operation modes. */ /* Operation modes. */
@@ -314,7 +320,7 @@ static struct option const long_options[] =
/* Parser. */ /* Parser. */
{ "debug", no_argument, 0, 't' }, { "debug", no_argument, 0, 't' },
{ "locations", no_argument, &locations_flag, 1 }, { "locations", no_argument, 0, LOCATIONS_OPTION },
{ "no-lines", no_argument, 0, 'l' }, { "no-lines", no_argument, 0, 'l' },
{ "no-parser", no_argument, 0, 'n' }, { "no-parser", no_argument, 0, 'n' },
{ "raw", no_argument, 0, 0 }, { "raw", no_argument, 0, 0 },
@@ -346,7 +352,7 @@ getargs (int argc, char *argv[])
break; break;
case 'y': case 'y':
yacc_flag = 1; yacc_flag = true;
break; break;
case 'h': case 'h':
@@ -358,7 +364,7 @@ getargs (int argc, char *argv[])
case 'g': case 'g':
/* Here, the -g and --graph=FILE options are differentiated. */ /* Here, the -g and --graph=FILE options are differentiated. */
graph_flag = 1; graph_flag = true;
if (optarg) if (optarg)
spec_graph_file = AS_FILE_NAME (optarg); spec_graph_file = AS_FILE_NAME (optarg);
break; break;
@@ -377,25 +383,29 @@ getargs (int argc, char *argv[])
case 'd': case 'd':
/* Here, the -d and --defines options are differentiated. */ /* Here, the -d and --defines options are differentiated. */
defines_flag = 1; defines_flag = true;
if (optarg) if (optarg)
spec_defines_file = AS_FILE_NAME (optarg); spec_defines_file = AS_FILE_NAME (optarg);
break; break;
case 'l': case 'l':
no_lines_flag = 1; no_lines_flag = true;
break;
case LOCATIONS_OPTION:
locations_flag = true;
break; break;
case 'k': case 'k':
token_table_flag = 1; token_table_flag = true;
break; break;
case 'n': case 'n':
no_parser_flag = 1; no_parser_flag = true;
break; break;
case 't': case 't':
debug_flag = 1; debug_flag = true;
break; break;
case 'o': case 'o':

View File

@@ -26,14 +26,14 @@
extern const char *skeleton; /* for -S */ extern const char *skeleton; /* for -S */
extern const char *include; /* for -I */ extern const char *include; /* for -I */
extern int debug_flag; /* for -t */ extern bool debug_flag; /* for -t */
extern int defines_flag; /* for -d */ extern bool defines_flag; /* for -d */
extern int locations_flag; extern bool locations_flag;
extern int no_lines_flag; /* for -l */ extern bool no_lines_flag; /* for -l */
extern int no_parser_flag; /* for -n */ extern bool no_parser_flag; /* for -n */
extern int token_table_flag; /* for -k */ extern bool token_table_flag; /* for -k */
extern int graph_flag; /* for -g */ extern bool graph_flag; /* for -g */
extern int yacc_flag; /* for -y */ extern bool yacc_flag; /* for -y */
/* GLR_PARSER is true if the input file says to use the GLR /* GLR_PARSER is true if the input file says to use the GLR
(Generalized LR) parser, and to output some additional information (Generalized LR) parser, and to output some additional information

View File

@@ -1,6 +1,6 @@
/* Compute look-ahead criteria for Bison. /* Compute look-ahead criteria for Bison.
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -239,7 +239,7 @@ build_relations (void)
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++) for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
{ {
int done; bool done;
int length = 1; int length = 1;
item_number *rp; item_number *rp;
state *s = states[from_state[i]]; state *s = states[from_state[i]];
@@ -256,10 +256,10 @@ build_relations (void)
add_lookback_edge (s, *rulep, i); add_lookback_edge (s, *rulep, i);
length--; length--;
done = 0; done = false;
while (!done) while (!done)
{ {
done = 1; done = true;
rp--; rp--;
/* JF added rp>=ritem && I hope to god its right! */ /* JF added rp>=ritem && I hope to god its right! */
if (rp >= ritem && ISVAR (*rp)) if (rp >= ritem && ISVAR (*rp))
@@ -268,7 +268,7 @@ build_relations (void)
edge[nedges++] = map_goto (states1[--length], edge[nedges++] = map_goto (states1[--length],
item_number_as_symbol_number (*rp)); item_number_as_symbol_number (*rp));
if (nullable[*rp - ntokens]) if (nullable[*rp - ntokens])
done = 0; done = false;
} }
} }
} }

View File

@@ -30,6 +30,12 @@ void muscle_free (void);
/* An obstack dedicated to receive muscle keys and values. */ /* An obstack dedicated to receive muscle keys and values. */
extern struct obstack muscle_obstack; extern struct obstack muscle_obstack;
#define MUSCLE_INSERT_BOOL(Key, Value) \
{ \
int v = Value; \
MUSCLE_INSERT_INT (Key, v); \
}
#define MUSCLE_INSERT_INT(Key, Value) \ #define MUSCLE_INSERT_INT(Key, Value) \
{ \ { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \ obstack_fgrow1 (&muscle_obstack, "%d", Value); \

View File

@@ -83,10 +83,10 @@ nullable_compute (void)
{ {
/* This rule has a non empty RHS. */ /* This rule has a non empty RHS. */
item_number *rp = NULL; item_number *rp = NULL;
int any_tokens = 0; bool any_tokens = false;
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp) for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
if (ISTOKEN (*rp)) if (ISTOKEN (*rp))
any_tokens = 1; any_tokens = true;
/* This rule has only nonterminals: schedule it for the second /* This rule has only nonterminals: schedule it for the second
pass. */ pass. */
@@ -108,7 +108,7 @@ nullable_compute (void)
if (rules_ruleno->useful if (rules_ruleno->useful
&& ! nullable[rules_ruleno->lhs->number - ntokens]) && ! nullable[rules_ruleno->lhs->number - ntokens])
{ {
nullable[rules_ruleno->lhs->number - ntokens] = 1; nullable[rules_ruleno->lhs->number - ntokens] = true;
*s2++ = rules_ruleno->lhs->number; *s2++ = rules_ruleno->lhs->number;
} }
} }
@@ -121,7 +121,7 @@ nullable_compute (void)
if (--rcount[r->number] == 0) if (--rcount[r->number] == 0)
if (r->useful && ! nullable[r->lhs->number - ntokens]) if (r->useful && ! nullable[r->lhs->number - ntokens])
{ {
nullable[r->lhs->number - ntokens] = 1; nullable[r->lhs->number - ntokens] = true;
*s2++ = r->lhs->number; *s2++ = r->lhs->number;
} }
} }

View File

@@ -45,7 +45,7 @@ void scan_skel (FILE *);
static struct obstack format_obstack; static struct obstack format_obstack;
int error_verbose = 0; bool error_verbose = false;
@@ -341,7 +341,7 @@ static void
token_definitions_output (FILE *out) token_definitions_output (FILE *out)
{ {
int i; int i;
int first = 1; char const *sep = "";
fputs ("m4_define([b4_tokens], \n[", out); fputs ("m4_define([b4_tokens], \n[", out);
for (i = 0; i < ntokens; ++i) for (i = 0; i < ntokens; ++i)
@@ -376,9 +376,8 @@ token_definitions_output (FILE *out)
continue; continue;
fprintf (out, "%s[[[%s]], [%d]]", fprintf (out, "%s[[[%s]], [%d]]",
first ? "" : ",\n", sym->tag, number); sep, sym->tag, number);
sep = ",\n";
first = 0;
} }
fputs ("])\n\n", out); fputs ("])\n\n", out);
} }
@@ -392,7 +391,7 @@ static void
symbol_destructors_output (FILE *out) symbol_destructors_output (FILE *out)
{ {
int i; int i;
int first = 1; char const *sep = "";
fputs ("m4_define([b4_symbol_destructors], \n[", out); fputs ("m4_define([b4_symbol_destructors], \n[", out);
for (i = 0; i < nsyms; ++i) for (i = 0; i < nsyms; ++i)
@@ -403,8 +402,8 @@ symbol_destructors_output (FILE *out)
/* Filename, lineno, /* Filename, lineno,
Symbol-name, Symbol-number, Symbol-name, Symbol-number,
destructor, typename. */ destructor, typename. */
fprintf (out, "%s[", fprintf (out, "%s[", sep);
first ? "" : ",\n"); sep = ",\n";
escaped_file_name_output (out, sym->destructor_location.start.file); escaped_file_name_output (out, sym->destructor_location.start.file);
fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]", fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
sym->destructor_location.start.line, sym->destructor_location.start.line,
@@ -412,8 +411,6 @@ symbol_destructors_output (FILE *out)
sym->number, sym->number,
sym->destructor, sym->destructor,
sym->type_name); sym->type_name);
first = 0;
} }
fputs ("])\n\n", out); fputs ("])\n\n", out);
} }
@@ -427,7 +424,7 @@ static void
symbol_printers_output (FILE *out) symbol_printers_output (FILE *out)
{ {
int i; int i;
int first = 1; char const *sep = "";
fputs ("m4_define([b4_symbol_printers], \n[", out); fputs ("m4_define([b4_symbol_printers], \n[", out);
for (i = 0; i < nsyms; ++i) for (i = 0; i < nsyms; ++i)
@@ -438,8 +435,8 @@ symbol_printers_output (FILE *out)
/* Filename, lineno, /* Filename, lineno,
Symbol-name, Symbol-number, Symbol-name, Symbol-number,
printer, typename. */ printer, typename. */
fprintf (out, "%s[", fprintf (out, "%s[", sep);
first ? "" : ",\n"); sep = ",\n";
escaped_file_name_output (out, sym->printer_location.start.file); escaped_file_name_output (out, sym->printer_location.start.file);
fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]", fprintf (out, ", [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
sym->printer_location.start.line, sym->printer_location.start.line,
@@ -447,8 +444,6 @@ symbol_printers_output (FILE *out)
sym->number, sym->number,
sym->printer, sym->printer,
sym->type_name); sym->type_name);
first = 0;
} }
fputs ("])\n\n", out); fputs ("])\n\n", out);
} }
@@ -595,12 +590,12 @@ static void
prepare (void) prepare (void)
{ {
/* Flags. */ /* Flags. */
MUSCLE_INSERT_INT ("debug", debug_flag); MUSCLE_INSERT_BOOL ("debug", debug_flag);
MUSCLE_INSERT_INT ("defines_flag", defines_flag); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
MUSCLE_INSERT_INT ("error_verbose", error_verbose); MUSCLE_INSERT_BOOL ("error_verbose", error_verbose);
MUSCLE_INSERT_INT ("locations_flag", locations_flag); MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
MUSCLE_INSERT_INT ("pure", pure_parser); MUSCLE_INSERT_BOOL ("pure", pure_parser);
MUSCLE_INSERT_INT ("synclines_flag", !no_lines_flag); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
/* File names. */ /* File names. */
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");

View File

@@ -1,5 +1,5 @@
/* Output the generated parsing program for bison, /* Output the generated parsing program for bison,
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -21,7 +21,7 @@
#ifndef OUTPUT_H_ #ifndef OUTPUT_H_
# define OUTPUT_H_ # define OUTPUT_H_
extern int error_verbose; extern bool error_verbose;
/* Output the parsing tables and the parser code to FTABLE. */ /* Output the parsing tables and the parser code to FTABLE. */
void output (void); void output (void);

View File

@@ -175,26 +175,26 @@ declarations:
declaration: declaration:
grammar_declaration grammar_declaration
| PROLOGUE { prologue_augment ($1, @1); } | PROLOGUE { prologue_augment ($1, @1); }
| "%debug" { debug_flag = 1; } | "%debug" { debug_flag = true; }
| "%define" string_content string_content { muscle_insert ($2, $3); } | "%define" string_content string_content { muscle_insert ($2, $3); }
| "%defines" { defines_flag = 1; } | "%defines" { defines_flag = true; }
| "%error-verbose" { error_verbose = 1; } | "%error-verbose" { error_verbose = true; }
| "%expect" INT { expected_conflicts = $2; } | "%expect" INT { expected_conflicts = $2; }
| "%file-prefix" "=" string_content { spec_file_prefix = $3; } | "%file-prefix" "=" string_content { spec_file_prefix = $3; }
| "%glr-parser" { nondeterministic_parser = true; | "%glr-parser" { nondeterministic_parser = true;
glr_parser = true; } glr_parser = true; }
| "%lex-param {...}" { add_param ("lex_param", $1, @1); } | "%lex-param {...}" { add_param ("lex_param", $1, @1); }
| "%locations" { locations_flag = 1; } | "%locations" { locations_flag = true; }
| "%name-prefix" "=" string_content { spec_name_prefix = $3; } | "%name-prefix" "=" string_content { spec_name_prefix = $3; }
| "%no-lines" { no_lines_flag = 1; } | "%no-lines" { no_lines_flag = true; }
| "%nondeterministic-parser" { nondeterministic_parser = true; } | "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" "=" string_content { spec_outfile = $3; } | "%output" "=" string_content { spec_outfile = $3; }
| "%parse-param {...}" { add_param ("parse_param", $1, @1); } | "%parse-param {...}" { add_param ("parse_param", $1, @1); }
| "%pure-parser" { pure_parser = true; } | "%pure-parser" { pure_parser = true; }
| "%skeleton" string_content { skeleton = $2; } | "%skeleton" string_content { skeleton = $2; }
| "%token-table" { token_table_flag = 1; } | "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag = report_states; } | "%verbose" { report_flag = report_states; }
| "%yacc" { yacc_flag = 1; } | "%yacc" { yacc_flag = true; }
| ";" | ";"
; ;
@@ -207,7 +207,7 @@ grammar_declaration:
} }
| "%union {...}" | "%union {...}"
{ {
typed = 1; typed = true;
MUSCLE_INSERT_INT ("stype_line", @1.start.line); MUSCLE_INSERT_INT ("stype_line", @1.start.line);
muscle_insert ("stype", $1); muscle_insert ("stype", $1);
} }

View File

@@ -327,16 +327,16 @@ print_reductions (FILE *out, state *s)
if (reds->lookaheads) if (reds->lookaheads)
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ {
int count = bitset_test (shiftset, i); bool count = bitset_test (shiftset, i);
for (j = 0; j < reds->num; ++j) for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i)) if (bitset_test (reds->lookaheads[j], i))
{ {
if (count == 0) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_rule)
max_length (&width, symbols[i]->tag); max_length (&width, symbols[i]->tag);
count++; count = true;
} }
else else
{ {
@@ -356,21 +356,21 @@ print_reductions (FILE *out, state *s)
if (reds->lookaheads) if (reds->lookaheads)
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ {
int defaulted = 0; bool defaulted = false;
int count = bitset_test (shiftset, i); bool count = bitset_test (shiftset, i);
for (j = 0; j < reds->num; ++j) for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i)) if (bitset_test (reds->lookaheads[j], i))
{ {
if (count == 0) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_rule)
print_reduction (out, width, print_reduction (out, width,
symbols[i]->tag, symbols[i]->tag,
reds->rules[j], true); reds->rules[j], true);
else else
defaulted = 1; defaulted = true;
count++; count = true;
} }
else else
{ {
@@ -378,7 +378,7 @@ print_reductions (FILE *out, state *s)
print_reduction (out, width, print_reduction (out, width,
symbols[i]->tag, symbols[i]->tag,
default_rule, true); default_rule, true);
defaulted = 0; defaulted = false;
print_reduction (out, width, print_reduction (out, width,
symbols[i]->tag, symbols[i]->tag,
reds->rules[j], false); reds->rules[j], false);

View File

@@ -1,6 +1,6 @@
/* Output a VCG description on generated parser, for Bison, /* Output a VCG description on generated parser, for Bison,
Copyright (C) 2001, 2002 Free Software Foundation, Inc. Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -100,12 +100,13 @@ print_core (struct obstack *oout, state *s)
{ {
bitset_iterator biter; bitset_iterator biter;
int k; int k;
int not_first = 0; char const *sep = "";
obstack_sgrow (oout, "["); obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookaheads[redno], k, 0) BITSET_FOR_EACH (biter, reds->lookaheads[redno], k, 0)
obstack_fgrow2 (oout, "%s%s", {
not_first++ ? ", " : "", obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
symbols[k]->tag); sep = ", ";
}
obstack_sgrow (oout, "]"); obstack_sgrow (oout, "]");
} }
} }

View File

@@ -36,11 +36,11 @@
#include "symtab.h" #include "symtab.h"
static symbol_list *grammar = NULL; static symbol_list *grammar = NULL;
static int start_flag = 0; static bool start_flag = false;
merger_list *merge_functions; merger_list *merge_functions;
/* Nonzero if %union has been seen. */ /* Has %union been seen? */
int typed = 0; bool typed = false;
/*-----------------------. /*-----------------------.
| Set the start symbol. | | Set the start symbol. |
@@ -53,7 +53,7 @@ grammar_start_symbol_set (symbol *sym, location loc)
complain_at (loc, _("multiple %s declarations"), "%start"); complain_at (loc, _("multiple %s declarations"), "%start");
else else
{ {
start_flag = 1; start_flag = true;
startsymbol = sym; startsymbol = sym;
startsymbol_location = loc; startsymbol_location = loc;
} }
@@ -213,7 +213,7 @@ grammar_rule_begin (symbol *lhs, location loc)
{ {
startsymbol = lhs; startsymbol = lhs;
startsymbol_location = loc; startsymbol_location = loc;
start_flag = 1; start_flag = true;
} }
/* Start a new rule and record its lhs. */ /* Start a new rule and record its lhs. */

View File

@@ -72,6 +72,6 @@ void free_merger_functions (void);
extern merger_list *merge_functions; extern merger_list *merge_functions;
extern int typed; extern bool typed;
#endif /* !READER_H_ */ #endif /* !READER_H_ */

View File

@@ -841,7 +841,7 @@ static inline bool
handle_action_at (char *text, location loc) handle_action_at (char *text, location loc)
{ {
char *cp = text + 1; char *cp = text + 1;
locations_flag = 1; locations_flag = true;
if (! current_rule) if (! current_rule)
return false; return false;

View File

@@ -236,12 +236,13 @@ state_rule_lookaheads_print (state *s, rule *r, FILE *out)
{ {
bitset_iterator biter; bitset_iterator biter;
int k; int k;
int not_first = 0; char const *sep = "";
fprintf (out, " ["); fprintf (out, " [");
BITSET_FOR_EACH (biter, reds->lookaheads[red], k, 0) BITSET_FOR_EACH (biter, reds->lookaheads[red], k, 0)
fprintf (out, "%s%s", {
not_first++ ? ", " : "", fprintf (out, "%s%s", sep, symbols[k]->tag);
symbols[k]->tag); sep = ", ";
}
fprintf (out, "]"); fprintf (out, "]");
} }
} }

View File

@@ -243,8 +243,8 @@ action_row (state *s)
transitions *trans = s->transitions; transitions *trans = s->transitions;
errs *errp = s->errs; errs *errp = s->errs;
/* Set to nonzero to inhibit having any default reduction. */ /* Set to nonzero to inhibit having any default reduction. */
int nodefault = 0; bool nodefault = false;
int conflicted = 0; bool conflicted = false;
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
actrow[i] = conflrow[i] = 0; actrow[i] = conflrow[i] = 0;
@@ -264,7 +264,10 @@ action_row (state *s)
/* and record this rule as the rule to use if that /* and record this rule as the rule to use if that
token follows. */ token follows. */
if (actrow[j] != 0) if (actrow[j] != 0)
conflicted = conflrow[j] = 1; {
conflicted = true;
conflrow[j] = 1;
}
actrow[j] = rule_number_as_item_number (reds->rules[i]->number); actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
} }
} }
@@ -278,13 +281,16 @@ action_row (state *s)
state *shift_state = trans->states[i]; state *shift_state = trans->states[i];
if (actrow[sym] != 0) if (actrow[sym] != 0)
conflicted = conflrow[sym] = 1; {
conflicted = true;
conflrow[sym] = 1;
}
actrow[sym] = state_number_as_int (shift_state->number); actrow[sym] = state_number_as_int (shift_state->number);
/* Do not use any default reduction if there is a shift for /* Do not use any default reduction if there is a shift for
error */ error */
if (sym == errtoken->number) if (sym == errtoken->number)
nodefault = 1; nodefault = true;
} }
/* See which tokens are an explicit error in this state (due to /* See which tokens are an explicit error in this state (due to
@@ -669,7 +675,7 @@ pack_vector (vector_number vector)
for (j = lowzero - from[0]; ; j++) for (j = lowzero - from[0]; ; j++)
{ {
int k; int k;
int ok = 1; bool ok = true;
if (table_size <= j) if (table_size <= j)
abort (); abort ();
@@ -681,12 +687,12 @@ pack_vector (vector_number vector)
table_grow (loc); table_grow (loc);
if (table[loc] != 0) if (table[loc] != 0)
ok = 0; ok = false;
} }
for (k = 0; ok && k < vector; k++) for (k = 0; ok && k < vector; k++)
if (pos[k] == j) if (pos[k] == j)
ok = 0; ok = false;
if (ok) if (ok)
{ {