mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 18:25:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5109f5af0 | ||
|
|
1bd0dedaaa | ||
|
|
c1432f6538 | ||
|
|
cf147260d2 | ||
|
|
3a73c9ae44 | ||
|
|
dbcdae2d04 | ||
|
|
70d8f2910e | ||
|
|
d110145422 | ||
|
|
ae199bf10f | ||
|
|
b47dbebee5 | ||
|
|
94306d5282 | ||
|
|
00292f6611 | ||
|
|
c89b4c032c | ||
|
|
d83a9c402c | ||
|
|
55f64b82cd | ||
|
|
127287e9c4 | ||
|
|
48b16bbc04 | ||
|
|
a420f9620e | ||
|
|
fa4d969f11 | ||
|
|
326eb46f40 | ||
|
|
7812f29985 | ||
|
|
7e7b77c138 | ||
|
|
9d5b26c682 | ||
|
|
42a6501d1a | ||
|
|
5b4aaf787b | ||
|
|
b5240ba555 | ||
|
|
ef9a1fafaf | ||
|
|
a4cf101a98 | ||
|
|
e6efa9dacc | ||
|
|
adc90f13ab | ||
|
|
15d29c1ffe | ||
|
|
6250acbdb1 | ||
|
|
ec5d1a8a24 | ||
|
|
dd5f2af2bd | ||
|
|
eab522e49a | ||
|
|
fe3816515c | ||
|
|
19e251af0f | ||
|
|
f9315de5a4 | ||
|
|
1fb38e78c2 | ||
|
|
ca5d201376 | ||
|
|
3d54b57635 | ||
|
|
d53ae497dc | ||
|
|
3bc00d6c4b | ||
|
|
e0045d49b6 | ||
|
|
fc01665ea5 | ||
|
|
57beea5776 | ||
|
|
5f3df3960e | ||
|
|
040984073a | ||
|
|
135bc829bd | ||
|
|
f938a7e7b8 | ||
|
|
f38b17c9bf | ||
|
|
aacbb77a75 | ||
|
|
89519adfbe | ||
|
|
26a69b31fa | ||
|
|
a9401edbf5 | ||
|
|
b3d0c7a208 | ||
|
|
1d0737fa58 | ||
|
|
1eeda0abd5 | ||
|
|
4ff8b7f7c9 | ||
|
|
6d07bacfc0 | ||
|
|
141f57937b | ||
|
|
0ffda36340 | ||
|
|
3922956abd | ||
|
|
9cbfdc9e01 | ||
|
|
9e0876fb0c | ||
|
|
49b1cf794d | ||
|
|
6fdb09caac | ||
|
|
dc9701e848 | ||
|
|
802b9687d0 | ||
|
|
ab703f2c9b | ||
|
|
0fab8d7b36 | ||
|
|
df9a1ba4de | ||
|
|
d11e0cfa89 | ||
|
|
258b75caaa | ||
|
|
6088a2a04d | ||
|
|
4cf31ef8e7 | ||
|
|
1a05945136 | ||
|
|
a778f668a1 | ||
|
|
8c27717915 | ||
|
|
97460c7864 | ||
|
|
9662b51284 | ||
|
|
30757c8c93 | ||
|
|
ac8c5689f8 | ||
|
|
6100a9aa2e | ||
|
|
67fd79c427 | ||
|
|
15f40952f7 | ||
|
|
c70fdfcd20 | ||
|
|
e2688cd96e | ||
|
|
1beb0b24f3 | ||
|
|
a22ff96f32 | ||
|
|
31d7addbf5 | ||
|
|
f32c66b5f4 | ||
|
|
71206cce8e | ||
|
|
d741bd1bfd | ||
|
|
0410a6e0cc | ||
|
|
a7db4add01 | ||
|
|
d2aaf69e73 | ||
|
|
eb520e4cc0 | ||
|
|
baf785db2e | ||
|
|
f7ab6a5010 | ||
|
|
22dda0f004 | ||
|
|
82b248ada6 | ||
|
|
2cbd078f51 | ||
|
|
1c02d4bfbf | ||
|
|
716f248dcd | ||
|
|
867a3e0085 | ||
|
|
fa0e93148c | ||
|
|
e054b19038 | ||
|
|
5f6da1c0f8 | ||
|
|
407d4a75bb | ||
|
|
34160ec4ec | ||
|
|
6770ae09d3 | ||
|
|
b34d96c1c3 | ||
|
|
c3d5a4a783 | ||
|
|
828c373b6d | ||
|
|
fd2df2ede4 | ||
|
|
63cb01d656 | ||
|
|
1c59e0a121 | ||
|
|
8a0adb0183 | ||
|
|
12545799f9 | ||
|
|
99be023555 | ||
|
|
0ffd4fd1a2 | ||
|
|
0925ebb4fa | ||
|
|
43d3b66471 | ||
|
|
73e561d51a | ||
|
|
3062864d2c | ||
|
|
681c331d2c | ||
|
|
989b5b8e3d | ||
|
|
4b43d40257 | ||
|
|
bedf57f515 | ||
|
|
4d1801f1a8 | ||
|
|
85ac3861e7 | ||
|
|
b94a9e1ed1 | ||
|
|
009ce67dbe | ||
|
|
f2a97c6294 | ||
|
|
c8775f9398 | ||
|
|
3ea5f0ec81 | ||
|
|
51c30d2144 | ||
|
|
ad7458633d | ||
|
|
010f91c341 | ||
|
|
bd134904da | ||
|
|
cea1469d47 | ||
|
|
5e6f62f2f1 | ||
|
|
0fb669f9d6 | ||
|
|
51f4735e22 | ||
|
|
7768896a25 | ||
|
|
80ce3401e9 | ||
|
|
b9c9f76197 | ||
|
|
9f666b5106 | ||
|
|
c19683bb19 | ||
|
|
ba20a26459 | ||
|
|
72f000b088 | ||
|
|
1094323fe4 | ||
|
|
f79b4f5ce1 | ||
|
|
2ce37586de | ||
|
|
ca407bdf9d | ||
|
|
506ffb1f74 | ||
|
|
ffc9da3a52 | ||
|
|
1ce590705a | ||
|
|
a749a69501 | ||
|
|
e8fd72d5bb | ||
|
|
e59adf8f04 | ||
|
|
8fb1053bfe | ||
|
|
4f136612d9 | ||
|
|
ff498c4aed | ||
|
|
65211d70bc | ||
|
|
72d848c21d | ||
|
|
9577fb1f47 | ||
|
|
f508a6a0d6 | ||
|
|
a2599d0fc2 | ||
|
|
727e8b0bde | ||
|
|
4b3017faf2 | ||
|
|
78b178f716 | ||
|
|
baf073c6c5 | ||
|
|
7296e729ce | ||
|
|
7cf96b1a9e | ||
|
|
05ac60f348 | ||
|
|
080e734812 | ||
|
|
7eb453acd5 | ||
|
|
3a4f411faa | ||
|
|
4c04c52a9d | ||
|
|
a730d142be | ||
|
|
a61e1620e7 | ||
|
|
e4f85c39b2 | ||
|
|
9ec93868c1 | ||
|
|
d46c3fc694 | ||
|
|
d6d67dbdcb | ||
|
|
73ce7e7e63 | ||
|
|
f8b30d02ec | ||
|
|
2e72b98ed8 | ||
|
|
a8999f947d | ||
|
|
ccf830a458 | ||
|
|
9b9642fca4 | ||
|
|
e0d634e5c3 | ||
|
|
e62f1a8991 | ||
|
|
7bbc8cb035 | ||
|
|
38989c080e | ||
|
|
b4fb989f02 | ||
|
|
08b770bc1b | ||
|
|
cb530ce9e2 | ||
|
|
e105489549 | ||
|
|
95f22ad2a7 | ||
|
|
d229d15c76 | ||
|
|
deb63d8117 | ||
|
|
ecadd90f94 | ||
|
|
419ab1055e | ||
|
|
213744b51e | ||
|
|
b47217154a | ||
|
|
c7a65b99a6 | ||
|
|
249d3236d0 | ||
|
|
d521d95a3d | ||
|
|
987cc1fb28 | ||
|
|
7ec5ab2e48 | ||
|
|
08fe02d9fc | ||
|
|
6201a1a70f | ||
|
|
f1bbfccee2 | ||
|
|
1821246647 | ||
|
|
010c0266ef | ||
|
|
592fde9564 | ||
|
|
508a43be8c | ||
|
|
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 |
+26
-17
@@ -1,21 +1,30 @@
|
||||
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
|
||||
_*
|
||||
a.exe
|
||||
a.out
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
b.out
|
||||
bison-*
|
||||
build-aux
|
||||
conf[0-9]*
|
||||
confdefs*
|
||||
config.cache
|
||||
config.h
|
||||
config.hin
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
configure.lineno
|
||||
conftest*
|
||||
intl
|
||||
patches
|
||||
releases
|
||||
stamp-h*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
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
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
@@ -313,7 +313,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
+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.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
|
||||
|
||||
@@ -70,14 +70,10 @@ release:
|
||||
See above.
|
||||
|
||||
** Update the foreign files
|
||||
Running `make update' in the top level should make it all for you.
|
||||
This covers PO files too. Beware that it happens that some PO files
|
||||
contain serious problems and are rejected by recent Gettext releases:
|
||||
fix them all, and complain to the Translation Project!
|
||||
|
||||
Note that there might be *new* PO files. Don't forget to update the
|
||||
whole machinery, which not only includes LINGUAS, but `cvs add'ing the
|
||||
PO files too.
|
||||
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
|
||||
@@ -107,17 +103,19 @@ 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], and [email protected].
|
||||
info-gnu@gnu.org (if a real release, or a ``serious beta''),
|
||||
bug-[email protected], [email protected], [email protected],
|
||||
and [email protected].
|
||||
|
||||
Send the same announcement on the comp.compilers newsgroup. 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.
|
||||
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 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
@@ -133,5 +131,5 @@ 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.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA.
|
||||
|
||||
+10
-23
@@ -1,5 +1,5 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001, 2002, 2003, 2004, 2005 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
|
||||
@@ -13,33 +13,20 @@
|
||||
|
||||
## 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
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = config po lib data src doc m4 tests
|
||||
SUBDIRS = config po runtime-po lib data src doc examples tests
|
||||
|
||||
EXTRA_DIST = REFERENCES OChangeLog Makefile.maint GNUmakefile
|
||||
# Files installed for use by Automake.
|
||||
aclocaldir = @aclocaldir@
|
||||
aclocal_DATA = m4/bison-i18n.m4
|
||||
|
||||
EXTRA_DIST = GNUmakefile Makefile.cfg Makefile.maint \
|
||||
OChangeLog PACKAGING
|
||||
|
||||
.PHONY: maintainer-check
|
||||
maintainer-check:
|
||||
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
|
||||
|
||||
## ---------------------------- ##
|
||||
## 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.
|
||||
url_dir_list = \
|
||||
ftp://alpha.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/missing
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
prev_version_file = $(srcdir)/config/prev-version.txt
|
||||
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
|
||||
+338
-123
@@ -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 (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001, 2002, 2003, 2004, 2005 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
|
||||
@@ -16,31 +16,57 @@
|
||||
##
|
||||
## 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.
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301, 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'
|
||||
# Use --rsyncable if available.
|
||||
GZIP_ENV = \
|
||||
"--no-name --best$$( \
|
||||
case $$(gzip --help) in \
|
||||
(*--rsyncable*) echo ' --rsyncable';; \
|
||||
esac \
|
||||
)"
|
||||
|
||||
CVS = cvs
|
||||
|
||||
prev_version_file ?= .prev-version
|
||||
CVS_LIST = sh -c ' \
|
||||
(cvsu --find --types=AFGM $$*) 2>/dev/null || \
|
||||
awk -F/ '\''{ \
|
||||
if (!$$1 && $$3 !~ /^-/) { \
|
||||
f=FILENAME; \
|
||||
sub(/CVS\/Entries/, "", f); \
|
||||
print f $$2; \
|
||||
}}'\'' \
|
||||
$$(find $${*-*} -name Entries -print) /dev/null \
|
||||
' dummy
|
||||
|
||||
CVS_LIST_EXCEPT = \
|
||||
$(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
## --------------- ##
|
||||
@@ -50,20 +76,191 @@ release_archive_dir ?= ../release
|
||||
# Checks that don't require cvs.
|
||||
# Run `changelog-check' last, as previous test may reveal problems requiring
|
||||
# new ChangeLog entries.
|
||||
local-check = \
|
||||
local-checks-available = \
|
||||
po-check copyright-check writable-files m4-check author_mark_check \
|
||||
changelog-check strftime-check header-check
|
||||
.PHONY: $(local-check)
|
||||
changelog-check strftime-check syntax-check makefile_path_separator_check \
|
||||
makefile-check
|
||||
.PHONY: $(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.
|
||||
header-check:
|
||||
if test -f $(srcdir)/src/sys2.h; then \
|
||||
if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
|
||||
|
||||
.PHONY: $(syntax-check-rules)
|
||||
syntax-check-rules = \
|
||||
sc_cast_of_argument_to_free \
|
||||
sc_cast_of_x_alloc_return_value \
|
||||
sc_cast_of_alloca_return_value \
|
||||
sc_changelog \
|
||||
sc_dd_max_sym_length \
|
||||
sc_error_exit_success \
|
||||
sc_file_system \
|
||||
sc_obsolete_symbols \
|
||||
sc_prohibit_atoi_atof \
|
||||
sc_prohibit_jm_in_m4 \
|
||||
sc_root_tests \
|
||||
sc_space_tab \
|
||||
sc_sun_os_names \
|
||||
sc_system_h_headers \
|
||||
sc_tight_scope \
|
||||
sc_trailing_space \
|
||||
sc_unmarked_diagnostics
|
||||
|
||||
syntax-check: $(syntax-check-rules)
|
||||
# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
|
||||
# $$(find -type f -name '*.[chly]') && \
|
||||
# { echo '$(ME): found conditional include' 1>&2; \
|
||||
# exit 1; } || :
|
||||
|
||||
# grep -nE '^# *include <(string|stdlib)\.h>' \
|
||||
# $(srcdir)/{lib,src}/*.[chy] && \
|
||||
# { echo '$(ME): FIXME' 1>&2; \
|
||||
# exit 1; } || :
|
||||
# FIXME: don't allow `#include .strings\.h' anywhere
|
||||
|
||||
sc_cast_of_argument_to_free:
|
||||
@grep -nE '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
|
||||
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_cast_of_x_alloc_return_value:
|
||||
@grep -nE --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_cast_of_alloca_return_value:
|
||||
@grep -nE '\*\) *alloca\>' \
|
||||
$(srcdir)/src/*.[chy] && \
|
||||
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_space_tab:
|
||||
@grep -n '[ ] ' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Don't use the old ato* functions in `real' code.
|
||||
# They provide no error checking mechanism.
|
||||
# Instead, use strto* functions.
|
||||
sc_prohibit_atoi_atof:
|
||||
@grep -nE '\<(ato[filq]|ato''ll)\>' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
|
||||
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 -nF 'error (EXIT_SUCCESS,' \
|
||||
$$(find -type f -name '*.[chly]') && \
|
||||
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_file_system:
|
||||
@grep -ni 'file''system' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found use of "file''system";' \
|
||||
'rewrite to use "file system"' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_obsolete_symbols:
|
||||
@grep -nE '\<(HAVE_''FCNTL_H)\>' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): do not use HAVE_''FCNTL_H' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# 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 -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
|
||||
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
|
||||
# with the strings from the two affected variables.
|
||||
dd_c = $(srcdir)/src/dd.c
|
||||
sc_dd_max_sym_length:
|
||||
ifneq ($(wildcard $(dd_c)),)
|
||||
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
|
||||
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
|
||||
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
|
||||
| wc --max-line-length); \
|
||||
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|
||||
|tr -d '"' | wc --max-line-length); \
|
||||
if test "$$len" = "$$max"; then :; else \
|
||||
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Many m4 macros names once began with `jm_'.
|
||||
# On 2004-04-13, they were all changed to start with gl_ instead.
|
||||
# Make sure that none are inadvertently reintroduced.
|
||||
sc_prohibit_jm_in_m4:
|
||||
@grep -nE 'jm_[A-Z]' \
|
||||
$$($(CVS_LIST) $(srcdir)/m4 |grep '\.m4$$') && \
|
||||
{ echo '$(ME): do not use jm_ in m4 macro names' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
sc_root_tests:
|
||||
@t1=sc-root.expected; t2=sc-root.actual; \
|
||||
grep -nl '^PRIV_CHECK_ARG=require-root' \
|
||||
$$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
|
||||
sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
|
||||
$(srcdir)/tests/Makefile.am |sort > $$t2; \
|
||||
diff -u $$t1 $$t2 || diff=1; \
|
||||
rm -f $$t1 $$t2; \
|
||||
test "$$diff" \
|
||||
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Create a list of regular expressions matching the names
|
||||
# of files included from system.h. Exclude a couple.
|
||||
.re-list:
|
||||
@sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
|
||||
| grep -Ev 'sys/(param|file)\.h' \
|
||||
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
|
||||
> $@-t
|
||||
@mv $@-t $@
|
||||
|
||||
# Files in src/ should not include directly any of
|
||||
# the headers already included via system.h.
|
||||
sc_system_h_headers: .re-list
|
||||
if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
|
||||
grep -nE -f .re-list \
|
||||
$$($(CVS_LIST) src | \
|
||||
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
|
||||
&& { echo '$(ME): the above are already included via system.h'\
|
||||
1>&2; exit 1; } || :; \
|
||||
fi
|
||||
|
||||
sc_sun_os_names:
|
||||
@grep -nEi \
|
||||
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
sc_tight_scope:
|
||||
$(MAKE) -C src $@
|
||||
|
||||
sc_trailing_space:
|
||||
@grep -n '[ ]$$' \
|
||||
$$($(CVS_LIST_EXCEPT)) && \
|
||||
{ echo '$(ME): found trailing space(s)' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# 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 -nE \
|
||||
'\<error \([^"]*"[^"]*[a-z]{3}' $(srcdir)/{lib,src}/*.c \
|
||||
| grep -v '_(' && \
|
||||
{ echo '$(ME): found unmarked diagnostic(s)' 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,
|
||||
@@ -80,6 +277,22 @@ strftime-check:
|
||||
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 -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
|
||||
&& { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
|
||||
|
||||
news-date-check: NEWS
|
||||
today=`date +%Y-%m-%d`; \
|
||||
if head NEWS | grep '^\*.*'$$today >/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "today's date is not in NEWS" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
changelog-check:
|
||||
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
|
||||
:; \
|
||||
@@ -94,31 +307,44 @@ m4-check:
|
||||
exit 1; } || :
|
||||
|
||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||
# FIXME: don't hard-code src/false.c below; use a more general mechanism.
|
||||
po-check:
|
||||
if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
|
||||
files=; \
|
||||
if test -f po/POTFILES.in; then \
|
||||
grep -E -v '^(#|$$)' po/POTFILES.in \
|
||||
| grep -v '^src/false\.c$$' | 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; \
|
||||
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_ (' && \
|
||||
@grep -n '^# *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 -n '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 \
|
||||
@@ -137,7 +363,7 @@ 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) \
|
||||
grep 'enum { COPYRIGHT_YEAR = 2005 };' $(v_etc_file) \
|
||||
>/dev/null \
|
||||
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
|
||||
exit 1; }; \
|
||||
@@ -153,10 +379,10 @@ cvs-tag-check:
|
||||
else :; fi
|
||||
|
||||
cvs-diff-check:
|
||||
if $(CVS) diff >cvs-diffs; then \
|
||||
rm cvs-diffs; \
|
||||
else \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
if $(CVS) diff >cvs-diffs; then \
|
||||
rm cvs-diffs; \
|
||||
else \
|
||||
echo "Some files are locally modified:" 1>&2; \
|
||||
cat cvs-diffs; \
|
||||
exit 1; \
|
||||
fi
|
||||
@@ -188,27 +414,33 @@ null_AM_MAKEFLAGS = \
|
||||
# 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
|
||||
# treated as a failure. Also, check for shadowing problems with -Wshadow.
|
||||
# These CFLAGS are pretty strict. If you build this target, you probably
|
||||
# have to have a recent version of gcc and glibc headers.
|
||||
TMPDIR ?= /tmp
|
||||
t=$(TMPDIR)/$(PACKAGE)/test
|
||||
my-distcheck: $(local-check)
|
||||
-rm -rf $(t)
|
||||
mkdir $(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 \
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) distclean
|
||||
cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
||||
(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/ -//')
|
||||
@@ -224,62 +456,31 @@ rel-check:
|
||||
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); \
|
||||
$(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
|
||||
|
||||
news-r1 = /^[^ ].*$(THIS_VERSION_REGEXP)[]:]/
|
||||
news-r2 = /^[^ ].*$(PREV_VERSION_REGEXP)[]:]/
|
||||
|
||||
rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
|
||||
rel-files = $(xd-delta) $(DIST_ARCHIVES)
|
||||
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:"; \
|
||||
echo; \
|
||||
echo "$(tgz-md5) $(my_distdir).tar.gz"; \
|
||||
echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
|
||||
echo "$(xdelta-md5) $(xd-delta)"; \
|
||||
echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
|
||||
echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
|
||||
echo "$(xdelta-sha1) $(xd-delta)"; \
|
||||
echo; \
|
||||
echo NEWS:; \
|
||||
sed -n "$(news-r1),$(news-r2)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"'; \
|
||||
)
|
||||
@./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
|
||||
@@ -304,7 +505,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
|
||||
@@ -321,64 +523,77 @@ 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/config.guess \
|
||||
$(srcdir)/config/config.sub \
|
||||
$(srcdir)/src/ansi2knr.c \
|
||||
$(srcdir)/config/texinfo.tex
|
||||
wget_files ?= \
|
||||
$(srcdir)/build-aux/config.guess \
|
||||
$(srcdir)/build-aux/config.sub \
|
||||
$(srcdir)/build-aux/texinfo.tex \
|
||||
$(srcdir)/src/ansi2knr.c
|
||||
|
||||
get-targets = $(patsubst %, get-%, $(wget_files))
|
||||
|
||||
config.guess-url_prefix = $(ftp-gnu)/config/
|
||||
config.sub-url_prefix = $(ftp-gnu)/config/
|
||||
config.guess-url_prefix = $(ftp-gnu)/build-aux/
|
||||
config.sub-url_prefix = $(ftp-gnu)/build-aux/
|
||||
|
||||
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: $(get-targets)
|
||||
$(get-targets):
|
||||
$(WGET) $(url) -O $(target).t \
|
||||
$(WGET) $(WGETFLAGS) $(url) -O $(target).t \
|
||||
&& $(move_if_change) $(target).t $(target)
|
||||
|
||||
cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing $(srcdir)/config/mkinstalldirs \
|
||||
$(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
|
||||
cvs_files ?= \
|
||||
$(srcdir)/build-aux/depcomp \
|
||||
$(srcdir)/build-aux/install-sh \
|
||||
$(srcdir)/build-aux/missing \
|
||||
$(srcdir)/build-aux/mkinstalldirs \
|
||||
$(srcdir)/src/ansi2knr.c
|
||||
automake_repo=:pserver:anoncvs:[email protected]:/cvs/automake
|
||||
.PHONY: wget-update
|
||||
wget-update: $(get-targets)
|
||||
|
||||
.PHONY: cvs-update
|
||||
cvs-update:
|
||||
for f in $(cvs_files); do \
|
||||
test -f $$f || { echo "*** skipping $$f" 1>&2; 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
|
||||
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
|
||||
|
||||
define emit-upload-commands
|
||||
echo =====================================
|
||||
echo =====================================
|
||||
echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
|
||||
echo '# send the /tmp/announcement e-mail'
|
||||
echo =====================================
|
||||
echo =====================================
|
||||
endef
|
||||
emit_upload_commands:
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
@echo "$(srcdir)/gnupload $(GNUPLOADFLAGS) \\"
|
||||
@echo " --to $(gnu_rel_host):coreutils \\"
|
||||
@echo " $(rel-files)"
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
|
||||
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
||||
xdelta delta -9 $^ $@ || :
|
||||
|
||||
alpha: $(local-check)
|
||||
.PHONY: alpha beta major
|
||||
alpha beta major: news-date-check $(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)
|
||||
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
||||
echo $(VERSION) > $(prev_version_file)
|
||||
$(CVS) ci -m. $(prev_version_file)
|
||||
@$(emit-upload-commands)
|
||||
|
||||
@@ -1,6 +1,94 @@
|
||||
Bison News
|
||||
----------
|
||||
|
||||
Changes in version 2.1, 2005-09-16:
|
||||
|
||||
* Bison-generated parsers now support the translation of diagnostics like
|
||||
"syntax error" into languages other than English. The default
|
||||
language is still English. For details, please see the new
|
||||
Internationalization section of the Bison manual. Software
|
||||
distributors should also see the new PACKAGING file. Thanks to
|
||||
Bruno Haible for this new feature.
|
||||
|
||||
* Wording in the Bison-generated parsers has been changed slightly to
|
||||
simplify translation. In particular, the message "memory exhausted"
|
||||
has replaced "parser stack overflow", as the old message was not
|
||||
always accurate for modern Bison-generated parsers.
|
||||
|
||||
* Destructors are now called when the parser aborts, for all symbols left
|
||||
behind on the stack. Also, the start symbol is now destroyed after a
|
||||
successful parse. In both cases, the behavior was formerly inconsistent.
|
||||
|
||||
* When generating verbose diagnostics, Bison-generated parsers no longer
|
||||
quote the literal strings associated with tokens. For example, for
|
||||
a syntax error associated with '%token NUM "number"' they might
|
||||
print 'syntax error, unexpected number' instead of 'syntax error,
|
||||
unexpected "number"'.
|
||||
|
||||
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
|
||||
@@ -93,7 +181,7 @@ Changes in version 1.875, 2003-01-01:
|
||||
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.
|
||||
@@ -124,7 +212,7 @@ Changes in version 1.75, 2002-10-14:
|
||||
|
||||
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
|
||||
@@ -171,7 +259,8 @@ Changes in version 1.50, 2002-10-04:
|
||||
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
|
||||
<http://mail.gnu.org/pipermail/bug-bison/2002-May/001452.html>.
|
||||
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.
|
||||
@@ -246,8 +335,8 @@ Changes in version 1.50, 2002-10-04:
|
||||
produces additional information:
|
||||
- itemset
|
||||
complete the core item sets with their closure
|
||||
- lookahead
|
||||
explicitly associate lookaheads to items
|
||||
- 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
|
||||
@@ -334,6 +423,8 @@ Changes in version 1.31, 2002-01-14:
|
||||
alloca is used only when compiled with GCC, to avoid portability
|
||||
problems as on AIX.
|
||||
|
||||
* yyparse now returns 2 if memory is exhausted; formerly it dumped core.
|
||||
|
||||
* When the generated parser lacks debugging code, YYDEBUG is now 0
|
||||
(as POSIX requires) instead of being undefined.
|
||||
|
||||
@@ -528,7 +619,7 @@ End:
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
@@ -545,5 +636,5 @@ 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.
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
Packaging hints for binary package distributors
|
||||
===============================================
|
||||
|
||||
Although the source of the bison package comes as a single package,
|
||||
in distributions of binary packages the installed files should
|
||||
be split into two packages:
|
||||
|
||||
bison-runtime
|
||||
Contents: Runtime libraries and programs.
|
||||
Audience: Anyone who wants to run internationalized programs
|
||||
that contain Bison-generated parsers.
|
||||
|
||||
bison
|
||||
Contents: Tools and documentation for developers that use Bison.
|
||||
Audience: Anyone who wants to develop programs that use parsers.
|
||||
Dependencies: requires bison-runtime.
|
||||
|
||||
The 'bison-runtime' binary package is much smaller than the 'bison'
|
||||
binary package. It should be included in any distribution that
|
||||
contains localized programs that use the diagnostics contained in
|
||||
Bison-generated parsers.
|
||||
|
||||
If you want to install both packages at the same time, you simply do
|
||||
at the toplevel directory:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
After installation, the file
|
||||
|
||||
$prefix/share/locale/*/LC_MESSAGES/bison-runtime.mo
|
||||
|
||||
belongs to the bison-runtime package; all other installed files belong
|
||||
to the bison package.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
@@ -1,24 +1,41 @@
|
||||
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.3 or later. See:
|
||||
|
||||
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.3.tar.gz
|
||||
|
||||
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.
|
||||
Bison can work with pre-1.4.3 distributions of GNU m4 if they are
|
||||
sufficiently patched, but if you encounter a bug with an older
|
||||
distribution and report a bug we will probably suggest that you
|
||||
upgrade to 1.4.3 as the first step in trying to fix it.
|
||||
|
||||
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.
|
||||
Please 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].
|
||||
If you have questions about using Bison and the documentation does
|
||||
not answer them, please send mail to <[email protected]>.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1992, 1998, 1999, 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
+4
-10
@@ -7,18 +7,12 @@ 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 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
@@ -34,5 +28,5 @@ 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.
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
+23
-29
@@ -6,14 +6,28 @@ Bison.
|
||||
* Requirements
|
||||
|
||||
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:
|
||||
maintenance, merges etc.), therefore you will have to get the latest
|
||||
stable versions of the maintainer tools we depend upon, including:
|
||||
|
||||
- Automake 1.7
|
||||
- Automake <http://www.gnu.org/software/automake/>
|
||||
- Autoconf <http://www.gnu.org/software/autoconf/>
|
||||
- Flex <http://www.gnu.org/software/flex/>
|
||||
- Gettext <http://www.gnu.org/software/gettext/>
|
||||
- Gzip <http://www.gnu.org/software/gzip/>
|
||||
- Tar <http://www.gnu.org/software/tar/>
|
||||
- Wget <http://www.gnu.org/software/wget/>
|
||||
|
||||
- Autoconf 2.54
|
||||
As of this writing, the latest stable version of Gzip is 1.2.4 but we
|
||||
suggest using test version 1.3.5 (or later, if one becomes available).
|
||||
|
||||
- Gettext 0.11.5
|
||||
Valgrind <http://valgrind.org/> is also highly recommended, if
|
||||
Valgrind supports your architecture.
|
||||
|
||||
Bison is written using Bison grammars, so there are bootstrapping
|
||||
issues. The bootstrap script attempts to discover when the C code
|
||||
generated from the grammars is out of date, and to bootstrap with an
|
||||
out-of-date version of the C code, but the process is not foolproof.
|
||||
Also, you may run into similar problems yourself if you modify Bison.
|
||||
|
||||
Only building the initial full source tree will be a bit painful,
|
||||
later, a plain `cvs update -P & make' should be sufficient.
|
||||
@@ -39,33 +53,13 @@ and the CVS master copy:
|
||||
|
||||
$ cvs diff
|
||||
|
||||
should output no difference, except maybe the date in po/*.po files.
|
||||
should output no difference.
|
||||
|
||||
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:
|
||||
http://www.lrde.epita.fr/~akim/download/
|
||||
|
||||
3. Extract it
|
||||
|
||||
4. Override the content of your checkout with the content of this
|
||||
tarball, i.e.:
|
||||
cp -r bison-1.49b/* bison-cvs
|
||||
|
||||
5. Proceed on ./configure && make etc.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
@@ -81,5 +75,5 @@ 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.
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, 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.]
|
||||
|
||||
@@ -5,12 +5,17 @@ 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]
|
||||
Anthony Heading [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Art Haas [email protected]
|
||||
Baron Schwartz [email protected]
|
||||
Benoit Perrot [email protected]
|
||||
Bert Deknuydt [email protected]
|
||||
Bruce Lilly [email protected]
|
||||
Bruno Haible [email protected]
|
||||
Charles-Henri de Boysson [email protected]
|
||||
Cris Bailiff [email protected]
|
||||
Cris van Pelt [email protected]
|
||||
@@ -21,12 +26,15 @@ Enrico Scholz [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Florian Krohm [email protected]
|
||||
Frank Heckenbach [email protected]
|
||||
Guido Trentalancia [email protected]
|
||||
H. Merijn Brand [email protected]
|
||||
Hans Aberg [email protected]
|
||||
Jan Nieuwenhuizen [email protected]
|
||||
Jesse Thilo [email protected]
|
||||
Jim Kent [email protected]
|
||||
Jim Meyering [email protected]
|
||||
Joel E. Denny [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne [email protected]
|
||||
@@ -44,10 +52,11 @@ Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand [email protected]
|
||||
Noah Friedman [email protected]
|
||||
Pascal Bart [email protected]
|
||||
Paul Eggert eggert@twinsun.com
|
||||
Paul Eggert eggert@cs.ucla.edu
|
||||
Paul Hilfinger [email protected]
|
||||
Per Allansson [email protected]
|
||||
Peter Hámorský [email protected]
|
||||
Peter Fales [email protected]
|
||||
Peter Hamorsky [email protected]
|
||||
Piotr Gackiewicz [email protected]
|
||||
Quoc Peyrot [email protected]
|
||||
R Blake [email protected]
|
||||
@@ -59,10 +68,13 @@ 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]
|
||||
[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.
|
||||
|
||||
@@ -12,24 +12,22 @@ They should not: it is not documented. But if they need to, let's
|
||||
find something clean (not like YYLSP_NEEDED...).
|
||||
|
||||
|
||||
* URGENT: Documenting C++ output
|
||||
Write a first documentation for C++ output.
|
||||
|
||||
|
||||
* Documentation
|
||||
Before releasing, make sure the documentation ("Understanding your
|
||||
parser") refers to the current `output' format.
|
||||
|
||||
* lalr1.cc
|
||||
** vector
|
||||
Move to using vector, drop stack.hh.
|
||||
|
||||
* GLR & C++
|
||||
Currently, the GLR parser cannot compile with a C++ compiler.
|
||||
|
||||
** I18n
|
||||
Catch up with yacc.c.
|
||||
|
||||
* Report
|
||||
|
||||
** GLR
|
||||
How would Paul like to display the conflicted actions? In particular,
|
||||
what when two reductions are possible on a given lookahead, but one is
|
||||
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.
|
||||
|
||||
@@ -52,14 +50,7 @@ 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
|
||||
** Labeling the symbols
|
||||
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:
|
||||
|
||||
@@ -69,6 +60,21 @@ 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...
|
||||
|
||||
But instead of using $a etc., we can use regular variables. And
|
||||
instead of using (), I propose to use `:' (again). Paul suggests
|
||||
supporting `->' in addition to `:' to separate LHS and RHS. In other
|
||||
words:
|
||||
|
||||
r:exp -> a:exp '+' b:exp { r = a + b; };
|
||||
|
||||
That requires an significant improvement of the grammar parser. Using
|
||||
GLR would be nice. It also requires that Bison know the type of the
|
||||
symbols (which will be useful for %include anyway). So we have some
|
||||
time before...
|
||||
|
||||
Note that there remains the problem of locations: `@r'?
|
||||
|
||||
|
||||
** $-1
|
||||
We should find a means to provide an access to values deep in the
|
||||
stack. For instance, instead of
|
||||
@@ -81,7 +87,6 @@ we should be able to have:
|
||||
|
||||
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
|
||||
@@ -118,6 +123,20 @@ to avoid falling into another CPP mistake.
|
||||
** -D, --define-muscle NAME=VALUE
|
||||
To define muscles via cli. Or maybe support directly NAME=VALUE?
|
||||
|
||||
** 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.
|
||||
|
||||
XML output for GNU Bison and gcc
|
||||
http://www.cs.may.ie/~jpower/Research/bisonXML/
|
||||
|
||||
XML output for GNU Bison
|
||||
http://yaxx.sourceforge.net/
|
||||
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
@@ -161,7 +180,7 @@ There are a couple of proposed outputs:
|
||||
which is based on Bison.
|
||||
<http://www.goice.co.jp/member/mo/hack-progs/bison-java.html>
|
||||
|
||||
Sébastien Serrurier ([email protected]) is working on this: he is
|
||||
Sebastien Serrurier ([email protected]) is working on this: he is
|
||||
expected to contact the authors, design the output, and implement it
|
||||
into Bison.
|
||||
|
||||
@@ -179,7 +198,9 @@ Paul notes:
|
||||
PDP-10 ports :-) but they should probably be documented
|
||||
somewhere.
|
||||
|
||||
|
||||
More importantly, Bison does not currently allow NUL bytes in
|
||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||
the source code. This should get fixed.
|
||||
|
||||
* --graph
|
||||
Show reductions. []
|
||||
@@ -324,7 +345,7 @@ 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 Bison.
|
||||
|
||||
@@ -340,5 +361,5 @@ 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.
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
@@ -1,6 +1,325 @@
|
||||
#! /bin/sh
|
||||
|
||||
echo "Bootstrapping CVS Bison..."
|
||||
# Bootstrap this package from CVS.
|
||||
|
||||
echo "running: autoreconf --verbose --install --force"
|
||||
autoreconf --verbose --install --force
|
||||
# Copyright (C) 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, 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.
|
||||
# Also, ensure diagnostics are in English, e.g., "wget --help" below.
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
# Parse options.
|
||||
|
||||
for option
|
||||
do
|
||||
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
|
||||
|
||||
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
|
||||
gettext
|
||||
hard-locale
|
||||
hash
|
||||
malloc
|
||||
mbswidth
|
||||
obstack
|
||||
quote
|
||||
quotearg
|
||||
stdbool
|
||||
stdio-safer
|
||||
stpcpy
|
||||
unistd-safer
|
||||
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
|
||||
|
||||
# This suppresses a bogus diagnostic
|
||||
# "warning: macro `AM_LANGINFO_CODESET' not found in library".
|
||||
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
|
||||
'')
|
||||
case `wget --help` in
|
||||
*'--no-cache'*)
|
||||
no_cache='--no-cache';;
|
||||
*'--cache=on/off'*)
|
||||
no_cache='--cache=off';;
|
||||
*)
|
||||
no_cache='';;
|
||||
esac
|
||||
|
||||
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 $no_cache \
|
||||
http://www.iro.umontreal.ca/translation/maint/$package/ &&
|
||||
ls *.po | sed 's/\.po$//' >LINGUAS
|
||||
) || exit
|
||||
|
||||
case $package in
|
||||
bison)
|
||||
echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
|
||||
(cd runtime-po &&
|
||||
rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po$/p'` &&
|
||||
wget -nv -nd -r -l 1 -A .po $no_cache \
|
||||
http://www.iro.umontreal.ca/translation/maint/$package-runtime/ &&
|
||||
|
||||
# For translations that have not yet been upgraded to the new
|
||||
# runtime-po domain, prime the pump by extracting the relevant
|
||||
# strings from the obsolete translations.
|
||||
# This code can be removed once the bison-runtime domain
|
||||
# has been translated by each team.
|
||||
for po in ../po/*.po; do
|
||||
test -f "$po" || continue
|
||||
runpo=`basename $po`
|
||||
test -f $runpo || {
|
||||
msggrep -K \
|
||||
-e 'memory exhausted' \
|
||||
-e 'syntax error' \
|
||||
$po 2>/dev/null |
|
||||
sed '
|
||||
s/^#~ //
|
||||
/^msgid "syntax error; also memory exhausted"$/,/^$/d
|
||||
/^$/,${ /^#/d; }
|
||||
' >$runpo-
|
||||
if cmp -s $runpo- $runpo; then
|
||||
rm $runpo-
|
||||
else
|
||||
mv $runpo- $runpo
|
||||
fi
|
||||
test -s $runpo || rm -f $runpo
|
||||
} || exit
|
||||
done &&
|
||||
|
||||
ls *.po | sed 's/\.po$//' >LINGUAS
|
||||
) || exit
|
||||
esac;;
|
||||
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/glibc2.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
|
||||
|
||||
# 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
|
||||
|
||||
# Likewise for runtime-po/Makevars, except also change a few other parameters.
|
||||
sed '
|
||||
s/^\(DOMAIN\) *=.*/\1 = bison-runtime/
|
||||
s/^\(subdir\) *=.*/\1 = runtime-po/
|
||||
s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = --keyword=YY_/
|
||||
' <po/Makevars >runtime-po/Makevars
|
||||
|
||||
# Copy identical files from po to runtime-po.
|
||||
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
|
||||
|
||||
# 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'."
|
||||
|
||||
+1
-9
@@ -1,11 +1,3 @@
|
||||
Makefile
|
||||
*.t
|
||||
Makefile
|
||||
Makefile.in
|
||||
mkinstalldirs
|
||||
missing
|
||||
config.sub
|
||||
config.guess
|
||||
mdate-sh
|
||||
texinfo.tex
|
||||
config.rpath
|
||||
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 config.rpath
|
||||
EXTRA_DIST = prev-version.txt
|
||||
|
||||
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;
|
||||
}
|
||||
-423
@@ -1,423 +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 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.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1="$dir.libs/$base.lo.d"
|
||||
tmpdepfile2="$dir.libs/$base.d"
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1="$dir$base.o.d"
|
||||
tmpdepfile2="$dir$base.d"
|
||||
"$@" -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.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'. We will use -o /dev/null later,
|
||||
# however we can't do the remplacement now because
|
||||
# `-o $object' might simply not be used
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
"$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
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)
|
||||
"$@" || exit $?
|
||||
# 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} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
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.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
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.
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
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"
|
||||
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,276 +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 "$0: no input file specified" >&2
|
||||
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" ] || [ -d "$src" ]
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "$0: $src does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "$0: no destination specified" >&2
|
||||
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 couple of temp file names in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
rmtmp=$dstdir/#rm.$$#
|
||||
|
||||
# Trap to clean up temp files at exit.
|
||||
|
||||
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd "$src" "$dsttmp" &&
|
||||
|
||||
# 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 remove or move aside any old file at destination location. We try this
|
||||
# two ways since rm can't unlink itself on some systems and the destination
|
||||
# file might be busy for other reasons. In this case, the final cleanup
|
||||
# might fail but the new file should still install successfully.
|
||||
|
||||
{
|
||||
if [ -f "$dstdir/$dstfile" ]
|
||||
then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
|
||||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
|
||||
{
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
|
||||
fi &&
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
|
||||
{
|
||||
(exit 0); exit
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Like mv $1 $2, but if the files are the same, just delete $1.
|
||||
# Status is 0 if $2 is changed, 1 otherwise.
|
||||
if
|
||||
test -r $2
|
||||
then
|
||||
if
|
||||
cmp -s $1 $2
|
||||
then
|
||||
echo $2 is unchanged
|
||||
rm -f $1
|
||||
else
|
||||
mv -f $1 $2
|
||||
fi
|
||||
else
|
||||
mv -f $1 $2
|
||||
fi
|
||||
@@ -1 +1 @@
|
||||
1.75
|
||||
2.0
|
||||
|
||||
+57
-41
@@ -1,6 +1,6 @@
|
||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2003, 2004, 2005 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
|
||||
@@ -14,24 +14,27 @@
|
||||
#
|
||||
# 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
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
# We need a recent Autoconf to run a recent Autotest.
|
||||
AC_PREREQ(2.54)
|
||||
# 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.875], [[email protected]])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_INIT([GNU Bison], [2.1], [[email protected]])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.7 check-news readme-alpha dist-bzip2])
|
||||
# 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])
|
||||
|
||||
gl_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# Checks for the compiler.
|
||||
AC_PROG_CC
|
||||
# Remove with Automake 1.8.
|
||||
AC_ISC_POSIX
|
||||
AC_GNU_SOURCE
|
||||
AC_MINIX
|
||||
AM_PROG_CC_STDC
|
||||
AC_ARG_ENABLE(gcc-warnings,
|
||||
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended)],
|
||||
@@ -44,21 +47,38 @@ 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
|
||||
|
||||
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
|
||||
@@ -70,9 +90,8 @@ 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])
|
||||
AC_HEADER_STDBOOL
|
||||
AC_CHECK_HEADERS_ONCE([locale.h])
|
||||
AM_STDBOOL_H
|
||||
|
||||
# Checks for compiler characteristics.
|
||||
AC_C_INLINE
|
||||
@@ -81,46 +100,43 @@ AC_C_INLINE
|
||||
AC_CHECK_TYPES([uintptr_t])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_OBSTACK
|
||||
AC_FUNC_ERROR_AT_LINE
|
||||
AC_FUNC_STRNLEN
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_DECLS([free, getenv, getopt,
|
||||
stpcpy, strchr, strspn, strnlen,
|
||||
malloc, memchr, memrchr])
|
||||
AC_REPLACE_FUNCS(memchr memrchr \
|
||||
strchr stpcpy strrchr strspn strtol strtoul)
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
jm_PREREQ_MBSWIDTH
|
||||
jm_PREREQ_QUOTEARG
|
||||
jm_FUNC_ARGMATCH
|
||||
jm_PREREQ_ERROR
|
||||
AC_CHECK_FUNCS_ONCE([setlocale])
|
||||
AM_WITH_DMALLOC
|
||||
BISON_PREREQ_SUBPIPE
|
||||
BISON_PREREQ_TIMEVAR
|
||||
|
||||
# Gettext.
|
||||
AM_GNU_GETTEXT(external, need-ngettext)
|
||||
AM_GNU_GETTEXT_VERSION(0.11.5)
|
||||
# gnulib and gettext.
|
||||
GNULIB_AUTOCONF_SNIPPET
|
||||
# We use po/Makevars, so we need at least gettext 0.12.
|
||||
AM_GNU_GETTEXT_VERSION([0.12])
|
||||
BISON_I18N
|
||||
|
||||
# Internationalized parsers.
|
||||
AC_CONFIG_FILES([runtime-po/Makefile.in])
|
||||
# Autoconf macros for packages using internationalized parsers.
|
||||
aclocaldir='${datadir}/aclocal'
|
||||
AC_SUBST([aclocaldir])
|
||||
|
||||
# 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_CHECK_PROGS([GXX], [g++])
|
||||
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] *//'`
|
||||
O0CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]] *//'`
|
||||
AC_SUBST([O0CFLAGS])
|
||||
O0CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]] *//'`
|
||||
AC_SUBST([O0CXXFLAGS])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
config/Makefile
|
||||
po/Makefile.in
|
||||
data/Makefile
|
||||
lib/Makefile src/Makefile doc/Makefile
|
||||
m4/Makefile])
|
||||
examples/Makefile
|
||||
examples/calc++/Makefile
|
||||
lib/Makefile src/Makefile doc/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2002, 2005 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
|
||||
@@ -12,10 +12,12 @@
|
||||
|
||||
## 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
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
dist_pkgdata_DATA = README c.m4 yacc.c lalr1.cc glr.c
|
||||
dist_pkgdata_DATA = README \
|
||||
c.m4 yacc.c glr.c \
|
||||
c++.m4 lalr1.cc
|
||||
|
||||
m4sugardir = $(pkgdatadir)/m4sugar
|
||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4
|
||||
|
||||
+2
-2
@@ -41,5 +41,5 @@ 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.
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
m4_divert(-1)
|
||||
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002, 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
# Default parser class name.
|
||||
m4_define_default([b4_parser_class_name], [parser])
|
||||
m4_define_default([b4_location_type], [location])
|
||||
m4_define_default([b4_filename_type], [std::string])
|
||||
|
||||
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[m4_if([$@], [[]], [],
|
||||
[/* Tokens. */
|
||||
enum yytokentype {
|
||||
m4_map_sep([ b4_token_enum], [,
|
||||
],
|
||||
[$@])
|
||||
};
|
||||
])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_lhs_value([TYPE])
|
||||
# --------------------
|
||||
# Expansion of $<TYPE>$.
|
||||
m4_define([b4_lhs_value],
|
||||
[(yyval[]m4_ifval([$1], [.$1]))])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||
# --------------------------------------
|
||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||
# symbols on RHS.
|
||||
m4_define([b4_rhs_value],
|
||||
[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylocation_stack_@{m4_eval([$1 - $2])@})])
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
# Change the parameter names from "foo" into "foo_yyarg", so that
|
||||
# there is no collision bw the user chosen attribute name, and the
|
||||
# argument name in the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
|
||||
|
||||
m4_define([b4_parse_param_decl_1],
|
||||
[$1_yyarg])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[,
|
||||
b4_cc_constructor_calls(b4_parse_param)])])
|
||||
m4_define([b4_cc_constructor_calls],
|
||||
[m4_map_sep([b4_cc_constructor_call], [,
|
||||
], [$@])])
|
||||
m4_define([b4_cc_constructor_call],
|
||||
[$2 ($2_yyarg)])
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
/* User arguments. */
|
||||
b4_cc_var_decls(b4_parse_param)])])
|
||||
m4_define([b4_cc_var_decls],
|
||||
[m4_map_sep([b4_cc_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_cc_var_decl],
|
||||
[ $1;])
|
||||
@@ -1,7 +1,7 @@
|
||||
m4_divert(-1) -*- Autoconf -*-
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002, 2004, 2005 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,8 +15,8 @@ m4_divert(-1) -*- Autoconf -*-
|
||||
|
||||
# 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
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
@@ -43,8 +43,8 @@ m4_define([b4_copyright],
|
||||
|
||||
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. */])
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */])
|
||||
|
||||
|
||||
# b4_identification
|
||||
@@ -53,6 +53,9 @@ m4_define([b4_identification],
|
||||
[/* Identify Bison output. */
|
||||
[#]define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
[#]define YYBISON_VERSION "b4_version"
|
||||
|
||||
/* Skeleton name. */
|
||||
[#]define YYSKELETON_NAME b4_skeleton
|
||||
|
||||
@@ -114,12 +117,12 @@ 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],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
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])])
|
||||
[int])])
|
||||
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
@@ -166,6 +169,16 @@ m4_define([b4_token_define],
|
||||
])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as #defines.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_if([$@], [[]], [],
|
||||
[/* Tokens. */
|
||||
m4_map([b4_token_define], [$@])])
|
||||
])
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
@@ -173,10 +186,10 @@ 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],
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[m4_if([$@], [[]], [],
|
||||
[/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@@ -189,8 +202,14 @@ m4_map_sep([ b4_token_enum], [,
|
||||
[$@])
|
||||
};
|
||||
#endif
|
||||
m4_map([b4_token_define], [$@])
|
||||
])
|
||||
])])
|
||||
|
||||
|
||||
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as enums and #defines.
|
||||
m4_define([b4_token_enums_defines],
|
||||
[b4_token_enums($@)b4_token_defines($@)
|
||||
])
|
||||
|
||||
|
||||
@@ -327,7 +346,8 @@ m4_define([b4_syncline],
|
||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||
# -------------------------------------------------
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_dollar_dollar], [yyvaluep->$6])dnl
|
||||
[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])
|
||||
@@ -344,13 +364,14 @@ m4_popdef([b4_dollar_dollar])dnl
|
||||
# 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],
|
||||
m4_define_default([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]]]))[
|
||||
@@ -359,6 +380,10 @@ m4_define([b4_yydestruct_generate],
|
||||
(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]))[
|
||||
@@ -374,7 +399,7 @@ m4_define([b4_yydestruct_generate],
|
||||
# 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],
|
||||
m4_define_default([b4_yysymprint_generate],
|
||||
[[/*--------------------------------.
|
||||
| Print this symbol on YYOUTPUT. |
|
||||
`--------------------------------*/
|
||||
@@ -390,23 +415,26 @@ m4_define([b4_yysymprint_generate],
|
||||
(void) yyvaluep;
|
||||
b4_location_if([ (void) yylocationp;
|
||||
])dnl
|
||||
|
||||
[
|
||||
if (yytype < YYNTOKENS)
|
||||
{
|
||||
YYFPRINTF (yyoutput, "token %s (", yytname[[yytype]]);
|
||||
# ifdef YYPRINT
|
||||
YYPRINT (yyoutput, yytoknum[[yytype]], *yyvaluep);
|
||||
# endif
|
||||
}
|
||||
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||
else
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[[yytype]]);
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||
|
||||
]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPRINTF (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:
|
||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
}
|
||||
])
|
||||
]])
|
||||
|
||||
+786
-412
File diff suppressed because it is too large
Load Diff
+951
-471
File diff suppressed because it is too large
Load Diff
+340
-376
File diff suppressed because it is too large
Load Diff
+408
-209
File diff suppressed because it is too large
Load Diff
+21
-1
@@ -1,12 +1,32 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2001, 2002, 2003, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
AM_MAKEINFOFLAGS = --no-split
|
||||
info_TEXINFOS = bison.texinfo
|
||||
man_MANS = bison.1
|
||||
bison_TEXINFOS = gpl.texi fdl.texi
|
||||
|
||||
EXTRA_DIST = FAQ bison.1 refcard.tex
|
||||
|
||||
CLEANFILES = refcard.dvi refcard.log refcard.ps
|
||||
CLEANFILES = refcard.dvi refcard.log refcard.ps bison.fns
|
||||
|
||||
clean-local:
|
||||
rm -rf *.t2d
|
||||
|
||||
refcard.dvi: refcard.tex
|
||||
tex refcard.tex
|
||||
|
||||
+1858
-412
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -7,7 +7,7 @@
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
@@ -344,7 +344,7 @@ and independent documents or works, in or on a volume of a storage or
|
||||
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 an aggregate, this License does not
|
||||
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.
|
||||
|
||||
@@ -366,7 +366,7 @@ 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, and all the license notices in the
|
||||
Document, and any Warrany Disclaimers, provided that you also include
|
||||
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
|
||||
@@ -420,8 +420,8 @@ license notices just after the title page:
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2
|
||||
or any later version published by the Free Software Foundation;
|
||||
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
|
||||
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
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
@@ -352,7 +352,7 @@ 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.
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
@end smallexample
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
+6
-6
@@ -35,8 +35,8 @@
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with either Flex or Bison; see the file COPYING. If not, write
|
||||
% to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
% Boston, MA 02111-1307, USA.
|
||||
% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
% Boston, MA 02110-1301, USA.
|
||||
%
|
||||
% This file is intended to be processed by plain TeX (TeX82).
|
||||
%
|
||||
@@ -96,9 +96,9 @@ For information, write to the:
|
||||
\vskip .2\baselineskip
|
||||
\centerline{Free Software Foundation, Inc.}
|
||||
\vskip .2\baselineskip
|
||||
\centerline{59 Temple Place - Suite 330}
|
||||
\centerline{51 Franklin Street, Fifth Floor}
|
||||
\vskip .2\baselineskip
|
||||
\centerline{Boston, MA 02111-1307 USA}
|
||||
\centerline{Boston, MA 02110-1301 USA}
|
||||
\endgroup}
|
||||
|
||||
%%%% smallcopyrightnotice for two column printing on one page.
|
||||
@@ -121,9 +121,9 @@ For information, write to the:
|
||||
\vskip .2\baselineskip
|
||||
\centerline{Free Software Foundation, Inc.}
|
||||
\vskip .2\baselineskip
|
||||
\centerline{59 Temple Place - Suite 330}
|
||||
\centerline{51 Franklin Street, Fifth Floor}
|
||||
\vskip .2\baselineskip
|
||||
\centerline{Boston, MA 02111-1307 USA}
|
||||
\centerline{Boston, MA 02110-1301 USA}
|
||||
\endgroup}
|
||||
|
||||
% make \bye not \outer so that the \def\bye in the \else clause below
|
||||
|
||||
-300
@@ -1,300 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# clcommit version 0.9.5
|
||||
|
||||
# Copyright (C) 1999, 2000, Free Software Foundation
|
||||
|
||||
# This script is Free Software, and it can be copied, distributed and
|
||||
# modified as defined in the GNU General Public License. A copy of
|
||||
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
# Originally by Gary V. Vaughan <[email protected]>
|
||||
# Pretty much rewritten by Alexandre Oliva <[email protected]>
|
||||
|
||||
# This scripts eases checking in changes to CVS-maintained projects
|
||||
# with ChangeLog files. It will check that there have been no
|
||||
# conflicting commits in the CVS repository and print which files it
|
||||
# is going to commit to stderr. A list of files to compare and to
|
||||
# check in can be given in the command line. If it is not given, all
|
||||
# files in the current directory (and below, unless `-l' is given) are
|
||||
# considered for check in.
|
||||
|
||||
# The commit message will be extracted from the differences between a
|
||||
# file named ChangeLog* in the commit list, or named after -C, and the
|
||||
# one in the repository (unless a message was specified with `-m' or
|
||||
# `-F'). An empty message is not accepted (but a blank line is). If
|
||||
# the message is acceptable, it will be presented for verification
|
||||
# (and possible edition) using the $PAGER environment variable (or
|
||||
# `more', if it is not set, or `cat', if the `-f' switch is given).
|
||||
# If $PAGER exits successfully, the modified files (at that moment)
|
||||
# are checked in, unless `-n' was specified, in which case nothing is
|
||||
# checked in.
|
||||
|
||||
# usage: clcommit [-v] [-h] [-f] [-l] [-n] [-q] [-z N] [-C ChangeLog_file]
|
||||
# [-m msg|-F msg_file|-1] [--] [file|dir ...]
|
||||
|
||||
# -f --force don't check (unless *followed* by -n), and just
|
||||
# display commit message instead of running $PAGER
|
||||
# -l --local don't descend into subdirectories
|
||||
# -m msg --message=msg set commit message
|
||||
# --msg=msg same as -m
|
||||
# -F file --file=file read commit message from file
|
||||
# -1 --first extract first entry from ChangeLog, no cvs diff
|
||||
# -C file --changelog=file extract commit message from specified ChangeLog
|
||||
# --fast same as --force --first
|
||||
# -n --dry-run don't commit anything
|
||||
# -q --quiet run cvs in quiet mode
|
||||
# -zN --compress=N set compression level (0-9, 0=none, 9=max)
|
||||
# -v --version print version information
|
||||
# -h,-? --help print short or long help message
|
||||
|
||||
name=clcommit
|
||||
: ${CVS=cvs}
|
||||
cvsopt=
|
||||
updateopt=
|
||||
commitopt=
|
||||
dry_run=false
|
||||
commit=:
|
||||
update=:
|
||||
log_file="${TMPDIR-/tmp}/commitlog.$$"
|
||||
first=false
|
||||
|
||||
rm -f "$log_file"
|
||||
trap 'rm -f "$log_file"; exit 1' 1 2 15
|
||||
|
||||
# this just eases exit handling
|
||||
main_repeat=":"
|
||||
while $main_repeat; do
|
||||
|
||||
repeat="test $# -gt 0"
|
||||
while $repeat; do
|
||||
case "$1" in
|
||||
--fast)
|
||||
shift
|
||||
set fnord --force --first ${1+"$@"}
|
||||
shift
|
||||
;;
|
||||
-f|--force)
|
||||
update=false
|
||||
PAGER=cat
|
||||
shift
|
||||
;;
|
||||
-l|--local)
|
||||
updateopt="$updateopt -l"
|
||||
commitopt="$commitopt -l"
|
||||
shift
|
||||
;;
|
||||
-m|--message|--msg)
|
||||
if test $# = 1; then
|
||||
echo "$name: missing argument for $1" >&2
|
||||
break
|
||||
fi
|
||||
if $first || test -f "$log_file"; then
|
||||
echo "$name: you can have at most one of -m, -F and -1" >&2
|
||||
break
|
||||
fi
|
||||
shift
|
||||
echo "$1" > "$log_file"
|
||||
shift
|
||||
;;
|
||||
-F|--file)
|
||||
if $first || test -f "$log_file"; then
|
||||
echo "$name: you can have at most one of -m, -F and -1" >&2
|
||||
break
|
||||
fi
|
||||
if test $# = 1; then
|
||||
echo "$name: missing argument for $1" >&2
|
||||
break
|
||||
fi
|
||||
shift
|
||||
if cat < "$1" > "$log_file"; then :; else
|
||||
break
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-1|--first)
|
||||
if test -f "$log_File"; then
|
||||
echo "$name: you can have at most one of -m, -F and -1" >&2
|
||||
break
|
||||
fi
|
||||
first=:
|
||||
shift
|
||||
;;
|
||||
-C|--[cC]hange[lL]og)
|
||||
if test $# = 1; then
|
||||
echo "$name: missing argument for $1" >&2
|
||||
break
|
||||
fi
|
||||
shift
|
||||
if test ! -f "$1"; then
|
||||
echo "$name: ChangeLog file \`$1' does not exist" >&2
|
||||
break
|
||||
fi
|
||||
ChangeLog="$1"
|
||||
shift
|
||||
;;
|
||||
-n|--dry-run)
|
||||
commit=false
|
||||
update=true
|
||||
shift
|
||||
;;
|
||||
-q|--quiet)
|
||||
cvsopt="$cvsopt -q"
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
cvsopt="$cvsopt -t"
|
||||
shift
|
||||
;;
|
||||
-z|--compress)
|
||||
if test $# = 1; then
|
||||
echo "$name: missing argument for $1" >&2
|
||||
break
|
||||
fi
|
||||
case "$2" in
|
||||
[0-9]) :;;
|
||||
*) echo "$name: invalid argument for $1" >&2
|
||||
break
|
||||
;;
|
||||
esac
|
||||
cvsopt="$cvsopt -z$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
|
||||
-m*|-F*|-C*|-z*)
|
||||
opt=`echo "$1" | sed '1s/^\(..\).*$/\1/;q'`
|
||||
arg=`echo "$1" | sed '1s/^-[a-zA-Z0-9]//'`
|
||||
shift
|
||||
set -- "$opt" "$arg" ${1+"$@"}
|
||||
;;
|
||||
--message=*|--msg=*|--file=*|--[Cc]hange[Ll]og=*|--compress=*)
|
||||
opt=`echo "$1" | sed '1s/^\(--[^=]*\)=.*/\1/;q'`
|
||||
arg=`echo "$1" | sed '1s/^--[^=]*=//'`
|
||||
shift
|
||||
set -- "$opt" "$arg" ${1+"$@"}
|
||||
;;
|
||||
|
||||
-v|--version)
|
||||
sed '/^# '$name' version /,/^# Heavily modified by/ { s/^# //; p; }; d' < $0
|
||||
exit 0
|
||||
;;
|
||||
-\?|-h)
|
||||
sed '/^# usage:/,/# -h/ { s/^# //; p; }; d' < $0 &&
|
||||
echo
|
||||
echo "run \`$name --help | more' for full usage"
|
||||
exit 0
|
||||
;;
|
||||
--help)
|
||||
sed '/^# '$name' version /,/^[^#]/ { /^[^#]/ d; s/^# //; p; }; d' < $0
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
repeat=false
|
||||
;;
|
||||
-*)
|
||||
echo "$name: invalid flag $1" >&2
|
||||
break
|
||||
;;
|
||||
*)
|
||||
repeat=false
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# might have used break 2 within the previous loop, but so what
|
||||
$repeat && break
|
||||
|
||||
$update && \
|
||||
if echo "$name: checking for conflicts..." >&2
|
||||
($CVS $cvsopt -q -n update $updateopt ${1+"$@"} 2>/dev/null \
|
||||
| while read line; do
|
||||
echo "$line"
|
||||
echo "$line" >&3
|
||||
done | grep '^C') 3>&1 >/dev/null; then
|
||||
echo "$name: some conflicts were found, aborting..." >&2
|
||||
break
|
||||
fi
|
||||
|
||||
if test ! -f "$log_file"; then
|
||||
if test -z "$ChangeLog"; then
|
||||
for f in ${1+"$@"}; do
|
||||
case "$f" in
|
||||
ChangeLog* | */ChangeLog*)
|
||||
if test -z "$ChangeLog"; then
|
||||
ChangeLog="$f"
|
||||
else
|
||||
echo "$name: multiple ChangeLog files: $ChangeLog and $f" >&2
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$name: checking commit message..." >&2
|
||||
if $first; then
|
||||
skipping=:
|
||||
sed 's,^,+,' < ${ChangeLog-ChangeLog} |
|
||||
while read line; do
|
||||
case "$line" in
|
||||
"+2"*) if $skipping; then skipping=false; else break; fi;;
|
||||
"+ "*)
|
||||
echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2
|
||||
echo "$line" | sed 's/^.//' >&2;;
|
||||
"+ "*)
|
||||
$skipping || echo "$line" ;;
|
||||
esac
|
||||
done |
|
||||
sed 's,^\+ ,,' > "$log_file" || break
|
||||
else
|
||||
$CVS $cvsopt diff -u ${ChangeLog-ChangeLog} |
|
||||
while read line; do
|
||||
case $line in
|
||||
"--- "*) :;;
|
||||
"-"*)
|
||||
echo "$name: *** Warning: the following line in ChangeLog diff is suspicious:" >&2
|
||||
echo "$line" | sed 's/^.//' >&2;;
|
||||
"+ "*)
|
||||
echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2
|
||||
echo "$line" | sed 's/^.//' >&2;;
|
||||
"+") echo;;
|
||||
"+ "*) echo "$line";;
|
||||
esac
|
||||
done |
|
||||
sed -e 's,\+ ,,' -e '/./p' -e '/./d' -e '1d' -e '$d' > "$log_file" \
|
||||
|| break
|
||||
fi
|
||||
# The sed script above removes "+TAB" from the beginning of a line, then
|
||||
# deletes the first and/or the last line, when they happen to be empty
|
||||
fi
|
||||
|
||||
if grep '[^ ]' < "$log_file" > /dev/null; then :; else
|
||||
echo "$name: empty commit message, aborting" >&2
|
||||
break
|
||||
fi
|
||||
|
||||
if grep '^$' < "$log_file" > /dev/null; then
|
||||
echo "$name: *** Warning: blank lines should not appear within commit messages." >&2
|
||||
echo "$name: *** They should be used to separate distinct commits." >&2
|
||||
fi
|
||||
|
||||
${PAGER-more} "$log_file" || break
|
||||
|
||||
sleep 1 # give the user some time for a ^C
|
||||
|
||||
# Do not check for empty $log_file again, even though the user might have
|
||||
# zeroed it out. If s/he did, it was probably intentional.
|
||||
|
||||
if $commit; then
|
||||
$CVS $cvsopt commit $commitopt -F $log_file ${1+"$@"} || break
|
||||
fi
|
||||
|
||||
main_repeat=false
|
||||
done
|
||||
|
||||
rm -f "$log_file"
|
||||
|
||||
# if main_repeat was not set to `false', we failed
|
||||
$main_repeat && exit 1
|
||||
exit 0
|
||||
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -0,0 +1,21 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
SUBDIRS = calc++
|
||||
|
||||
dist_noinst_SCRIPTS = extexi
|
||||
@@ -0,0 +1,11 @@
|
||||
*.cc
|
||||
*.hh
|
||||
*.ll
|
||||
*.output
|
||||
*.stamp
|
||||
*.tmp
|
||||
*.yy
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
calc++
|
||||
@@ -0,0 +1,87 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
## ------------------------------------- ##
|
||||
## Running the bison from this tarball. ##
|
||||
## ------------------------------------- ##
|
||||
|
||||
BISON = $(top_builddir)/tests/bison
|
||||
BISON_IN = $(top_srcdir)/tests/bison.in
|
||||
|
||||
$(BISON): $(BISON_IN)
|
||||
cd $(top_builddir)/tests && $(MAKE) $(AM_MAKEFLAGS) bison
|
||||
|
||||
## ------------ ##
|
||||
## Extracting. ##
|
||||
## ------------ ##
|
||||
|
||||
doc = $(top_srcdir)/doc/bison.texinfo
|
||||
extexi = $(top_srcdir)/examples/extexi
|
||||
# Extract in src.
|
||||
$(calc_extracted): $(doc) $(extexi)
|
||||
cd $(srcdir) && \
|
||||
$(AWK) -f ../extexi ../../doc/bison.texinfo -- \
|
||||
calc++-parser.yy \
|
||||
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
||||
|
||||
|
||||
## ------------------- ##
|
||||
## Parser generation. ##
|
||||
## ------------------- ##
|
||||
|
||||
BUILT_SOURCES = $(calc_extracted) $(calc_sources_generated)
|
||||
CLEANFILES = $(srcdir)/*.output *.tmp
|
||||
MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
|
||||
|
||||
# Compile the parser and save cycles.
|
||||
# This code comes from "Handling Tools that Produce Many Outputs",
|
||||
# from the Automake documentation.
|
||||
EXTRA_DIST = $(srcdir)/calc++-parser.stamp $(srcdir)/calc++-parser.yy
|
||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||
# in srcdir, including during distcheck, which is forbidden.
|
||||
$(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN)
|
||||
@rm -f calc++-parser.tmp
|
||||
@touch calc++-parser.tmp
|
||||
$(BISON) -d -ra -S lalr1.cc -o $(srcdir)/calc++-parser.cc \
|
||||
$(srcdir)/calc++-parser.yy
|
||||
@mv -f calc++-parser.tmp $@
|
||||
|
||||
$(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
||||
@if test -f $@; then :; else \
|
||||
rm -f $(srcdir)/calc++-parser.stamp && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp; \
|
||||
fi
|
||||
|
||||
|
||||
## --------------------------- ##
|
||||
## Building & testing calc++. ##
|
||||
## --------------------------- ##
|
||||
|
||||
noinst_PROGRAMS = calc++
|
||||
|
||||
calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \
|
||||
$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc
|
||||
calc_extracted = $(calc_sources_extracted) $(srcdir)/calc++-parser.yy
|
||||
calc_sources_generated = \
|
||||
$(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
|
||||
$(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc
|
||||
|
||||
calc___SOURCES = $(calc_sources_extracted) $(calc_sources_generated)
|
||||
|
||||
TESTS = test
|
||||
EXTRA_DIST += $(TESTS)
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#! /bin/sh
|
||||
|
||||
set +e
|
||||
cat >input <<EOF
|
||||
a := 1
|
||||
b := 2
|
||||
c := 3
|
||||
d := a + b * c
|
||||
d
|
||||
EOF
|
||||
|
||||
./calc++ input
|
||||
./calc++ -p input
|
||||
|
||||
cat >input <<EOF
|
||||
a := 1
|
||||
d := a + b * c
|
||||
EOF
|
||||
./calc++ input
|
||||
|
||||
set -x
|
||||
echo toto
|
||||
cat >input <<EOF
|
||||
toto := 1
|
||||
toto
|
||||
EOF
|
||||
./calc++ -s input
|
||||
|
||||
rm input
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
# Extract all examples from the manual source. -*- AWK -*-
|
||||
|
||||
# This file is part of GNU Bison
|
||||
# Copyright 1992, 2000, 2001, 2005 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
|
||||
|
||||
# This script is for use with any Awk that conforms to POSIX.
|
||||
# It was derived from a similar script tests/generate.awk in GNU m4.
|
||||
#
|
||||
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
||||
BEGIN {
|
||||
if (!output_dir)
|
||||
output_dir = ".";
|
||||
for (argc = 1; argc < ARGC; ++argc)
|
||||
if (ARGV[argc] == "--")
|
||||
break;
|
||||
for (i = argc + 1; i < ARGC; ++i)
|
||||
file_wanted[ARGV[i]] = 1;
|
||||
ARGC = argc;
|
||||
}
|
||||
|
||||
/^@node / {
|
||||
if (seq > 0)
|
||||
print "AT_CLEANUP";
|
||||
|
||||
split ($0, tmp, ",");
|
||||
node = substr(tmp[1], 7);
|
||||
seq = 0;
|
||||
}
|
||||
|
||||
/^@comment file: / {
|
||||
if (!file_wanted[$3])
|
||||
message("ignoring " $3);
|
||||
else
|
||||
{
|
||||
message("extracting " $3);
|
||||
file = $3;
|
||||
}
|
||||
}
|
||||
|
||||
/^@example$/, /^@end example$/ {
|
||||
if (!file)
|
||||
next;
|
||||
|
||||
if ($0 ~ /^@example$/)
|
||||
{
|
||||
input = files_output[file] ? "\n" : "";
|
||||
|
||||
# FNR is starting at 0 instead of 1, and
|
||||
# #line report the line number of the *next* line.
|
||||
# => + 2.
|
||||
# Note that recent Bison support it, but not Flex.
|
||||
if (file ~ /\.[chy]*$/)
|
||||
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($0 ~ /^@end example$/)
|
||||
{
|
||||
if (input == "")
|
||||
fatal("no contents: " file);
|
||||
|
||||
input = normalize(input);
|
||||
# No spurious end of line: use printf.
|
||||
if (files_output[file])
|
||||
printf ("%s", input) >> output_dir "/" file;
|
||||
else
|
||||
printf ("%s", input) > output_dir "/" file;
|
||||
close (output_dir "/" file);
|
||||
files_output[file] = 1;
|
||||
|
||||
file = input = "";
|
||||
next;
|
||||
}
|
||||
|
||||
input = input $0 "\n";
|
||||
}
|
||||
|
||||
|
||||
# We have to handle CONTENTS line per line, since anchors in AWK are
|
||||
# referring to the whole string, not the lines.
|
||||
function normalize(contents, i, lines, n, line, res) {
|
||||
# Remove the Texinfo tags.
|
||||
n = split (contents, lines, "\n");
|
||||
# We don't want the last field which empty: it's behind the last \n.
|
||||
for (i = 1; i < n; ++i)
|
||||
{
|
||||
line = lines[i];
|
||||
|
||||
# Whole line commands.
|
||||
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
||||
# Gperf accepts empty lines as valid input!!!
|
||||
if (file ~ /\.gperf$/)
|
||||
continue;
|
||||
else
|
||||
line = "";
|
||||
|
||||
gsub (/^@result\{\}/, "", line);
|
||||
gsub (/^@error\{\}/, "", line);
|
||||
gsub ("@[{]", "{", line);
|
||||
gsub ("@}", "}", line);
|
||||
gsub ("@@", "@", line);
|
||||
gsub ("@comment.*", "", line);
|
||||
|
||||
res = res line "\n";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
function message(msg) {
|
||||
if (! message_printed[msg])
|
||||
{
|
||||
print "extexi: " msg > "/dev/stderr";
|
||||
message_printed[msg] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
function fatal(msg) {
|
||||
message(msg);
|
||||
exit 1
|
||||
}
|
||||
+58
-1
@@ -1,4 +1,61 @@
|
||||
*_.c
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
alloca.c
|
||||
alloca.h
|
||||
alloca_.h
|
||||
argmatch.c
|
||||
argmatch.h
|
||||
basename.c
|
||||
dirname.c
|
||||
dirname.h
|
||||
dup-safer.c
|
||||
error.c
|
||||
error.h
|
||||
exit.h
|
||||
exitfail.c
|
||||
exitfail.h
|
||||
fd-safer.c
|
||||
fopen-safer.c
|
||||
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
|
||||
pipe-safer.c
|
||||
quote.c
|
||||
quote.h
|
||||
quotearg.c
|
||||
quotearg.h
|
||||
stdbool.h
|
||||
stdbool_.h
|
||||
stdio--.h
|
||||
stdio-safer.h
|
||||
stpcpy.c
|
||||
stpcpy.h
|
||||
strdup.c
|
||||
strdup.h
|
||||
stripslash.c
|
||||
strndup.c
|
||||
strndup.h
|
||||
strnlen.c
|
||||
strnlen.h
|
||||
unistd--.h
|
||||
unistd-safer.h
|
||||
unlocked-io.h
|
||||
xalloc-die.c
|
||||
xalloc.h
|
||||
xmalloc.c
|
||||
xstrndup.c
|
||||
xstrndup.h
|
||||
|
||||
+18
-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
|
||||
@@ -12,44 +12,32 @@
|
||||
|
||||
## 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
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
## 02110-1301 USA
|
||||
|
||||
AM_CFLAGS = $(WARNING_CFLAGS)
|
||||
|
||||
lib_LIBRARIES = liby.a
|
||||
noinst_LIBRARIES = libbison.a
|
||||
BUILT_SOURCES =
|
||||
EXTRA_DIST =
|
||||
MOSTLYCLEANFILES =
|
||||
|
||||
# config.h is in build/., and system.h is in src/src/.
|
||||
INCLUDES = -I$(top_builddir) \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/lib
|
||||
lib_LIBRARIES = $(YACC_LIBRARY)
|
||||
EXTRA_LIBRARIES = liby.a
|
||||
noinst_LIBRARIES = libbison.a
|
||||
|
||||
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 \
|
||||
libbison_a_SOURCES = $(lib_SOURCES)
|
||||
lib_SOURCES = \
|
||||
get-errno.h get-errno.c \
|
||||
getopt.h getopt.c getopt1.c \
|
||||
hash.h hash.c \
|
||||
mbswidth.h mbswidth.c \
|
||||
quote.h quote.c quotearg.h quotearg.c \
|
||||
subpipe.h subpipe.c unlocked-io.h \
|
||||
xalloc.h xmalloc.c xstrdup.c xstrndup.c \
|
||||
subpipe.h subpipe.c \
|
||||
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
||||
|
||||
# Implementation of bitsets
|
||||
bitsets_sources = \
|
||||
libiberty.h \
|
||||
abitset.c bitset.c bitset_stats.h ebitset.c lbitset.h \
|
||||
abitset.h bitset.h bitsetv.c ebitset.h \
|
||||
bbitset.h bitset_stats.c bitsetv.h lbitset.c
|
||||
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
|
||||
|
||||
# Additional bitset operations.
|
||||
additional_bitsets_sources = \
|
||||
@@ -59,5 +47,7 @@ additional_bitsets_sources = \
|
||||
timevars_sources = \
|
||||
timevar.h timevar.c timevar.def
|
||||
|
||||
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libbison_a_LIBADD = $(LIBOBJS) $(ALLOCA)
|
||||
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
||||
|
||||
include gnulib.mk
|
||||
|
||||
+59
-55
@@ -1,5 +1,5 @@
|
||||
/* Array bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
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
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
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.
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -31,16 +31,18 @@
|
||||
|
||||
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||
#define ABITSET_WORDS(X) ((X)->a.words)
|
||||
#define ABITSET_N_BITS(X) ((X)->a.n_bits)
|
||||
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
static bitset_bindex
|
||||
abitset_size (bitset src)
|
||||
abitset_resize (bitset src ATTRIBUTE_UNUSED,
|
||||
bitset_bindex size ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return ABITSET_N_BITS (src);
|
||||
}
|
||||
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
|
||||
@@ -60,7 +62,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
size = ABITSET_N_BITS (src);
|
||||
size = BITSET_SIZE_ (src);
|
||||
bitno = *next;
|
||||
if (bitno >= size)
|
||||
return 0;
|
||||
@@ -105,8 +107,9 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
||||
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. */
|
||||
/* 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 ();
|
||||
}
|
||||
|
||||
@@ -116,21 +119,20 @@ 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. */
|
||||
abort ();
|
||||
/* 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 int
|
||||
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. */
|
||||
abort ();
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +151,7 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||
unsigned int bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_bindex n_bits = ABITSET_N_BITS (src);
|
||||
bitset_bindex n_bits = BITSET_SIZE_ (src);
|
||||
|
||||
rbitno = *next;
|
||||
|
||||
@@ -228,7 +230,7 @@ abitset_list (bitset src, bitset_bindex *list,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bitno >= ABITSET_N_BITS (src))
|
||||
if (bitno >= BITSET_SIZE_ (src))
|
||||
return 0;
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
@@ -304,7 +306,7 @@ abitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned int last_bit;
|
||||
|
||||
last_bit = ABITSET_N_BITS (dst) % BITSET_WORD_BITS;
|
||||
last_bit = BITSET_SIZE_ (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
((bitset_word) 1 << last_bit) - 1;
|
||||
@@ -336,7 +338,7 @@ abitset_zero (bitset dst)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_empty_p (bitset dst)
|
||||
{
|
||||
bitset_windex i;
|
||||
@@ -344,9 +346,9 @@ abitset_empty_p (bitset dst)
|
||||
|
||||
for (i = 0; i < dst->b.csize; i++)
|
||||
if (dstp[i])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +379,7 @@ abitset_not (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
@@ -387,12 +389,12 @@ abitset_equal_p (bitset dst, bitset src)
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ != *dstp++)
|
||||
return 0;
|
||||
return 1;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
@@ -402,12 +404,12 @@ abitset_subset_p (bitset dst, bitset src)
|
||||
|
||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||
if (*dstp != (*srcp | *dstp))
|
||||
return 0;
|
||||
return 1;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex i;
|
||||
@@ -417,9 +419,9 @@ abitset_disjoint_p (bitset dst, bitset src)
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
if (*srcp++ & *dstp++)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -437,11 +439,11 @@ abitset_and (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
@@ -453,7 +455,7 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -475,11 +477,11 @@ abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
@@ -491,7 +493,7 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -513,11 +515,11 @@ abitset_or (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
@@ -529,7 +531,7 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -551,11 +553,11 @@ abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
@@ -567,7 +569,7 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -590,11 +592,11 @@ abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
@@ -607,7 +609,7 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -630,11 +632,11 @@ abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
@@ -647,7 +649,7 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -670,11 +672,11 @@ abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
bitset_windex i;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
@@ -687,7 +689,7 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -711,7 +713,8 @@ struct bitset_vtable abitset_small_vtable = {
|
||||
abitset_reset,
|
||||
bitset_toggle_,
|
||||
abitset_test,
|
||||
abitset_size,
|
||||
abitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
abitset_empty_p,
|
||||
abitset_ones,
|
||||
@@ -748,7 +751,8 @@ struct bitset_vtable abitset_vtable = {
|
||||
abitset_reset,
|
||||
bitset_toggle_,
|
||||
abitset_test,
|
||||
abitset_size,
|
||||
abitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
abitset_empty_p,
|
||||
abitset_ones,
|
||||
@@ -809,7 +813,7 @@ abitset_init (bitset bset, bitset_bindex n_bits)
|
||||
bitset_windex size;
|
||||
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
ABITSET_N_BITS (bset) = 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
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/* Functions to support abitsets.
|
||||
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
|
||||
@@ -14,15 +14,15 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _ABITSET_H
|
||||
#define _ABITSET_H
|
||||
#define _ABITSET_H
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t abitset_bytes PARAMS ((bitset_bindex));
|
||||
extern size_t abitset_bytes (bitset_bindex);
|
||||
|
||||
extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
|
||||
extern bitset abitset_init (bitset, bitset_bindex);
|
||||
|
||||
#endif
|
||||
|
||||
-508
@@ -1,508 +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 "lisp.h"
|
||||
# include "blockinput.h"
|
||||
# define xalloc_die() memory_full ()
|
||||
# ifdef EMACS_FREE
|
||||
# undef free
|
||||
# define free EMACS_FREE
|
||||
# endif
|
||||
#else
|
||||
# include <xalloc.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
|
||||
/* Using #error here is not wise since this file should work for
|
||||
old and obscure compilers. */
|
||||
# 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
|
||||
|
||||
# ifndef POINTER_TYPE
|
||||
# ifdef __STDC__
|
||||
# define POINTER_TYPE void
|
||||
# else
|
||||
# define POINTER_TYPE char
|
||||
# endif
|
||||
# endif
|
||||
typedef POINTER_TYPE *pointer;
|
||||
|
||||
# ifndef NULL
|
||||
# define NULL 0
|
||||
# endif
|
||||
|
||||
/* 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)
|
||||
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. */
|
||||
|
||||
{
|
||||
/* Address of header. */
|
||||
register pointer new;
|
||||
|
||||
size_t combined_size = sizeof (header) + size;
|
||||
if (combined_size < sizeof (header))
|
||||
xalloc_die ();
|
||||
|
||||
new = xmalloc (combined_size);
|
||||
|
||||
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 */
|
||||
-274
@@ -1,274 +0,0 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1998, 1999, 2001, 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. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>
|
||||
Modified by Akim Demaille <[email protected]> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "argmatch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
#include "unlocked-io.h"
|
||||
|
||||
/* When reporting an invalid argument, show nonprinting characters
|
||||
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
literal_quoting_style. */
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
#endif
|
||||
|
||||
/* Non failing version of argmatch call this function after failing. */
|
||||
#ifndef ARGMATCH_DIE
|
||||
# define ARGMATCH_DIE exit (EXIT_FAILURE)
|
||||
#endif
|
||||
|
||||
#ifdef ARGMATCH_DIE_DECL
|
||||
ARGMATCH_DIE_DECL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__argmatch_die (void)
|
||||
{
|
||||
ARGMATCH_DIE;
|
||||
}
|
||||
|
||||
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array ARGLIST, return the index in ARGLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
|
||||
If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
synonyms, i.e., for
|
||||
"yes", "yop" -> 0
|
||||
"no", "nope" -> 1
|
||||
"y" is a valid argument, for `0', and "n" for `1'. */
|
||||
|
||||
int
|
||||
argmatch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i; /* Temporary index in ARGLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; arglist[i]; i++)
|
||||
{
|
||||
if (!strncmp (arglist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (arglist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
{
|
||||
/* Second nonexact match found. */
|
||||
if (vallist == NULL
|
||||
|| memcmp (vallist + valsize * matchind,
|
||||
vallist + valsize * i, valsize))
|
||||
{
|
||||
/* There is a real ambiguity, or we could not
|
||||
disambiguate. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
CONTEXT is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
argmatch_invalid (const char *context, const char *value, int problem)
|
||||
{
|
||||
char const *format = (problem == -1
|
||||
? _("invalid argument %s for %s")
|
||||
: _("ambiguous argument %s for %s"));
|
||||
|
||||
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
|
||||
quote_n (1, context));
|
||||
}
|
||||
|
||||
/* List the valid arguments for argmatch.
|
||||
ARGLIST is the same as in argmatch.
|
||||
VALLIST is a pointer to an array of values.
|
||||
VALSIZE is the size of the elements of VALLIST */
|
||||
void
|
||||
argmatch_valid (const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
const char *last_val = NULL;
|
||||
|
||||
/* We try to put synonyms on the same line. The assumption is that
|
||||
synonyms follow each other */
|
||||
fprintf (stderr, _("Valid arguments are:"));
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if ((i == 0)
|
||||
|| memcmp (last_val, vallist + valsize * i, valsize))
|
||||
{
|
||||
fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
last_val = vallist + valsize * i;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, ", `%s'", arglist[i]);
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
/* Never failing versions of the previous functions.
|
||||
|
||||
CONTEXT is the context for which argmatch is called (e.g.,
|
||||
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
calls the (supposed never to return) function EXIT_FN. */
|
||||
|
||||
int
|
||||
__xargmatch_internal (const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
argmatch_exit_fn exit_fn)
|
||||
{
|
||||
int res = argmatch (arg, arglist, vallist, valsize);
|
||||
if (res >= 0)
|
||||
/* Success. */
|
||||
return res;
|
||||
|
||||
/* We failed. Explain why. */
|
||||
argmatch_invalid (context, arg, res);
|
||||
argmatch_valid (arglist, vallist, valsize);
|
||||
(*exit_fn) ();
|
||||
|
||||
return -1; /* To please the compilers. */
|
||||
}
|
||||
|
||||
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
return the first corresponding argument in ARGLIST */
|
||||
const char *
|
||||
argmatch_to_argument (const char *value,
|
||||
const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
return arglist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Based on "getversion.c" by David MacKenzie <[email protected]>
|
||||
*/
|
||||
char *program_name;
|
||||
extern const char *getenv ();
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
/* Two tables describing arguments (keys) and their corresponding
|
||||
values */
|
||||
static const char *const backup_args[] =
|
||||
{
|
||||
"no", "none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_vals[] =
|
||||
{
|
||||
none, none, none,
|
||||
simple, simple,
|
||||
numbered_existing, numbered_existing,
|
||||
numbered, numbered
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, const char *const *argv)
|
||||
{
|
||||
const char *cp;
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
program_name = (char *) argv[0];
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ((cp = getenv ("VERSION_CONTROL")))
|
||||
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
|
||||
backup_args, backup_vals);
|
||||
|
||||
if (argc == 2)
|
||||
backup_type = XARGMATCH (program_name, argv[1],
|
||||
backup_args, backup_vals);
|
||||
|
||||
printf ("The version control is `%s'\n",
|
||||
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
Copyright (C) 1990, 1998, 1999, 2001, 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. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>
|
||||
Modified by Akim Demaille <[email protected]> */
|
||||
|
||||
#ifndef ARGMATCH_H_
|
||||
# define ARGMATCH_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
|
||||
|
||||
# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \
|
||||
(ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
|
||||
|
||||
/* Assert there are as many real arguments as there are values
|
||||
(argument list ends with a NULL guard). ARGMATCH_VERIFY is
|
||||
preferred, since it is guaranteed to be checked at compile-time.
|
||||
ARGMATCH_ASSERT is for backward compatibility only. */
|
||||
|
||||
# define ARGMATCH_VERIFY(Arglist, Vallist) \
|
||||
struct argmatch_verify \
|
||||
{ \
|
||||
char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \
|
||||
}
|
||||
|
||||
# define ARGMATCH_ASSERT(Arglist, Vallist) \
|
||||
assert (ARGMATCH_CONSTRAINT (Arglist, Vallist))
|
||||
|
||||
/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
false ambiguities (i.e., different matches of ARG but corresponding
|
||||
to the same values in VALLIST). */
|
||||
|
||||
int argmatch (char const *arg, char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
/* xargmatch calls this function when it fails. This function should not
|
||||
return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
in turn defaults to `exit (EXIT_FAILURE)'. */
|
||||
typedef void (*argmatch_exit_fn) (void);
|
||||
extern argmatch_exit_fn argmatch_die;
|
||||
|
||||
/* Report on stderr why argmatch failed. Report correct values. */
|
||||
|
||||
void argmatch_invalid (char const *context, char const *value, int problem);
|
||||
|
||||
/* Left for compatibility with the old name invalid_arg */
|
||||
|
||||
# define invalid_arg(Context, Value, Problem) \
|
||||
argmatch_invalid (Context, Value, Problem)
|
||||
|
||||
|
||||
|
||||
/* Report on stderr the list of possible arguments. */
|
||||
|
||||
void argmatch_valid (char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
|
||||
|
||||
/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
failure, and exits using the function EXIT_FN. */
|
||||
|
||||
int __xargmatch_internal (char const *context,
|
||||
char const *arg, char const *const *arglist,
|
||||
char const *vallist, size_t valsize,
|
||||
argmatch_exit_fn exit_fn);
|
||||
|
||||
/* Programmer friendly interface to __xargmatch_internal. */
|
||||
|
||||
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \
|
||||
(char const *) (Vallist), \
|
||||
sizeof *(Vallist), \
|
||||
argmatch_die)])
|
||||
|
||||
/* Convert a value into a corresponding argument. */
|
||||
|
||||
char const *argmatch_to_argument (char const *value,
|
||||
char const *const *arglist,
|
||||
char const *vallist, size_t valsize);
|
||||
|
||||
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
argmatch_to_argument (Value, Arglist, \
|
||||
(char const *) (Vallist), sizeof *(Vallist))
|
||||
|
||||
#endif /* ARGMATCH_H_ */
|
||||
@@ -1,79 +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
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include "dirname.h"
|
||||
|
||||
/* 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.
|
||||
|
||||
Return the address of the last file name component of NAME. If
|
||||
NAME has no file name components because it is all slashes, return
|
||||
NAME if it is empty, the address of its last slash otherwise. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name + FILESYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
{
|
||||
/* Treat multiple adjacent slashes like a single slash. */
|
||||
do p++;
|
||||
while (ISSLASH (*p));
|
||||
|
||||
/* If the file name ends in slash, use the trailing slash as
|
||||
the basename if no non-slashes have been found. */
|
||||
if (! *p)
|
||||
{
|
||||
if (ISSLASH (*base))
|
||||
base = p - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* *P is a non-slash preceded by a slash. */
|
||||
base = p;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
/* Return the length of of the basename NAME. Typically NAME is the
|
||||
value returned by base_name. Act like strlen (NAME), except omit
|
||||
redundant trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
return len;
|
||||
}
|
||||
+79
-59
@@ -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
|
||||
@@ -14,37 +14,42 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _BBITSET_H
|
||||
#define _BBITSET_H
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
/* Currently we support three flavours of bitsets:
|
||||
/* Currently we support five flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
|
||||
BITSET_LIST: Linked list of array of bits (variable size, least storage
|
||||
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 array of bits
|
||||
BITSET_TABLE: Expandable table of pointers to arrays of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
|
||||
BITSET_STATS: Wrapper bitset for internal use only.
|
||||
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,
|
||||
BITSET_STATS};
|
||||
#define BITSET_TYPE_NAMES {"abitset", "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"}
|
||||
|
||||
extern const char * const bitset_type_names[];
|
||||
|
||||
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. 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
|
||||
@@ -79,10 +84,11 @@ enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||
|
||||
struct bbitset_struct
|
||||
{
|
||||
const struct bitset_vtable * vtable;
|
||||
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.
|
||||
@@ -94,52 +100,61 @@ struct bbitset_struct
|
||||
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_vtable
|
||||
{
|
||||
void (*set) PARAMS ((bitset, bitset_bindex));
|
||||
void (*reset) PARAMS ((bitset, bitset_bindex));
|
||||
int (*toggle) PARAMS ((bitset, bitset_bindex));
|
||||
int (*test) PARAMS ((bitset, bitset_bindex));
|
||||
bitset_bindex (*size) PARAMS ((bitset));
|
||||
bitset_bindex (*count) PARAMS ((bitset));
|
||||
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);
|
||||
|
||||
int (*empty_p) PARAMS ((bitset));
|
||||
void (*ones) PARAMS ((bitset));
|
||||
void (*zero) PARAMS ((bitset));
|
||||
bool (*empty_p) (bitset);
|
||||
void (*ones) (bitset);
|
||||
void (*zero) (bitset);
|
||||
|
||||
void (*copy) PARAMS ((bitset, bitset));
|
||||
int (*disjoint_p) PARAMS ((bitset, bitset));
|
||||
int (*equal_p) PARAMS ((bitset, bitset));
|
||||
void (*not) PARAMS ((bitset, bitset));
|
||||
int (*subset_p) PARAMS ((bitset, 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) PARAMS ((bitset, bitset, bitset));
|
||||
int (*and_cmp) PARAMS ((bitset, bitset, bitset));
|
||||
void (*andn) PARAMS ((bitset, bitset, bitset));
|
||||
int (*andn_cmp) PARAMS ((bitset, bitset, bitset));
|
||||
void (*or) PARAMS ((bitset, bitset, bitset));
|
||||
int (*or_cmp) PARAMS ((bitset, bitset, bitset));
|
||||
void (*xor) PARAMS ((bitset, bitset, bitset));
|
||||
int (*xor_cmp) PARAMS ((bitset, 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) PARAMS ((bitset, bitset, bitset, bitset));
|
||||
int (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
|
||||
void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset));
|
||||
int (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
|
||||
void (*or_and) PARAMS ((bitset, bitset, bitset, bitset));
|
||||
int (*or_and_cmp) PARAMS ((bitset, 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) PARAMS ((bitset, bitset_bindex *,
|
||||
bitset_bindex, bitset_bindex *));
|
||||
bitset_bindex (*list_reverse) PARAMS ((bitset,
|
||||
bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
void (*free) PARAMS ((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.vtable == (BSET2)->b.vtable)
|
||||
#define BITSET_COMPATIBLE_(BSET1, BSET2) \
|
||||
((BSET1)->b.vtable == (BSET2)->b.vtable)
|
||||
|
||||
#define BITSET_CHECK2_(DST, SRC) \
|
||||
if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
|
||||
@@ -153,6 +168,9 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||
|| !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
|
||||
|
||||
|
||||
/* Redefine number of bits in bitset DST. */
|
||||
#define BITSET_RESIZE_(DST, SIZE) (DST)->b.vtable->resize (DST, SIZE)
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET_SIZE_(SRC) (SRC)->b.vtable->size (SRC)
|
||||
|
||||
@@ -261,22 +279,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||
|
||||
/* Private functions for bitset implementations. */
|
||||
|
||||
extern int bitset_toggle_ PARAMS ((bitset, bitset_bindex));
|
||||
extern bool bitset_toggle_ (bitset, bitset_bindex);
|
||||
|
||||
extern bitset_bindex bitset_count_ PARAMS ((bitset));
|
||||
extern bitset_bindex bitset_count_ (bitset);
|
||||
|
||||
extern int bitset_copy_ PARAMS ((bitset, bitset));
|
||||
extern bitset_bindex bitset_size_ (bitset);
|
||||
|
||||
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||
extern bool bitset_copy_ (bitset, bitset);
|
||||
|
||||
extern int bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern int bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
|
||||
|
||||
extern int bitset_or_and_cmp_ PARAMS ((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 */
|
||||
|
||||
+65
-39
@@ -1,5 +1,5 @@
|
||||
/* General bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -14,17 +14,19 @@
|
||||
|
||||
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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "bitset.h"
|
||||
#include "abitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "vbitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include "obstack.h"
|
||||
|
||||
@@ -55,6 +57,10 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_VARRAY:
|
||||
bytes = vbitset_bytes (n_bits);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
@@ -81,6 +87,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
case BITSET_TABLE:
|
||||
return ebitset_init (bset, n_bits);
|
||||
|
||||
case BITSET_VARRAY:
|
||||
return vbitset_init (bset, n_bits);
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
@@ -93,27 +102,30 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
enum bitset_type
|
||||
bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned int attr)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
/* Check attributes. */
|
||||
if (attr & BITSET_FIXED && attr & BITSET_VARIABLE)
|
||||
abort ();
|
||||
if (attr & BITSET_SPARSE && attr & BITSET_DENSE)
|
||||
abort ();
|
||||
|
||||
/* Choose the type of bitset. Note that sometimes we will be asked
|
||||
/* Choose the type of bitset. Note that sometimes we will be asked
|
||||
for a zero length fixed size bitset. */
|
||||
|
||||
type = BITSET_ARRAY;
|
||||
/* Currently, the simple bitsets do not support a variable size. */
|
||||
if (attr & BITSET_VARIABLE || attr & BITSET_SPARSE)
|
||||
{
|
||||
type = BITSET_LIST;
|
||||
if (attr & BITSET_DENSE || attr & BITSET_GREEDY)
|
||||
type = BITSET_TABLE;
|
||||
}
|
||||
|
||||
return type;
|
||||
/* If no attributes selected, choose a good compromise. */
|
||||
if (!attr)
|
||||
return BITSET_VARRAY;
|
||||
|
||||
if (attr & BITSET_SPARSE)
|
||||
return BITSET_LIST;
|
||||
|
||||
if (attr & BITSET_FIXED)
|
||||
return BITSET_ARRAY;
|
||||
|
||||
if (attr & BITSET_GREEDY)
|
||||
return BITSET_TABLE;
|
||||
|
||||
return BITSET_VARRAY;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +138,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
||||
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bset = (bitset) xcalloc (1, bytes);
|
||||
bset = xcalloc (1, bytes);
|
||||
|
||||
/* The cache is disabled until some elements are allocated. If we
|
||||
have variable length arrays, then we may need to allocate a dummy
|
||||
@@ -223,6 +235,14 @@ bitset_next (bitset src, bitset_bindex bitno)
|
||||
}
|
||||
|
||||
|
||||
/* Return true if both bitsets are of the same type and size. */
|
||||
extern bool
|
||||
bitset_compatible_p (bitset bset1, bitset bset2)
|
||||
{
|
||||
return BITSET_COMPATIBLE_ (bset1, bset2);
|
||||
}
|
||||
|
||||
|
||||
/* Find previous bit set in SRC starting from and including BITNO.
|
||||
Return BITSET_BINDEX_MAX if SRC empty. */
|
||||
bitset_bindex
|
||||
@@ -253,22 +273,22 @@ bitset_last (bitset src)
|
||||
}
|
||||
|
||||
|
||||
/* Return non-zero if BITNO in SRC is the only set bit. */
|
||||
int
|
||||
/* Is BITNO in SRC the only set bit? */
|
||||
bool
|
||||
bitset_only_set_p (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset_bindex val[2];
|
||||
bitset_bindex next = 0;
|
||||
|
||||
if (bitset_list (src, val, 2, &next) != 1)
|
||||
return 0;
|
||||
return false;
|
||||
return val[0] == bitno;
|
||||
}
|
||||
|
||||
|
||||
/* Print contents of bitset BSET to FILE. */
|
||||
static void
|
||||
bitset_print (FILE *file, bitset bset, int verbose)
|
||||
bitset_print (FILE *file, bitset bset, bool verbose)
|
||||
{
|
||||
unsigned int pos;
|
||||
bitset_bindex i;
|
||||
@@ -276,7 +296,7 @@ bitset_print (FILE *file, bitset bset, int verbose)
|
||||
|
||||
if (verbose)
|
||||
fprintf (file, "n_bits = %lu, set = {",
|
||||
(unsigned long) bitset_size (bset));
|
||||
(unsigned long int) bitset_size (bset));
|
||||
|
||||
pos = 30;
|
||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||
@@ -287,7 +307,7 @@ bitset_print (FILE *file, bitset bset, int verbose)
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
fprintf (file, "%d ", i);
|
||||
fprintf (file, "%lu ", (unsigned long int) i);
|
||||
pos += 1 + (i >= 10) + (i >= 100);
|
||||
};
|
||||
|
||||
@@ -300,11 +320,10 @@ bitset_print (FILE *file, bitset bset, int verbose)
|
||||
void
|
||||
bitset_dump (FILE *file, bitset bset)
|
||||
{
|
||||
bitset_print (file, bset, 0);
|
||||
bitset_print (file, bset, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Release memory associated with bitsets. */
|
||||
void
|
||||
bitset_release_memory (void)
|
||||
@@ -314,9 +333,8 @@ bitset_release_memory (void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Toggle bit BITNO in bitset BSET and return non-zero if not set. */
|
||||
int
|
||||
/* Toggle bit BITNO in bitset BSET and the new value of the bit. */
|
||||
bool
|
||||
bitset_toggle_ (bitset bset, bitset_bindex bitno)
|
||||
{
|
||||
/* This routine is for completeness. It could be optimized if
|
||||
@@ -324,16 +342,24 @@ bitset_toggle_ (bitset bset, bitset_bindex bitno)
|
||||
if (bitset_test (bset, bitno))
|
||||
{
|
||||
bitset_reset (bset, bitno);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitset_set (bset, bitno);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Return number of bits in bitset SRC. */
|
||||
bitset_bindex
|
||||
bitset_size_ (bitset src)
|
||||
{
|
||||
return BITSET_NBITS_ (src);
|
||||
}
|
||||
|
||||
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
bitset_bindex
|
||||
bitset_count_ (bitset src)
|
||||
@@ -356,10 +382,10 @@ bitset_count_ (bitset src)
|
||||
}
|
||||
|
||||
|
||||
/* DST = SRC. Return non-zero if DST != SRC.
|
||||
/* DST = SRC. Return true if DST != SRC.
|
||||
This is a fallback for the case where SRC and DST are different
|
||||
bitset types. */
|
||||
int
|
||||
bool
|
||||
bitset_copy_ (bitset dst, bitset src)
|
||||
{
|
||||
bitset_bindex i;
|
||||
@@ -373,23 +399,23 @@ bitset_copy_ (bitset dst, bitset src)
|
||||
bitset_set (dst, i);
|
||||
};
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This is a fallback for implementations that do not support
|
||||
four operand operations. */
|
||||
static inline int
|
||||
static inline bool
|
||||
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
||||
enum bitset_ops op)
|
||||
{
|
||||
int changed = 0;
|
||||
int stats_enabled_save;
|
||||
bool changed = false;
|
||||
bool stats_enabled_save;
|
||||
bitset tmp;
|
||||
|
||||
/* Create temporary bitset. */
|
||||
stats_enabled_save = bitset_stats_enabled;
|
||||
bitset_stats_enabled = 0;
|
||||
bitset_stats_enabled = false;
|
||||
tmp = bitset_alloc (0, bitset_type_get (dst));
|
||||
bitset_stats_enabled = stats_enabled_save;
|
||||
|
||||
@@ -429,7 +455,7 @@ bitset_and_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & SRC2) | SRC3. */
|
||||
int
|
||||
bool
|
||||
bitset_and_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_AND_OR);
|
||||
@@ -446,7 +472,7 @@ bitset_andn_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||
int
|
||||
bool
|
||||
bitset_andn_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_ANDN_OR);
|
||||
@@ -463,7 +489,7 @@ bitset_or_and_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
int
|
||||
bool
|
||||
bitset_or_and_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||
{
|
||||
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_OR_AND);
|
||||
@@ -475,5 +501,5 @@ void
|
||||
debug_bitset (bitset bset)
|
||||
{
|
||||
if (bset)
|
||||
bitset_print (stderr, bset, 1);
|
||||
bitset_print (stderr, bset, true);
|
||||
}
|
||||
|
||||
+59
-49
@@ -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
|
||||
@@ -14,7 +14,7 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _BITSET_H
|
||||
#define _BITSET_H
|
||||
@@ -44,12 +44,11 @@ union bitset_union
|
||||
{
|
||||
/* This must be the first member of every other structure that is a
|
||||
member of this union. */
|
||||
struct bbitset_struct b;
|
||||
struct bbitset_struct b; /* Base bitset data. */
|
||||
|
||||
struct abitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset_bindex n_bits; /* Number of bits. */
|
||||
bitset_word words[1]; /* The array of bits. */
|
||||
} a;
|
||||
|
||||
@@ -72,6 +71,13 @@ union bitset_union
|
||||
struct bbitset_struct b;
|
||||
bitset bset;
|
||||
} s;
|
||||
|
||||
struct vbitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
bitset_windex size; /* Allocated size of array. */
|
||||
} v;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -87,38 +93,37 @@ typedef struct
|
||||
|
||||
|
||||
/* Return bytes required for bitset of desired type and size. */
|
||||
extern size_t 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 bitset type. */
|
||||
extern enum bitset_type bitset_type_get PARAMS ((bitset));
|
||||
extern enum bitset_type bitset_type_get (bitset);
|
||||
|
||||
/* Return bitset type name. */
|
||||
extern const char *bitset_type_name_get PARAMS ((bitset));
|
||||
extern const char *bitset_type_name_get (bitset);
|
||||
|
||||
|
||||
/* Set bit BITNO in bitset BSET. */
|
||||
@@ -150,7 +155,7 @@ bitset_reset (bitset bset, bitset_bindex bitno)
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset BSET. */
|
||||
static inline int
|
||||
static inline bool
|
||||
bitset_test (bitset bset, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
@@ -169,6 +174,9 @@ bitset_test (bitset bset, bitset_bindex bitno)
|
||||
/* 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)
|
||||
|
||||
@@ -266,65 +274,69 @@ bitset_test (bitset bset, bitset_bindex bitno)
|
||||
#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. */
|
||||
extern bitset_bindex bitset_next PARAMS ((bitset, bitset_bindex));
|
||||
/* Find next set bit from the given bit index. */
|
||||
extern bitset_bindex bitset_next (bitset, bitset_bindex);
|
||||
|
||||
/* Find previous set bit. */
|
||||
extern bitset_bindex bitset_prev PARAMS ((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 bitset_bindex bitset_first PARAMS ((bitset));
|
||||
extern bitset_bindex bitset_first (bitset);
|
||||
|
||||
/* Find last set bit. */
|
||||
extern bitset_bindex bitset_last PARAMS ((bitset));
|
||||
extern bitset_bindex bitset_last (bitset);
|
||||
|
||||
/* Return nonzero if this is the only set bit. */
|
||||
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex));
|
||||
extern bool bitset_only_set_p (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, setting BIT
|
||||
/* 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_zero (dst);
|
||||
BITSET_FOR_EACH (iter, src, i, 0)
|
||||
{
|
||||
printf ("%ld ", i);
|
||||
printf ("%lu ", (unsigned long int) i);
|
||||
};
|
||||
*/
|
||||
#define BITSET_FOR_EACH(ITER, BSET, BIT, MIN) \
|
||||
#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, \
|
||||
(ITER.num == BITSET_LIST_SIZE) \
|
||||
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
|
||||
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, setting BIT to the index of each set bit. For example, the
|
||||
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_zero (dst);
|
||||
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
|
||||
{
|
||||
printf ("%ld ", i);
|
||||
printf ("%lu ", (unsigned long int) i);
|
||||
};
|
||||
*/
|
||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, BIT, MIN) \
|
||||
#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_SIZE) \
|
||||
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
|
||||
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. */
|
||||
@@ -349,30 +361,28 @@ extern void bitset_dump PARAMS ((FILE *, bitset));
|
||||
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);
|
||||
|
||||
/* Enable bitset stats gathering. */
|
||||
extern void bitset_stats_enable PARAMS ((void));
|
||||
extern void bitset_stats_enable (void);
|
||||
|
||||
/* Disable bitset stats gathering. */
|
||||
extern void bitset_stats_disable PARAMS ((void));
|
||||
extern void bitset_stats_disable (void);
|
||||
|
||||
/* Read bitset stats file of accummulated stats. */
|
||||
void bitset_stats_read PARAMS ((const char *filename));
|
||||
void bitset_stats_read (const char *file_name);
|
||||
|
||||
/* Write bitset stats file of accummulated stats. */
|
||||
void bitset_stats_write PARAMS ((const char *filename));
|
||||
void bitset_stats_write (const char *file_name);
|
||||
|
||||
/* 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 */
|
||||
|
||||
|
||||
+63
-52
@@ -1,5 +1,5 @@
|
||||
/* Bitset statistics.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
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.
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* This file is a wrapper bitset implementation for the other bitset
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "abitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "vbitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -49,29 +50,29 @@
|
||||
|
||||
|
||||
/* Accessor macros. */
|
||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||
bitset_stats_info->types[(TYPE)].allocs++
|
||||
#define BITSET_STATS_FREES_INC(BSET) \
|
||||
#define BITSET_STATS_FREES_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
||||
#define BITSET_STATS_SETS_INC(BSET) \
|
||||
#define BITSET_STATS_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
||||
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
||||
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
||||
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
||||
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
||||
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||
#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) \
|
||||
#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) \
|
||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||
|
||||
|
||||
@@ -100,7 +101,7 @@ struct bitset_stats_info_struct
|
||||
|
||||
struct bitset_stats_info_struct bitset_stats_info_data;
|
||||
struct bitset_stats_info_struct *bitset_stats_info;
|
||||
int bitset_stats_enabled = 0;
|
||||
bool bitset_stats_enabled = false;
|
||||
|
||||
|
||||
/* Print a percentage histogram with message MSG to FILE. */
|
||||
@@ -159,8 +160,8 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||
for (; i < n_bins; i++)
|
||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||
(unsigned long) 1 << (i - 1),
|
||||
((unsigned long) 1 << i) - 1,
|
||||
1UL << (i - 1),
|
||||
(1UL << i) - 1,
|
||||
bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
@@ -203,7 +204,7 @@ bitset_stats_print_1 (FILE *file, const char *name,
|
||||
|
||||
/* Print all bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print (FILE *file, int verbose ATTRIBUTE_UNUSED)
|
||||
bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -227,30 +228,30 @@ bitset_stats_enable (void)
|
||||
{
|
||||
if (!bitset_stats_info)
|
||||
bitset_stats_info = &bitset_stats_info_data;
|
||||
bitset_stats_enabled = 1;
|
||||
bitset_stats_enabled = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bitset_stats_disable (void)
|
||||
{
|
||||
bitset_stats_enabled = 0;
|
||||
bitset_stats_enabled = false;
|
||||
}
|
||||
|
||||
|
||||
/* Read bitset statistics file. */
|
||||
void
|
||||
bitset_stats_read (const char *filename)
|
||||
bitset_stats_read (const char *file_name)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
if (!file_name)
|
||||
file_name = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "r");
|
||||
file = fopen (file_name, "r");
|
||||
if (file)
|
||||
{
|
||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
@@ -270,17 +271,17 @@ bitset_stats_read (const char *filename)
|
||||
|
||||
/* Write bitset statistics file. */
|
||||
void
|
||||
bitset_stats_write (const char *filename)
|
||||
bitset_stats_write (const char *file_name)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
if (!file_name)
|
||||
file_name = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "w");
|
||||
file = fopen (file_name, "w");
|
||||
if (file)
|
||||
{
|
||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
@@ -298,7 +299,7 @@ bitset_stats_write (const char *filename)
|
||||
void
|
||||
bitset_stats_dump (FILE *file)
|
||||
{
|
||||
bitset_stats_print (file, 0);
|
||||
bitset_stats_print (file, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +307,7 @@ bitset_stats_dump (FILE *file)
|
||||
void
|
||||
debug_bitset_stats (void)
|
||||
{
|
||||
bitset_stats_print (stderr, 1);
|
||||
bitset_stats_print (stderr, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,14 +350,14 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_test (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset bset = src->s.bset;
|
||||
@@ -375,6 +376,13 @@ bitset_stats_test (bitset src, bitset_bindex 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)
|
||||
{
|
||||
@@ -389,7 +397,7 @@ bitset_stats_count (bitset src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_empty_p (bitset dst)
|
||||
{
|
||||
return BITSET_EMPTY_P_ (dst->s.bset);
|
||||
@@ -418,7 +426,7 @@ bitset_stats_copy (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
@@ -426,7 +434,7 @@ bitset_stats_disjoint_p (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
@@ -442,7 +450,7 @@ bitset_stats_not (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
@@ -458,7 +466,7 @@ bitset_stats_and (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
@@ -474,7 +482,7 @@ bitset_stats_andn (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
@@ -490,7 +498,7 @@ bitset_stats_or (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
@@ -506,7 +514,7 @@ bitset_stats_xor (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
@@ -518,16 +526,14 @@ 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 int
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -536,16 +542,14 @@ 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 int
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -554,16 +558,14 @@ 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 int
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -628,6 +630,7 @@ struct bitset_vtable bitset_stats_vtable = {
|
||||
bitset_stats_reset,
|
||||
bitset_stats_toggle,
|
||||
bitset_stats_test,
|
||||
bitset_stats_resize,
|
||||
bitset_stats_size,
|
||||
bitset_stats_count,
|
||||
bitset_stats_empty_p,
|
||||
@@ -687,28 +690,36 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||
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);
|
||||
sbset = xcalloc (1, bytes);
|
||||
abitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_LIST:
|
||||
bytes = lbitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
sbset = xcalloc (1, bytes);
|
||||
lbitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_TABLE:
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
sbset = xcalloc (1, bytes);
|
||||
ebitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_VARRAY:
|
||||
bytes = vbitset_bytes (n_bits);
|
||||
sbset = xcalloc (1, bytes);
|
||||
vbitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
+6
-7
@@ -1,5 +1,5 @@
|
||||
/* Functions to support bitset statistics.
|
||||
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
|
||||
@@ -14,20 +14,19 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _BITSET_STATS_H
|
||||
#define _BITSET_STATS_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
extern int bitset_stats_enabled;
|
||||
extern bool bitset_stats_enabled;
|
||||
|
||||
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
|
||||
extern enum bitset_type bitset_stats_type_get (bitset);
|
||||
|
||||
extern size_t bitset_stats_bytes PARAMS ((void));
|
||||
extern size_t bitset_stats_bytes (void);
|
||||
|
||||
extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex,
|
||||
enum bitset_type));
|
||||
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
|
||||
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison.
|
||||
|
||||
@@ -15,8 +15,8 @@ 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. */
|
||||
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -57,7 +57,7 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||
/* Contents. */
|
||||
for (i = 0; bset[i]; ++i)
|
||||
{
|
||||
fprintf (out, "%2lu|", (unsigned long) 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);
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
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
|
||||
@@ -14,7 +14,7 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _BITSETV_PRINT_H
|
||||
#define _BITSETV_PRINT_H
|
||||
@@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#include "bitsetv.h"
|
||||
|
||||
/* Dump vector of bitsets as a matrix. */
|
||||
extern void bitsetv_matrix_dump PARAMS ((FILE *, const char *,
|
||||
bitsetv));
|
||||
extern void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
@@ -15,8 +15,8 @@ for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -47,7 +47,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||
/* Allocate vector table at head of bitset array. */
|
||||
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
|
||||
vector_bytes -= vector_bytes % bytes;
|
||||
bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||
bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||
|
||||
for (i = 0; i < n_vecs; i++)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||
fprintf (file, "%s\n", title);
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
|
||||
fprintf (file, "%s %lu\n", subtitle, (unsigned long int) i);
|
||||
bitset_dump (file, bsetv[i]);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ debug_bitsetv (bitsetv bsetv)
|
||||
|
||||
for (i = 0; bsetv[i]; i++)
|
||||
{
|
||||
fprintf (stderr, "%lu: ", (unsigned long) i);
|
||||
fprintf (stderr, "%lu: ", (unsigned long int) i);
|
||||
debug_bitset (bsetv[i]);
|
||||
}
|
||||
|
||||
|
||||
+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
|
||||
@@ -14,7 +14,7 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _BITSETV_H
|
||||
#define _BITSETV_H
|
||||
@@ -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 ((bitset_bindex, bitset_bindex,
|
||||
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 ((bitset_bindex, bitset_bindex,
|
||||
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
|
||||
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 */
|
||||
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
/* dirname.c -- return all but the last element in a path
|
||||
Copyright 1990, 1998, 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
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Return the length of `dirname (PATH)', or zero if PATH is
|
||||
in the working directory. Works properly even if
|
||||
there are trailing slashes (by effectively ignoring them). */
|
||||
size_t
|
||||
dir_len (char const *path)
|
||||
{
|
||||
size_t prefix_length = FILESYSTEM_PREFIX_LEN (path);
|
||||
size_t length;
|
||||
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = base_name (path) - path; prefix_length < length; length--)
|
||||
if (! ISSLASH (path[length - 1]))
|
||||
return length;
|
||||
|
||||
/* But don't strip the only slash from "/". */
|
||||
return prefix_length + ISSLASH (path[prefix_length]);
|
||||
}
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with xmalloc.
|
||||
Works properly even if there are trailing slashes
|
||||
(by effectively ignoring them). */
|
||||
|
||||
char *
|
||||
dir_name (char const *path)
|
||||
{
|
||||
size_t length = dir_len (path);
|
||||
int append_dot = (length == FILESYSTEM_PREFIX_LEN (path));
|
||||
char *newpath = xmalloc (length + append_dot + 1);
|
||||
memcpy (newpath, path, length);
|
||||
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 \
|
||||
basename.c dirname.c xmalloc.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>
|
||||
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
/* Copyright (C) 1998, 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. */
|
||||
|
||||
#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
|
||||
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
# endif
|
||||
|
||||
# ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
# endif
|
||||
|
||||
# ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
|
||||
char *base_name PARAMS ((char const *path));
|
||||
char *dir_name PARAMS ((char const *path));
|
||||
size_t base_len PARAMS ((char const *path));
|
||||
size_t dir_len PARAMS ((char const *path));
|
||||
|
||||
int strip_trailing_slashes PARAMS ((char *path));
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
||||
+233
-125
@@ -1,5 +1,5 @@
|
||||
/* Functions to support expandable bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
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.
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ebitset.h"
|
||||
#include "obstack.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This file implements expandable bitsets. These bitsets can be of
|
||||
arbitrary length and are more efficient than arrays of bits for
|
||||
@@ -51,7 +52,7 @@
|
||||
|
||||
/* Number of bits stored in each element. */
|
||||
#define EBITSET_ELT_BITS \
|
||||
((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
|
||||
((unsigned int) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
|
||||
|
||||
/* Ebitset element. We use an array of bits. */
|
||||
typedef struct ebitset_elt_struct
|
||||
@@ -75,11 +76,6 @@ typedef ebitset_elt *ebitset_elts;
|
||||
#define EBITSET_INITIAL_SIZE 2
|
||||
#endif
|
||||
|
||||
/* Minimum number of elements to grow table. */
|
||||
|
||||
#ifndef EBITSET_GROW_SIZE
|
||||
#define EBITSET_GROW_SIZE 4
|
||||
#endif
|
||||
|
||||
enum ebitset_find_mode
|
||||
{ EBITSET_FIND, EBITSET_CREATE, EBITSET_SUBST };
|
||||
@@ -88,11 +84,13 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
|
||||
|
||||
/* Obstack to allocate bitset elements from. */
|
||||
static struct obstack ebitset_obstack;
|
||||
static int ebitset_obstack_init = 0;
|
||||
static bool ebitset_obstack_init = false;
|
||||
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
||||
|
||||
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
|
||||
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
|
||||
#define EBITSET_SIZE(BSET) ((BSET)->e.size)
|
||||
#define EBITSET_SIZE(BSET) EBITSET_N_ELTS (BITSET_NBITS_ (BSET))
|
||||
#define EBITSET_ASIZE(BSET) ((BSET)->e.size)
|
||||
|
||||
#define EBITSET_NEXT(ELT) ((ELT)->u.next)
|
||||
#define EBITSET_WORDS(ELT) ((ELT)->u.words)
|
||||
@@ -117,25 +115,65 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
|
||||
((BSET)->b.cindex = (EINDEX) * EBITSET_ELT_WORDS, \
|
||||
(BSET)->b.cdata = EBITSET_WORDS (EBITSET_ELTS (BSET) [EINDEX]))
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* Grow the expandable table for BSET by SIZE elements. */
|
||||
static void
|
||||
ebitset_elts_grow (bitset bset, bitset_windex size)
|
||||
static bitset_bindex
|
||||
ebitset_resize (bitset src, bitset_bindex n_bits)
|
||||
{
|
||||
bitset_windex oldsize;
|
||||
bitset_windex newsize;
|
||||
|
||||
oldsize = EBITSET_SIZE (bset);
|
||||
newsize = oldsize + size;
|
||||
if (n_bits == BITSET_NBITS_ (src))
|
||||
return n_bits;
|
||||
|
||||
if (BITSET_SIZE_MAX / sizeof (ebitset_elt *) < newsize)
|
||||
xalloc_die ();
|
||||
oldsize = EBITSET_SIZE (src);
|
||||
newsize = EBITSET_N_ELTS (n_bits);
|
||||
|
||||
EBITSET_ELTS (bset) = xrealloc (EBITSET_ELTS (bset),
|
||||
newsize * sizeof (ebitset_elt *));
|
||||
EBITSET_SIZE (bset) = newsize;
|
||||
if (oldsize < newsize)
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
memset (EBITSET_ELTS (bset) + oldsize, 0, size * sizeof (ebitset_elt *));
|
||||
/* The bitset needs to grow. If we already have enough memory
|
||||
allocated, then just zero what we need. */
|
||||
if (newsize > EBITSET_ASIZE (src))
|
||||
{
|
||||
/* We need to allocate more memory. When oldsize is
|
||||
non-zero this means that we are changing the size, so
|
||||
grow the bitset 25% larger than requested to reduce
|
||||
number of reallocations. */
|
||||
|
||||
if (oldsize == 0)
|
||||
size = newsize;
|
||||
else
|
||||
size = newsize + newsize / 4;
|
||||
|
||||
EBITSET_ELTS (src)
|
||||
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
||||
EBITSET_ASIZE (src) = size;
|
||||
}
|
||||
|
||||
memset (EBITSET_ELTS (src) + oldsize, 0,
|
||||
(newsize - oldsize) * sizeof (ebitset_elt *));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The bitset needs to shrink. There's no point deallocating
|
||||
the memory unless it is shrinking by a reasonable amount. */
|
||||
if ((oldsize - newsize) >= oldsize / 2)
|
||||
{
|
||||
EBITSET_ELTS (src)
|
||||
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
|
||||
EBITSET_ASIZE (src) = newsize;
|
||||
}
|
||||
|
||||
/* Need to prune any excess bits. FIXME. */
|
||||
}
|
||||
|
||||
BITSET_NBITS_ (src) = n_bits;
|
||||
return n_bits;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +192,7 @@ ebitset_elt_alloc (void)
|
||||
{
|
||||
if (!ebitset_obstack_init)
|
||||
{
|
||||
ebitset_obstack_init = 1;
|
||||
ebitset_obstack_init = true;
|
||||
|
||||
/* Let particular systems override the size of a chunk. */
|
||||
|
||||
@@ -178,9 +216,7 @@ ebitset_elt_alloc (void)
|
||||
|
||||
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||
__alignof__ (ebitset_elt),
|
||||
(void *(*)PARAMS ((long)))
|
||||
OBSTACK_CHUNK_ALLOC,
|
||||
(void (*)PARAMS ((void *)))
|
||||
OBSTACK_CHUNK_FREE);
|
||||
}
|
||||
|
||||
@@ -242,22 +278,22 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
|
||||
}
|
||||
|
||||
|
||||
/* Return nonzero if all bits in an element are zero. */
|
||||
static inline int
|
||||
/* Are all bits in an element zero? */
|
||||
static inline bool
|
||||
ebitset_elt_zero_p (ebitset_elt *elt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (elt)[i])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static ebitset_elt *
|
||||
ebitset_elt_find (bitset bset, bitset_windex windex,
|
||||
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||
enum ebitset_find_mode mode)
|
||||
{
|
||||
ebitset_elt *elt;
|
||||
@@ -265,7 +301,7 @@ ebitset_elt_find (bitset bset, bitset_windex windex,
|
||||
bitset_windex eindex;
|
||||
ebitset_elts *elts;
|
||||
|
||||
eindex = windex / EBITSET_ELT_WORDS;
|
||||
eindex = bindex / EBITSET_ELT_BITS;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
size = EBITSET_SIZE (bset);
|
||||
@@ -291,21 +327,7 @@ ebitset_elt_find (bitset bset, bitset_windex windex,
|
||||
|
||||
case EBITSET_CREATE:
|
||||
if (eindex >= size)
|
||||
{
|
||||
bitset_windex extra;
|
||||
|
||||
extra = eindex - size + 1;
|
||||
|
||||
/* We need to expand the table by EXTRA elements. It may be
|
||||
better with large bitsets to grow the number of
|
||||
elements by some fraction of the current size otherwise
|
||||
we can spend a lot of time slowly increasing the size of the
|
||||
bitset. */
|
||||
if (extra < EBITSET_GROW_SIZE)
|
||||
extra = EBITSET_GROW_SIZE;
|
||||
|
||||
ebitset_elts_grow (bset, extra);
|
||||
}
|
||||
ebitset_resize (bset, bindex);
|
||||
|
||||
/* Create a new element. */
|
||||
elt = ebitset_elt_calloc ();
|
||||
@@ -322,18 +344,6 @@ ebitset_elt_find (bitset bset, bitset_windex windex,
|
||||
}
|
||||
|
||||
|
||||
static inline ebitset_elt *
|
||||
ebitset_elt_last (bitset bset)
|
||||
{
|
||||
ebitset_elts *elts;
|
||||
|
||||
elts = EBITSET_ELTS (bset);
|
||||
|
||||
/* Assume that have at least one element in elts. */
|
||||
return elts[EBITSET_SIZE (bset) - 1];
|
||||
}
|
||||
|
||||
|
||||
/* Weed out the zero elements from the elts. */
|
||||
static inline bitset_windex
|
||||
ebitset_weed (bitset bset)
|
||||
@@ -353,7 +363,7 @@ ebitset_weed (bitset bset)
|
||||
|
||||
if (elt)
|
||||
{
|
||||
if (elt && ebitset_elt_zero_p (elt))
|
||||
if (ebitset_elt_zero_p (elt))
|
||||
{
|
||||
ebitset_elt_remove (bset, j);
|
||||
count++;
|
||||
@@ -402,7 +412,7 @@ ebitset_zero (bitset bset)
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
static inline bool
|
||||
ebitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
ebitset_elts *selts;
|
||||
@@ -410,13 +420,13 @@ ebitset_equal_p (bitset dst, bitset src)
|
||||
bitset_windex j;
|
||||
|
||||
if (src == dst)
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
ebitset_weed (dst);
|
||||
ebitset_weed (src);
|
||||
|
||||
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
@@ -430,13 +440,13 @@ ebitset_equal_p (bitset dst, bitset src)
|
||||
if (!selt && !delt)
|
||||
continue;
|
||||
if ((selt && !delt) || (!selt && delt))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,8 +463,8 @@ ebitset_copy_ (bitset dst, bitset src)
|
||||
|
||||
ebitset_zero (dst);
|
||||
|
||||
if (EBITSET_SIZE (dst) < EBITSET_SIZE (src))
|
||||
ebitset_elts_grow (dst, EBITSET_SIZE (src) - EBITSET_SIZE (dst));
|
||||
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
|
||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
||||
|
||||
selts = EBITSET_ELTS (src);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
@@ -476,13 +486,13 @@ ebitset_copy_ (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
/* Copy bits from bitset SRC to bitset DST. Return non-zero if
|
||||
/* Copy bits from bitset SRC to bitset DST. Return true if
|
||||
bitsets different. */
|
||||
static inline int
|
||||
static inline bool
|
||||
ebitset_copy_cmp (bitset dst, bitset src)
|
||||
{
|
||||
if (src == dst)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (EBITSET_ZERO_P (dst))
|
||||
{
|
||||
@@ -491,19 +501,10 @@ ebitset_copy_cmp (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
if (ebitset_equal_p (dst, src))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
ebitset_copy_ (dst, src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
static bitset_bindex
|
||||
ebitset_size (bitset src)
|
||||
{
|
||||
/* Return current size of bitset in bits. */
|
||||
return EBITSET_SIZE (src) * EBITSET_ELT_BITS;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -513,7 +514,7 @@ ebitset_set (bitset dst, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
ebitset_elt_find (dst, windex, EBITSET_CREATE);
|
||||
ebitset_elt_find (dst, bitno, EBITSET_CREATE);
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] |=
|
||||
(bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||
@@ -526,7 +527,7 @@ ebitset_reset (bitset dst, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
if (!ebitset_elt_find (dst, windex, EBITSET_FIND))
|
||||
if (!ebitset_elt_find (dst, bitno, EBITSET_FIND))
|
||||
return;
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] &=
|
||||
@@ -539,16 +540,15 @@ ebitset_reset (bitset dst, bitset_bindex bitno)
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static int
|
||||
static bool
|
||||
ebitset_test (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
if (!ebitset_elt_find (src, windex, EBITSET_FIND))
|
||||
return 0;
|
||||
|
||||
return (src->b.
|
||||
cdata[windex - src->b.cindex] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
|
||||
&& ((src->b.cdata[windex - src->b.cindex]
|
||||
>> (bitno % BITSET_WORD_BITS))
|
||||
& 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -732,6 +732,48 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
{
|
||||
/* The coast is clear, plant boot! */
|
||||
|
||||
#if EBITSET_ELT_WORDS == 2
|
||||
word = srcp[0];
|
||||
if (word)
|
||||
{
|
||||
if (!(word & 0xffff))
|
||||
{
|
||||
word >>= 16;
|
||||
bitno += 16;
|
||||
}
|
||||
if (!(word & 0xff))
|
||||
{
|
||||
word >>= 8;
|
||||
bitno += 8;
|
||||
}
|
||||
for (; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
windex++;
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
|
||||
word = srcp[1];
|
||||
if (word)
|
||||
{
|
||||
if (!(word & 0xffff))
|
||||
{
|
||||
word >>= 16;
|
||||
bitno += 16;
|
||||
}
|
||||
for (; word; bitno++)
|
||||
{
|
||||
if (word & 1)
|
||||
list[count++] = bitno;
|
||||
word >>= 1;
|
||||
}
|
||||
}
|
||||
windex++;
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
#else
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||
{
|
||||
bitno = windex * BITSET_WORD_BITS;
|
||||
@@ -757,6 +799,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -789,29 +832,91 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
||||
}
|
||||
|
||||
|
||||
/* Ensure that any unused bits within the last element are clear. */
|
||||
static inline void
|
||||
ebitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned int last_bit;
|
||||
bitset_bindex n_bits;
|
||||
|
||||
n_bits = BITSET_NBITS_ (dst);
|
||||
last_bit = n_bits % EBITSET_ELT_BITS;
|
||||
|
||||
if (last_bit)
|
||||
{
|
||||
bitset_windex eindex;
|
||||
ebitset_elts *elts;
|
||||
ebitset_elt *elt;
|
||||
|
||||
elts = EBITSET_ELTS (dst);
|
||||
|
||||
eindex = n_bits / EBITSET_ELT_BITS;
|
||||
|
||||
elt = elts[eindex];
|
||||
if (elt)
|
||||
{
|
||||
bitset_windex windex;
|
||||
bitset_windex woffset;
|
||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||
|
||||
windex = n_bits / BITSET_WORD_BITS;
|
||||
woffset = eindex * EBITSET_ELT_WORDS;
|
||||
|
||||
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
||||
windex++;
|
||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||
srcp[windex - woffset] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ebitset_ones (bitset dst)
|
||||
{
|
||||
bitset_windex j;
|
||||
ebitset_elt *elt;
|
||||
|
||||
|
||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
{
|
||||
/* Create new elements if they cannot be found. Perhaps
|
||||
we should just add pointers to a ones element. */
|
||||
we should just add pointers to a ones element? */
|
||||
elt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||
}
|
||||
EBITSET_NONZERO_SET (dst);
|
||||
ebitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_empty_p (bitset dst)
|
||||
{
|
||||
return !ebitset_weed (dst);
|
||||
ebitset_elts *elts;
|
||||
bitset_windex j;
|
||||
|
||||
if (EBITSET_ZERO_P (dst))
|
||||
return 1;
|
||||
|
||||
elts = EBITSET_ELTS (dst);
|
||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||
{
|
||||
ebitset_elt *elt = elts[j];
|
||||
|
||||
if (elt)
|
||||
{
|
||||
if (!ebitset_elt_zero_p (elt))
|
||||
return 0;
|
||||
/* Do some weeding as we go. */
|
||||
ebitset_elt_remove (dst, j);
|
||||
}
|
||||
}
|
||||
|
||||
/* All the bits are zero. We could shrink the elts.
|
||||
For now just mark DST as known to be zero. */
|
||||
EBITSET_ZERO_SET (dst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -823,24 +928,27 @@ ebitset_not (bitset dst, bitset src)
|
||||
ebitset_elt *delt;
|
||||
bitset_windex j;
|
||||
|
||||
ebitset_resize (dst, BITSET_NBITS_ (src));
|
||||
|
||||
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||
{
|
||||
/* Create new elements for dst if they cannot be found
|
||||
or substitute zero elements if src elements not found. */
|
||||
or substitute zero elements if src elements not found. */
|
||||
selt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_SUBST);
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
||||
delt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
|
||||
}
|
||||
EBITSET_NONZERO_SET (dst);
|
||||
ebitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
|
||||
/* Return 1 if DST == DST | SRC. */
|
||||
static int
|
||||
/* Is DST == DST | SRC? */
|
||||
static bool
|
||||
ebitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex j;
|
||||
@@ -875,14 +983,14 @@ ebitset_subset_p (bitset dst, bitset src)
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if (EBITSET_WORDS (delt)[i]
|
||||
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Return 1 if DST & SRC == 0. */
|
||||
static int
|
||||
/* Is DST & SRC == 0? */
|
||||
static bool
|
||||
ebitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
bitset_windex j;
|
||||
@@ -911,14 +1019,14 @@ ebitset_disjoint_p (bitset dst, bitset src)
|
||||
|
||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
{
|
||||
bitset_windex ssize1;
|
||||
@@ -931,10 +1039,12 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
bitset_word *srcp1;
|
||||
bitset_word *srcp2;
|
||||
bitset_word *dstp;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
unsigned int i;
|
||||
bitset_windex j;
|
||||
|
||||
ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
|
||||
|
||||
ssize1 = EBITSET_SIZE (src1);
|
||||
ssize2 = EBITSET_SIZE (src2);
|
||||
dsize = EBITSET_SIZE (dst);
|
||||
@@ -942,9 +1052,6 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
if (size < ssize2)
|
||||
size = ssize2;
|
||||
|
||||
if (size > dsize)
|
||||
ebitset_elts_grow (dst, size - dsize);
|
||||
|
||||
selts1 = EBITSET_ELTS (src1);
|
||||
selts2 = EBITSET_ELTS (src2);
|
||||
delts = EBITSET_ELTS (dst);
|
||||
@@ -963,7 +1070,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
{
|
||||
if (delt)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
ebitset_elt_remove (dst, j);
|
||||
}
|
||||
continue;
|
||||
@@ -990,7 +1097,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1003,7 +1110,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1016,7 +1123,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1029,7 +1136,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1054,7 +1161,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
{
|
||||
ebitset_elt *delt;
|
||||
|
||||
changed = 1;
|
||||
changed = true;
|
||||
|
||||
delt = delts[j];
|
||||
|
||||
@@ -1067,10 +1174,10 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
int changed;
|
||||
bool changed;
|
||||
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
{
|
||||
@@ -1097,10 +1204,10 @@ ebitset_and (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
int changed;
|
||||
bool changed;
|
||||
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
{
|
||||
@@ -1124,7 +1231,7 @@ ebitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
@@ -1146,7 +1253,7 @@ ebitset_or (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
ebitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
if (EBITSET_ZERO_P (src2))
|
||||
@@ -1184,7 +1291,8 @@ struct bitset_vtable ebitset_vtable = {
|
||||
ebitset_reset,
|
||||
bitset_toggle_,
|
||||
ebitset_test,
|
||||
ebitset_size,
|
||||
ebitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
ebitset_empty_p,
|
||||
ebitset_ones,
|
||||
@@ -1239,9 +1347,9 @@ ebitset_init (bitset bset, bitset_bindex n_bits)
|
||||
size = n_bits ? (n_bits + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS
|
||||
: EBITSET_INITIAL_SIZE;
|
||||
|
||||
EBITSET_SIZE (bset) = 0;
|
||||
EBITSET_ASIZE (bset) = 0;
|
||||
EBITSET_ELTS (bset) = 0;
|
||||
ebitset_elts_grow (bset, size);
|
||||
ebitset_resize (bset, n_bits);
|
||||
|
||||
return bset;
|
||||
}
|
||||
@@ -1253,7 +1361,7 @@ ebitset_release_memory (void)
|
||||
ebitset_free_list = 0;
|
||||
if (ebitset_obstack_init)
|
||||
{
|
||||
ebitset_obstack_init = 0;
|
||||
ebitset_obstack_init = false;
|
||||
obstack_free (&ebitset_obstack, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
+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 (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -14,17 +14,17 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t 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
|
||||
|
||||
-407
@@ -1,407 +0,0 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000, 2001, 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. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
#else
|
||||
# include "gettext.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"
|
||||
|
||||
#if !_LIBC
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#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>
|
||||
# include <libio/libioP.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) INTUSE(_IO_fflush) (s)
|
||||
# undef putc
|
||||
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||
# 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 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. */
|
||||
|
||||
#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
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
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. */
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
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. */
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
extern int get_errno (void);
|
||||
extern void set_errno (int);
|
||||
|
||||
-1273
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.
|
||||
|
||||
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 _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 */
|
||||
-195
@@ -1,195 +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.
|
||||
|
||||
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
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <getopt.h>
|
||||
#else
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
# ifdef _LIBC
|
||||
libc_hidden_def (getopt_long)
|
||||
libc_hidden_def (getopt_long_only)
|
||||
# endif
|
||||
|
||||
#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,69 +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
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* 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 */
|
||||
-1053
File diff suppressed because it is too large
Load Diff
-93
@@ -1,93 +0,0 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998, 1999, 2001 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 HASH_H_
|
||||
# define HASH_H_
|
||||
|
||||
# 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;
|
||||
|
||||
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 *));
|
||||
|
||||
#endif
|
||||
+110
-77
@@ -1,5 +1,5 @@
|
||||
/* Functions to support link list bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 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
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
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.
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This file implements linked-list bitsets. These bitsets can be of
|
||||
arbitrary length and are more efficient than arrays of bits for
|
||||
@@ -40,7 +41,10 @@
|
||||
/* Number of words to use for each element. The larger the value the
|
||||
greater the size of the cache and the shorter the time to find a given bit
|
||||
but the more memory wasted for sparse bitsets and the longer the time
|
||||
to search for set bits. */
|
||||
to search for set bits.
|
||||
|
||||
The routines that dominate timing profiles are lbitset_elt_find
|
||||
and lbitset_elt_link, especially when accessing the bits randomly. */
|
||||
|
||||
#define LBITSET_ELT_WORDS 2
|
||||
|
||||
@@ -50,7 +54,7 @@ typedef bitset_word lbitset_word;
|
||||
|
||||
/* Number of bits stored in each element. */
|
||||
#define LBITSET_ELT_BITS \
|
||||
((unsigned) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
|
||||
((unsigned int) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
|
||||
|
||||
/* Lbitset element. We use an array of bits for each element.
|
||||
These are linked together in a doubly-linked list. */
|
||||
@@ -71,10 +75,10 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
|
||||
|
||||
/* Obstack to allocate bitset elements from. */
|
||||
static struct obstack lbitset_obstack;
|
||||
static int lbitset_obstack_init = 0;
|
||||
static bool lbitset_obstack_init = false;
|
||||
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
|
||||
|
||||
extern void debug_lbitset PARAMS ((bitset));
|
||||
extern void debug_lbitset (bitset);
|
||||
|
||||
#define LBITSET_CURRENT1(X) \
|
||||
((lbitset_elt *) (void *) ((char *) (X) - offsetof (lbitset_elt, words)))
|
||||
@@ -99,7 +103,7 @@ lbitset_elt_alloc (void)
|
||||
{
|
||||
if (!lbitset_obstack_init)
|
||||
{
|
||||
lbitset_obstack_init = 1;
|
||||
lbitset_obstack_init = true;
|
||||
|
||||
/* Let particular systems override the size of a chunk. */
|
||||
|
||||
@@ -123,9 +127,7 @@ lbitset_elt_alloc (void)
|
||||
|
||||
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||
__alignof__ (lbitset_elt),
|
||||
(void *(*)PARAMS ((long)))
|
||||
OBSTACK_CHUNK_ALLOC,
|
||||
(void (*)PARAMS ((void *)))
|
||||
OBSTACK_CHUNK_FREE);
|
||||
}
|
||||
|
||||
@@ -236,17 +238,17 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
|
||||
}
|
||||
|
||||
|
||||
/* Return nonzero if all bits in an element are zero. */
|
||||
static inline int
|
||||
/* Are all bits in an element zero? */
|
||||
static inline bool
|
||||
lbitset_elt_zero_p (lbitset_elt *elt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
if (elt->words[i])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -412,8 +414,8 @@ lbitset_zero (bitset bset)
|
||||
}
|
||||
|
||||
|
||||
/* Return 1 if DST == SRC. */
|
||||
static inline int
|
||||
/* Is DST == SRC? */
|
||||
static inline bool
|
||||
lbitset_equal_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
@@ -421,7 +423,7 @@ lbitset_equal_p (bitset dst, bitset src)
|
||||
int j;
|
||||
|
||||
if (src == dst)
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
lbitset_weed (src);
|
||||
lbitset_weed (dst);
|
||||
@@ -429,11 +431,11 @@ lbitset_equal_p (bitset dst, bitset src)
|
||||
selt && delt; selt = selt->next, delt = delt->next)
|
||||
{
|
||||
if (selt->index != delt->index)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (delt->words[j] != selt->words[j])
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return !selt && !delt;
|
||||
}
|
||||
@@ -480,13 +482,13 @@ lbitset_copy (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
|
||||
/* Copy bits from bitset SRC to bitset DST. Return non-zero if
|
||||
/* Copy bits from bitset SRC to bitset DST. Return true if
|
||||
bitsets different. */
|
||||
static inline int
|
||||
static inline bool
|
||||
lbitset_copy_cmp (bitset dst, bitset src)
|
||||
{
|
||||
if (src == dst)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (!LBITSET_HEAD (dst))
|
||||
{
|
||||
@@ -495,28 +497,22 @@ lbitset_copy_cmp (bitset dst, bitset src)
|
||||
}
|
||||
|
||||
if (lbitset_equal_p (dst, src))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
lbitset_copy (dst, src);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
static bitset_bindex
|
||||
lbitset_size (bitset src)
|
||||
lbitset_resize (bitset src, bitset_bindex size)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
BITSET_NBITS_ (src) = size;
|
||||
|
||||
elt = LBITSET_TAIL (src);
|
||||
if (!elt)
|
||||
return 0;
|
||||
|
||||
/* Return current size of bitset in bits. */
|
||||
return (elt->index + LBITSET_ELT_WORDS) * BITSET_WORD_BITS;
|
||||
/* Need to prune any excess bits. FIXME. */
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
static void
|
||||
lbitset_set (bitset dst, bitset_bindex bitno)
|
||||
@@ -547,16 +543,15 @@ lbitset_reset (bitset dst, bitset_bindex bitno)
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static int
|
||||
static bool
|
||||
lbitset_test (bitset src, bitset_bindex bitno)
|
||||
{
|
||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||
|
||||
if (!lbitset_elt_find (src, windex, LBITSET_FIND))
|
||||
return 0;
|
||||
|
||||
return (src->b.cdata[windex - src->b.cindex]
|
||||
>> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
return (lbitset_elt_find (src, windex, LBITSET_FIND)
|
||||
&& ((src->b.cdata[windex - src->b.cindex]
|
||||
>> (bitno % BITSET_WORD_BITS))
|
||||
& 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -865,16 +860,54 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_empty_p (bitset dst)
|
||||
{
|
||||
lbitset_weed (dst);
|
||||
if (LBITSET_HEAD (dst))
|
||||
return 0;
|
||||
lbitset_elt *elt;
|
||||
lbitset_elt *next;
|
||||
|
||||
for (elt = LBITSET_HEAD (dst); elt; elt = next)
|
||||
{
|
||||
next = elt->next;
|
||||
if (!lbitset_elt_zero_p (elt))
|
||||
return 0;
|
||||
/* Weed as we go. */
|
||||
lbitset_elt_unlink (dst, elt);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure that any unused bits within the last element are clear. */
|
||||
static inline void
|
||||
lbitset_unused_clear (bitset dst)
|
||||
{
|
||||
unsigned int last_bit;
|
||||
bitset_bindex n_bits;
|
||||
|
||||
n_bits = BITSET_SIZE_ (dst);
|
||||
last_bit = n_bits % LBITSET_ELT_BITS;
|
||||
|
||||
if (last_bit)
|
||||
{
|
||||
lbitset_elt *elt;
|
||||
bitset_windex windex;
|
||||
bitset_word *srcp;
|
||||
|
||||
elt = LBITSET_TAIL (dst);
|
||||
srcp = elt->words;
|
||||
windex = n_bits / BITSET_WORD_BITS;
|
||||
|
||||
srcp[windex - elt->index] &= ((bitset_word) 1 << last_bit) - 1;
|
||||
windex++;
|
||||
|
||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
||||
srcp[windex - elt->index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
lbitset_ones (bitset dst)
|
||||
{
|
||||
@@ -886,18 +919,17 @@ lbitset_ones (bitset dst)
|
||||
bitset! It makes a sparse bitset become dense. An alternative
|
||||
is to have a flag that indicates that the bitset stores the
|
||||
complement of what it indicates. */
|
||||
elt = LBITSET_TAIL (dst);
|
||||
/* Ignore empty set. */
|
||||
if (!elt)
|
||||
return;
|
||||
|
||||
windex = elt->index;
|
||||
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
|
||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
{
|
||||
/* Create new elements if they cannot be found. */
|
||||
elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
memset (elt->words, -1, sizeof (elt->words));
|
||||
}
|
||||
|
||||
lbitset_unused_clear (dst);
|
||||
}
|
||||
|
||||
|
||||
@@ -914,11 +946,9 @@ lbitset_not (bitset dst, bitset src)
|
||||
/* This is another unfriendly operation for a linked list
|
||||
bitset! */
|
||||
elt = LBITSET_TAIL (dst);
|
||||
/* Ignore empty set. */
|
||||
if (!elt)
|
||||
return;
|
||||
|
||||
windex = elt->index;
|
||||
windex = (BITSET_SIZE_ (dst) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS;
|
||||
|
||||
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||
{
|
||||
/* Create new elements for dst if they cannot be found
|
||||
@@ -929,13 +959,14 @@ lbitset_not (bitset dst, bitset src)
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
delt->words[j] = ~selt->words[j];
|
||||
}
|
||||
lbitset_unused_clear (dst);
|
||||
lbitset_weed (dst);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Return 1 if DST == DST | SRC. */
|
||||
static int
|
||||
/* Is DST == DST | SRC? */
|
||||
static bool
|
||||
lbitset_subset_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
@@ -965,14 +996,14 @@ lbitset_subset_p (bitset dst, bitset src)
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Return 1 if DST & SRC == 0. */
|
||||
static int
|
||||
/* Is DST & SRC == 0? */
|
||||
static bool
|
||||
lbitset_disjoint_p (bitset dst, bitset src)
|
||||
{
|
||||
lbitset_elt *selt;
|
||||
@@ -1001,13 +1032,13 @@ lbitset_disjoint_p (bitset dst, bitset src)
|
||||
|
||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||
if (selt->words[j] & delt->words[j])
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
@@ -1022,7 +1053,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
bitset_word *srcp1;
|
||||
bitset_word *srcp2;
|
||||
bitset_word *dstp;
|
||||
int changed = 0;
|
||||
bool changed = false;
|
||||
unsigned int i;
|
||||
|
||||
LBITSET_HEAD (dst) = 0;
|
||||
@@ -1066,7 +1097,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
elements that we've skipped. */
|
||||
while (delt && delt->index < windex)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
dtmp = delt;
|
||||
delt = delt->next;
|
||||
lbitset_elt_free (dtmp);
|
||||
@@ -1093,7 +1124,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1106,7 +1137,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1119,7 +1150,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1132,7 +1163,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
|
||||
if (*dstp != tmp)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
*dstp = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1157,7 +1188,7 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
/* If we have elements of DST left over, free them all. */
|
||||
if (delt)
|
||||
{
|
||||
changed = 1;
|
||||
changed = true;
|
||||
lbitset_prune (dst, delt);
|
||||
}
|
||||
|
||||
@@ -1165,12 +1196,12 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
int changed;
|
||||
bool changed;
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
@@ -1197,12 +1228,12 @@ lbitset_and (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
lbitset_elt *selt2 = LBITSET_HEAD (src2);
|
||||
int changed;
|
||||
bool changed;
|
||||
|
||||
if (!selt2)
|
||||
{
|
||||
@@ -1226,7 +1257,7 @@ lbitset_andn (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
@@ -1251,7 +1282,7 @@ lbitset_or (bitset dst, bitset src1, bitset src2)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static bool
|
||||
lbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||
{
|
||||
lbitset_elt *selt1 = LBITSET_HEAD (src1);
|
||||
@@ -1283,7 +1314,8 @@ struct bitset_vtable lbitset_vtable = {
|
||||
lbitset_reset,
|
||||
bitset_toggle_,
|
||||
lbitset_test,
|
||||
lbitset_size,
|
||||
lbitset_resize,
|
||||
bitset_size_,
|
||||
bitset_count_,
|
||||
lbitset_empty_p,
|
||||
lbitset_ones,
|
||||
@@ -1326,6 +1358,7 @@ lbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
|
||||
bitset
|
||||
lbitset_init (bitset bset, bitset_bindex n_bits ATTRIBUTE_UNUSED)
|
||||
{
|
||||
BITSET_NBITS_ (bset) = n_bits;
|
||||
bset->b.vtable = &lbitset_vtable;
|
||||
return bset;
|
||||
}
|
||||
@@ -1337,7 +1370,7 @@ lbitset_release_memory (void)
|
||||
lbitset_free_list = 0;
|
||||
if (lbitset_obstack_init)
|
||||
{
|
||||
lbitset_obstack_init = 0;
|
||||
lbitset_obstack_init = false;
|
||||
obstack_free (&lbitset_obstack, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1355,7 +1388,7 @@ debug_lbitset (bitset bset)
|
||||
|
||||
for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
|
||||
{
|
||||
fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
|
||||
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
|
||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
+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
|
||||
@@ -14,17 +14,17 @@ 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. */
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
|
||||
#include "bitset.h"
|
||||
|
||||
extern size_t 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
|
||||
|
||||
+3
-25
@@ -1,5 +1,5 @@
|
||||
/* Fake libiberty.h for Bison.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
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
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
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. */
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
|
||||
/* Bison depends on libiberty's implementation of bitsets, which
|
||||
@@ -23,35 +23,13 @@
|
||||
#ifndef BISON_LIBIBERTY_H_
|
||||
# define BISON_LIBIBERTY_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
|
||||
/* 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
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
|
||||
# include "xalloc.h"
|
||||
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
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. */
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
-213
@@ -1,213 +0,0 @@
|
||||
/* Determine the number of screen columns needed for a string.
|
||||
Copyright (C) 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 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 Bruno Haible <[email protected]>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "mbswidth.h"
|
||||
|
||||
/* Get MB_CUR_MAX. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Get isprint(). */
|
||||
#include <ctype.h>
|
||||
|
||||
/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */
|
||||
#if HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
/* Get iswprint(), iswcntrl(). */
|
||||
#if HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
#if !defined iswprint && !HAVE_ISWPRINT
|
||||
# define iswprint(wc) 1
|
||||
#endif
|
||||
#if !defined iswcntrl && !HAVE_ISWCNTRL
|
||||
# define iswcntrl(wc) 0
|
||||
#endif
|
||||
|
||||
#ifndef mbsinit
|
||||
# if !HAVE_MBSINIT
|
||||
# define mbsinit(ps) 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_WCWIDTH
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_WCWIDTH
|
||||
int wcwidth ();
|
||||
#endif
|
||||
|
||||
#ifndef wcwidth
|
||||
# if !HAVE_WCWIDTH
|
||||
/* wcwidth doesn't exist, so assume all printable characters have
|
||||
width 1. */
|
||||
# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Get ISPRINT. */
|
||||
#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))
|
||||
#undef ISCNTRL
|
||||
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
|
||||
|
||||
/* Returns the number of columns needed to represent the multibyte
|
||||
character string pointed to by STRING. If a non-printable character
|
||||
occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
|
||||
With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is
|
||||
the multibyte analogon of the wcswidth function. */
|
||||
int
|
||||
mbswidth (const char *string, int flags)
|
||||
{
|
||||
return mbsnwidth (string, strlen (string), flags);
|
||||
}
|
||||
|
||||
/* Returns the number of columns needed to represent the multibyte
|
||||
character string pointed to by STRING of length NBYTES. If a
|
||||
non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is
|
||||
specified, -1 is returned. */
|
||||
int
|
||||
mbsnwidth (const char *string, size_t nbytes, int flags)
|
||||
{
|
||||
const char *p = string;
|
||||
const char *plimit = p + nbytes;
|
||||
int width;
|
||||
|
||||
width = 0;
|
||||
#if HAVE_MBRTOWC
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
while (p < plimit)
|
||||
switch (*p)
|
||||
{
|
||||
case ' ': case '!': case '"': case '#': case '%':
|
||||
case '&': case '\'': case '(': case ')': 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 '<': case '=': 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 ']': 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 '}': case '~':
|
||||
/* These characters are printable ASCII characters. */
|
||||
p++;
|
||||
width++;
|
||||
break;
|
||||
default:
|
||||
/* If we have a multibyte sequence, scan it up to its end. */
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
do
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t bytes;
|
||||
int w;
|
||||
|
||||
bytes = mbrtowc (&wc, p, plimit - p, &mbstate);
|
||||
|
||||
if (bytes == (size_t) -1)
|
||||
/* An invalid multibyte sequence was encountered. */
|
||||
{
|
||||
if (!(flags & MBSW_REJECT_INVALID))
|
||||
{
|
||||
p++;
|
||||
width++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes == (size_t) -2)
|
||||
/* An incomplete multibyte character at the end. */
|
||||
{
|
||||
if (!(flags & MBSW_REJECT_INVALID))
|
||||
{
|
||||
p = plimit;
|
||||
width++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes == 0)
|
||||
/* A null wide character was encountered. */
|
||||
bytes = 1;
|
||||
|
||||
w = wcwidth (wc);
|
||||
if (w >= 0)
|
||||
/* A printable multibyte character. */
|
||||
width += w;
|
||||
else
|
||||
/* An unprintable multibyte character. */
|
||||
if (!(flags & MBSW_REJECT_UNPRINTABLE))
|
||||
width += (iswcntrl (wc) ? 0 : 1);
|
||||
else
|
||||
return -1;
|
||||
|
||||
p += bytes;
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (p < plimit)
|
||||
{
|
||||
unsigned char c = (unsigned char) *p++;
|
||||
|
||||
if (ISPRINT (c))
|
||||
width++;
|
||||
else if (!(flags & MBSW_REJECT_UNPRINTABLE))
|
||||
width += (ISCNTRL (c) ? 0 : 1);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Determine the number of screen columns needed for a string.
|
||||
Copyright (C) 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 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. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Optional flags to influence mbswidth/mbsnwidth behavior. */
|
||||
|
||||
/* If this bit is set, return -1 upon finding an invalid or incomplete
|
||||
character. Otherwise, assume invalid characters have width 1. */
|
||||
#define MBSW_REJECT_INVALID 1
|
||||
|
||||
/* If this bit is set, return -1 upon finding a non-printable character.
|
||||
Otherwise, assume unprintable characters have width 0 if they are
|
||||
control characters and 1 otherwise. */
|
||||
#define MBSW_REJECT_UNPRINTABLE 2
|
||||
|
||||
/* Returns the number of screen columns needed for STRING. */
|
||||
#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
|
||||
extern int mbswidth (const char *string, int flags);
|
||||
|
||||
/* Returns the number of screen columns needed for the NBYTES bytes
|
||||
starting at BUF. */
|
||||
extern int mbsnwidth (const char *buf, size_t nbytes, int flags);
|
||||
-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
|
||||
-386
@@ -1,386 +0,0 @@
|
||||
/* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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. */
|
||||
# undef const
|
||||
# define const
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#ifndef __P
|
||||
# if defined __GNUC__ || (defined __STDC__ && __STDC__)
|
||||
# define __P(args) args
|
||||
# else
|
||||
# define __P(args) ()
|
||||
# endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
#if defined HAVE_STRING_H || defined _LIBC
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#undef memcmp
|
||||
|
||||
#ifdef _LIBC
|
||||
|
||||
# include <memcopy.h>
|
||||
# include <endian.h>
|
||||
|
||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define WORDS_BIGENDIAN
|
||||
# endif
|
||||
|
||||
#else /* Not in the GNU C library. */
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
/* Type to use for aligned memory operations.
|
||||
This should normally be the biggest type supported by a single load
|
||||
and store. Must be an unsigned type. */
|
||||
# define op_t unsigned long int
|
||||
# define OPSIZ (sizeof(op_t))
|
||||
|
||||
/* Threshold value for when to enter the unrolled loops. */
|
||||
# define OP_T_THRES 16
|
||||
|
||||
/* Type to use for unaligned operations. */
|
||||
typedef unsigned char byte;
|
||||
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
|
||||
# else
|
||||
# define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
|
||||
# endif
|
||||
|
||||
#endif /* In the GNU C library. */
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
|
||||
#else
|
||||
# define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
|
||||
#endif
|
||||
|
||||
/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
|
||||
|
||||
/* The strategy of this memcmp is:
|
||||
|
||||
1. Compare bytes until one of the block pointers is aligned.
|
||||
|
||||
2. Compare using memcmp_common_alignment or
|
||||
memcmp_not_common_alignment, regarding the alignment of the other
|
||||
block after the initial byte operations. The maximum number of
|
||||
full words (of type op_t) are compared in this way.
|
||||
|
||||
3. Compare the few remaining bytes. */
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
|
||||
A and B are known to be different.
|
||||
This is needed only on little-endian machines. */
|
||||
|
||||
static int memcmp_bytes __P((op_t, op_t));
|
||||
|
||||
# ifdef __GNUC__
|
||||
__inline
|
||||
# endif
|
||||
static int
|
||||
memcmp_bytes (long unsigned int a, long unsigned int b)
|
||||
{
|
||||
long int srcp1 = (long int) &a;
|
||||
long int srcp2 = (long int) &b;
|
||||
op_t a0, b0;
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
}
|
||||
while (a0 == b0);
|
||||
return a0 - b0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int memcmp_common_alignment __P((long, long, size_t));
|
||||
|
||||
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
|
||||
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
|
||||
memory operations on `op_t's. */
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
|
||||
{
|
||||
op_t a0, a1;
|
||||
op_t b0, b1;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
default: /* Avoid warning about uninitialized local variables. */
|
||||
case 2:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 2 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= OPSIZ;
|
||||
srcp2 -= OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
goto do3;
|
||||
case 1:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 += OPSIZ;
|
||||
srcp2 += OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
if (a0 != b0)
|
||||
return CMP_LT_OR_GT (a0, b0);
|
||||
|
||||
do2:
|
||||
a0 = ((op_t *) srcp1)[2];
|
||||
b0 = ((op_t *) srcp2)[2];
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
|
||||
do1:
|
||||
a1 = ((op_t *) srcp1)[3];
|
||||
b1 = ((op_t *) srcp2)[3];
|
||||
if (a0 != b0)
|
||||
return CMP_LT_OR_GT (a0, b0);
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int memcmp_not_common_alignment __P((long, long, size_t));
|
||||
|
||||
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
|
||||
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
|
||||
operations on `op_t', but SRCP1 *should be unaligned*. */
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len)
|
||||
{
|
||||
op_t a0, a1, a2, a3;
|
||||
op_t b0, b1, b2, b3;
|
||||
op_t x;
|
||||
int shl, shr;
|
||||
|
||||
/* Calculate how to shift a word read at the memory operation
|
||||
aligned srcp1 to make it aligned for comparison. */
|
||||
|
||||
shl = 8 * (srcp1 % OPSIZ);
|
||||
shr = 8 * OPSIZ - shl;
|
||||
|
||||
/* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
|
||||
it points in the middle of. */
|
||||
srcp1 &= -OPSIZ;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
default: /* Avoid warning about uninitialized local variables. */
|
||||
case 2:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
a2 = ((op_t *) srcp1)[1];
|
||||
b2 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 1 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp2 -= 1 * OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a3 = ((op_t *) srcp1)[0];
|
||||
a0 = ((op_t *) srcp1)[1];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 1 * OPSIZ;
|
||||
goto do3;
|
||||
case 1:
|
||||
a2 = ((op_t *) srcp1)[0];
|
||||
a3 = ((op_t *) srcp1)[1];
|
||||
b3 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 2 * OPSIZ;
|
||||
srcp2 += 1 * OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
if (x != b3)
|
||||
return CMP_LT_OR_GT (x, b3);
|
||||
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
x = MERGE(a3, shl, a0, shr);
|
||||
if (x != b0)
|
||||
return CMP_LT_OR_GT (x, b0);
|
||||
|
||||
do2:
|
||||
a2 = ((op_t *) srcp1)[2];
|
||||
b2 = ((op_t *) srcp2)[2];
|
||||
x = MERGE(a0, shl, a1, shr);
|
||||
if (x != b1)
|
||||
return CMP_LT_OR_GT (x, b1);
|
||||
|
||||
do1:
|
||||
a3 = ((op_t *) srcp1)[3];
|
||||
b3 = ((op_t *) srcp2)[3];
|
||||
x = MERGE(a1, shl, a2, shr);
|
||||
if (x != b2)
|
||||
return CMP_LT_OR_GT (x, b2);
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
if (x != b3)
|
||||
return CMP_LT_OR_GT (x, b3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rpl_memcmp (const void *s1, const void *s2, size_t len)
|
||||
{
|
||||
op_t a0;
|
||||
op_t b0;
|
||||
long int srcp1 = (long int) s1;
|
||||
long int srcp2 = (long int) s2;
|
||||
op_t res;
|
||||
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* There are at least some bytes to compare. No need to test
|
||||
for LEN == 0 in this alignment loop. */
|
||||
while (srcp2 % OPSIZ != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
/* SRCP2 is now aligned for memory operations on `op_t'.
|
||||
SRCP1 alignment determines if we can do a simple,
|
||||
aligned compare or need to shuffle bits. */
|
||||
|
||||
if (srcp1 % OPSIZ == 0)
|
||||
res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
else
|
||||
res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
/* Number of bytes remaining in the interval [0..OPSIZ-1]. */
|
||||
srcp1 += len & -OPSIZ;
|
||||
srcp2 += len & -OPSIZ;
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* There are just a few bytes to compare. Use byte memory operations. */
|
||||
while (len != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
# undef bcmp
|
||||
weak_alias (memcmp, bcmp)
|
||||
#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
|
||||
-616
@@ -1,616 +0,0 @@
|
||||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988-1994, 1996-1999, 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 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 "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. */
|
||||
# ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
# else
|
||||
# include "gettext.h"
|
||||
# endif
|
||||
# define _(msgid) gettext (msgid)
|
||||
|
||||
# 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);
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
/* quote.h - prototypes for quote.c
|
||||
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. */
|
||||
|
||||
|
||||
#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));
|
||||
-630
@@ -1,630 +0,0 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 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. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "quotearg.h"
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#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
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
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)
|
||||
{
|
||||
int e = errno;
|
||||
struct quoting_options *p = xmalloc (sizeof *p);
|
||||
*p = *(o ? o : &default_quoting_options);
|
||||
errno = e;
|
||||
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_MAX ? 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 '\0':
|
||||
if (backslash_escapes)
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0');
|
||||
STORE ('0');
|
||||
c = '0';
|
||||
}
|
||||
break;
|
||||
|
||||
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. */
|
||||
c = arg[i + 2];
|
||||
i += 2;
|
||||
STORE ('?');
|
||||
STORE ('\\');
|
||||
STORE ('?');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\a': 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_MAX)
|
||||
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;
|
||||
int e = errno;
|
||||
size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
p->style, p);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of argument ARG.
|
||||
ARG is of size ARGSIZE, but if that is -1, ARG is a null-terminated string.
|
||||
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, size_t argsize,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
int e = errno;
|
||||
|
||||
/* 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 = xmalloc (sizeof *slotvec);
|
||||
*slotvec = slotvec0;
|
||||
}
|
||||
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, argsize, 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, argsize, options);
|
||||
}
|
||||
|
||||
errno = e;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
/* Return quoting options for STYLE, with no extra quoting. */
|
||||
static struct quoting_options
|
||||
quoting_options_from_style (enum quoting_style style)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = style;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return o;
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, argsize, &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, SIZE_MAX, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 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. */
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
#ifndef QUOTEARG_H_
|
||||
# define QUOTEARG_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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 (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 (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 (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 (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 (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 (int n, char const *arg);
|
||||
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg (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 (int n, enum quoting_style s, char const *arg);
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the
|
||||
argument ARG of size ARGSIZE. This is like quotearg_n_style
|
||||
(N, S, ARG), except it can quote null bytes. */
|
||||
char *quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize);
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style (enum quoting_style s, char const *arg);
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char (char const *arg, char ch);
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon (char const *arg);
|
||||
|
||||
#endif /* !QUOTEARG_H_ */
|
||||
@@ -1,44 +0,0 @@
|
||||
/* Work around bug on some systems where realloc (NULL, 0) fails.
|
||||
Copyright (C) 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 Jim Meyering */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef realloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
char *malloc ();
|
||||
char *realloc ();
|
||||
|
||||
/* 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. */
|
||||
|
||||
char *
|
||||
rpl_realloc (p, n)
|
||||
char *p;
|
||||
size_t n;
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if (p == 0)
|
||||
return malloc (n);
|
||||
return realloc (p, n);
|
||||
}
|
||||
@@ -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,66 +0,0 @@
|
||||
/* strcasecmp.c -- case insensitive string comparator
|
||||
Copyright (C) 1998, 1999 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 LENGTH_LIMIT
|
||||
# define STRXCASECMP_FUNCTION strncasecmp
|
||||
# define STRXCASECMP_DECLARE_N , size_t n
|
||||
# define LENGTH_LIMIT_EXPR(Expr) Expr
|
||||
#else
|
||||
# define STRXCASECMP_FUNCTION strcasecmp
|
||||
# define STRXCASECMP_DECLARE_N /* empty */
|
||||
# define LENGTH_LIMIT_EXPR(Expr) 0
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
/* Compare {{no more than N characters of }}strings S1 and S2,
|
||||
ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less
|
||||
than, equal to or greater than S2. */
|
||||
|
||||
int
|
||||
STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N)
|
||||
{
|
||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0))
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = TOLOWER (*p1);
|
||||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
@@ -1,31 +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 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
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
strchr (const char *s, int c)
|
||||
{
|
||||
return index (s, c);
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
#define LENGTH_LIMIT
|
||||
#include "strcasecmp.c"
|
||||
@@ -1,62 +0,0 @@
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
Copyright (C) 1996, 1997, 1998, 2000-2002 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
|
||||
/* Temporarily redefine strnlen so that an inconsistent prototype
|
||||
(on at least AIX4.3.2.0 w/gcc-2.95.3) doesn't cause trouble. */
|
||||
# define strnlen system_strnlen
|
||||
# include <string.h>
|
||||
# undef strnlen
|
||||
#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,30 +0,0 @@
|
||||
/* Portable version of strrchr().
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
|
||||
@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
|
||||
|
||||
Returns a pointer to the last occurrence of the character @var{c} in
|
||||
the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
|
||||
null character, the results are undefined.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
|
||||
char *
|
||||
strrchr (s, c)
|
||||
register const char *s;
|
||||
int c;
|
||||
{
|
||||
char *rtnval = 0;
|
||||
|
||||
do {
|
||||
if (*s == c)
|
||||
rtnval = (char*) s;
|
||||
} while (*s++);
|
||||
return (rtnval);
|
||||
}
|
||||
@@ -1,58 +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 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
|
||||
|
||||
#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;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user