]> git.saurik.com Git - bison.git/blame - lib/bitsetv-print.c
* NEWS (2.5): New section. Describe new -D/--define feature.
[bison.git] / lib / bitsetv-print.c
CommitLineData
1565b720 1/* Bitset vectors.
02650b7f 2 Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
1565b720 3
f16b0819 4 This program is free software: you can redistribute it and/or modify
02650b7f 5 it under the terms of the GNU General Public License as published by
f16b0819 6 the Free Software Foundation, either version 3 of the License, or
02650b7f 7 (at your option) any later version.
1565b720 8
02650b7f
PE
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
1565b720 13
02650b7f 14 You should have received a copy of the GNU General Public License
f16b0819 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1565b720 16
231ed89a 17#include <config.h>
1565b720 18
1565b720
AD
19#include "bitsetv-print.h"
20
231ed89a
PE
21#include <stdlib.h>
22
1565b720
AD
23/*--------------------------------------------------------.
24| Display the MATRIX array of SIZE bitsets of size SIZE. |
25`--------------------------------------------------------*/
26
27void
28bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
29{
4fc71aa3
PE
30 bitset_bindex i, j;
31 bitset_bindex hsize = bitset_size (bset[0]);
1565b720
AD
32
33 /* Title. */
34 fprintf (out, "%s BEGIN\n", title);
35
36 /* Column numbers. */
37 fputs (" ", out);
38 for (i = 0; i < hsize; ++i)
39 putc (i / 10 ? '0' + i / 10 : ' ', out);
40 putc ('\n', out);
41 fputs (" ", out);
42 for (i = 0; i < hsize; ++i)
4fc71aa3 43 fprintf (out, "%d", (int) (i % 10));
1565b720
AD
44 putc ('\n', out);
45
46 /* Bar. */
47 fputs (" .", out);
48 for (i = 0; i < hsize; ++i)
49 putc ('-', out);
50 fputs (".\n", out);
51
52 /* Contents. */
53 for (i = 0; bset[i]; ++i)
54 {
779e7ceb 55 fprintf (out, "%2lu|", (unsigned long int) i);
1565b720
AD
56 for (j = 0; j < hsize; ++j)
57 fputs (bitset_test (bset[i], j) ? "1" : " ", out);
58 fputs ("|\n", out);
59 }
60
61 /* Bar. */
62 fputs (" `", out);
63 for (i = 0; i < hsize; ++i)
64 putc ('-', out);
65 fputs ("'\n", out);
66
67 /* End title. */
68 fprintf (out, "%s END\n\n", title);
69}