mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-09 02:35:15 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a4734aa97 | ||
|
|
c935d93471 | ||
|
|
577d7c33df | ||
|
|
da436e4383 | ||
|
|
da12206a7c | ||
|
|
82de6b0dde | ||
|
|
6c7ffa8380 | ||
|
|
895789c673 | ||
|
|
55a91a8242 | ||
|
|
d7e14fc000 | ||
|
|
0a2c51373a | ||
|
|
f28ac696ee | ||
|
|
e019c24779 | ||
|
|
72731bb70b | ||
|
|
d390b02b8e | ||
|
|
9a0d8becd8 | ||
|
|
99880de508 | ||
|
|
9bec482e39 | ||
|
|
f6fbd3da9d | ||
|
|
efeed02327 | ||
|
|
76dcf299b7 | ||
|
|
bc82c5a593 | ||
|
|
fd19f2714f | ||
|
|
10454ea42f | ||
|
|
c5b95ccf6b | ||
|
|
617a8f1227 | ||
|
|
1e547e6e8c | ||
|
|
ea193b9dae | ||
|
|
3239db74b1 | ||
|
|
735d6bd42e | ||
|
|
f69a414266 | ||
|
|
2e1f5829ee | ||
|
|
a3cb624893 | ||
|
|
07fed89197 | ||
|
|
e603eaa5d4 | ||
|
|
63d72da75b | ||
|
|
bbd3fa0c61 | ||
|
|
fafb007d45 | ||
|
|
9fafc4ddfd | ||
|
|
24e0cbd0e1 | ||
|
|
766de5eb7c | ||
|
|
a4e1a53bf9 | ||
|
|
bf46a7c193 | ||
|
|
48814dcd46 | ||
|
|
1c1609b7d0 | ||
|
|
68b082af0c | ||
|
|
a14a26fa44 | ||
|
|
5bdca67817 | ||
|
|
337116ba3d | ||
|
|
db5c43f791 | ||
|
|
7b21ee09da | ||
|
|
88636fbd49 | ||
|
|
80a183578b | ||
|
|
046ac74eef | ||
|
|
161a71f34c | ||
|
|
267757362f | ||
|
|
da2a7671e1 | ||
|
|
86a54ab102 | ||
|
|
8175837596 | ||
|
|
67961b9ea0 | ||
|
|
44aabce335 | ||
|
|
00baeeac7e | ||
|
|
78143b92af | ||
|
|
60e3ecc734 | ||
|
|
b03595a5c2 | ||
|
|
be3d9d4219 | ||
|
|
78e526d5fa | ||
|
|
42e826a47d | ||
|
|
afbb696d19 | ||
|
|
c1f8f16a9b | ||
|
|
9a1e998918 | ||
|
|
85c19f8819 | ||
|
|
68e11668e4 | ||
|
|
e268877e7e | ||
|
|
b9b51bf05a | ||
|
|
97cbc73e2a | ||
|
|
288006a259 | ||
|
|
f74b6f91f6 | ||
|
|
e342c3beaf | ||
|
|
93602febc0 | ||
|
|
7886c2d419 | ||
|
|
ed4cdb7afc | ||
|
|
0859e438eb | ||
|
|
f55ec70868 | ||
|
|
4cf44c0045 | ||
|
|
dba08b0461 | ||
|
|
14d4662b83 | ||
|
|
df09ef2e8f | ||
|
|
2ed24dd8c7 | ||
|
|
146bc99dcf | ||
|
|
7d1be3bdff | ||
|
|
bd22e8363a | ||
|
|
13c29075c5 | ||
|
|
e503aa60d5 | ||
|
|
2c0ddf03ab | ||
|
|
8a8dc872fa | ||
|
|
b4a2033855 | ||
|
|
f85a5e6f4b | ||
|
|
b203fc2c07 | ||
|
|
3fee967f83 | ||
|
|
5b7e1e73e6 | ||
|
|
ead9e56eb2 | ||
|
|
0dcca5c22f | ||
|
|
6dde1c82cd | ||
|
|
b233d5558f | ||
|
|
619404e3fd | ||
|
|
dd8d90221a | ||
|
|
0092f063af | ||
|
|
451364edb1 | ||
|
|
18d192f0ea | ||
|
|
b8458aa5cc | ||
|
|
3fc16193d9 | ||
|
|
ecfe33e799 | ||
|
|
1576d44dce | ||
|
|
9c66f418c4 | ||
|
|
52d5733ff0 | ||
|
|
a0e68930d8 | ||
|
|
e757bb10bc | ||
|
|
0fe1f06d36 | ||
|
|
284acc8ba7 | ||
|
|
b7c72fe1c4 | ||
|
|
a5eb1ed262 | ||
|
|
417141dd61 | ||
|
|
2fa09258b1 | ||
|
|
2ed973bf1d | ||
|
|
9378b5082b | ||
|
|
a9f027b9c4 | ||
|
|
87a8ad5cd3 | ||
|
|
dca81a78f8 | ||
|
|
c9cbf7c58e | ||
|
|
ac700aa646 | ||
|
|
ee42c6166b | ||
|
|
c0659069d0 | ||
|
|
60c8294801 | ||
|
|
fa7e68c397 | ||
|
|
0817d1eccb | ||
|
|
99a9344e77 | ||
|
|
85f23fae45 | ||
|
|
8dd162d3ff | ||
|
|
57a90331bd | ||
|
|
69daa921b8 | ||
|
|
8ed3234a14 | ||
|
|
0797198341 | ||
|
|
2905865228 | ||
|
|
fd418816b9 | ||
|
|
329d23c5d6 | ||
|
|
62cb8a9920 | ||
|
|
caa52c10c5 | ||
|
|
5c9be03d6d | ||
|
|
2cef3017cd | ||
|
|
b9c85d5cef | ||
|
|
4bfd5e4e53 | ||
|
|
6712933e0f | ||
|
|
6a36ff9495 | ||
|
|
209ea708c4 | ||
|
|
383e69dc79 | ||
|
|
41ca25499e | ||
|
|
e476c87d93 | ||
|
|
233a88ad11 | ||
|
|
9668e2be96 | ||
|
|
a76ca26309 | ||
|
|
12ffdd2835 | ||
|
|
4febdd9667 | ||
|
|
e23d0dd71e | ||
|
|
1f65350a16 | ||
|
|
f97de3247f | ||
|
|
6e26ca8c27 | ||
|
|
b970803c91 | ||
|
|
126e375187 | ||
|
|
7d7d666369 | ||
|
|
ca6f187f64 | ||
|
|
0f53f2226d | ||
|
|
45d5982f04 | ||
|
|
1f916a78e6 | ||
|
|
4f16766c00 | ||
|
|
584bbcd839 | ||
|
|
779e7ceb93 | ||
|
|
2ae64eed27 | ||
|
|
d63282419d | ||
|
|
1452af69b4 | ||
|
|
006d217ddd | ||
|
|
6a60c4cf45 | ||
|
|
c2729758f2 | ||
|
|
0b31edd3e1 | ||
|
|
dd0e0635ec | ||
|
|
d0d5aa6425 | ||
|
|
be16239bf7 | ||
|
|
5fa908329c | ||
|
|
0ced3098fd | ||
|
|
dc8a217381 | ||
|
|
ce05140d9d | ||
|
|
3dc4c5faa9 | ||
|
|
eecf08fe94 | ||
|
|
28f57d2ae3 | ||
|
|
b165c324a3 | ||
|
|
26e06a2157 | ||
|
|
eda429346a | ||
|
|
6a5ecb38fc | ||
|
|
92ac370570 | ||
|
|
91d2c560a8 | ||
|
|
0cc3da3a4e | ||
|
|
66ef8b9d65 | ||
|
|
22fccf958f | ||
|
|
fc8f296538 | ||
|
|
92f5e991da | ||
|
|
42db4e2b74 | ||
|
|
39a06c251a | ||
|
|
7f41b88821 | ||
|
|
62b6aef925 | ||
|
|
89e1cc61b7 | ||
|
|
a08460b08c | ||
|
|
603f1cfdc5 | ||
|
|
cd3684cfa8 | ||
|
|
388f8b197d | ||
|
|
4e03e2015c | ||
|
|
8c182d0592 | ||
|
|
25f66e1a6a | ||
|
|
5348bfbe29 | ||
|
|
473013144d | ||
|
|
1f7a61ff99 | ||
|
|
750a5211c0 | ||
|
|
327b5b5675 | ||
|
|
7b98f503de | ||
|
|
16caa4f431 | ||
|
|
0051e3edb0 | ||
|
|
64c4fd521a | ||
|
|
5b620e069d | ||
|
|
dfc8a22010 | ||
|
|
137437c6db | ||
|
|
2779e38386 | ||
|
|
a525b5687d | ||
|
|
b81a6e01dc | ||
|
|
ddb85ca59e | ||
|
|
4dcf140b13 | ||
|
|
29103e06b5 | ||
|
|
6040d33886 | ||
|
|
39910e0949 | ||
|
|
0ae99356d5 | ||
|
|
81fd08cad0 | ||
|
|
08fc98e544 | ||
|
|
cd05d13c9e | ||
|
|
5cc16ecc96 | ||
|
|
7b49187432 | ||
|
|
226dcab028 | ||
|
|
8a2757b9e2 | ||
|
|
e6ce73154c | ||
|
|
465b4444e8 | ||
|
|
f8e8262e70 | ||
|
|
7a5a3475cf | ||
|
|
7cc661648b | ||
|
|
acfafa9d91 | ||
|
|
98bb5428c8 | ||
|
|
8dd76bee16 | ||
|
|
3473d0f899 | ||
|
|
ec622ab417 | ||
|
|
3647fcc8af | ||
|
|
cbb0d2d116 | ||
|
|
88ab880d90 | ||
|
|
6f2d9f5854 | ||
|
|
28ee846711 | ||
|
|
75d0ea41fa | ||
|
|
6a75a421f0 | ||
|
|
fa8db4baa7 | ||
|
|
3f764fe576 | ||
|
|
99c32453d0 | ||
|
|
94a23f969c | ||
|
|
ac08ca6c30 | ||
|
|
e64fec0a0f | ||
|
|
e2527c97f9 | ||
|
|
1930ac784a | ||
|
|
e9665d1605 | ||
|
|
671881d12d | ||
|
|
907e3bc851 | ||
|
|
b8a204c09b | ||
|
|
25005f6ab0 | ||
|
|
144c1e767a | ||
|
|
65d5286c12 | ||
|
|
1f5bf95b48 | ||
|
|
25e845d1be | ||
|
|
711f40b715 | ||
|
|
848dc439cb | ||
|
|
f56f6d78b0 | ||
|
|
1d4055aa2b | ||
|
|
e77419464c | ||
|
|
cea5324737 | ||
|
|
eaef5507fc | ||
|
|
ac695f7df5 | ||
|
|
2ffbee0e0b | ||
|
|
26ec81e097 | ||
|
|
57f5199797 | ||
|
|
713535c232 | ||
|
|
504f20f77e | ||
|
|
6a84279cb5 | ||
|
|
82c53be476 | ||
|
|
a6b89bb2dc | ||
|
|
ed3265ddc5 | ||
|
|
6a0835a144 | ||
|
|
ac89e8176f | ||
|
|
c6ae27df0b | ||
|
|
d7aa6ec179 | ||
|
|
f545262547 | ||
|
|
83a457be99 | ||
|
|
d08290769c | ||
|
|
637fa3f83e | ||
|
|
829fd4c70d | ||
|
|
6b2584b7a2 | ||
|
|
eae34f44e6 | ||
|
|
087b9fdf03 | ||
|
|
8d0a98bb50 | ||
|
|
caf37a3666 | ||
|
|
3ab370773d | ||
|
|
0e14ad772f | ||
|
|
163ab32161 | ||
|
|
cfbb7304d8 | ||
|
|
e743727fcd | ||
|
|
2175bfbd09 | ||
|
|
a1c84f4523 | ||
|
|
916708d59e | ||
|
|
a06ea4aa98 | ||
|
|
ca752c3497 | ||
|
|
211074caca | ||
|
|
2f924dd373 | ||
|
|
6175ffe321 | ||
|
|
68cdf74747 | ||
|
|
b1e9585744 | ||
|
|
b929851a33 | ||
|
|
3470c57bea | ||
|
|
0c3c1f98ec | ||
|
|
acda9df6f9 | ||
|
|
b59d8a44df | ||
|
|
b5250f2635 | ||
|
|
3192f9ece7 | ||
|
|
089ac0f11c | ||
|
|
1d2d7eddf7 | ||
|
|
1b8f2fff2a | ||
|
|
47e7600a21 | ||
|
|
aa4180418f | ||
|
|
5ededac618 | ||
|
|
2740f1691f | ||
|
|
0de45ae542 | ||
|
|
b8be913233 | ||
|
|
d423d46080 | ||
|
|
c7e441b49c | ||
|
|
231897ad21 | ||
|
|
22a74fece3 | ||
|
|
5b06606339 | ||
|
|
fef4cb511e | ||
|
|
265d1ec403 | ||
|
|
0eee27e7b7 | ||
|
|
0eadf43ccc | ||
|
|
5fa179f52b | ||
|
|
9986d7a732 | ||
|
|
ae5895dd3a | ||
|
|
ab8fe29d0c | ||
|
|
537636c7e5 | ||
|
|
379f0ac840 | ||
|
|
4a99c66490 | ||
|
|
0baf7c50ed | ||
|
|
a93df6bad3 | ||
|
|
8012adae7b | ||
|
|
f61aad9399 | ||
|
|
4f8a9f6dba | ||
|
|
e13bcfbbbd | ||
|
|
6f7d430291 | ||
|
|
650aa2cfbf | ||
|
|
d2ffe11637 | ||
|
|
052826fdd1 | ||
|
|
c47495657b | ||
|
|
d5286af19b | ||
|
|
95b52400d5 | ||
|
|
22e304a6da | ||
|
|
67a25fed4c | ||
|
|
9c2b381f79 | ||
|
|
a2bc9dbc7b | ||
|
|
0433ba88f9 | ||
|
|
6d5aa694aa | ||
|
|
b305ea6918 | ||
|
|
02d5ffac8b | ||
|
|
c3d25e01e8 | ||
|
|
974075dc6c | ||
|
|
c267ffbced | ||
|
|
52f32190aa | ||
|
|
9b76b7868e | ||
|
|
47ee29cf60 | ||
|
|
1bc9d5f9d4 | ||
|
|
ba1ecc079b | ||
|
|
f939fc12fe | ||
|
|
95923bd6a6 | ||
|
|
2cdc240eeb | ||
|
|
5d00311619 | ||
|
|
d02b25f99b | ||
|
|
0d1c3a04b7 | ||
|
|
60a777aa24 | ||
|
|
0b86fc416c | ||
|
|
da99a5dc03 | ||
|
|
97c9a05ecd | ||
|
|
9d56d2940a | ||
|
|
93b8c255e8 | ||
|
|
93a0df697f | ||
|
|
3aa2f55d71 | ||
|
|
7548fed236 | ||
|
|
d5a3fe37a9 | ||
|
|
1d64f0bab6 | ||
|
|
1d32c92eef | ||
|
|
43a176ef35 | ||
|
|
fc049e9caf | ||
|
|
a737b2163c | ||
|
|
ba24760f05 | ||
|
|
68e93ad549 | ||
|
|
7aff61d4dc | ||
|
|
ab10c47576 | ||
|
|
a2814891a4 | ||
|
|
1d9d5d7159 | ||
|
|
f4ca512cc8 | ||
|
|
9289898605 | ||
|
|
9e10007658 | ||
|
|
9a2b42a3ff | ||
|
|
0435d061f2 | ||
|
|
6029a57f53 | ||
|
|
ede3d3bcbc | ||
|
|
f868dc04e4 | ||
|
|
6cee62971e | ||
|
|
b61c697827 | ||
|
|
b2a836b51e | ||
|
|
8a3eb3c8ba | ||
|
|
4196b9316c | ||
|
|
34e1d16097 | ||
|
|
3ae831b413 | ||
|
|
0692b77351 | ||
|
|
e3aa65c502 | ||
|
|
69363a9e4d | ||
|
|
8522c9ed2a | ||
|
|
f0057011f7 | ||
|
|
1ee6d2a02e | ||
|
|
a1a44c02ab | ||
|
|
3add7b9cb1 | ||
|
|
d4fd77c450 | ||
|
|
f6481e2fdc | ||
|
|
d600ee67ee | ||
|
|
a504e06dd7 | ||
|
|
66abff154f | ||
|
|
4beda9accf | ||
|
|
93b716f4aa | ||
|
|
464c692789 | ||
|
|
49b6b48b99 | ||
|
|
2f10a596a7 | ||
|
|
0fff129c7c | ||
|
|
fd520abff8 | ||
|
|
547734f14d | ||
|
|
c1a0d7e076 | ||
|
|
b14ec5333b | ||
|
|
f7c398aaff | ||
|
|
45aa0550a1 | ||
|
|
1029ea6d02 | ||
|
|
0f42c7d501 | ||
|
|
f96e75a64e | ||
|
|
14c0cf3c88 | ||
|
|
d891bc49ac | ||
|
|
597ba9e333 | ||
|
|
2efa0406e3 | ||
|
|
8e4900ef40 | ||
|
|
dc546b0f6e | ||
|
|
1deb9bdcad | ||
|
|
2c09b6a7ea | ||
|
|
83adb046bf | ||
|
|
255227393f | ||
|
|
5b25cd7cd8 | ||
|
|
535c0f6328 | ||
|
|
527203e98e | ||
|
|
7b56c4bc0e | ||
|
|
78a00b7d7f | ||
|
|
963fcc1705 | ||
|
|
00c378a21f | ||
|
|
a4b746ea04 | ||
|
|
2c8ba4cd59 | ||
|
|
be7280480c | ||
|
|
5a99098d0b | ||
|
|
fb8ccdcd35 | ||
|
|
8ca1967ea2 | ||
|
|
b1efe548af | ||
|
|
120f129d67 | ||
|
|
96b93a3da4 | ||
|
|
d42f69cdf7 | ||
|
|
04877eec24 | ||
|
|
053658d584 | ||
|
|
6876ecd36e | ||
|
|
76be9271f2 | ||
|
|
983c5c2c2a | ||
|
|
5b66ea8b80 | ||
|
|
70b4c070cc | ||
|
|
cce7a5f423 | ||
|
|
2fd4e13193 | ||
|
|
7eab453e1b | ||
|
|
f6abc26e38 | ||
|
|
ea03c24f05 | ||
|
|
fcbfa6b01c | ||
|
|
9dd5b37815 | ||
|
|
88015bf06b | ||
|
|
7ea9026a59 | ||
|
|
ebec3740c2 | ||
|
|
23f2d9dc0f | ||
|
|
73521d9ff8 | ||
|
|
366041f014 | ||
|
|
80483e8e0d | ||
|
|
5320ca4d6f | ||
|
|
33167b8b05 | ||
|
|
624a35e20b | ||
|
|
ef4479de37 | ||
|
|
e9ce56889c | ||
|
|
6273355b36 | ||
|
|
050c471b8e | ||
|
|
fa8c3ebca3 | ||
|
|
75eb3bc4e7 | ||
|
|
52328c6e99 | ||
|
|
f67ad422a4 | ||
|
|
879ca4f81b | ||
|
|
9417597809 | ||
|
|
20daca0631 | ||
|
|
b317297e4d | ||
|
|
1c5fe69d46 | ||
|
|
a20713a4af | ||
|
|
d2caf5545c | ||
|
|
c5df10951a | ||
|
|
d1de53722b | ||
|
|
00ba950c7b | ||
|
|
05d18c2493 | ||
|
|
397ec0734f | ||
|
|
d8388d7ab6 | ||
|
|
148b7779f3 | ||
|
|
dbb95312e2 | ||
|
|
f47dbf6bef | ||
|
|
fc659dfd69 | ||
|
|
ec1ef903c3 | ||
|
|
1915f1331e | ||
|
|
d0f3fe233d | ||
|
|
ca2e738c81 | ||
|
|
177d84c081 | ||
|
|
4613f49b90 | ||
|
|
04e309ce35 | ||
|
|
ac72f3e9b5 | ||
|
|
ff5c8b8557 | ||
|
|
deedb0b77c | ||
|
|
2cc6b61207 | ||
|
|
0fb1efaf58 | ||
|
|
2073d76939 | ||
|
|
03b9e27342 | ||
|
|
3b1e470c6d | ||
|
|
f2a655b6cc | ||
|
|
c488293484 | ||
|
|
9c4637fa8c | ||
|
|
87ceef7346 | ||
|
|
0993971437 | ||
|
|
e00b682606 | ||
|
|
a54a1bdc6b | ||
|
|
5362cd5f78 | ||
|
|
e46cedb9be | ||
|
|
e59a68718b | ||
|
|
6c5f863aec | ||
|
|
6f84e9abca | ||
|
|
08721544d1 | ||
|
|
82129ef5d5 | ||
|
|
69cecfeb38 | ||
|
|
1dd15b6ea6 | ||
|
|
bb7c2bc623 | ||
|
|
eb0ca72d8e | ||
|
|
26b4a96981 | ||
|
|
051ade8391 | ||
|
|
e3aa2baac6 | ||
|
|
1faeb1414d | ||
|
|
106344fb01 | ||
|
|
17ee7397a8 | ||
|
|
3671fb8483 | ||
|
|
c801dbf7d9 | ||
|
|
982cc3023c | ||
|
|
7486e51b76 | ||
|
|
e39214489e | ||
|
|
784573d14a | ||
|
|
353d3eb651 | ||
|
|
223ff46e4c | ||
|
|
7b5cb0cd30 | ||
|
|
5b2dd224dc | ||
|
|
16bb742fce | ||
|
|
3d2cbc2662 | ||
|
|
21fd22d6ec | ||
|
|
a0b76449c7 | ||
|
|
2b5ff972bf | ||
|
|
8322e8f580 | ||
|
|
69b8cc095f | ||
|
|
81ebdef91d | ||
|
|
b78d8c23da | ||
|
|
5dde542557 | ||
|
|
7478c462f2 | ||
|
|
e8a0acd666 | ||
|
|
d38a11a64b | ||
|
|
651ec3d0ec | ||
|
|
6d441fc378 | ||
|
|
fbfa091d05 | ||
|
|
f041e30b91 | ||
|
|
41f83caf1c | ||
|
|
c7bd07f75a | ||
|
|
3de372bb1b | ||
|
|
c134bfbeee | ||
|
|
5bf3d7c115 | ||
|
|
add6614e2b | ||
|
|
7c612afb7e | ||
|
|
e22ad7fa22 | ||
|
|
f6a8ccf40a | ||
|
|
178365909f | ||
|
|
9939fdb139 | ||
|
|
4bebc88ee1 | ||
|
|
557962dcff | ||
|
|
5bab03fcf8 | ||
|
|
996b1c7e8c | ||
|
|
e19c4e5d1c | ||
|
|
050931e3f9 | ||
|
|
e551232efa | ||
|
|
b06af56f55 | ||
|
|
2bf21a8322 | ||
|
|
3f2d73f157 | ||
|
|
d6ea8200af | ||
|
|
0aa32d51bb | ||
|
|
2073702c37 | ||
|
|
b729552289 | ||
|
|
8f759107f1 | ||
|
|
b17a1fc541 | ||
|
|
5fcdb07b70 | ||
|
|
7f8ba6c7f3 | ||
|
|
4b68955b1d | ||
|
|
b69d743e78 | ||
|
|
4f21fffe7e | ||
|
|
c5d128ec1a | ||
|
|
b64755e391 | ||
|
|
022fb98e85 | ||
|
|
570fe42828 | ||
|
|
6c30d6413e | ||
|
|
6ba5559289 | ||
|
|
e927351156 | ||
|
|
38e71ff8c8 | ||
|
|
3b0ee3aa8b | ||
|
|
6e746484fc | ||
|
|
74724a70a5 | ||
|
|
1fec91df90 | ||
|
|
d18f45311a | ||
|
|
93dd49ab29 | ||
|
|
1f14d97ae5 | ||
|
|
0af19cd0c1 | ||
|
|
38a92d500a | ||
|
|
6b0d38ab2c | ||
|
|
88510f9c07 | ||
|
|
da90e18c6e | ||
|
|
763ed7a687 | ||
|
|
1773ceee65 | ||
|
|
feeb0edaf1 | ||
|
|
78c3da9e09 | ||
|
|
4f39538148 | ||
|
|
bb92250c78 | ||
|
|
41141c568e | ||
|
|
f6d03984ae | ||
|
|
ad8a3efc5a | ||
|
|
831d3c996d | ||
|
|
136d65300d | ||
|
|
14740648d5 | ||
|
|
08cae37b47 | ||
|
|
ceed6cdce5 | ||
|
|
3af4feb22f | ||
|
|
dda7aa54b6 | ||
|
|
16f37b35a5 | ||
|
|
300a796626 | ||
|
|
f6cf0f6e5f | ||
|
|
69e16b4c5e | ||
|
|
0368ae1269 | ||
|
|
580043087e | ||
|
|
6f5db56451 | ||
|
|
500bbfcd81 | ||
|
|
63d0fb9ce4 | ||
|
|
7a86d7eba9 | ||
|
|
4344c500b5 | ||
|
|
443594d0c4 | ||
|
|
87aabbff99 | ||
|
|
2f82502a6f | ||
|
|
fe22d5d20f | ||
|
|
ec14f0c83f | ||
|
|
35dcf428c9 | ||
|
|
a932883e41 | ||
|
|
b475e0cce5 | ||
|
|
58a84254ef | ||
|
|
7223426a2b | ||
|
|
b9a0104860 | ||
|
|
937fd8646f | ||
|
|
b973108e1e | ||
|
|
51dffcbca9 | ||
|
|
76ae81983c | ||
|
|
df38312ab0 | ||
|
|
8d8a7238ee | ||
|
|
d3c4e709ff | ||
|
|
4e8c79eb7f | ||
|
|
ee16363fd2 | ||
|
|
60a3dcf956 | ||
|
|
b0937b2259 | ||
|
|
c5e3e51055 | ||
|
|
4c6cc1db75 | ||
|
|
6d9e8019e1 | ||
|
|
ee41006f01 | ||
|
|
b25d88f6d2 | ||
|
|
5dac0025f6 | ||
|
|
f0616f0b5c | ||
|
|
6e649e659e | ||
|
|
0f39aab92a | ||
|
|
761c1926a1 | ||
|
|
0258d1661c | ||
|
|
b0f98b1016 | ||
|
|
edbc04c709 | ||
|
|
7ec1b48eb8 | ||
|
|
93ba6bf344 | ||
|
|
970785f1a0 | ||
|
|
cfff7583d2 | ||
|
|
8fcc7db138 | ||
|
|
1d39f854cf | ||
|
|
dda7a53e4d | ||
|
|
f32b346d84 | ||
|
|
4e8d992c7d | ||
|
|
9501dc6e69 | ||
|
|
18b519c0d6 | ||
|
|
daa33def28 | ||
|
|
2b42986e75 | ||
|
|
efc6bf1b94 | ||
|
|
149365be01 | ||
|
|
9a86cdb99b | ||
|
|
c240826c06 | ||
|
|
caf52fdfab | ||
|
|
9c1e26bd3b | ||
|
|
f7e096fee3 | ||
|
|
73dbb6420e | ||
|
|
87f721cc87 | ||
|
|
ff03259279 | ||
|
|
dbba6a3be7 | ||
|
|
e84e65da40 | ||
|
|
53b7799056 | ||
|
|
412f8a5975 | ||
|
|
322c501d89 | ||
|
|
8a1dd2fe05 | ||
|
|
0eae1c91c8 | ||
|
|
be14ade55e | ||
|
|
cc13ba4dc0 | ||
|
|
05291fbc74 | ||
|
|
1f5fd52e9b | ||
|
|
43a91d61eb | ||
|
|
283f1e6482 | ||
|
|
886b69d197 | ||
|
|
3df374151b | ||
|
|
7bd6c77e5e | ||
|
|
b0400cc6ef | ||
|
|
72f889cca3 | ||
|
|
b1ae9233bc | ||
|
|
7ec2d4cd39 | ||
|
|
573a6cd356 | ||
|
|
95612cfa60 | ||
|
|
3e6656f9ab | ||
|
|
ccdb39e0a6 | ||
|
|
62ddaef6a7 | ||
|
|
ea44c25efc | ||
|
|
7672019c42 | ||
|
|
5b7f88c7f2 | ||
|
|
e9683cfd3d | ||
|
|
ac060e78a3 | ||
|
|
6c239755dc | ||
|
|
3813e141f8 | ||
|
|
a027c30d42 | ||
|
|
4e956a7d9e | ||
|
|
42481a1fd1 | ||
|
|
947427ae83 | ||
|
|
6ad762a8c0 | ||
|
|
fa3f2a885a | ||
|
|
acea4f3bb6 | ||
|
|
66871a8103 | ||
|
|
2115939b03 | ||
|
|
345532d70b | ||
|
|
944ed9f4e9 | ||
|
|
09d353a08f | ||
|
|
20ef1ad524 | ||
|
|
a706a1cc03 | ||
|
|
87fbb0bffc | ||
|
|
959e5f515a | ||
|
|
1c0c3e955d | ||
|
|
93724f139a | ||
|
|
0e25cad542 | ||
|
|
58918640ad | ||
|
|
8e6ef48342 | ||
|
|
fdac0091ce | ||
|
|
4e0813a6cf | ||
|
|
6e40b4ebd4 | ||
|
|
3d9a71d28a | ||
|
|
2dfbfc122c | ||
|
|
437c2d8000 | ||
|
|
900c5db537 | ||
|
|
e183b12388 | ||
|
|
9906579faa | ||
|
|
98f2caaa5f | ||
|
|
886a425c6f | ||
|
|
51b4a04cd0 | ||
|
|
d04946c717 | ||
|
|
193eb6b7ef | ||
|
|
1a9e39f116 | ||
|
|
48e28efa9e | ||
|
|
bcb3effb3c | ||
|
|
29c017256a | ||
|
|
8aeac3ca0c | ||
|
|
793a58bb66 | ||
|
|
c4d720cdbb | ||
|
|
386642761d | ||
|
|
613a0dc5b5 | ||
|
|
baa00b7f43 | ||
|
|
45a8a65dee | ||
|
|
2a8d363aab | ||
|
|
9e32add8e6 | ||
|
|
1a43c452ea | ||
|
|
03cae905c6 | ||
|
|
b02d90a5e6 | ||
|
|
206fe6a5ec | ||
|
|
d8d3f94a99 | ||
|
|
565a33db8f | ||
|
|
2bfc2e2a7d | ||
|
|
5389a5bff4 | ||
|
|
aad8382e8d | ||
|
|
1d9f7cd4f8 | ||
|
|
c0acc0f522 | ||
|
|
b9e0056255 | ||
|
|
397477b4e9 | ||
|
|
9e4c5cb833 | ||
|
|
01cfa69791 | ||
|
|
3fbf949b82 | ||
|
|
762b212bdf | ||
|
|
56100c60da | ||
|
|
30ba05f239 | ||
|
|
e63ee1f16c | ||
|
|
760d7aa8fa | ||
|
|
11a712626c | ||
|
|
782a05f9de | ||
|
|
09903f303a | ||
|
|
413fcf3a20 | ||
|
|
5c16c6b13a | ||
|
|
1f1b791bf0 | ||
|
|
bf1ebda27b | ||
|
|
2946869a28 | ||
|
|
c469accea7 | ||
|
|
b526ee6116 | ||
|
|
f1886bb280 | ||
|
|
48461d4b28 | ||
|
|
c55762568f | ||
|
|
f6d0c2394c | ||
|
|
f956c304c5 | ||
|
|
27b0ffea3e | ||
|
|
223a78837b | ||
|
|
41cce2f604 | ||
|
|
e0c74f0d34 | ||
|
|
e95aed631d | ||
|
|
ffa4c58acb | ||
|
|
c827f760f6 | ||
|
|
6db10d14be | ||
|
|
8b76775adb | ||
|
|
f0e48240c9 | ||
|
|
78bcec17c8 | ||
|
|
ec88357a8c | ||
|
|
5ca3209b44 | ||
|
|
0df27e8b2d | ||
|
|
901ec1537a | ||
|
|
0ae6073a18 | ||
|
|
8307162d58 | ||
|
|
738c69de37 | ||
|
|
b4afb6bbe5 | ||
|
|
637c4b283c | ||
|
|
78b8881659 | ||
|
|
a3714bcedf | ||
|
|
5dd5fd4a56 | ||
|
|
fece5986bf | ||
|
|
8d60a570d5 | ||
|
|
a7e92301ef | ||
|
|
a4b6efd473 | ||
|
|
92a060fd6a | ||
|
|
d33cb3ae09 | ||
|
|
b8452344de | ||
|
|
930393cf02 | ||
|
|
49f801e6fe | ||
|
|
2118414023 | ||
|
|
87004b05f7 | ||
|
|
e7cb57c0b8 | ||
|
|
0245f82d31 | ||
|
|
39912f5263 | ||
|
|
20c1e2ad98 | ||
|
|
21964f4394 | ||
|
|
66d30cd4eb | ||
|
|
95f2c9fe7d | ||
|
|
975553805c | ||
|
|
2cdb2a7b05 | ||
|
|
573312acb6 | ||
|
|
f7aed66054 | ||
|
|
82f9f11f39 | ||
|
|
6d55632cb7 | ||
|
|
2593afab81 | ||
|
|
5b2d69cc5b | ||
|
|
bb33f19a4b | ||
|
|
d9d363b172 | ||
|
|
9e2c5ef112 | ||
|
|
55b929cab2 | ||
|
|
c19988b766 | ||
|
|
ae7453f2ba | ||
|
|
0e57572183 | ||
|
|
3a781eb26b | ||
|
|
3eb4916379 | ||
|
|
724ce7f524 | ||
|
|
ac5dd84c25 | ||
|
|
d968424300 | ||
|
|
473d0a7567 | ||
|
|
93e2236a6d | ||
|
|
f7737e2e16 | ||
|
|
e76d2469e5 | ||
|
|
24c7b92b25 | ||
|
|
dddb8b6121 | ||
|
|
71d1d25c7a | ||
|
|
da2292e5c7 | ||
|
|
b37e55423b | ||
|
|
5bd1c41900 | ||
|
|
829f74d293 | ||
|
|
75f10004fe | ||
|
|
24f4e18b77 | ||
|
|
a182371d69 | ||
|
|
bba392ec8a | ||
|
|
d65ec44e3b | ||
|
|
04af9e5267 | ||
|
|
447e90bcef | ||
|
|
59fc3dcdf4 | ||
|
|
a911db9cba | ||
|
|
1a9bf9b959 | ||
|
|
ae26e1f02a | ||
|
|
d43baf71a7 | ||
|
|
7ebc83e34d | ||
|
|
b0a7a533c9 | ||
|
|
d90c934c05 | ||
|
|
05846dae07 | ||
|
|
447fbb178d | ||
|
|
b56471a689 | ||
|
|
1318e37d58 | ||
|
|
22a00a0cd2 | ||
|
|
768eb43fe8 | ||
|
|
7c78fa1885 | ||
|
|
5038f418c1 | ||
|
|
e5cfd9d8af | ||
|
|
cc0f0794b8 | ||
|
|
6b8c325436 | ||
|
|
6fed0802ee | ||
|
|
32f0598d06 | ||
|
|
7ea9a33f3b | ||
|
|
ea99527d23 | ||
|
|
f377f69fec | ||
|
|
2a1fe6ed6f | ||
|
|
f50adbbdb0 | ||
|
|
3b7d4eb2cd | ||
|
|
bcbad5b9a0 | ||
|
|
0ff67d71d7 | ||
|
|
efcb44dd47 | ||
|
|
1fe611e544 | ||
|
|
a6352deb14 | ||
|
|
bd0ba42d72 | ||
|
|
46b8b6ce90 | ||
|
|
fdabfd76d6 | ||
|
|
ea9ed226e0 | ||
|
|
98194095fe | ||
|
|
3f4c0f8017 | ||
|
|
14904b8965 | ||
|
|
17acead581 | ||
|
|
095b9f05c3 | ||
|
|
68449b3ad3 | ||
|
|
ff6dca1839 | ||
|
|
df5aed8c11 | ||
|
|
eb71459201 | ||
|
|
b7195100fd | ||
|
|
f28a0f2dd1 | ||
|
|
303e6da265 | ||
|
|
ef5da92061 | ||
|
|
3e0a8627e1 | ||
|
|
fd5c1e824e | ||
|
|
f5e211a120 | ||
|
|
55e728eb31 | ||
|
|
47c8386f83 | ||
|
|
d5c559cde4 | ||
|
|
d9d83ef277 | ||
|
|
d4d399fcce | ||
|
|
6fbe49845f | ||
|
|
7933f2b5dd | ||
|
|
0f9cd74fdb | ||
|
|
09147be095 | ||
|
|
7a542f5d81 | ||
|
|
420f93c83b | ||
|
|
a337a5eb7e | ||
|
|
595878d7f5 | ||
|
|
242a6e484e | ||
|
|
01eb033cf5 | ||
|
|
1c303b00fe | ||
|
|
f704e33362 | ||
|
|
5beedd9b58 | ||
|
|
9abb46d527 | ||
|
|
cd931d9b53 | ||
|
|
a4bf0390a0 | ||
|
|
72d2299ca0 | ||
|
|
ff68026d4f | ||
|
|
bf5c381136 | ||
|
|
5c319390d7 | ||
|
|
effda851f6 | ||
|
|
52f8da14ea | ||
|
|
eb6172cd1e | ||
|
|
32e218da16 | ||
|
|
4fc71aa390 | ||
|
|
c9de3b4080 | ||
|
|
2d382ea853 | ||
|
|
808a5918e6 | ||
|
|
d32fe6f64f | ||
|
|
f6ebdb3174 | ||
|
|
8207d52123 | ||
|
|
62a34c3eb6 | ||
|
|
6aa452a643 | ||
|
|
719010ad2b | ||
|
|
927f781708 | ||
|
|
e88dbdbf44 | ||
|
|
b778eff5f9 | ||
|
|
805e703284 | ||
|
|
464197c3a7 | ||
|
|
35f6ddeafb | ||
|
|
a75649b395 | ||
|
|
c0cac722f7 | ||
|
|
9738f41e3f | ||
|
|
a5c75d7fc6 | ||
|
|
8280e1797d | ||
|
|
ae64af3556 | ||
|
|
d1a1114f7f | ||
|
|
b906441c95 | ||
|
|
bd7018115a | ||
|
|
e0a13e7b30 | ||
|
|
43674285cc | ||
|
|
c97011bfc1 | ||
|
|
d862b1be60 | ||
|
|
f414d77d38 | ||
|
|
f25e23a632 | ||
|
|
54d25cfb74 | ||
|
|
3d38c03a86 | ||
|
|
b63473552d | ||
|
|
1b17ce8ebc | ||
|
|
09ba4ab244 | ||
|
|
262aa8dd59 | ||
|
|
0252b55c07 | ||
|
|
ad66f664ef | ||
|
|
21846f695d | ||
|
|
c0ad8bf3c2 | ||
|
|
eb34f4177c | ||
|
|
3a93251e73 | ||
|
|
427c0dda0c | ||
|
|
3f8237696f | ||
|
|
9503bbd27d | ||
|
|
3c146b5e6f | ||
|
|
948be909e9 | ||
|
|
8442d6ba22 | ||
|
|
645e30d193 | ||
|
|
6a254321ad | ||
|
|
04b6e11ebb | ||
|
|
c0d9cc4211 | ||
|
|
accea6db68 | ||
|
|
93a1e33a1d | ||
|
|
49e794c553 | ||
|
|
88ba3d332f | ||
|
|
002b9b7d1f | ||
|
|
6563aa9221 | ||
|
|
48c4080d0d | ||
|
|
63400d5d02 | ||
|
|
04c5cba268 | ||
|
|
d7163c0a58 | ||
|
|
db2cc12fd0 | ||
|
|
7e78575709 | ||
|
|
f9a85a156a | ||
|
|
c81bad8950 | ||
|
|
158e69f984 | ||
|
|
211e7860a2 | ||
|
|
e3fbd37fc0 | ||
|
|
a11166dddc | ||
|
|
9ff012ca23 | ||
|
|
3d70dbe593 | ||
|
|
91e1aa523d | ||
|
|
00a6930855 | ||
|
|
6fc82eafd5 | ||
|
|
0755be2ff9 | ||
|
|
b4ebc2134b | ||
|
|
30ad432609 | ||
|
|
1a92955799 | ||
|
|
a319e6a7a3 | ||
|
|
eb9568566a | ||
|
|
d5629ce34a | ||
|
|
c2143a71d6 | ||
|
|
c340180d81 | ||
|
|
c837b82803 | ||
|
|
e601ff27f4 | ||
|
|
c131cbff03 | ||
|
|
50f095c92f | ||
|
|
16cb098b72 | ||
|
|
9742c552f2 | ||
|
|
8434f2222e | ||
|
|
d6eba4239f | ||
|
|
81fe8b23e9 | ||
|
|
02e090934a | ||
|
|
87b7d7bad5 | ||
|
|
cf126971ad | ||
|
|
c896cfc95e | ||
|
|
a447fcd20c | ||
|
|
a861a3390f | ||
|
|
2cf6e61086 | ||
|
|
c8f002c7d3 | ||
|
|
cd08e51eda | ||
|
|
bb0027a9ac | ||
|
|
3325ddc49c | ||
|
|
c6f1a33c06 | ||
|
|
1509d42fcb | ||
|
|
273a74fa89 | ||
|
|
2ed0e35f86 | ||
|
|
217598dadc | ||
|
|
52489d4445 | ||
|
|
e8832397ea | ||
|
|
caf23d249c | ||
|
|
640748eecf | ||
|
|
88bce5a2ef | ||
|
|
1bfb97dba5 | ||
|
|
fc5734fe23 | ||
|
|
3650b4b8dd | ||
|
|
4b3d3a8e46 | ||
|
|
4a2a22f4c0 | ||
|
|
b8df32232a | ||
|
|
a762e609e7 | ||
|
|
12b0043a6d | ||
|
|
5dde258a9e | ||
|
|
a945ec3929 | ||
|
|
7601152fab | ||
|
|
fae437e835 | ||
|
|
1a715ef2fc | ||
|
|
a5d5099417 | ||
|
|
b275314e2d | ||
|
|
c5f5043618 | ||
|
|
2ab9a04ffc | ||
|
|
865b9df14c | ||
|
|
c76e14da4b | ||
|
|
7db2ed2d82 | ||
|
|
3a9e26be57 | ||
|
|
e68e0410ab | ||
|
|
e1a4f3a428 | ||
|
|
536545f3a4 | ||
|
|
8b752b00fd | ||
|
|
613f5e1a89 | ||
|
|
524346a3a3 | ||
|
|
26e0cadc37 | ||
|
|
e68d4575b3 | ||
|
|
bb3f671805 | ||
|
|
88e7e94146 | ||
|
|
1154ccedaf | ||
|
|
97650f4efc | ||
|
|
d257636504 | ||
|
|
ccaf65bc63 | ||
|
|
87675353bf | ||
|
|
ce4ccb4b11 | ||
|
|
bc933ef16d | ||
|
|
53d4308dbb | ||
|
|
574fb2d568 | ||
|
|
05811fd755 | ||
|
|
0e4d575330 | ||
|
|
24c7d80020 | ||
|
|
9222837b27 | ||
|
|
260008e546 | ||
|
|
8a731ca829 | ||
|
|
32e1e0a486 | ||
|
|
e5fb671032 | ||
|
|
c7ca99d4b0 | ||
|
|
df0e7316a9 | ||
|
|
39f4191608 | ||
|
|
d57650a5ff | ||
|
|
5a08f1ce21 | ||
|
|
720623af84 | ||
|
|
fb8135fa99 | ||
|
|
4fa887b790 | ||
|
|
4144248075 | ||
|
|
e0e5bf84b0 | ||
|
|
b5480d74b8 | ||
|
|
676385e29c | ||
|
|
01241d47b4 | ||
|
|
ba29c4ec25 | ||
|
|
e2aaf4c4f9 | ||
|
|
7cca31a2f2 | ||
|
|
60491a948b | ||
|
|
2a10b47aaf | ||
|
|
12bebc0445 | ||
|
|
febef6caec | ||
|
|
9be0c25bf0 | ||
|
|
976e627098 | ||
|
|
3424c3868f | ||
|
|
1ae7286376 | ||
|
|
87542d29a5 | ||
|
|
1a31ed21b1 | ||
|
|
e776192e4f | ||
|
|
5c1180b3c4 | ||
|
|
e317006080 | ||
|
|
253862fd4c | ||
|
|
366eea36d3 | ||
|
|
1ce5149ac8 | ||
|
|
4f25ebb043 | ||
|
|
93b68a0e09 | ||
|
|
7431029172 | ||
|
|
58612f1de0 | ||
|
|
02097d3eab | ||
|
|
f25bfb75aa | ||
|
|
c732d2c6dc | ||
|
|
8c165d891d | ||
|
|
ca98bf5758 | ||
|
|
0bfb02fff7 | ||
|
|
24c0aad7e7 | ||
|
|
5719c1092f | ||
|
|
271efced67 | ||
|
|
abd741b1f6 | ||
|
|
9280d3ef89 | ||
|
|
dafdc66ff0 | ||
|
|
56c4720342 | ||
|
|
1e0bab9276 | ||
|
|
74886d31e7 | ||
|
|
04e6065479 | ||
|
|
10e5b8bd0a | ||
|
|
9801d40c50 | ||
|
|
c026349221 | ||
|
|
9757c359ef | ||
|
|
6b98e4b563 | ||
|
|
ee000ba4fc | ||
|
|
8efe435c05 | ||
|
|
4f6bb8b24b | ||
|
|
1921f1d7a4 | ||
|
|
4515534cd2 | ||
|
|
f958596b44 | ||
|
|
2c5690250c | ||
|
|
592e8d4d01 | ||
|
|
0c15323de7 | ||
|
|
e96c9728da | ||
|
|
75d1fe1611 | ||
|
|
6c35d22c39 | ||
|
|
3420246357 | ||
|
|
1d6412adeb | ||
|
|
4cdb01db9b | ||
|
|
44995b2e39 | ||
|
|
e9955c8373 | ||
|
|
39fd0b540d | ||
|
|
d7215705ee | ||
|
|
5346290247 | ||
|
|
2e04746125 | ||
|
|
9af3fbce7c | ||
|
|
1485e106a4 | ||
|
|
da4160c30a | ||
|
|
f6d0f937fd | ||
|
|
69078d4b3b | ||
|
|
0624954c7e | ||
|
|
5e424082ce | ||
|
|
44536b35c4 | ||
|
|
8b9f2372c7 | ||
|
|
3ae2b51f08 | ||
|
|
2f1afb737f | ||
|
|
e9bca3aded | ||
|
|
86eff18354 | ||
|
|
9411f454b0 | ||
|
|
717be1971f | ||
|
|
efea623135 | ||
|
|
670ddffd5b | ||
|
|
769b430fce | ||
|
|
7067cb3620 | ||
|
|
4a713ec2e3 | ||
|
|
b0e5f19eab | ||
|
|
54049e5db0 | ||
|
|
b408954b40 | ||
|
|
a49aecd528 | ||
|
|
5504898e82 | ||
|
|
4fd2214bc6 | ||
|
|
ec3bc3961d | ||
|
|
78df825093 | ||
|
|
68cd8af38b | ||
|
|
660bc8dd09 | ||
|
|
c0c9ea051b | ||
|
|
6390a83f8b | ||
|
|
db7c8e9a72 | ||
|
|
158c687b65 | ||
|
|
fcc618005a | ||
|
|
308a2f7637 | ||
|
|
a46c847244 | ||
|
|
5683e9b26a | ||
|
|
0c2d3f4cba | ||
|
|
e41fdc9310 | ||
|
|
1565b72064 | ||
|
|
5181e40827 | ||
|
|
cfaee611d8 | ||
|
|
458be8e0ed | ||
|
|
a900a6248c | ||
|
|
9bbd181ae0 | ||
|
|
d4e7d3a191 | ||
|
|
39ceb25bdb | ||
|
|
5372019fab | ||
|
|
5df5f6d538 | ||
|
|
77714df234 | ||
|
|
b87f8b2159 | ||
|
|
8bb936e4f7 | ||
|
|
fba798c78e | ||
|
|
9306c70c63 | ||
|
|
3c9160d912 | ||
|
|
53c71a12c8 | ||
|
|
2de3aceee7 | ||
|
|
289dd0cf98 | ||
|
|
db85e524b4 | ||
|
|
0164db681e | ||
|
|
83ccf991a6 | ||
|
|
1f41899519 | ||
|
|
77f6f42074 | ||
|
|
45119f0446 | ||
|
|
b2d52318fa | ||
|
|
3a8b410924 | ||
|
|
2243f537c6 | ||
|
|
84614e1373 | ||
|
|
fdbcd8e289 | ||
|
|
64bd62a1be | ||
|
|
900c877b41 | ||
|
|
82b6cb3fb2 | ||
|
|
6cbfbcc58c |
+19
-17
@@ -1,21 +1,23 @@
|
||||
Makefile
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
stamp-h*
|
||||
bison-*
|
||||
patches
|
||||
*.flc
|
||||
*.patch *.log log patches applied
|
||||
*.prj
|
||||
releases
|
||||
*.flc
|
||||
autom4te.cache
|
||||
intl
|
||||
Makefile.in
|
||||
configure
|
||||
config.hin
|
||||
aclocal.m4
|
||||
ABOUT-NLS
|
||||
INSTALL
|
||||
COPYING
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
_*
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
bison-*
|
||||
config.cache
|
||||
config.h
|
||||
config.hin
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
configure.lineno
|
||||
intl
|
||||
patches
|
||||
releases
|
||||
stamp-h*
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
patch_list='Bison Patches <[email protected]>'
|
||||
+26
@@ -4,9 +4,31 @@
|
||||
# It is necessary if you want to build targets usually of interest
|
||||
# only to the maintainer.
|
||||
|
||||
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
# Systems where /bin/sh is not the default shell need this. The $(shell)
|
||||
# command below won't work with e.g. stock DOS/Windows shells.
|
||||
ifeq ($(wildcard /bin/s[h]),/bin/sh)
|
||||
SHELL = /bin/sh
|
||||
else
|
||||
# will be used only with the next shell-test line, then overwritten
|
||||
# by a configured-in value
|
||||
SHELL = sh
|
||||
endif
|
||||
|
||||
have-Makefile := $(shell test -f Makefile && echo yes)
|
||||
|
||||
@@ -14,7 +36,11 @@ have-Makefile := $(shell test -f Makefile && echo yes)
|
||||
# give them a diagnostic.
|
||||
ifeq ($(have-Makefile),yes)
|
||||
|
||||
# Make tar archive easier to reproduce.
|
||||
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
|
||||
|
||||
include Makefile
|
||||
include $(srcdir)/Makefile.cfg
|
||||
include $(srcdir)/Makefile.maint
|
||||
|
||||
else
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
-*- outline -*-
|
||||
|
||||
This file attempts to describe the rules to use when hacking Bison.
|
||||
Don't put this file into the distribution. Don't mention it in the
|
||||
ChangeLog.
|
||||
|
||||
Everything related to the development of Bison is on Savannah:
|
||||
|
||||
http://savannah.gnu.org/projects/bison/
|
||||
|
||||
|
||||
* Administrivia
|
||||
|
||||
** If you incorporate a change from somebody on the net:
|
||||
First, if it is a large change, you must make sure they have signed
|
||||
the appropriate paperwork. Second, be sure to add their name and
|
||||
email address to THANKS.
|
||||
|
||||
** If a change fixes a test, mention the test in the ChangeLog entry.
|
||||
|
||||
** Bug reports
|
||||
If somebody reports a new bug, mention his name in the ChangeLog entry
|
||||
and in the test case you write. Put him into THANKS.
|
||||
|
||||
The correct response to most actual bugs is to write a new test case
|
||||
which demonstrates the bug. Then fix the bug, re-run the test suite,
|
||||
and check everything in.
|
||||
|
||||
|
||||
* Hacking
|
||||
|
||||
** Visible changes
|
||||
Which include serious bug fixes, must be mentioned in NEWS.
|
||||
|
||||
** Translations
|
||||
Only user visible strings are to be translated: error messages, bits
|
||||
of the .output file etc. This excludes impossible error messages
|
||||
(comparable to assert/abort), and all the --trace output which is
|
||||
meant for the maintainers only.
|
||||
|
||||
|
||||
* Test suite
|
||||
|
||||
** make check
|
||||
Use liberally.
|
||||
|
||||
** Release checks
|
||||
Try to run the test suite with more severe conditions before a
|
||||
release:
|
||||
|
||||
- Configure the package with --enable-gcc-warnings, so that one checks
|
||||
that 1. Bison compiles cleanly, 2. the parsers it produces compile
|
||||
cleanly too.
|
||||
|
||||
- run `make maintainer-check' which:
|
||||
- runs `valgrind -q bison' to run Bison under Valgrind.
|
||||
- runs the parsers under Valgrind.
|
||||
- runs the test suite with G++ as C compiler...
|
||||
|
||||
- Change tests/atlocal/CFLAGS to add your preferred options. For
|
||||
instance, `-traditional' to check that the parsers are K&R. Note
|
||||
that it does not make sense for glr.c, which should be ANSI,
|
||||
but currently is actually GNU C, nor for lalr1.cc, which anyway is
|
||||
not exercised yet in the test suite.
|
||||
|
||||
|
||||
* Release Procedure
|
||||
|
||||
** Tests
|
||||
See above.
|
||||
|
||||
** Update the foreign files
|
||||
Running `./bootstrap' in the top level should update them all for you.
|
||||
This covers PO files too. Sometimes a PO file contains problems that
|
||||
causes it to be rejected by recent Gettext releases; please report
|
||||
these to the Translation Project.
|
||||
|
||||
** Update NEWS
|
||||
The version number, *and* the date of the release (including for
|
||||
betas).
|
||||
|
||||
** Update ChangeLog
|
||||
Should have an entry similar to `Version 1.49b.'.
|
||||
Check all this in once `make distcheck' passes.
|
||||
|
||||
** make alpha
|
||||
Running `make alpha' is absolutely perfect for beta releases: it makes
|
||||
the tarballs, the xdeltas, and prepares (in /tmp/) a proto
|
||||
announcement. It is so neat, that that's what I use anyway for
|
||||
genuine releases, but adjusting things by hand (e.g., the urls in the
|
||||
announcement file, the ChangeLog which is not needed etc.).
|
||||
|
||||
If it fails, you're on your own...
|
||||
|
||||
It requires GNU Make.
|
||||
|
||||
** Upload
|
||||
Put the tarballs/xdeltas where they should be. Or put it somewhere,
|
||||
and send the URL to [email protected].
|
||||
|
||||
** Bump the version number
|
||||
In configure.ac. Run `make', check this in.
|
||||
|
||||
** Announce
|
||||
Complete/fix the announcement file, and send it at least to
|
||||
[email protected] (if a real release, or a ``serious beta''),
|
||||
[email protected], [email protected], [email protected],
|
||||
and [email protected].
|
||||
|
||||
Send the same announcement on the comp.compilers newsgroup by sending
|
||||
email to [email protected]. Do not make any Cc as the moderator will
|
||||
throw away anything cross-posted or Cc'ed. It really needs to be a
|
||||
separate message.
|
||||
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
+7
-27
@@ -1,4 +1,5 @@
|
||||
## Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -15,33 +16,12 @@
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
AUTOMAKE_OPTIONS = 1.6 check-news readme-alpha dist-bzip2
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = config intl po lib data src doc m4 tests
|
||||
SUBDIRS = config po lib data src doc tests
|
||||
|
||||
EXTRA_DIST = config/config.rpath REFERENCES configure.bat OChangeLog Makefile.maint GNUmakefile
|
||||
EXTRA_DIST = REFERENCES OChangeLog Makefile.maint GNUmakefile Makefile.cfg
|
||||
|
||||
DISTCLEANFILES = intl/libintl.h
|
||||
|
||||
|
||||
## ---------------------------- ##
|
||||
## Customizing Makefile.maint. ##
|
||||
## ---------------------------- ##
|
||||
|
||||
move_if_change = $(srcdir)/config/move-if-change
|
||||
prev_version_file = $(srcdir)/config/prev-version.txt
|
||||
release_archive_dir = releases
|
||||
|
||||
# Uploading betas.
|
||||
hosts = alpha
|
||||
alpha_host = alpha.gnu.org
|
||||
alpha_url_dir = gnu/bison
|
||||
|
||||
# Files to update automatically.
|
||||
wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
|
||||
$(srcdir)/config/texinfo.tex
|
||||
|
||||
cvs_files = $(srcdir)/config/missing
|
||||
.PHONY: maintainer-check
|
||||
maintainer-check:
|
||||
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Customize Makefile.maint for Bison. -*- makefile -*-
|
||||
# Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
prev_version_file = $(srcdir)/config/prev-version.txt
|
||||
move_if_change = $(srcdir)/config/move-if-change
|
||||
announce_gen = $(srcdir)/config/announce-gen
|
||||
release_archive_dir = releases
|
||||
|
||||
# Use alpha.gnu.org for alpha and beta releases.
|
||||
# Use ftp.gnu.org for major releases.
|
||||
gnu_ftp_host-alpha = alpha
|
||||
gnu_ftp_host-beta = alpha
|
||||
gnu_ftp_host-major = ftp
|
||||
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
|
||||
|
||||
url_dir_list = \
|
||||
ftp://$(gnu_rel_host).gnu.org/gnu/bison
|
||||
|
||||
# Files to update automatically.
|
||||
wget_files = \
|
||||
$(srcdir)/config/config.guess \
|
||||
$(srcdir)/config/config.sub \
|
||||
$(srcdir)/config/texinfo.tex \
|
||||
|
||||
cvs_files = \
|
||||
$(srcdir)/config/install-sh \
|
||||
$(srcdir)/config/mdate-sh \
|
||||
$(srcdir)/config/missing \
|
||||
$(srcdir)/config/mkinstalldirs
|
||||
|
||||
# Tests not to run.
|
||||
# local-checks-to-skip ?= \
|
||||
# author_mark_check \
|
||||
# strftime-check syntax-check makefile_path_separator_check \
|
||||
# makefile-check
|
||||
+408
-238
@@ -1,8 +1,8 @@
|
||||
# -*-Makefile-*-
|
||||
# This Makefile fragment is shared between fileutils, sh-utils, textutils,
|
||||
# This Makefile fragment is shared between the coreutils,
|
||||
# CPPI, Bison, and Autoconf.
|
||||
|
||||
## Copyright 2001 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -19,40 +19,402 @@
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
## 02111-1307, USA.
|
||||
|
||||
# This is reported not to work with make-3.79.1
|
||||
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
ME := Makefile.maint
|
||||
|
||||
# Do not save the original name or timestamp in the .tar.gz file.
|
||||
GZIP_ENV = '--no-name --best'
|
||||
GZIP_ENV = \
|
||||
"--no-name --best$$( \
|
||||
case $$(gzip --help) in \
|
||||
(*--rsyncable*) echo ' --rsyncable';; \
|
||||
esac \
|
||||
)"
|
||||
|
||||
CVS = cvs
|
||||
|
||||
prev_version_file ?= .prev-version
|
||||
ifeq ($(origin prev_version_file), undefined)
|
||||
prev_version_file = .prev-version
|
||||
endif
|
||||
|
||||
THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
PREV_VERSION := $(shell cat $(prev_version_file))
|
||||
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
|
||||
|
||||
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
|
||||
tag-this-version = $(subst .,_,$(VERSION))
|
||||
tag-prev-version = $(subst .,_,$(PREV_VERSION))
|
||||
this-cvs-tag = $(tag-package)-$(tag-this-version)
|
||||
prev-cvs-tag = $(tag-package)-$(tag-prev-version)
|
||||
my_distdir = $(PACKAGE)-$(VERSION)
|
||||
|
||||
# Old releases are stored here.
|
||||
# Used for diffs and xdeltas.
|
||||
release_archive_dir ?= ../release
|
||||
|
||||
# Prevent programs like 'sort' from considering distinct strings to be equal.
|
||||
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
|
||||
export LC_ALL = C
|
||||
|
||||
|
||||
|
||||
## --------------- ##
|
||||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# Checks that don't require cvs.
|
||||
# Run `changelog-check' last, as previous test may reveal problems requiring
|
||||
# new ChangeLog entries.
|
||||
local-checks-available = \
|
||||
po-check copyright-check writable-files m4-check author_mark_check \
|
||||
changelog-check strftime-check syntax-check makefile_path_separator_check \
|
||||
makefile-check
|
||||
.PHONY: $(local-checks-available)
|
||||
|
||||
local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
|
||||
|
||||
# Make sure C source files in src/ don't include xalloc.h directly,
|
||||
# since they all already include it via sys2.h.
|
||||
# It's not a big deal -- just aesthetics.
|
||||
.PHONY: $(syntax-check-rules)
|
||||
syntax-check-rules = \
|
||||
sc_cast_of_argument_to_free \
|
||||
sc_cast_of_x_alloc_return_value \
|
||||
sc_changelog \
|
||||
sc_error_exit_success \
|
||||
sc_space_tab \
|
||||
sc_sun_os_names \
|
||||
sc_system_h_headers \
|
||||
sc_unmarked_diagnostics \
|
||||
sc_xalloc_h_in_src
|
||||
|
||||
syntax-check: $(syntax-check-rules)
|
||||
# @grep -E '# *include <(limits|std(def|arg|bool))\.h>' \
|
||||
# $$(find -type f -name '*.[chly]') && \
|
||||
# { echo '$(ME): found conditional include' 1>&2; \
|
||||
# exit 1; } || :
|
||||
|
||||
# grep -E '^# *include <(string|stdlib)\.h>' \
|
||||
# $(srcdir)/{lib,src}/*.[chy] && \
|
||||
# { echo '$(ME): FIXME' 1>&2; \
|
||||
# exit 1; } || :
|
||||
# FIXME: don't allow `#include .strings\.h' anywhere
|
||||
|
||||
# Look for diagnostics that aren't marked for translation.
|
||||
# This won't find any for which error's format string is on a separate line.
|
||||
sc_unmarked_diagnostics:
|
||||
@grep --exclude=$(srcdir)/src/shred.c -E \
|
||||
'\<error \([^"]*"[^"]*[a-z]{3}' $(srcdir)/{lib,src}/*.c \
|
||||
| grep -v '_(' && \
|
||||
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_argument_to_free:
|
||||
@grep -E '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
|
||||
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_x_alloc_return_value:
|
||||
@grep -E --exclude=$(srcdir)/lib/regex.c \
|
||||
'\*\) *x(m|c|re)alloc\>' $(srcdir)/{lib,src}/*.[chy] && \
|
||||
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_space_tab:
|
||||
@( cvsu --list ) > /dev/null 2>&1 || : && \
|
||||
grep '[ ] ' \
|
||||
$$(cvsu --list | grep -vEf .x-$@ ) && \
|
||||
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
||||
# since when that parameter is 0, error does not exit. Use `0' instead.
|
||||
sc_error_exit_success:
|
||||
@grep -F 'error (EXIT_SUCCESS,' \
|
||||
$$(find -type f -name '*.[chly]') && \
|
||||
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# FIXME: merge this with sc_system_h_headers below.
|
||||
# xalloc.h is included via system.h, so should not be included
|
||||
# directly by any file in src/.
|
||||
sc_xalloc_h_in_src:
|
||||
@if test -f $(srcdir)/src/sys2.h; then \
|
||||
if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
|
||||
|
||||
# Each nonempty line must start with a year number, or a TAB.
|
||||
sc_changelog:
|
||||
@grep '^[^12 ]' $$(find . -name ChangeLog -maxdepth 2) && \
|
||||
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
header_regexp = \
|
||||
alloca\
|
||||
|closeout\
|
||||
|ctype\
|
||||
|dirent\
|
||||
|errno\
|
||||
|fcntl\
|
||||
|inttypes\
|
||||
|limits\
|
||||
|locale\
|
||||
|pathmax\
|
||||
|std(lib|bool)\
|
||||
|string\
|
||||
|sys/(stat|dir|time)\
|
||||
|time\
|
||||
|unistd\
|
||||
|utime\
|
||||
|version-etc\
|
||||
|xalloc
|
||||
h_re := $(shell echo '$(header_regexp)'|tr -d ' ')
|
||||
|
||||
# Files in src/ should not include directly any of
|
||||
# the headers already included via system.h.
|
||||
# Get list of candidates with this:
|
||||
# grep -h include src/sys*.h|sed 's/.*include //'|sort -
|
||||
sc_system_h_headers:
|
||||
@( cvsu --list ) > /dev/null 2>&1 || : && \
|
||||
grep -E '^# *include ["<]($(h_re))\.h[">]' \
|
||||
$$(cvsu --list src | grep -Ev 'sys(2|tem)\.h$$') \
|
||||
&& { echo '$(ME): the above are already included via system.h'\
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
sc_sun_os_names:
|
||||
@( cvsu --list ) > /dev/null 2>&1 || : && \
|
||||
grep -Ei \
|
||||
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
|
||||
$$(cvsu --list | grep -vEf .x-$@ ) && \
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
# which date accepts but GNU strftime does not.
|
||||
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
|
||||
strftime-check:
|
||||
if test -f $(srcdir)/src/date.c; then \
|
||||
grep '^ %. ' $(srcdir)/src/date.c | sort \
|
||||
| $(extract_char) > $@-src; \
|
||||
{ echo N; \
|
||||
info libc date calendar format | grep '^ `%.'\' \
|
||||
| $(extract_char); } | sort > $@-info; \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
rm -f $@-src $@-info; \
|
||||
fi
|
||||
|
||||
# Ensure that we use only the standard $(VAR) notation,
|
||||
# not @...@ in Makefile.am, now that we can rely on automake
|
||||
# to emit a definition for each substituted variable.
|
||||
makefile-check:
|
||||
grep -E '@[A-Z_0-9]+@' `find . -name Makefile.am` \
|
||||
&& { echo 'Makefile.maint: use $(...), not @...@' 1>&2; exit 1; } || :
|
||||
|
||||
changelog-check:
|
||||
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
m4-check:
|
||||
@grep 'AC_DEFUN([^[]' m4/*.m4 \
|
||||
&& { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||
po-check:
|
||||
if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
|
||||
files=; \
|
||||
for file in lib/*.[chly] src/*.[chly]; do \
|
||||
case $$file in \
|
||||
*.[ch]) \
|
||||
base=`expr " $$file" : ' \(.*\)\..'`; \
|
||||
{ test -f $$base.l || test -f $$base.y; } && continue;; \
|
||||
esac; \
|
||||
files="$$files $$file"; \
|
||||
done; \
|
||||
grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
|
||||
diff -u $@-1 $@-2 || exit 1; \
|
||||
rm -f $@-1 $@-2; \
|
||||
fi
|
||||
|
||||
# In a definition of #define AUTHORS "... and ..." where the RHS contains
|
||||
# the English word `and', the string must be marked with `N_ (...)' so that
|
||||
# gettext recognizes it as a string requiring translation.
|
||||
author_mark_check:
|
||||
@grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
|
||||
{ echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Sometimes it is useful to change the PATH environment variable
|
||||
# in Makefiles. When doing so, it's better not to use the Unix-centric
|
||||
# path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
|
||||
# It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
|
||||
# and there probably aren't many projects with so many Makefile.am files
|
||||
# that we'd have to worry about limits on command line length.
|
||||
msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
|
||||
makefile_path_separator_check:
|
||||
@grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
|
||||
&& { echo $(msg) 1>&2; exit 1; } || :
|
||||
|
||||
# Check that `make alpha' will not fail at the end of the process.
|
||||
writable-files:
|
||||
if test -d $(release_archive_dir); then :; else \
|
||||
mkdir $(release_archive_dir); \
|
||||
fi
|
||||
for file in $(distdir).tar.gz $(xd-delta) \
|
||||
$(release_archive_dir)/$(distdir).tar.gz \
|
||||
$(release_archive_dir)/$(xd-delta); do \
|
||||
test -e $$file || continue; \
|
||||
test -w $$file \
|
||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||
done; \
|
||||
test "$$fail" && exit 1 || :
|
||||
|
||||
v_etc_file = lib/version-etc.c
|
||||
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
||||
copyright-check:
|
||||
@if test -f $(v_etc_file); then \
|
||||
grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
fi
|
||||
|
||||
|
||||
# Sanity checks with the CVS repository.
|
||||
cvs-tag-check:
|
||||
echo $(this-cvs-tag); \
|
||||
if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
|
||||
echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
else :; fi
|
||||
|
||||
cvs-diff-check:
|
||||
if $(CVS) diff >cvs-diffs; then \
|
||||
rm cvs-diffs; \
|
||||
else \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
cat cvs-diffs; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
cvs-check: cvs-diff-check cvs-tag-check
|
||||
|
||||
maintainer-distcheck: changelog-check
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
|
||||
# Tag before making distribution. Also, don't make a distribution if
|
||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
||||
cvs-dist: $(local-check) cvs-check maintainer-distcheck
|
||||
$(CVS) update po
|
||||
$(CVS) tag -c $(this-cvs-tag)
|
||||
$(MAKE) dist
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
# from a virgin tgz file, below.
|
||||
null_AM_MAKEFLAGS = \
|
||||
ACLOCAL=false \
|
||||
AUTOCONF=false \
|
||||
AUTOMAKE=false \
|
||||
AUTOHEADER=false \
|
||||
MAKEINFO=false
|
||||
|
||||
# Detect format-string/arg-list mismatches that would normally be obscured
|
||||
# by the use of _(). The --disable-nls effectively defines away that macro,
|
||||
# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
|
||||
# treated as a failure.
|
||||
TMPDIR ?= /tmp
|
||||
t=$(TMPDIR)/$(PACKAGE)/test
|
||||
my-distcheck: $(local-check)
|
||||
-rm -rf $(t)
|
||||
mkdir -p $(t)
|
||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) distclean
|
||||
(cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
|
||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
echo "========================"
|
||||
|
||||
WGET = wget
|
||||
WGETFLAGS = -C off
|
||||
|
||||
tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||
tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||
bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||
bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||
xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
|
||||
xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
|
||||
tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
|
||||
bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
|
||||
xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
|
||||
|
||||
rel-check:
|
||||
tarz=/tmp/rel-check-tarz-$$$$; \
|
||||
md5_tmp=/tmp/rel-check-md5-$$$$; \
|
||||
set -e; \
|
||||
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
|
||||
$(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
|
||||
echo "$(md5) -" > $$md5_tmp; \
|
||||
md5sum -c $$md5_tmp < $$tarz
|
||||
|
||||
prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
||||
|
||||
signatures ?= $(distdir).tar.bz2.asc $(distdir).tar.gz.asc
|
||||
%.asc: %
|
||||
rm -f $@
|
||||
gpg --armor --detach-sign -o $@ $<
|
||||
|
||||
rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz $(signatures)
|
||||
announce_gen ?= ./announce-gen
|
||||
announcement: NEWS ChangeLog $(rel-files) $(signatures)
|
||||
@$(announce_gen) \
|
||||
--release-type=$(RELEASE_TYPE) \
|
||||
--package=$(PACKAGE) \
|
||||
--prev=$(PREV_VERSION) \
|
||||
--curr=$(VERSION) \
|
||||
--release-archive-directory=$(release_archive_dir) \
|
||||
--news=NEWS \
|
||||
$(addprefix --url-dir=, $(url_dir_list)) \
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Updating files. ##
|
||||
## ---------------- ##
|
||||
|
||||
WGET = wget
|
||||
ftp-gnu = ftp://ftp.gnu.org/gnu
|
||||
www-gnu = http://www.gnu.org
|
||||
|
||||
# Use mv, if you don't have/want move-if-change.
|
||||
move_if_change ?= move-if-change
|
||||
|
||||
|
||||
# --------------------- #
|
||||
# Updating everything. #
|
||||
# --------------------- #
|
||||
|
||||
.PHONY: update
|
||||
local_updates ?= wget-update cvs-update po-update
|
||||
update: $(local_updates)
|
||||
|
||||
|
||||
# ------------------- #
|
||||
# Updating PO files. #
|
||||
# ------------------- #
|
||||
@@ -63,7 +425,8 @@ do-po-update:
|
||||
tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
|
||||
rm -rf $$tmppo && \
|
||||
mkdir $$tmppo && \
|
||||
(cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
|
||||
(cd $$tmppo && \
|
||||
$(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
|
||||
cp $$tmppo/*.po po
|
||||
cd po && $(MAKE) update-po
|
||||
$(MAKE) po-check
|
||||
@@ -80,10 +443,11 @@ po-update:
|
||||
# The following pseudo table associates a local directory and a URL
|
||||
# with each of the files that belongs to some other package and is
|
||||
# regularly updated from the specified URL.
|
||||
wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
|
||||
wget_files ?= $(srcdir)/config/config.guess \
|
||||
$(srcdir)/config/config.sub \
|
||||
$(srcdir)/src/ansi2knr.c \
|
||||
$(srcdir)/doc/texinfo.tex
|
||||
wget-targets = $(patsubst %, get-%, $(wget_files))
|
||||
$(srcdir)/config/texinfo.tex
|
||||
get-targets = $(patsubst %, get-%, $(wget_files))
|
||||
|
||||
config.guess-url_prefix = $(ftp-gnu)/config/
|
||||
config.sub-url_prefix = $(ftp-gnu)/config/
|
||||
@@ -92,241 +456,46 @@ ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
|
||||
|
||||
texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
|
||||
|
||||
standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
|
||||
make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
|
||||
standards.texi-url_prefix = $(www-gnu)/prep/
|
||||
make-stds.texi-url_prefix = $(standards.texi-url_prefix)
|
||||
|
||||
target = $(patsubst get-%, %, $@)
|
||||
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
|
||||
|
||||
.PHONY: $(wget-targets)
|
||||
$(wget-targets):
|
||||
$(WGET) $(url) -O $(target).t \
|
||||
.PHONY: $(get-targets)
|
||||
$(get-targets):
|
||||
$(WGET) $(WGETFLAGS) $(url) -O $(target).t \
|
||||
&& $(move_if_change) $(target).t $(target)
|
||||
|
||||
cvs_files ?= \
|
||||
$(srcdir)/src/ansi2knr.c \
|
||||
$(srcdir)/config/depcomp \
|
||||
$(srcdir)/config/install-sh \
|
||||
$(srcdir)/config/missing \
|
||||
$(srcdir)/config/mkinstalldirs
|
||||
automake_repo=:pserver:anoncvs:[email protected]:/cvs/automake
|
||||
.PHONY: wget-update
|
||||
wget-update: $(wget-targets)
|
||||
|
||||
|
||||
# Updating tools via CVS.
|
||||
cvs_files ?= depcomp missing
|
||||
cvs-targets = $(patsubst %, get-%, $(cvs_files))
|
||||
|
||||
automake_repo = :pserver:[email protected]:/cvs/automake
|
||||
.PHONY: $(cvs-targets)
|
||||
$(cvs-targets):
|
||||
$(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \
|
||||
>$(target).t \
|
||||
&& $(move_if_change) $(target).t $(target);
|
||||
wget-update: $(get-targets)
|
||||
|
||||
.PHONY: cvs-update
|
||||
cvs-update: $(cvs-targets)
|
||||
|
||||
|
||||
# --------------------- #
|
||||
# Updating everything. #
|
||||
# --------------------- #
|
||||
|
||||
.PHONY: update
|
||||
update: wget-update cvs-update po-update
|
||||
|
||||
|
||||
|
||||
## --------------- ##
|
||||
## Sanity checks. ##
|
||||
## --------------- ##
|
||||
|
||||
# Checks that don't require cvs. Run `changelog-check' last as
|
||||
# previous test may reveal problems requiring new ChangeLog entries.
|
||||
local-check: po-check copyright-check writable-files changelog-check
|
||||
|
||||
changelog-check:
|
||||
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||
po-check:
|
||||
if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
|
||||
grep -E -l '\b_\(' lib/*.c src/*.c | sort > $@-2; \
|
||||
diff -u $@-1 $@-2 || exit 1; \
|
||||
rm -f $@-1 $@-2; \
|
||||
fi
|
||||
|
||||
# Check that `make alpha' will not fail at the end of the process.
|
||||
writable-files:
|
||||
if test -d $(release_archive_dir); then :; else \
|
||||
mkdir $(release_archive_dir); \
|
||||
fi
|
||||
for file in $(distdir).tar.gz $(xd-delta) \
|
||||
$(release_archive_dir)/$(distdir).tar.gz \
|
||||
$(release_archive_dir)/$(xd-delta); do \
|
||||
test -e $$file || continue; \
|
||||
test -w $$file \
|
||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||
cvs-update:
|
||||
fail=; \
|
||||
for f in $(cvs_files); do \
|
||||
test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
|
||||
cvs diff $$f > /dev/null \
|
||||
|| { echo "*** $$f is locally modified; skipping it" 1>&2; \
|
||||
fail=yes; continue; }; \
|
||||
file=$$(basename $$f); \
|
||||
echo checking out $$file...; \
|
||||
$(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
|
||||
&& $(move_if_change) $$f.t $$f; \
|
||||
done; \
|
||||
test "$$fail" && exit 1 || :
|
||||
test "$$fail" && exit 1
|
||||
|
||||
# Make sure that the copyright date in lib/version-etc.c is up to date.
|
||||
copyright-check:
|
||||
@if test -f lib/version-etc.c; then \
|
||||
grep 'N_("Copyright (C) $(shell date +%Y) Free' lib/version-etc.c \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $<; update it' 1>&2; exit 1; }; \
|
||||
fi
|
||||
|
||||
|
||||
# Sanity checks with the CVS repository.
|
||||
cvs-tag-check:
|
||||
echo $(this-cvs-tag); \
|
||||
if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
|
||||
echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
else :; fi
|
||||
|
||||
cvs-diff-check:
|
||||
if $(CVS) diff >cvs-diffs; then \
|
||||
rm cvs-diffs; \
|
||||
else \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
cat cvs-diffs; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
cvs-check: cvs-diff-check cvs-tag-check
|
||||
|
||||
maintainer-distcheck: changelog-check
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Making dists. ##
|
||||
## -------------- ##
|
||||
|
||||
|
||||
# Tag before making distribution. Also, don't make a distribution if
|
||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
||||
cvs-dist: local-check cvs-check maintainer-distcheck
|
||||
$(CVS) update po
|
||||
$(CVS) tag -c $(this-cvs-tag)
|
||||
$(MAKE) dist
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
# from a virgin tgz file, below.
|
||||
null_AM_MAKEFLAGS = \
|
||||
ACLOCAL=false \
|
||||
AUTOCONF=false \
|
||||
AUTOM4TE=false \
|
||||
AUTOMAKE=false \
|
||||
AUTOHEADER=false \
|
||||
MAKEINFO=false
|
||||
|
||||
# Detect format-string/arg-list mismatches that would normally be obscured
|
||||
# by the use of _(). The --disable-nls effectively defines away that macro,
|
||||
# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
|
||||
# treated as a failure.
|
||||
t=./=test
|
||||
my-distcheck: writable-files po-check
|
||||
-rm -rf $(t)
|
||||
mkdir $(t)
|
||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) distclean
|
||||
cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
echo "========================"
|
||||
|
||||
# This must be the same name on both hosts.
|
||||
# Make it a symlink that points to the right place.
|
||||
real_dir = fetish-ftp
|
||||
|
||||
url_dir_list = $(foreach x,$(hosts),ftp://$($(x)_host)/$($(x)_url_dir))
|
||||
|
||||
tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||
tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||
bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||
bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||
tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([Mk]\).*/ \1B/')
|
||||
bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([Mk]\).*/ \1B/')
|
||||
xd-size = $(shell du --human $(xd-delta)|sed 's/\([Mk]\).*/ \1B/')
|
||||
|
||||
rel-check:
|
||||
tarz=/tmp/rel-check-tarz-$$$$; \
|
||||
md5_tmp=/tmp/rel-check-md5-$$$$; \
|
||||
set -e; \
|
||||
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
|
||||
$(WGET) -q --output-document=$$tarz $(url); \
|
||||
echo "$(md5) -" > $$md5_tmp; \
|
||||
md5sum -c $$md5_tmp < $$tarz
|
||||
|
||||
prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
||||
|
||||
GZIP = gzip
|
||||
BZIP2 = bzip2
|
||||
$(my_distdir).tar.bz2: $(my_distdir).tar.gz
|
||||
$(GZIP) -dc $< > $(my_distdir).tar
|
||||
rm -f $@
|
||||
$(BZIP2) -9 $(my_distdir).tar
|
||||
|
||||
rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
|
||||
announcement: NEWS ChangeLog $(rel-files)
|
||||
@( \
|
||||
echo Subject: $(my_distdir) released; \
|
||||
echo; \
|
||||
echo FIXME: put comments here; \
|
||||
echo; \
|
||||
for url in $(url_dir_list); do \
|
||||
echo " $$url/$(my_distdir).tar.gz ($(tgz-size))"; \
|
||||
echo " $$url/$(my_distdir).tar.bz2 ($(bz2-size))"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo And here are xdelta-style diffs; \
|
||||
echo; \
|
||||
for url in $(url_dir_list); do \
|
||||
echo " $$url/$(xd-delta) ($(xd-size))"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo "Here are the MD5 and SHA1 signatures for the compressed tar files:"; \
|
||||
echo; \
|
||||
echo "$(tgz-md5) $(my_distdir).tar.gz"; \
|
||||
echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
|
||||
echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
|
||||
echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
|
||||
echo; \
|
||||
echo NEWS:; \
|
||||
sed -n "/$(THIS_VERSION_REGEXP)[]:]/,/$(PREV_VERSION_REGEXP)[]:]/p" NEWS \
|
||||
| grep -v '^\['; \
|
||||
echo; \
|
||||
echo ChangeLog entries:; \
|
||||
find . -name ChangeLog -maxdepth 2 \
|
||||
| xargs $(CVS) diff -up -r$(prev-cvs-tag) -rHEAD \
|
||||
| sed -n 's/^+//p' \
|
||||
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
|
||||
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
|
||||
)
|
||||
|
||||
define emit-rsync-commands
|
||||
define emit-upload-commands
|
||||
echo =====================================
|
||||
echo =====================================
|
||||
echo 'for host in $(a_host) $(b_host); do \'
|
||||
echo ' rsync -e ssh --pro -av $(xd-delta) $(my_distdir).tar.bz2 \'
|
||||
echo ' $(my_distdir).tar.gz $$host:$(real_dir); done'
|
||||
echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
|
||||
echo '# send the /tmp/announcement e-mail'
|
||||
echo =====================================
|
||||
echo =====================================
|
||||
@@ -335,12 +504,13 @@ endef
|
||||
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
||||
xdelta delta -9 $^ $@ || :
|
||||
|
||||
alpha:
|
||||
.PHONY: alpha beta major
|
||||
alpha beta major: $(local-check)
|
||||
$(MAKE) cvs-dist
|
||||
$(MAKE) $(xd-delta)
|
||||
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
|
||||
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
|
||||
ln $(rel-files) $(release_archive_dir)
|
||||
chmod a-w $(rel-files)
|
||||
echo $(VERSION) > $(prev_version_file)
|
||||
$(CVS) ci -m. $(prev_version_file)
|
||||
@$(emit-rsync-commands)
|
||||
@$(emit-upload-commands)
|
||||
|
||||
@@ -1,36 +1,269 @@
|
||||
Bison News
|
||||
----------
|
||||
|
||||
Changes in version 1.49a:
|
||||
Changes in version 2.0, 2004-12-25:
|
||||
|
||||
* Possibly-incompatible changes
|
||||
|
||||
- Bison-generated parsers no longer default to using the alloca function
|
||||
(when available) to extend the parser stack, due to widespread
|
||||
problems in unchecked stack-overflow detection. You can "#define
|
||||
YYSTACK_USE_ALLOCA 1" to require the use of alloca, but please read
|
||||
the manual to determine safe values for YYMAXDEPTH in that case.
|
||||
|
||||
- Error token location.
|
||||
During error recovery, the location of the syntax error is updated
|
||||
to cover the whole sequence covered by the error token: it includes
|
||||
the shifted symbols thrown away during the first part of the error
|
||||
recovery, and the lookahead rejected during the second part.
|
||||
|
||||
- Semicolon changes:
|
||||
. Stray semicolons are no longer allowed at the start of a grammar.
|
||||
. Semicolons are now required after in-grammar declarations.
|
||||
|
||||
- Unescaped newlines are no longer allowed in character constants or
|
||||
string literals. They were never portable, and GCC 3.4.0 has
|
||||
dropped support for them. Better diagnostics are now generated if
|
||||
forget a closing quote.
|
||||
|
||||
- NUL bytes are no longer allowed in Bison string literals, unfortunately.
|
||||
|
||||
* New features
|
||||
|
||||
- GLR grammars now support locations.
|
||||
|
||||
- New directive: %initial-action.
|
||||
This directive allows the user to run arbitrary code (including
|
||||
initializing @$) from yyparse before parsing starts.
|
||||
|
||||
- A new directive "%expect-rr N" specifies the expected number of
|
||||
reduce/reduce conflicts in GLR parsers.
|
||||
|
||||
- %token numbers can now be hexadecimal integers, e.g., `%token FOO 0x12d'.
|
||||
This is a GNU extension.
|
||||
|
||||
- The option `--report=lookahead' was changed to `--report=look-ahead'.
|
||||
The old spelling still works, but is not documented and will be
|
||||
removed.
|
||||
|
||||
- Experimental %destructor support has been added to lalr1.cc.
|
||||
|
||||
- New configure option --disable-yacc, to disable installation of the
|
||||
yacc command and -ly library introduced in 1.875 for POSIX conformance.
|
||||
|
||||
* Bug fixes
|
||||
|
||||
- For now, %expect-count violations are now just warnings, not errors.
|
||||
This is for compatibility with Bison 1.75 and earlier (when there are
|
||||
reduce/reduce conflicts) and with Bison 1.30 and earlier (when there
|
||||
are too many or too few shift/reduce conflicts). However, in future
|
||||
versions of Bison we plan to improve the %expect machinery so that
|
||||
these violations will become errors again.
|
||||
|
||||
- Within Bison itself, numbers (e.g., goto numbers) are no longer
|
||||
arbitrarily limited to 16-bit counts.
|
||||
|
||||
- Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
|
||||
|
||||
Changes in version 1.875, 2003-01-01:
|
||||
|
||||
* The documentation license has been upgraded to version 1.2
|
||||
of the GNU Free Documentation License.
|
||||
|
||||
* syntax error processing
|
||||
|
||||
- In Yacc-style parsers YYLLOC_DEFAULT is now used to compute error
|
||||
locations too. This fixes bugs in error-location computation.
|
||||
|
||||
- %destructor
|
||||
It is now possible to reclaim the memory associated to symbols
|
||||
discarded during error recovery. This feature is still experimental.
|
||||
|
||||
- %error-verbose
|
||||
This new directive is preferred over YYERROR_VERBOSE.
|
||||
|
||||
- #defining yyerror to steal internal variables is discouraged.
|
||||
It is not guaranteed to work forever.
|
||||
|
||||
* POSIX conformance
|
||||
|
||||
- Semicolons are once again optional at the end of grammar rules.
|
||||
This reverts to the behavior of Bison 1.33 and earlier, and improves
|
||||
compatibility with Yacc.
|
||||
|
||||
- `parse error' -> `syntax error'
|
||||
Bison now uniformly uses the term `syntax error'; formerly, the code
|
||||
and manual sometimes used the term `parse error' instead. POSIX
|
||||
requires `syntax error' in diagnostics, and it was thought better to
|
||||
be consistent.
|
||||
|
||||
- The documentation now emphasizes that yylex and yyerror must be
|
||||
declared before use. C99 requires this.
|
||||
|
||||
- Bison now parses C99 lexical constructs like UCNs and
|
||||
backslash-newline within C escape sequences, as POSIX 1003.1-2001 requires.
|
||||
|
||||
- File names are properly escaped in C output. E.g., foo\bar.y is
|
||||
output as "foo\\bar.y".
|
||||
|
||||
- Yacc command and library now available
|
||||
The Bison distribution now installs a `yacc' command, as POSIX requires.
|
||||
Also, Bison now installs a small library liby.a containing
|
||||
implementations of Yacc-compatible yyerror and main functions.
|
||||
This library is normally not useful, but POSIX requires it.
|
||||
|
||||
- Type clashes now generate warnings, not errors.
|
||||
|
||||
- If the user does not define YYSTYPE as a macro, Bison now declares it
|
||||
using typedef instead of defining it as a macro.
|
||||
For consistency, YYLTYPE is also declared instead of defined.
|
||||
|
||||
* Other compatibility issues
|
||||
|
||||
- %union directives can now have a tag before the `{', e.g., the
|
||||
directive `%union foo {...}' now generates the C code
|
||||
`typedef union foo { ... } YYSTYPE;'; this is for Yacc compatibility.
|
||||
The default union tag is `YYSTYPE', for compatibility with Solaris 9 Yacc.
|
||||
For consistency, YYLTYPE's struct tag is now `YYLTYPE' not `yyltype'.
|
||||
This is for compatibility with both Yacc and Bison 1.35.
|
||||
|
||||
- `;' is output before the terminating `}' of an action, for
|
||||
compatibility with Bison 1.35.
|
||||
|
||||
- Bison now uses a Yacc-style format for conflict reports, e.g.,
|
||||
`conflicts: 2 shift/reduce, 1 reduce/reduce'.
|
||||
|
||||
- `yystype' and `yyltype' are now obsolescent macros instead of being
|
||||
typedefs or tags; they are no longer documented and are planned to be
|
||||
withdrawn in a future release.
|
||||
|
||||
* GLR parser notes
|
||||
|
||||
- GLR and inline
|
||||
Users of Bison have to decide how they handle the portability of the
|
||||
C keyword `inline'.
|
||||
|
||||
- `parsing stack overflow...' -> `parser stack overflow'
|
||||
GLR parsers now report `parser stack overflow' as per the Bison manual.
|
||||
|
||||
* Bison now warns if it detects conflicting outputs to the same file,
|
||||
e.g., it generates a warning for `bison -d -o foo.h foo.y' since
|
||||
that command outputs both code and header to foo.h.
|
||||
|
||||
* #line in output files
|
||||
- --no-line works properly.
|
||||
|
||||
* Bison can no longer be built by a K&R C compiler; it requires C89 or
|
||||
later to be built. This change originally took place a few versions
|
||||
ago, but nobody noticed until we recently asked someone to try
|
||||
building Bison with a K&R C compiler.
|
||||
|
||||
Changes in version 1.75, 2002-10-14:
|
||||
|
||||
* Bison should now work on 64-bit hosts.
|
||||
|
||||
* Indonesian translation thanks to Tedi Heriyanto.
|
||||
|
||||
* GLR parsers
|
||||
Fix spurious parse errors.
|
||||
|
||||
* Pure parsers
|
||||
Some people redefine yyerror to steal yyparse' private variables.
|
||||
Reenable this trick until an official feature replaces it.
|
||||
|
||||
* Type Clashes
|
||||
In agreement with POSIX and with other Yaccs, leaving a default
|
||||
action is valid when $$ is untyped, and $1 typed:
|
||||
|
||||
untyped: ... typed;
|
||||
|
||||
but the converse remains an error:
|
||||
|
||||
typed: ... untyped;
|
||||
|
||||
* Values of mid-rule actions
|
||||
The following code:
|
||||
|
||||
foo: { ... } { $$ = $1; } ...
|
||||
|
||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||
action, and is equal to the $$ of the first mid-rule action.
|
||||
|
||||
Changes in version 1.50, 2002-10-04:
|
||||
|
||||
* GLR parsing
|
||||
The declaration
|
||||
%glr-parser
|
||||
causes Bison to produce a Generalized LR (GLR) parser, capable of handling
|
||||
almost any context-free grammar, ambiguous or not. The new declarations
|
||||
%dprec and %merge on grammar rules allow parse-time resolution of
|
||||
ambiguities. Contributed by Paul Hilfinger.
|
||||
|
||||
Unfortunately Bison 1.50 does not work properly on 64-bit hosts
|
||||
like the Alpha, so please stick to 32-bit hosts for now.
|
||||
|
||||
* Output Directory
|
||||
When not in Yacc compatibility mode, when the output file was not
|
||||
specified, running `bison foo/bar.y' created `foo/bar.c'. It
|
||||
now creates `bar.c'.
|
||||
|
||||
* Undefined token
|
||||
The undefined token was systematically mapped to 2 which prevented
|
||||
the use of 2 from the user. This is no longer the case.
|
||||
the use of 2 by the user. This is no longer the case.
|
||||
|
||||
* Undefined token
|
||||
If yylex returned a code out of range, yyparse could die. This is
|
||||
* Unknown token numbers
|
||||
If yylex returned an out of range value, yyparse could die. This is
|
||||
no longer the case.
|
||||
|
||||
* Error token
|
||||
According to POSIX, the error token should be numbered as 256.
|
||||
According to POSIX, the error token must be 256.
|
||||
Bison extends this requirement by making it a preference: *if* the
|
||||
user specified that one of her tokens is numbered 256, then error
|
||||
will be mapped onto another number.
|
||||
|
||||
* Large grammars
|
||||
Are now supported (large token numbers, large grammar size (= sum of
|
||||
the LHS and RHS lengths), large LALR tables).
|
||||
* Verbose error messages
|
||||
They no longer report `..., expecting error or...' for states where
|
||||
error recovery is possible.
|
||||
|
||||
* The initial rule is explicit.
|
||||
* End token
|
||||
Defaults to `$end' instead of `$'.
|
||||
|
||||
* Error recovery now conforms to documentation and to POSIX
|
||||
When a Bison-generated parser encounters a syntax error, it now pops
|
||||
the stack until it finds a state that allows shifting the error
|
||||
token. Formerly, it popped the stack until it found a state that
|
||||
allowed some non-error action other than a default reduction on the
|
||||
error token. The new behavior has long been the documented behavior,
|
||||
and has long been required by POSIX. For more details, please see
|
||||
Paul Eggert, "Reductions during Bison error handling" (2002-05-20)
|
||||
<http://lists.gnu.org/archive/html/bug-bison/2002-05/msg00038.html>.
|
||||
|
||||
* Traces
|
||||
Popped tokens and nonterminals are now reported.
|
||||
|
||||
* Larger grammars
|
||||
Larger grammars are now supported (larger token numbers, larger grammar
|
||||
size (= sum of the LHS and RHS lengths), larger LALR tables).
|
||||
Formerly, many of these numbers ran afoul of 16-bit limits;
|
||||
now these limits are 32 bits on most hosts.
|
||||
|
||||
* Explicit initial rule
|
||||
Bison used to play hacks with the initial rule, which the user does
|
||||
not write. It is now explicit, and visible in the reports and
|
||||
graphs as rule 0.
|
||||
|
||||
* Useless rules are actually removed.
|
||||
* Useless rules
|
||||
Before, Bison reported the useless rules, but, although not used,
|
||||
included them in the parsers.
|
||||
included them in the parsers. They are now actually removed.
|
||||
|
||||
* False `Token not used' report fixed.
|
||||
* Useless rules, useless nonterminals
|
||||
They are now reported, as a warning, with their locations.
|
||||
|
||||
* Rules never reduced
|
||||
Rules that can never be reduced because of conflicts are now
|
||||
reported.
|
||||
|
||||
* Incorrect `Token not used'
|
||||
On a grammar such as
|
||||
|
||||
%token useless useful
|
||||
@@ -40,21 +273,62 @@ Changes in version 1.49a:
|
||||
where a token was used to set the precedence of the last rule,
|
||||
bison reported both `useful' and `useless' as useless tokens.
|
||||
|
||||
* Revert the C++ namespace changes introduced in 1.31, as they caused too
|
||||
many portability hassles.
|
||||
* Revert the C++ namespace changes introduced in 1.31
|
||||
as they caused too many portability hassles.
|
||||
|
||||
* Items overflow
|
||||
Bison no longer dumps core when there are too many items, it just
|
||||
dies.
|
||||
* Default locations
|
||||
By an accident of design, the default computation of @$ was
|
||||
performed after another default computation was performed: @$ = @1.
|
||||
The latter is now removed: YYLLOC_DEFAULT is fully responsible of
|
||||
the computation of @$.
|
||||
|
||||
* Token end-of-file
|
||||
The token end of file may be specified by the user, in which case,
|
||||
the user symbol is used in the reports, the graphs, and the verbose
|
||||
error messages instead of `$', which remains being the defaults.
|
||||
error messages instead of `$end', which remains being the default.
|
||||
For instance
|
||||
%token YYEOF 0
|
||||
%token MYEOF 0
|
||||
or
|
||||
%token YYEOF 0 "end of file"
|
||||
%token MYEOF 0 "end of file"
|
||||
|
||||
* Semantic parser
|
||||
This old option, which has been broken for ages, is removed.
|
||||
|
||||
* New translations
|
||||
Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
|
||||
Croatian, thanks to Denis Lackovic.
|
||||
|
||||
* Incorrect token definitions
|
||||
When given `%token 'a' "A"', Bison used to output `#define 'a' 65'.
|
||||
|
||||
* Token definitions as enums
|
||||
Tokens are output both as the traditional #define's, and, provided
|
||||
the compiler supports ANSI C or is a C++ compiler, as enums.
|
||||
This lets debuggers display names instead of integers.
|
||||
|
||||
* Reports
|
||||
In addition to --verbose, bison supports --report=THINGS, which
|
||||
produces additional information:
|
||||
- itemset
|
||||
complete the core item sets with their closure
|
||||
- lookahead [changed to `look-ahead' in 1.875e and later]
|
||||
explicitly associate look-ahead tokens to items
|
||||
- solved
|
||||
describe shift/reduce conflicts solving.
|
||||
Bison used to systematically output this information on top of
|
||||
the report. Solved conflicts are now attached to their states.
|
||||
|
||||
* Type clashes
|
||||
Previous versions don't complain when there is a type clash on
|
||||
the default action if the rule has a mid-rule action, such as in:
|
||||
|
||||
%type <foo> bar
|
||||
%%
|
||||
bar: '0' {} '0';
|
||||
|
||||
This is fixed.
|
||||
|
||||
* GNU M4 is now required when using Bison.
|
||||
|
||||
Changes in version 1.35, 2002-03-25:
|
||||
|
||||
@@ -70,7 +344,6 @@ Changes in version 1.35, 2002-03-25:
|
||||
|
||||
This kludge also addresses some C++ problems when the stack was
|
||||
extended.
|
||||
|
||||
|
||||
Changes in version 1.34, 2002-03-12:
|
||||
|
||||
@@ -196,8 +469,8 @@ Changes in version 1.31, 2002-01-14:
|
||||
|
||||
Changes in version 1.30, 2001-10-26:
|
||||
|
||||
* `--defines' and `--graph' have now an optionnal argument which is the
|
||||
output file name. `-d' and `-g' do not change, they do not take any
|
||||
* `--defines' and `--graph' have now an optional argument which is the
|
||||
output file name. `-d' and `-g' do not change; they do not take any
|
||||
argument.
|
||||
|
||||
* `%source_extension' and `%header_extension' are removed, failed
|
||||
@@ -320,16 +593,17 @@ End:
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Autoconf.
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
GNU Autoconf is free software; you can redistribute it and/or modify
|
||||
Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Autoconf is distributed in the hope that it will be useful,
|
||||
Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
@@ -1,24 +1,50 @@
|
||||
This directory contains the Bison parser generator.
|
||||
|
||||
See the file INSTALL for compilation and installation instructions.
|
||||
See the file INSTALL for generic compilation and installation instructions.
|
||||
See the file doc/FAQ for frequently asked questions.
|
||||
|
||||
It was once true that, when installing Bison on Sequent (or Pyramid?)
|
||||
systems, you had to be in the Berkeley universe. This may no longer
|
||||
be true; we have no way to tell.
|
||||
Bison requires GNU m4 1.4 or later. Vanilla GNU m4 1.4 has some
|
||||
serious bugs, so we recommend using m4 1.4 as patched by the standard
|
||||
GNU/Linux distributions. If you're building GNU m4 1.4 from scratch
|
||||
we suggest using this version:
|
||||
|
||||
On VMS, you will probably have to create Makefile from Makefile.in by
|
||||
hand. Remember to do `SET COMMAND BISON' to install the data in
|
||||
`BISON.CLD'.
|
||||
ftp://ftp.gnu.org/gnu/m4/m4-1.4.2.tar.gz
|
||||
|
||||
Older versions of Sun Forte Developer 6 update 2 have a compiler bug
|
||||
that cause "make check" to fail with a "Encounter BINCL entry"
|
||||
diagnostic. To fix the bug, update to the latest set of Solaris and
|
||||
Forte patches recommended by Sun.
|
||||
|
||||
VMS and MS-DOS builds are probably broken right now. If you are able
|
||||
to build Bison on either platform and you need to make changes to do
|
||||
so, please submit those changes as a bug report.
|
||||
so, please submit those changes as a bug report. On VMS, you will
|
||||
probably have to create Makefile from Makefile.in by hand. Remember
|
||||
to do `SET COMMAND BISON' to install the data in `BISON.CLD'.
|
||||
|
||||
Send bug reports to [email protected]. Please include the version
|
||||
Send bug reports to <[email protected]>. Please include the version
|
||||
number from `bison --version', and a complete, self-contained test
|
||||
case in each bug report.
|
||||
|
||||
If you have questions about using Bison which the documentation does
|
||||
not answer, send mail to [email protected].
|
||||
not answer, send mail to <[email protected]>.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1992, 1998, 1999, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with autoconf; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
+21
-6
@@ -7,11 +7,26 @@ The documentation still needs more work. Suggestions welcome.
|
||||
Patches even more welcome.
|
||||
|
||||
Please send comments and problem reports about this test release to
|
||||
[email protected]. This program will get better only if you report
|
||||
<[email protected]>. This program will get better only if you report
|
||||
the problems you encounter.
|
||||
|
||||
Please, *do not package this*, *do not distribute it* widely, it is
|
||||
not ready for full scale use. Because it is not fully functional, if
|
||||
you distribute this package, we will be buried under bug reports from
|
||||
panicked users. We don't have time to spend on this, and nor do the
|
||||
users.
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
+39
-14
@@ -1,13 +1,19 @@
|
||||
These notes intend to help people working on the CVS versions of
|
||||
Bison. Only the sources are installed in the CVS repository (to ease
|
||||
the maintenance, merges etc.), therefore you will have to the
|
||||
maintainer tools we depend upon:
|
||||
-*- outline -*-
|
||||
|
||||
- Automake 1.6 or 1.6.1
|
||||
- Autoconf 2.53a or better
|
||||
ftp://alpha.gnu.org/gnu/autoconf/autoconf-2.53a.tar.gz (992 kB)
|
||||
ftp://alpha.gnu.org/gnu/autoconf/autoconf-2.53a.tar.bz2 (756 kB)
|
||||
- Gettext 0.10.1
|
||||
These notes intend to help people working on the CVS versions of
|
||||
Bison.
|
||||
|
||||
* Requirements
|
||||
|
||||
Only the sources are installed in the CVS repository (to ease the
|
||||
maintenance, merges etc.), therefore you will have to get the latest
|
||||
stable versions of the maintainer tools we depend upon, including:
|
||||
|
||||
- Automake
|
||||
- Autoconf
|
||||
- Flex
|
||||
- Gettext
|
||||
- CVS Bison itself
|
||||
|
||||
Only building the initial full source tree will be a bit painful,
|
||||
later, a plain `cvs update -P & make' should be sufficient.
|
||||
@@ -37,24 +43,43 @@ should output no difference, except maybe the date in po/*.po files.
|
||||
|
||||
Enjoy!
|
||||
|
||||
* Troubleshooting
|
||||
|
||||
Unfortunately the current Gettext still does not include all the
|
||||
needed tools so that the bootstrapping always perform successfully.
|
||||
|
||||
If you experience problems, I suggest the following:
|
||||
|
||||
1. Do a regular CVS checkout
|
||||
|
||||
2. Fetch a recent tarball in:
|
||||
ftp://alpha.gnu.org/gnu/bison/
|
||||
|
||||
3. Extract it
|
||||
|
||||
4. Override the content of your checkout with the content of this
|
||||
tarball, i.e.:
|
||||
cp -r bison-1.875c/* bison-cvs
|
||||
|
||||
5. Proceed on ./configure && make etc.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Autoconf.
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Autoconf is free software; you can redistribute it and/or modify
|
||||
GNU Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Autoconf is distributed in the hope that it will be useful,
|
||||
GNU Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with autoconf; see the file COPYING. If not, write to
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
+6
-3
@@ -19,12 +19,15 @@ kludges that Johnson had to perpetrate to make Yacc fit in a PDP-11.
|
||||
Also, Bison uses a faster but less space-efficient encoding for the
|
||||
parse tables (see Corbett's PhD thesis from Berkeley, "Static
|
||||
Semantics in Compiler Error Recovery", June 1985, Report No. UCB/CSD
|
||||
85/251), and more modern technique for generating the lookahead sets.
|
||||
(See "Efficient Construction of LALR(1) Lookahead Sets" by F. DeRemer
|
||||
and A. Pennello, in ACM TOPLS Vol 4 No 4, October 1982. Their
|
||||
85/251), and more modern technique for generating the look-ahead sets.
|
||||
(See Frank DeRemer and Thomas Pennello, "Efficient Computation of
|
||||
LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
||||
technique is the standard one now.)
|
||||
|
||||
paul rubin
|
||||
free software foundation
|
||||
|
||||
|
||||
[DeRemer-Pennello reference corrected by Paul Eggert <[email protected]>,
|
||||
2004-06-21.]
|
||||
|
||||
@@ -1,53 +1,77 @@
|
||||
Bison was originally written by Robert Corbett. It would not be what
|
||||
it is today without the invaluable help of these people:
|
||||
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Benoit Perrot [email protected]
|
||||
Bruce Lilly blilly@erols.com
|
||||
Cris van Pelt [email protected]
|
||||
Daniel Hagerty hag@gnu.org
|
||||
David J. MacKenzie [email protected]
|
||||
Dick Streefland [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Florian Krohm [email protected].com
|
||||
H. Merijn Brand h.m.brand@hccnet.nl
|
||||
Hans Aberg ha[email protected]
|
||||
Jesse Thilo jthilo@gnu.org
|
||||
Jim Meyering [email protected]
|
||||
Juan Manuel Guerrero [email protected]e
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne kbrowne@legato.com
|
||||
Laurent Mascherpa [email protected]
|
||||
Magnus Fromreide [email protected]u.se
|
||||
Marc Autret [email protected]
|
||||
Michael Hayes [email protected].nz
|
||||
Mike Castle [email protected]
|
||||
Neil Booth [email protected]
|
||||
Nelson H. F. Beebe [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand [email protected]
|
||||
Noah Friedman [email protected]
|
||||
Pascal Bart [email protected]
|
||||
Paul Eggert eggert@twinsun.com
|
||||
Per Allansson [email protected]
|
||||
Peter Hámorský hamo@upjs.sk
|
||||
Piotr Gackiewicz [email protected]
|
||||
Richard Stallman [email protected]
|
||||
Robert Anisko [email protected]
|
||||
Shura [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tom Lane [email protected]
|
||||
Tom Tromey [email protected]
|
||||
Wayne Green [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp subscript@free.fr
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Andrew Suffield [email protected]
|
||||
Arnold Robbins arnold@skeeve.com
|
||||
Art Haas [email protected]
|
||||
Baron Schwartz baron@sequent.org
|
||||
Benoit Perrot [email protected]
|
||||
Bert Deknuydt [email protected]
|
||||
Bruce Lilly [email protected]
|
||||
Bruno Haible [email protected]
|
||||
Charles-Henri de Boysson [email protected]
|
||||
Cris Bailiff c.bailiff+bison@awayweb.com
|
||||
Cris van Pelt [email protected].nl
|
||||
Daniel Hagerty ha[email protected]
|
||||
David J. MacKenzie djm@gnu.org
|
||||
Dick Streefland [email protected]
|
||||
Enrico Scholz [email protected]e
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac noon@cote-dazur.com
|
||||
Florian Krohm [email protected]
|
||||
Frank Heckenbach frank@g-n-u.de
|
||||
Guido Trentalancia [email protected]
|
||||
H. Merijn Brand h.m.brand@hccnet.nl
|
||||
Hans Aberg [email protected]
|
||||
Jan Nieuwenhuizen [email protected]
|
||||
Jesse Thilo [email protected]
|
||||
Jim Kent [email protected]
|
||||
Jim Meyering [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne kbrowne@legato.com
|
||||
Laurent Mascherpa [email protected]
|
||||
Magnus Fromreide [email protected].se
|
||||
Marc Autret [email protected]
|
||||
Martin Mokrejs [email protected]
|
||||
Matt Kraai [email protected]
|
||||
Matt Rosing [email protected]
|
||||
Michael Hayes [email protected]
|
||||
Mike Castle [email protected]
|
||||
Neil Booth [email protected]
|
||||
Nelson H. F. Beebe [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand nicolas.tisserand@epita.fr
|
||||
Noah Friedman [email protected]
|
||||
Pascal Bart [email protected]
|
||||
Paul Eggert [email protected]
|
||||
Paul Hilfinger [email protected]
|
||||
Per Allansson [email protected]
|
||||
Peter Fales [email protected]
|
||||
Peter Hamorsky [email protected]
|
||||
Piotr Gackiewicz [email protected]
|
||||
Quoc Peyrot [email protected]
|
||||
R Blake [email protected]
|
||||
Raja R Harinath [email protected]
|
||||
Richard Stallman [email protected]
|
||||
Robert Anisko [email protected]
|
||||
Shura [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tim Van Holder [email protected]
|
||||
Tom Lane [email protected]
|
||||
Tom Tromey [email protected]
|
||||
Troy A. Johnson [email protected]
|
||||
Vin Shelton [email protected]
|
||||
Wayne Green [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp [email protected]
|
||||
Zack Weinberg [email protected]
|
||||
|
||||
Many people are not named here because we lost track of them. We
|
||||
thank them! Please, help us keeping this list up to date.
|
||||
|
||||
@@ -1,49 +1,96 @@
|
||||
-*- outline -*-
|
||||
|
||||
* Header guards
|
||||
|
||||
* URGENT: Prologue
|
||||
The %union is declared after the user C declarations. It can be
|
||||
a problem if YYSTYPE is declared after the user part.
|
||||
From Franc,ois: should we keep the directory part in the CPP guard?
|
||||
|
||||
Actually, the real problem seems that the %union ought to be output
|
||||
where it was defined. For instance, in gettext/intl/plural.y, we
|
||||
have:
|
||||
|
||||
%{
|
||||
...
|
||||
#include "gettextP.h"
|
||||
...
|
||||
%}
|
||||
* Yacc.c: CPP Macros
|
||||
|
||||
%union {
|
||||
unsigned long int num;
|
||||
enum operator op;
|
||||
struct expression *exp;
|
||||
}
|
||||
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
|
||||
They should not: it is not documented. But if they need to, let's
|
||||
find something clean (not like YYLSP_NEEDED...).
|
||||
|
||||
%{
|
||||
...
|
||||
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
|
||||
...
|
||||
%}
|
||||
|
||||
Where the first part defines struct expression, the second uses it to
|
||||
define YYSTYPE, and the last uses YYSTYPE. Only this order is valid.
|
||||
* URGENT: Documenting C++ output
|
||||
Write a first documentation for C++ output.
|
||||
|
||||
Note that we have the same problem with GCC.
|
||||
|
||||
I suggest splitting the prologue into pre-prologue and post-prologue.
|
||||
The reason is that:
|
||||
* Documentation
|
||||
Before releasing, make sure the documentation ("Understanding your
|
||||
parser") refers to the current `output' format.
|
||||
|
||||
1. we keep language independance as it is the skeleton that joins the
|
||||
two prologues (there is no need for the engine to encode union yystype
|
||||
and to output it inside the prologue, which breaks the language
|
||||
independance of the generator)
|
||||
|
||||
2. that makes it possible to have several %union in input. I think
|
||||
this is a pleasant (but useless currently) feature, but in the future,
|
||||
I want a means to %include other bits of grammars, and _then_ it will
|
||||
be important for the various bits to define their needs in %union.
|
||||
* GLR & C++
|
||||
Currently, the GLR parser cannot compile with a C++ compiler.
|
||||
|
||||
|
||||
* Report
|
||||
|
||||
** GLR
|
||||
How would Paul like to display the conflicted actions? In particular,
|
||||
what when two reductions are possible on a given look-ahead token, but one is
|
||||
part of $default. Should we make the two reductions explicit, or just
|
||||
keep $default? See the following point.
|
||||
|
||||
** Disabled Reductions
|
||||
See `tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
|
||||
what we want to do.
|
||||
|
||||
** Documentation
|
||||
Extend with error productions. The hard part will probably be finding
|
||||
the right rule so that a single state does not exhibit too many yet
|
||||
undocumented ``features''. Maybe an empty action ought to be
|
||||
presented too. Shall we try to make a single grammar with all these
|
||||
features, or should we have several very small grammars?
|
||||
|
||||
** --report=conflict-path
|
||||
Provide better assistance for understanding the conflicts by providing
|
||||
a sample text exhibiting the (LALR) ambiguity. See the paper from
|
||||
DeRemer and Penello: they already provide the algorithm.
|
||||
|
||||
|
||||
* Extensions
|
||||
|
||||
** %destructor
|
||||
I think we should document it as experimental, and allow its use in
|
||||
the next releases. But we also need to port it to GLR. What about
|
||||
lalr1.cc? Well, read what Hans reported, maybe we don't want
|
||||
%detructor. On the other hand, there is no reason not to provide it:
|
||||
users can avoid its use.
|
||||
|
||||
** $foo
|
||||
Have a look at the Lemon parser generator: instead of $1, $2 etc. they
|
||||
can name the values. This is much more pleasant. For instance:
|
||||
|
||||
exp (res): exp (a) '+' exp (b) { $res = $a + $b; };
|
||||
|
||||
I love this. I have been bitten too often by the removal of the
|
||||
symbol, and forgetting to shift all the $n to $n-1. If you are
|
||||
unlucky, it compiles...
|
||||
|
||||
** $-1
|
||||
We should find a means to provide an access to values deep in the
|
||||
stack. For instance, instead of
|
||||
|
||||
baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
|
||||
|
||||
we should be able to have:
|
||||
|
||||
foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
|
||||
|
||||
Or something like this.
|
||||
|
||||
** yysymprint interface
|
||||
It should be improved, in particular when using Bison features such as
|
||||
locations, and YYPARSE_PARAMS. For the time being, it is almost
|
||||
recommended to yyprint to steal internal variables...
|
||||
|
||||
** Several %unions
|
||||
I think this is a pleasant (but useless currently) feature, but in the
|
||||
future, I want a means to %include other bits of grammars, and _then_
|
||||
it will be important for the various bits to define their needs in
|
||||
%union.
|
||||
|
||||
When implementing multiple-%union support, bare the following in mind:
|
||||
|
||||
@@ -60,30 +107,77 @@ When implementing multiple-%union support, bare the following in mind:
|
||||
char *sval;
|
||||
}
|
||||
|
||||
* Language independent actions
|
||||
** %if and the like
|
||||
It should be possible to have %if/%else/%endif. The implementation is
|
||||
not clear: should it be lexical or syntactic. Vadim Maslow thinks it
|
||||
must be in the scanner: we must not parse what is in a switched off
|
||||
part of %if. Akim Demaille thinks it should be in the parser, so as
|
||||
to avoid falling into another CPP mistake.
|
||||
|
||||
Currently bison, the generator, transforms $1, $$ and so forth into
|
||||
direct C code, manipulating the stacks. This is problematic, because
|
||||
(i) it means that if we want more languages, we need to update the
|
||||
generator, and (ii), it forces names everywhere (e.g., the C++
|
||||
skeleton would be happy to use other naming schemes, and actually,
|
||||
even other accessing schemes).
|
||||
** -D, --define-muscle NAME=VALUE
|
||||
To define muscles via cli. Or maybe support directly NAME=VALUE?
|
||||
|
||||
Therefore we want
|
||||
** XML Output
|
||||
There are couple of available extensions of Bison targeting some XML
|
||||
output. Some day we should consider including them. One issue is
|
||||
that they seem to be quite orthogonal to the parsing technique, and
|
||||
seem to depend mostly on the possibility to have some code triggered
|
||||
for each reduction. As a matter of fact, such hooks could also be
|
||||
used to generate the yydebug traces. Some generic scheme probably
|
||||
exists in there.
|
||||
|
||||
1. the generator to replace $1, etc. by M4 macro invocations
|
||||
(b4_dollar(1), b4_at(3), b4_dollar_dollar) etc.
|
||||
XML output for GNU Bison and gcc
|
||||
http://www.cs.may.ie/~jpower/Research/bisonXML/
|
||||
|
||||
2. the skeletons to define these macros.
|
||||
XML output for GNU Bison
|
||||
http://yaxx.sourceforge.net/
|
||||
|
||||
But currently the actions are double-quoted, to protect them from M4
|
||||
evaluation. So we need to:
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
|
||||
3. stop quoting them
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
4. change the [ and ] in the actions into @<:@ and @:>@
|
||||
into
|
||||
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
when there are no actions. This can significantly speed up some
|
||||
grammars. I can't find the papers. In particular the book `LR
|
||||
parsing: Theory and Practice' is impossible to find, but according to
|
||||
`Parsing Techniques: a Practical Guide', it includes information about
|
||||
this issue. Does anybody have it?
|
||||
|
||||
|
||||
|
||||
* Documentation
|
||||
|
||||
** History/Bibliography
|
||||
Some history of Bison and some bibliography would be most welcome.
|
||||
Are there any Texinfo standards for bibliography?
|
||||
|
||||
|
||||
|
||||
* Java, Fortran, etc.
|
||||
|
||||
|
||||
** Java
|
||||
|
||||
There are a couple of proposed outputs:
|
||||
|
||||
- BYACC/J
|
||||
which is based on Byacc.
|
||||
<http://troi.lincom-asg.com/~rjamison/byacc/>
|
||||
|
||||
- Bison Java
|
||||
which is based on Bison.
|
||||
<http://www.goice.co.jp/member/mo/hack-progs/bison-java.html>
|
||||
|
||||
Sebastien Serrurier ([email protected]) is working on this: he is
|
||||
expected to contact the authors, design the output, and implement it
|
||||
into Bison.
|
||||
|
||||
5. extend the postprocessor to maps these back onto [ and ].
|
||||
|
||||
* Coding system independence
|
||||
Paul notes:
|
||||
@@ -98,174 +192,17 @@ Paul notes:
|
||||
PDP-10 ports :-) but they should probably be documented
|
||||
somewhere.
|
||||
|
||||
* Using enums instead of int for tokens.
|
||||
Paul suggests:
|
||||
|
||||
#ifndef YYTOKENTYPE
|
||||
# if defined (__STDC__) || defined (__cplusplus)
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
FOO = 256,
|
||||
BAR,
|
||||
...
|
||||
};
|
||||
/* POSIX requires `int' for tokens in interfaces. */
|
||||
# define YYTOKENTYPE int
|
||||
# endif
|
||||
#endif
|
||||
#define FOO 256
|
||||
#define BAR 257
|
||||
...
|
||||
|
||||
* Output directory
|
||||
Akim:
|
||||
|
||||
| I consider this to be a bug in bison:
|
||||
|
|
||||
| /tmp % mkdir src
|
||||
| /tmp % cp ~/src/bison/tests/calc.y src
|
||||
| /tmp % mkdir build && cd build
|
||||
| /tmp/build % bison ../src/calc.y
|
||||
| /tmp/build % cd ..
|
||||
| /tmp % ls -l build src
|
||||
| build:
|
||||
| total 0
|
||||
|
|
||||
| src:
|
||||
| total 32
|
||||
| -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
|
||||
| -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
|
||||
|
|
||||
|
|
||||
| Would it be safe to change this behavior to something more reasonable?
|
||||
| Do you think some people depend upon this?
|
||||
|
||||
Jim:
|
||||
|
||||
Is it that behavior documented?
|
||||
If so, then it's probably not reasonable to change it.
|
||||
I've Cc'd the automake list, because some of automake's
|
||||
rules use bison through $(YACC) -- though I'll bet they
|
||||
all use it in yacc-compatible mode.
|
||||
|
||||
Pavel:
|
||||
|
||||
Hello, Jim and others!
|
||||
|
||||
> Is it that behavior documented?
|
||||
> If so, then it's probably not reasonable to change it.
|
||||
> I've Cc'd the automake list, because some of automake's
|
||||
> rules use bison through $(YACC) -- though I'll bet they
|
||||
> all use it in yacc-compatible mode.
|
||||
|
||||
Yes, Automake currently used bison in Automake-compatible mode, but it
|
||||
would be fair for Automake to switch to the native mode as long as the
|
||||
processed files are distributed and "missing" emulates bison.
|
||||
|
||||
In any case, the makefiles should specify the output file explicitly
|
||||
instead of relying on weird defaults.
|
||||
|
||||
> | src:
|
||||
> | total 32
|
||||
> | -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
|
||||
> | -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
|
||||
|
||||
This is not _that_ ugly as it seems - with Automake you want to put
|
||||
sources where they belong - to the source directory.
|
||||
|
||||
> | This is not _that_ ugly as it seems - with Automake you want to put
|
||||
> | sources where they belong - to the source directory.
|
||||
>
|
||||
> The difference source/build you are referring to is based on Automake
|
||||
> concepts. They have no sense at all for tools such as bison or gcc
|
||||
> etc. They have input and output. I do not want them to try to grasp
|
||||
> source/build. I want them to behave uniformly: output *here*.
|
||||
|
||||
I realize that.
|
||||
|
||||
It's unfortunate that the native mode of Bison behaves in a less uniform
|
||||
way than the yacc mode. I agree with your point. Bison maintainters may
|
||||
want to fix it along with the documentation.
|
||||
|
||||
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
into
|
||||
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
when there are no actions. This can significantly speed up some
|
||||
grammars.
|
||||
|
||||
* Stupid error messages
|
||||
An example shows it easily:
|
||||
|
||||
src/bison/tests % ./testsuite -k calc,location,error-verbose -l
|
||||
GNU Bison 1.49a test suite test groups:
|
||||
|
||||
NUM: FILENAME:LINE TEST-GROUP-NAME
|
||||
KEYWORDS
|
||||
|
||||
51: calc.at:440 Calculator --locations --yyerror-verbose
|
||||
52: calc.at:442 Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
|
||||
54: calc.at:445 Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
|
||||
src/bison/tests % ./testsuite 51 -d
|
||||
## --------------------------- ##
|
||||
## GNU Bison 1.49a test suite. ##
|
||||
## --------------------------- ##
|
||||
51: calc.at:440 ok
|
||||
## ---------------------------- ##
|
||||
## All 1 tests were successful. ##
|
||||
## ---------------------------- ##
|
||||
src/bison/tests % cd ./testsuite.dir/51
|
||||
tests/testsuite.dir/51 % echo "()" | ./calc
|
||||
1.2-1.3: parse error, unexpected ')', expecting error or "number" or '-' or '('
|
||||
|
||||
* yyerror, yyprint interface
|
||||
It should be improved, in particular when using Bison features such as
|
||||
locations, and YYPARSE_PARAMS. For the time being, it is recommended
|
||||
to #define yyerror and yyprint to steal internal variables...
|
||||
|
||||
* read_pipe.c
|
||||
This is not portable to DOS for instance. Implement a more portable
|
||||
scheme. Sources of inspiration include GNU diff, and Free Recode.
|
||||
|
||||
* Memory leaks in the generator
|
||||
A round of memory leak clean ups would be most welcome. Dmalloc,
|
||||
Checker GCC, Electric Fence, or Valgrind: you chose your tool.
|
||||
|
||||
* Memory leaks in the parser
|
||||
The same applies to the generated parsers. In particular, this is
|
||||
critical for user data: when aborting a parsing, when handling the
|
||||
error token etc., we often throw away yylval without giving a chance
|
||||
of cleaning it up to the user.
|
||||
|
||||
* --graph
|
||||
Show reductions. []
|
||||
|
||||
* Broken options ?
|
||||
** %no-lines [ok]
|
||||
** %no-parser []
|
||||
** %pure-parser []
|
||||
** %semantic-parser []
|
||||
** %token-table []
|
||||
** Options which could use parse_dquoted_param ().
|
||||
Maybe transfered in lex.c.
|
||||
*** %skeleton [ok]
|
||||
*** %output []
|
||||
*** %file-prefix []
|
||||
*** %name-prefix []
|
||||
|
||||
** Skeleton strategy. []
|
||||
Must we keep %no-parser?
|
||||
%token-table?
|
||||
*** New skeletons. []
|
||||
|
||||
* src/print_graph.c
|
||||
Find the best graph parameters. []
|
||||
@@ -273,7 +210,7 @@ Find the best graph parameters. []
|
||||
* doc/bison.texinfo
|
||||
** Update
|
||||
informations about ERROR_VERBOSE. []
|
||||
** Add explainations about
|
||||
** Add explanations about
|
||||
skeleton muscles. []
|
||||
%skeleton. []
|
||||
|
||||
@@ -281,127 +218,52 @@ skeleton muscles. []
|
||||
** tests/pure-parser.at []
|
||||
New tests.
|
||||
|
||||
* Debugging parsers
|
||||
|
||||
From Greg McGary:
|
||||
|
||||
akim demaille <[email protected]> writes:
|
||||
|
||||
> With great pleasure! Nonetheless, things which are debatable
|
||||
> (or not, but just `big') should be discuss in `public': something
|
||||
> like help- or [email protected] is just fine. Jesse and I are there,
|
||||
> but there is also Jim and some other people.
|
||||
|
||||
I have no idea whether it qualifies as big or controversial, so I'll
|
||||
just summarize for you. I proposed this change years ago and was
|
||||
surprised that it was met with utter indifference!
|
||||
|
||||
This debug feature is for the programs/grammars one develops with
|
||||
bison, not for debugging bison itself. I find that the YYDEBUG
|
||||
output comes in a very inconvenient format for my purposes.
|
||||
When debugging gcc, for instance, what I want is to see a trace of
|
||||
the sequence of reductions and the line#s for the semantic actions
|
||||
so I can follow what's happening. Single-step in gdb doesn't cut it
|
||||
because to move from one semantic action to the next takes you through
|
||||
lots of internal machinery of the parser, which is uninteresting.
|
||||
|
||||
The change I made was to the format of the debug output, so that it
|
||||
comes out in the format of C error messages, digestible by emacs
|
||||
compile mode, like so:
|
||||
|
||||
grammar.y:1234: foo: bar(0x123456) baz(0x345678)
|
||||
|
||||
where "foo: bar baz" is the reduction rule, whose semantic action
|
||||
appears on line 1234 of the bison grammar file grammar.y. The hex
|
||||
numbers on the rhs tokens are the parse-stack values associated with
|
||||
those tokens. Of course, yytype might be something totally
|
||||
incompatible with that representation, but for the most part, yytype
|
||||
values are single words (scalars or pointers). In the case of gcc,
|
||||
they're most often pointers to tree nodes. Come to think of it, the
|
||||
right thing to do is to make the printing of stack values be
|
||||
user-definable. It would also be useful to include the filename &
|
||||
line# of the file being parsed, but the main filename & line# should
|
||||
continue to be that of grammar.y
|
||||
|
||||
Anyway, this feature has saved my life on numerous occasions. The way
|
||||
I customarily use it is to first run bison with the traces on, isolate
|
||||
the sequence of reductions that interests me, put those traces in a
|
||||
buffer and force it into compile-mode, then visit each of those lines
|
||||
in the grammar and set breakpoints with C-x SPACE. Then, I can run
|
||||
again under the control of gdb and stop at each semantic action.
|
||||
With the hex addresses of tree nodes, I can inspect the values
|
||||
associated with any rhs token.
|
||||
|
||||
You like?
|
||||
|
||||
* input synclines
|
||||
Some users create their foo.y files, and equip them with #line. Bison
|
||||
should recognize these, and preserve them.
|
||||
|
||||
* BTYacc
|
||||
See if we can integrate backtracking in Bison. Contact the BTYacc
|
||||
maintainers.
|
||||
See if we can integrate backtracking in Bison. Charles-Henri de
|
||||
Boysson <[email protected]> is working on this, and already has some
|
||||
results. Vadim Maslow, the maintainer of BTYacc was contacted, and we
|
||||
stay in touch with him. Adjusting the Bison grammar parser will be
|
||||
needed to support some extra BTYacc features. This is less urgent.
|
||||
|
||||
* Automaton report
|
||||
Display more clearly the lookaheads for each item.
|
||||
** Keeping the conflicted actions
|
||||
First, analyze the differences between byacc and btyacc (I'm referring
|
||||
to the executables). Find where the conflicts are preserved.
|
||||
|
||||
** Compare with the GLR tables
|
||||
See how isomorphic the way BTYacc and the way the GLR adjustments in
|
||||
Bison are compatible. *As much as possible* one should try to use the
|
||||
same implementation in the Bison executables. I insist: it should be
|
||||
very feasible to use the very same conflict tables.
|
||||
|
||||
** Adjust the skeletons
|
||||
Import the skeletons for C and C++.
|
||||
|
||||
** Improve the skeletons
|
||||
Have them support yysymprint, yydestruct and so forth.
|
||||
|
||||
* RR conflicts
|
||||
See if we can use precedence between rules to solve RR conflicts. See
|
||||
what POSIX says.
|
||||
|
||||
* Precedence
|
||||
|
||||
** Partial order
|
||||
It is unfortunate that there is a total order for precedence. It
|
||||
makes it impossible to have modular precedence information. We should
|
||||
move to partial orders.
|
||||
move to partial orders (sounds like series/parallel orders to me).
|
||||
|
||||
* Parsing grammars
|
||||
Rewrite the reader in Bison.
|
||||
This will be possible with a Bison parser for the grammar, as it will
|
||||
make it much easier to extend the grammar.
|
||||
|
||||
* Problems with aliases
|
||||
From: "Baum, Nathan I" <[email protected]>
|
||||
Subject: Token Alias Bug
|
||||
To: "'[email protected]'" <[email protected]>
|
||||
** Correlation b/w precedence and associativity
|
||||
Also, I fail to understand why we have to assign the same
|
||||
associativity to operators with the same precedence. For instance,
|
||||
why can't I decide that the precedence of * and / is the same, but the
|
||||
latter is nonassoc?
|
||||
|
||||
I've noticed a bug in bison. Sadly, our eternally wise sysadmins won't let
|
||||
us use CVS, so I can't find out if it's been fixed already...
|
||||
If there is really no profound motivation, we should find a new syntax
|
||||
to allow specifying this.
|
||||
|
||||
Basically, I made a program (in flex) that went through a .y file looking
|
||||
for "..."-tokens, and then outputed a %token
|
||||
line for it. For single-character ""-tokens, I reasoned, I could just use
|
||||
[%token 'A' "A"]. However, this causes Bison to output a [#define 'A' 65],
|
||||
which cppp chokes on, not unreasonably. (And even if cppp didn't choke, I
|
||||
obviously wouldn't want (char)'A' to be replaced with (int)65 throughout my
|
||||
code.
|
||||
|
||||
Bison normally forgoes outputing a #define for a character token. However,
|
||||
it always outputs an aliased token -- even if the token is an alias for a
|
||||
character token. We don't want that. The problem is in /output.c/, as I
|
||||
recall. When it outputs the token definitions, it checks for a character
|
||||
token, and then checks for an alias token. If the character token check is
|
||||
placed after the alias check, then it works correctly.
|
||||
|
||||
Alias tokens seem to be something of a kludge. What about an [%alias "..."]
|
||||
command...
|
||||
|
||||
%alias T_IF "IF"
|
||||
|
||||
Hmm. I can't help thinking... What about a --generate-lex option that
|
||||
creates an .l file for the alias tokens used... (Or an option to make a
|
||||
gperf file, etc...)
|
||||
|
||||
* Presentation of the report file
|
||||
From: "Baum, Nathan I" <[email protected]>
|
||||
Subject: Token Alias Bug
|
||||
To: "'[email protected]'" <[email protected]>
|
||||
|
||||
I've also noticed something, that whilst not *wrong*, is inconvienient: I
|
||||
use the verbose mode to help find the causes of unresolved shift/reduce
|
||||
conflicts. However, this mode insists on starting the .output file with a
|
||||
list of *resolved* conflicts, something I find quite useless. Might it be
|
||||
possible to define a -v mode, and a -vv mode -- Where the -vv mode shows
|
||||
everything, but the -v mode only tells you what you need for examining
|
||||
conflicts? (Or, perhaps, a "*** This state has N conflicts ***" marker above
|
||||
each state with conflicts.)
|
||||
** RR conflicts
|
||||
See if we can use precedence between rules to solve RR conflicts. See
|
||||
what POSIX says.
|
||||
|
||||
|
||||
* $undefined
|
||||
@@ -412,6 +274,7 @@ addition to the $undefined value.
|
||||
|
||||
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
||||
|
||||
|
||||
* Default Action
|
||||
From Hans:
|
||||
- For use with my C++ parser, I transported the "switch (yyn)" statement
|
||||
@@ -426,6 +289,20 @@ $<type_name>$ = $<type_name>1. I therefore think that one should implement
|
||||
a Bison option where every typed default rule is explicitly written out
|
||||
(same typed ruled can of course be grouped together).
|
||||
|
||||
Note: Robert Anisko handles this. He knows how to do it.
|
||||
|
||||
|
||||
* Warnings
|
||||
It would be nice to have warning support. See how Autoconf handles
|
||||
them, it is fairly well described there. It would be very nice to
|
||||
implement this in such a way that other programs could use
|
||||
lib/warnings.[ch].
|
||||
|
||||
Don't work on this without first announcing you do, as I already have
|
||||
thought about it, and know many of the components that can be used to
|
||||
implement it.
|
||||
|
||||
|
||||
* Pre and post actions.
|
||||
From: Florian Krohm <[email protected]>
|
||||
Subject: YYACT_EPILOGUE
|
||||
@@ -454,23 +331,27 @@ at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
|
||||
I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
|
||||
to bison. If you're interested, I'll work on a patch.
|
||||
|
||||
* Move to Graphviz
|
||||
Well, VCG seems really dead. Move to Graphviz instead. Also, equip
|
||||
the parser with a means to create the (visual) parse tree.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Autoconf.
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Autoconf is free software; you can redistribute it and/or modify
|
||||
GNU Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Autoconf is distributed in the hope that it will be useful,
|
||||
GNU Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with autoconf; see the file COPYING. If not, write to
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
@@ -1,22 +1,272 @@
|
||||
#! /bin/sh
|
||||
|
||||
echo "Bootstrapping CVS Bison..."
|
||||
# Bootstrap this package from CVS.
|
||||
|
||||
# This will run gettextize which will patch some files, and cause
|
||||
# autoconf to choke (because for instance intl/Makefile is registered
|
||||
# several times).
|
||||
autoreconf --verbose --install --force
|
||||
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
# gettextize modified these files: restore them.
|
||||
for f in m4/Makefile.am Makefile.am configure.in
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
# Written by Paul Eggert.
|
||||
|
||||
package=bison
|
||||
|
||||
# Ensure file names are sorted consistently across platforms;
|
||||
# e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Parse options.
|
||||
|
||||
for option
|
||||
do
|
||||
if test -f "$f~"; then
|
||||
mv -f "$f~" "$f"
|
||||
fi
|
||||
case $option in
|
||||
--help)
|
||||
echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]"
|
||||
exit;;
|
||||
--gnulib-srcdir=*)
|
||||
GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
--cvs-user=*)
|
||||
CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
|
||||
--skip-po)
|
||||
SKIP_PO=t;;
|
||||
*)
|
||||
echo >&2 "$0: $option: unknown option"
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
rm -f po/Makevars.template
|
||||
|
||||
# Since some files were restored, some files must probably be remade.
|
||||
# But automake could not install all of its files, so pass --install
|
||||
# for it.
|
||||
autoreconf --verbose --install
|
||||
echo "$0: Bootstrapping CVS $package..."
|
||||
|
||||
build_cvs_prefix() {
|
||||
CVS_PREFIX=:${1}:
|
||||
if [ "${2}" != - ]; then
|
||||
CVS_PREFIX=${CVS_PREFIX}${2}@
|
||||
fi
|
||||
}
|
||||
|
||||
# Get gnulib files.
|
||||
|
||||
case ${GNULIB_SRCDIR--} in
|
||||
-)
|
||||
if [ ! -d gnulib ]; then
|
||||
echo "$0: getting gnulib files..."
|
||||
|
||||
trap exit 1 2 13 15
|
||||
trap 'rm -fr gnulib; exit 1' 0
|
||||
|
||||
case ${CVS_AUTH-anoncvs} in
|
||||
anoncvs)
|
||||
CVS_PREFIX='anoncvs@';;
|
||||
ssh)
|
||||
CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
|
||||
*)
|
||||
echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
case $CVS_RSH in
|
||||
'') export CVS_RSH=ssh;;
|
||||
esac
|
||||
|
||||
cvs -z3 -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib || exit
|
||||
|
||||
trap 0
|
||||
fi
|
||||
GNULIB_SRCDIR=gnulib
|
||||
esac
|
||||
|
||||
<$GNULIB_SRCDIR/gnulib-tool || exit
|
||||
|
||||
gnulib_modules='
|
||||
alloca
|
||||
argmatch
|
||||
dirname
|
||||
error
|
||||
extensions
|
||||
getopt
|
||||
hard-locale
|
||||
hash
|
||||
malloc
|
||||
mbswidth
|
||||
obstack
|
||||
quote
|
||||
quotearg
|
||||
stdbool
|
||||
stpcpy
|
||||
xalloc
|
||||
xalloc-die
|
||||
xstrndup
|
||||
'
|
||||
|
||||
previous_gnulib_modules=
|
||||
while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
|
||||
previous_gnulib_modules=$gnulib_modules
|
||||
gnulib_modules=`
|
||||
(echo "$gnulib_modules"
|
||||
for gnulib_module in $gnulib_modules; do
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
|
||||
done) | sort -u
|
||||
`
|
||||
done
|
||||
|
||||
gnulib_files=`
|
||||
(for gnulib_module in $gnulib_modules; do
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
|
||||
done) | sort -u
|
||||
`
|
||||
|
||||
gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
|
||||
mkdir -p $gnulib_dirs || exit
|
||||
|
||||
for gnulib_file in $gnulib_files; do
|
||||
dest=$gnulib_file
|
||||
|
||||
case $gnulib_file in
|
||||
m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
|
||||
# These will be overwritten by autopoint, which still uses
|
||||
# old jm_.* macro names, so we have to keep both copies.
|
||||
# m4/gettext.m4 isn't mentioned here, since it's patched below.
|
||||
m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
|
||||
m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
|
||||
m4/ulonglong.m4)
|
||||
dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
|
||||
esac
|
||||
|
||||
rm -f $dest &&
|
||||
echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
|
||||
cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
|
||||
done
|
||||
|
||||
echo "$0: patching m4/gettext.m4 so that AM_INTL_SUBDIR is empty ..."
|
||||
sed '
|
||||
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
|
||||
AC_DEFUN([AM_INTL_SUBDIR], [])
|
||||
' m4/gettext.m4 >m4/gettext_gl.m4 || exit
|
||||
|
||||
|
||||
# Get translations.
|
||||
|
||||
case $SKIP_PO in
|
||||
'')
|
||||
echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
|
||||
(cd po &&
|
||||
rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
|
||||
wget -nv -nd -r -l 1 -A .po -C off \
|
||||
http://www2.iro.umontreal.ca/~gnutra/po/maint/$package/ &&
|
||||
ls *.po | sed 's/\.po$//' >LINGUAS
|
||||
) || exit;;
|
||||
esac
|
||||
|
||||
|
||||
# Generate autoconf and automake snippets.
|
||||
|
||||
(echo '# This file is generated automatically by "bootstrap".' &&
|
||||
echo 'AC_DEFUN([GNULIB_AUTOCONF_SNIPPET],[' &&
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_modules &&
|
||||
echo '])'
|
||||
) >m4/gnulib.m4 || exit
|
||||
|
||||
(echo '# This file is generated automatically by "bootstrap".' &&
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_modules
|
||||
) >lib/gnulib.mk || exit
|
||||
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
echo "$0: autoreconf --verbose --install --force ..."
|
||||
autoreconf --verbose --install --force || exit
|
||||
|
||||
|
||||
# We don't need intl, so remove it.
|
||||
# Remove aclocal.m4 too, so that it gets rebuilt.
|
||||
intl_files_to_remove='
|
||||
aclocal.m4
|
||||
intl
|
||||
m4/codeset.m4
|
||||
m4/gettext.m4
|
||||
m4/glibc21.m4
|
||||
m4/intdiv0.m4
|
||||
m4/intmax.m4
|
||||
m4/inttypes_h.m4
|
||||
m4/inttypes.m4
|
||||
m4/inttypes-pri.m4
|
||||
m4/isc-posix.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lib-ld.m4
|
||||
m4/lib-prefix.m4
|
||||
m4/longdouble.m4
|
||||
m4/longlong.m4
|
||||
m4/po.m4
|
||||
m4/printf-posix.m4
|
||||
m4/signed.m4
|
||||
m4/size_max.m4
|
||||
m4/stdint_h.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/wchar_t.m4
|
||||
m4/wint_t.m4
|
||||
m4/xsize.m4
|
||||
'
|
||||
echo $0: rm -fr $intl_files_to_remove ...
|
||||
rm -fr $intl_files_to_remove || exit
|
||||
|
||||
# Patch what appears to be a bug in gettext 0.14.1;
|
||||
# remove this once the bug is fixed.
|
||||
grep @top_builddir@ po/Makefile.in.in >/dev/null || {
|
||||
echo "$0: prepending 'top_builddir=@top_builddir@' to po/Makefile.in.in ... "
|
||||
old_contents=`cat po/Makefile.in.in` || exit
|
||||
cat >po/Makefile.in.in <<EOF
|
||||
top_builddir=@top_builddir@
|
||||
$old_contents
|
||||
EOF
|
||||
}
|
||||
|
||||
# Put bug-reporting address into po/Makevars.
|
||||
echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= [email protected]/' po/Makevars.template >po/Makevars ..."
|
||||
sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= [email protected]/' po/Makevars.template >po/Makevars
|
||||
|
||||
|
||||
# if src/parse-gram.[ch] are out of date, rebuild them.
|
||||
parse_gram_y=`find src/parse-gram.y \
|
||||
'(' -newer src/parse-gram.c -o -newer src/parse-gram.h ')' \
|
||||
-print` || exit
|
||||
case $parse_gram_y in
|
||||
?*)
|
||||
echo "$0: warning: bootstrapping with old src/parse-gram.[ch] files."
|
||||
|
||||
echo "$0: touch -c src/parse-gram.[ch] ... "
|
||||
touch -c src/parse-gram.[ch] || exit
|
||||
|
||||
echo "$0: ./configure --disable-nls ..."
|
||||
./configure --disable-nls || exit
|
||||
|
||||
echo "$0: (cd lib && make) ..."
|
||||
(cd lib && make) || exit
|
||||
|
||||
echo "$0: (cd src && make) ..."
|
||||
(cd src && make) || exit
|
||||
|
||||
echo "$0: rm -f src/parse-gram.c src/parse-gram.h ..."
|
||||
rm -f src/parse-gram.c src/parse-gram.h || exit
|
||||
|
||||
echo "$0: (cd src && make parse-gram.c parse-gram.h) ..."
|
||||
(cd src && make parse-gram.c parse-gram.h) || exit
|
||||
|
||||
echo "$0: make distclean ..."
|
||||
make distclean || exit;;
|
||||
esac
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
+8
-4
@@ -1,9 +1,13 @@
|
||||
Makefile
|
||||
*.t
|
||||
Makefile
|
||||
Makefile.in
|
||||
mkinstalldirs
|
||||
missing
|
||||
config.sub
|
||||
config.guess
|
||||
config.rpath
|
||||
config.sub
|
||||
depcomp
|
||||
install-sh
|
||||
mdate-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
texinfo.tex
|
||||
ylwrap
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
EXTRA_DIST = move-if-change prev-version.txt
|
||||
EXTRA_DIST = move-if-change prev-version.txt config.rpath
|
||||
|
||||
Executable
+338
@@ -0,0 +1,338 @@
|
||||
#!/usr/bin/perl -w
|
||||
# Generate an announcement message.
|
||||
use strict;
|
||||
|
||||
use Getopt::Long;
|
||||
use Digest::MD5;
|
||||
use Digest::SHA1;
|
||||
|
||||
(my $VERSION = '$Revision$ ') =~ tr/[0-9].//cd;
|
||||
(my $ME = $0) =~ s|.*/||;
|
||||
|
||||
my %valid_release_types = map {$_ => 1} qw (alpha beta major);
|
||||
|
||||
END
|
||||
{
|
||||
# Nobody ever checks the status of print()s. That's okay, because
|
||||
# if any do fail, we're guaranteed to get an indicator when we close()
|
||||
# the filehandle.
|
||||
#
|
||||
# Close stdout now, and if there were no errors, return happy status.
|
||||
# If stdout has already been closed by the script, though, do nothing.
|
||||
defined fileno STDOUT
|
||||
or return;
|
||||
close STDOUT
|
||||
and return;
|
||||
|
||||
# Errors closing stdout. Indicate that, and hope stderr is OK.
|
||||
warn "$ME: closing standard output: $!\n";
|
||||
|
||||
# Don't be so arrogant as to assume that we're the first END handler
|
||||
# defined, and thus the last one invoked. There may be others yet
|
||||
# to come. $? will be passed on to them, and to the final _exit().
|
||||
#
|
||||
# If it isn't already an error, make it one (and if it _is_ an error,
|
||||
# preserve the value: it might be important).
|
||||
$? ||= 1;
|
||||
}
|
||||
|
||||
sub usage ($)
|
||||
{
|
||||
my ($exit_code) = @_;
|
||||
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
|
||||
if ($exit_code != 0)
|
||||
{
|
||||
print $STREAM "Try `$ME --help' for more information.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my @types = sort keys %valid_release_types;
|
||||
print $STREAM <<EOF;
|
||||
Usage: $ME [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
Generate an announcement message.
|
||||
|
||||
FIXME: describe the following
|
||||
|
||||
--release-type=TYPE TYPE must be one of @types
|
||||
--package-name=PACKAGE_NAME
|
||||
--previous-version=VER
|
||||
--current-version=VER
|
||||
--release-archive-directory=DIR
|
||||
--url-directory=URL_DIR
|
||||
--news=NEWS_FILE optional
|
||||
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
EOF
|
||||
}
|
||||
exit $exit_code;
|
||||
}
|
||||
|
||||
sub print_changelog_deltas ($$)
|
||||
{
|
||||
my ($package_name, $prev_version) = @_;
|
||||
|
||||
# Print new ChangeLog entries.
|
||||
|
||||
# First find all CVS-controlled ChangeLog files.
|
||||
use File::Find;
|
||||
my @changelog;
|
||||
find ({wanted => sub {$_ eq 'ChangeLog' && -d 'CVS'
|
||||
and push @changelog, $File::Find::name}},
|
||||
'.');
|
||||
|
||||
# If there are no ChangeLog files, we're done.
|
||||
@changelog
|
||||
or return;
|
||||
my %changelog = map {$_ => 1} @changelog;
|
||||
|
||||
# Reorder the list of files so that if there are ChangeLog
|
||||
# files in the specified directories, they're listed first,
|
||||
# in this order:
|
||||
my @dir = qw ( . src lib m4 config doc );
|
||||
|
||||
# A typical @changelog array might look like this:
|
||||
# ./ChangeLog
|
||||
# ./po/ChangeLog
|
||||
# ./m4/ChangeLog
|
||||
# ./lib/ChangeLog
|
||||
# ./doc/ChangeLog
|
||||
# ./config/ChangeLog
|
||||
my @reordered;
|
||||
foreach my $d (@dir)
|
||||
{
|
||||
my $dot_slash = $d eq '.' ? $d : "./$d";
|
||||
my $target = "$dot_slash/ChangeLog";
|
||||
delete $changelog{$target}
|
||||
and push @reordered, $target;
|
||||
}
|
||||
|
||||
# Append any remaining ChangeLog files.
|
||||
push @reordered, sort keys %changelog;
|
||||
|
||||
# Remove leading `./'.
|
||||
@reordered = map { s!^\./!!; $_ } @reordered;
|
||||
|
||||
print "\nChangeLog entries:\n\n";
|
||||
# print join ("\n", @reordered), "\n";
|
||||
|
||||
$prev_version =~ s/\./_/g;
|
||||
my $prev_cvs_tag = "\U$package_name\E-$prev_version";
|
||||
|
||||
my $cmd = "cvs -n diff -u -r$prev_cvs_tag -rHEAD @reordered";
|
||||
open DIFF, '-|', $cmd
|
||||
or die "$ME: cannot run `$cmd': $!\n";
|
||||
# Print two types of lines, making minor changes:
|
||||
# Lines starting with `+++ ', e.g.,
|
||||
# +++ ChangeLog 22 Feb 2003 16:52:51 -0000 1.247
|
||||
# and those starting with `+'.
|
||||
# Don't print the others.
|
||||
my $prev_printed_line_empty = 1;
|
||||
while (defined (my $line = <DIFF>))
|
||||
{
|
||||
if ($line =~ /^\+\+\+ /)
|
||||
{
|
||||
my $separator = "*"x70 ."\n";
|
||||
$line =~ s///;
|
||||
$line =~ s/\s.*//;
|
||||
$prev_printed_line_empty
|
||||
or print "\n";
|
||||
print $separator, $line, $separator;
|
||||
}
|
||||
elsif ($line =~ /^\+/)
|
||||
{
|
||||
$line =~ s///;
|
||||
print $line;
|
||||
$prev_printed_line_empty = ($line =~ /^$/);
|
||||
}
|
||||
}
|
||||
close DIFF;
|
||||
|
||||
# The exit code should be 1.
|
||||
# Allow in case there are no modified ChangeLog entries.
|
||||
$? == 256 || $? == 128
|
||||
or warn "$ME: warning: `cmd' had unexpected exit code or signal ($?)\n";
|
||||
}
|
||||
|
||||
{
|
||||
my $release_type;
|
||||
my $package_name;
|
||||
my $prev_version;
|
||||
my $curr_version;
|
||||
my $release_archive_dir;
|
||||
my @url_dir_list;
|
||||
my $news_file;
|
||||
|
||||
GetOptions
|
||||
(
|
||||
'release-type=s' => \$release_type,
|
||||
'package-name=s' => \$package_name,
|
||||
'previous-version=s' => \$prev_version,
|
||||
'current-version=s' => \$curr_version,
|
||||
'release-archive-directory=s' => \$release_archive_dir,
|
||||
'url-directory=s@' => \@url_dir_list,
|
||||
'news=s@' => \$news_file,
|
||||
|
||||
help => sub { usage 0 },
|
||||
version => sub { print "$ME version $VERSION\n"; exit },
|
||||
) or usage 1;
|
||||
|
||||
my $fail = 0;
|
||||
# Ensure that sure each required option is specified.
|
||||
$release_type
|
||||
or (warn "$ME: release type not specified\n"), $fail = 1;
|
||||
$package_name
|
||||
or (warn "$ME: package name not specified\n"), $fail = 1;
|
||||
$prev_version
|
||||
or (warn "$ME: previous version string not specified\n"), $fail = 1;
|
||||
$curr_version
|
||||
or (warn "$ME: current version string not specified\n"), $fail = 1;
|
||||
$release_archive_dir
|
||||
or (warn "$ME: release directory name not specified\n"), $fail = 1;
|
||||
@url_dir_list
|
||||
or (warn "$ME: URL directory name(s) not specified\n"), $fail = 1;
|
||||
|
||||
exists $valid_release_types{$release_type}
|
||||
or (warn "$ME: `$release_type': invalid release type\n"), $fail = 1;
|
||||
|
||||
@ARGV
|
||||
and (warn "$ME: too many arguments\n"), $fail = 1;
|
||||
$fail
|
||||
and usage 1;
|
||||
|
||||
my $my_distdir = "$package_name-$curr_version";
|
||||
my $tgz = "$my_distdir.tar.gz";
|
||||
my $tbz = "$my_distdir.tar.bz2";
|
||||
my $xd = "$package_name-$prev_version-$curr_version.xdelta";
|
||||
|
||||
my %size;
|
||||
|
||||
foreach my $f (($tgz, $tbz, $xd))
|
||||
{
|
||||
my $cmd = "du --human $f";
|
||||
my $t = `$cmd`;
|
||||
# FIXME-someday: give a better diagnostic, a la $PROCESS_STATUS
|
||||
$@
|
||||
and (warn "$ME: command failed: `$cmd'\n"), $fail = 1;
|
||||
chomp $t;
|
||||
$t =~ s/^([\d.]+[MkK]).*/${1}B/;
|
||||
$size{$f} = $t;
|
||||
}
|
||||
|
||||
$fail
|
||||
and exit 1;
|
||||
|
||||
# The markup is escaped as <\# so that when this script is sent by
|
||||
# mail (or part of a diff), Gnus is not triggered.
|
||||
print <<EOF;
|
||||
|
||||
Subject: $my_distdir released
|
||||
|
||||
<\#secure method=pgpmime mode=sign>
|
||||
|
||||
FIXME: put comments here
|
||||
|
||||
EOF
|
||||
|
||||
print "Here are the compressed sources:\n";
|
||||
foreach my $url (@url_dir_list)
|
||||
{
|
||||
print " $url/$tgz ($size{$tgz})\n";
|
||||
print " $url/$tbz ($size{$tbz})\n";
|
||||
}
|
||||
|
||||
print "\nAnd here are xdelta-style diffs:\n";
|
||||
foreach my $url (@url_dir_list)
|
||||
{
|
||||
print " $url/$xd ($size{$xd})\n";
|
||||
}
|
||||
|
||||
print "\nHere are GPG detached signatures:\n";
|
||||
foreach my $url (@url_dir_list)
|
||||
{
|
||||
print " $url/$tgz.asc\n";
|
||||
print " $url/$tbz.asc\n";
|
||||
}
|
||||
|
||||
# FIXME: clean up upon interrupt or die
|
||||
my $tmpdir = $ENV{TMPDIR} || '/tmp';
|
||||
my $tmp = "$tmpdir/$ME-$$";
|
||||
unlink $tmp; # ignore failure
|
||||
|
||||
print "\nHere are the MD5 and SHA1 signatures:\n";
|
||||
print "\n";
|
||||
# The markup is escaped as <\# so that when this script is sent by
|
||||
# mail (or part of a diff), Gnus is not triggered.
|
||||
print "<\#part type=text/plain filename=\"$tmp\" disposition=inline>\n"
|
||||
. "<\#/part>\n";
|
||||
|
||||
open OUT, '>', $tmp
|
||||
or die "$ME: $tmp: cannot open for writing: $!\n";
|
||||
|
||||
foreach my $meth (qw (md5 sha1))
|
||||
{
|
||||
foreach my $f (($tgz, $tbz, $xd))
|
||||
{
|
||||
open IN, '<', $f
|
||||
or die "$ME: $f: cannot open for reading: $!\n";
|
||||
binmode IN;
|
||||
my $dig =
|
||||
($meth eq 'md5'
|
||||
? Digest::MD5->new->addfile(*IN)->hexdigest
|
||||
: Digest::SHA1->new->addfile(*IN)->hexdigest);
|
||||
close IN;
|
||||
print OUT "$dig $f\n";
|
||||
}
|
||||
}
|
||||
|
||||
close OUT
|
||||
or die "$ME: $tmp: while writing: $!\n";
|
||||
chmod 0400, $tmp; # ignore failure
|
||||
|
||||
if ($news_file)
|
||||
{
|
||||
print "\nNEWS\n\n";
|
||||
|
||||
# Print all lines from $news_file, starting with the first one
|
||||
# that mentions $curr_version up to but not including
|
||||
# the first occurrence of $prev_version.
|
||||
my $in_items;
|
||||
open NEWS, '<', $news_file
|
||||
or die "$ME: $news_file: cannot open for reading: $!\n";
|
||||
while (defined (my $line = <NEWS>))
|
||||
{
|
||||
if ( ! $in_items)
|
||||
{
|
||||
# Match lines like this one:
|
||||
# * Major changes in release 5.0.1:
|
||||
# but not any other line that starts with a space, *, or -.
|
||||
$line =~ /^(\* Major changes.*|[^ *-].*)\Q$curr_version\E/o
|
||||
or next;
|
||||
$in_items = 1;
|
||||
print $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
# Be careful that this regexp cannot match version numbers
|
||||
# in NEWS items -- they might well say `introduced in 4.5.5',
|
||||
# and we don't want that to match.
|
||||
$line =~ /^(\* Major changes.*|[^ *-].*)\Q$prev_version\E/o
|
||||
and last;
|
||||
print $line;
|
||||
}
|
||||
}
|
||||
close NEWS;
|
||||
|
||||
$in_items
|
||||
or die "$ME: $news_file: no matching lines for `$curr_version'\n";
|
||||
}
|
||||
|
||||
$release_type eq 'major'
|
||||
or print_changelog_deltas ($package_name, $prev_version);
|
||||
|
||||
exit 0;
|
||||
}
|
||||
-436
@@ -1,436 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
# Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <[email protected]>.
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# `libtool' can also be set to `yes' or `no'.
|
||||
|
||||
if test -z "$depfile"; then
|
||||
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
|
||||
dir=`echo "$object" | sed 's,/.*$,/,'`
|
||||
if test "$dir" = "$object"; then
|
||||
dir=
|
||||
fi
|
||||
# FIXME: should be _deps on DOS.
|
||||
depfile="$dir.deps/$base"
|
||||
fi
|
||||
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. This file always lives in the current directory.
|
||||
# Also, the AIX compiler puts `$object:' at the start of each line;
|
||||
# $object doesn't have directory information.
|
||||
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
outname="$stripped.o"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
|
||||
base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'`
|
||||
tmpdepfile1="$base.o.d"
|
||||
tmpdepfile2="$base.d"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile1"; then
|
||||
tmpdepfile="$tmpdepfile1"
|
||||
else
|
||||
tmpdepfile="$tmpdepfile2"
|
||||
fi
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a space and a tab in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*) # this is libtool, let us make it quiet
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case "$arg" in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
# X makedepend
|
||||
(
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in no)
|
||||
set ""; shift
|
||||
cleared=yes
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*)
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case $arg in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*)
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case $arg in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,251 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
@@ -1 +1 @@
|
||||
1.29c
|
||||
1.75
|
||||
|
||||
+76
-63
@@ -1,6 +1,6 @@
|
||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,37 +17,25 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
# 02111-1307 USA
|
||||
|
||||
# We need a recent Autoconf to run a recent Autotest.
|
||||
AC_PREREQ(2.53)
|
||||
# This file uses AC_CONFIG_MACRO_DIR, so we need Autoconf 2.58 or better.
|
||||
# But Autoconf 2.58 has a bug in the way that it generates tests: it
|
||||
# puts the wrong absolute path names in the tests. So we need at
|
||||
# least Autoconf 2.59.
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([GNU Bison], [1.49a], [[email protected]])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_INIT([GNU Bison], [2.0], [[email protected]])
|
||||
AC_CONFIG_AUX_DIR([config])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([bison], [1.49a])
|
||||
AM_CONFIG_HEADER(config.h:config.hin)
|
||||
# We don't have a file m4/Makefile.am, so we need Automake 1.8 or later.
|
||||
AM_INIT_AUTOMAKE([1.8 check-news readme-alpha dist-bzip2])
|
||||
AC_CONFIG_HEADERS([config.h:config.hin])
|
||||
|
||||
# Initialize the test suite.
|
||||
AC_CONFIG_TESTDIR(tests)
|
||||
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
||||
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
||||
# Needed by tests/atlocal.in.
|
||||
AC_SUBST([GCC])
|
||||
gl_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# Checks for programs.
|
||||
# Checks for the compiler.
|
||||
AC_PROG_CC
|
||||
AM_PROG_LEX
|
||||
AC_PROG_YACC
|
||||
AC_MINIX
|
||||
AC_ISC_POSIX
|
||||
AM_PROG_CC_STDC
|
||||
AC_PROG_RANLIB
|
||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||
BISON_PROG_GNU_M4
|
||||
if test x"$ac_cv_prog_gnu_m4" != xyes; then
|
||||
AC_MSG_ERROR([GNU M4 1.4 is required])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||
|
||||
AC_ARG_ENABLE(gcc-warnings,
|
||||
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended)],
|
||||
[case "${enableval}" in
|
||||
@@ -59,62 +47,87 @@ if test "${enableval}" = yes; then
|
||||
BISON_WARNING(-Werror)
|
||||
AC_SUBST([WERROR_CFLAGS], [$WARNING_CFLAGS])
|
||||
WARNING_CFLAGS=
|
||||
BISON_WARNING(-Wall)
|
||||
BISON_WARNING(-W)
|
||||
BISON_WARNING(-Wbad-function-cast)
|
||||
BISON_WARNING(-Wall)
|
||||
BISON_WARNING(-Wcast-align)
|
||||
BISON_WARNING(-Wcast-qual)
|
||||
BISON_WARNING(-Wformat)
|
||||
BISON_WARNING(-Wwrite-strings)
|
||||
AC_SUBST([WARNING_CXXFLAGS], [$WARNING_CFLAGS])
|
||||
# The following warnings are not suitable for C++.
|
||||
BISON_WARNING(-Wbad-function-cast)
|
||||
BISON_WARNING(-Wmissing-declarations)
|
||||
BISON_WARNING(-Wmissing-prototypes)
|
||||
BISON_WARNING(-Wnested-externs)
|
||||
BISON_WARNING(-Wshadow)
|
||||
BISON_WARNING(-Wstrict-prototypes)
|
||||
BISON_WARNING(-Wwrite-strings)
|
||||
AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
|
||||
fi
|
||||
|
||||
# Checks for libraries.
|
||||
AC_DEFINE([_GNU_SOURCE],1,[Define to 1 for GNU C library extensions.])
|
||||
AC_ARG_ENABLE([yacc],
|
||||
[AC_HELP_STRING([--disable-yacc],
|
||||
[do not build a yacc command or an -ly library])],
|
||||
, [enable_yacc=yes])
|
||||
case $enable_yacc in
|
||||
yes)
|
||||
YACC_SCRIPT=yacc
|
||||
YACC_LIBRARY=liby.a;;
|
||||
*)
|
||||
YACC_SCRIPT=
|
||||
YACC_LIBRARY=;;
|
||||
esac
|
||||
AC_SUBST([YACC_SCRIPT])
|
||||
AC_SUBST([YACC_LIBRARY])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_LEX
|
||||
AC_PROG_YACC
|
||||
AC_PROG_RANLIB
|
||||
BISON_PROG_GNU_M4
|
||||
if test x"$ac_cv_prog_gnu_m4" != xyes; then
|
||||
AC_MSG_ERROR([GNU M4 1.4 is required])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(ctype.h locale.h memory.h stdlib.h string.h unistd.h)
|
||||
|
||||
# Checks for typedefs.
|
||||
|
||||
# Checks for structures.
|
||||
AC_CHECK_HEADERS_ONCE([locale.h])
|
||||
AM_STDBOOL_H
|
||||
|
||||
# Checks for compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AM_C_PROTOTYPES
|
||||
|
||||
# Checks for types.
|
||||
AC_CHECK_TYPES([uintptr_t])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_OBSTACK
|
||||
AC_FUNC_ERROR_AT_LINE
|
||||
AC_FUNC_STRNLEN
|
||||
UTILS_FUNC_MKSTEMP
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_DECLS([free, stpcpy, strchr, strspn, strnlen, malloc, memchr, memrchr])
|
||||
AC_REPLACE_FUNCS(stpcpy strchr strspn memchr memrchr)
|
||||
jm_FUNC_MALLOC
|
||||
jm_FUNC_REALLOC
|
||||
jm_PREREQ_QUOTEARG
|
||||
jm_PREREQ_ERROR
|
||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||
AM_WITH_DMALLOC
|
||||
BISON_PREREQ_SUBPIPE
|
||||
BISON_PREREQ_TIMEVAR
|
||||
|
||||
ALL_LINGUAS="de es et fr it ja nl ru sv tr"
|
||||
AM_GNU_GETTEXT(, need-ngettext)
|
||||
# gnulib and gettext.
|
||||
GNULIB_AUTOCONF_SNIPPET
|
||||
# We use po/Makevars.template, so we need at least gettext 0.12.
|
||||
AM_GNU_GETTEXT_VERSION([0.12])
|
||||
|
||||
# This is necessary so that .o files in LIBOBJS are also built via
|
||||
# the ANSI2KNR-filtering rules.
|
||||
LIB@&t@OBJS=`echo $LIB@&t@OBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
|
||||
AC_SUBST(LIB@&t@OBJS)
|
||||
# Initialize the test suite.
|
||||
AC_CONFIG_TESTDIR(tests)
|
||||
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
||||
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
||||
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
||||
AC_PROG_CXX
|
||||
BISON_TEST_FOR_WORKING_CXX_COMPILER
|
||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||
# Needed by tests/atlocal.in.
|
||||
AC_SUBST([GCC])
|
||||
O0CFLAGS=`echo $CFLAGS | sed 's/-O[0-9] *//'`
|
||||
AC_SUBST([O0CFLAGS])
|
||||
O0CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[0-9] *//'`
|
||||
AC_SUBST([O0CXXFLAGS])
|
||||
|
||||
AC_OUTPUT([Makefile
|
||||
config/Makefile
|
||||
intl/Makefile po/Makefile.in
|
||||
data/Makefile
|
||||
lib/Makefile src/Makefile doc/Makefile
|
||||
m4/Makefile])
|
||||
AC_CONFIG_FILES([Makefile
|
||||
config/Makefile
|
||||
po/Makefile.in
|
||||
data/Makefile
|
||||
lib/Makefile src/Makefile doc/Makefile])
|
||||
AC_OUTPUT
|
||||
@@ -1,28 +0,0 @@
|
||||
@echo off
|
||||
echo Configuring bison for go32
|
||||
rem This batch file assumes a unix-type "sed" program
|
||||
|
||||
echo # Makefile generated by "configure.bat"> Makefile
|
||||
echo all.dos : bison >> Makefile
|
||||
|
||||
if exist config.sed del config.sed
|
||||
|
||||
echo "s/@srcdir@/./g ">> config.sed
|
||||
echo "s/@CC@/gcc/g ">> config.sed
|
||||
echo "s/@INSTALL@//g ">> config.sed
|
||||
echo "s/@INSTALL_PROGRAM@//g ">> config.sed
|
||||
echo "s/@INSTALL_DATA@//g ">> config.sed
|
||||
echo "s/@DEFS@/-DHAVE_STRERROR/g ">> config.sed
|
||||
echo "s/@LIBS@//g ">> config.sed
|
||||
echo "s/@ALLOCA@//g ">> config.sed
|
||||
|
||||
echo "/^bison[ ]*:/,/-o/ { ">> config.sed
|
||||
echo " s/ \$(CC)/ >bison.rf/ ">> config.sed
|
||||
echo " /-o/ a\ ">> config.sed
|
||||
echo " $(CC) @bison.rf ">> config.sed
|
||||
echo "} ">> config.sed
|
||||
|
||||
sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed
|
||||
sed -f config2.sed Makefile.in >> Makefile
|
||||
del config.sed
|
||||
del config2.sed
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
## Copyright 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -15,7 +15,7 @@
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
dist_pkgdata_DATA = bison.simple bison.hairy bison.c++
|
||||
dist_pkgdata_DATA = README c.m4 yacc.c lalr1.cc glr.c
|
||||
|
||||
m4sugardir = $(pkgdatadir)/m4sugar
|
||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
|
||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
-*- outline -*-
|
||||
|
||||
This directory contains Bison skeletons: the general shapes of the
|
||||
different parser kinds, that are specialized for specific grammars by
|
||||
the bison program.
|
||||
|
||||
Currently, there are only three supported skeletons:
|
||||
|
||||
- yacc.c
|
||||
It used to be named bison.simple: it corresponds to C Yacc
|
||||
compatible LALR(1) parsers.
|
||||
|
||||
- lalr1.cc
|
||||
Produces a C++ parser class. It is still very experimental, and not
|
||||
yet supported. Please, subscribe to [email protected].
|
||||
|
||||
- glr.c
|
||||
A Generalized LR C parser based on Bison's LALR(1) tables.
|
||||
|
||||
These skeletons are the only ones supported by the Bison team.
|
||||
Because the interface between skeletons and the bison program is not
|
||||
finished, *we are not bound to it*. In particular, Bison is not
|
||||
mature enough for us to consider that ``foreign skeletons'' are
|
||||
supported.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
-878
@@ -1,878 +0,0 @@
|
||||
m4_divert(-1)
|
||||
|
||||
# b4_sint_type(MAX)
|
||||
# -----------------
|
||||
# Return the smallest signed int type able to handle the number MAX.
|
||||
m4_define([b4_sint_type],
|
||||
[m4_if(m4_eval([$1 <= 127]), [1], [signed char],
|
||||
m4_eval([$1 <= 32767]), [1], [signed short],
|
||||
m4_eval([$1 <= 2147483647]), [1], [signed int],
|
||||
[m4_fatal([no signed int type for $1])])])
|
||||
|
||||
|
||||
# b4_uint_type(MAX)
|
||||
# -----------------
|
||||
# Return the smallest unsigned int type able to handle the number MAX.
|
||||
m4_define([b4_uint_type],
|
||||
[m4_if(m4_eval([$1 <= 255]), [1], [unsigned char],
|
||||
m4_eval([$1 <= 65535]), [1], [unsigned short],
|
||||
m4_eval([$1 <= 4294967295]), [1], [unsigned int],
|
||||
[m4_fatal([no unsigned int type for $1])])])
|
||||
|
||||
|
||||
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ------------------------------------------
|
||||
# Output the definition of this token as #define.
|
||||
m4_define([b4_token_define],
|
||||
[#define $1 $2
|
||||
])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens as #define.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_map([b4_token_define], [$@])])
|
||||
|
||||
m4_define_default([b4_input_suffix], [.y])
|
||||
|
||||
m4_define_default([b4_output_parser_suffix],
|
||||
[m4_translit(b4_input_suffix, [yY], [cC])])
|
||||
|
||||
m4_define_default([b4_output_parser_name],
|
||||
[b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
|
||||
|
||||
|
||||
m4_define_default([b4_output_header_suffix],
|
||||
[m4_translit(b4_input_suffix, [yY], [hH])])
|
||||
|
||||
m4_define_default([b4_output_header_name],
|
||||
[b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
|
||||
|
||||
m4_define_default([b4_header_guard],
|
||||
[m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
|
||||
[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
|
||||
|
||||
m4_define([b4_inherit],
|
||||
[m4_ifdef([b4_root],
|
||||
[: public b4_root
|
||||
],
|
||||
[])])
|
||||
|
||||
m4_define([b4_param],
|
||||
[m4_ifdef([b4_root],
|
||||
[,
|
||||
const Param& param],
|
||||
[])])
|
||||
|
||||
m4_define([b4_constructor],
|
||||
[m4_ifdef([b4_root],
|
||||
[b4_root (param),
|
||||
],
|
||||
[])])
|
||||
|
||||
m4_define([b4_copyright],
|
||||
[/* -*- C++ -*- */
|
||||
/* A Bison parser, made from b4_filename,
|
||||
by GNU bison b4_version. */
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
Copyright 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */])
|
||||
|
||||
m4_divert(0)dnl
|
||||
#output "b4_output_header_name"
|
||||
b4_copyright
|
||||
#ifndef b4_header_guard
|
||||
# define b4_header_guard
|
||||
|
||||
#include "stack.hh"
|
||||
#include "location.hh"
|
||||
|
||||
#include <string>
|
||||
|
||||
/* Using locations. */
|
||||
#define YYLSP_NEEDED b4_locations_flag
|
||||
|
||||
/* Copy the first part of user declarations. */
|
||||
b4_pre_prologue
|
||||
|
||||
/* Tokens. */
|
||||
b4_token_defines(b4_tokens)
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG b4_debug
|
||||
#endif
|
||||
|
||||
/* Enabling verbose error message. */
|
||||
#ifndef YYERROR_VERBOSE
|
||||
# define YYERROR_VERBOSE b4_error_verbose
|
||||
#endif
|
||||
|
||||
#ifndef YYSTYPE
|
||||
m4_ifdef([b4_stype_line],
|
||||
[#line b4_stype_line "b4_filename"
|
||||
])dnl
|
||||
typedef b4_stype
|
||||
yystype;
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
b4_post_prologue
|
||||
|
||||
#line __oline__ "__ofile__"
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
Current.last_line = Rhs[[N]].last_line; \
|
||||
Current.last_column = Rhs[[N]].last_column;
|
||||
#endif
|
||||
|
||||
m4_if(b4_locations_flag, [0], [],
|
||||
[#ifndef YYLTYPE
|
||||
typedef struct yyltype
|
||||
{
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
} yyltype;
|
||||
# define YYLTYPE yyltype
|
||||
#endif])
|
||||
|
||||
namespace yy
|
||||
{
|
||||
class b4_name;
|
||||
|
||||
template < typename P >
|
||||
struct Traits
|
||||
{
|
||||
};
|
||||
|
||||
template < >
|
||||
struct Traits< b4_name >
|
||||
{
|
||||
typedef b4_uint_type(b4_token_number_max) TokenNumberType;
|
||||
typedef b4_sint_type(b4_rhs_number_max) RhsNumberType;
|
||||
typedef int StateType;
|
||||
typedef yystype SemanticType;
|
||||
typedef b4_ltype LocationType;
|
||||
};
|
||||
}
|
||||
|
||||
namespace yy
|
||||
{
|
||||
class b4_name b4_inherit
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Traits< b4_name >::TokenNumberType TokenNumberType;
|
||||
typedef Traits< b4_name >::RhsNumberType RhsNumberType;
|
||||
typedef Traits< b4_name >::StateType StateType;
|
||||
typedef Traits< b4_name >::SemanticType SemanticType;
|
||||
typedef Traits< b4_name >::LocationType LocationType;
|
||||
|
||||
typedef Stack< StateType > StateStack;
|
||||
typedef Stack< SemanticType > SemanticStack;
|
||||
typedef Stack< LocationType > LocationStack;
|
||||
|
||||
#if YYLSP_NEEDED
|
||||
b4_name (bool debug,
|
||||
LocationType initlocation[]b4_param) :
|
||||
b4_constructor[]debug_ (debug),
|
||||
initlocation_ (initlocation)
|
||||
#else
|
||||
b4_name (bool debug[]b4_param) :
|
||||
b4_constructor[]debug_ (debug)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~b4_name ()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int parse ();
|
||||
|
||||
private:
|
||||
|
||||
virtual void lex_ ();
|
||||
virtual void error_ ();
|
||||
virtual void print_ ();
|
||||
|
||||
/* Stacks. */
|
||||
StateStack state_stack_;
|
||||
SemanticStack semantic_stack_;
|
||||
LocationStack location_stack_;
|
||||
|
||||
/* Tables. */
|
||||
static const short pact_[[]];
|
||||
static const short defact_[[]];
|
||||
static const short pgoto_[[]];
|
||||
static const short defgoto_[[]];
|
||||
static const short table_[[]];
|
||||
static const short check_[[]];
|
||||
static const TokenNumberType r1_[[]];
|
||||
static const short r2_[[]];
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE
|
||||
static const char* const name_[[]];
|
||||
#endif
|
||||
|
||||
/* More tables, for debugging. */
|
||||
#if YYDEBUG
|
||||
static const RhsNumberType rhs_[[]];
|
||||
static const short prhs_[[]];
|
||||
static const short rline_[[]];
|
||||
#endif
|
||||
|
||||
/* Even more tables. */
|
||||
static inline TokenNumberType translate_ (int token);
|
||||
|
||||
/* Constants. */
|
||||
static const int eof_;
|
||||
static const int last_;
|
||||
static const int flag_;
|
||||
static const int nnts_;
|
||||
static const int nsym_;
|
||||
static const int empty_;
|
||||
static const int final_;
|
||||
static const int terror_;
|
||||
static const int errcode_;
|
||||
static const int ntokens_;
|
||||
static const int initdepth_;
|
||||
static const unsigned user_token_number_max_;
|
||||
static const TokenNumberType undef_token_;
|
||||
|
||||
/* State. */
|
||||
int n_;
|
||||
int len_;
|
||||
int debug_;
|
||||
int state_;
|
||||
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
int looka_;
|
||||
int ilooka_;
|
||||
|
||||
/* Message. */
|
||||
std::string message;
|
||||
|
||||
/* Semantic value and location of lookahead token. */
|
||||
SemanticType value;
|
||||
LocationType location;
|
||||
|
||||
/* @$ and $$. */
|
||||
SemanticType yyval;
|
||||
LocationType yyloc;
|
||||
|
||||
/* Initial location. */
|
||||
LocationType initlocation_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* not b4_header_guard */
|
||||
|
||||
#output "b4_output_prefix[]b4_output_infix[].cc"
|
||||
b4_copyright
|
||||
|
||||
#include "b4_output_header_name"
|
||||
|
||||
/* Enable debugging if requested. */
|
||||
#if YYDEBUG
|
||||
# include <cstdio>
|
||||
# define YYFPRINTF std::fprintf
|
||||
# define YYDPRINTF(Args) \
|
||||
do { \
|
||||
if (debug_) \
|
||||
YYFPRINTF Args; \
|
||||
} while (0)
|
||||
#else /* !YYDEBUG */
|
||||
# define YYDPRINTF(Args)
|
||||
#endif /* !YYDEBUG */
|
||||
|
||||
int
|
||||
yy::b4_name::parse ()
|
||||
{
|
||||
int nerrs = 0;
|
||||
int errstatus = 0;
|
||||
|
||||
/* Initialize stack. */
|
||||
state_stack_ = StateStack (0);
|
||||
semantic_stack_ = SemanticStack (1);
|
||||
location_stack_ = LocationStack (1);
|
||||
|
||||
/* Reserve initial space. The C parser needed that, but is it really
|
||||
useful here? */
|
||||
state_stack_.reserve (initdepth_);
|
||||
semantic_stack_.reserve (initdepth_);
|
||||
location_stack_.reserve (initdepth_);
|
||||
|
||||
/* Start. */
|
||||
state_ = 0;
|
||||
looka_ = empty_;
|
||||
#if YYLSP_NEEDED
|
||||
location = initlocation_;
|
||||
#endif
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
/* New state. */
|
||||
yynewstate:
|
||||
state_stack_.push (state_);
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", state_));
|
||||
goto yybackup;
|
||||
|
||||
/* Backup. */
|
||||
yybackup:
|
||||
|
||||
/* Try to take a decision without lookahead. */
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ == flag_)
|
||||
goto yydefault;
|
||||
|
||||
/* Read a lookahead token. */
|
||||
if (looka_ == empty_)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
lex_ ();
|
||||
}
|
||||
|
||||
/* Convert token to internal form. */
|
||||
if (looka_ <= 0)
|
||||
{
|
||||
looka_ = eof_;
|
||||
ilooka_ = 0;
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ilooka_ = translate_ (looka_);
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Next token is %d (%s", looka_, name_[[ilooka_]]);
|
||||
print_ ();
|
||||
YYFPRINTF (stderr, ")\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
n_ += ilooka_;
|
||||
if (n_ < 0 || n_ > last_ || check_[[n_]] != ilooka_)
|
||||
goto yydefault;
|
||||
|
||||
/* Reduce or error. */
|
||||
n_ = table_[[n_]];
|
||||
if (n_ < 0)
|
||||
{
|
||||
if (n_ == flag_)
|
||||
goto yyerrlab;
|
||||
else
|
||||
{
|
||||
n_ = -n_;
|
||||
goto yyreduce;
|
||||
}
|
||||
}
|
||||
else if (n_ == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
/* Accept? */
|
||||
if (n_ == final_)
|
||||
goto yyacceptlab;
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
YYDPRINTF ((stderr, "Shifting token %d (%s), ", looka_, name_[[ilooka_]]));
|
||||
|
||||
/* Discard the token being shifted unless it is eof. */
|
||||
if (looka_ != eof_)
|
||||
looka_ = empty_;
|
||||
|
||||
semantic_stack_.push (value);
|
||||
location_stack_.push (location);
|
||||
|
||||
/* Count tokens shifted since error; after three, turn off error
|
||||
status. */
|
||||
if (errstatus)
|
||||
--errstatus;
|
||||
|
||||
state_ = n_;
|
||||
goto yynewstate;
|
||||
|
||||
/* Default action. */
|
||||
yydefault:
|
||||
n_ = defact_[[state_]];
|
||||
if (n_ == 0)
|
||||
goto yyerrlab;
|
||||
goto yyreduce;
|
||||
|
||||
/* Reduce. */
|
||||
yyreduce:
|
||||
len_ = r2_[[n_]];
|
||||
if (len_)
|
||||
{
|
||||
yyval = semantic_stack_[[1 - len_]];
|
||||
yyloc = location_stack_[[1 - len_]];
|
||||
}
|
||||
else
|
||||
{
|
||||
yyval = semantic_stack_[[0]];
|
||||
yyloc = location_stack_[[0]];
|
||||
}
|
||||
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, rline_[[n_]]);
|
||||
for (unsigned i = prhs_[[n_]];
|
||||
rhs_[[i]] >= 0; ++i)
|
||||
YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]);
|
||||
YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len_)
|
||||
{
|
||||
Slice< LocationType, LocationStack > slice (location_stack_, len_);
|
||||
YYLLOC_DEFAULT (yyloc, slice, len_);
|
||||
}
|
||||
|
||||
{
|
||||
SemanticStack& yyvsp (semantic_stack_);
|
||||
LocationStack& yylsp (location_stack_);
|
||||
|
||||
switch (n_)
|
||||
{
|
||||
b4_actions
|
||||
}
|
||||
}
|
||||
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"
|
||||
|
||||
state_stack_.pop (len_);
|
||||
semantic_stack_.pop (len_);
|
||||
location_stack_.pop (len_);
|
||||
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "state stack now");
|
||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||
i != state_stack_.end (); ++i)
|
||||
YYFPRINTF (stderr, " %d", *i);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
semantic_stack_.push (yyval);
|
||||
location_stack_.push (yyloc);
|
||||
|
||||
/* Shift the result of the reduction. */
|
||||
n_ = r1_[[n_]];
|
||||
state_ = pgoto_[[n_ - ntokens_]] + state_stack_[[0]];
|
||||
if (state_ >= 0 && state_ <= last_ && check_[[state_]] == state_stack_[[0]])
|
||||
state_ = table_[[state_]];
|
||||
else
|
||||
state_ = defgoto_[[n_ - ntokens_]];
|
||||
goto yynewstate;
|
||||
|
||||
/* Report and recover from errors. This is very incomplete. */
|
||||
yyerrlab:
|
||||
/* If not already recovering from an error, report this error. */
|
||||
if (!errstatus)
|
||||
{
|
||||
++nerrs;
|
||||
|
||||
#if YYERROR_VERBOSE
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ > flag_ && n_ < last_)
|
||||
{
|
||||
message = "parse error, unexpected ";
|
||||
message += name_[[ilooka_]];
|
||||
{
|
||||
int count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
{
|
||||
message += (!count++) ? ", expecting " : " or ";
|
||||
message += name_[[x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
message = "parse error";
|
||||
error_ ();
|
||||
}
|
||||
goto yyerrlab1;
|
||||
|
||||
/* Error raised explicitly by an action. */
|
||||
yyerrlab1:
|
||||
if (errstatus == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
|
||||
/* Return failure if at end of input. */
|
||||
if (looka_ == eof_)
|
||||
goto yyabortlab;
|
||||
YYDPRINTF ((stderr, "Discarding token %d (%s).\n", looka_, name_[[ilooka_]]));
|
||||
looka_ = empty_;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token after shifting the error
|
||||
token. */
|
||||
|
||||
errstatus = 3;
|
||||
goto yyerrhandle;
|
||||
|
||||
/* Pop the current state because it cannot handle the error token. */
|
||||
yyerrdefault:
|
||||
yyerrpop:
|
||||
if (!state_stack_.height ())
|
||||
goto yyabortlab;
|
||||
state_ = (state_stack_.pop (), state_stack_[[0]]);
|
||||
semantic_stack_.pop ();
|
||||
location_stack_.pop ();;
|
||||
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Error: state stack now");
|
||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||
i != state_stack_.end (); ++i)
|
||||
YYFPRINTF (stderr, " %d", *i);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
yyerrhandle:
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ == flag_)
|
||||
goto yyerrdefault;
|
||||
|
||||
n_ += terror_;
|
||||
if (n_ < 0 || n_ > last_ || check_[[n_]] != terror_)
|
||||
goto yyerrdefault;
|
||||
|
||||
n_ = table_[[n_]];
|
||||
if (n_ < 0)
|
||||
{
|
||||
if (n_ == flag_)
|
||||
goto yyerrpop;
|
||||
n_ = -n_;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (!n_)
|
||||
goto yyerrpop;
|
||||
|
||||
if (n_ == final_)
|
||||
goto yyacceptlab;
|
||||
|
||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
||||
|
||||
semantic_stack_.push (value);
|
||||
location_stack_.push (location);
|
||||
|
||||
state_ = n_;
|
||||
goto yynewstate;
|
||||
|
||||
/* Accept. */
|
||||
yyacceptlab:
|
||||
return 0;
|
||||
|
||||
/* Abort. */
|
||||
yyabortlab:
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
yy::b4_name::lex_ ()
|
||||
{
|
||||
#if YYLSP_NEEDED
|
||||
looka_ = yylex (&value, &location);
|
||||
#else
|
||||
looka_ = yylex (&value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
|
||||
STATE-NUM. */
|
||||
const short
|
||||
yy::b4_name::pact_[[]] =
|
||||
{
|
||||
b4_pact
|
||||
};
|
||||
|
||||
/* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE
|
||||
doesn't specify something else to do. Zero means the default is an
|
||||
error. */
|
||||
const short
|
||||
yy::b4_name::defact_[[]] =
|
||||
{
|
||||
b4_defact
|
||||
};
|
||||
|
||||
/* YYPGOTO[[NTERM-NUM]]. */
|
||||
const short
|
||||
yy::b4_name::pgoto_[[]] =
|
||||
{
|
||||
b4_pgoto
|
||||
};
|
||||
|
||||
/* YYDEFGOTO[[NTERM-NUM]]. */
|
||||
const short
|
||||
yy::b4_name::defgoto_[[]] =
|
||||
{
|
||||
b4_defgoto
|
||||
};
|
||||
|
||||
/* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
|
||||
positive, shift that token. If negative, reduce the rule which
|
||||
number is the opposite. If zero, do what YYDEFACT says. */
|
||||
const short
|
||||
yy::b4_name::table_[[]] =
|
||||
{
|
||||
b4_table
|
||||
};
|
||||
|
||||
/* YYCHECK. */
|
||||
const short
|
||||
yy::b4_name::check_[[]] =
|
||||
{
|
||||
b4_check
|
||||
};
|
||||
|
||||
/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
|
||||
const yy::b4_name::TokenNumberType
|
||||
yy::b4_name::r1_[[]] =
|
||||
{
|
||||
b4_r1
|
||||
};
|
||||
|
||||
/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
|
||||
const short
|
||||
yy::b4_name::r2_[[]] =
|
||||
{
|
||||
b4_r2
|
||||
};
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE
|
||||
/* YYTNAME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||
const char*
|
||||
const yy::b4_name::name_[[]] =
|
||||
{
|
||||
b4_tname
|
||||
};
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||
const yy::b4_name::RhsNumberType
|
||||
yy::b4_name::rhs_[[]] =
|
||||
{
|
||||
b4_rhs
|
||||
};
|
||||
|
||||
/* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
|
||||
YYRHS. */
|
||||
const short
|
||||
yy::b4_name::prhs_[[]] =
|
||||
{
|
||||
b4_prhs
|
||||
};
|
||||
|
||||
/* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */
|
||||
const short
|
||||
yy::b4_name::rline_[[]] =
|
||||
{
|
||||
b4_rline
|
||||
};
|
||||
#endif
|
||||
|
||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
yy::b4_name::TokenNumberType
|
||||
yy::b4_name::translate_ (int token)
|
||||
{
|
||||
static
|
||||
const TokenNumberType
|
||||
translate_[[]] =
|
||||
{
|
||||
b4_translate
|
||||
};
|
||||
if ((unsigned) token <= user_token_number_max_)
|
||||
return translate_[[token]];
|
||||
else
|
||||
return undef_token_;
|
||||
}
|
||||
|
||||
const int yy::b4_name::eof_ = 0;
|
||||
const int yy::b4_name::last_ = b4_last;
|
||||
const int yy::b4_name::flag_ = b4_flag;
|
||||
const int yy::b4_name::nnts_ = b4_nnts;
|
||||
const int yy::b4_name::nsym_ = b4_nsym;
|
||||
const int yy::b4_name::empty_ = -2;
|
||||
const int yy::b4_name::final_ = b4_final;
|
||||
const int yy::b4_name::terror_ = 1;
|
||||
const int yy::b4_name::errcode_ = 256;
|
||||
const int yy::b4_name::ntokens_ = b4_ntokens;
|
||||
const int yy::b4_name::initdepth_ = b4_initdepth;
|
||||
|
||||
const unsigned yy::b4_name::user_token_number_max_ = b4_user_token_number_max;
|
||||
const yy::b4_name::TokenNumberType yy::b4_name::undef_token_ = b4_undef_token_number;
|
||||
|
||||
b4_epilogue
|
||||
|
||||
#output "stack.hh"
|
||||
b4_copyright
|
||||
|
||||
#ifndef BISON_STACK_HH
|
||||
# define BISON_STACK_HH
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace yy
|
||||
{
|
||||
template < class T, class S = std::vector< T > >
|
||||
class Stack
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename S::iterator Iterator;
|
||||
typedef typename S::const_iterator ConstIterator;
|
||||
|
||||
Stack () : seq_ ()
|
||||
{
|
||||
}
|
||||
|
||||
Stack (unsigned n) : seq_ (n)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
T&
|
||||
operator [[]] (int index)
|
||||
{
|
||||
return seq_[[height () - 1 + index]];
|
||||
}
|
||||
|
||||
inline
|
||||
const T&
|
||||
operator [[]] (int index) const
|
||||
{
|
||||
return seq_[[height () - 1 + index]];
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
push (const T& t)
|
||||
{
|
||||
seq_.push_back (t);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
pop (unsigned n = 1)
|
||||
{
|
||||
for (; n; --n)
|
||||
seq_.pop_back ();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
reserve (unsigned n)
|
||||
{
|
||||
seq_.reserve (n);
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
height () const
|
||||
{
|
||||
return seq_.size ();
|
||||
}
|
||||
|
||||
inline ConstIterator begin () const { return seq_.begin (); }
|
||||
inline ConstIterator end () const { return seq_.end (); }
|
||||
|
||||
private:
|
||||
|
||||
S seq_;
|
||||
};
|
||||
|
||||
template < class T, class S = Stack< T > >
|
||||
class Slice
|
||||
{
|
||||
public:
|
||||
|
||||
Slice (const S& stack,
|
||||
unsigned range) : stack_ (stack),
|
||||
range_ (range)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
const T&
|
||||
operator [[]] (unsigned index) const
|
||||
{
|
||||
return stack_[[index - range_]];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const S& stack_;
|
||||
unsigned range_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // not BISON_STACK_HH
|
||||
|
||||
#output "location.hh"
|
||||
b4_copyright
|
||||
|
||||
#ifndef BISON_LOCATION_HH
|
||||
# define BISON_LOCATION_HH
|
||||
|
||||
namespace yy
|
||||
{
|
||||
struct Position
|
||||
{
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
|
||||
struct Location
|
||||
{
|
||||
Position first;
|
||||
Position last;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // not BISON_LOCATION_HH
|
||||
@@ -1,336 +0,0 @@
|
||||
%%{section} %%{output-prefix} %%{output-infix} %%".c"
|
||||
/* -*- C -*- */
|
||||
|
||||
/* YYERROR and YYCOST are set by guards. If yyerror is set to a
|
||||
nonzero value by a guard, the reduction with which the guard is
|
||||
associated is not performed, and the error recovery mechanism is
|
||||
invoked. Yycost indicates the cost of performing the reduction
|
||||
given the attributes of the symbols. */
|
||||
static int yyerror;
|
||||
static int yycost;
|
||||
|
||||
/* YYMAXDEPTH indicates the size of the parser's state and value
|
||||
stacks. */
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
# define YYMAXDEPTH 500
|
||||
#endif
|
||||
|
||||
/* YYMAXRULES must be at least as large as the number of rules that
|
||||
could be placed in the rule queue. That number could be determined
|
||||
from the grammar and the size of the stack, but, as yet, it is not.
|
||||
*/
|
||||
|
||||
#ifndef YYMAXRULES
|
||||
# define YYMAXRULES 100
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXBACKUP
|
||||
# define YYMAXBACKUP 100
|
||||
#endif
|
||||
|
||||
|
||||
/* The state stack. */
|
||||
static short yyss[YYMAXDEPTH];
|
||||
/* The semantic value stack. */
|
||||
static YYSTYPE yyvs[YYMAXDEPTH];
|
||||
/* The location stack. */
|
||||
static YYLTYPE yyls[YYMAXDEPTH];
|
||||
/* The rule queue. */
|
||||
static short yyrq[YYMAXRULES];
|
||||
/* The lookahead symbol. */
|
||||
static int yychar;
|
||||
|
||||
/* the semantic value of the lookahead symbol. */
|
||||
static YYSTYPE yylval;
|
||||
|
||||
/* the semantic value for the state at the top of the state stack. */
|
||||
static YYSTYPE yytval;
|
||||
|
||||
/* the variable used to return semantic values from the action
|
||||
routines. */
|
||||
static YYSTYPE yyval;
|
||||
|
||||
/* location data for the lookahead symbol. */
|
||||
static YYLTYPE yylloc;
|
||||
|
||||
/* location data for the state at the top of the state stack. */
|
||||
static YYLTYPE yytloc;
|
||||
|
||||
|
||||
static int yynunlexed;
|
||||
static short yyunchar[YYMAXBACKUP];
|
||||
static YYSTYPE yyunval[YYMAXBACKUP];
|
||||
static YYLTYPE yyunloc[YYMAXBACKUP];
|
||||
|
||||
/* a pointer to the top of the state stack; only set during error
|
||||
recovery. */
|
||||
static short *yygssp;
|
||||
|
||||
/* a pointer to the top of the value stack; only set during error
|
||||
recovery. */
|
||||
static YYSTYPE *yygvsp;
|
||||
|
||||
/* a pointer to the top of the location stack; only set during error
|
||||
recovery. */
|
||||
static YYLTYPE *yyglsp;
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| Yyget is an interface between the parser and the lexical analyzer. |
|
||||
| It is costly to provide such an interface, but it avoids requiring |
|
||||
| the lexical analyzer to be able to back up the scan. |
|
||||
`--------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yyget (void)
|
||||
{
|
||||
if (yynunlexed > 0)
|
||||
{
|
||||
yynunlexed--;
|
||||
yychar = yyunchar[yynunlexed];
|
||||
yylval = yyunval[yynunlexed];
|
||||
yylloc = yyunloc[yynunlexed];
|
||||
}
|
||||
else if (yychar <= 0)
|
||||
yychar = 0;
|
||||
else
|
||||
{
|
||||
yychar = yylex ();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else
|
||||
yychar = YYTRANSLATE (yychar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
yyunlex (int chr, YYSTYPE val, YYLTYPE loc)
|
||||
{
|
||||
yyunchar[yynunlexed] = chr;
|
||||
yyunval[yynunlexed] = val;
|
||||
yyunloc[yynunlexed] = loc;
|
||||
yynunlexed++;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
yyrestore (short *first, short *last)
|
||||
{
|
||||
short *ssp;
|
||||
short *rp;
|
||||
int symbol;
|
||||
int state;
|
||||
int tvalsaved;
|
||||
|
||||
ssp = yygssp;
|
||||
yyunlex (yychar, yylval, yylloc);
|
||||
|
||||
tvalsaved = 0;
|
||||
while (first != last)
|
||||
{
|
||||
symbol = yystos[*ssp];
|
||||
if (symbol < YYNTBASE)
|
||||
{
|
||||
yyunlex (symbol, yytval, yytloc);
|
||||
tvalsaved = 1;
|
||||
ssp--;
|
||||
}
|
||||
|
||||
ssp--;
|
||||
|
||||
if (first == yyrq)
|
||||
first = yyrq + YYMAXRULES;
|
||||
|
||||
first--;
|
||||
|
||||
for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
|
||||
{
|
||||
if (symbol < YYNTBASE)
|
||||
state = yytable[yypact[*ssp] + symbol];
|
||||
else
|
||||
{
|
||||
state = yypgoto[symbol - YYNTBASE] + *ssp;
|
||||
|
||||
if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
|
||||
state = yytable[state];
|
||||
else
|
||||
state = yydefgoto[symbol - YYNTBASE];
|
||||
}
|
||||
|
||||
*++ssp = state;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tvalsaved && ssp > yyss)
|
||||
{
|
||||
yyunlex (yystos[*ssp], yytval, yytloc);
|
||||
ssp--;
|
||||
}
|
||||
|
||||
yygssp = ssp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
yyparse (void)
|
||||
{
|
||||
int yystate;
|
||||
int yyn;
|
||||
short *yyssp;
|
||||
short *yyrq0;
|
||||
short *yyptr;
|
||||
YYSTYPE *yyvsp;
|
||||
|
||||
int yylen;
|
||||
YYLTYPE *yylsp;
|
||||
short *yyrq1;
|
||||
short *yyrq2;
|
||||
|
||||
yystate = 0;
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs - 1;
|
||||
yylsp = yyls - 1;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
|
||||
yychar = yylex ();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else
|
||||
yychar = YYTRANSLATE (yychar);
|
||||
|
||||
yynewstate:
|
||||
|
||||
if (yyssp >= yyss + YYMAXDEPTH - 1)
|
||||
{
|
||||
yyabort ("Parser Stack Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
yyresume:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
yyn += yychar;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yystate = yyn;
|
||||
|
||||
yyptr = yyrq2;
|
||||
while (yyptr != yyrq1)
|
||||
{
|
||||
yyn = *yyptr++;
|
||||
yylen = yyr2[yyn];
|
||||
yyvsp -= yylen;
|
||||
yylsp -= yylen;
|
||||
|
||||
yyguard (yyn, yyvsp, yylsp);
|
||||
if (yyerror)
|
||||
goto yysemerr;
|
||||
|
||||
yyaction (yyn, yyvsp, yylsp);
|
||||
*++yyvsp = yyval;
|
||||
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->first_line = yytloc.first_line;
|
||||
yylsp->first_column = yytloc.first_column;
|
||||
yylsp->last_line = (yylsp - 1)->last_line;
|
||||
yylsp->last_column = (yylsp - 1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp + yylen - 1)->last_line;
|
||||
yylsp->last_column = (yylsp + yylen - 1)->last_column;
|
||||
}
|
||||
|
||||
if (yyptr == yyrq + YYMAXRULES)
|
||||
yyptr = yyrq;
|
||||
}
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
yyrq2 = yyptr;
|
||||
yyrq1 = yyrq0;
|
||||
|
||||
*++yyvsp = yytval;
|
||||
*++yylsp = yytloc;
|
||||
yytval = yylval;
|
||||
yytloc = yylloc;
|
||||
yyget ();
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yyreduce:
|
||||
|
||||
*yyrq0++ = yyn;
|
||||
|
||||
if (yyrq0 == yyrq + YYMAXRULES)
|
||||
yyrq0 = yyrq;
|
||||
|
||||
if (yyrq0 == yyrq2)
|
||||
{
|
||||
yyabort ("Parser Rule Queue Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
yyssp -= yyr2[yyn];
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yysemerr:
|
||||
*--yyptr = yyn;
|
||||
yyrq2 = yyptr;
|
||||
yyvsp += yyr2[yyn];
|
||||
|
||||
yyerrlab:
|
||||
|
||||
yygssp = yyssp;
|
||||
yygvsp = yyvsp;
|
||||
yyglsp = yylsp;
|
||||
yyrestore (yyrq0, yyrq2);
|
||||
yyrecover ();
|
||||
yystate = *yygssp;
|
||||
yyssp = yygssp;
|
||||
yyvsp = yygvsp;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
goto yyresume;
|
||||
}
|
||||
|
||||
%%{actions}
|
||||
-1224
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,421 @@
|
||||
m4_divert(-1) -*- Autoconf -*-
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
# 02111-1307 USA
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Identification. ##
|
||||
## ---------------- ##
|
||||
|
||||
# b4_copyright(TITLE, YEARS)
|
||||
# --------------------------
|
||||
m4_define([b4_copyright],
|
||||
[/* A Bison parser, made by GNU Bison b4_version. */
|
||||
|
||||
/* $1,
|
||||
Copyright (C) $2 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
[/* Identify Bison output. */
|
||||
[#]define YYBISON 1
|
||||
|
||||
/* Skeleton name. */
|
||||
[#]define YYSKELETON_NAME b4_skeleton
|
||||
|
||||
/* Pure parsers. */
|
||||
[#]define YYPURE b4_pure
|
||||
|
||||
/* Using locations. */
|
||||
[#]define YYLSP_NEEDED b4_locations_flag
|
||||
])
|
||||
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
m4_define_default([b4_epilogue], [])
|
||||
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
## Pure/impure interfaces. ##
|
||||
## ------------------------ ##
|
||||
|
||||
|
||||
# b4_user_args
|
||||
# ------------
|
||||
m4_define([b4_user_args],
|
||||
[m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||
# it to be single quoted.
|
||||
m4_define_default([b4_parse_param])
|
||||
m4_define([b4_parse_param],
|
||||
b4_parse_param))
|
||||
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data Types. ##
|
||||
## ------------ ##
|
||||
|
||||
|
||||
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
||||
# ---------------------------------
|
||||
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
||||
m4_define([b4_ints_in],
|
||||
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
b4_ints_in($@, [-128], [127]), [1], [signed char],
|
||||
|
||||
b4_ints_in($@, [0], [65535]), [1], [unsigned short int],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short int],
|
||||
|
||||
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||
|
||||
[int])])
|
||||
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# `NAME_min' to `NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
|
||||
## ------------------ ##
|
||||
## Decoding options. ##
|
||||
## ------------------ ##
|
||||
|
||||
|
||||
# b4_location_if(IF-TRUE, IF-FALSE)
|
||||
# ---------------------------------
|
||||
# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
|
||||
m4_define([b4_location_if],
|
||||
[m4_if(b4_locations_flag, [1],
|
||||
[$1],
|
||||
[$2])])
|
||||
|
||||
|
||||
# b4_pure_if(IF-TRUE, IF-FALSE)
|
||||
# -----------------------------
|
||||
# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
|
||||
m4_define([b4_pure_if],
|
||||
[m4_if(b4_pure, [1],
|
||||
[$1],
|
||||
[$2])])
|
||||
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
|
||||
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# -----------------------------------------
|
||||
# Output the definition of this token as #define.
|
||||
m4_define([b4_token_define],
|
||||
[#define $1 $2
|
||||
])
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[$1 = $2])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as enums and #define.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_if([$@], [[]], [],
|
||||
[/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
m4_map_sep([ b4_token_enum], [,
|
||||
],
|
||||
[$@])
|
||||
};
|
||||
#endif
|
||||
m4_map([b4_token_define], [$@])
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
|
||||
## --------------------------------------------- ##
|
||||
## Defining C functions in both K&R and ANSI-C. ##
|
||||
## --------------------------------------------- ##
|
||||
|
||||
|
||||
# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ----------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_function_def],
|
||||
[#if defined (__STDC__) || defined (__cplusplus)
|
||||
b4_c_ansi_function_def($@)
|
||||
#else
|
||||
$2
|
||||
$1 (b4_c_knr_formal_names(m4_shiftn(2, $@)))
|
||||
b4_c_knr_formal_decls(m4_shiftn(2, $@))
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ---------------------------------------------------------------
|
||||
# Declare the function NAME in ANSI.
|
||||
m4_define([b4_c_ansi_function_def],
|
||||
[$2
|
||||
$1 (b4_c_ansi_formals(m4_shiftn(2, $@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_formals([DECL1, NAME1], ...)
|
||||
# --------------------------------------
|
||||
# Output the arguments ANSI-C definition.
|
||||
m4_define([b4_c_ansi_formals],
|
||||
[m4_case([$@],
|
||||
[], [void],
|
||||
[[]], [void],
|
||||
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||
|
||||
m4_define([b4_c_ansi_formal],
|
||||
[$1])
|
||||
|
||||
|
||||
# b4_c_knr_formal_names([DECL1, NAME1], ...)
|
||||
# ------------------------------------------
|
||||
# Output the argument names.
|
||||
m4_define([b4_c_knr_formal_names],
|
||||
[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_knr_formal_name],
|
||||
[$2])
|
||||
|
||||
|
||||
# b4_c_knr_formal_decls([DECL1, NAME1], ...)
|
||||
# ------------------------------------------
|
||||
# Output the K&R argument declarations.
|
||||
m4_define([b4_c_knr_formal_decls],
|
||||
[m4_map_sep([b4_c_knr_formal_decl],
|
||||
[
|
||||
],
|
||||
[$@])])
|
||||
|
||||
m4_define([b4_c_knr_formal_decl],
|
||||
[ $1;])
|
||||
|
||||
|
||||
|
||||
## ------------------------------------------------------------ ##
|
||||
## Declaring (prototyping) C functions in both K&R and ANSI-C. ##
|
||||
## ------------------------------------------------------------ ##
|
||||
|
||||
|
||||
# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_function_decl],
|
||||
[#if defined (__STDC__) || defined (__cplusplus)
|
||||
b4_c_ansi_function_decl($@)
|
||||
#else
|
||||
$2 $1 ();
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ----------------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_ansi_function_decl],
|
||||
[$2 $1 (b4_c_ansi_formals(m4_shiftn(2, $@)));[]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Calling C functions. ##
|
||||
## --------------------- ##
|
||||
|
||||
|
||||
# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Call the function NAME with arguments NAME1, NAME2 etc.
|
||||
m4_define([b4_c_function_call],
|
||||
[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_args([DECL1, NAME1], ...)
|
||||
# ------------------------------
|
||||
# Output the arguments NAME1, NAME2...
|
||||
m4_define([b4_c_args],
|
||||
[m4_map_sep([b4_c_arg], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_arg],
|
||||
[$2])
|
||||
|
||||
|
||||
## ----------- ##
|
||||
## Synclines. ##
|
||||
## ----------- ##
|
||||
|
||||
|
||||
# b4_syncline(LINE, FILE)
|
||||
# -----------------------
|
||||
m4_define([b4_syncline],
|
||||
[m4_if(b4_synclines_flag, 1,
|
||||
[[#]line $1 $2])])
|
||||
|
||||
|
||||
# b4_symbol_actions(FILENAME, LINENO,
|
||||
# SYMBOL-TAG, SYMBOL-NUM,
|
||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||
# -------------------------------------------------
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
|
||||
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
||||
case $4: /* $3 */
|
||||
b4_syncline([$2], [$1])
|
||||
$5;
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
break;
|
||||
m4_popdef([b4_at_dollar])dnl
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
||||
# -------------------------------------------
|
||||
# Generate the "yydestruct" function, which declaration is issued using
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||
# or "b4_c_function_def" for K&R.
|
||||
m4_define([b4_yydestruct_generate],
|
||||
[[/*-----------------------------------------------.
|
||||
| Release the memory associated to this symbol. |
|
||||
`-----------------------------------------------*/
|
||||
|
||||
]$1([yydestruct],
|
||||
[static void],
|
||||
[[const char *yymsg], [yymsg]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
||||
[[YYLTYPE *yylocationp], [yylocationp]]]))[
|
||||
{
|
||||
/* Pacify ``unused variable'' warnings. */
|
||||
(void) yyvaluep;
|
||||
]b4_location_if([ (void) yylocationp;
|
||||
])[
|
||||
if (!yymsg)
|
||||
yymsg = "Deleting";
|
||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||
|
||||
switch (yytype)
|
||||
{
|
||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_yysymprint_generate(FUNCTION-DECLARATOR)
|
||||
# -------------------------------------------
|
||||
# Generate the "yysymprint" function, which declaration is issued using
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||
# or "b4_c_function_def" for K&R.
|
||||
m4_define([b4_yysymprint_generate],
|
||||
[[/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
|
||||
]$1([yysymprint],
|
||||
[static void],
|
||||
[[FILE *yyoutput], [yyoutput]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
||||
[[YYLTYPE *yylocationp], [yylocationp]]]))
|
||||
{
|
||||
/* Pacify ``unused variable'' warnings. */
|
||||
(void) yyvaluep;
|
||||
b4_location_if([ (void) yylocationp;
|
||||
])dnl
|
||||
[
|
||||
if (yytype < YYNTOKENS)
|
||||
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||
else
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||
|
||||
]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
fprintf (yyoutput, ": ");
|
||||
])dnl
|
||||
[
|
||||
# ifdef YYPRINT
|
||||
if (yytype < YYNTOKENS)
|
||||
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
||||
# endif
|
||||
switch (yytype)
|
||||
{
|
||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
}
|
||||
]])
|
||||
+2089
File diff suppressed because it is too large
Load Diff
+1372
File diff suppressed because it is too large
Load Diff
+23
-17
@@ -2,7 +2,7 @@ divert(-1)# -*- Autoconf -*-
|
||||
# This file is part of Autoconf.
|
||||
# Base M4 layer.
|
||||
# Requires GNU M4.
|
||||
# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -422,8 +422,8 @@ m4_define([m4_bmatch],
|
||||
[m4_if([$#], 0, [],
|
||||
[$#], 1, [],
|
||||
[$#], 2, [$2],
|
||||
m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
|
||||
[$3])])
|
||||
[m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
|
||||
[$3])])])
|
||||
|
||||
|
||||
# m4_map(MACRO, LIST)
|
||||
@@ -432,11 +432,26 @@ m4_define([m4_bmatch],
|
||||
# of LIST (which can be lists themselves, for multiple arguments MACROs).
|
||||
m4_define([m4_fst], [$1])
|
||||
m4_define([m4_map],
|
||||
[m4_if([$2], [[]], [],
|
||||
[m4_if([$2], [], [],
|
||||
[$2], [[]], [],
|
||||
[$1(m4_fst($2))[]dnl
|
||||
m4_map([$1], m4_cdr($2))])])
|
||||
|
||||
|
||||
# m4_map_sep(MACRO, SEPARATOR, LIST)
|
||||
# ----------------------------------
|
||||
# Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1, $2... $N
|
||||
# are the elements of LIST (which can be lists themselves, for multiple
|
||||
# arguments MACROs).
|
||||
m4_define([m4_map_sep],
|
||||
[m4_if([$3], [[]], [],
|
||||
[$1(m4_fst($3))[]dnl
|
||||
m4_if(m4_cdr($3),
|
||||
[[]], [],
|
||||
[$2])[]dnl
|
||||
m4_map_sep([$1], [$2], m4_cdr($3))])])
|
||||
|
||||
|
||||
## ---------------------------------------- ##
|
||||
## 6. Enhanced version of some primitives. ##
|
||||
## ---------------------------------------- ##
|
||||
@@ -469,7 +484,7 @@ m4_define([m4_bpatsubsts],
|
||||
# ------------------
|
||||
# This macro invokes all its arguments (in sequence, of course). It is
|
||||
# useful for making your macros more structured and readable by dropping
|
||||
# unecessary dnl's and have the macros indented properly.
|
||||
# unnecessary dnl's and have the macros indented properly.
|
||||
m4_define([m4_do],
|
||||
[m4_if($#, 0, [],
|
||||
$#, 1, [$1],
|
||||
@@ -615,7 +630,7 @@ m4_if($1, [$2], [],
|
||||
# Implementing `foreach' loops in m4 is much more tricky than it may
|
||||
# seem. Actually, the example of a `foreach' loop in the m4
|
||||
# documentation is wrong: it does not quote the arguments properly,
|
||||
# which leads to undesired expansions.
|
||||
# which leads to undesirable expansions.
|
||||
#
|
||||
# The example in the documentation is:
|
||||
#
|
||||
@@ -829,7 +844,7 @@ m4_define([m4_undivert],
|
||||
# m4_require'd.
|
||||
#
|
||||
# The implementation is based on two ideas, (i) using diversions to
|
||||
# prepare the expansion of the macro and its dependencies (by François
|
||||
# prepare the expansion of the macro and its dependencies (by Franc,ois
|
||||
# Pinard), and (ii) expand the most recently m4_require'd macros _after_
|
||||
# the previous macros (by Axel Thimm).
|
||||
#
|
||||
@@ -1484,7 +1499,7 @@ m4_define([m4_flatten],
|
||||
# of brackets around $1 (don't forget that the result must be quoted
|
||||
# too, hence one more quoting than applications).
|
||||
#
|
||||
# Then notice the 2 last pattens: they are in charge of removing the
|
||||
# Then notice the 2 last patterns: they are in charge of removing the
|
||||
# leading/trailing spaces. Why not just `[^ ]'? Because they are
|
||||
# applied to doubly quoted strings, i.e. more or less [[STRING]]. So
|
||||
# if there is a leading space in STRING, then it is the *third*
|
||||
@@ -1731,15 +1746,6 @@ m4_define([m4_version_compare],
|
||||
(m4_split(m4_version_unletter([$2]), [\.])))])
|
||||
|
||||
|
||||
# m4_PACKAGE_NAME
|
||||
# m4_PACKAGE_TARNAME
|
||||
# m4_PACKAGE_VERSION
|
||||
# m4_PACKAGE_STRING
|
||||
# m4_PACKAGE_BUGREPORT
|
||||
# --------------------
|
||||
m4_include([m4sugar/version.m4])
|
||||
|
||||
|
||||
# m4_version_prereq(VERSION, [IF-OK], [IF-NOT = FAIL])
|
||||
# ----------------------------------------------------
|
||||
# Check this Autoconf version against VERSION.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# This file is part of -*- Autoconf -*-.
|
||||
# Version of Autoconf.
|
||||
# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
m4_define([m4_PACKAGE_NAME], [GNU Autoconf])
|
||||
m4_define([m4_PACKAGE_TARNAME], [autoconf])
|
||||
m4_define([m4_PACKAGE_VERSION], [2.52h])
|
||||
m4_define([m4_PACKAGE_STRING], [GNU Autoconf 2.52h])
|
||||
m4_define([m4_PACKAGE_BUGREPORT], [[email protected]])
|
||||
+1318
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ A1. If you're looking for a guarantee or certification, I can't
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Q2. I can't build Bison because "make" complains that "msgfmt" is not
|
||||
fund. What should I do?
|
||||
found. What should I do?
|
||||
|
||||
A2. Like most GNU packages with internationalization support, that
|
||||
feature is turned on by default. If you have problems building
|
||||
|
||||
+19
-2
@@ -1,12 +1,29 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
AM_MAKEINFOFLAGS = --no-split
|
||||
info_TEXINFOS = bison.texinfo
|
||||
man_MANS = bison.1
|
||||
bison_TEXINFOS = gpl.texi fdl.texi
|
||||
|
||||
EXTRA_DIST = FAQ bison.1 bison.rnh refcard.tex
|
||||
EXTRA_DIST = FAQ bison.1 refcard.tex
|
||||
|
||||
CLEANFILES = refcard.dvi refcard.log refcard.ps
|
||||
CLEANFILES = refcard.dvi refcard.log refcard.ps bison.fns
|
||||
|
||||
refcard.dvi: refcard.tex
|
||||
tex refcard.tex
|
||||
|
||||
+39
-41
@@ -59,6 +59,11 @@ bison \- GNU Project parser generator (yacc replacement)
|
||||
.B \-\-fixed-output-files
|
||||
]
|
||||
file
|
||||
.br
|
||||
.B yacc
|
||||
[
|
||||
.I "similar options and operands"
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.I Bison
|
||||
is a parser generator in the style of
|
||||
@@ -75,10 +80,10 @@ Unlike
|
||||
.IR yacc ,
|
||||
the generated files do not have fixed names, but instead use the prefix
|
||||
of the input file.
|
||||
Moreover, if you need to put
|
||||
.IR C++
|
||||
Moreover, if you need to put
|
||||
.I C++
|
||||
code in the input file, you can end his name by a C++-like extension
|
||||
(.ypp or .y++), then bison will follow your extension to name the
|
||||
(.ypp or .y++), then bison will follow your extension to name the
|
||||
output file (.cpp or .c++).
|
||||
For instance, a grammar description file named
|
||||
.B parse.yxx
|
||||
@@ -86,10 +91,10 @@ would produce the generated parser in a file named
|
||||
.BR parse.tab.cxx ,
|
||||
instead of
|
||||
.IR yacc 's
|
||||
.BR y.tab.c
|
||||
or old
|
||||
.IR Bison
|
||||
versions
|
||||
.B y.tab.c
|
||||
or old
|
||||
.I Bison
|
||||
version's
|
||||
.BR parse.tab.c .
|
||||
.PP
|
||||
This description of the options that can be given to
|
||||
@@ -122,7 +127,7 @@ Specify a prefix to use for all
|
||||
.I bison
|
||||
output file names. The names are
|
||||
chosen as if the input file were named
|
||||
\fIfile-prefix\fB.c\fR.
|
||||
\fIfile-prefix\fP\fB.c\fP.
|
||||
.TP
|
||||
.B \-d
|
||||
.br
|
||||
@@ -135,10 +140,10 @@ as well as a few
|
||||
variable declarations.
|
||||
.sp
|
||||
If the parser output file is named
|
||||
\fIname\fB.c\fR
|
||||
.IB name .c
|
||||
then this file
|
||||
is named
|
||||
\fIname\fB.h\fR.
|
||||
\fIname\fP\fB.h\fP.
|
||||
.sp
|
||||
This output file is essential if you wish to put the definition of
|
||||
.B yylex
|
||||
@@ -148,29 +153,29 @@ needs to be able to refer to token type codes and the variable
|
||||
.BR yylval .
|
||||
.TP
|
||||
.BI \-\-defines= defines-file
|
||||
The behaviour of
|
||||
.BI \-\-defines
|
||||
is the same than
|
||||
.BI \-d
|
||||
option.
|
||||
The only difference is that it has an optionnal argument which is
|
||||
The behavior of
|
||||
.B \-\-defines
|
||||
is the same than
|
||||
.B \-d
|
||||
option.
|
||||
The only difference is that it has an optional argument which is
|
||||
the name of the output filename.
|
||||
.TP
|
||||
.BI \-g
|
||||
.br
|
||||
.ns
|
||||
Output a VCG definition of the LALR(1) grammar automaton computed by
|
||||
Bison. If the grammar file is
|
||||
Bison. If the grammar file is
|
||||
.BR foo.y
|
||||
, the VCG output file will be
|
||||
.BR foo.vcg .
|
||||
.TP
|
||||
.BI \-\-graph= graph-file
|
||||
The behaviour of
|
||||
.BI \-\-graph
|
||||
The behavior of
|
||||
.BI \-\-graph
|
||||
is the same than
|
||||
.BI \-g
|
||||
option. The only difference is that it has an optionnal argument which
|
||||
option. The only difference is that it has an optional argument which
|
||||
is the name of the output graph filename.
|
||||
.TP
|
||||
.B \-k
|
||||
@@ -178,8 +183,10 @@ is the name of the output graph filename.
|
||||
.ns
|
||||
.TP
|
||||
.B \-\-token-table
|
||||
This switch causes the \fIname\fB.tab.c\fR output to include a list of
|
||||
token names in order by their token numbers; this is defined in the array
|
||||
This switch causes the
|
||||
.IB name .tab.c
|
||||
output to include a list of
|
||||
token names in order by their token numbers; this is defined in the array
|
||||
.IR yytname .
|
||||
Also generated
|
||||
are #defines for
|
||||
@@ -209,9 +216,13 @@ parser file, treating it an independent source file in its own right.
|
||||
.ns
|
||||
.TP
|
||||
.B \-\-no-parser
|
||||
Do not generate the parser code into the output; generate only
|
||||
declarations. The generated \fIname\fB.tab.c\fR file will have only
|
||||
constant declarations. In addition, a \fIname\fB.act\fR file is
|
||||
Do not generate the parser code into the output; generate only
|
||||
declarations. The generated
|
||||
.IB name .tab.c
|
||||
file will have only
|
||||
constant declarations. In addition, a
|
||||
.IB name .act
|
||||
file is
|
||||
generated containing a switch statement body containing all the
|
||||
translated actions.
|
||||
.TP
|
||||
@@ -334,29 +345,16 @@ The purpose of this switch is to imitate
|
||||
.IR yacc 's
|
||||
output file name conventions.
|
||||
Thus, the following shell script can substitute for
|
||||
.I yacc
|
||||
and is often installed as
|
||||
.IR yacc :
|
||||
.sp
|
||||
.RS
|
||||
.ft B
|
||||
bison \-y $*
|
||||
bison \-y "$@"
|
||||
.ft R
|
||||
.sp
|
||||
.RE
|
||||
.SH FILES
|
||||
/usr/local/share/bison/bison.simple simple parser
|
||||
.br
|
||||
/usr/local/share/bison/bison.hairy complicated parser
|
||||
.SH "ENVIRONMENT VARIABLES"
|
||||
.TP
|
||||
.SM BISON_SIMPLE
|
||||
If this is set, it specifies the location in which the
|
||||
.B bison.simple
|
||||
parser can be found.
|
||||
.TP
|
||||
.SM BISON_HAIRY
|
||||
If this is set, it specifies the location in which the
|
||||
.B bison.hairy
|
||||
parser can be found.
|
||||
.SH SEE ALSO
|
||||
.IR yacc (1)
|
||||
.br
|
||||
|
||||
-192
@@ -1,192 +0,0 @@
|
||||
.!
|
||||
.! RUNOFF source file for BISON.HLP
|
||||
.!
|
||||
.! This is a RUNOFF input file which will produce a VMS help file
|
||||
.! for the VMS HELP library.
|
||||
.!
|
||||
.! Eric Youngdale and Wilfred J. Hansen ([email protected]).
|
||||
.!
|
||||
.literal
|
||||
.end literal
|
||||
.no paging
|
||||
.no flags all
|
||||
.right margin 70
|
||||
.left margin 1
|
||||
|
||||
.indent -1
|
||||
1 BISON
|
||||
.skip
|
||||
The BISON command invokes the GNU BISON parser generator.
|
||||
.skip
|
||||
.literal
|
||||
BISON file-spec
|
||||
.end literal
|
||||
.skip
|
||||
.indent -1
|
||||
2 Parameters
|
||||
.skip
|
||||
file-spec
|
||||
.skip
|
||||
Here file-spec is the grammar file name, which usually ends in
|
||||
.y. The parser file's name is made by replacing the .y
|
||||
with _tab.c. Thus, the command bison foo.y yields
|
||||
foo_tab.c.
|
||||
|
||||
.skip
|
||||
.indent -1
|
||||
2 Qualifiers
|
||||
.skip
|
||||
The following is the list of available qualifiers for BISON:
|
||||
.literal
|
||||
/DEBUG
|
||||
/DEFINES
|
||||
/FILE_PREFIX=prefix
|
||||
/FIXED_OUTFILES
|
||||
/NAME_PREFIX=prefix
|
||||
/NOLINES
|
||||
/NOPARSER
|
||||
/OUTPUT=outfilefile
|
||||
/RAW
|
||||
/TOKEN_TABLE
|
||||
/VERBOSE
|
||||
/VERSION
|
||||
/YACC
|
||||
.end literal
|
||||
.skip
|
||||
.indent -1
|
||||
2 /DEBUG
|
||||
.skip
|
||||
In the parser file,
|
||||
define the macro YYDEBUG to 1 if it is not already defined,
|
||||
so that the debugging facilities are compiled.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /DEFINES
|
||||
.skip
|
||||
Write an extra output file containing macro definitions for the token
|
||||
type names defined in the grammar and the semantic value type
|
||||
YYSTYPE, as well as a extern variable declarations.
|
||||
.skip
|
||||
If the parser output file is named "name.c" then this file
|
||||
is named "name.h".
|
||||
.skip
|
||||
This output file is essential if you wish to put the definition of
|
||||
yylex in a separate source file, because yylex needs to
|
||||
be able to refer to token type codes and the variable
|
||||
yylval.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /FILE_PREFIX
|
||||
.skip
|
||||
.literal
|
||||
/FILIE_PREFIX=prefix
|
||||
.end literal
|
||||
.skip
|
||||
Specify a prefix to use for all Bison output file names. The names are
|
||||
chosen as if the input file were named prefix.c
|
||||
|
||||
.skip
|
||||
.indent -1
|
||||
2 /FIXED_OUTFILES
|
||||
.skip
|
||||
Equivalent to /OUTPUT=y_tab.c; the parser output file is called
|
||||
y_tab.c, and the other outputs are called y.output and
|
||||
y_tab.h. The purpose of this switch is to imitate Yacc's output
|
||||
file name conventions. The /YACC qualifier is functionally equivalent
|
||||
to /FIXED_OUTFILES. The following command definition will
|
||||
work as a substitute for Yacc:
|
||||
|
||||
.literal
|
||||
$YACC:==BISON/FIXED_OUTFILES
|
||||
.end literal
|
||||
.skip
|
||||
.indent -1
|
||||
2 /NAME_PREFIX
|
||||
.skip
|
||||
.literal
|
||||
/NAME_PREFIX=prefix
|
||||
.end literal
|
||||
.skip
|
||||
Rename the external symbols used in the parser so that they start with
|
||||
"prefix" instead of "yy". The precise list of symbols renamed
|
||||
is yyparse, yylex, yyerror, yylval, yychar and yydebug.
|
||||
|
||||
For example, if you use /NAME_PREFIX="c", the names become cparse,
|
||||
clex, and so on.
|
||||
|
||||
.skip
|
||||
.indent -1
|
||||
2 /NOLINES
|
||||
.skip
|
||||
Don't put any "#line" preprocessor commands in the parser file.
|
||||
Ordinarily Bison puts them in the parser file so that the C compiler
|
||||
and debuggers will associate errors with your source file, the
|
||||
grammar file. This option causes them to associate errors with the
|
||||
parser file, treating it an independent source file in its own right.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /NOPARSER
|
||||
.skip
|
||||
Do not generate the parser code into the output; generate only
|
||||
declarations. The generated name_tab.c file will have only
|
||||
constant declarations. In addition, a name.act file is
|
||||
generated containing a switch statement body containing all the
|
||||
translated actions.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /OUTPUT
|
||||
.skip
|
||||
.literal
|
||||
/OUTPUT=outfile
|
||||
.end literal
|
||||
.skip
|
||||
Specify the name "outfile" for the parser file.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /RAW
|
||||
.skip
|
||||
When this switch is specified, the .tab.h file defines the tokens to
|
||||
have the bison token numbers rather than the yacc compatible numbers.
|
||||
To employ this switch you would have to have your own parser.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /TOKEN_TABLE
|
||||
.skip
|
||||
This switch causes the name_tab.c output to include a list of
|
||||
token names in order by their token numbers; this is defined in the array
|
||||
yytname. Also generated are #defines for YYNTOKENS, YYNNTS, YYNRULES,
|
||||
and YYNSTATES.
|
||||
|
||||
.skip
|
||||
.indent -1
|
||||
2 /VERBOSE
|
||||
.skip
|
||||
Write an extra output file containing verbose descriptions of the
|
||||
parser states and what is done for each type of look-ahead token in
|
||||
that state.
|
||||
.skip
|
||||
This file also describes all the conflicts, both those resolved by
|
||||
operator precedence and the unresolved ones.
|
||||
.skip
|
||||
The file's name is made by removing _tab.c or .c from
|
||||
the parser output file name, and adding .output instead.
|
||||
.skip
|
||||
Therefore, if the input file is foo.y, then the parser file is
|
||||
called foo_tab.c by default. As a consequence, the verbose
|
||||
output file is called foo.output.
|
||||
.skip
|
||||
.indent -1
|
||||
2 /VERSION
|
||||
.skip
|
||||
Print the version number of Bison.
|
||||
|
||||
.skip
|
||||
.indent -1
|
||||
2 /YACC
|
||||
.skip
|
||||
See /FIXED_OUTFILES.
|
||||
.skip
|
||||
.indent -1
|
||||
|
||||
|
||||
|
||||
+2641
-842
File diff suppressed because it is too large
Load Diff
+138
-87
@@ -1,11 +1,12 @@
|
||||
|
||||
@node GNU Free Documentation License
|
||||
@appendixsec GNU Free Documentation License
|
||||
|
||||
@cindex FDL, GNU Free Documentation License
|
||||
@center Version 1.1, March 2000
|
||||
@center Version 1.2, November 2002
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 2000 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
@@ -17,12 +18,12 @@ of this license document, but changing it is not allowed.
|
||||
PREAMBLE
|
||||
|
||||
The purpose of this License is to make a manual, textbook, or other
|
||||
written document @dfn{free} in the sense of freedom: to assure everyone
|
||||
the effective freedom to copy and redistribute it, with or without
|
||||
modifying it, either commercially or noncommercially. Secondarily,
|
||||
this License preserves for the author and publisher a way to get
|
||||
credit for their work, while not being considered responsible for
|
||||
modifications made by others.
|
||||
functional and useful document @dfn{free} in the sense of freedom: to
|
||||
assure everyone the effective freedom to copy and redistribute it,
|
||||
with or without modifying it, either commercially or noncommercially.
|
||||
Secondarily, this License preserves for the author and publisher a way
|
||||
to get credit for their work, while not being considered responsible
|
||||
for modifications made by others.
|
||||
|
||||
This License is a kind of ``copyleft'', which means that derivative
|
||||
works of the document must themselves be free in the same sense. It
|
||||
@@ -40,57 +41,69 @@ principally for works whose purpose is instruction or reference.
|
||||
@item
|
||||
APPLICABILITY AND DEFINITIONS
|
||||
|
||||
This License applies to any manual or other work that contains a
|
||||
notice placed by the copyright holder saying it can be distributed
|
||||
under the terms of this License. The ``Document'', below, refers to any
|
||||
such manual or work. Any member of the public is a licensee, and is
|
||||
addressed as ``you''.
|
||||
This License applies to any manual or other work, in any medium, that
|
||||
contains a notice placed by the copyright holder saying it can be
|
||||
distributed under the terms of this License. Such a notice grants a
|
||||
world-wide, royalty-free license, unlimited in duration, to use that
|
||||
work under the conditions stated herein. The ``Document'', below,
|
||||
refers to any such manual or work. Any member of the public is a
|
||||
licensee, and is addressed as ``you''. You accept the license if you
|
||||
copy, modify or distribute the work in a way requiring permission
|
||||
under copyright law.
|
||||
|
||||
A ``Modified Version'' of the Document means any work containing the
|
||||
Document or a portion of it, either copied verbatim, or with
|
||||
modifications and/or translated into another language.
|
||||
|
||||
A ``Secondary Section'' is a named appendix or a front-matter section of
|
||||
the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall subject
|
||||
(or to related matters) and contains nothing that could fall directly
|
||||
within that overall subject. (For example, if the Document is in part a
|
||||
textbook of mathematics, a Secondary Section may not explain any
|
||||
mathematics.) The relationship could be a matter of historical
|
||||
A ``Secondary Section'' is a named appendix or a front-matter section
|
||||
of the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall
|
||||
subject (or to related matters) and contains nothing that could fall
|
||||
directly within that overall subject. (Thus, if the Document is in
|
||||
part a textbook of mathematics, a Secondary Section may not explain
|
||||
any mathematics.) The relationship could be a matter of historical
|
||||
connection with the subject or with related matters, or of legal,
|
||||
commercial, philosophical, ethical or political position regarding
|
||||
them.
|
||||
|
||||
The ``Invariant Sections'' are certain Secondary Sections whose titles
|
||||
are designated, as being those of Invariant Sections, in the notice
|
||||
that says that the Document is released under this License.
|
||||
that says that the Document is released under this License. If a
|
||||
section does not fit the above definition of Secondary then it is not
|
||||
allowed to be designated as Invariant. The Document may contain zero
|
||||
Invariant Sections. If the Document does not identify any Invariant
|
||||
Sections then there are none.
|
||||
|
||||
The ``Cover Texts'' are certain short passages of text that are listed,
|
||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
the Document is released under this License.
|
||||
the Document is released under this License. A Front-Cover Text may
|
||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||
|
||||
A ``Transparent'' copy of the Document means a machine-readable copy,
|
||||
represented in a format whose specification is available to the
|
||||
general public, whose contents can be viewed and edited directly and
|
||||
general public, that is suitable for revising the document
|
||||
straightforwardly with generic text editors or (for images composed of
|
||||
pixels) generic paint programs or (for drawings) some widely available
|
||||
drawing editor, and that is suitable for input to text formatters or
|
||||
for automatic translation to a variety of formats suitable for input
|
||||
to text formatters. A copy made in an otherwise Transparent file
|
||||
format whose markup has been designed to thwart or discourage
|
||||
subsequent modification by readers is not Transparent. A copy that is
|
||||
not ``Transparent'' is called ``Opaque''.
|
||||
format whose markup, or absence of markup, has been arranged to thwart
|
||||
or discourage subsequent modification by readers is not Transparent.
|
||||
An image format is not Transparent if used for any substantial amount
|
||||
of text. A copy that is not ``Transparent'' is called ``Opaque''.
|
||||
|
||||
Examples of suitable formats for Transparent copies include plain
|
||||
@sc{ascii} without markup, Texinfo input format, La@TeX{} input format,
|
||||
@acronym{SGML} or @acronym{XML} using a publicly available
|
||||
@acronym{DTD}, and standard-conforming simple @acronym{HTML} designed
|
||||
for human modification. Opaque formats include PostScript,
|
||||
@acronym{PDF}, proprietary formats that can be read and edited only by
|
||||
proprietary word processors, @acronym{SGML} or @acronym{XML} for which
|
||||
the @acronym{DTD} and/or processing tools are not generally available,
|
||||
and the machine-generated @acronym{HTML} produced by some word
|
||||
processors for output purposes only.
|
||||
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
|
||||
format, @acronym{SGML} or @acronym{XML} using a publicly available
|
||||
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
|
||||
PostScript or @acronym{PDF} designed for human modification. Examples
|
||||
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
|
||||
@acronym{JPG}. Opaque formats include proprietary formats that can be
|
||||
read and edited only by proprietary word processors, @acronym{SGML} or
|
||||
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
|
||||
not generally available, and the machine-generated @acronym{HTML},
|
||||
PostScript or @acronym{PDF} produced by some word processors for
|
||||
output purposes only.
|
||||
|
||||
The ``Title Page'' means, for a printed book, the title page itself,
|
||||
plus such following pages as are needed to hold, legibly, the material
|
||||
@@ -99,6 +112,21 @@ formats which do not have any title page as such, ``Title Page'' means
|
||||
the text near the most prominent appearance of the work's title,
|
||||
preceding the beginning of the body of the text.
|
||||
|
||||
A section ``Entitled XYZ'' means a named subunit of the Document whose
|
||||
title either is precisely XYZ or contains XYZ in parentheses following
|
||||
text that translates XYZ in another language. (Here XYZ stands for a
|
||||
specific section name mentioned below, such as ``Acknowledgements'',
|
||||
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
|
||||
of such a section when you modify the Document means that it remains a
|
||||
section ``Entitled XYZ'' according to this definition.
|
||||
|
||||
The Document may include Warranty Disclaimers next to the notice which
|
||||
states that this License applies to the Document. These Warranty
|
||||
Disclaimers are considered to be included by reference in this
|
||||
License, but only as regards disclaiming warranties: any other
|
||||
implication that these Warranty Disclaimers may have is void and has
|
||||
no effect on the meaning of this License.
|
||||
|
||||
@item
|
||||
VERBATIM COPYING
|
||||
|
||||
@@ -118,9 +146,10 @@ you may publicly display copies.
|
||||
@item
|
||||
COPYING IN QUANTITY
|
||||
|
||||
If you publish printed copies of the Document numbering more than 100,
|
||||
and the Document's license notice requires Cover Texts, you must enclose
|
||||
the copies in covers that carry, clearly and legibly, all these Cover
|
||||
If you publish printed copies (or copies in media that commonly have
|
||||
printed covers) of the Document, numbering more than 100, and the
|
||||
Document's license notice requires Cover Texts, you must enclose the
|
||||
copies in covers that carry, clearly and legibly, all these Cover
|
||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
the back cover. Both covers must also clearly and legibly identify
|
||||
you as the publisher of these copies. The front cover must present
|
||||
@@ -138,16 +167,15 @@ pages.
|
||||
If you publish or distribute Opaque copies of the Document numbering
|
||||
more than 100, you must either include a machine-readable Transparent
|
||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
a publicly-accessible computer-network location containing a complete
|
||||
Transparent copy of the Document, free of added material, which the
|
||||
general network-using public has access to download anonymously at no
|
||||
charge using public-standard network protocols. If you use the latter
|
||||
option, you must take reasonably prudent steps, when you begin
|
||||
distribution of Opaque copies in quantity, to ensure that this
|
||||
Transparent copy will remain thus accessible at the stated location
|
||||
until at least one year after the last time you distribute an Opaque
|
||||
copy (directly or through your agents or retailers) of that edition to
|
||||
the public.
|
||||
a computer-network location from which the general network-using
|
||||
public has access to download using public-standard network protocols
|
||||
a complete Transparent copy of the Document, free of added material.
|
||||
If you use the latter option, you must take reasonably prudent steps,
|
||||
when you begin distribution of Opaque copies in quantity, to ensure
|
||||
that this Transparent copy will remain thus accessible at the stated
|
||||
location until at least one year after the last time you distribute an
|
||||
Opaque copy (directly or through your agents or retailers) of that
|
||||
edition to the public.
|
||||
|
||||
It is requested, but not required, that you contact the authors of the
|
||||
Document well before redistributing any large number of copies, to give
|
||||
@@ -175,7 +203,8 @@ if the original publisher of that version gives permission.
|
||||
List on the Title Page, as authors, one or more persons or entities
|
||||
responsible for authorship of the modifications in the Modified
|
||||
Version, together with at least five of the principal authors of the
|
||||
Document (all of its principal authors, if it has less than five).
|
||||
Document (all of its principal authors, if it has fewer than five),
|
||||
unless they release you from this requirement.
|
||||
|
||||
@item
|
||||
State on the Title page the name of the publisher of the
|
||||
@@ -201,10 +230,10 @@ and required Cover Texts given in the Document's license notice.
|
||||
Include an unaltered copy of this License.
|
||||
|
||||
@item
|
||||
Preserve the section entitled ``History'', and its title, and add to
|
||||
it an item stating at least the title, year, new authors, and
|
||||
Preserve the section Entitled ``History'', Preserve its Title, and add
|
||||
to it an item stating at least the title, year, new authors, and
|
||||
publisher of the Modified Version as given on the Title Page. If
|
||||
there is no section entitled ``History'' in the Document, create one
|
||||
there is no section Entitled ``History'' in the Document, create one
|
||||
stating the title, year, authors, and publisher of the Document as
|
||||
given on its Title Page, then add an item describing the Modified
|
||||
Version as stated in the previous sentence.
|
||||
@@ -219,10 +248,10 @@ least four years before the Document itself, or if the original
|
||||
publisher of the version it refers to gives permission.
|
||||
|
||||
@item
|
||||
In any section entitled ``Acknowledgments'' or ``Dedications'',
|
||||
preserve the section's title, and preserve in the section all the
|
||||
substance and tone of each of the contributor acknowledgments
|
||||
and/or dedications given therein.
|
||||
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
|
||||
the Title of the section, and preserve in the section all the
|
||||
substance and tone of each of the contributor acknowledgements and/or
|
||||
dedications given therein.
|
||||
|
||||
@item
|
||||
Preserve all the Invariant Sections of the Document,
|
||||
@@ -230,12 +259,15 @@ unaltered in their text and in their titles. Section numbers
|
||||
or the equivalent are not considered part of the section titles.
|
||||
|
||||
@item
|
||||
Delete any section entitled ``Endorsements''. Such a section
|
||||
Delete any section Entitled ``Endorsements''. Such a section
|
||||
may not be included in the Modified Version.
|
||||
|
||||
@item
|
||||
Do not retitle any existing section as ``Endorsements''
|
||||
or to conflict in title with any Invariant Section.
|
||||
Do not retitle any existing section to be Entitled ``Endorsements'' or
|
||||
to conflict in title with any Invariant Section.
|
||||
|
||||
@item
|
||||
Preserve any Warranty Disclaimers.
|
||||
@end enumerate
|
||||
|
||||
If the Modified Version includes new front-matter sections or
|
||||
@@ -245,7 +277,7 @@ of these sections as invariant. To do this, add their titles to the
|
||||
list of Invariant Sections in the Modified Version's license notice.
|
||||
These titles must be distinct from any other section titles.
|
||||
|
||||
You may add a section entitled ``Endorsements'', provided it contains
|
||||
You may add a section Entitled ``Endorsements'', provided it contains
|
||||
nothing but endorsements of your Modified Version by various
|
||||
parties---for example, statements of peer review or that the text has
|
||||
been approved by an organization as the authoritative definition of a
|
||||
@@ -273,7 +305,7 @@ License, under the terms defined in section 4 above for modified
|
||||
versions, provided that you include in the combination all of the
|
||||
Invariant Sections of all of the original documents, unmodified, and
|
||||
list them all as Invariant Sections of your combined work in its
|
||||
license notice.
|
||||
license notice, and that you preserve all their Warranty Disclaimers.
|
||||
|
||||
The combined work need only contain one copy of this License, and
|
||||
multiple identical Invariant Sections may be replaced with a single
|
||||
@@ -284,11 +316,11 @@ author or publisher of that section if known, or else a unique number.
|
||||
Make the same adjustment to the section titles in the list of
|
||||
Invariant Sections in the license notice of the combined work.
|
||||
|
||||
In the combination, you must combine any sections entitled ``History''
|
||||
in the various original documents, forming one section entitled
|
||||
``History''; likewise combine any sections entitled ``Acknowledgments'',
|
||||
and any sections entitled ``Dedications''. You must delete all sections
|
||||
entitled ``Endorsements.''
|
||||
In the combination, you must combine any sections Entitled ``History''
|
||||
in the various original documents, forming one section Entitled
|
||||
``History''; likewise combine any sections Entitled ``Acknowledgements'',
|
||||
and any sections Entitled ``Dedications''. You must delete all
|
||||
sections Entitled ``Endorsements.''
|
||||
|
||||
@item
|
||||
COLLECTIONS OF DOCUMENTS
|
||||
@@ -309,18 +341,20 @@ AGGREGATION WITH INDEPENDENT WORKS
|
||||
|
||||
A compilation of the Document or its derivatives with other separate
|
||||
and independent documents or works, in or on a volume of a storage or
|
||||
distribution medium, does not as a whole count as a Modified Version
|
||||
of the Document, provided no compilation copyright is claimed for the
|
||||
compilation. Such a compilation is called an ``aggregate'', and this
|
||||
License does not apply to the other self-contained works thus compiled
|
||||
with the Document, on account of their being thus compiled, if they
|
||||
are not themselves derivative works of the Document.
|
||||
distribution medium, is called an ``aggregate'' if the copyright
|
||||
resulting from the compilation is not used to limit the legal rights
|
||||
of the compilation's users beyond what the individual works permit.
|
||||
When the Document is included in an aggregate, this License does not
|
||||
apply to the other works in the aggregate which are not themselves
|
||||
derivative works of the Document.
|
||||
|
||||
If the Cover Text requirement of section 3 is applicable to these
|
||||
copies of the Document, then if the Document is less than one quarter
|
||||
of the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that surround only the Document within the aggregate.
|
||||
Otherwise they must appear on covers around the whole aggregate.
|
||||
copies of the Document, then if the Document is less than one half of
|
||||
the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that bracket the Document within the aggregate, or the
|
||||
electronic equivalent of covers if the Document is in electronic form.
|
||||
Otherwise they must appear on printed covers that bracket the whole
|
||||
aggregate.
|
||||
|
||||
@item
|
||||
TRANSLATION
|
||||
@@ -331,10 +365,17 @@ Replacing Invariant Sections with translations requires special
|
||||
permission from their copyright holders, but you may include
|
||||
translations of some or all Invariant Sections in addition to the
|
||||
original versions of these Invariant Sections. You may include a
|
||||
translation of this License provided that you also include the
|
||||
original English version of this License. In case of a disagreement
|
||||
between the translation and the original English version of this
|
||||
License, the original English version will prevail.
|
||||
translation of this License, and all the license notices in the
|
||||
Document, and any Warranty Disclaimers, provided that you also include
|
||||
the original English version of this License and the original versions
|
||||
of those notices and disclaimers. In case of a disagreement between
|
||||
the translation and the original version of this License or a notice
|
||||
or disclaimer, the original version will prevail.
|
||||
|
||||
If a section in the Document is Entitled ``Acknowledgements'',
|
||||
``Dedications'', or ``History'', the requirement (section 4) to Preserve
|
||||
its Title (section 1) will typically require changing the actual
|
||||
title.
|
||||
|
||||
@item
|
||||
TERMINATION
|
||||
@@ -377,19 +418,28 @@ license notices just after the title page:
|
||||
@group
|
||||
Copyright (C) @var{year} @var{your name}.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1
|
||||
under the terms of the GNU Free Documentation License, Version 1.2
|
||||
or any later version published by the Free Software Foundation;
|
||||
with the Invariant Sections being @var{list their titles}, with the
|
||||
Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}.
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled ``GNU
|
||||
Free Documentation License''.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have no Invariant Sections, write ``with no Invariant Sections''
|
||||
instead of saying which ones are invariant. If you have no
|
||||
Front-Cover Texts, write ``no Front-Cover Texts'' instead of
|
||||
``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts.
|
||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||
replace the ``with...Texts.'' line with this:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
with the Invariant Sections being @var{list their titles}, with
|
||||
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
|
||||
being @var{list}.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have Invariant Sections without Cover Texts, or some other
|
||||
combination of the three, merge those two alternatives to suit the
|
||||
situation.
|
||||
|
||||
If your document contains nontrivial examples of program code, we
|
||||
recommend releasing these examples in parallel under your choice of
|
||||
@@ -399,3 +449,4 @@ to permit their use in free software.
|
||||
@c Local Variables:
|
||||
@c ispell-local-pdict: "ispell-dict"
|
||||
@c End:
|
||||
|
||||
|
||||
+52
-2
@@ -1,5 +1,55 @@
|
||||
*_.c
|
||||
.deps
|
||||
Makefile
|
||||
ansi2knr ansi2knr.*
|
||||
Makefile.in
|
||||
alloca.c
|
||||
alloca.h
|
||||
alloca_.h
|
||||
argmatch.c
|
||||
argmatch.h
|
||||
basename.c
|
||||
dirname.c
|
||||
dirname.h
|
||||
error.c
|
||||
error.h
|
||||
exit.h
|
||||
exitfail.c
|
||||
exitfail.h
|
||||
getopt.c
|
||||
getopt.h
|
||||
getopt1.c
|
||||
getopt_.h
|
||||
getopt_int.h
|
||||
gettext.h
|
||||
gnulib.mk
|
||||
hard-locale.c
|
||||
hard-locale.h
|
||||
hash.c
|
||||
hash.h
|
||||
malloc.c
|
||||
mbswidth.c
|
||||
mbswidth.h
|
||||
obstack.c
|
||||
obstack.h
|
||||
quote.c
|
||||
quote.h
|
||||
quotearg.c
|
||||
quotearg.h
|
||||
realloc.c
|
||||
stdbool.h
|
||||
stdbool_.h
|
||||
stpcpy.c
|
||||
stpcpy.h
|
||||
strdup.c
|
||||
strdup.h
|
||||
stripslash.c
|
||||
strncasecmp.c
|
||||
strndup.c
|
||||
strndup.h
|
||||
strnlen.c
|
||||
unlocked-io.h
|
||||
xalloc-die.c
|
||||
xalloc.h
|
||||
xmalloc.c
|
||||
xstrdup.c
|
||||
xstrndup.c
|
||||
xstrndup.h
|
||||
|
||||
+28
-28
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -15,39 +15,39 @@
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
AUTOMAKE_OPTIONS = ansi2knr
|
||||
AM_CFLAGS = $(WARNING_CFLAGS)
|
||||
|
||||
CFLAGS = @CFLAGS@ $(WARNING_CFLAGS)
|
||||
BUILT_SOURCES =
|
||||
EXTRA_DIST =
|
||||
MOSTLYCLEANFILES =
|
||||
|
||||
lib_LIBRARIES = $(YACC_LIBRARY)
|
||||
EXTRA_LIBRARIES = liby.a
|
||||
noinst_LIBRARIES = libbison.a
|
||||
|
||||
# libintl.h in is build/intl, libgettext.h in src/intl/,
|
||||
# config.h in build/., and system.h is in src/src/.
|
||||
INCLUDES = -I$(top_builddir)/intl \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/intl \
|
||||
-I$(top_srcdir)/lib
|
||||
liby_a_SOURCES = main.c yyerror.c
|
||||
|
||||
# Heck, we are still using an old version of Automake which does not
|
||||
# understand inner AC_LIBOBJ (i.e., from Autoconf itself, not from
|
||||
# configure.in).
|
||||
EXTRA_DIST = malloc.c realloc.c strnlen.c
|
||||
|
||||
libbison_a_SOURCES = \
|
||||
gettext.h \
|
||||
basename.c dirname.h dirname.c \
|
||||
getopt.h getopt.c getopt1.c \
|
||||
hash.h hash.c \
|
||||
quote.h quote.c quotearg.h quotearg.c \
|
||||
xalloc.h xmalloc.c xstrdup.c xstrndup.c \
|
||||
readpipe.c
|
||||
libbison_a_SOURCES = $(lib_SOURCES)
|
||||
lib_SOURCES = \
|
||||
get-errno.h get-errno.c \
|
||||
subpipe.h subpipe.c \
|
||||
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
||||
|
||||
# Implementation of bitsets
|
||||
libbison_a_SOURCES += \
|
||||
bbitset.h \
|
||||
bitset-int.h bitset.h bitsetv.h ebitset.h lbitset.h sbitset.h \
|
||||
bitset.c bitsetv.c ebitset.c lbitset.c sbitset.c
|
||||
bitsets_sources = \
|
||||
abitset.c abitset.h bbitset.h bitset.c bitset.h bitset_stats.c \
|
||||
bitset_stats.h bitsetv.c bitsetv.h ebitset.c ebitset.h lbitset.c \
|
||||
lbitset.h libiberty.h vbitset.c vbitset.h
|
||||
|
||||
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
# Additional bitset operations.
|
||||
additional_bitsets_sources = \
|
||||
bitsetv-print.h bitsetv-print.c
|
||||
|
||||
# timevars, stolen from GCC.
|
||||
timevars_sources = \
|
||||
timevar.h timevar.c timevar.def
|
||||
|
||||
libbison_a_LIBADD = $(LIBOBJS) $(ALLOCA)
|
||||
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
||||
|
||||
include gnulib.mk
|
||||
|
||||
+830
@@ -0,0 +1,830 @@
|
||||
/* Array bitsets.
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "abitset.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This file implements fixed size bitsets stored as an array
|
||||
of words. Any unused bits in the last word must be zero. */
|
||||
|
||||
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||
#define ABITSET_WORDS(X) ((X)->a.words)
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
abitset_resize (bitset src ATTRIBUTE_UNUSED,
|
||||
bitset_bindex size ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (BITSET_SIZE_ (src) == size)
|
||||
return size;
|
||||
|
||||
/* These bitsets have a fixed size. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
abitset_small_list (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
bitset_word word;
|
||||
|
||||
word = ABITSET_WORDS (src)[0];
|
||||
|
||||
/* Short circuit common case. */
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
size = BITSET_SIZE_ (src);
|
||||
bitno = *next;
|
||||
if (bitno >= size)
|
||||
return 0;
|
||||
|
||||
word >>= bitno;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
if (num >= BITSET_WORD_BITS)
|
||||
{
|
||||
for (count = 0; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (count = 0; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
bitno++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
*next = bitno;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
static void
|
||||
abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* This should never occur for abitsets since we should always hit
|
||||
the cache. It is likely someone is trying to access outside the
|
||||
bounds of the bitset. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
static void
|
||||
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* This should never occur for abitsets since we should always hit
|
||||
the cache. It is likely someone is trying to access outside the
|
||||
bounds of the bitset. Since the bit is zero anyway, let it pass. */
|
||||
}
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static bool
|
||||
abitset_test (bitset src ATTRIBUTE_UNUSED,
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* This should never occur for abitsets since we should always
|
||||
hit the cache. */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET in reverse order, starting
|
||||
from and including NEXT and store in array LIST. Return with
|
||||
actual number of bits found and with *NEXT indicating where search
|
||||
stopped. */
|
||||
static bitset_bindex
|
||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex rbitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
unsigned int bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
||||
|
||||
rbitno = *next;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
|
||||
do
|
||||
{
|
||||
bitset_word word;
|
||||
|
||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
for (; word; bitcnt--)
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
{
|
||||
list[count++] = bitoff + bitcnt;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = n_bits - (bitoff + bitcnt);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word <<= 1;
|
||||
}
|
||||
bitoff -= BITSET_WORD_BITS;
|
||||
bitcnt = BITSET_WORD_BITS - 1;
|
||||
}
|
||||
while (windex--);
|
||||
|
||||
*next = n_bits - (bitoff + 1);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static bitset_bindex
|
||||
abitset_list (bitset src, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_windex size = src->b.csize;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word word;
|
||||
|
||||
bitno = *next;
|
||||
|
||||
count = 0;
|
||||
if (!bitno)
|
||||
{
|
||||
/* Many bitsets are zero, so make this common case fast. */
|
||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||
continue;
|
||||
if (windex >= size)
|
||||
return 0;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the current word. */
|
||||
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bitno >= BITSET_SIZE_ (src))
|
||||
return 0;
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitno = bitno % BITSET_WORD_BITS;
|
||||
|
||||
if (bitno)
|
||||
{
|
||||
/* Handle the case where we start within a word.
|
||||
Most often, this is executed with large bitsets
|
||||
with many set bits where we filled the array
|
||||
on the previous call to this function. */
|
||||
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
word = srcp[windex] >> bitno;
|
||||
for (bitno = bitoff + bitno; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = bitno + 1;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
windex++;
|
||||
}
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
}
|
||||
|
||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||
{
|
||||
if (!(word = srcp[windex]))
|
||||
continue;
|
||||
|
||||
if ((count + BITSET_WORD_BITS) < num)
|
||||
{
|
||||
for (bitno = bitoff; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (bitno = bitoff; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = bitno + 1;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*next = bitoff;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure that any unused bits within the last word are clear. */
|
||||
static inline void
|
||||
abitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned int last_bit;
|
||||
|
||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
((bitset_word) 1 << last_bit) - 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_ones (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
size_t bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
|
||||
memset (dstp, -1, bytes);
|
||||
abitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_zero (bitset dst)
|
||||
{
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
size_t bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
|
||||
memset (dstp, 0, bytes);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_empty_p (bitset dst)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
|
||||
for (i = 0; i < dst->b.csize; i++)
|
||||
if (dstp[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_copy1 (bitset dst, bitset src)
|
||||
{
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
if (srcp == dstp)
|
||||
return;
|
||||
memcpy (dstp, srcp, sizeof (bitset_word) * size);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_not (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
abitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_and (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ & ~(*src2p++);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_or (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ | *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ | *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = *src1p++ ^ *src2p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
abitset_copy (bitset dst, bitset src)
|
||||
{
|
||||
if (BITSET_COMPATIBLE_ (dst, src))
|
||||
abitset_copy1 (dst, src);
|
||||
else
|
||||
bitset_copy_ (dst, src);
|
||||
}
|
||||
|
||||
|
||||
/* Vector of operations for single word bitsets. */
|
||||
struct bitset_vtable abitset_small_vtable = {
|
||||
abitset_set,
|
||||
abitset_reset,
|
||||
bitset_toggle_,
|
||||
abitset_test,
|
||||
abitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
abitset_empty_p,
|
||||
abitset_ones,
|
||||
abitset_zero,
|
||||
abitset_copy,
|
||||
abitset_disjoint_p,
|
||||
abitset_equal_p,
|
||||
abitset_not,
|
||||
abitset_subset_p,
|
||||
abitset_and,
|
||||
abitset_and_cmp,
|
||||
abitset_andn,
|
||||
abitset_andn_cmp,
|
||||
abitset_or,
|
||||
abitset_or_cmp,
|
||||
abitset_xor,
|
||||
abitset_xor_cmp,
|
||||
abitset_and_or,
|
||||
abitset_and_or_cmp,
|
||||
abitset_andn_or,
|
||||
abitset_andn_or_cmp,
|
||||
abitset_or_and,
|
||||
abitset_or_and_cmp,
|
||||
abitset_small_list,
|
||||
abitset_list_reverse,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
/* Vector of operations for multiple word bitsets. */
|
||||
struct bitset_vtable abitset_vtable = {
|
||||
abitset_set,
|
||||
abitset_reset,
|
||||
bitset_toggle_,
|
||||
abitset_test,
|
||||
abitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
abitset_empty_p,
|
||||
abitset_ones,
|
||||
abitset_zero,
|
||||
abitset_copy,
|
||||
abitset_disjoint_p,
|
||||
abitset_equal_p,
|
||||
abitset_not,
|
||||
abitset_subset_p,
|
||||
abitset_and,
|
||||
abitset_and_cmp,
|
||||
abitset_andn,
|
||||
abitset_andn_cmp,
|
||||
abitset_or,
|
||||
abitset_or_cmp,
|
||||
abitset_xor,
|
||||
abitset_xor_cmp,
|
||||
abitset_and_or,
|
||||
abitset_and_or_cmp,
|
||||
abitset_andn_or,
|
||||
abitset_andn_or_cmp,
|
||||
abitset_or_and,
|
||||
abitset_or_and_cmp,
|
||||
abitset_list,
|
||||
abitset_list_reverse,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
size_t
|
||||
abitset_bytes (bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex size;
|
||||
size_t bytes;
|
||||
size_t header_size = offsetof (union bitset_union, a.words);
|
||||
struct bitset_align_struct { char a; union bitset_union b; };
|
||||
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
||||
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
bytes = header_size + size * sizeof (bitset_word);
|
||||
|
||||
/* Align the size properly for a vector of abitset objects. */
|
||||
if (header_size % bitset_alignment != 0
|
||||
|| sizeof (bitset_word) % bitset_alignment != 0)
|
||||
{
|
||||
bytes += bitset_alignment - 1;
|
||||
bytes -= bytes % bitset_alignment;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
abitset_init (bitset bset, bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
BITSET_NBITS_ (bset) = n_bits;
|
||||
|
||||
/* Use optimized routines if bitset fits within a single word.
|
||||
There is probably little merit if using caching since
|
||||
the small bitset will always fit in the cache. */
|
||||
if (size == 1)
|
||||
bset->b.vtable = &abitset_small_vtable;
|
||||
else
|
||||
bset->b.vtable = &abitset_vtable;
|
||||
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = size;
|
||||
bset->b.cdata = ABITSET_WORDS (bset);
|
||||
return bset;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Functions to support sbitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
/* Functions to support abitsets.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -16,13 +16,13 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _SBITSET_H
|
||||
#define _SBITSET_H
|
||||
#ifndef _ABITSET_H
|
||||
#define _ABITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "bitset.h"
|
||||
|
||||
extern int sbitset_bytes PARAMS ((bitset_bindex));
|
||||
extern size_t abitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset sbitset_init PARAMS ((bitset, bitset_bindex));
|
||||
extern bitset abitset_init (bitset, bitset_bindex);
|
||||
|
||||
#endif
|
||||
-504
@@ -1,504 +0,0 @@
|
||||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
(Mostly) portable public-domain implementation -- D A Gwyn
|
||||
|
||||
This implementation of the PWB library alloca function,
|
||||
which is used to allocate space off the run-time stack so
|
||||
that it is automatically reclaimed upon procedure exit,
|
||||
was inspired by discussions with J. Q. Johnson of Cornell.
|
||||
J.Otto Tennant <[email protected]> contributed the Cray support.
|
||||
|
||||
There are some preprocessor constants that can
|
||||
be defined when compiling for your specific system, for
|
||||
improved efficiency; however, the defaults should be okay.
|
||||
|
||||
The general concept of this implementation is to keep
|
||||
track of all alloca-allocated blocks, and reclaim any
|
||||
that are found to be deeper in the stack than the current
|
||||
invocation. This heuristic does not reclaim storage as
|
||||
soon as it becomes invalid, but it will do so eventually.
|
||||
|
||||
As a special case, alloca(0) reclaims storage without
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef emacs
|
||||
# include "blockinput.h"
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. */
|
||||
#if !defined (__GNUC__) || __GNUC__ < 2
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
# ifndef alloca
|
||||
|
||||
# ifdef emacs
|
||||
# ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
# ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
# endif /* STACK_DIRECTION undefined */
|
||||
# endif /* static */
|
||||
# endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
# else
|
||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||
# endif
|
||||
|
||||
# if __STDC__
|
||||
typedef void *pointer;
|
||||
# else
|
||||
typedef char *pointer;
|
||||
# endif
|
||||
|
||||
# ifndef NULL
|
||||
# define NULL 0
|
||||
# endif
|
||||
|
||||
/* Different portions of Emacs need to call different versions of
|
||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
||||
ordinary malloc isn't protected from input signals. On the other
|
||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
||||
them are very simple, and don't have an xmalloc routine.
|
||||
|
||||
Non-Emacs programs expect this to call xmalloc.
|
||||
|
||||
Callers below should use malloc. */
|
||||
|
||||
# ifndef emacs
|
||||
# undef malloc
|
||||
# define malloc xmalloc
|
||||
# endif
|
||||
extern pointer malloc ();
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
deduced at run-time.
|
||||
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
# ifndef STACK_DIRECTION
|
||||
# define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
# endif
|
||||
|
||||
# if STACK_DIRECTION != 0
|
||||
|
||||
# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
# else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
# define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction ()
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
# endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
(b) keep track of stack depth.
|
||||
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
# ifndef ALIGN_SIZE
|
||||
# define ALIGN_SIZE sizeof(double)
|
||||
# endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
the procedure that called alloca. Originally, this space
|
||||
was supposed to be taken from the current stack frame of the
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
pointer
|
||||
alloca (size_t size)
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
# if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
# endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
# ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
# endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free ((pointer) hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
# ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
register pointer new = malloc (sizeof (header) + size);
|
||||
/* Address of header. */
|
||||
|
||||
if (new == 0)
|
||||
abort();
|
||||
|
||||
((header *) new)->h.next = last_alloca_header;
|
||||
((header *) new)->h.deep = depth;
|
||||
|
||||
last_alloca_header = (header *) new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (pointer) ((char *) new + sizeof (header));
|
||||
}
|
||||
}
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
# ifndef CRAY_STACK
|
||||
# define CRAY_STACK
|
||||
# ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
part of the stack segment linkage control information is
|
||||
0200 (octal) words. This provides for register storage
|
||||
for the routine which overflows the stack. */
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
long ssa3;
|
||||
long ssa4;
|
||||
long ssa5;
|
||||
long ssa6;
|
||||
long ssa7;
|
||||
long sss0;
|
||||
long sss1;
|
||||
long sss2;
|
||||
long sss3;
|
||||
long sss4;
|
||||
long sss5;
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
# else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
long unknown8;
|
||||
long unknown9;
|
||||
long unknown10;
|
||||
long unknown11;
|
||||
long unknown12;
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
# endif /* CRAY2 */
|
||||
# endif /* not CRAY_STACK */
|
||||
|
||||
# ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long
|
||||
i00afunc (long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
|
||||
STKSTAT (&status);
|
||||
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort ();
|
||||
|
||||
/* Discard segments that do not contain our argument address. */
|
||||
|
||||
while (trailer != 0)
|
||||
{
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
# else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long
|
||||
i00afunc (long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
long size, pseg, this_segment, stack;
|
||||
long result = 0;
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END ();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
# endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
this_segment = stkl - size;
|
||||
}
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
# endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
result += size;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
# endif /* not CRAY2 */
|
||||
# endif /* CRAY */
|
||||
|
||||
# endif /* no alloca */
|
||||
#endif /* not GCC version 2 */
|
||||
@@ -1,71 +0,0 @@
|
||||
/* basename.c -- return the last element in a path
|
||||
Copyright (C) 1990, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
char *base_name PARAMS ((char const *name));
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
If NAME is all slashes, be sure to return `/'. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
int all_slashes = 1;
|
||||
char const *p;
|
||||
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
base = p + 1;
|
||||
else
|
||||
all_slashes = 0;
|
||||
}
|
||||
|
||||
/* If NAME is all slashes, arrange to return `/'. */
|
||||
if (*base == '\0' && ISSLASH (*name) && all_slashes)
|
||||
--base;
|
||||
|
||||
/* Make sure the last byte is not a slash. */
|
||||
assert (all_slashes || !ISSLASH (*(p - 1)));
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
+223
-196
@@ -1,5 +1,5 @@
|
||||
/* Base bitset stuff.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,83 +19,59 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#ifndef _BBITSET_H
|
||||
#define _BBITSET_H
|
||||
|
||||
/* Bison modifications: BEGIN. */
|
||||
#define IN_BISON 1
|
||||
#if IN_BISON
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
#include "libiberty.h"
|
||||
|
||||
# define BITSET_STATS 1
|
||||
/* This file is the public interface to the bitset abstract data type.
|
||||
Only use the functions and macros defined in this file. */
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# endif
|
||||
# include "xalloc.h"
|
||||
#else /* ! IN_BISON */
|
||||
# include "libiberty.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
/* Currently we support three flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, faster).
|
||||
BITSET_LIST: Linked list of array of bits (variable size, least storage
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
/* Currently we support five flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
|
||||
Memory for bit array and bitset structure allocated
|
||||
contiguously.
|
||||
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to arrays of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
Faster than BITSET_LIST for random access.
|
||||
BITSET_VARRAY: Variable array of bits (variable size, fast for
|
||||
dense bitsets).
|
||||
BITSET_STATS: Wrapper bitset for internal use only. Used for gathering
|
||||
statistics and/or better run-time checking.
|
||||
*/
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM};
|
||||
#define BITSET_TYPE_NAMES {"sbitset", "lbitset", "ebitset"}
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
|
||||
BITSET_TYPE_NUM, BITSET_STATS};
|
||||
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
|
||||
|
||||
/* Non-zero to enable bitset caching. */
|
||||
#define BITSET_CACHE 1
|
||||
extern const char * const bitset_type_names[];
|
||||
|
||||
/* Non-zero to use inline functions instead of macros. */
|
||||
#define BITSET_INLINE 0
|
||||
|
||||
/* Non-zero to enable bitset statistics gathering. */
|
||||
#define BITSET_STATS 1
|
||||
|
||||
/* Non-zero to enable bitset type checking. */
|
||||
#define BITSET_CHECK 1
|
||||
enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
|
||||
|
||||
/* Data type used to store a word of bits. */
|
||||
typedef unsigned long bitset_word;
|
||||
#define BITSET_WORD_BITS ((unsigned) CHAR_BIT * sizeof (bitset_word))
|
||||
typedef unsigned long int bitset_word;
|
||||
#define BITSET_WORD_BITS ((unsigned int) (CHAR_BIT * sizeof (bitset_word)))
|
||||
|
||||
/* Bit index. */
|
||||
typedef unsigned long bitset_bindex;
|
||||
/* Bit index. In theory we might need a type wider than size_t, but
|
||||
in practice we lose at most a factor of CHAR_BIT by going with
|
||||
size_t, and that is good enough. If this type is changed to be
|
||||
wider than size_t, the code needs to be modified to check for
|
||||
overflow when converting bit counts to byte or word counts.
|
||||
The bit and word index types must be unsigned. */
|
||||
typedef size_t bitset_bindex;
|
||||
|
||||
/* Word index. */
|
||||
typedef unsigned long bitset_windex;
|
||||
typedef size_t bitset_windex;
|
||||
|
||||
#define BITSET_INDEX_MAX ((1U << (BITSET_WORD_BITS - 1)))
|
||||
/* Maximum values for commonly-used unsigned types. BITSET_SIZE_MAX
|
||||
always equals SIZE_MAX, but some older systems lack SIZE_MAX. */
|
||||
#define BITSET_BINDEX_MAX ((bitset_bindex) -1)
|
||||
|
||||
#define BITSET_MSB (1U << (BITSET_WORD_BITS - 1))
|
||||
/* Limit max word index to the maximum value of a signed integer
|
||||
to simplify cache disabling. */
|
||||
#define BITSET_WINDEX_MAX (((bitset_windex) -1) >> 1)
|
||||
#define BITSET_SIZE_MAX ((size_t) -1)
|
||||
|
||||
#define BITSET_MSB ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
|
||||
|
||||
#define BITSET_LIST_SIZE 1024
|
||||
|
||||
@@ -106,114 +82,13 @@ enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
||||
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET_SIZE_(SRC) (SRC)->b.ops->size (SRC)
|
||||
|
||||
/* Return type of bitset SRC. */
|
||||
#define BITSET_TYPE_(DST) (DST)->b.ops->type
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
#define BITSET_SET_(DST, BITNO) (DST)->b.ops->set (DST, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
#define BITSET_RESET_(DST, BITNO) (DST)->b.ops->reset (DST, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define BITSET_TEST_(SRC, BITNO) (SRC)->b.ops->test (SRC, BITNO)
|
||||
|
||||
/* Free bitset SRC. */
|
||||
#define BITSET_FREE_(SRC)\
|
||||
((SRC)->b.ops->free ? (SRC)->b.ops->free (SRC) :(void)0)
|
||||
|
||||
/* Perform operation OP on DST. */
|
||||
#define BITSET_OP1_(DST, OP) (DST)->b.ops->op1 (DST, OP)
|
||||
|
||||
/* Perform operation OP on SRC and store in DST. */
|
||||
#define BITSET_OP2_(DST, SRC, OP) (DST)->b.ops->op2 (DST, SRC, OP)
|
||||
|
||||
/* DST = SRC1 OP SRC2. */
|
||||
#define BITSET_OP3_(DST, SRC1, SRC2, OP) \
|
||||
(DST)->b.ops->op3 (DST, SRC1, SRC2, OP)
|
||||
|
||||
/* DST = (SRC1 OP1 SRC2) OP2 SRC3. */
|
||||
#define BITSET_OP4_(DST, SRC1, SRC2, SRC3, OP) \
|
||||
(DST)->b.ops->op4 (DST, SRC1, SRC2, SRC3, OP)
|
||||
|
||||
/* DST = 0. */
|
||||
#define BITSET_ZERO_(DST) BITSET_OP1_ (DST, BITSET_OP_ZERO);
|
||||
|
||||
/* DST = ~0. */
|
||||
#define BITSET_ONES_(DST) BITSET_OP1_ (DST, BITSET_OP_ONES);
|
||||
|
||||
/* Return SRC == 0. */
|
||||
#define BITSET_EMPTY_P_(SRC) BITSET_OP1_ (SRC, BITSET_OP_EMPTY_P);
|
||||
|
||||
/* Return DST == SRC. */
|
||||
#define BITSET_EQUAL_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_EQUAL_P)
|
||||
|
||||
/* Return DST == DST | SRC. */
|
||||
#define BITSET_SUBSET_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_SUBSET_P)
|
||||
|
||||
/* Return DST & SRC == 0. */
|
||||
#define BITSET_DISJOINT_P_(DST, SRC)\
|
||||
BITSET_OP2_ (DST, SRC, BITSET_OP_DISJOINT_P)
|
||||
|
||||
/* DST = SRC. */
|
||||
#define BITSET_COPY_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_COPY)
|
||||
|
||||
/* DST = ~SRC. */
|
||||
#define BITSET_NOT_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_NOT)
|
||||
|
||||
/* DST = SRC1 | SRC2. */
|
||||
#define BITSET_OR_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2,\
|
||||
BITSET_OP_OR)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. */
|
||||
#define BITSET_XOR_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2,\
|
||||
BITSET_OP_XOR)
|
||||
|
||||
/* DST = SRC1 & SRC2. */
|
||||
#define BITSET_AND_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2, \
|
||||
BITSET_OP_AND)
|
||||
|
||||
/* DST = SRC1 & ~SRC2. */
|
||||
#define BITSET_ANDN_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2, \
|
||||
BITSET_OP_ANDN)
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & SRC2) | SRC3. */
|
||||
#define BITSET_AND_OR_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_AND_OR)
|
||||
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
#define BITSET_OR_AND_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_OR_AND)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||
#define BITSET_ANDN_OR_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_ANDN_OR)
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#define BITSET_LIST_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.ops->list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define BITSET_REVERSE_LIST_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.ops->reverse_list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
|
||||
struct bbitset_struct
|
||||
{
|
||||
struct bitset_ops_struct *ops;
|
||||
const struct bitset_vtable *vtable;
|
||||
bitset_windex cindex; /* Cache word index. */
|
||||
bitset_windex csize; /* Cache size in words. */
|
||||
bitset_word *cdata; /* Cache data pointer. */
|
||||
bitset_bindex n_bits; /* Number of bits. */
|
||||
/* Perhaps we could sacrifice another word to indicate
|
||||
that the bitset is known to be zero, that a bit has been set
|
||||
in the cache, and that a bit has been cleared in the cache.
|
||||
@@ -222,35 +97,65 @@ struct bbitset_struct
|
||||
};
|
||||
|
||||
|
||||
typedef struct bitset_struct *bitset;
|
||||
typedef union bitset_union *bitset;
|
||||
|
||||
|
||||
/* Private accessor macros to bitset structure. */
|
||||
#define BITSET_VTABLE_(SRC) (SRC)->b.vtable
|
||||
#define BITSET_CINDEX_(SRC) (SRC)->b.cindex
|
||||
#define BITSET_CDATA_(SRC) (SRC)->b.cdata
|
||||
#define BITSET_CSIZE_(SRC) (SRC)->b.csize
|
||||
#define BITSET_NBITS_(SRC) (SRC)->b.n_bits
|
||||
|
||||
|
||||
/* The contents of this structure should be considered private. */
|
||||
struct bitset_ops_struct
|
||||
struct bitset_vtable
|
||||
{
|
||||
void (*set) PARAMS ((struct bitset_struct *, bitset_bindex));
|
||||
void (*reset) PARAMS ((struct bitset_struct *, bitset_bindex));
|
||||
int (*test) PARAMS ((struct bitset_struct *, bitset_bindex));
|
||||
int (*size) PARAMS ((struct bitset_struct *));
|
||||
int (*op1) PARAMS ((struct bitset_struct *, enum bitset_ops));
|
||||
int (*op2) PARAMS ((struct bitset_struct *, struct bitset_struct *,
|
||||
enum bitset_ops));
|
||||
int (*op3) PARAMS ((struct bitset_struct *, struct bitset_struct *,
|
||||
struct bitset_struct *, enum bitset_ops));
|
||||
int (*op4) PARAMS ((struct bitset_struct *, struct bitset_struct *,
|
||||
struct bitset_struct *, struct bitset_struct *,
|
||||
enum bitset_ops));
|
||||
int (*list) PARAMS ((struct bitset_struct *, bitset_bindex *,
|
||||
bitset_bindex, bitset_bindex *));
|
||||
int (*reverse_list) PARAMS ((struct bitset_struct *, bitset_bindex *,
|
||||
bitset_bindex, bitset_bindex *));
|
||||
void (*free) PARAMS ((struct bitset_struct *));
|
||||
void (*set) (bitset, bitset_bindex);
|
||||
void (*reset) (bitset, bitset_bindex);
|
||||
bool (*toggle) (bitset, bitset_bindex);
|
||||
bool (*test) (bitset, bitset_bindex);
|
||||
bitset_bindex (*resize) (bitset, bitset_bindex);
|
||||
bitset_bindex (*size) (bitset);
|
||||
bitset_bindex (*count) (bitset);
|
||||
|
||||
bool (*empty_p) (bitset);
|
||||
void (*ones) (bitset);
|
||||
void (*zero) (bitset);
|
||||
|
||||
void (*copy) (bitset, bitset);
|
||||
bool (*disjoint_p) (bitset, bitset);
|
||||
bool (*equal_p) (bitset, bitset);
|
||||
void (*not) (bitset, bitset);
|
||||
bool (*subset_p) (bitset, bitset);
|
||||
|
||||
void (*and) (bitset, bitset, bitset);
|
||||
bool (*and_cmp) (bitset, bitset, bitset);
|
||||
void (*andn) (bitset, bitset, bitset);
|
||||
bool (*andn_cmp) (bitset, bitset, bitset);
|
||||
void (*or) (bitset, bitset, bitset);
|
||||
bool (*or_cmp) (bitset, bitset, bitset);
|
||||
void (*xor) (bitset, bitset, bitset);
|
||||
bool (*xor_cmp) (bitset, bitset, bitset);
|
||||
|
||||
void (*and_or) (bitset, bitset, bitset, bitset);
|
||||
bool (*and_or_cmp) (bitset, bitset, bitset, bitset);
|
||||
void (*andn_or) (bitset, bitset, bitset, bitset);
|
||||
bool (*andn_or_cmp) (bitset, bitset, bitset, bitset);
|
||||
void (*or_and) (bitset, bitset, bitset, bitset);
|
||||
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
|
||||
|
||||
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *);
|
||||
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *);
|
||||
void (*free) (bitset);
|
||||
enum bitset_type type;
|
||||
};
|
||||
|
||||
#define BITSET_COMPATIBLE_(BSET1, BSET2) ((BSET1)->b.ops == (BSET2)->b.ops)
|
||||
#define BITSET_COMPATIBLE_(BSET1, BSET2) \
|
||||
((BSET1)->b.vtable == (BSET2)->b.vtable)
|
||||
|
||||
#if BITSET_CHECK
|
||||
#define BITSET_CHECK2_(DST, SRC) \
|
||||
if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
|
||||
|
||||
@@ -261,15 +166,137 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) \
|
||||
#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3) \
|
||||
if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||
|| !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
|
||||
#else
|
||||
#define BITSET_CHECK2_(DST, SRC)
|
||||
|
||||
#define BITSET_CHECK3_(DST, SRC1, SRC2)
|
||||
|
||||
#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3)
|
||||
#endif
|
||||
/* Redefine number of bits in bitset DST. */
|
||||
#define BITSET_RESIZE_(DST, SIZE) (DST)->b.vtable->resize (DST, SIZE)
|
||||
|
||||
extern int bitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
enum bitset_ops op));
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET_SIZE_(SRC) (SRC)->b.vtable->size (SRC)
|
||||
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
#define BITSET_COUNT_(SRC) (SRC)->b.vtable->count (SRC)
|
||||
|
||||
/* Return type of bitset SRC. */
|
||||
#define BITSET_TYPE_(DST) (DST)->b.vtable->type
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
#define BITSET_SET_(DST, BITNO) (DST)->b.vtable->set (DST, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
#define BITSET_RESET_(DST, BITNO) (DST)->b.vtable->reset (DST, BITNO)
|
||||
|
||||
/* Toggle bit BITNO in bitset DST. */
|
||||
#define BITSET_TOGGLE_(DST, BITNO) (DST)->b.vtable->toggle (DST, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define BITSET_TEST_(SRC, BITNO) (SRC)->b.vtable->test (SRC, BITNO)
|
||||
|
||||
/* Free bitset SRC. */
|
||||
#define BITSET_FREE_(SRC)\
|
||||
((SRC)->b.vtable->free ? (SRC)->b.vtable->free (SRC) :(void)0)
|
||||
|
||||
|
||||
/* Return SRC == 0. */
|
||||
#define BITSET_EMPTY_P_(SRC) (SRC)->b.vtable->empty_p (SRC)
|
||||
|
||||
/* DST = ~0. */
|
||||
#define BITSET_ONES_(DST) (DST)->b.vtable->ones (DST)
|
||||
|
||||
/* DST = 0. */
|
||||
#define BITSET_ZERO_(DST) (DST)->b.vtable->zero (DST)
|
||||
|
||||
|
||||
|
||||
/* DST = SRC. */
|
||||
#define BITSET_COPY_(DST, SRC) (SRC)->b.vtable->copy (DST, SRC)
|
||||
|
||||
/* Return DST & SRC == 0. */
|
||||
#define BITSET_DISJOINT_P_(DST, SRC) (SRC)->b.vtable->disjoint_p (DST, SRC)
|
||||
|
||||
/* Return DST == SRC. */
|
||||
#define BITSET_EQUAL_P_(DST, SRC) (SRC)->b.vtable->equal_p (DST, SRC)
|
||||
|
||||
/* DST = ~SRC. */
|
||||
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not (DST, SRC)
|
||||
|
||||
/* Return DST == DST | SRC. */
|
||||
#define BITSET_SUBSET_P_(DST, SRC) (SRC)->b.vtable->subset_p (DST, SRC)
|
||||
|
||||
|
||||
/* DST = SRC1 & SRC2. */
|
||||
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and (DST, SRC1, SRC2)
|
||||
#define BITSET_AND_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_cmp (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 & ~SRC2. */
|
||||
#define BITSET_ANDN_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn (DST, SRC1, SRC2)
|
||||
#define BITSET_ANDN_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn_cmp (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 | SRC2. */
|
||||
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or (DST, SRC1, SRC2)
|
||||
#define BITSET_OR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_cmp (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. */
|
||||
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor (DST, SRC1, SRC2)
|
||||
#define BITSET_XOR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_cmp (DST, SRC1, SRC2)
|
||||
|
||||
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & SRC2) | SRC3. */
|
||||
#define BITSET_AND_OR_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->and_or (DST, SRC1, SRC2, SRC3)
|
||||
#define BITSET_AND_OR_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->and_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||
#define BITSET_ANDN_OR_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->andn_or (DST, SRC1, SRC2, SRC3)
|
||||
#define BITSET_ANDN_OR_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->andn_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
#define BITSET_OR_AND_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->or_and (DST, SRC1, SRC2, SRC3)
|
||||
#define BITSET_OR_AND_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||
(SRC1)->b.vtable->or_and_cmp (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#define BITSET_LIST_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.vtable->list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define BITSET_LIST_REVERSE_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.vtable->list_reverse (BSET, LIST, NUM, NEXT)
|
||||
|
||||
|
||||
/* Private functions for bitset implementations. */
|
||||
|
||||
extern bool bitset_toggle_ (bitset, bitset_bindex);
|
||||
|
||||
extern bitset_bindex bitset_count_ (bitset);
|
||||
|
||||
extern bitset_bindex bitset_size_ (bitset);
|
||||
|
||||
extern bool bitset_copy_ (bitset, bitset);
|
||||
|
||||
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_or_and_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
#endif /* _BBITSET_H */
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/* Internal bitset definitions.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _BITSET_INT_H
|
||||
#define _BITSET_INT_H
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Currently we support three flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, faster).
|
||||
BITSET_LIST: Linked list of array of bits (variable size, least storage
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
*/
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM};
|
||||
#define BITSET__TYPE_NAMES {"sbitset", "lbitset", "ebitset"}
|
||||
|
||||
/* Non-zero to enable bitset caching. */
|
||||
#define BITSET_CACHE 1
|
||||
|
||||
/* Non-zero to use inline functions instead of macros. */
|
||||
#define BITSET_INLINE 0
|
||||
|
||||
/* Non-zero to enable bitset statistics gathering. */
|
||||
#define BITSET_STATS 1
|
||||
|
||||
/* Non-zero to enable bitset type checking. */
|
||||
#define BITSET_CHECK 0
|
||||
|
||||
typedef unsigned long bitset_word;
|
||||
#define BITSET_WORD_BITS ((unsigned) CHAR_BIT * sizeof (bitset_word))
|
||||
|
||||
/* Bit index. */
|
||||
typedef unsigned long bitset_bindex;
|
||||
|
||||
/* Word index. */
|
||||
typedef unsigned long bitset_windex;
|
||||
|
||||
#define BITSET_INDEX_MAX ((1U << (BITSET_WORD_BITS - 1)))
|
||||
|
||||
#define BITSET_MSB (1U << (BITSET_WORD_BITS - 1))
|
||||
|
||||
#define BITSET_LIST_SIZE 1024
|
||||
|
||||
enum bitset_ops {BITSET_ZERO, BITSET_ONES, BITSET_EMPTY_P,
|
||||
BITSET_COPY, BITSET_EQUAL_P, BITSET_SUBSET_P, BITSET_NOT,
|
||||
BITSET_AND, BITSET_OR, BITSET_XOR, BITSET_ANDN, BITSET_ORN,
|
||||
BITSET_OR_AND, BITSET_AND_OR, BITSET_ANDN_OR};
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET__SIZE(SRC) (SRC)->ops->size (SRC)
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
#define BITSET__SET(DST, BITNO) (DST)->ops->set (DST, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
#define BITSET__RESET(DST, BITNO) (DST)->ops->reset (DST, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define BITSET__TEST(SRC, BITNO) (SRC)->ops->test (SRC, BITNO)
|
||||
|
||||
/* Free bitset SRC. */
|
||||
#define BITSET__FREE(SRC) ((SRC)->ops->free) (SRC)
|
||||
|
||||
/* Perform operation OP on DST. */
|
||||
#define BITSET__OP1(DST, OP) (DST)->ops->op1 (DST, OP)
|
||||
|
||||
/* Perform operation OP on SRC and store in DST. */
|
||||
#define BITSET__OP2(DST, SRC, OP) (DST)->ops->op2 (DST, SRC, OP)
|
||||
|
||||
/* DST = SRC1 OP SRC2. */
|
||||
#define BITSET__OP3(DST, SRC1, SRC2, OP) \
|
||||
(DST)->ops->op3 (DST, SRC1, SRC2, OP)
|
||||
|
||||
/* DST = (SRC1 OP1 SRC2) OP2 SRC3. */
|
||||
#define BITSET__OP4(DST, SRC1, SRC2, SRC3, OP) \
|
||||
(DST)->ops->op4 (DST, SRC1, SRC2, SRC3, OP)
|
||||
|
||||
/* DST = SRC. */
|
||||
#define BITSET__COPY(DST, SRC) BITSET__OP2 (DST, SRC, BITSET_COPY)
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#define BITSET__LIST(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->ops->list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define BITSET__REVERSE_LIST(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->ops->reverse_list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
#endif /* _BITSET_INT_H */
|
||||
+221
-652
File diff suppressed because it is too large
Load Diff
+234
-186
@@ -1,5 +1,5 @@
|
||||
/* Generic bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -32,310 +32,358 @@ enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
||||
BITSET_DENSE = 4, /* Bitset dense. */
|
||||
BITSET_SPARSE = 8, /* Bitset sparse. */
|
||||
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
||||
BITSET_GREEDY = 32}; /* Prefer fastest. */
|
||||
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
||||
|
||||
typedef unsigned int bitset_attrs;
|
||||
|
||||
/* The contents of the structure should be considered to be private.
|
||||
While I would like to make this structure opaque, it needs to be
|
||||
visible for the inline bit set/test functions. */
|
||||
struct bitset_struct
|
||||
/* The contents of the union should be considered to be private.
|
||||
While I would like to make this union opaque, it needs to be
|
||||
visible for the inline bit set/test functions, and for delegation
|
||||
to the proper implementation. */
|
||||
union bitset_union
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
/* This must be the first member of every other structure that is a
|
||||
member of this union. */
|
||||
struct bbitset_struct b; /* Base bitset data. */
|
||||
|
||||
struct abitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset_word words[1]; /* The array of bits. */
|
||||
} a;
|
||||
|
||||
struct ebitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset_windex size; /* Number of elements. */
|
||||
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
||||
} e;
|
||||
|
||||
struct lbitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
struct lbitset_elt_struct *head; /* First element in linked list. */
|
||||
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
||||
} l;
|
||||
|
||||
struct bitset_stats_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset bset;
|
||||
} s;
|
||||
|
||||
struct vbitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset_windex size; /* Allocated size of array. */
|
||||
} v;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* The contents of this structure should be considered private.
|
||||
It is used for iterating over set bits. */
|
||||
typedef struct
|
||||
{
|
||||
bitset_bindex list[BITSET_LIST_SIZE];
|
||||
bitset_bindex next;
|
||||
bitset_bindex num;
|
||||
bitset_bindex i;
|
||||
} bitset_iterator;
|
||||
|
||||
|
||||
/* Return bytes required for bitset of desired type and size. */
|
||||
extern int bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
|
||||
extern size_t bitset_bytes (enum bitset_type, bitset_bindex);
|
||||
|
||||
/* Initialise a bitset with desired type and size. */
|
||||
extern bitset bitset_init PARAMS ((bitset, bitset_bindex, enum bitset_type));
|
||||
extern bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Select an implementation type based on the desired bitset size
|
||||
and attributes. */
|
||||
extern enum bitset_type bitset_type_choose PARAMS ((bitset_bindex,
|
||||
bitset_attrs));
|
||||
extern enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
|
||||
|
||||
/* Create a bitset of desired type and size. The bitset is zeroed. */
|
||||
extern bitset bitset_alloc PARAMS ((bitset_bindex, enum bitset_type));
|
||||
extern bitset bitset_alloc (bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Free bitset. */
|
||||
extern void bitset_free PARAMS ((bitset));
|
||||
extern void bitset_free (bitset);
|
||||
|
||||
/* Create a bitset of desired type and size using an obstack. The
|
||||
bitset is zeroed. */
|
||||
extern bitset bitset_obstack_alloc PARAMS ((struct obstack *bobstack,
|
||||
bitset_bindex, enum bitset_type));
|
||||
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||
bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Free bitset allocated on obstack. */
|
||||
extern void bitset_obstack_free PARAMS ((bitset));
|
||||
extern void bitset_obstack_free (bitset);
|
||||
|
||||
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
|
||||
extern bitset bitset_create PARAMS ((bitset_bindex, bitset_attrs));
|
||||
extern bitset bitset_create (bitset_bindex, bitset_attrs);
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
extern int bitset_size PARAMS ((bitset));
|
||||
/* Return bitset type. */
|
||||
extern enum bitset_type bitset_type_get (bitset);
|
||||
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
extern int bitset_count PARAMS ((bitset));
|
||||
/* Return bitset type name. */
|
||||
extern const char *bitset_type_name_get (bitset);
|
||||
|
||||
#if BITSET_CACHE && BITSET_INLINE
|
||||
static inline void bitset_set PARAMS ((bitset, bitset_bindex));
|
||||
static inline void bitset_reset PARAMS ((bitset, bitset_bindex));
|
||||
static inline int bitset_test PARAMS ((bitset, bitset_bindex));
|
||||
|
||||
/* Set bit BITNO in bitset BSET. */
|
||||
static inline void bitset_set (bset, bitno)
|
||||
bitset bset;
|
||||
bitset_bindex bitno;
|
||||
static inline void
|
||||
bitset_set (bitset bset, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = windex - bset->b.cindex;
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
bset->b.cdata[offset] |= (1 << (bitno % BITSET_WORD_BITS));
|
||||
bset->b.cdata[offset] |= ((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
else
|
||||
BITSET_SET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
/* Reset bit BITNO in bitset BSET. */
|
||||
static inline void bitset_reset (bset, bitno)
|
||||
bitset bset;
|
||||
bitset_bindex bitno;
|
||||
static inline void
|
||||
bitset_reset (bitset bset, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = windex - bset->b.cindex;
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
bset->b.cdata[offset] &= ~(1 << (bitno % BITSET_WORD_BITS));
|
||||
bset->b.cdata[offset] &= ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
else
|
||||
BITSET_RESET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset BSET. */
|
||||
static inline int bitset_test (bset, bitno)
|
||||
bitset bset;
|
||||
bitset_bindex bitno;
|
||||
static inline bool
|
||||
bitset_test (bitset bset, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = windex - bset->b.cindex;
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
else
|
||||
return BITSET_TEST_ (bset, bitno);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BITSET_CACHE && ! BITSET_INLINE
|
||||
|
||||
/* Set bit BITNO in bitset BSET. */
|
||||
#define bitset_set(bset, bitno) \
|
||||
do \
|
||||
{ \
|
||||
bitset_bindex _bitno = (bitno); \
|
||||
bitset_windex _index = _bitno / BITSET_WORD_BITS; \
|
||||
bitset_windex _offset = _index - (bset)->b.cindex; \
|
||||
\
|
||||
if (_offset < (bset)->b.csize) \
|
||||
(bset)->b.cdata[_offset] |= (1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
else \
|
||||
BITSET_SET_ ((bset), _bitno); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Reset bit BITNO in bitset BSET. */
|
||||
#define bitset_reset(bset, bitno) \
|
||||
do \
|
||||
{ \
|
||||
bitset_bindex _bitno = (bitno); \
|
||||
bitset_windex _index = _bitno / BITSET_WORD_BITS; \
|
||||
bitset_windex _offset = _index - (bset)->b.cindex; \
|
||||
\
|
||||
if (_offset < (bset)->b.csize) \
|
||||
(bset)->b.cdata[_offset] &= ~(1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
else \
|
||||
BITSET_RESET_ ((bset), _bitno); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset BSET. */
|
||||
#define bitset_test(bset, bitno) \
|
||||
(((((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex) < (bset)->b.csize) \
|
||||
? ((bset)->b.cdata[(((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex)] \
|
||||
>> ((bitno) % BITSET_WORD_BITS)) & 1 \
|
||||
: (unsigned int) BITSET_TEST_ ((bset), (bitno)))
|
||||
#endif
|
||||
|
||||
#if ! BITSET_CACHE
|
||||
/* Set bit BITNO in bitset SRC. */
|
||||
#define bitset_set(SRC, BITNO) BITSET_SET_ (SRC, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset SRC. */
|
||||
#define bitset_reset(SRC, BITNO) BITSET_RESET_ (SRC, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define bitset_test(SRC, BITNO) BITSET_TEST_ (SRC, BITNO)
|
||||
#endif
|
||||
|
||||
/* Toggle bit BITNO in bitset BSET and return non-zero if now set. */
|
||||
extern int bitset_toggle PARAMS ((bitset, bitset_bindex));
|
||||
#define bitset_toggle(bset, bitno) BITSET_TOGGLE_ (bset, bitno)
|
||||
|
||||
/* DST = 0. */
|
||||
extern int bitset_zero PARAMS ((bitset));
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
|
||||
|
||||
/* Change size of bitset. */
|
||||
extern void bitset_resize (bitset, bitset_bindex);
|
||||
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
|
||||
|
||||
|
||||
/* Return SRC == 0. */
|
||||
#define bitset_empty_p(SRC) BITSET_EMPTY_P_ (SRC)
|
||||
|
||||
/* DST = ~0. */
|
||||
extern int bitset_ones PARAMS ((bitset));
|
||||
#define bitset_ones(DST) BITSET_ONES_ (DST)
|
||||
|
||||
/* Return non-zero if all bits in bitset SRC are reset. */
|
||||
extern int bitset_empty_p PARAMS ((bitset));
|
||||
/* DST = 0. */
|
||||
#define bitset_zero(DST) BITSET_ZERO_ (DST)
|
||||
|
||||
/* Return DST == DST | SRC. */
|
||||
extern int bitset_subset_p PARAMS ((bitset, bitset));
|
||||
|
||||
/* Return DST == SRC. */
|
||||
extern int bitset_equal_p PARAMS ((bitset, bitset));
|
||||
|
||||
/* DST = SRC. */
|
||||
#define bitset_copy(DST, SRC) BITSET_COPY_ (DST, SRC)
|
||||
|
||||
/* Return DST & SRC == 0. */
|
||||
extern int bitset_disjoint_p PARAMS ((bitset, bitset));
|
||||
#define bitset_disjoint_p(DST, SRC) BITSET_DISJOINT_P_ (DST, SRC)
|
||||
|
||||
/* DST == SRC. */
|
||||
extern int bitset_copy PARAMS ((bitset, bitset));
|
||||
/* Return DST == SRC. */
|
||||
#define bitset_equal_p(DST, SRC) BITSET_EQUAL_P_ (DST, SRC)
|
||||
|
||||
/* DST = ~SRC. */
|
||||
extern int bitset_not PARAMS ((bitset, bitset));
|
||||
#define bitset_not(DST, SRC) BITSET_NOT_ (DST, SRC)
|
||||
|
||||
/* DST = SRC1 | SRC2. Return non-zero if DST != SRC1 | SRC2. */
|
||||
extern int bitset_or PARAMS ((bitset, bitset, bitset));
|
||||
/* Return DST == DST | SRC. */
|
||||
#define bitset_subset_p(DST, SRC) BITSET_SUBSET_P_ (DST, SRC)
|
||||
|
||||
|
||||
|
||||
/* DST = SRC1 & SRC2. */
|
||||
#define bitset_and(DST, SRC1, SRC2) BITSET_AND_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 & SRC2. Return non-zero if DST != SRC1 & SRC2. */
|
||||
extern int bitset_and PARAMS ((bitset, bitset, bitset));
|
||||
#define bitset_and_cmp(DST, SRC1, SRC2) BITSET_AND_CMP_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. Return non-zero if DST != SRC1 ^ SRC2. */
|
||||
extern int bitset_xor PARAMS ((bitset, bitset, bitset));
|
||||
/* DST = SRC1 & ~SRC2. */
|
||||
#define bitset_andn(DST, SRC1, SRC2) BITSET_ANDN_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 & ~SRC2. Return non-zero if DST != SRC1 & ~SRC2. */
|
||||
extern int bitset_andn PARAMS ((bitset, bitset, bitset));
|
||||
#define bitset_andn_cmp(DST, SRC1, SRC2) BITSET_ANDN_CMP_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
extern int bitset_or_and PARAMS ((bitset, bitset, bitset, bitset));
|
||||
/* DST = SRC1 | SRC2. */
|
||||
#define bitset_or(DST, SRC1, SRC2) BITSET_OR_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 | SRC2. Return non-zero if DST != SRC1 | SRC2. */
|
||||
#define bitset_or_cmp(DST, SRC1, SRC2) BITSET_OR_CMP_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. */
|
||||
#define bitset_xor(DST, SRC1, SRC2) BITSET_XOR_ (DST, SRC1, SRC2)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. Return non-zero if DST != SRC1 ^ SRC2. */
|
||||
#define bitset_xor_cmp(DST, SRC1, SRC2) BITSET_XOR_CMP_ (DST, SRC1, SRC2)
|
||||
|
||||
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. */
|
||||
#define bitset_and_or(DST, SRC1, SRC2, SRC3) \
|
||||
BITSET_AND_OR_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & SRC2) | SRC3. */
|
||||
extern int bitset_and_or PARAMS ((bitset, bitset, bitset, bitset));
|
||||
#define bitset_and_or_cmp(DST, SRC1, SRC2, SRC3) \
|
||||
BITSET_AND_OR_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. */
|
||||
#define bitset_andn_or(DST, SRC1, SRC2, SRC3) \
|
||||
BITSET_ANDN_OR_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||
extern int bitset_andn_or PARAMS ((bitset, bitset, bitset, bitset));
|
||||
#define bitset_andn_or_cmp(DST, SRC1, SRC2, SRC3) \
|
||||
BITSET_ANDN_OR_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* Find next bit set in BSET starting from and including BITNO. */
|
||||
extern int bitset_next PARAMS ((bitset, bitset_bindex));
|
||||
/* DST = (SRC1 | SRC2) & SRC3. */
|
||||
#define bitset_or_and(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OR_AND_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* Find previous bit set in BSET starting from and including BITNO. */
|
||||
extern int bitset_prev PARAMS ((bitset, bitset_bindex));
|
||||
|
||||
/* Return non-zero if BITNO in SRC is the only set bit. */
|
||||
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex));
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
#define bitset_or_and_cmp(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OR_AND_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#if BITSET_STATS
|
||||
extern int bitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
#else
|
||||
#define bitset_list(BSET, LIST, NUM, NEXT) \
|
||||
BITSET_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
#endif
|
||||
BITSET_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define bitset_reverse_list(BSET, LIST, NUM, NEXT) \
|
||||
BITSET_REVERSE_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
#define bitset_list_reverse(BSET, LIST, NUM, NEXT) \
|
||||
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Return true if both bitsets are of the same type and size. */
|
||||
extern bool bitset_compatible_p (bitset bset1, bitset bset2);
|
||||
|
||||
/* Find next set bit from the given bit index. */
|
||||
extern bitset_bindex bitset_next (bitset, bitset_bindex);
|
||||
|
||||
/* Find previous set bit from the given bit index. */
|
||||
extern bitset_bindex bitset_prev (bitset, bitset_bindex);
|
||||
|
||||
/* Find first set bit. */
|
||||
extern int bitset_first PARAMS ((bitset));
|
||||
extern bitset_bindex bitset_first (bitset);
|
||||
|
||||
/* Find last set bit. */
|
||||
extern int bitset_last PARAMS ((bitset));
|
||||
extern bitset_bindex bitset_last (bitset);
|
||||
|
||||
/* Return nonzero if this is the only set bit. */
|
||||
extern bool bitset_only_set_p (bitset, bitset_bindex);
|
||||
|
||||
/* Dump bitset. */
|
||||
extern void bitset_dump PARAMS ((FILE *, bitset));
|
||||
extern void bitset_dump (FILE *, bitset);
|
||||
|
||||
/* Loop over all elements of BSET, starting with MIN, executing CODE. */
|
||||
#define BITSET_EXECUTE(BSET, MIN, N, CODE) \
|
||||
do { \
|
||||
bitset_bindex _list[BITSET_LIST_SIZE]; \
|
||||
bitset_bindex _next = (MIN); \
|
||||
int _num; \
|
||||
\
|
||||
while ((_num = bitset_list ((BSET), _list, BITSET_LIST_SIZE, &_next)))\
|
||||
{ \
|
||||
int _i; \
|
||||
\
|
||||
for (_i = 0; _i < _num; _i++) \
|
||||
{ \
|
||||
(N) = _list[_i]; \
|
||||
CODE; \
|
||||
} \
|
||||
if (_num < BITSET_LIST_SIZE) \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
/* Loop over all elements of BSET, starting with MIN, setting INDEX
|
||||
to the index of each set bit. For example, the following will print
|
||||
the bits set in a bitset:
|
||||
|
||||
bitset_bindex i;
|
||||
bitset_iterator iter;
|
||||
|
||||
BITSET_FOR_EACH (iter, src, i, 0)
|
||||
{
|
||||
printf ("%lu ", (unsigned long int) i);
|
||||
};
|
||||
*/
|
||||
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
(ITER.num == BITSET_LIST_SIZE) \
|
||||
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; \
|
||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||
ITER.i++)
|
||||
|
||||
|
||||
/* Loop over all elements of BSET, in reverse order starting with
|
||||
MIN, executing CODE. */
|
||||
#define BITSET_REVERSE_EXECUTE(BSET, MIN, N, CODE) \
|
||||
do { \
|
||||
bitset_bindex _list[BITSET_LIST_SIZE]; \
|
||||
bitset_bindex _next = (MIN); \
|
||||
int _num; \
|
||||
\
|
||||
while ((_num = bitset_reverse_list ((BSET), _list, \
|
||||
BITSET_LIST_SIZE, &_next))) \
|
||||
{ \
|
||||
int _i; \
|
||||
\
|
||||
for (_i = 0; _i < _num; _i++) \
|
||||
{ \
|
||||
(N) = _list[_i]; \
|
||||
CODE; \
|
||||
} \
|
||||
if (_num < BITSET_LIST_SIZE) \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
MIN, setting INDEX to the index of each set bit. For example, the
|
||||
following will print the bits set in a bitset in reverse order:
|
||||
|
||||
bitset_bindex i;
|
||||
bitset_iterator iter;
|
||||
|
||||
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
|
||||
{
|
||||
printf ("%lu ", (unsigned long int) i);
|
||||
};
|
||||
*/
|
||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
(ITER.num == BITSET_LIST_SIZE) \
|
||||
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; \
|
||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||
ITER.i++)
|
||||
|
||||
|
||||
/* Define set operations in terms of logical operations. */
|
||||
|
||||
#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
|
||||
#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
|
||||
#define bitset_diff_cmp(DST, SRC1, SRC2) bitset_andn_cmp (DST, SRC1, SRC2)
|
||||
|
||||
#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
|
||||
#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
|
||||
#define bitset_intersection_cmp(DST, SRC1, SRC2) bitset_and_cmp (DST, SRC1, SRC2)
|
||||
|
||||
#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
|
||||
#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
|
||||
#define bitset_union_cmp(DST, SRC1, SRC2) bitset_or_cmp (DST, SRC1, SRC2)
|
||||
|
||||
/* Symmetrical difference. */
|
||||
#define bitset_symdiff(DST, SRC1, SRC2) bitset_xor (DST, SRC1, SRC2)
|
||||
#define bitset_symdiff_cmp(DST, SRC1, SRC2) bitset_xor_cmp (DST, SRC1, SRC2)
|
||||
|
||||
/* Union of difference. */
|
||||
#define bitset_diff_union(DST, SRC1, SRC2, SRC3) \
|
||||
bitset_andn_or (DST, SRC1, SRC2, SRC3)
|
||||
#define bitset_diff_union_cmp(DST, SRC1, SRC2, SRC3) \
|
||||
bitset_andn_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
|
||||
/* Release any memory tied up with bitsets. */
|
||||
extern void bitset_release_memory PARAMS ((void));
|
||||
extern void bitset_release_memory (void);
|
||||
|
||||
/* Initialise bitset stats. */
|
||||
extern void bitset_stats_init PARAMS ((void));
|
||||
/* Enable bitset stats gathering. */
|
||||
extern void bitset_stats_enable (void);
|
||||
|
||||
/* Disable bitset stats gathering. */
|
||||
extern void bitset_stats_disable (void);
|
||||
|
||||
/* Read bitset stats file of accummulated stats. */
|
||||
void bitset_stats_read (const char *filename);
|
||||
|
||||
/* Write bitset stats file of accummulated stats. */
|
||||
void bitset_stats_write (const char *filename);
|
||||
|
||||
/* Dump bitset stats. */
|
||||
extern void bitset_stats_dump PARAMS ((FILE *));
|
||||
extern void bitset_stats_dump (FILE *);
|
||||
|
||||
/* Function to debug bitset from debugger. */
|
||||
extern void debug_bitset PARAMS ((bitset));
|
||||
extern void debug_bitset (bitset);
|
||||
|
||||
/* Function to debug bitset stats from debugger. */
|
||||
extern void debug_bitset_stats PARAMS ((void));
|
||||
extern void debug_bitset_stats (void);
|
||||
|
||||
#endif /* _BITSET_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,732 @@
|
||||
/* Bitset statistics.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* This file is a wrapper bitset implementation for the other bitset
|
||||
implementations. It provides bitset compatibility checking and
|
||||
statistics gathering without having to instrument the bitset
|
||||
implementations. When statistics gathering is enabled, the bitset
|
||||
operations get vectored through here and we then call the appropriate
|
||||
routines.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "abitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "vbitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(Msgid) gettext (Msgid)
|
||||
|
||||
/* Configuration macros. */
|
||||
#define BITSET_STATS_FILE "bitset.dat"
|
||||
#define BITSET_LOG_COUNT_BINS 10
|
||||
#define BITSET_LOG_SIZE_BINS 16
|
||||
#define BITSET_DENSITY_BINS 20
|
||||
|
||||
|
||||
/* Accessor macros. */
|
||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||
bitset_stats_info->types[(TYPE)].allocs++
|
||||
#define BITSET_STATS_FREES_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
||||
#define BITSET_STATS_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
||||
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
||||
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
||||
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
||||
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
||||
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
||||
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||
|
||||
|
||||
struct bitset_type_info_struct
|
||||
{
|
||||
unsigned int allocs;
|
||||
unsigned int frees;
|
||||
unsigned int lists;
|
||||
unsigned int sets;
|
||||
unsigned int cache_sets;
|
||||
unsigned int resets;
|
||||
unsigned int cache_resets;
|
||||
unsigned int tests;
|
||||
unsigned int cache_tests;
|
||||
unsigned int list_counts[BITSET_LOG_COUNT_BINS];
|
||||
unsigned int list_sizes[BITSET_LOG_SIZE_BINS];
|
||||
unsigned int list_density[BITSET_DENSITY_BINS];
|
||||
};
|
||||
|
||||
struct bitset_stats_info_struct
|
||||
{
|
||||
unsigned int runs;
|
||||
struct bitset_type_info_struct types[BITSET_TYPE_NUM];
|
||||
};
|
||||
|
||||
|
||||
struct bitset_stats_info_struct bitset_stats_info_data;
|
||||
struct bitset_stats_info_struct *bitset_stats_info;
|
||||
bool bitset_stats_enabled = false;
|
||||
|
||||
|
||||
/* Print a percentage histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
||||
unsigned int n_bins, unsigned int *bins)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < n_bins; i++)
|
||||
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||
i * 100.0 / n_bins,
|
||||
(i + 1) * 100.0 / n_bins, bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print a log histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||
unsigned int n_bins, unsigned int *bins)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
unsigned int max_width;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
/* Determine number of useful bins. */
|
||||
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||
continue;
|
||||
n_bins = i;
|
||||
|
||||
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
|
||||
max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < 2; i++)
|
||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||
|
||||
for (; i < n_bins; i++)
|
||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||
1UL << (i - 1),
|
||||
(1UL << i) - 1,
|
||||
bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print_1 (FILE *file, const char *name,
|
||||
struct bitset_type_info_struct *stats)
|
||||
{
|
||||
if (!stats)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s:\n", name);
|
||||
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
||||
stats->allocs, stats->frees,
|
||||
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
||||
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
||||
stats->sets, stats->cache_sets,
|
||||
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
||||
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
||||
stats->resets, stats->cache_resets,
|
||||
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
||||
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
||||
stats->tests, stats->cache_tests,
|
||||
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
||||
|
||||
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
||||
|
||||
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
||||
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
||||
|
||||
bitset_log_histogram_print (file, name, _("size log histogram\n"),
|
||||
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
||||
|
||||
bitset_percent_histogram_print (file, name, _("density histogram\n"),
|
||||
BITSET_DENSITY_BINS, stats->list_density);
|
||||
}
|
||||
|
||||
|
||||
/* Print all bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
fprintf (file, _("Bitset statistics:\n\n"));
|
||||
|
||||
if (bitset_stats_info->runs > 1)
|
||||
fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
|
||||
|
||||
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||
bitset_stats_print_1 (file, bitset_type_names[i],
|
||||
&bitset_stats_info->types[i]);
|
||||
}
|
||||
|
||||
|
||||
/* Initialise bitset statistics logging. */
|
||||
void
|
||||
bitset_stats_enable (void)
|
||||
{
|
||||
if (!bitset_stats_info)
|
||||
bitset_stats_info = &bitset_stats_info_data;
|
||||
bitset_stats_enabled = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bitset_stats_disable (void)
|
||||
{
|
||||
bitset_stats_enabled = false;
|
||||
}
|
||||
|
||||
|
||||
/* Read bitset statistics file. */
|
||||
void
|
||||
bitset_stats_read (const char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "r");
|
||||
if (file)
|
||||
{
|
||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
1, file) != 1)
|
||||
{
|
||||
if (ferror (file))
|
||||
perror (_("Could not read stats file."));
|
||||
else
|
||||
fprintf (stderr, _("Bad stats file size.\n"));
|
||||
}
|
||||
if (fclose (file) != 0)
|
||||
perror (_("Could not read stats file."));
|
||||
}
|
||||
bitset_stats_info_data.runs++;
|
||||
}
|
||||
|
||||
|
||||
/* Write bitset statistics file. */
|
||||
void
|
||||
bitset_stats_write (const char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "w");
|
||||
if (file)
|
||||
{
|
||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
1, file) != 1)
|
||||
perror (_("Could not write stats file."));
|
||||
if (fclose (file) != 0)
|
||||
perror (_("Could not write stats file."));
|
||||
}
|
||||
else
|
||||
perror (_("Could not open stats file for writing."));
|
||||
}
|
||||
|
||||
|
||||
/* Dump bitset statistics to FILE. */
|
||||
void
|
||||
bitset_stats_dump (FILE *file)
|
||||
{
|
||||
bitset_stats_print (file, false);
|
||||
}
|
||||
|
||||
|
||||
/* Function to be called from debugger to print bitset stats. */
|
||||
void
|
||||
debug_bitset_stats (void)
|
||||
{
|
||||
bitset_stats_print (stderr, true);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_set (bitset dst, bitset_bindex bitno)
|
||||
{
|
||||
bitset bset = dst->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_SETS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
bset->b.cdata[offset] |= (bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||
BITSET_STATS_CACHE_SETS_INC (bset);
|
||||
}
|
||||
else
|
||||
BITSET_SET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
||||
{
|
||||
bitset bset = dst->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_RESETS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
bset->b.cdata[offset] &=
|
||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
BITSET_STATS_CACHE_RESETS_INC (bset);
|
||||
}
|
||||
else
|
||||
BITSET_RESET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_test (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset bset = src->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_TESTS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
BITSET_STATS_CACHE_TESTS_INC (bset);
|
||||
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
}
|
||||
else
|
||||
return BITSET_TEST_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
bitset_stats_resize (bitset src, bitset_bindex size)
|
||||
{
|
||||
return BITSET_RESIZE_ (src->s.bset, size);
|
||||
}
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
bitset_stats_size (bitset src)
|
||||
{
|
||||
return BITSET_SIZE_ (src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
bitset_stats_count (bitset src)
|
||||
{
|
||||
return BITSET_COUNT_ (src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_empty_p (bitset dst)
|
||||
{
|
||||
return BITSET_EMPTY_P_ (dst->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_ones (bitset dst)
|
||||
{
|
||||
BITSET_ONES_ (dst->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_zero (bitset dst)
|
||||
{
|
||||
BITSET_ZERO_ (dst->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_copy (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
BITSET_COPY_ (dst->s.bset, src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_DISJOINT_P_ (dst->s.bset, src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_EQUAL_P_ (dst->s.bset, src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_not (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
BITSET_NOT_ (dst->s.bset, src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_SUBSET_P_ (dst->s.bset, src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_and (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
BITSET_AND_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_andn (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
BITSET_ANDN_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_ANDN_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_or (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
BITSET_OR_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_xor (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
BITSET_XOR_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_XOR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
BITSET_AND_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_AND_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
BITSET_ANDN_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_ANDN_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
BITSET_OR_AND_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_OR_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
bitset_stats_list (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
bitset_bindex count;
|
||||
bitset_bindex tmp;
|
||||
bitset_bindex size;
|
||||
bitset_bindex i;
|
||||
enum bitset_type type;
|
||||
|
||||
count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||
|
||||
type = BITSET_TYPE_ (bset->s.bset);
|
||||
BITSET_STATS_LISTS_INC (bset->s.bset);
|
||||
|
||||
/* Log histogram of number of set bits. */
|
||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_COUNT_BINS)
|
||||
i = BITSET_LOG_COUNT_BINS - 1;
|
||||
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
|
||||
|
||||
/* Log histogram of number of bits in set. */
|
||||
size = BITSET_SIZE_ (bset->s.bset);
|
||||
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_SIZE_BINS)
|
||||
i = BITSET_LOG_SIZE_BINS - 1;
|
||||
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
|
||||
|
||||
/* Histogram of fraction of bits set. */
|
||||
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||
if (i >= BITSET_DENSITY_BINS)
|
||||
i = BITSET_DENSITY_BINS - 1;
|
||||
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static bitset_bindex
|
||||
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
|
||||
bitset_bindex num, bitset_bindex *next)
|
||||
{
|
||||
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_free (bitset bset)
|
||||
{
|
||||
BITSET_STATS_FREES_INC (bset->s.bset);
|
||||
BITSET_FREE_ (bset->s.bset);
|
||||
}
|
||||
|
||||
|
||||
struct bitset_vtable bitset_stats_vtable = {
|
||||
bitset_stats_set,
|
||||
bitset_stats_reset,
|
||||
bitset_stats_toggle,
|
||||
bitset_stats_test,
|
||||
bitset_stats_resize,
|
||||
bitset_stats_size,
|
||||
bitset_stats_count,
|
||||
bitset_stats_empty_p,
|
||||
bitset_stats_ones,
|
||||
bitset_stats_zero,
|
||||
bitset_stats_copy,
|
||||
bitset_stats_disjoint_p,
|
||||
bitset_stats_equal_p,
|
||||
bitset_stats_not,
|
||||
bitset_stats_subset_p,
|
||||
bitset_stats_and,
|
||||
bitset_stats_and_cmp,
|
||||
bitset_stats_andn,
|
||||
bitset_stats_andn_cmp,
|
||||
bitset_stats_or,
|
||||
bitset_stats_or_cmp,
|
||||
bitset_stats_xor,
|
||||
bitset_stats_xor_cmp,
|
||||
bitset_stats_and_or,
|
||||
bitset_stats_and_or_cmp,
|
||||
bitset_stats_andn_or,
|
||||
bitset_stats_andn_or_cmp,
|
||||
bitset_stats_or_and,
|
||||
bitset_stats_or_and_cmp,
|
||||
bitset_stats_list,
|
||||
bitset_stats_list_reverse,
|
||||
bitset_stats_free,
|
||||
BITSET_STATS
|
||||
};
|
||||
|
||||
|
||||
/* Return enclosed bitset type. */
|
||||
enum bitset_type
|
||||
bitset_stats_type_get (bitset bset)
|
||||
{
|
||||
return BITSET_TYPE_ (bset->s.bset);
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
bitset_stats_bytes (void)
|
||||
{
|
||||
return sizeof (struct bitset_stats_struct);
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
{
|
||||
size_t bytes;
|
||||
bitset sbset;
|
||||
|
||||
bset->b.vtable = &bitset_stats_vtable;
|
||||
|
||||
/* Disable cache. */
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = 0;
|
||||
bset->b.cdata = 0;
|
||||
|
||||
BITSET_NBITS_ (bset) = n_bits;
|
||||
|
||||
/* Set up the actual bitset implementation that
|
||||
we are a wrapper over. */
|
||||
switch (type)
|
||||
{
|
||||
case BITSET_ARRAY:
|
||||
bytes = abitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
abitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_LIST:
|
||||
bytes = lbitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
lbitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_TABLE:
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
ebitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_VARRAY:
|
||||
bytes = vbitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
vbitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
bset->s.bset = sbset;
|
||||
|
||||
BITSET_STATS_ALLOCS_INC (type);
|
||||
|
||||
return bset;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Functions to support bitset statistics.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _BITSET_STATS_H
|
||||
#define _BITSET_STATS_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
extern bool bitset_stats_enabled;
|
||||
|
||||
extern enum bitset_type bitset_stats_type_get (bitset);
|
||||
|
||||
extern size_t bitset_stats_bytes (void);
|
||||
|
||||
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2, or (at your option) any later
|
||||
version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "bitsetv-print.h"
|
||||
|
||||
/*--------------------------------------------------------.
|
||||
| Display the MATRIX array of SIZE bitsets of size SIZE. |
|
||||
`--------------------------------------------------------*/
|
||||
|
||||
void
|
||||
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||
{
|
||||
bitset_bindex i, j;
|
||||
bitset_bindex hsize = bitset_size (bset[0]);
|
||||
|
||||
/* Title. */
|
||||
fprintf (out, "%s BEGIN\n", title);
|
||||
|
||||
/* Column numbers. */
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
||||
putc ('\n', out);
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
fprintf (out, "%d", (int) (i % 10));
|
||||
putc ('\n', out);
|
||||
|
||||
/* Bar. */
|
||||
fputs (" .", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs (".\n", out);
|
||||
|
||||
/* Contents. */
|
||||
for (i = 0; bset[i]; ++i)
|
||||
{
|
||||
fprintf (out, "%2lu|", (unsigned long int) i);
|
||||
for (j = 0; j < hsize; ++j)
|
||||
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||
fputs ("|\n", out);
|
||||
}
|
||||
|
||||
/* Bar. */
|
||||
fputs (" `", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs ("'\n", out);
|
||||
|
||||
/* End title. */
|
||||
fprintf (out, "%s END\n\n", title);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Akim Demaille ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _BITSETV_PRINT_H
|
||||
#define _BITSETV_PRINT_H
|
||||
|
||||
#include "bitsetv.h"
|
||||
|
||||
/* Dump vector of bitsets as a matrix. */
|
||||
extern void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
+44
-51
@@ -1,5 +1,5 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
@@ -29,30 +29,33 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
|
||||
type TYPE. */
|
||||
bitset *
|
||||
bitsetv_alloc (n_vecs, n_bits, type)
|
||||
unsigned int n_vecs;
|
||||
unsigned int n_bits;
|
||||
enum bitset_type type;
|
||||
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||
enum bitset_type type)
|
||||
{
|
||||
unsigned int vector_bytes;
|
||||
unsigned int bytes;
|
||||
size_t vector_bytes;
|
||||
size_t bytes;
|
||||
bitset *bsetv;
|
||||
unsigned int i;
|
||||
|
||||
bitset_bindex i;
|
||||
|
||||
/* Determine number of bytes for each set. */
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
|
||||
/* If size calculation overflows, memory is exhausted. */
|
||||
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
|
||||
xalloc_die ();
|
||||
|
||||
/* Allocate vector table at head of bitset array. */
|
||||
vector_bytes = (n_vecs + 1) * sizeof (bitset);
|
||||
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
|
||||
vector_bytes -= vector_bytes % bytes;
|
||||
bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||
|
||||
|
||||
for (i = 0; i < n_vecs; i++)
|
||||
{
|
||||
bsetv[i] = (bitset) ((char *) bsetv + vector_bytes + i * bytes);
|
||||
bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes);
|
||||
|
||||
bitset_init (bsetv[i], n_bits, type);
|
||||
}
|
||||
|
||||
|
||||
/* Null terminate table. */
|
||||
bsetv[i] = 0;
|
||||
return bsetv;
|
||||
@@ -62,13 +65,10 @@ bitsetv_alloc (n_vecs, n_bits, type)
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
|
||||
attribute hints specified by ATTR. */
|
||||
bitset *
|
||||
bitsetv_create (n_vecs, n_bits, attr)
|
||||
unsigned int n_vecs;
|
||||
unsigned int n_bits;
|
||||
unsigned int attr;
|
||||
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned int attr)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
|
||||
type = bitset_type_choose (n_bits, attr);
|
||||
return bitsetv_alloc (n_vecs, n_bits, type);
|
||||
}
|
||||
@@ -76,10 +76,9 @@ bitsetv_create (n_vecs, n_bits, attr)
|
||||
|
||||
/* Free bitset vector BSETV. */
|
||||
void
|
||||
bitsetv_free (bsetv)
|
||||
bitset *bsetv;
|
||||
bitsetv_free (bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
BITSET_FREE_ (bsetv[i]);
|
||||
@@ -89,11 +88,10 @@ bitsetv_free (bsetv)
|
||||
|
||||
/* Zero a vector of bitsets. */
|
||||
void
|
||||
bitsetv_zero (bsetv)
|
||||
struct bitset_struct **bsetv;
|
||||
bitsetv_zero (bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
bitset_zero (bsetv[i]);
|
||||
}
|
||||
@@ -101,11 +99,10 @@ bitsetv_zero (bsetv)
|
||||
|
||||
/* Set a vector of bitsets to ones. */
|
||||
void
|
||||
bitsetv_ones (bsetv)
|
||||
bitset *bsetv;
|
||||
bitsetv_ones (bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
bitset_bindex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
bitset_ones (bsetv[i]);
|
||||
}
|
||||
@@ -114,27 +111,26 @@ bitsetv_ones (bsetv)
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the transitive closure of what was given. */
|
||||
void
|
||||
bitsetv_transitive_closure (bsetv)
|
||||
bitset *bsetv;
|
||||
bitsetv_transitive_closure (bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
bitset_bindex i;
|
||||
bitset_bindex j;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
for (j = 0; bsetv[j]; j++)
|
||||
if (bitset_test (bsetv[j], i))
|
||||
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||
}
|
||||
|
||||
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the reflexive transitive closure of what was given. This is
|
||||
be the reflexive transitive closure of what was given. This is
|
||||
the same as transitive closure but with all bits on the diagonal
|
||||
of the bit matrix set. */
|
||||
void
|
||||
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
||||
{
|
||||
int i;
|
||||
bitset_bindex i;
|
||||
|
||||
bitsetv_transitive_closure (bsetv);
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
@@ -145,35 +141,32 @@ bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
||||
/* Dump the contents of a bitset vector BSETV with N_VECS elements to
|
||||
FILE. */
|
||||
void
|
||||
bitsetv_dump (file, title, subtitle, bsetv)
|
||||
FILE *file;
|
||||
const char *title, *subtitle;
|
||||
bitset *bsetv;
|
||||
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||
bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
bitset_windex i;
|
||||
|
||||
fprintf (file, "%s\n", title);
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (file, "%s %d\n", subtitle, i);
|
||||
fprintf (file, "%s %lu\n", subtitle, (unsigned long int) i);
|
||||
bitset_dump (file, bsetv[i]);
|
||||
}
|
||||
|
||||
|
||||
fprintf (file, "\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
debug_bitsetv (bsetv)
|
||||
bitset *bsetv;
|
||||
debug_bitsetv (bitsetv bsetv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
bitset_windex i;
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (stderr, "%d: ", i);
|
||||
fprintf (stderr, "%lu: ", (unsigned long int) i);
|
||||
debug_bitset (bsetv[i]);
|
||||
}
|
||||
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
+11
-14
@@ -1,5 +1,5 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -25,38 +25,35 @@ typedef bitset * bitsetv;
|
||||
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
|
||||
type TYPE. */
|
||||
extern bitsetv bitsetv_alloc PARAMS ((unsigned int, unsigned int,
|
||||
enum bitset_type));
|
||||
extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
|
||||
|
||||
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
|
||||
attribute hints specified by ATTR. */
|
||||
extern bitsetv bitsetv_create PARAMS ((unsigned int, unsigned int,
|
||||
unsigned int));
|
||||
extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned int);
|
||||
|
||||
/* Free vector of bitsets. */
|
||||
extern void bitsetv_free PARAMS ((bitsetv));
|
||||
extern void bitsetv_free (bitsetv);
|
||||
|
||||
/* Zero vector of bitsets. */
|
||||
extern void bitsetv_zero PARAMS ((bitsetv));
|
||||
extern void bitsetv_zero (bitsetv);
|
||||
|
||||
/* Set vector of bitsets. */
|
||||
extern void bitsetv_ones PARAMS ((bitsetv));
|
||||
extern void bitsetv_ones (bitsetv);
|
||||
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the transitive closure of what was given. */
|
||||
extern void bitsetv_transitive_closure PARAMS ((bitsetv));
|
||||
extern void bitsetv_transitive_closure (bitsetv);
|
||||
|
||||
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||
be the reflexive transitive closure of what was given. This is
|
||||
be the reflexive transitive closure of what was given. This is
|
||||
the same as transitive closure but with all bits on the diagonal
|
||||
of the bit matrix set. */
|
||||
extern void bitsetv_reflexive_transitive_closure PARAMS ((bitsetv));
|
||||
extern void bitsetv_reflexive_transitive_closure (bitsetv);
|
||||
|
||||
/* Dump vector of bitsets. */
|
||||
extern void bitsetv_dump PARAMS ((FILE *, const char *,
|
||||
const char *, bitsetv));
|
||||
extern void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
|
||||
|
||||
/* Function to debug vector of bitsets from debugger. */
|
||||
extern void debug_bitsetv PARAMS ((bitsetv));
|
||||
extern void debug_bitsetv (bitsetv);
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
|
||||
-189
@@ -1,189 +0,0 @@
|
||||
/* dirname.c -- return all but the last element in a path
|
||||
Copyright (C) 1990, 1998, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
#if defined STDC_HEADERS || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
# ifndef strrchr
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef HAVE_DECL_MEMRCHR
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MEMRCHR
|
||||
void *memrchr ();
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
#define BACKSLASH_IS_PATH_SEPARATOR ISSLASH ('\\')
|
||||
|
||||
/* Return the length of `dirname (PATH)' and set *RESULT to point
|
||||
to PATH or to `"."', as appropriate. Works properly even if
|
||||
there are trailing slashes (by effectively ignoring them).
|
||||
WARNING: This function doesn't work for cwd-relative names like
|
||||
`a:foo' that are specified with a drive-letter prefix. That case
|
||||
is handled in the caller. */
|
||||
static size_t
|
||||
dir_name_r (char const *path, char const **result)
|
||||
{
|
||||
char const *slash;
|
||||
size_t length; /* Length of result, not including NUL. */
|
||||
|
||||
slash = strrchr (path, '/');
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char const *b = strrchr (path, '\\');
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
|
||||
/* If the last byte of PATH is a slash, decrement SLASH until it's
|
||||
pointing at the leftmost in a sequence of trailing slashes. */
|
||||
if (slash && slash[1] == 0)
|
||||
{
|
||||
while (path < slash && ISSLASH (slash[-1]))
|
||||
{
|
||||
--slash;
|
||||
}
|
||||
|
||||
if (path < slash)
|
||||
{
|
||||
size_t len = slash - path;
|
||||
slash = memrchr (path, '/', len);
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char const *b = memrchr (path, '\\', len);
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slash == 0)
|
||||
{
|
||||
/* File is in the current directory. */
|
||||
|
||||
length = FILESYSTEM_PREFIX_LEN (path);
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
path = ".";
|
||||
length = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove any trailing slashes from the result. If we have a
|
||||
canonicalized "d:/path", leave alone the root case "d:/". */
|
||||
char const *lim = path + FILESYSTEM_PREFIX_LEN (path);
|
||||
|
||||
while (lim < slash && ISSLASH (*slash))
|
||||
--slash;
|
||||
|
||||
length = slash - path + 1;
|
||||
}
|
||||
|
||||
*result = path;
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with malloc. If out of memory, return 0.
|
||||
Works properly even if there are trailing slashes
|
||||
(by effectively ignoring them). */
|
||||
|
||||
char *
|
||||
dir_name (char const *path)
|
||||
{
|
||||
char const *result;
|
||||
size_t length = dir_name_r (path, &result);
|
||||
int append_dot = (length && length == FILESYSTEM_PREFIX_LEN (newpath));
|
||||
char *newpath = (char *) malloc (length + append_dot + 1);
|
||||
if (newpath == 0)
|
||||
return 0;
|
||||
strncpy (newpath, result, length);
|
||||
/* If PATH is "d:foo", return "d:.", the CWD on drive d: */
|
||||
if (append_dot)
|
||||
newpath[length++] = '.';
|
||||
newpath[length] = 0;
|
||||
return newpath;
|
||||
}
|
||||
|
||||
#ifdef TEST_DIRNAME
|
||||
/*
|
||||
|
||||
Run the test like this (expect no output):
|
||||
gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall memrchr.c dirname.c
|
||||
sed -n '/^BEGIN-DATA$/,/^END-DATA$/p' dirname.c|grep -v DATA|./a.out
|
||||
|
||||
BEGIN-DATA
|
||||
foo//// .
|
||||
bar/foo//// bar
|
||||
foo/ .
|
||||
/ /
|
||||
. .
|
||||
a .
|
||||
END-DATA
|
||||
|
||||
*/
|
||||
|
||||
# define MAX_BUFF_LEN 1024
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char buff[MAX_BUFF_LEN + 1];
|
||||
|
||||
buff[MAX_BUFF_LEN] = 0;
|
||||
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
|
||||
{
|
||||
char path[MAX_BUFF_LEN];
|
||||
char expected_result[MAX_BUFF_LEN];
|
||||
char const *result;
|
||||
sscanf (buff, "%s %s", path, expected_result);
|
||||
result = dir_name (path);
|
||||
if (strcmp (result, expected_result))
|
||||
printf ("%s: got %s, expected %s\n", path, result, expected_result);
|
||||
}
|
||||
exit (0);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef DIRNAME_H_
|
||||
# define DIRNAME_H_ 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
char *
|
||||
dir_name PARAMS ((const char *path));
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
||||
+542
-434
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -1,5 +1,5 @@
|
||||
/* Functions to support ebitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,14 +17,14 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "bitset.h"
|
||||
|
||||
extern int ebitset_bytes PARAMS ((bitset_bindex));
|
||||
extern size_t ebitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset ebitset_init PARAMS ((bitset, bitset_bindex));
|
||||
extern bitset ebitset_init (bitset, bitset_bindex);
|
||||
|
||||
extern void ebitset_release_memory PARAMS ((void));
|
||||
extern void ebitset_release_memory (void);
|
||||
|
||||
#endif
|
||||
|
||||
-400
@@ -1,400 +0,0 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
#endif
|
||||
#ifdef _LIBC
|
||||
# include <wchar.h>
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
#endif
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||
# if __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(args, lastarg) va_start(args, lastarg)
|
||||
# else
|
||||
# include <varargs.h>
|
||||
# define VA_START(args, lastarg) va_start(args)
|
||||
# endif
|
||||
#else
|
||||
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
|
||||
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || _LIBC
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
void exit ();
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) (
|
||||
#if __STDC__ - 0
|
||||
void
|
||||
#endif
|
||||
);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
extern void __error (int status, int errnum, const char *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
# ifdef USE_IN_LIBIO
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) _IO_fflush (s)
|
||||
# endif
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
char *strerror_r ();
|
||||
# endif
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# else
|
||||
# if HAVE_STRERROR
|
||||
# ifndef HAVE_DECL_STRERROR
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
# if !HAVE_DECL_STRERROR
|
||||
char *strerror ();
|
||||
# endif
|
||||
# else
|
||||
static char *
|
||||
private_strerror (int errnum)
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return _(sys_errlist[errnum]);
|
||||
return _("Unknown system error");
|
||||
}
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
{
|
||||
char const *s;
|
||||
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if STRERROR_R_CHAR_P || _LIBC
|
||||
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
# else
|
||||
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||
s = errbuf;
|
||||
else
|
||||
s = 0;
|
||||
# endif
|
||||
#else
|
||||
s = strerror (errnum);
|
||||
#endif
|
||||
|
||||
#if !_LIBC
|
||||
if (! s)
|
||||
s = _("Unknown system error");
|
||||
#endif
|
||||
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
__fwprintf (stderr, L": %s", s);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf (stderr, ": %s", s);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
static void
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
{
|
||||
# if HAVE_VPRINTF || _LIBC
|
||||
# if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
# define ALLOCA_LIMIT 2000
|
||||
size_t len = strlen (message) + 1;
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
|
||||
do
|
||||
{
|
||||
if (len < ALLOCA_LIMIT)
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (wmessage != NULL && len / 2 < ALLOCA_LIMIT)
|
||||
wmessage = NULL;
|
||||
|
||||
wmessage = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
|
||||
if (wmessage == NULL)
|
||||
{
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp =message;
|
||||
}
|
||||
while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len);
|
||||
|
||||
if (res == (size_t) -1)
|
||||
/* The string cannot be converted. */
|
||||
wmessage = (wchar_t *) L"???";
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
vfprintf (stderr, message, args);
|
||||
# else
|
||||
_doprnt (message, args, stderr);
|
||||
# endif
|
||||
va_end (args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
# if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
putwc (L'\n', stderr);
|
||||
else
|
||||
# endif
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
/* VARARGS */
|
||||
void
|
||||
#if defined VA_START && __STDC__
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
#else
|
||||
error (status, errnum, message, va_alist)
|
||||
int status;
|
||||
int errnum;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_flockfile (stderr);
|
||||
# else
|
||||
__flockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
#else
|
||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_funlockfile (stderr);
|
||||
# else
|
||||
__funlockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
#if defined VA_START && __STDC__
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
#else
|
||||
error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
int status;
|
||||
int errnum;
|
||||
const char *file_name;
|
||||
unsigned int line_number;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_flockfile (stderr);
|
||||
# else
|
||||
__flockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
}
|
||||
|
||||
if (file_name != NULL)
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s:%d: ", file_name, line_number);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
#else
|
||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_funlockfile (stderr);
|
||||
# else
|
||||
__funlockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to [email protected].
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int status, int errnum, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int status, int errnum, const char *fname,
|
||||
unsigned int lineno, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
#else
|
||||
void error ();
|
||||
void error_at_line ();
|
||||
extern void (*error_print_progname) ();
|
||||
#endif
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Work around bug on some systems where realloc (NULL, 0) fails.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
/* get-errno.h - get and set errno.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -15,30 +16,30 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef realloc
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
char *malloc ();
|
||||
char *realloc ();
|
||||
#include "get-errno.h"
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. If N is zero, change it to 1. If P is NULL,
|
||||
use malloc. */
|
||||
/* Get and set errno. A source file that needs to set or get errno,
|
||||
but doesn't need to test for specific errno values, can use these
|
||||
functions to avoid namespace pollution. For example, a file that
|
||||
defines EQUAL should not include <errno.h>, since <errno.h> might
|
||||
define EQUAL; such a file can include <get-errno.h> instead. */
|
||||
|
||||
char *
|
||||
rpl_realloc (p, n)
|
||||
char *p;
|
||||
size_t n;
|
||||
int
|
||||
get_errno (void)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if (p == 0)
|
||||
return malloc (n);
|
||||
return realloc (p, n);
|
||||
return errno;
|
||||
}
|
||||
|
||||
void
|
||||
set_errno (int e)
|
||||
{
|
||||
errno = e;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/* quote.h - prototypes for quote.c
|
||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
/* get-errno.h - get and set errno.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -15,14 +16,5 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char const *quote_n PARAMS ((int n, char const *name));
|
||||
char const *quote PARAMS ((char const *name));
|
||||
extern int get_errno (void);
|
||||
extern void set_errno (int);
|
||||
-1068
File diff suppressed because it is too large
Load Diff
-180
@@ -1,180 +0,0 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
# if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
const char *name;
|
||||
# else
|
||||
char *name;
|
||||
# endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`getopt'. */
|
||||
|
||||
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
# ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
|
||||
# else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
# endif /* __GNU_LIBRARY__ */
|
||||
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
extern int getopt_long_only (int __argc, char *const *__argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int __argc, char *const *__argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only);
|
||||
# endif
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
# endif
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
@@ -1,59 +0,0 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
||||
-1009
File diff suppressed because it is too large
Load Diff
-120
@@ -1,120 +0,0 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <meyering@ascend.com>, 1998.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* A generic hash table package. */
|
||||
|
||||
/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use
|
||||
obstacks instead of malloc, and recompile `hash.c' with same setting. */
|
||||
|
||||
#ifndef PARAMS
|
||||
# if PROTOTYPES || __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef unsigned (*Hash_hasher) PARAMS ((const void *, unsigned));
|
||||
typedef bool (*Hash_comparator) PARAMS ((const void *, const void *));
|
||||
typedef void (*Hash_data_freer) PARAMS ((void *));
|
||||
typedef bool (*Hash_processor) PARAMS ((void *, void *));
|
||||
|
||||
struct hash_entry
|
||||
{
|
||||
void *data;
|
||||
struct hash_entry *next;
|
||||
};
|
||||
|
||||
struct hash_tuning
|
||||
{
|
||||
/* This structure is mainly used for `hash_initialize', see the block
|
||||
documentation of `hash_reset_tuning' for more complete comments. */
|
||||
|
||||
float shrink_threshold; /* ratio of used buckets to trigger a shrink */
|
||||
float shrink_factor; /* ratio of new smaller size to original size */
|
||||
float growth_threshold; /* ratio of used buckets to trigger a growth */
|
||||
float growth_factor; /* ratio of new bigger size to original size */
|
||||
bool is_n_buckets; /* if CANDIDATE really means table size */
|
||||
};
|
||||
|
||||
typedef struct hash_tuning Hash_tuning;
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
/* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
|
||||
for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
|
||||
are not empty, there are N_ENTRIES active entries in the table. */
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *bucket_limit;
|
||||
unsigned n_buckets;
|
||||
unsigned n_buckets_used;
|
||||
unsigned n_entries;
|
||||
|
||||
/* Tuning arguments, kept in a physicaly separate structure. */
|
||||
const Hash_tuning *tuning;
|
||||
|
||||
/* Three functions are given to `hash_initialize', see the documentation
|
||||
block for this function. In a word, HASHER randomizes a user entry
|
||||
into a number up from 0 up to some maximum minus 1; COMPARATOR returns
|
||||
true if two user entries compare equally; and DATA_FREER is the cleanup
|
||||
function for a user entry. */
|
||||
Hash_hasher hasher;
|
||||
Hash_comparator comparator;
|
||||
Hash_data_freer data_freer;
|
||||
|
||||
/* A linked list of freed struct hash_entry structs. */
|
||||
struct hash_entry *free_entry_list;
|
||||
|
||||
#if USE_OBSTACK
|
||||
/* Whenever obstacks are used, it is possible to allocate all overflowed
|
||||
entries into a single stack, so they all can be freed in a single
|
||||
operation. It is not clear if the speedup is worth the trouble. */
|
||||
struct obstack entry_stack;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct hash_table Hash_table;
|
||||
|
||||
/* Information and lookup. */
|
||||
unsigned hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_entries PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||
bool hash_table_ok PARAMS ((const Hash_table *));
|
||||
void hash_print_statistics PARAMS ((const Hash_table *, FILE *));
|
||||
void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||
|
||||
/* Walking. */
|
||||
void *hash_get_first PARAMS ((const Hash_table *));
|
||||
void *hash_get_next PARAMS ((const Hash_table *, const void *));
|
||||
unsigned hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
|
||||
unsigned hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
|
||||
|
||||
/* Allocation and clean-up. */
|
||||
unsigned hash_string PARAMS ((const char *, unsigned));
|
||||
void hash_reset_tuning PARAMS ((Hash_tuning *));
|
||||
Hash_table *hash_initialize PARAMS ((unsigned, const Hash_tuning *,
|
||||
Hash_hasher, Hash_comparator,
|
||||
Hash_data_freer));
|
||||
void hash_clear PARAMS ((Hash_table *));
|
||||
void hash_free PARAMS ((Hash_table *));
|
||||
|
||||
/* Insertion and deletion. */
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *));
|
||||
void *hash_delete PARAMS ((Hash_table *, const void *));
|
||||
+431
-353
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -1,5 +1,5 @@
|
||||
/* Functions to support lbitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,14 +17,14 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "bitset.h"
|
||||
|
||||
extern int lbitset_bytes PARAMS ((bitset_bindex));
|
||||
extern size_t lbitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset lbitset_init PARAMS ((bitset, bitset_bindex));
|
||||
extern bitset lbitset_init (bitset, bitset_bindex);
|
||||
|
||||
extern void lbitset_release_memory PARAMS ((void));
|
||||
extern void lbitset_release_memory (void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xstrdup.c -- copy a string with out of memory checking
|
||||
Copyright (C) 1990, 1996, 1998, 2001 Free Software Foundation, Inc.
|
||||
/* Fake libiberty.h for Bison.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -15,24 +15,22 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
/* Bison depends on libiberty's implementation of bitsets, which
|
||||
requires a `libiberty.h' file. This file provides the minimum
|
||||
services. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef BISON_LIBIBERTY_H_
|
||||
# define BISON_LIBIBERTY_H_ 1
|
||||
|
||||
#include "xalloc.h"
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Return a newly allocated copy of STRING. */
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
|
||||
char *
|
||||
xstrdup (const char *string)
|
||||
{
|
||||
return strcpy (xmalloc (strlen (string) + 1), string);
|
||||
}
|
||||
# include "xalloc.h"
|
||||
|
||||
#endif /* ! BISON_LIBIBERTY_H_ */
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/* Yacc library main function.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
#if ! HAVE_SETLOCALE
|
||||
# define setlocale(Category, Locale)
|
||||
#endif
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
return yyparse ();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/* Work around bug on some systems where malloc (0) fails.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef malloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
char *malloc ();
|
||||
|
||||
/* Allocate an N-byte block of memory from the heap.
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
char *
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
return malloc (n);
|
||||
}
|
||||
-216
@@ -1,216 +0,0 @@
|
||||
/* Copyright (C) 1991,93,96,97,99,2000 Free Software Foundation, Inc.
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
|
||||
# define __ptr_t void *
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#if defined _LIBC
|
||||
# include <string.h>
|
||||
# include <memcopy.h>
|
||||
#else
|
||||
# define reg_char char
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H || defined _LIBC
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H || defined _LIBC
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#define LONG_MAX_32_BITS 2147483647
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX LONG_MAX_32_BITS
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#if HAVE_BP_SYM_H || defined _LIBC
|
||||
# include <bp-sym.h>
|
||||
#else
|
||||
# define BP_SYM(sym) sym
|
||||
#endif
|
||||
|
||||
#undef memchr
|
||||
#undef __memchr
|
||||
|
||||
/* Search no more than N bytes of S for C. */
|
||||
__ptr_t
|
||||
__memchr (s, c_in, n)
|
||||
const __ptr_t s;
|
||||
int c_in;
|
||||
size_t n;
|
||||
{
|
||||
const unsigned char *char_ptr;
|
||||
const unsigned long int *longword_ptr;
|
||||
unsigned long int longword, magic_bits, charmask;
|
||||
unsigned reg_char c;
|
||||
|
||||
c = (unsigned char) c_in;
|
||||
|
||||
/* Handle the first few characters by reading one character at a time.
|
||||
Do this until CHAR_PTR is aligned on a longword boundary. */
|
||||
for (char_ptr = (const unsigned char *) s;
|
||||
n > 0 && ((unsigned long int) char_ptr
|
||||
& (sizeof (longword) - 1)) != 0;
|
||||
--n, ++char_ptr)
|
||||
if (*char_ptr == c)
|
||||
return (__ptr_t) char_ptr;
|
||||
|
||||
/* All these elucidatory comments refer to 4-byte longwords,
|
||||
but the theory applies equally well to 8-byte longwords. */
|
||||
|
||||
longword_ptr = (unsigned long int *) char_ptr;
|
||||
|
||||
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
|
||||
the "holes." Note that there is a hole just to the left of
|
||||
each byte, with an extra at the end:
|
||||
|
||||
bits: 01111110 11111110 11111110 11111111
|
||||
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
|
||||
|
||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||
The 0-bits provide holes for carries to fall into. */
|
||||
|
||||
if (sizeof (longword) != 4 && sizeof (longword) != 8)
|
||||
abort ();
|
||||
|
||||
#if LONG_MAX <= LONG_MAX_32_BITS
|
||||
magic_bits = 0x7efefeff;
|
||||
#else
|
||||
magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
|
||||
#endif
|
||||
|
||||
/* Set up a longword, each of whose bytes is C. */
|
||||
charmask = c | (c << 8);
|
||||
charmask |= charmask << 16;
|
||||
#if LONG_MAX > LONG_MAX_32_BITS
|
||||
charmask |= charmask << 32;
|
||||
#endif
|
||||
|
||||
/* Instead of the traditional loop which tests each character,
|
||||
we will test a longword at a time. The tricky part is testing
|
||||
if *any of the four* bytes in the longword in question are zero. */
|
||||
while (n >= sizeof (longword))
|
||||
{
|
||||
/* We tentatively exit the loop if adding MAGIC_BITS to
|
||||
LONGWORD fails to change any of the hole bits of LONGWORD.
|
||||
|
||||
1) Is this safe? Will it catch all the zero bytes?
|
||||
Suppose there is a byte with all zeros. Any carry bits
|
||||
propagating from its left will fall into the hole at its
|
||||
least significant bit and stop. Since there will be no
|
||||
carry from its most significant bit, the LSB of the
|
||||
byte to the left will be unchanged, and the zero will be
|
||||
detected.
|
||||
|
||||
2) Is this worthwhile? Will it ignore everything except
|
||||
zero bytes? Suppose every byte of LONGWORD has a bit set
|
||||
somewhere. There will be a carry into bit 8. If bit 8
|
||||
is set, this will carry into bit 16. If bit 8 is clear,
|
||||
one of bits 9-15 must be set, so there will be a carry
|
||||
into bit 16. Similarly, there will be a carry into bit
|
||||
24. If one of bits 24-30 is set, there will be a carry
|
||||
into bit 31, so all of the hole bits will be changed.
|
||||
|
||||
The one misfire occurs when bits 24-30 are clear and bit
|
||||
31 is set; in this case, the hole at bit 31 is not
|
||||
changed. If we had access to the processor carry flag,
|
||||
we could close this loophole by putting the fourth hole
|
||||
at bit 32!
|
||||
|
||||
So it ignores everything except 128's, when they're aligned
|
||||
properly.
|
||||
|
||||
3) But wait! Aren't we looking for C, not zero?
|
||||
Good point. So what we do is XOR LONGWORD with a longword,
|
||||
each of whose bytes is C. This turns each byte that is C
|
||||
into a zero. */
|
||||
|
||||
longword = *longword_ptr++ ^ charmask;
|
||||
|
||||
/* Add MAGIC_BITS to LONGWORD. */
|
||||
if ((((longword + magic_bits)
|
||||
|
||||
/* Set those bits that were unchanged by the addition. */
|
||||
^ ~longword)
|
||||
|
||||
/* Look at only the hole bits. If any of the hole bits
|
||||
are unchanged, most likely one of the bytes was a
|
||||
zero. */
|
||||
& ~magic_bits) != 0)
|
||||
{
|
||||
/* Which of the bytes was C? If none of them were, it was
|
||||
a misfire; continue the search. */
|
||||
|
||||
const unsigned char *cp = (const unsigned char *) (longword_ptr - 1);
|
||||
|
||||
if (cp[0] == c)
|
||||
return (__ptr_t) cp;
|
||||
if (cp[1] == c)
|
||||
return (__ptr_t) &cp[1];
|
||||
if (cp[2] == c)
|
||||
return (__ptr_t) &cp[2];
|
||||
if (cp[3] == c)
|
||||
return (__ptr_t) &cp[3];
|
||||
#if LONG_MAX > 2147483647
|
||||
if (cp[4] == c)
|
||||
return (__ptr_t) &cp[4];
|
||||
if (cp[5] == c)
|
||||
return (__ptr_t) &cp[5];
|
||||
if (cp[6] == c)
|
||||
return (__ptr_t) &cp[6];
|
||||
if (cp[7] == c)
|
||||
return (__ptr_t) &cp[7];
|
||||
#endif
|
||||
}
|
||||
|
||||
n -= sizeof (longword);
|
||||
}
|
||||
|
||||
char_ptr = (const unsigned char *) longword_ptr;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
if (*char_ptr == c)
|
||||
return (__ptr_t) char_ptr;
|
||||
else
|
||||
++char_ptr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__memchr, BP_SYM (memchr))
|
||||
#endif
|
||||
-209
@@ -1,209 +0,0 @@
|
||||
/* memrchr -- find the last occurrence of a byte in a memory block
|
||||
Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc.
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
|
||||
# define __ptr_t void *
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#if defined (_LIBC)
|
||||
# include <string.h>
|
||||
# include <memcopy.h>
|
||||
#else
|
||||
# define reg_char char
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_LIMITS_H) || defined (_LIBC)
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#define LONG_MAX_32_BITS 2147483647
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX LONG_MAX_32_BITS
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#undef __memrchr
|
||||
#undef memrchr
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __memrchr memrchr
|
||||
#endif
|
||||
|
||||
/* Search no more than N bytes of S for C. */
|
||||
__ptr_t
|
||||
__memrchr (s, c_in, n)
|
||||
const __ptr_t s;
|
||||
int c_in;
|
||||
size_t n;
|
||||
{
|
||||
const unsigned char *char_ptr;
|
||||
const unsigned long int *longword_ptr;
|
||||
unsigned long int longword, magic_bits, charmask;
|
||||
unsigned reg_char c;
|
||||
|
||||
c = (unsigned char) c_in;
|
||||
|
||||
/* Handle the last few characters by reading one character at a time.
|
||||
Do this until CHAR_PTR is aligned on a longword boundary. */
|
||||
for (char_ptr = (const unsigned char *) s + n;
|
||||
n > 0 && ((unsigned long int) char_ptr
|
||||
& (sizeof (longword) - 1)) != 0;
|
||||
--n)
|
||||
if (*--char_ptr == c)
|
||||
return (__ptr_t) char_ptr;
|
||||
|
||||
/* All these elucidatory comments refer to 4-byte longwords,
|
||||
but the theory applies equally well to 8-byte longwords. */
|
||||
|
||||
longword_ptr = (unsigned long int *) char_ptr;
|
||||
|
||||
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
|
||||
the "holes." Note that there is a hole just to the left of
|
||||
each byte, with an extra at the end:
|
||||
|
||||
bits: 01111110 11111110 11111110 11111111
|
||||
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
|
||||
|
||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||
The 0-bits provide holes for carries to fall into. */
|
||||
|
||||
if (sizeof (longword) != 4 && sizeof (longword) != 8)
|
||||
abort ();
|
||||
|
||||
#if LONG_MAX <= LONG_MAX_32_BITS
|
||||
magic_bits = 0x7efefeff;
|
||||
#else
|
||||
magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
|
||||
#endif
|
||||
|
||||
/* Set up a longword, each of whose bytes is C. */
|
||||
charmask = c | (c << 8);
|
||||
charmask |= charmask << 16;
|
||||
#if LONG_MAX > LONG_MAX_32_BITS
|
||||
charmask |= charmask << 32;
|
||||
#endif
|
||||
|
||||
/* Instead of the traditional loop which tests each character,
|
||||
we will test a longword at a time. The tricky part is testing
|
||||
if *any of the four* bytes in the longword in question are zero. */
|
||||
while (n >= sizeof (longword))
|
||||
{
|
||||
/* We tentatively exit the loop if adding MAGIC_BITS to
|
||||
LONGWORD fails to change any of the hole bits of LONGWORD.
|
||||
|
||||
1) Is this safe? Will it catch all the zero bytes?
|
||||
Suppose there is a byte with all zeros. Any carry bits
|
||||
propagating from its left will fall into the hole at its
|
||||
least significant bit and stop. Since there will be no
|
||||
carry from its most significant bit, the LSB of the
|
||||
byte to the left will be unchanged, and the zero will be
|
||||
detected.
|
||||
|
||||
2) Is this worthwhile? Will it ignore everything except
|
||||
zero bytes? Suppose every byte of LONGWORD has a bit set
|
||||
somewhere. There will be a carry into bit 8. If bit 8
|
||||
is set, this will carry into bit 16. If bit 8 is clear,
|
||||
one of bits 9-15 must be set, so there will be a carry
|
||||
into bit 16. Similarly, there will be a carry into bit
|
||||
24. If one of bits 24-30 is set, there will be a carry
|
||||
into bit 31, so all of the hole bits will be changed.
|
||||
|
||||
The one misfire occurs when bits 24-30 are clear and bit
|
||||
31 is set; in this case, the hole at bit 31 is not
|
||||
changed. If we had access to the processor carry flag,
|
||||
we could close this loophole by putting the fourth hole
|
||||
at bit 32!
|
||||
|
||||
So it ignores everything except 128's, when they're aligned
|
||||
properly.
|
||||
|
||||
3) But wait! Aren't we looking for C, not zero?
|
||||
Good point. So what we do is XOR LONGWORD with a longword,
|
||||
each of whose bytes is C. This turns each byte that is C
|
||||
into a zero. */
|
||||
|
||||
longword = *--longword_ptr ^ charmask;
|
||||
|
||||
/* Add MAGIC_BITS to LONGWORD. */
|
||||
if ((((longword + magic_bits)
|
||||
|
||||
/* Set those bits that were unchanged by the addition. */
|
||||
^ ~longword)
|
||||
|
||||
/* Look at only the hole bits. If any of the hole bits
|
||||
are unchanged, most likely one of the bytes was a
|
||||
zero. */
|
||||
& ~magic_bits) != 0)
|
||||
{
|
||||
/* Which of the bytes was C? If none of them were, it was
|
||||
a misfire; continue the search. */
|
||||
|
||||
const unsigned char *cp = (const unsigned char *) longword_ptr;
|
||||
|
||||
#if LONG_MAX > 2147483647
|
||||
if (cp[7] == c)
|
||||
return (__ptr_t) &cp[7];
|
||||
if (cp[6] == c)
|
||||
return (__ptr_t) &cp[6];
|
||||
if (cp[5] == c)
|
||||
return (__ptr_t) &cp[5];
|
||||
if (cp[4] == c)
|
||||
return (__ptr_t) &cp[4];
|
||||
#endif
|
||||
if (cp[3] == c)
|
||||
return (__ptr_t) &cp[3];
|
||||
if (cp[2] == c)
|
||||
return (__ptr_t) &cp[2];
|
||||
if (cp[1] == c)
|
||||
return (__ptr_t) &cp[1];
|
||||
if (cp[0] == c)
|
||||
return (__ptr_t) cp;
|
||||
}
|
||||
|
||||
n -= sizeof (longword);
|
||||
}
|
||||
|
||||
char_ptr = (const unsigned char *) longword_ptr;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
if (*--char_ptr == c)
|
||||
return (__ptr_t) char_ptr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__memrchr, memrchr)
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Disable the definition of mkstemp to rpl_mkstemp (from config.h) in this
|
||||
file. Otherwise, we'd get conflicting prototypes for rpl_mkstemp on
|
||||
most systems. */
|
||||
#undef mkstemp
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
#endif
|
||||
|
||||
int __gen_tempname ();
|
||||
|
||||
/* Generate a unique temporary file name from TEMPLATE.
|
||||
The last six characters of TEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the filename unique.
|
||||
Then open the file and return a fd. */
|
||||
int
|
||||
rpl_mkstemp (char *template)
|
||||
{
|
||||
return __gen_tempname (template, __GT_FILE);
|
||||
}
|
||||
-623
@@ -1,623 +0,0 @@
|
||||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988-1994,96,97,98,99,2000,2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
|
||||
incremented whenever callers compiled using an old obstack.h can no
|
||||
longer properly call the functions in this obstack.c. */
|
||||
#define OBSTACK_INTERFACE_VERSION 1
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself, and the installed library
|
||||
supports the same library interface we do. This code is part of the GNU
|
||||
C Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object
|
||||
files, it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
||||
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
|
||||
# include <gnu-versions.h>
|
||||
# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||
# define ELIDE_CODE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _LIBC && defined USE_IN_LIBIO
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define POINTER void *
|
||||
# else
|
||||
# define POINTER char *
|
||||
# endif
|
||||
|
||||
/* Determine default alignment. */
|
||||
struct fooalign {char x; double d;};
|
||||
# define DEFAULT_ALIGNMENT \
|
||||
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
||||
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
||||
But in fact it might be less smart and round addresses to as much as
|
||||
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
||||
union fooround {long x; double d;};
|
||||
# define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||
|
||||
/* When we copy a long block of data, this is the unit to do it with.
|
||||
On some machines, copying successive ints does not work;
|
||||
in such a case, redefine COPYING_UNIT to `long' (if that works)
|
||||
or `char' as a last resort. */
|
||||
# ifndef COPYING_UNIT
|
||||
# define COPYING_UNIT int
|
||||
# endif
|
||||
|
||||
|
||||
/* The functions allocating more room by calling `obstack_chunk_alloc'
|
||||
jump to the handler pointed to by `obstack_alloc_failed_handler'.
|
||||
This can be set to a user defined function which should either
|
||||
abort gracefully or use longjump - but shouldn't return. This
|
||||
variable by default points to the internal function
|
||||
`print_and_abort'. */
|
||||
# if defined __STDC__ && __STDC__
|
||||
static void print_and_abort (void);
|
||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||
# else
|
||||
static void print_and_abort ();
|
||||
void (*obstack_alloc_failed_handler) () = print_and_abort;
|
||||
# endif
|
||||
|
||||
/* Exit value used when `print_and_abort' is used. */
|
||||
# if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
# endif
|
||||
int obstack_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* The non-GNU-C macros copy the obstack into this global variable
|
||||
to avoid multiple evaluation. */
|
||||
|
||||
struct obstack *_obstack;
|
||||
|
||||
/* Define a macro that either calls functions with the traditional malloc/free
|
||||
calling interface, or calls functions with the mmalloc/mfree interface
|
||||
(that adds an extra first argument), based on the state of use_extra_arg.
|
||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||
do not allow (expr) ? void : void. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
|
||||
|
||||
# define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
# else
|
||||
# define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
|
||||
|
||||
# define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
# endif
|
||||
|
||||
|
||||
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
|
||||
Objects start on multiples of ALIGNMENT (0 means use default).
|
||||
CHUNKFUN is the function to use to allocate chunks,
|
||||
and FREEFUN the function to free them.
|
||||
|
||||
Return nonzero if successful, calls obstack_alloc_failed_handler if
|
||||
allocation fails. */
|
||||
|
||||
int
|
||||
_obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
# if defined __STDC__ && __STDC__
|
||||
POINTER (*chunkfun) (long);
|
||||
void (*freefun) (void *);
|
||||
# else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
# endif
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
|
||||
Use the values for range checking, because if range checking is off,
|
||||
the extra bytes won't be missed terribly, but if range checking is on
|
||||
and we used a larger request, a whole extra 4096 bytes would be
|
||||
allocated.
|
||||
|
||||
These number are irrelevant to the new GNU malloc. I suspect it is
|
||||
less sensitive to the size of the request. */
|
||||
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
|
||||
+ 4 + DEFAULT_ROUNDING - 1)
|
||||
& ~(DEFAULT_ROUNDING - 1));
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
# else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
# endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->use_extra_arg = 0;
|
||||
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
/* The initial chunk now contains no empty object. */
|
||||
h->maybe_empty_object = 0;
|
||||
h->alloc_failed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
# if defined __STDC__ && __STDC__
|
||||
POINTER (*chunkfun) (POINTER, long);
|
||||
void (*freefun) (POINTER, POINTER);
|
||||
# else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
# endif
|
||||
POINTER arg;
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
|
||||
Use the values for range checking, because if range checking is off,
|
||||
the extra bytes won't be missed terribly, but if range checking is on
|
||||
and we used a larger request, a whole extra 4096 bytes would be
|
||||
allocated.
|
||||
|
||||
These number are irrelevant to the new GNU malloc. I suspect it is
|
||||
less sensitive to the size of the request. */
|
||||
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
|
||||
+ 4 + DEFAULT_ROUNDING - 1)
|
||||
& ~(DEFAULT_ROUNDING - 1));
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
# else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
# endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->extra_arg = arg;
|
||||
h->use_extra_arg = 1;
|
||||
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
/* The initial chunk now contains no empty object. */
|
||||
h->maybe_empty_object = 0;
|
||||
h->alloc_failed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Allocate a new current chunk for the obstack *H
|
||||
on the assumption that LENGTH bytes need to be added
|
||||
to the current object, or a new object of length LENGTH allocated.
|
||||
Copies any partial object from the end of the old chunk
|
||||
to the beginning of the new one. */
|
||||
|
||||
void
|
||||
_obstack_newchunk (h, length)
|
||||
struct obstack *h;
|
||||
int length;
|
||||
{
|
||||
register struct _obstack_chunk *old_chunk = h->chunk;
|
||||
register struct _obstack_chunk *new_chunk;
|
||||
register long new_size;
|
||||
register long obj_size = h->next_free - h->object_base;
|
||||
register long i;
|
||||
long already;
|
||||
char *object_base;
|
||||
|
||||
/* Compute size for new chunk. */
|
||||
new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100;
|
||||
if (new_size < h->chunk_size)
|
||||
new_size = h->chunk_size;
|
||||
|
||||
/* Allocate and initialize the new chunk. */
|
||||
new_chunk = CALL_CHUNKFUN (h, new_size);
|
||||
if (!new_chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->chunk = new_chunk;
|
||||
new_chunk->prev = old_chunk;
|
||||
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
|
||||
|
||||
/* Compute an aligned object_base in the new chunk */
|
||||
object_base =
|
||||
__INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask)
|
||||
& ~ (h->alignment_mask));
|
||||
|
||||
/* Move the existing object to the new chunk.
|
||||
Word at a time is fast and is safe if the object
|
||||
is sufficiently aligned. */
|
||||
if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
|
||||
{
|
||||
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
|
||||
i >= 0; i--)
|
||||
((COPYING_UNIT *)object_base)[i]
|
||||
= ((COPYING_UNIT *)h->object_base)[i];
|
||||
/* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
|
||||
but that can cross a page boundary on a machine
|
||||
which does not do strict alignment for COPYING_UNITS. */
|
||||
already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
|
||||
}
|
||||
else
|
||||
already = 0;
|
||||
/* Copy remaining bytes one by one. */
|
||||
for (i = already; i < obj_size; i++)
|
||||
object_base[i] = h->object_base[i];
|
||||
|
||||
/* If the object just copied was the only data in OLD_CHUNK,
|
||||
free that chunk and remove it from the chain.
|
||||
But not if that chunk might contain an empty object. */
|
||||
if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
|
||||
{
|
||||
new_chunk->prev = old_chunk->prev;
|
||||
CALL_FREEFUN (h, old_chunk);
|
||||
}
|
||||
|
||||
h->object_base = object_base;
|
||||
h->next_free = h->object_base + obj_size;
|
||||
/* The new chunk certainly contains no empty object yet. */
|
||||
h->maybe_empty_object = 0;
|
||||
}
|
||||
|
||||
/* Return nonzero if object OBJ has been allocated from obstack H.
|
||||
This is here for debugging.
|
||||
If you use it in a program, you are probably losing. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||
obstack.h because it is just for debugging. */
|
||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||
# endif
|
||||
|
||||
int
|
||||
_obstack_allocated_p (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = (h)->chunk;
|
||||
/* We use >= rather than > since the object cannot be exactly at
|
||||
the beginning of the chunk but might be an empty object exactly
|
||||
at the end of an adjacent chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
lp = plp;
|
||||
}
|
||||
return lp != 0;
|
||||
}
|
||||
|
||||
/* Free objects in obstack H, including OBJ and everything allocate
|
||||
more recently than OBJ. If OBJ is zero, free everything in H. */
|
||||
|
||||
# undef obstack_free
|
||||
|
||||
/* This function has two names with identical definitions.
|
||||
This is the first one, called from non-ANSI code. */
|
||||
|
||||
void
|
||||
_obstack_free (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = h->chunk;
|
||||
/* We use >= because there cannot be an object at the beginning of a chunk.
|
||||
But there can be an empty object at that address
|
||||
at the end of another chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
CALL_FREEFUN (h, lp);
|
||||
lp = plp;
|
||||
/* If we switch chunks, we can't tell whether the new current
|
||||
chunk contains an empty object, so assume that it may. */
|
||||
h->maybe_empty_object = 1;
|
||||
}
|
||||
if (lp)
|
||||
{
|
||||
h->object_base = h->next_free = (char *) (obj);
|
||||
h->chunk_limit = lp->limit;
|
||||
h->chunk = lp;
|
||||
}
|
||||
else if (obj != 0)
|
||||
/* obj is not in any of the chunks! */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This function is used from ANSI code. */
|
||||
|
||||
void
|
||||
obstack_free (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = h->chunk;
|
||||
/* We use >= because there cannot be an object at the beginning of a chunk.
|
||||
But there can be an empty object at that address
|
||||
at the end of another chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
CALL_FREEFUN (h, lp);
|
||||
lp = plp;
|
||||
/* If we switch chunks, we can't tell whether the new current
|
||||
chunk contains an empty object, so assume that it may. */
|
||||
h->maybe_empty_object = 1;
|
||||
}
|
||||
if (lp)
|
||||
{
|
||||
h->object_base = h->next_free = (char *) (obj);
|
||||
h->chunk_limit = lp->limit;
|
||||
h->chunk = lp;
|
||||
}
|
||||
else if (obj != 0)
|
||||
/* obj is not in any of the chunks! */
|
||||
abort ();
|
||||
}
|
||||
|
||||
int
|
||||
_obstack_memory_used (h)
|
||||
struct obstack *h;
|
||||
{
|
||||
register struct _obstack_chunk* lp;
|
||||
register int nbytes = 0;
|
||||
|
||||
for (lp = h->chunk; lp != 0; lp = lp->prev)
|
||||
{
|
||||
nbytes += lp->limit - (char *) lp;
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/* Define the error handler. */
|
||||
# ifndef _
|
||||
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
||||
# include <libintl.h>
|
||||
# ifndef _
|
||||
# define _(Str) gettext (Str)
|
||||
# endif
|
||||
# else
|
||||
# define _(Str) (Str)
|
||||
# endif
|
||||
# endif
|
||||
# if defined _LIBC && defined USE_IN_LIBIO
|
||||
# include <libio/iolibio.h>
|
||||
# define fputs(s, f) _IO_fputs (s, f)
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
static void
|
||||
__attribute__ ((noreturn))
|
||||
print_and_abort ()
|
||||
{
|
||||
/* Don't change any of these strings. Yes, it would be possible to add
|
||||
the newline to the string and use fputs or so. But this must not
|
||||
happen because the "memory exhausted" message appears in other places
|
||||
like this and the translation should be reused instead of creating
|
||||
a very similar string which requires a separate translation. */
|
||||
# if defined _LIBC && defined USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s\n", _("memory exhausted"));
|
||||
else
|
||||
# endif
|
||||
fprintf (stderr, "%s\n", _("memory exhausted"));
|
||||
exit (obstack_exit_failure);
|
||||
}
|
||||
|
||||
# if 0
|
||||
/* These are now turned off because the applications do not use it
|
||||
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
|
||||
|
||||
/* Now define the functional versions of the obstack macros.
|
||||
Define them to simply use the corresponding macros to do the job. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
/* These function definitions do not work with non-ANSI preprocessors;
|
||||
they won't pass through the macro names in parentheses. */
|
||||
|
||||
/* The function names appear in parentheses in order to prevent
|
||||
the macro-definitions of the names from being expanded there. */
|
||||
|
||||
POINTER (obstack_base) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_base (obstack);
|
||||
}
|
||||
|
||||
POINTER (obstack_next_free) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_next_free (obstack);
|
||||
}
|
||||
|
||||
int (obstack_object_size) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_object_size (obstack);
|
||||
}
|
||||
|
||||
int (obstack_room) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_room (obstack);
|
||||
}
|
||||
|
||||
int (obstack_make_room) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
return obstack_make_room (obstack, length);
|
||||
}
|
||||
|
||||
void (obstack_grow) (obstack, data, length)
|
||||
struct obstack *obstack;
|
||||
const POINTER data;
|
||||
int length;
|
||||
{
|
||||
obstack_grow (obstack, data, length);
|
||||
}
|
||||
|
||||
void (obstack_grow0) (obstack, data, length)
|
||||
struct obstack *obstack;
|
||||
const POINTER data;
|
||||
int length;
|
||||
{
|
||||
obstack_grow0 (obstack, data, length);
|
||||
}
|
||||
|
||||
void (obstack_1grow) (obstack, character)
|
||||
struct obstack *obstack;
|
||||
int character;
|
||||
{
|
||||
obstack_1grow (obstack, character);
|
||||
}
|
||||
|
||||
void (obstack_blank) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
obstack_blank (obstack, length);
|
||||
}
|
||||
|
||||
void (obstack_1grow_fast) (obstack, character)
|
||||
struct obstack *obstack;
|
||||
int character;
|
||||
{
|
||||
obstack_1grow_fast (obstack, character);
|
||||
}
|
||||
|
||||
void (obstack_blank_fast) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
obstack_blank_fast (obstack, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_finish) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_finish (obstack);
|
||||
}
|
||||
|
||||
POINTER (obstack_alloc) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
return obstack_alloc (obstack, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_copy) (obstack, address, length)
|
||||
struct obstack *obstack;
|
||||
const POINTER address;
|
||||
int length;
|
||||
{
|
||||
return obstack_copy (obstack, address, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_copy0) (obstack, address, length)
|
||||
struct obstack *obstack;
|
||||
const POINTER address;
|
||||
int length;
|
||||
{
|
||||
return obstack_copy0 (obstack, address, length);
|
||||
}
|
||||
|
||||
# endif /* __STDC__ */
|
||||
|
||||
# endif /* 0 */
|
||||
|
||||
#endif /* !ELIDE_CODE */
|
||||
-609
@@ -1,609 +0,0 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
/* Summary:
|
||||
|
||||
All the apparent functions defined here are macros. The idea
|
||||
is that you would use these pre-tested macros to solve a
|
||||
very specific set of problems, and they would run fast.
|
||||
Caution: no side-effects in arguments please!! They may be
|
||||
evaluated MANY times!!
|
||||
|
||||
These macros operate a stack of objects. Each object starts life
|
||||
small, and may grow to maturity. (Consider building a word syllable
|
||||
by syllable.) An object can move while it is growing. Once it has
|
||||
been "finished" it never changes address again. So the "top of the
|
||||
stack" is typically an immature growing object, while the rest of the
|
||||
stack is of mature, fixed size and fixed address objects.
|
||||
|
||||
These routines grab large chunks of memory, using a function you
|
||||
supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
|
||||
by calling `obstack_chunk_free'. You must define them and declare
|
||||
them before using any obstack macros.
|
||||
|
||||
Each independent stack is represented by a `struct obstack'.
|
||||
Each of the obstack macros expects a pointer to such a structure
|
||||
as the first argument.
|
||||
|
||||
One motivation for this package is the problem of growing char strings
|
||||
in symbol tables. Unless you are "fascist pig with a read-only mind"
|
||||
--Gosper's immortal quote from HAKMEM item 154, out of context--you
|
||||
would not like to put any arbitrary upper limit on the length of your
|
||||
symbols.
|
||||
|
||||
In practice this often means you will build many short symbols and a
|
||||
few long symbols. At the time you are reading a symbol you don't know
|
||||
how long it is. One traditional method is to read a symbol into a
|
||||
buffer, realloc()ating the buffer every time you try to read a symbol
|
||||
that is longer than the buffer. This is beaut, but you still will
|
||||
want to copy the symbol from the buffer to a more permanent
|
||||
symbol-table entry say about half the time.
|
||||
|
||||
With obstacks, you can work differently. Use one obstack for all symbol
|
||||
names. As you read a symbol, grow the name in the obstack gradually.
|
||||
When the name is complete, finalize it. Then, if the symbol exists already,
|
||||
free the newly read name.
|
||||
|
||||
The way we do this is to take a large chunk, allocating memory from
|
||||
low addresses. When you want to build a symbol in the chunk you just
|
||||
add chars above the current "high water mark" in the chunk. When you
|
||||
have finished adding chars, because you got to the end of the symbol,
|
||||
you know how long the chars are, and you can create a new object.
|
||||
Mostly the chars will not burst over the highest address of the chunk,
|
||||
because you would typically expect a chunk to be (say) 100 times as
|
||||
long as an average object.
|
||||
|
||||
In case that isn't clear, when we have enough chars to make up
|
||||
the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
|
||||
so we just point to it where it lies. No moving of chars is
|
||||
needed and this is the second win: potentially long strings need
|
||||
never be explicitly shuffled. Once an object is formed, it does not
|
||||
change its address during its lifetime.
|
||||
|
||||
When the chars burst over a chunk boundary, we allocate a larger
|
||||
chunk, and then copy the partly formed object from the end of the old
|
||||
chunk to the beginning of the new larger chunk. We then carry on
|
||||
accreting characters to the end of the object as we normally would.
|
||||
|
||||
A special macro is provided to add a single char at a time to a
|
||||
growing object. This allows the use of register variables, which
|
||||
break the ordinary 'growth' macro.
|
||||
|
||||
Summary:
|
||||
We allocate large chunks.
|
||||
We carve out one object at a time from the current chunk.
|
||||
Once carved, an object never moves.
|
||||
We are free to append data of any size to the currently
|
||||
growing object.
|
||||
Exactly one object is growing in an obstack at any one time.
|
||||
You can run one obstack per control block.
|
||||
You may have as many control blocks as you dare.
|
||||
Because of the way we do it, you can `unwind' an obstack
|
||||
back to a previous state. (You may remove objects much
|
||||
as you would with a stack.)
|
||||
*/
|
||||
|
||||
|
||||
/* Don't do the contents of this file more than once. */
|
||||
|
||||
#ifndef _OBSTACK_H
|
||||
#define _OBSTACK_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* We use subtraction of (char *) 0 instead of casting to int
|
||||
because on word-addressable machines a simple cast to int
|
||||
may ignore the byte-within-word field of the pointer. */
|
||||
|
||||
#ifndef __PTR_TO_INT
|
||||
# define __PTR_TO_INT(P) ((P) - (char *) 0)
|
||||
#endif
|
||||
|
||||
#ifndef __INT_TO_PTR
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
#endif
|
||||
|
||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||
defined, as with GNU C, use that; that way we don't pollute the
|
||||
namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is
|
||||
available, include it and use ptrdiff_t. In traditional C, long is
|
||||
the best that we can do. */
|
||||
|
||||
#ifdef __PTRDIFF_TYPE__
|
||||
# define PTR_INT_TYPE __PTRDIFF_TYPE__
|
||||
#else
|
||||
# ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
# define PTR_INT_TYPE ptrdiff_t
|
||||
# else
|
||||
# define PTR_INT_TYPE long
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
#else
|
||||
# ifdef memcpy
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
# else
|
||||
# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct _obstack_chunk /* Lives at front of each chunk. */
|
||||
{
|
||||
char *limit; /* 1 past end of this chunk */
|
||||
struct _obstack_chunk *prev; /* address of prior chunk or NULL */
|
||||
char contents[4]; /* objects begin here */
|
||||
};
|
||||
|
||||
struct obstack /* control current object in current chunk */
|
||||
{
|
||||
long chunk_size; /* preferred size to allocate chunks in */
|
||||
struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
|
||||
char *object_base; /* address of object we are building */
|
||||
char *next_free; /* where to add next char to current object */
|
||||
char *chunk_limit; /* address of char after current chunk */
|
||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||
int alignment_mask; /* Mask of alignment for each object. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
/* These prototypes vary based on `use_extra_arg', and we use
|
||||
casts to the prototypeless function type in all assignments,
|
||||
but having prototypes here quiets -Wstrict-prototypes. */
|
||||
struct _obstack_chunk *(*chunkfun) (void *, long);
|
||||
void (*freefun) (void *, struct _obstack_chunk *);
|
||||
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
|
||||
#else
|
||||
struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
|
||||
void (*freefun) (); /* User's function to free a chunk. */
|
||||
char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
|
||||
#endif
|
||||
unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
|
||||
unsigned maybe_empty_object:1;/* There is a possibility that the current
|
||||
chunk contains a zero-length object. This
|
||||
prevents freeing the chunk if we allocate
|
||||
a bigger chunk to replace it. */
|
||||
unsigned alloc_failed:1; /* No longer used, as we now call the failed
|
||||
handler on error, but retained for binary
|
||||
compatibility. */
|
||||
};
|
||||
|
||||
/* Declare the external functions we use; they are in obstack.c. */
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void _obstack_newchunk (struct obstack *, int);
|
||||
extern void _obstack_free (struct obstack *, void *);
|
||||
extern int _obstack_begin (struct obstack *, int, int,
|
||||
void *(*) (long), void (*) (void *));
|
||||
extern int _obstack_begin_1 (struct obstack *, int, int,
|
||||
void *(*) (void *, long),
|
||||
void (*) (void *, void *), void *);
|
||||
extern int _obstack_memory_used (struct obstack *);
|
||||
#else
|
||||
extern void _obstack_newchunk ();
|
||||
extern void _obstack_free ();
|
||||
extern int _obstack_begin ();
|
||||
extern int _obstack_begin_1 ();
|
||||
extern int _obstack_memory_used ();
|
||||
#endif
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
/* Do the function-declarations after the structs
|
||||
but before defining the macros. */
|
||||
|
||||
void obstack_init (struct obstack *obstack);
|
||||
|
||||
void * obstack_alloc (struct obstack *obstack, int size);
|
||||
|
||||
void * obstack_copy (struct obstack *obstack, const void *address, int size);
|
||||
void * obstack_copy0 (struct obstack *obstack, const void *address, int size);
|
||||
|
||||
void obstack_free (struct obstack *obstack, void *block);
|
||||
|
||||
void obstack_blank (struct obstack *obstack, int size);
|
||||
|
||||
void obstack_grow (struct obstack *obstack, const void *data, int size);
|
||||
void obstack_grow0 (struct obstack *obstack, const void *data, int size);
|
||||
|
||||
void obstack_1grow (struct obstack *obstack, int data_char);
|
||||
void obstack_ptr_grow (struct obstack *obstack, const void *data);
|
||||
void obstack_int_grow (struct obstack *obstack, int data);
|
||||
|
||||
void * obstack_finish (struct obstack *obstack);
|
||||
|
||||
int obstack_object_size (struct obstack *obstack);
|
||||
|
||||
int obstack_room (struct obstack *obstack);
|
||||
void obstack_make_room (struct obstack *obstack, int size);
|
||||
void obstack_1grow_fast (struct obstack *obstack, int data_char);
|
||||
void obstack_ptr_grow_fast (struct obstack *obstack, const void *data);
|
||||
void obstack_int_grow_fast (struct obstack *obstack, int data);
|
||||
void obstack_blank_fast (struct obstack *obstack, int size);
|
||||
|
||||
void * obstack_base (struct obstack *obstack);
|
||||
void * obstack_next_free (struct obstack *obstack);
|
||||
int obstack_alignment_mask (struct obstack *obstack);
|
||||
int obstack_chunk_size (struct obstack *obstack);
|
||||
int obstack_memory_used (struct obstack *obstack);
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
/* Non-ANSI C cannot really support alternative functions for these macros,
|
||||
so we do not declare them. */
|
||||
|
||||
/* Error handler called when `obstack_chunk_alloc' failed to allocate
|
||||
more memory. This can be set to a user defined function which
|
||||
should either abort gracefully or use longjump - but shouldn't
|
||||
return. The default action is to print a message and abort. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void (*obstack_alloc_failed_handler) (void);
|
||||
#else
|
||||
extern void (*obstack_alloc_failed_handler) ();
|
||||
#endif
|
||||
|
||||
/* Exit value used when `print_and_abort' is used. */
|
||||
extern int obstack_exit_failure;
|
||||
|
||||
/* Pointer to beginning of object being allocated or to be allocated next.
|
||||
Note that this might not be the final address of the object
|
||||
because a new chunk might be needed to hold the final size. */
|
||||
|
||||
#define obstack_base(h) ((h)->object_base)
|
||||
|
||||
/* Size for allocating ordinary chunks. */
|
||||
|
||||
#define obstack_chunk_size(h) ((h)->chunk_size)
|
||||
|
||||
/* Pointer to next byte not yet allocated in current chunk. */
|
||||
|
||||
#define obstack_next_free(h) ((h)->next_free)
|
||||
|
||||
/* Mask specifying low bits that should be clear in address of an object. */
|
||||
|
||||
#define obstack_alignment_mask(h) ((h)->alignment_mask)
|
||||
|
||||
/* To prevent prototype warnings provide complete argument list in
|
||||
standard C version. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, \
|
||||
(void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, \
|
||||
(void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) (long)) (chunkfun), \
|
||||
(void (*) (void *)) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) (void *, long)) (chunkfun), \
|
||||
(void (*) (void *, void *)) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
|
||||
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
|
||||
|
||||
#else
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, \
|
||||
(void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, \
|
||||
(void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), \
|
||||
(void (*) ()) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), \
|
||||
(void (*) ()) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
|
||||
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)()) (newfreefun))
|
||||
|
||||
#endif
|
||||
|
||||
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
|
||||
|
||||
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
|
||||
|
||||
#define obstack_memory_used(h) _obstack_memory_used (h)
|
||||
|
||||
#if defined __GNUC__ && defined __STDC__ && __STDC__
|
||||
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
|
||||
does not implement __extension__. But that compiler doesn't define
|
||||
__GNUC_MINOR__. */
|
||||
# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
|
||||
# define __extension__
|
||||
# endif
|
||||
|
||||
/* For GNU C, if not -traditional,
|
||||
we can define these macros to compute all args only once
|
||||
without using a global variable.
|
||||
Also, we can avoid using the `temp' slot, to make faster code. */
|
||||
|
||||
# define obstack_object_size(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->next_free - __o->object_base); })
|
||||
|
||||
# define obstack_room(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->chunk_limit - __o->next_free); })
|
||||
|
||||
# define obstack_make_room(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->chunk_limit - __o->next_free < __len) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_empty_p(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
|
||||
|
||||
# define obstack_grow(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
_obstack_memcpy (__o->next_free, (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_grow0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len + 1); \
|
||||
_obstack_memcpy (__o->next_free, (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
*(__o->next_free)++ = 0; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_1grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, 1); \
|
||||
*(__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
/* These assume that the obstack alignment is good enough for pointers
|
||||
or ints, and that the data added so far to the current object
|
||||
shares that much alignment. */
|
||||
|
||||
# define obstack_ptr_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (void *)); \
|
||||
*((void **)__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_int_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (int)); \
|
||||
*((int *)__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) \
|
||||
(*((void **) (h)->next_free)++ = (aptr))
|
||||
|
||||
# define obstack_int_grow_fast(h,aint) \
|
||||
(*((int *) (h)->next_free)++ = (aint))
|
||||
|
||||
# define obstack_blank(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->chunk_limit - __o->next_free < __len) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_alloc(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_blank (__h, (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
# define obstack_copy(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow (__h, (where), (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
# define obstack_copy0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow0 (__h, (where), (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
/* The local variable is named __o1 to avoid a name conflict
|
||||
when obstack_blank is called. */
|
||||
# define obstack_finish(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o1 = (OBSTACK); \
|
||||
void *value; \
|
||||
value = (void *) __o1->object_base; \
|
||||
if (__o1->next_free == value) \
|
||||
__o1->maybe_empty_object = 1; \
|
||||
__o1->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
|
||||
& ~ (__o1->alignment_mask)); \
|
||||
if (__o1->next_free - (char *)__o1->chunk \
|
||||
> __o1->chunk_limit - (char *)__o1->chunk) \
|
||||
__o1->next_free = __o1->chunk_limit; \
|
||||
__o1->object_base = __o1->next_free; \
|
||||
value; })
|
||||
|
||||
# define obstack_free(OBSTACK, OBJ) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
void *__obj = (OBJ); \
|
||||
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
|
||||
__o->next_free = __o->object_base = (char *)__obj; \
|
||||
else (obstack_free) (__o, __obj); })
|
||||
|
||||
#else /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
# define obstack_object_size(h) \
|
||||
(unsigned) ((h)->next_free - (h)->object_base)
|
||||
|
||||
# define obstack_room(h) \
|
||||
(unsigned) ((h)->chunk_limit - (h)->next_free)
|
||||
|
||||
# define obstack_empty_p(h) \
|
||||
((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
|
||||
|
||||
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
|
||||
so that we can avoid having void expressions
|
||||
in the arms of the conditional expression.
|
||||
Casting the third operand to void was tried before,
|
||||
but some compilers won't accept it. */
|
||||
|
||||
# define obstack_make_room(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
|
||||
|
||||
# define obstack_grow(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp)
|
||||
|
||||
# define obstack_grow0(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp, \
|
||||
*((h)->next_free)++ = 0)
|
||||
|
||||
# define obstack_1grow(h,datum) \
|
||||
( (((h)->next_free + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), 1), 0) : 0), \
|
||||
(*((h)->next_free)++ = (datum)))
|
||||
|
||||
# define obstack_ptr_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
|
||||
(*((const char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = (datum)))
|
||||
|
||||
# define obstack_int_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = (datum)))
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) \
|
||||
(*((const char **) (h)->next_free)++ = (aptr))
|
||||
|
||||
# define obstack_int_grow_fast(h,aint) \
|
||||
(*((int *) (h)->next_free)++ = (aint))
|
||||
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
((h)->next_free += (h)->temp))
|
||||
|
||||
# define obstack_alloc(h,length) \
|
||||
(obstack_blank ((h), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_copy(h,where,length) \
|
||||
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_copy0(h,where,length) \
|
||||
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_finish(h) \
|
||||
( ((h)->next_free == (h)->object_base \
|
||||
? (((h)->maybe_empty_object = 1), 0) \
|
||||
: 0), \
|
||||
(h)->temp = __PTR_TO_INT ((h)->object_base), \
|
||||
(h)->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
|
||||
& ~ ((h)->alignment_mask)), \
|
||||
(((h)->next_free - (char *) (h)->chunk \
|
||||
> (h)->chunk_limit - (char *) (h)->chunk) \
|
||||
? ((h)->next_free = (h)->chunk_limit) : 0), \
|
||||
(h)->object_base = (h)->next_free, \
|
||||
__INT_TO_PTR ((h)->temp))
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
|
||||
# else
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
|
||||
# endif
|
||||
|
||||
#endif /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C++ */
|
||||
#endif
|
||||
|
||||
#endif /* obstack.h */
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/* quote.c - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* Return an unambiguous printable representated, allocated in slot N,
|
||||
for NAME, suitable for diagnostics. */
|
||||
char const *
|
||||
quote_n (int n, char const *name)
|
||||
{
|
||||
return quotearg_n_style (n, locale_quoting_style, name);
|
||||
}
|
||||
|
||||
/* Return an unambiguous printable representation of NAME, suitable
|
||||
for diagnostics. */
|
||||
char const *
|
||||
quote (char const *name)
|
||||
{
|
||||
return quote_n (0, name);
|
||||
}
|
||||
-635
@@ -1,635 +0,0 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include "quotearg.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(text) gettext (text)
|
||||
#else
|
||||
# define _(text) text
|
||||
#endif
|
||||
#define N_(text) text
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX ((unsigned char) -1)
|
||||
#endif
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) -1)
|
||||
#endif
|
||||
|
||||
#if HAVE_C_BACKSLASH_A
|
||||
# define ALERT_CHAR '\a'
|
||||
#else
|
||||
# define ALERT_CHAR '\7'
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_WCHAR_H
|
||||
|
||||
/* BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared. */
|
||||
# include <stdio.h>
|
||||
# include <time.h>
|
||||
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_MBRTOWC
|
||||
/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the
|
||||
other macros are defined only for documentation and to satisfy C
|
||||
syntax. */
|
||||
# undef MB_CUR_MAX
|
||||
# define MB_CUR_MAX 1
|
||||
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
||||
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
|
||||
# undef HAVE_MBSINIT
|
||||
#endif
|
||||
|
||||
#if !defined mbsinit && !HAVE_MBSINIT
|
||||
# define mbsinit(ps) 1
|
||||
#endif
|
||||
|
||||
#ifndef iswprint
|
||||
# if HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
# endif
|
||||
# if !defined iswprint && !HAVE_ISWPRINT
|
||||
# define iswprint(wc) 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
|
||||
#undef ISPRINT
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
|
||||
struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Quote the characters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
|
||||
};
|
||||
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal",
|
||||
"shell",
|
||||
"shell-always",
|
||||
"c",
|
||||
"escape",
|
||||
"locale",
|
||||
"clocale",
|
||||
0
|
||||
};
|
||||
|
||||
/* Correspondences to quoting style names. */
|
||||
enum quoting_style const quoting_style_vals[] =
|
||||
{
|
||||
literal_quoting_style,
|
||||
shell_quoting_style,
|
||||
shell_always_quoting_style,
|
||||
c_quoting_style,
|
||||
escape_quoting_style,
|
||||
locale_quoting_style,
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* The default quoting options. */
|
||||
static struct quoting_options default_quoting_options;
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *
|
||||
clone_quoting_options (struct quoting_options *o)
|
||||
{
|
||||
struct quoting_options *p
|
||||
= (struct quoting_options *) xmalloc (sizeof (struct quoting_options));
|
||||
*p = *(o ? o : &default_quoting_options);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style
|
||||
get_quoting_style (struct quoting_options *o)
|
||||
{
|
||||
return (o ? o : &default_quoting_options)->style;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void
|
||||
set_quoting_style (struct quoting_options *o, enum quoting_style s)
|
||||
{
|
||||
(o ? o : &default_quoting_options)->style = s;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int
|
||||
set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
{
|
||||
unsigned char uc = c;
|
||||
int *p = (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
|
||||
int shift = uc % INT_BITS;
|
||||
int r = (*p >> shift) & 1;
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* MSGID approximates a quotation mark. Return its translation if it
|
||||
has one; otherwise, return either it or "\"", depending on S. */
|
||||
static char const *
|
||||
gettext_quote (char const *msgid, enum quoting_style s)
|
||||
{
|
||||
char const *translation = _(msgid);
|
||||
if (translation == msgid && s == clocale_quoting_style)
|
||||
translation = "\"";
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using QUOTING_STYLE and the
|
||||
non-quoting-style part of O to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
|
||||
|
||||
This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
|
||||
ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting
|
||||
style specified by O, and O may not be null. */
|
||||
|
||||
static size_t
|
||||
quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
enum quoting_style quoting_style,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = 0;
|
||||
char const *quote_string = 0;
|
||||
size_t quote_string_len = 0;
|
||||
int backslash_escapes = 0;
|
||||
int unibyte_locale = MB_CUR_MAX == 1;
|
||||
|
||||
#define STORE(c) \
|
||||
do \
|
||||
{ \
|
||||
if (len < buffersize) \
|
||||
buffer[len] = (c); \
|
||||
len++; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case c_quoting_style:
|
||||
STORE ('"');
|
||||
backslash_escapes = 1;
|
||||
quote_string = "\"";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case escape_quoting_style:
|
||||
backslash_escapes = 1;
|
||||
break;
|
||||
|
||||
case locale_quoting_style:
|
||||
case clocale_quoting_style:
|
||||
{
|
||||
/* Get translations for open and closing quotation marks.
|
||||
|
||||
The message catalog should translate "`" to a left
|
||||
quotation mark suitable for the locale, and similarly for
|
||||
"'". If the catalog has no translation,
|
||||
locale_quoting_style quotes `like this', and
|
||||
clocale_quoting_style quotes "like this".
|
||||
|
||||
For example, an American English Unicode locale should
|
||||
translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
|
||||
should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
|
||||
MARK). A British English Unicode locale should instead
|
||||
translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and
|
||||
U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. */
|
||||
|
||||
char const *left = gettext_quote (N_("`"), quoting_style);
|
||||
char const *right = gettext_quote (N_("'"), quoting_style);
|
||||
for (quote_string = left; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
backslash_escapes = 1;
|
||||
quote_string = right;
|
||||
quote_string_len = strlen (quote_string);
|
||||
}
|
||||
break;
|
||||
|
||||
case shell_always_quoting_style:
|
||||
STORE ('\'');
|
||||
quote_string = "'";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned char esc;
|
||||
|
||||
if (backslash_escapes
|
||||
&& quote_string_len
|
||||
&& i + quote_string_len <= argsize
|
||||
&& memcmp (arg + i, quote_string, quote_string_len) == 0)
|
||||
STORE ('\\');
|
||||
|
||||
c = arg[i];
|
||||
switch (c)
|
||||
{
|
||||
case '?':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
goto use_shell_always_quoting_style;
|
||||
|
||||
case c_quoting_style:
|
||||
if (i + 2 < argsize && arg[i + 1] == '?')
|
||||
switch (arg[i + 2])
|
||||
{
|
||||
case '!': case '\'':
|
||||
case '(': case ')': case '-': case '/':
|
||||
case '<': case '=': case '>':
|
||||
/* Escape the second '?' in what would otherwise be
|
||||
a trigraph. */
|
||||
i += 2;
|
||||
c = arg[i + 2];
|
||||
STORE ('?');
|
||||
STORE ('\\');
|
||||
STORE ('?');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ALERT_CHAR: esc = 'a'; goto c_escape;
|
||||
case '\b': esc = 'b'; goto c_escape;
|
||||
case '\f': esc = 'f'; goto c_escape;
|
||||
case '\n': esc = 'n'; goto c_and_shell_escape;
|
||||
case '\r': esc = 'r'; goto c_and_shell_escape;
|
||||
case '\t': esc = 't'; goto c_and_shell_escape;
|
||||
case '\v': esc = 'v'; goto c_escape;
|
||||
case '\\': esc = c; goto c_and_shell_escape;
|
||||
|
||||
c_and_shell_escape:
|
||||
if (quoting_style == shell_quoting_style)
|
||||
goto use_shell_always_quoting_style;
|
||||
c_escape:
|
||||
if (backslash_escapes)
|
||||
{
|
||||
c = esc;
|
||||
goto store_escape;
|
||||
}
|
||||
break;
|
||||
|
||||
case '#': case '~':
|
||||
if (i != 0)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case ' ':
|
||||
case '!': /* special in bash */
|
||||
case '"': case '$': case '&':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '[':
|
||||
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
/* A shell special character. In theory, '$' and '`' could
|
||||
be the first bytes of multibyte characters, which means
|
||||
we should check them with mbrtowc, but in practice this
|
||||
doesn't happen so it's not worth worrying about. */
|
||||
if (quoting_style == shell_quoting_style)
|
||||
goto use_shell_always_quoting_style;
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
goto use_shell_always_quoting_style;
|
||||
|
||||
case shell_always_quoting_style:
|
||||
STORE ('\'');
|
||||
STORE ('\\');
|
||||
STORE ('\'');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%': case '+': case ',': case '-': case '.': case '/':
|
||||
case '0': case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9': case ':': case '=':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
|
||||
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
|
||||
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
||||
case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
|
||||
case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
|
||||
case 'o': case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||
case '{': case '}':
|
||||
/* These characters don't cause problems, no matter what the
|
||||
quoting style is. They cannot start multibyte sequences. */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* If we have a multibyte sequence, copy it until we reach
|
||||
its end, find an error, or come back to the initial shift
|
||||
state. For C-like styles, if the sequence has
|
||||
unprintable characters, escape the whole sequence, since
|
||||
we can't easily escape single characters within it. */
|
||||
{
|
||||
/* Length of multibyte sequence found so far. */
|
||||
size_t m;
|
||||
|
||||
int printable;
|
||||
|
||||
if (unibyte_locale)
|
||||
{
|
||||
m = 1;
|
||||
printable = ISPRINT (c);
|
||||
}
|
||||
else
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
|
||||
m = 0;
|
||||
printable = 1;
|
||||
if (argsize == (size_t) -1)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = 0;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! iswprint (w))
|
||||
printable = 0;
|
||||
m += bytes;
|
||||
}
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
|
||||
if (1 < m || (backslash_escapes && ! printable))
|
||||
{
|
||||
/* Output a multibyte sequence, or an escaped
|
||||
unprintable unibyte character. */
|
||||
size_t ilim = i + m;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (backslash_escapes && ! printable)
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
}
|
||||
if (ilim <= i + 1)
|
||||
break;
|
||||
STORE (c);
|
||||
c = arg[++i];
|
||||
}
|
||||
|
||||
goto store_c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! (backslash_escapes
|
||||
&& o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
store_escape:
|
||||
STORE ('\\');
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (quote_string)
|
||||
for (; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
|
||||
if (len < buffersize)
|
||||
buffer[len] = '\0';
|
||||
return len;
|
||||
|
||||
use_shell_always_quoting_style:
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
shell_always_quoting_style, o);
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
p->style, p);
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. N is deliberately declared with type "int"
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
one small component of a "memory exhausted" message in slot 0. */
|
||||
static char slot0[256];
|
||||
static unsigned int nslots = 1;
|
||||
unsigned int n0 = n;
|
||||
struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
};
|
||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||
static struct slotvec *slotvec = &slotvec0;
|
||||
|
||||
if (n < 0)
|
||||
abort ();
|
||||
|
||||
if (nslots <= n0)
|
||||
{
|
||||
unsigned int n1 = n0 + 1;
|
||||
size_t s = n1 * sizeof *slotvec;
|
||||
|
||||
if (SIZE_MAX / UINT_MAX <= sizeof *slotvec
|
||||
&& n1 != s / sizeof *slotvec)
|
||||
xalloc_die ();
|
||||
|
||||
if (slotvec == &slotvec0)
|
||||
{
|
||||
slotvec = (struct slotvec *) xmalloc (sizeof *slotvec);
|
||||
*slotvec = slotvec0;
|
||||
}
|
||||
slotvec = (struct slotvec *) xrealloc (slotvec, s);
|
||||
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof *slotvec);
|
||||
nslots = n1;
|
||||
}
|
||||
|
||||
{
|
||||
size_t size = slotvec[n].size;
|
||||
char *val = slotvec[n].val;
|
||||
size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
slotvec[n].size = size = qsize + 1;
|
||||
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
||||
quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = s;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return quotearg_n_options (n, arg, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style (enum quoting_style s, char const *arg)
|
||||
{
|
||||
return quotearg_n_style (0, s, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
struct quoting_options options;
|
||||
options = default_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
/* Basic quoting styles. */
|
||||
enum quoting_style
|
||||
{
|
||||
literal_quoting_style, /* --quoting-style=literal */
|
||||
shell_quoting_style, /* --quoting-style=shell */
|
||||
shell_always_quoting_style, /* --quoting-style=shell-always */
|
||||
c_quoting_style, /* --quoting-style=c */
|
||||
escape_quoting_style, /* --quoting-style=escape */
|
||||
locale_quoting_style, /* --quoting-style=locale */
|
||||
clocale_quoting_style /* --quoting-style=clocale */
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
#ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
#endif
|
||||
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || defined __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The functions listed below set and use a hidden variable
|
||||
that contains the default quoting style options. */
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *clone_quoting_options
|
||||
PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void set_quoting_style PARAMS ((struct quoting_options *o,
|
||||
enum quoting_style s));
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o));
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
Use the default quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
char *quotearg_n PARAMS ((int n, char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg PARAMS ((char const *arg));
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the string ARG.
|
||||
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style PARAMS ((int n, enum quoting_style s, char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style PARAMS ((enum quoting_style s, char const *arg));
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char PARAMS ((char const *arg, char ch));
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon PARAMS ((char const *arg));
|
||||
@@ -1,96 +0,0 @@
|
||||
/* Open a pipe to read from a program without intermediary sh.
|
||||
Copyright (C) 1992, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Open a pipe to read from a program without intermediary sh. Checks
|
||||
PATH. Sample use:
|
||||
|
||||
stream = readpipe ("progname", "arg1", "arg2", (char *) 0);
|
||||
|
||||
Return 0 on error. */
|
||||
|
||||
#if __STDC__
|
||||
FILE *
|
||||
readpipe (char *progname, ...)
|
||||
#else
|
||||
FILE *
|
||||
readpipe (va_alist)
|
||||
#endif
|
||||
{
|
||||
#if ! __STDC__
|
||||
char *progname;
|
||||
#endif
|
||||
int fds[2];
|
||||
va_list ap;
|
||||
char *args[100];
|
||||
int argno = 0;
|
||||
|
||||
/* Copy arguments into `args'. */
|
||||
#if __STDC__
|
||||
va_start (ap, progname);
|
||||
#else
|
||||
va_start (ap);
|
||||
progname = va_arg (ap, char *);
|
||||
#endif
|
||||
args[argno++] = progname;
|
||||
while ((args[argno++] = va_arg (ap, char *)) != NULL)
|
||||
;
|
||||
va_end (ap);
|
||||
|
||||
if (pipe (fds) == -1)
|
||||
return 0;
|
||||
|
||||
switch (fork ())
|
||||
{
|
||||
case 0: /* Child. Write to pipe. */
|
||||
close (fds[0]); /* Not needed. */
|
||||
if (fds[1] != 1) /* Redirect 1 (stdout) only if needed. */
|
||||
{
|
||||
close (1); /* We don't want the old stdout. */
|
||||
if (dup (fds[1]) == 0)/* Maybe stdin was closed. */
|
||||
{
|
||||
dup (fds[1]); /* Guaranteed to dup to 1 (stdout). */
|
||||
close (0);
|
||||
}
|
||||
close (fds[1]); /* No longer needed. */
|
||||
}
|
||||
execvp (args[0], args);
|
||||
_exit (2); /* 2 for `cmp'. */
|
||||
case -1: /* Error. */
|
||||
return 0;
|
||||
default: /* Parent. Read from pipe. */
|
||||
close (fds[1]); /* Not needed. */
|
||||
return fdopen (fds[0], "r");
|
||||
}
|
||||
}
|
||||
-672
@@ -1,672 +0,0 @@
|
||||
/* Simple bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "sbitset.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This file implements fixed size bitsets stored as an array
|
||||
of words. Any unused bits in the last word must be zero. */
|
||||
|
||||
typedef struct sbitset_struct
|
||||
{
|
||||
unsigned int n_bits; /* Number of bits. */
|
||||
bitset_word words[1]; /* The array of bits. */
|
||||
}
|
||||
*sbitset;
|
||||
|
||||
|
||||
struct bitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
struct sbitset_struct s;
|
||||
};
|
||||
|
||||
static void sbitset_unused_clear PARAMS ((bitset));
|
||||
|
||||
static int sbitset_small_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
|
||||
static void sbitset_set PARAMS ((bitset, bitset_bindex));
|
||||
static void sbitset_reset PARAMS ((bitset, bitset_bindex));
|
||||
static int sbitset_test PARAMS ((bitset, bitset_bindex));
|
||||
static int sbitset_size PARAMS ((bitset));
|
||||
static int sbitset_op1 PARAMS ((bitset, enum bitset_ops));
|
||||
static int sbitset_op2 PARAMS ((bitset, bitset, enum bitset_ops));
|
||||
static int sbitset_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));
|
||||
static int sbitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
enum bitset_ops));
|
||||
static int sbitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
static int sbitset_reverse_list
|
||||
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
|
||||
|
||||
#define SBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||
#define SBITSET_WORDS(X) ((X)->s.words)
|
||||
#define SBITSET_N_BITS(X) ((X)->s.n_bits)
|
||||
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
static int
|
||||
sbitset_size (src)
|
||||
bitset src;
|
||||
{
|
||||
return SBITSET_N_BITS (src);
|
||||
}
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static int
|
||||
sbitset_small_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
bitset_word word;
|
||||
|
||||
word = SBITSET_WORDS (src)[0];
|
||||
|
||||
/* Short circuit common case. */
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
size = SBITSET_N_BITS (src);
|
||||
bitno = *next;
|
||||
if (bitno >= size)
|
||||
return 0;
|
||||
|
||||
word >>= bitno;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
if (num >= BITSET_WORD_BITS)
|
||||
{
|
||||
for (count = 0; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (count = 0; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
bitno++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
*next = bitno;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
static void
|
||||
sbitset_set (dst, bitno)
|
||||
bitset dst ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
static void
|
||||
sbitset_reset (dst, bitno)
|
||||
bitset dst ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static int
|
||||
sbitset_test (src, bitno)
|
||||
bitset src ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET in reverse order, starting
|
||||
from and including NEXT and store in array LIST. Return with
|
||||
actual number of bits found and with *NEXT indicating where search
|
||||
stopped. */
|
||||
static int
|
||||
sbitset_reverse_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex rbitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
unsigned int bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word word;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_bindex n_bits = SBITSET_N_BITS (src);
|
||||
|
||||
rbitno = *next;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the word of interest. */
|
||||
|
||||
if (rbitno >= n_bits)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
|
||||
bitno = n_bits - (rbitno + 1);
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
|
||||
for (; windex != ~0U; windex--, bitoff -= BITSET_WORD_BITS,
|
||||
bitcnt = BITSET_WORD_BITS - 1)
|
||||
{
|
||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
for (; word; bitcnt--)
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
{
|
||||
list[count++] = bitoff + bitcnt;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = n_bits - (bitoff + bitcnt);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
*next = n_bits - (bitoff + 1);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static int
|
||||
sbitset_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
bitset_bindex bitno;
|
||||
bitset_bindex count;
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_windex size = src->b.csize;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_word word;
|
||||
|
||||
bitno = *next;
|
||||
|
||||
count = 0;
|
||||
if (!bitno)
|
||||
{
|
||||
/* Many bitsets are zero, so make this common case fast. */
|
||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||
continue;
|
||||
if (windex >= size)
|
||||
return 0;
|
||||
|
||||
/* If num is 1, we could speed things up with a binary search
|
||||
of the current word. */
|
||||
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bitno >= SBITSET_N_BITS (src))
|
||||
return 0;
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
bitno = bitno % BITSET_WORD_BITS;
|
||||
|
||||
if (bitno)
|
||||
{
|
||||
/* Handle the case where we start within a word.
|
||||
Most often, this is executed with large bitsets
|
||||
with many set bits where we filled the array
|
||||
on the previous call to this function. */
|
||||
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
word = srcp[windex] >> bitno;
|
||||
for (bitno = bitoff + bitno; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = bitno + 1;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
windex++;
|
||||
}
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
}
|
||||
|
||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||
{
|
||||
if (!(word = srcp[windex]))
|
||||
continue;
|
||||
|
||||
if ((count + BITSET_WORD_BITS) < num)
|
||||
{
|
||||
for (bitno = bitoff; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (bitno = bitoff; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
{
|
||||
list[count++] = bitno;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = bitno + 1;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*next = bitoff;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure that any unused bits within the last word are clear. */
|
||||
static inline void
|
||||
sbitset_unused_clear (dst)
|
||||
bitset dst;
|
||||
{
|
||||
unsigned int last_bit;
|
||||
|
||||
last_bit = SBITSET_N_BITS (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
SBITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
(bitset_word) ((1 << last_bit) - 1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op1 (dst, op)
|
||||
bitset dst;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
unsigned int bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_ZERO:
|
||||
memset (dstp, 0, bytes);
|
||||
break;
|
||||
|
||||
case BITSET_OP_ONES:
|
||||
memset (dstp, ~0, bytes);
|
||||
sbitset_unused_clear (dst);
|
||||
break;
|
||||
|
||||
case BITSET_OP_EMPTY_P:
|
||||
for (i = 0; i < dst->b.csize; i++)
|
||||
if (dstp[i])
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op2 (dst, src, op)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_COPY:
|
||||
if (srcp == dstp)
|
||||
break;
|
||||
memcpy (dstp, srcp, sizeof (bitset_word) * size);
|
||||
break;
|
||||
|
||||
case BITSET_OP_NOT:
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
sbitset_unused_clear (dst);
|
||||
break;
|
||||
|
||||
case BITSET_OP_EQUAL_P:
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case BITSET_OP_SUBSET_P:
|
||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case BITSET_OP_DISJOINT_P:
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op3 (dst, src1, src2, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p = SBITSET_WORDS (src1);
|
||||
bitset_word *src2p = SBITSET_WORDS (src2);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src1) != SBITSET_N_BITS (dst)
|
||||
SBITSET_N_BITS (src2) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_OR:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ | *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_OP_AND:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_OP_XOR:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_OP_ANDN:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op4 (dst, src1, src2, src3, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
bitset src3;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p = SBITSET_WORDS (src1);
|
||||
bitset_word *src2p = SBITSET_WORDS (src2);
|
||||
bitset_word *src3p = SBITSET_WORDS (src3);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src1) != SBITSET_N_BITS (dst)
|
||||
|| SBITSET_N_BITS (src2) != SBITSET_N_BITS (dst)
|
||||
|| SBITSET_N_BITS (src3) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_OR_AND:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_OP_AND_OR:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BITSET_OP_ANDN_OR:
|
||||
for (i = 0; i < size; i++, dstp++)
|
||||
{
|
||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/* Vector of operations for single word bitsets. */
|
||||
struct bitset_ops_struct sbitset_small_ops = {
|
||||
sbitset_set,
|
||||
sbitset_reset,
|
||||
sbitset_test,
|
||||
sbitset_size,
|
||||
sbitset_op1,
|
||||
sbitset_op2,
|
||||
sbitset_op3,
|
||||
sbitset_op4,
|
||||
sbitset_small_list,
|
||||
sbitset_reverse_list,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
/* Vector of operations for multiple word bitsets. */
|
||||
struct bitset_ops_struct sbitset_ops = {
|
||||
sbitset_set,
|
||||
sbitset_reset,
|
||||
sbitset_test,
|
||||
sbitset_size,
|
||||
sbitset_op1,
|
||||
sbitset_op2,
|
||||
sbitset_op3,
|
||||
sbitset_op4,
|
||||
sbitset_list,
|
||||
sbitset_reverse_list,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
sbitset_bytes (n_bits)
|
||||
bitset_bindex n_bits;
|
||||
{
|
||||
unsigned int bytes, size;
|
||||
|
||||
size = SBITSET_N_WORDS (n_bits);
|
||||
bytes = size * sizeof (bitset_word);
|
||||
return sizeof (struct bitset_struct) + bytes - sizeof (bitset_word);
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
sbitset_init (bset, n_bits)
|
||||
bitset bset;
|
||||
bitset_bindex n_bits;
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
size = SBITSET_N_WORDS (n_bits);
|
||||
SBITSET_N_BITS (bset) = n_bits;
|
||||
|
||||
/* Use optimized routines if bitset fits within a single word.
|
||||
There is probably little merit if using caching since
|
||||
the small bitset will always fit in the cache. */
|
||||
if (size == 1)
|
||||
bset->b.ops = &sbitset_small_ops;
|
||||
else
|
||||
bset->b.ops = &sbitset_ops;
|
||||
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = size;
|
||||
bset->b.cdata = SBITSET_WORDS (bset);
|
||||
return bset;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/* stpcpy.c -- copy a string and return pointer to end of new string
|
||||
Copyright (C) 1992, 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#undef __stpcpy
|
||||
#undef stpcpy
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __stpcpy stpcpy
|
||||
#endif
|
||||
|
||||
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
|
||||
char *
|
||||
__stpcpy (char *dest, const char *src)
|
||||
{
|
||||
register char *d = dest;
|
||||
register const char *s = src;
|
||||
|
||||
do
|
||||
*d++ = *s;
|
||||
while (*s++ != '\0');
|
||||
|
||||
return d - 1;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__stpcpy, stpcpy)
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place -
|
||||
Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
strchr (const char *s, int c)
|
||||
{
|
||||
return index (s, c);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_MEMCHR
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MEMCHR
|
||||
char *memchr ();
|
||||
#endif
|
||||
|
||||
#undef __strnlen
|
||||
#undef strnlen
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __strnlen strnlen
|
||||
#endif
|
||||
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
If no '\0' terminator is found in that many characters, return MAXLEN. */
|
||||
|
||||
size_t
|
||||
__strnlen (const char *string, size_t maxlen)
|
||||
{
|
||||
const char *end = memchr (string, '\0', maxlen);
|
||||
return end ? (size_t) (end - string) : maxlen;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__strnlen, strnlen)
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU
|
||||
C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place -
|
||||
Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
# ifndef strchr
|
||||
# define strchr index
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef strspn
|
||||
|
||||
/* Return the length of the maximum initial segment
|
||||
of S which contains only characters in ACCEPT. */
|
||||
size_t
|
||||
strspn (s, accept)
|
||||
const char *s;
|
||||
const char *accept;
|
||||
{
|
||||
const char *p;
|
||||
const char *a;
|
||||
size_t count = 0;
|
||||
|
||||
for (p = s; *p != '\0'; ++p)
|
||||
{
|
||||
for (a = accept; *a != '\0'; ++a)
|
||||
if (*p == *a)
|
||||
break;
|
||||
if (*a == '\0')
|
||||
return count;
|
||||
else
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/* Subprocesses with pipes.
|
||||
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]>
|
||||
and Florian Krohm <florian@edamail.fishkill.ibm.com>. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "subpipe.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <signal.h>
|
||||
#if ! defined SIGCHLD && defined SIGCLD
|
||||
# define SIGCHLD SIGCLD
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO 0
|
||||
#endif
|
||||
#ifndef STDOUT_FILENO
|
||||
# define STDOUT_FILENO 1
|
||||
#endif
|
||||
#if ! HAVE_DUP2 && ! defined dup2
|
||||
# if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# define dup2(f, t) (close (t), fcntl (f, F_DUPFD, t))
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#ifndef WEXITSTATUS
|
||||
# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
|
||||
#endif
|
||||
#ifndef WIFEXITED
|
||||
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
|
||||
#endif
|
||||
|
||||
#if HAVE_VFORK_H
|
||||
# include <vfork.h>
|
||||
#endif
|
||||
#if ! HAVE_WORKING_VFORK
|
||||
# define vfork fork
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(Msgid) gettext (Msgid)
|
||||
|
||||
|
||||
/* Initialize this module. */
|
||||
|
||||
void
|
||||
init_subpipe (void)
|
||||
{
|
||||
#ifdef SIGCHLD
|
||||
/* System V fork+wait does not work if SIGCHLD is ignored. */
|
||||
signal (SIGCHLD, SIG_DFL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Create a subprocess that is run as a filter. ARGV is the
|
||||
NULL-terminated argument vector for the subprocess. Store read and
|
||||
write file descriptors for communication with the subprocess into
|
||||
FD[0] and FD[1]: input meant for the process can be written into
|
||||
FD[0], and output from the process can be read from FD[1]. Return
|
||||
the subprocess id.
|
||||
|
||||
To avoid deadlock, the invoker must not let incoming data pile up
|
||||
in FD[1] while writing data to FD[0]. */
|
||||
|
||||
pid_t
|
||||
create_subpipe (char const * const *argv, int fd[2])
|
||||
{
|
||||
int pipe_fd[2];
|
||||
int from_in_fd;
|
||||
int from_out_fd;
|
||||
int to_in_fd;
|
||||
int to_out_fd;
|
||||
pid_t pid;
|
||||
|
||||
if (pipe (pipe_fd) != 0)
|
||||
error (EXIT_FAILURE, errno, "pipe");
|
||||
to_in_fd = pipe_fd[0];
|
||||
to_out_fd = pipe_fd[1];
|
||||
|
||||
if (pipe (pipe_fd) != 0)
|
||||
error (EXIT_FAILURE, errno, "pipe");
|
||||
from_in_fd = pipe_fd[0];
|
||||
from_out_fd = pipe_fd[1];
|
||||
|
||||
pid = vfork ();
|
||||
if (pid < 0)
|
||||
error (EXIT_FAILURE, errno, "fork");
|
||||
|
||||
if (! pid)
|
||||
{
|
||||
/* Child. */
|
||||
close (to_out_fd);
|
||||
close (from_in_fd);
|
||||
|
||||
if (to_in_fd != STDIN_FILENO)
|
||||
{
|
||||
dup2 (to_in_fd, STDIN_FILENO);
|
||||
close (to_in_fd);
|
||||
}
|
||||
if (from_out_fd != STDOUT_FILENO)
|
||||
{
|
||||
dup2 (from_out_fd, STDOUT_FILENO);
|
||||
close (from_out_fd);
|
||||
}
|
||||
|
||||
/* The cast to (char **) rather than (char * const *) is needed
|
||||
for portability to older hosts with a nonstandard prototype
|
||||
for execvp. */
|
||||
execvp (argv[0], (char **) argv);
|
||||
|
||||
_exit (errno == ENOENT ? 127 : 126);
|
||||
}
|
||||
|
||||
/* Parent. */
|
||||
close (to_in_fd);
|
||||
close (from_out_fd);
|
||||
fd[0] = to_out_fd;
|
||||
fd[1] = from_in_fd;
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
/* Wait for the subprocess to exit. */
|
||||
|
||||
void
|
||||
reap_subpipe (pid_t pid, char const *program)
|
||||
{
|
||||
#if HAVE_WAITPID || defined waitpid
|
||||
int wstatus;
|
||||
if (waitpid (pid, &wstatus, 0) < 0)
|
||||
error (EXIT_FAILURE, errno, "waitpid");
|
||||
else
|
||||
{
|
||||
int status = WIFEXITED (wstatus) ? WEXITSTATUS (wstatus) : -1;
|
||||
if (status)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_(status == 126
|
||||
? "subsidiary program `%s' could not be invoked"
|
||||
: status == 127
|
||||
? "subsidiary program `%s' not found"
|
||||
: status < 0
|
||||
? "subsidiary program `%s' failed"
|
||||
: "subsidiary program `%s' failed (exit status %d)"),
|
||||
program, status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/* Subprocesses with pipes.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]>
|
||||
and Florian Krohm <florian@edamail.fishkill.ibm.com>. */
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
void init_subpipe (void);
|
||||
pid_t create_subpipe (char const * const *, int[2]);
|
||||
void reap_subpipe (pid_t, char const *);
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef P_tmpdir
|
||||
# define P_tmpdir "/tmp"
|
||||
#endif
|
||||
#ifndef TMP_MAX
|
||||
# define TMP_MAX 238328
|
||||
#endif
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
# define __GT_BIGFILE 1
|
||||
# define __GT_DIR 2
|
||||
# define __GT_NOCREATE 3
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || _LIBC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_FCNTL_H || _LIBC
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TIME_H || _LIBC
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H || _LIBC
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H || _LIBC
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISDIR
|
||||
#endif
|
||||
#if !defined S_ISDIR && defined S_IFDIR
|
||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if !S_IRUSR && S_IREAD
|
||||
# define S_IRUSR S_IREAD
|
||||
#endif
|
||||
#if !S_IRUSR
|
||||
# define S_IRUSR 00400
|
||||
#endif
|
||||
#if !S_IWUSR && S_IWRITE
|
||||
# define S_IWUSR S_IWRITE
|
||||
#endif
|
||||
#if !S_IWUSR
|
||||
# define S_IWUSR 00200
|
||||
#endif
|
||||
#if !S_IXUSR && S_IEXEC
|
||||
# define S_IXUSR S_IEXEC
|
||||
#endif
|
||||
#if !S_IXUSR
|
||||
# define S_IXUSR 00100
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
# define struct_stat64 struct stat64
|
||||
#else
|
||||
# define struct_stat64 struct stat
|
||||
# define __getpid getpid
|
||||
# define __gettimeofday gettimeofday
|
||||
# define __mkdir mkdir
|
||||
# define __open open
|
||||
# define __open64 open
|
||||
# define __lxstat64(version, path, buf) lstat (path, buf)
|
||||
# define __xstat64(version, path, buf) stat (path, buf)
|
||||
#endif
|
||||
|
||||
#if ! (HAVE___SECURE_GETENV || _LIBC)
|
||||
# define __secure_getenv getenv
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <hp-timing.h>
|
||||
# if HP_TIMING_AVAIL
|
||||
# define RANDOM_BITS(Var) \
|
||||
if (__builtin_expect (value == UINT64_C (0), 0)) \
|
||||
{ \
|
||||
/* If this is the first time this function is used initialize \
|
||||
the variable we accumulate the value in to some somewhat \
|
||||
random value. If we'd not do this programs at startup time \
|
||||
might have a reduced set of possible names, at least on slow \
|
||||
machines. */ \
|
||||
struct timeval tv; \
|
||||
__gettimeofday (&tv, NULL); \
|
||||
value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \
|
||||
} \
|
||||
HP_TIMING_NOW (Var)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Use the widest available unsigned type if uint64_t is not
|
||||
available. The algorithm below extracts a number less than 62**6
|
||||
(approximately 2**35.725) from uint64_t, so ancient hosts where
|
||||
uintmax_t is only 32 bits lose about 3.725 bits of randomness,
|
||||
which is better than not having mkstemp at all. */
|
||||
#if !defined UINT64_MAX && !defined uint64_t
|
||||
# define uint64_t uintmax_t
|
||||
#endif
|
||||
|
||||
/* Return nonzero if DIR is an existent directory. */
|
||||
static int
|
||||
direxists (const char *dir)
|
||||
{
|
||||
struct_stat64 buf;
|
||||
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
||||
}
|
||||
|
||||
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
|
||||
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
|
||||
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
|
||||
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
|
||||
doesn't exist, none of the searched dirs exists, or there's not
|
||||
enough space in TMPL. */
|
||||
int
|
||||
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||
int try_tmpdir)
|
||||
{
|
||||
const char *d;
|
||||
size_t dlen, plen;
|
||||
|
||||
if (!pfx || !pfx[0])
|
||||
{
|
||||
pfx = "file";
|
||||
plen = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
plen = strlen (pfx);
|
||||
if (plen > 5)
|
||||
plen = 5;
|
||||
}
|
||||
|
||||
if (try_tmpdir)
|
||||
{
|
||||
d = __secure_getenv ("TMPDIR");
|
||||
if (d != NULL && direxists (d))
|
||||
dir = d;
|
||||
else if (dir != NULL && direxists (dir))
|
||||
/* nothing */ ;
|
||||
else
|
||||
dir = NULL;
|
||||
}
|
||||
if (dir == NULL)
|
||||
{
|
||||
if (direxists (P_tmpdir))
|
||||
dir = P_tmpdir;
|
||||
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
|
||||
dir = "/tmp";
|
||||
else
|
||||
{
|
||||
__set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dlen = strlen (dir);
|
||||
while (dlen > 1 && dir[dlen - 1] == '/')
|
||||
dlen--; /* remove trailing slashes */
|
||||
|
||||
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
|
||||
if (tmpl_len < dlen + 1 + plen + 6 + 1)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* These are the characters used in temporary filenames. */
|
||||
static const char letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
|
||||
does not exist at the time of the call to __gen_tempname. TMPL is
|
||||
overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
__GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
__GT_BIGFILE: same as __GT_FILE but use open64().
|
||||
__GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
int
|
||||
__gen_tempname (char *tmpl, int kind)
|
||||
{
|
||||
int len;
|
||||
char *XXXXXX;
|
||||
static uint64_t value;
|
||||
uint64_t random_time_bits;
|
||||
unsigned int count;
|
||||
int fd = -1;
|
||||
int save_errno = errno;
|
||||
struct_stat64 st;
|
||||
|
||||
/* A lower bound on the number of temporary files to attempt to
|
||||
generate. The maximum total number of temporary file names that
|
||||
can exist for a given template is 62**6. It should never be
|
||||
necessary to try all these combinations. Instead if a reasonable
|
||||
number of names is tried (we define reasonable as 62**3) fail to
|
||||
give the system administrator the chance to remove the problems. */
|
||||
unsigned int attempts_min = 62 * 62 * 62;
|
||||
|
||||
/* The number of times to attempt to generate a temporary file. To
|
||||
conform to POSIX, this must be no smaller than TMP_MAX. */
|
||||
unsigned int attempts = attempts_min < TMP_MAX ? TMP_MAX : attempts_min;
|
||||
|
||||
len = strlen (tmpl);
|
||||
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is where the Xs start. */
|
||||
XXXXXX = &tmpl[len - 6];
|
||||
|
||||
/* Get some more or less random data. */
|
||||
#ifdef RANDOM_BITS
|
||||
RANDOM_BITS (random_time_bits);
|
||||
#else
|
||||
# if HAVE_GETTIMEOFDAY || _LIBC
|
||||
{
|
||||
struct timeval tv;
|
||||
__gettimeofday (&tv, NULL);
|
||||
random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
|
||||
}
|
||||
# else
|
||||
random_time_bits = time (NULL);
|
||||
# endif
|
||||
#endif
|
||||
value += random_time_bits ^ __getpid ();
|
||||
|
||||
for (count = 0; count < attempts; value += 7777, ++count)
|
||||
{
|
||||
uint64_t v = value;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case __GT_FILE:
|
||||
fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_BIGFILE:
|
||||
fd = __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_DIR:
|
||||
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
break;
|
||||
|
||||
case __GT_NOCREATE:
|
||||
/* This case is backward from the other three. __gen_tempname
|
||||
succeeds if __xstat fails because the name does not exist.
|
||||
Note the continue to bypass the common logic at the bottom
|
||||
of the loop. */
|
||||
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
/* Give up now. */
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
assert (! "invalid KIND in __gen_tempname");
|
||||
}
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return fd;
|
||||
}
|
||||
else if (errno != EEXIST)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We got out of the loop because we ran out of combinations to try. */
|
||||
__set_errno (EEXIST);
|
||||
return -1;
|
||||
}
|
||||
+565
@@ -0,0 +1,565 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2, or (at your option) any later
|
||||
version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#if IN_GCC
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "intl.h"
|
||||
#include "rtl.h"
|
||||
|
||||
#else
|
||||
|
||||
/* This source file is taken from the GCC source code, with slight
|
||||
modifications that are under control of the IN_GCC preprocessor
|
||||
variable. The !IN_GCC part of this file is specific to Bison. */
|
||||
|
||||
# include "../src/system.h"
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
int timevar_report = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOCK_T
|
||||
typedef int clock_t;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_TMS
|
||||
struct tms
|
||||
{
|
||||
clock_t tms_utime;
|
||||
clock_t tms_stime;
|
||||
clock_t tms_cutime;
|
||||
clock_t tms_cstime;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
|
||||
extern int getrusage (int, struct rusage *);
|
||||
#endif
|
||||
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
|
||||
extern clock_t times (struct tms *);
|
||||
#endif
|
||||
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
|
||||
extern clock_t clock (void);
|
||||
#endif
|
||||
|
||||
#ifndef RUSAGE_SELF
|
||||
# define RUSAGE_SELF 0
|
||||
#endif
|
||||
|
||||
/* Calculation of scale factor to convert ticks to microseconds.
|
||||
We mustn't use CLOCKS_PER_SEC except with clock(). */
|
||||
#if HAVE_SYSCONF && defined _SC_CLK_TCK
|
||||
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
|
||||
#else
|
||||
# ifdef CLK_TCK
|
||||
# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
|
||||
# else
|
||||
# ifdef HZ
|
||||
# define TICKS_PER_SECOND HZ /* traditional UNIX */
|
||||
# else
|
||||
# define TICKS_PER_SECOND 100 /* often the correct value */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Prefer times to getrusage to clock (each gives successively less
|
||||
information). */
|
||||
#ifdef HAVE_TIMES
|
||||
# define USE_TIMES
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
# define HAVE_WALL_TIME
|
||||
#else
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
# define USE_GETRUSAGE
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
#else
|
||||
#ifdef HAVE_CLOCK
|
||||
# define USE_CLOCK
|
||||
# define HAVE_USER_TIME
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* libc is very likely to have snuck a call to sysconf() into one of
|
||||
the underlying constants, and that can be very slow, so we have to
|
||||
precompute them. Whose wonderful idea was it to make all those
|
||||
_constants_ variable at run time, anyway? */
|
||||
#ifdef USE_TIMES
|
||||
static float ticks_to_msec;
|
||||
#define TICKS_TO_MSEC (1.0 / TICKS_PER_SECOND)
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLOCK
|
||||
static float clocks_to_msec;
|
||||
#define CLOCKS_TO_MSEC (1.0 / CLOCKS_PER_SEC)
|
||||
#endif
|
||||
|
||||
#if IN_GCC
|
||||
#include "flags.h"
|
||||
#endif
|
||||
#include "timevar.h"
|
||||
|
||||
/* See timevar.h for an explanation of timing variables. */
|
||||
|
||||
/* This macro evaluates to nonzero if timing variables are enabled. */
|
||||
#define TIMEVAR_ENABLE (timevar_report)
|
||||
|
||||
/* A timing variable. */
|
||||
|
||||
struct timevar_def
|
||||
{
|
||||
/* Elapsed time for this variable. */
|
||||
struct timevar_time_def elapsed;
|
||||
|
||||
/* If this variable is timed independently of the timing stack,
|
||||
using timevar_start, this contains the start time. */
|
||||
struct timevar_time_def start_time;
|
||||
|
||||
/* The name of this timing variable. */
|
||||
const char *name;
|
||||
|
||||
/* Non-zero if this timing variable is running as a standalone
|
||||
timer. */
|
||||
unsigned standalone : 1;
|
||||
|
||||
/* Non-zero if this timing variable was ever started or pushed onto
|
||||
the timing stack. */
|
||||
unsigned used : 1;
|
||||
};
|
||||
|
||||
/* An element on the timing stack. Elapsed time is attributed to the
|
||||
topmost timing variable on the stack. */
|
||||
|
||||
struct timevar_stack_def
|
||||
{
|
||||
/* The timing variable at this stack level. */
|
||||
struct timevar_def *timevar;
|
||||
|
||||
/* The next lower timing variable context in the stack. */
|
||||
struct timevar_stack_def *next;
|
||||
};
|
||||
|
||||
/* Declared timing variables. Constructed from the contents of
|
||||
timevar.def. */
|
||||
static struct timevar_def timevars[TIMEVAR_LAST];
|
||||
|
||||
/* The top of the timing stack. */
|
||||
static struct timevar_stack_def *stack;
|
||||
|
||||
/* A list of unused (i.e. allocated and subsequently popped)
|
||||
timevar_stack_def instances. */
|
||||
static struct timevar_stack_def *unused_stack_instances;
|
||||
|
||||
/* The time at which the topmost element on the timing stack was
|
||||
pushed. Time elapsed since then is attributed to the topmost
|
||||
element. */
|
||||
static struct timevar_time_def start_time;
|
||||
|
||||
static void get_time (struct timevar_time_def *);
|
||||
static void timevar_accumulate (struct timevar_time_def *,
|
||||
struct timevar_time_def *,
|
||||
struct timevar_time_def *);
|
||||
|
||||
/* Fill the current times into TIME. The definition of this function
|
||||
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
||||
HAVE_WALL_TIME macros. */
|
||||
|
||||
static void
|
||||
get_time (now)
|
||||
struct timevar_time_def *now;
|
||||
{
|
||||
now->user = 0;
|
||||
now->sys = 0;
|
||||
now->wall = 0;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
{
|
||||
#ifdef USE_TIMES
|
||||
struct tms tms;
|
||||
now->wall = times (&tms) * ticks_to_msec;
|
||||
#if IN_GCC
|
||||
now->user = tms.tms_utime * ticks_to_msec;
|
||||
now->sys = tms.tms_stime * ticks_to_msec;
|
||||
#else
|
||||
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
|
||||
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
#if IN_GCC
|
||||
getrusage (RUSAGE_SELF, &rusage);
|
||||
#else
|
||||
getrusage (RUSAGE_CHILDREN, &rusage);
|
||||
#endif
|
||||
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
now->user = clock () * clocks_to_msec;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the difference between STOP and START to TIMER. */
|
||||
|
||||
static void
|
||||
timevar_accumulate (timer, start, stop)
|
||||
struct timevar_time_def *timer;
|
||||
struct timevar_time_def *start;
|
||||
struct timevar_time_def *stop;
|
||||
{
|
||||
timer->user += stop->user - start->user;
|
||||
timer->sys += stop->sys - start->sys;
|
||||
timer->wall += stop->wall - start->wall;
|
||||
}
|
||||
|
||||
/* Initialize timing variables. */
|
||||
|
||||
void
|
||||
init_timevar ()
|
||||
{
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Zero all elapsed times. */
|
||||
memset ((void *) timevars, 0, sizeof (timevars));
|
||||
|
||||
/* Initialize the names of timing variables. */
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
timevars[identifier__].name = name__;
|
||||
#include "timevar.def"
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
#ifdef USE_TIMES
|
||||
ticks_to_msec = TICKS_TO_MSEC;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
clocks_to_msec = CLOCKS_TO_MSEC;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Push TIMEVAR onto the timing stack. No further elapsed time is
|
||||
attributed to the previous topmost timing variable on the stack;
|
||||
subsequent elapsed time is attributed to TIMEVAR, until it is
|
||||
popped or another element is pushed on top.
|
||||
|
||||
TIMEVAR cannot be running as a standalone timer. */
|
||||
|
||||
void
|
||||
timevar_push (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_stack_def *context;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Can't push a standalone timer. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
/* See if we have a previously-allocated stack instance. If so,
|
||||
take it off the list. If not, malloc a new one. */
|
||||
if (unused_stack_instances != NULL)
|
||||
{
|
||||
context = unused_stack_instances;
|
||||
unused_stack_instances = unused_stack_instances->next;
|
||||
}
|
||||
else
|
||||
context = (struct timevar_stack_def *)
|
||||
xmalloc (sizeof (struct timevar_stack_def));
|
||||
|
||||
/* Fill it in and put it on the stack. */
|
||||
context->timevar = tv;
|
||||
context->next = stack;
|
||||
stack = context;
|
||||
}
|
||||
|
||||
/* Pop the topmost timing variable element off the timing stack. The
|
||||
popped variable must be TIMEVAR. Elapsed time since the that
|
||||
element was pushed on, or since it was last exposed on top of the
|
||||
stack when the element above it was popped off, is credited to that
|
||||
timing variable. */
|
||||
|
||||
void
|
||||
timevar_pop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_time_def now;
|
||||
struct timevar_stack_def *popped = stack;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
if (&timevars[timevar] != stack->timevar)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* Attribute the elapsed time to the element we're popping. */
|
||||
timevar_accumulate (&popped->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to the
|
||||
element just exposed on the stack. */
|
||||
start_time = now;
|
||||
|
||||
/* Take the item off the stack. */
|
||||
stack = stack->next;
|
||||
|
||||
/* Don't delete the stack element; instead, add it to the list of
|
||||
unused elements for later use. */
|
||||
popped->next = unused_stack_instances;
|
||||
unused_stack_instances = popped;
|
||||
}
|
||||
|
||||
/* Start timing TIMEVAR independently of the timing stack. Elapsed
|
||||
time until timevar_stop is called for the same timing variable is
|
||||
attributed to TIMEVAR. */
|
||||
|
||||
void
|
||||
timevar_start (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Don't allow the same timing variable to be started more than
|
||||
once. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
tv->standalone = 1;
|
||||
|
||||
get_time (&tv->start_time);
|
||||
}
|
||||
|
||||
/* Stop timing TIMEVAR. Time elapsed since timevar_start was called
|
||||
is attributed to it. */
|
||||
|
||||
void
|
||||
timevar_stop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* TIMEVAR must have been started via timevar_start. */
|
||||
if (!tv->standalone)
|
||||
abort ();
|
||||
|
||||
get_time (&now);
|
||||
timevar_accumulate (&tv->elapsed, &tv->start_time, &now);
|
||||
}
|
||||
|
||||
/* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
|
||||
update-to-date information even if TIMEVAR is currently running. */
|
||||
|
||||
void
|
||||
timevar_get (timevar, elapsed)
|
||||
timevar_id_t timevar;
|
||||
struct timevar_time_def *elapsed;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
*elapsed = tv->elapsed;
|
||||
|
||||
/* Is TIMEVAR currently running as a standalone timer? */
|
||||
if (tv->standalone)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &tv->start_time, &now);
|
||||
}
|
||||
/* Or is TIMEVAR at the top of the timer stack? */
|
||||
else if (stack->timevar == tv)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &start_time, &now);
|
||||
}
|
||||
}
|
||||
|
||||
/* Summarize timing variables to FP. The timing variable TV_TOTAL has
|
||||
a special meaning -- it's considered to be the total elapsed time,
|
||||
for normalizing the others, and is displayed last. */
|
||||
|
||||
void
|
||||
timevar_print (fp)
|
||||
FILE *fp;
|
||||
{
|
||||
/* Only print stuff if we have some sort of time information. */
|
||||
#if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME)
|
||||
unsigned int /* timevar_id_t */ id;
|
||||
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Update timing information in case we're calling this from GDB. */
|
||||
|
||||
if (fp == 0)
|
||||
fp = stderr;
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
fputs (_("\nExecution times (seconds)\n"), fp);
|
||||
for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id)
|
||||
{
|
||||
struct timevar_def *tv = &timevars[(timevar_id_t) id];
|
||||
const float tiny = 5e-3;
|
||||
|
||||
/* Don't print the total execution time here; that goes at the
|
||||
end. */
|
||||
if ((timevar_id_t) id == TV_TOTAL)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables that were never used. */
|
||||
if (!tv->used)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables if we're going to get a row of
|
||||
zeroes. */
|
||||
if (tv->elapsed.user < tiny
|
||||
&& tv->elapsed.sys < tiny
|
||||
&& tv->elapsed.wall < tiny)
|
||||
continue;
|
||||
|
||||
/* The timing variable name. */
|
||||
fprintf (fp, " %-22s:", tv->name);
|
||||
|
||||
#ifdef HAVE_USER_TIME
|
||||
/* Print user-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||
tv->elapsed.user,
|
||||
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||
#endif /* HAVE_USER_TIME */
|
||||
|
||||
#ifdef HAVE_SYS_TIME
|
||||
/* Print system-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||
tv->elapsed.sys,
|
||||
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||
#endif /* HAVE_SYS_TIME */
|
||||
|
||||
#ifdef HAVE_WALL_TIME
|
||||
/* Print wall clock time elapsed. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||
tv->elapsed.wall,
|
||||
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||
#endif /* HAVE_WALL_TIME */
|
||||
|
||||
putc ('\n', fp);
|
||||
}
|
||||
|
||||
/* Print total time. */
|
||||
fputs (_(" TOTAL :"), fp);
|
||||
#ifdef HAVE_USER_TIME
|
||||
fprintf (fp, "%7.2f ", total->user);
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME
|
||||
fprintf (fp, "%7.2f ", total->sys);
|
||||
#endif
|
||||
#ifdef HAVE_WALL_TIME
|
||||
fprintf (fp, "%7.2f\n", total->wall);
|
||||
#endif
|
||||
|
||||
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
||||
|| defined (HAVE_WALL_TIME) */
|
||||
}
|
||||
|
||||
/* Returns time (user + system) used so far by the compiler process,
|
||||
in microseconds. */
|
||||
|
||||
long
|
||||
get_run_time ()
|
||||
{
|
||||
struct timevar_time_def total_elapsed;
|
||||
timevar_get (TV_TOTAL, &total_elapsed);
|
||||
return total_elapsed.user + total_elapsed.sys;
|
||||
}
|
||||
|
||||
/* Prints a message to stderr stating that time elapsed in STR is
|
||||
TOTAL (given in microseconds). */
|
||||
|
||||
void
|
||||
print_time (str, total)
|
||||
const char *str;
|
||||
long total;
|
||||
{
|
||||
long all_time = get_run_time ();
|
||||
fprintf (stderr,
|
||||
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||
str, total / 1000000, total % 1000000,
|
||||
all_time == 0 ? 0
|
||||
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* This file contains the definitions for timing variables used to -*- C -*-
|
||||
measure run-time performance of the compiler.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Akim Demaille <akim@freefriends.org>.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file contains timing variable definitions, used by timevar.h
|
||||
and timevar.c.
|
||||
|
||||
Syntax:
|
||||
|
||||
DEFTIMEVAR (id, name)
|
||||
|
||||
where ID is the enumeral value used to identify the timing
|
||||
variable, and NAME is a character string describing its purpose. */
|
||||
|
||||
/* The total execution time. */
|
||||
DEFTIMEVAR (TV_TOTAL , "total time")
|
||||
|
||||
/* Time spent in the reader. */
|
||||
DEFTIMEVAR (TV_READER , "reader")
|
||||
DEFTIMEVAR (TV_SCANNING , "scanner")
|
||||
DEFTIMEVAR (TV_PARSING , "parser")
|
||||
|
||||
/* Time spent handling the grammar. */
|
||||
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
|
||||
DEFTIMEVAR (TV_SETS , "computing the sets")
|
||||
DEFTIMEVAR (TV_LR0 , "LR(0)")
|
||||
DEFTIMEVAR (TV_LALR , "LALR(1)")
|
||||
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
|
||||
|
||||
/* Time spent outputing results. */
|
||||
DEFTIMEVAR (TV_REPORT , "outputing report")
|
||||
DEFTIMEVAR (TV_GRAPH , "outputing graph")
|
||||
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
|
||||
DEFTIMEVAR (TV_PARSER , "outputing parser")
|
||||
DEFTIMEVAR (TV_M4 , "running m4")
|
||||
|
||||
/* Time spent by freeing the memory :). */
|
||||
DEFTIMEVAR (TV_FREE , "freeing")
|
||||
@@ -0,0 +1,93 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
Bison is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bison is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#ifndef GCC_TIMEVAR_H
|
||||
#define GCC_TIMEVAR_H
|
||||
|
||||
/* Timing variables are used to measure elapsed time in various
|
||||
portions of the compiler. Each measures elapsed user, system, and
|
||||
wall-clock time, as appropriate to and supported by the host
|
||||
system.
|
||||
|
||||
Timing variables are defined using the DEFTIMEVAR macro in
|
||||
timevar.def. Each has an enumeral identifier, used when referring
|
||||
to the timing variable in code, and a character string name.
|
||||
|
||||
Timing variables can be used in two ways:
|
||||
|
||||
- On the timing stack, using timevar_push and timevar_pop.
|
||||
Timing variables may be pushed onto the stack; elapsed time is
|
||||
attributed to the topmost timing variable on the stack. When
|
||||
another variable is pushed on, the previous topmost variable is
|
||||
`paused' until the pushed variable is popped back off.
|
||||
|
||||
- As a standalone timer, using timevar_start and timevar_stop.
|
||||
All time elapsed between the two calls is attributed to the
|
||||
variable.
|
||||
*/
|
||||
|
||||
/* This structure stores the various varieties of time that can be
|
||||
measured. Times are stored in seconds. The time may be an
|
||||
absolute time or a time difference; in the former case, the time
|
||||
base is undefined, except that the difference between two times
|
||||
produces a valid time difference. */
|
||||
|
||||
struct timevar_time_def
|
||||
{
|
||||
/* User time in this process. */
|
||||
float user;
|
||||
|
||||
/* System time (if applicable for this host platform) in this
|
||||
process. */
|
||||
float sys;
|
||||
|
||||
/* Wall clock time. */
|
||||
float wall;
|
||||
};
|
||||
|
||||
/* An enumeration of timing variable identifiers. Constructed from
|
||||
the contents of timevar.def. */
|
||||
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
identifier__,
|
||||
typedef enum
|
||||
{
|
||||
#include "timevar.def"
|
||||
TIMEVAR_LAST
|
||||
}
|
||||
timevar_id_t;
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
extern void init_timevar (void);
|
||||
extern void timevar_push (timevar_id_t);
|
||||
extern void timevar_pop (timevar_id_t);
|
||||
extern void timevar_start (timevar_id_t);
|
||||
extern void timevar_stop (timevar_id_t);
|
||||
extern void timevar_get (timevar_id_t, struct timevar_time_def *);
|
||||
extern void timevar_print (FILE *);
|
||||
|
||||
/* Provided for backward compatibility. */
|
||||
extern long get_run_time (void);
|
||||
extern void print_time (const char *, long);
|
||||
|
||||
extern int timevar_report;
|
||||
|
||||
#endif /* ! GCC_TIMEVAR_H */
|
||||
+1140
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
/* Functions to support vbitsets.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _VBITSET_H
|
||||
#define _VBITSET_H
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t vbitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset vbitset_init (bitset, bitset_bindex);
|
||||
|
||||
#endif
|
||||
@@ -1,87 +0,0 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
It is initialized to EXIT_FAILURE, but the caller may set it to
|
||||
some other value. */
|
||||
extern int xalloc_exit_failure;
|
||||
|
||||
/* If this pointer is non-zero, run the specified function upon each
|
||||
allocation failure. It is initialized to zero. */
|
||||
extern void (*xalloc_fail_func) PARAMS ((void));
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
|
||||
message is output. It is translated via gettext.
|
||||
Its value is "memory exhausted". */
|
||||
extern char const xalloc_msg_memory_exhausted[];
|
||||
|
||||
/* This function is always triggered when memory is exhausted. It is
|
||||
in charge of honoring the three previous items. This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc PARAMS ((size_t n));
|
||||
void *xcalloc PARAMS ((size_t n, size_t s));
|
||||
void *xrealloc PARAMS ((void *p, size_t n));
|
||||
char *xstrdup PARAMS ((const char *str));
|
||||
|
||||
# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
|
||||
# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
|
||||
# define XREALLOC(Ptr, Type, N_items) \
|
||||
((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
|
||||
|
||||
/* Declare and alloc memory for VAR of type TYPE. */
|
||||
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
|
||||
|
||||
/* Free VAR only if non NULL. */
|
||||
# define XFREE(Var) \
|
||||
do { \
|
||||
if (Var) \
|
||||
free (Var); \
|
||||
} while (0)
|
||||
|
||||
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
|
||||
# define CCLONE(Src, Num) \
|
||||
(memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
|
||||
|
||||
/* Return a malloc'ed copy of SRC. */
|
||||
# define CLONE(Src) CCLONE (Src, 1)
|
||||
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
void *calloc ();
|
||||
void *malloc ();
|
||||
void *realloc ();
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define textdomain(Domain)
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
#define N_(Text) Text
|
||||
|
||||
#include "error.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working malloc -- see malloc.m4"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working realloc --see realloc.m4"
|
||||
#endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
The caller may set it to some other value. */
|
||||
int xalloc_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* If non NULL, call this function when memory is exhausted. */
|
||||
void (*xalloc_fail_func) PARAMS ((void)) = 0;
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
char const xalloc_msg_memory_exhausted[] = N_("memory exhausted");
|
||||
|
||||
void
|
||||
xalloc_die (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
/* The `noreturn' cannot be given to error, since it may return if
|
||||
its first argument is 0. To help compilers understand the
|
||||
xalloc_die does terminate, call exit. */
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = malloc (n);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
p = realloc (p, n);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Allocate memory for N elements of S bytes, with error checking. */
|
||||
|
||||
void *
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = calloc (n, s);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user