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