]> git.saurik.com Git - bison.git/blob - lib/bitsetv-print.c
* tests/actions.at (Actions after errors): New test case.
[bison.git] / lib / bitsetv-print.c
1 /* Bitset vectors.
2 Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3
4 This file is part of Bison.
5
6 Bison is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Bison is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Bison; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <stdlib.h>
26 #include "bitsetv-print.h"
27
28 /*--------------------------------------------------------.
29 | Display the MATRIX array of SIZE bitsets of size SIZE. |
30 `--------------------------------------------------------*/
31
32 void
33 bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
34 {
35 bitset_bindex i, j;
36 bitset_bindex hsize = bitset_size (bset[0]);
37
38 /* Title. */
39 fprintf (out, "%s BEGIN\n", title);
40
41 /* Column numbers. */
42 fputs (" ", out);
43 for (i = 0; i < hsize; ++i)
44 putc (i / 10 ? '0' + i / 10 : ' ', out);
45 putc ('\n', out);
46 fputs (" ", out);
47 for (i = 0; i < hsize; ++i)
48 fprintf (out, "%d", (int) (i % 10));
49 putc ('\n', out);
50
51 /* Bar. */
52 fputs (" .", out);
53 for (i = 0; i < hsize; ++i)
54 putc ('-', out);
55 fputs (".\n", out);
56
57 /* Contents. */
58 for (i = 0; bset[i]; ++i)
59 {
60 fprintf (out, "%2lu|", (unsigned long) i);
61 for (j = 0; j < hsize; ++j)
62 fputs (bitset_test (bset[i], j) ? "1" : " ", out);
63 fputs ("|\n", out);
64 }
65
66 /* Bar. */
67 fputs (" `", out);
68 for (i = 0; i < hsize; ++i)
69 putc ('-', out);
70 fputs ("'\n", out);
71
72 /* End title. */
73 fprintf (out, "%s END\n\n", title);
74 }