mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-09-24 17:27:07 +00:00
Compare commits
1392
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e4900ef40 | ||
|
|
dc546b0f6e | ||
|
|
1deb9bdcad | ||
|
|
2c09b6a7ea | ||
|
|
83adb046bf | ||
|
|
255227393f | ||
|
|
5b25cd7cd8 | ||
|
|
535c0f6328 | ||
|
|
527203e98e | ||
|
|
7b56c4bc0e | ||
|
|
78a00b7d7f | ||
|
|
963fcc1705 | ||
|
|
00c378a21f | ||
|
|
a4b746ea04 | ||
|
|
2c8ba4cd59 | ||
|
|
be7280480c | ||
|
|
5a99098d0b | ||
|
|
fb8ccdcd35 | ||
|
|
8ca1967ea2 | ||
|
|
b1efe548af | ||
|
|
120f129d67 | ||
|
|
96b93a3da4 | ||
|
|
d42f69cdf7 | ||
|
|
04877eec24 | ||
|
|
053658d584 | ||
|
|
6876ecd36e | ||
|
|
76be9271f2 | ||
|
|
983c5c2c2a | ||
|
|
5b66ea8b80 | ||
|
|
70b4c070cc | ||
|
|
cce7a5f423 | ||
|
|
2fd4e13193 | ||
|
|
7eab453e1b | ||
|
|
f6abc26e38 | ||
|
|
ea03c24f05 | ||
|
|
fcbfa6b01c | ||
|
|
9dd5b37815 | ||
|
|
88015bf06b | ||
|
|
7ea9026a59 | ||
|
|
ebec3740c2 | ||
|
|
23f2d9dc0f | ||
|
|
73521d9ff8 | ||
|
|
366041f014 | ||
|
|
80483e8e0d | ||
|
|
5320ca4d6f | ||
|
|
33167b8b05 | ||
|
|
624a35e20b | ||
|
|
ef4479de37 | ||
|
|
e9ce56889c | ||
|
|
6273355b36 | ||
|
|
050c471b8e | ||
|
|
fa8c3ebca3 | ||
|
|
75eb3bc4e7 | ||
|
|
52328c6e99 | ||
|
|
f67ad422a4 | ||
|
|
879ca4f81b | ||
|
|
9417597809 | ||
|
|
20daca0631 | ||
|
|
b317297e4d | ||
|
|
1c5fe69d46 | ||
|
|
a20713a4af | ||
|
|
d2caf5545c | ||
|
|
c5df10951a | ||
|
|
d1de53722b | ||
|
|
00ba950c7b | ||
|
|
05d18c2493 | ||
|
|
397ec0734f | ||
|
|
d8388d7ab6 | ||
|
|
148b7779f3 | ||
|
|
dbb95312e2 | ||
|
|
f47dbf6bef | ||
|
|
fc659dfd69 | ||
|
|
ec1ef903c3 | ||
|
|
1915f1331e | ||
|
|
d0f3fe233d | ||
|
|
ca2e738c81 | ||
|
|
177d84c081 | ||
|
|
4613f49b90 | ||
|
|
04e309ce35 | ||
|
|
ac72f3e9b5 | ||
|
|
ff5c8b8557 | ||
|
|
deedb0b77c | ||
|
|
2cc6b61207 | ||
|
|
0fb1efaf58 | ||
|
|
2073d76939 | ||
|
|
03b9e27342 | ||
|
|
3b1e470c6d | ||
|
|
f2a655b6cc | ||
|
|
c488293484 | ||
|
|
9c4637fa8c | ||
|
|
87ceef7346 | ||
|
|
0993971437 | ||
|
|
e00b682606 | ||
|
|
a54a1bdc6b | ||
|
|
5362cd5f78 | ||
|
|
e46cedb9be | ||
|
|
e59a68718b | ||
|
|
6c5f863aec | ||
|
|
6f84e9abca | ||
|
|
08721544d1 | ||
|
|
82129ef5d5 | ||
|
|
69cecfeb38 | ||
|
|
1dd15b6ea6 | ||
|
|
bb7c2bc623 | ||
|
|
eb0ca72d8e | ||
|
|
26b4a96981 | ||
|
|
051ade8391 | ||
|
|
e3aa2baac6 | ||
|
|
1faeb1414d | ||
|
|
106344fb01 | ||
|
|
17ee7397a8 | ||
|
|
3671fb8483 | ||
|
|
c801dbf7d9 | ||
|
|
982cc3023c | ||
|
|
7486e51b76 | ||
|
|
e39214489e | ||
|
|
784573d14a | ||
|
|
353d3eb651 | ||
|
|
223ff46e4c | ||
|
|
7b5cb0cd30 | ||
|
|
5b2dd224dc | ||
|
|
16bb742fce | ||
|
|
3d2cbc2662 | ||
|
|
21fd22d6ec | ||
|
|
a0b76449c7 | ||
|
|
2b5ff972bf | ||
|
|
8322e8f580 | ||
|
|
69b8cc095f | ||
|
|
81ebdef91d | ||
|
|
b78d8c23da | ||
|
|
5dde542557 | ||
|
|
7478c462f2 | ||
|
|
e8a0acd666 | ||
|
|
d38a11a64b | ||
|
|
651ec3d0ec | ||
|
|
6d441fc378 | ||
|
|
fbfa091d05 | ||
|
|
f041e30b91 | ||
|
|
41f83caf1c | ||
|
|
c7bd07f75a | ||
|
|
3de372bb1b | ||
|
|
c134bfbeee | ||
|
|
5bf3d7c115 | ||
|
|
add6614e2b | ||
|
|
7c612afb7e | ||
|
|
e22ad7fa22 | ||
|
|
f6a8ccf40a | ||
|
|
178365909f | ||
|
|
9939fdb139 | ||
|
|
4bebc88ee1 | ||
|
|
557962dcff | ||
|
|
5bab03fcf8 | ||
|
|
996b1c7e8c | ||
|
|
e19c4e5d1c | ||
|
|
050931e3f9 | ||
|
|
e551232efa | ||
|
|
b06af56f55 | ||
|
|
2bf21a8322 | ||
|
|
3f2d73f157 | ||
|
|
d6ea8200af | ||
|
|
0aa32d51bb | ||
|
|
2073702c37 | ||
|
|
b729552289 | ||
|
|
8f759107f1 | ||
|
|
b17a1fc541 | ||
|
|
5fcdb07b70 | ||
|
|
7f8ba6c7f3 | ||
|
|
4b68955b1d | ||
|
|
b69d743e78 | ||
|
|
4f21fffe7e | ||
|
|
c5d128ec1a | ||
|
|
b64755e391 | ||
|
|
022fb98e85 | ||
|
|
570fe42828 | ||
|
|
6c30d6413e | ||
|
|
6ba5559289 | ||
|
|
e927351156 | ||
|
|
38e71ff8c8 | ||
|
|
3b0ee3aa8b | ||
|
|
6e746484fc | ||
|
|
74724a70a5 | ||
|
|
1fec91df90 | ||
|
|
d18f45311a | ||
|
|
93dd49ab29 | ||
|
|
1f14d97ae5 | ||
|
|
0af19cd0c1 | ||
|
|
38a92d500a | ||
|
|
6b0d38ab2c | ||
|
|
88510f9c07 | ||
|
|
da90e18c6e | ||
|
|
763ed7a687 | ||
|
|
1773ceee65 | ||
|
|
feeb0edaf1 | ||
|
|
78c3da9e09 | ||
|
|
4f39538148 | ||
|
|
bb92250c78 | ||
|
|
41141c568e | ||
|
|
f6d03984ae | ||
|
|
ad8a3efc5a | ||
|
|
831d3c996d | ||
|
|
136d65300d | ||
|
|
14740648d5 | ||
|
|
08cae37b47 | ||
|
|
ceed6cdce5 | ||
|
|
3af4feb22f | ||
|
|
dda7aa54b6 | ||
|
|
16f37b35a5 | ||
|
|
300a796626 | ||
|
|
f6cf0f6e5f | ||
|
|
69e16b4c5e | ||
|
|
0368ae1269 | ||
|
|
580043087e | ||
|
|
6f5db56451 | ||
|
|
500bbfcd81 | ||
|
|
63d0fb9ce4 | ||
|
|
7a86d7eba9 | ||
|
|
4344c500b5 | ||
|
|
443594d0c4 | ||
|
|
87aabbff99 | ||
|
|
2f82502a6f | ||
|
|
fe22d5d20f | ||
|
|
ec14f0c83f | ||
|
|
35dcf428c9 | ||
|
|
a932883e41 | ||
|
|
b475e0cce5 | ||
|
|
58a84254ef | ||
|
|
7223426a2b | ||
|
|
b9a0104860 | ||
|
|
937fd8646f | ||
|
|
b973108e1e | ||
|
|
51dffcbca9 | ||
|
|
76ae81983c | ||
|
|
df38312ab0 | ||
|
|
8d8a7238ee | ||
|
|
d3c4e709ff | ||
|
|
4e8c79eb7f | ||
|
|
ee16363fd2 | ||
|
|
60a3dcf956 | ||
|
|
b0937b2259 | ||
|
|
c5e3e51055 | ||
|
|
4c6cc1db75 | ||
|
|
6d9e8019e1 | ||
|
|
ee41006f01 | ||
|
|
b25d88f6d2 | ||
|
|
5dac0025f6 | ||
|
|
f0616f0b5c | ||
|
|
6e649e659e | ||
|
|
0f39aab92a | ||
|
|
761c1926a1 | ||
|
|
0258d1661c | ||
|
|
b0f98b1016 | ||
|
|
edbc04c709 | ||
|
|
7ec1b48eb8 | ||
|
|
93ba6bf344 | ||
|
|
970785f1a0 | ||
|
|
cfff7583d2 | ||
|
|
8fcc7db138 | ||
|
|
1d39f854cf | ||
|
|
dda7a53e4d | ||
|
|
f32b346d84 | ||
|
|
4e8d992c7d | ||
|
|
9501dc6e69 | ||
|
|
18b519c0d6 | ||
|
|
daa33def28 | ||
|
|
2b42986e75 | ||
|
|
efc6bf1b94 | ||
|
|
149365be01 | ||
|
|
9a86cdb99b | ||
|
|
c240826c06 | ||
|
|
caf52fdfab | ||
|
|
9c1e26bd3b | ||
|
|
f7e096fee3 | ||
|
|
73dbb6420e | ||
|
|
87f721cc87 | ||
|
|
ff03259279 | ||
|
|
dbba6a3be7 | ||
|
|
e84e65da40 | ||
|
|
53b7799056 | ||
|
|
412f8a5975 | ||
|
|
322c501d89 | ||
|
|
8a1dd2fe05 | ||
|
|
0eae1c91c8 | ||
|
|
be14ade55e | ||
|
|
cc13ba4dc0 | ||
|
|
05291fbc74 | ||
|
|
1f5fd52e9b | ||
|
|
43a91d61eb | ||
|
|
283f1e6482 | ||
|
|
886b69d197 | ||
|
|
3df374151b | ||
|
|
7bd6c77e5e | ||
|
|
b0400cc6ef | ||
|
|
72f889cca3 | ||
|
|
b1ae9233bc | ||
|
|
7ec2d4cd39 | ||
|
|
573a6cd356 | ||
|
|
95612cfa60 | ||
|
|
3e6656f9ab | ||
|
|
ccdb39e0a6 | ||
|
|
62ddaef6a7 | ||
|
|
ea44c25efc | ||
|
|
7672019c42 | ||
|
|
5b7f88c7f2 | ||
|
|
e9683cfd3d | ||
|
|
ac060e78a3 | ||
|
|
6c239755dc | ||
|
|
3813e141f8 | ||
|
|
a027c30d42 | ||
|
|
4e956a7d9e | ||
|
|
42481a1fd1 | ||
|
|
947427ae83 | ||
|
|
6ad762a8c0 | ||
|
|
fa3f2a885a | ||
|
|
acea4f3bb6 | ||
|
|
66871a8103 | ||
|
|
2115939b03 | ||
|
|
345532d70b | ||
|
|
944ed9f4e9 | ||
|
|
09d353a08f | ||
|
|
20ef1ad524 | ||
|
|
a706a1cc03 | ||
|
|
87fbb0bffc | ||
|
|
959e5f515a | ||
|
|
1c0c3e955d | ||
|
|
93724f139a | ||
|
|
0e25cad542 | ||
|
|
58918640ad | ||
|
|
8e6ef48342 | ||
|
|
fdac0091ce | ||
|
|
4e0813a6cf | ||
|
|
6e40b4ebd4 | ||
|
|
3d9a71d28a | ||
|
|
2dfbfc122c | ||
|
|
437c2d8000 | ||
|
|
900c5db537 | ||
|
|
e183b12388 | ||
|
|
9906579faa | ||
|
|
98f2caaa5f | ||
|
|
886a425c6f | ||
|
|
51b4a04cd0 | ||
|
|
d04946c717 | ||
|
|
193eb6b7ef | ||
|
|
1a9e39f116 | ||
|
|
48e28efa9e | ||
|
|
bcb3effb3c | ||
|
|
29c017256a | ||
|
|
8aeac3ca0c | ||
|
|
793a58bb66 | ||
|
|
c4d720cdbb | ||
|
|
386642761d | ||
|
|
613a0dc5b5 | ||
|
|
baa00b7f43 | ||
|
|
45a8a65dee | ||
|
|
2a8d363aab | ||
|
|
9e32add8e6 | ||
|
|
1a43c452ea | ||
|
|
03cae905c6 | ||
|
|
b02d90a5e6 | ||
|
|
206fe6a5ec | ||
|
|
d8d3f94a99 | ||
|
|
565a33db8f | ||
|
|
2bfc2e2a7d | ||
|
|
5389a5bff4 | ||
|
|
aad8382e8d | ||
|
|
1d9f7cd4f8 | ||
|
|
c0acc0f522 | ||
|
|
b9e0056255 | ||
|
|
397477b4e9 | ||
|
|
9e4c5cb833 | ||
|
|
01cfa69791 | ||
|
|
3fbf949b82 | ||
|
|
762b212bdf | ||
|
|
56100c60da | ||
|
|
30ba05f239 | ||
|
|
e63ee1f16c | ||
|
|
760d7aa8fa | ||
|
|
11a712626c | ||
|
|
782a05f9de | ||
|
|
09903f303a | ||
|
|
413fcf3a20 | ||
|
|
5c16c6b13a | ||
|
|
1f1b791bf0 | ||
|
|
bf1ebda27b | ||
|
|
2946869a28 | ||
|
|
c469accea7 | ||
|
|
b526ee6116 | ||
|
|
f1886bb280 | ||
|
|
48461d4b28 | ||
|
|
c55762568f | ||
|
|
f6d0c2394c | ||
|
|
f956c304c5 | ||
|
|
27b0ffea3e | ||
|
|
223a78837b | ||
|
|
41cce2f604 | ||
|
|
e0c74f0d34 | ||
|
|
e95aed631d | ||
|
|
ffa4c58acb | ||
|
|
c827f760f6 | ||
|
|
6db10d14be | ||
|
|
8b76775adb | ||
|
|
f0e48240c9 | ||
|
|
78bcec17c8 | ||
|
|
ec88357a8c | ||
|
|
5ca3209b44 | ||
|
|
0df27e8b2d | ||
|
|
901ec1537a | ||
|
|
0ae6073a18 | ||
|
|
8307162d58 | ||
|
|
738c69de37 | ||
|
|
b4afb6bbe5 | ||
|
|
637c4b283c | ||
|
|
78b8881659 | ||
|
|
a3714bcedf | ||
|
|
5dd5fd4a56 | ||
|
|
fece5986bf | ||
|
|
8d60a570d5 | ||
|
|
a7e92301ef | ||
|
|
a4b6efd473 | ||
|
|
92a060fd6a | ||
|
|
d33cb3ae09 | ||
|
|
b8452344de | ||
|
|
930393cf02 | ||
|
|
49f801e6fe | ||
|
|
2118414023 | ||
|
|
87004b05f7 | ||
|
|
e7cb57c0b8 | ||
|
|
0245f82d31 | ||
|
|
39912f5263 | ||
|
|
20c1e2ad98 | ||
|
|
21964f4394 | ||
|
|
66d30cd4eb | ||
|
|
95f2c9fe7d | ||
|
|
975553805c | ||
|
|
2cdb2a7b05 | ||
|
|
573312acb6 | ||
|
|
f7aed66054 | ||
|
|
82f9f11f39 | ||
|
|
6d55632cb7 | ||
|
|
2593afab81 | ||
|
|
5b2d69cc5b | ||
|
|
bb33f19a4b | ||
|
|
d9d363b172 | ||
|
|
9e2c5ef112 | ||
|
|
55b929cab2 | ||
|
|
c19988b766 | ||
|
|
ae7453f2ba | ||
|
|
0e57572183 | ||
|
|
3a781eb26b | ||
|
|
3eb4916379 | ||
|
|
724ce7f524 | ||
|
|
ac5dd84c25 | ||
|
|
d968424300 | ||
|
|
473d0a7567 | ||
|
|
93e2236a6d | ||
|
|
f7737e2e16 | ||
|
|
e76d2469e5 | ||
|
|
24c7b92b25 | ||
|
|
dddb8b6121 | ||
|
|
71d1d25c7a | ||
|
|
da2292e5c7 | ||
|
|
b37e55423b | ||
|
|
5bd1c41900 | ||
|
|
829f74d293 | ||
|
|
75f10004fe | ||
|
|
24f4e18b77 | ||
|
|
a182371d69 | ||
|
|
bba392ec8a | ||
|
|
d65ec44e3b | ||
|
|
04af9e5267 | ||
|
|
447e90bcef | ||
|
|
59fc3dcdf4 | ||
|
|
a911db9cba | ||
|
|
1a9bf9b959 | ||
|
|
ae26e1f02a | ||
|
|
d43baf71a7 | ||
|
|
7ebc83e34d | ||
|
|
b0a7a533c9 | ||
|
|
d90c934c05 | ||
|
|
05846dae07 | ||
|
|
447fbb178d | ||
|
|
b56471a689 | ||
|
|
1318e37d58 | ||
|
|
22a00a0cd2 | ||
|
|
768eb43fe8 | ||
|
|
7c78fa1885 | ||
|
|
5038f418c1 | ||
|
|
e5cfd9d8af | ||
|
|
cc0f0794b8 | ||
|
|
6b8c325436 | ||
|
|
6fed0802ee | ||
|
|
32f0598d06 | ||
|
|
7ea9a33f3b | ||
|
|
ea99527d23 | ||
|
|
f377f69fec | ||
|
|
2a1fe6ed6f | ||
|
|
f50adbbdb0 | ||
|
|
3b7d4eb2cd | ||
|
|
bcbad5b9a0 | ||
|
|
0ff67d71d7 | ||
|
|
efcb44dd47 | ||
|
|
1fe611e544 | ||
|
|
a6352deb14 | ||
|
|
bd0ba42d72 | ||
|
|
46b8b6ce90 | ||
|
|
fdabfd76d6 | ||
|
|
ea9ed226e0 | ||
|
|
98194095fe | ||
|
|
3f4c0f8017 | ||
|
|
14904b8965 | ||
|
|
17acead581 | ||
|
|
095b9f05c3 | ||
|
|
68449b3ad3 | ||
|
|
ff6dca1839 | ||
|
|
df5aed8c11 | ||
|
|
eb71459201 | ||
|
|
b7195100fd | ||
|
|
f28a0f2dd1 | ||
|
|
303e6da265 | ||
|
|
ef5da92061 | ||
|
|
3e0a8627e1 | ||
|
|
fd5c1e824e | ||
|
|
f5e211a120 | ||
|
|
55e728eb31 | ||
|
|
47c8386f83 | ||
|
|
d5c559cde4 | ||
|
|
d9d83ef277 | ||
|
|
d4d399fcce | ||
|
|
6fbe49845f | ||
|
|
7933f2b5dd | ||
|
|
0f9cd74fdb | ||
|
|
09147be095 | ||
|
|
7a542f5d81 | ||
|
|
420f93c83b | ||
|
|
a337a5eb7e | ||
|
|
595878d7f5 | ||
|
|
242a6e484e | ||
|
|
01eb033cf5 | ||
|
|
1c303b00fe | ||
|
|
f704e33362 | ||
|
|
5beedd9b58 | ||
|
|
9abb46d527 | ||
|
|
cd931d9b53 | ||
|
|
a4bf0390a0 | ||
|
|
72d2299ca0 | ||
|
|
ff68026d4f | ||
|
|
bf5c381136 | ||
|
|
5c319390d7 | ||
|
|
effda851f6 | ||
|
|
52f8da14ea | ||
|
|
eb6172cd1e | ||
|
|
32e218da16 | ||
|
|
4fc71aa390 | ||
|
|
c9de3b4080 | ||
|
|
2d382ea853 | ||
|
|
808a5918e6 | ||
|
|
d32fe6f64f | ||
|
|
f6ebdb3174 | ||
|
|
8207d52123 | ||
|
|
62a34c3eb6 | ||
|
|
6aa452a643 | ||
|
|
719010ad2b | ||
|
|
927f781708 | ||
|
|
e88dbdbf44 | ||
|
|
b778eff5f9 | ||
|
|
805e703284 | ||
|
|
464197c3a7 | ||
|
|
35f6ddeafb | ||
|
|
a75649b395 | ||
|
|
c0cac722f7 | ||
|
|
9738f41e3f | ||
|
|
a5c75d7fc6 | ||
|
|
8280e1797d | ||
|
|
ae64af3556 | ||
|
|
d1a1114f7f | ||
|
|
b906441c95 | ||
|
|
bd7018115a | ||
|
|
e0a13e7b30 | ||
|
|
43674285cc | ||
|
|
c97011bfc1 | ||
|
|
d862b1be60 | ||
|
|
f414d77d38 | ||
|
|
f25e23a632 | ||
|
|
54d25cfb74 | ||
|
|
3d38c03a86 | ||
|
|
b63473552d | ||
|
|
1b17ce8ebc | ||
|
|
09ba4ab244 | ||
|
|
262aa8dd59 | ||
|
|
0252b55c07 | ||
|
|
ad66f664ef | ||
|
|
21846f695d | ||
|
|
c0ad8bf3c2 | ||
|
|
eb34f4177c | ||
|
|
3a93251e73 | ||
|
|
427c0dda0c | ||
|
|
3f8237696f | ||
|
|
9503bbd27d | ||
|
|
3c146b5e6f | ||
|
|
948be909e9 | ||
|
|
8442d6ba22 | ||
|
|
645e30d193 | ||
|
|
6a254321ad | ||
|
|
04b6e11ebb | ||
|
|
c0d9cc4211 | ||
|
|
accea6db68 | ||
|
|
93a1e33a1d | ||
|
|
49e794c553 | ||
|
|
88ba3d332f | ||
|
|
002b9b7d1f | ||
|
|
6563aa9221 | ||
|
|
48c4080d0d | ||
|
|
63400d5d02 | ||
|
|
04c5cba268 | ||
|
|
d7163c0a58 | ||
|
|
db2cc12fd0 | ||
|
|
7e78575709 | ||
|
|
f9a85a156a | ||
|
|
c81bad8950 | ||
|
|
158e69f984 | ||
|
|
211e7860a2 | ||
|
|
e3fbd37fc0 | ||
|
|
a11166dddc | ||
|
|
9ff012ca23 | ||
|
|
3d70dbe593 | ||
|
|
91e1aa523d | ||
|
|
00a6930855 | ||
|
|
6fc82eafd5 | ||
|
|
0755be2ff9 | ||
|
|
b4ebc2134b | ||
|
|
30ad432609 | ||
|
|
1a92955799 | ||
|
|
a319e6a7a3 | ||
|
|
eb9568566a | ||
|
|
d5629ce34a | ||
|
|
c2143a71d6 | ||
|
|
c340180d81 | ||
|
|
c837b82803 | ||
|
|
e601ff27f4 | ||
|
|
c131cbff03 | ||
|
|
50f095c92f | ||
|
|
16cb098b72 | ||
|
|
9742c552f2 | ||
|
|
8434f2222e | ||
|
|
d6eba4239f | ||
|
|
81fe8b23e9 | ||
|
|
02e090934a | ||
|
|
87b7d7bad5 | ||
|
|
cf126971ad | ||
|
|
c896cfc95e | ||
|
|
a447fcd20c | ||
|
|
a861a3390f | ||
|
|
2cf6e61086 | ||
|
|
c8f002c7d3 | ||
|
|
cd08e51eda | ||
|
|
bb0027a9ac | ||
|
|
3325ddc49c | ||
|
|
c6f1a33c06 | ||
|
|
1509d42fcb | ||
|
|
273a74fa89 | ||
|
|
2ed0e35f86 | ||
|
|
217598dadc | ||
|
|
52489d4445 | ||
|
|
e8832397ea | ||
|
|
caf23d249c | ||
|
|
640748eecf | ||
|
|
88bce5a2ef | ||
|
|
1bfb97dba5 | ||
|
|
fc5734fe23 | ||
|
|
3650b4b8dd | ||
|
|
4b3d3a8e46 | ||
|
|
4a2a22f4c0 | ||
|
|
b8df32232a | ||
|
|
a762e609e7 | ||
|
|
12b0043a6d | ||
|
|
5dde258a9e | ||
|
|
a945ec3929 | ||
|
|
7601152fab | ||
|
|
fae437e835 | ||
|
|
1a715ef2fc | ||
|
|
a5d5099417 | ||
|
|
b275314e2d | ||
|
|
c5f5043618 | ||
|
|
2ab9a04ffc | ||
|
|
865b9df14c | ||
|
|
c76e14da4b | ||
|
|
7db2ed2d82 | ||
|
|
3a9e26be57 | ||
|
|
e68e0410ab | ||
|
|
e1a4f3a428 | ||
|
|
536545f3a4 | ||
|
|
8b752b00fd | ||
|
|
613f5e1a89 | ||
|
|
524346a3a3 | ||
|
|
26e0cadc37 | ||
|
|
e68d4575b3 | ||
|
|
bb3f671805 | ||
|
|
88e7e94146 | ||
|
|
1154ccedaf | ||
|
|
97650f4efc | ||
|
|
d257636504 | ||
|
|
ccaf65bc63 | ||
|
|
87675353bf | ||
|
|
ce4ccb4b11 | ||
|
|
bc933ef16d | ||
|
|
53d4308dbb | ||
|
|
574fb2d568 | ||
|
|
05811fd755 | ||
|
|
0e4d575330 | ||
|
|
24c7d80020 | ||
|
|
9222837b27 | ||
|
|
260008e546 | ||
|
|
8a731ca829 | ||
|
|
32e1e0a486 | ||
|
|
e5fb671032 | ||
|
|
c7ca99d4b0 | ||
|
|
df0e7316a9 | ||
|
|
39f4191608 | ||
|
|
d57650a5ff | ||
|
|
5a08f1ce21 | ||
|
|
720623af84 | ||
|
|
fb8135fa99 | ||
|
|
4fa887b790 | ||
|
|
4144248075 | ||
|
|
e0e5bf84b0 | ||
|
|
b5480d74b8 | ||
|
|
676385e29c | ||
|
|
01241d47b4 | ||
|
|
ba29c4ec25 | ||
|
|
e2aaf4c4f9 | ||
|
|
7cca31a2f2 | ||
|
|
60491a948b | ||
|
|
2a10b47aaf | ||
|
|
12bebc0445 | ||
|
|
febef6caec | ||
|
|
9be0c25bf0 | ||
|
|
976e627098 | ||
|
|
3424c3868f | ||
|
|
1ae7286376 | ||
|
|
87542d29a5 | ||
|
|
1a31ed21b1 | ||
|
|
e776192e4f | ||
|
|
5c1180b3c4 | ||
|
|
e317006080 | ||
|
|
253862fd4c | ||
|
|
366eea36d3 | ||
|
|
1ce5149ac8 | ||
|
|
4f25ebb043 | ||
|
|
93b68a0e09 | ||
|
|
7431029172 | ||
|
|
58612f1de0 | ||
|
|
02097d3eab | ||
|
|
f25bfb75aa | ||
|
|
c732d2c6dc | ||
|
|
8c165d891d | ||
|
|
ca98bf5758 | ||
|
|
0bfb02fff7 | ||
|
|
24c0aad7e7 | ||
|
|
5719c1092f | ||
|
|
271efced67 | ||
|
|
abd741b1f6 | ||
|
|
9280d3ef89 | ||
|
|
dafdc66ff0 | ||
|
|
56c4720342 | ||
|
|
1e0bab9276 | ||
|
|
74886d31e7 | ||
|
|
04e6065479 | ||
|
|
10e5b8bd0a | ||
|
|
9801d40c50 | ||
|
|
c026349221 | ||
|
|
9757c359ef | ||
|
|
6b98e4b563 | ||
|
|
ee000ba4fc | ||
|
|
8efe435c05 | ||
|
|
4f6bb8b24b | ||
|
|
1921f1d7a4 | ||
|
|
4515534cd2 | ||
|
|
f958596b44 | ||
|
|
2c5690250c | ||
|
|
592e8d4d01 | ||
|
|
0c15323de7 | ||
|
|
e96c9728da | ||
|
|
75d1fe1611 | ||
|
|
6c35d22c39 | ||
|
|
3420246357 | ||
|
|
1d6412adeb | ||
|
|
4cdb01db9b | ||
|
|
44995b2e39 | ||
|
|
e9955c8373 | ||
|
|
39fd0b540d | ||
|
|
d7215705ee | ||
|
|
5346290247 | ||
|
|
2e04746125 | ||
|
|
9af3fbce7c | ||
|
|
1485e106a4 | ||
|
|
da4160c30a | ||
|
|
f6d0f937fd | ||
|
|
69078d4b3b | ||
|
|
0624954c7e | ||
|
|
5e424082ce | ||
|
|
44536b35c4 | ||
|
|
8b9f2372c7 | ||
|
|
3ae2b51f08 | ||
|
|
2f1afb737f | ||
|
|
e9bca3aded | ||
|
|
86eff18354 | ||
|
|
9411f454b0 | ||
|
|
717be1971f | ||
|
|
efea623135 | ||
|
|
670ddffd5b | ||
|
|
769b430fce | ||
|
|
7067cb3620 | ||
|
|
4a713ec2e3 | ||
|
|
b0e5f19eab | ||
|
|
54049e5db0 | ||
|
|
b408954b40 | ||
|
|
a49aecd528 | ||
|
|
5504898e82 | ||
|
|
4fd2214bc6 | ||
|
|
ec3bc3961d | ||
|
|
78df825093 | ||
|
|
68cd8af38b | ||
|
|
660bc8dd09 | ||
|
|
c0c9ea051b | ||
|
|
6390a83f8b | ||
|
|
db7c8e9a72 | ||
|
|
158c687b65 | ||
|
|
fcc618005a | ||
|
|
308a2f7637 | ||
|
|
a46c847244 | ||
|
|
5683e9b26a | ||
|
|
0c2d3f4cba | ||
|
|
e41fdc9310 | ||
|
|
1565b72064 | ||
|
|
5181e40827 | ||
|
|
cfaee611d8 | ||
|
|
458be8e0ed | ||
|
|
a900a6248c | ||
|
|
9bbd181ae0 | ||
|
|
d4e7d3a191 | ||
|
|
39ceb25bdb | ||
|
|
5372019fab | ||
|
|
5df5f6d538 | ||
|
|
77714df234 | ||
|
|
b87f8b2159 | ||
|
|
8bb936e4f7 | ||
|
|
fba798c78e | ||
|
|
9306c70c63 | ||
|
|
3c9160d912 | ||
|
|
53c71a12c8 | ||
|
|
2de3aceee7 | ||
|
|
289dd0cf98 | ||
|
|
db85e524b4 | ||
|
|
0164db681e | ||
|
|
83ccf991a6 | ||
|
|
1f41899519 | ||
|
|
77f6f42074 | ||
|
|
45119f0446 | ||
|
|
b2d52318fa | ||
|
|
3a8b410924 | ||
|
|
2243f537c6 | ||
|
|
84614e1373 | ||
|
|
fdbcd8e289 | ||
|
|
64bd62a1be | ||
|
|
900c877b41 | ||
|
|
82b6cb3fb2 | ||
|
|
6cbfbcc58c | ||
|
|
b85481146a | ||
|
|
b219268ad8 | ||
|
|
a05fafb944 | ||
|
|
c20cd1facb | ||
|
|
8a9566d401 | ||
|
|
b756bb754c | ||
|
|
0c76a0c911 | ||
|
|
71cd15d49b | ||
|
|
8c6d399ada | ||
|
|
2b7ed18a60 | ||
|
|
34a89c5066 | ||
|
|
969e2ed98b | ||
|
|
0dd1580afc | ||
|
|
b98ec53ee4 | ||
|
|
b4cbf822eb | ||
|
|
c47dc59adc | ||
|
|
83c1796f41 | ||
|
|
cf44a9aea7 | ||
|
|
5c0a0514da | ||
|
|
1207eeacc2 | ||
|
|
8e521837dc | ||
|
|
08e49d20f0 | ||
|
|
e91ff6ce3d | ||
|
|
7655146399 | ||
|
|
216eb8c9f2 | ||
|
|
78ab8f674f | ||
|
|
133c20e252 | ||
|
|
9515e8a7f8 | ||
|
|
23c5a17453 | ||
|
|
5fbb0954b8 | ||
|
|
4f940944da | ||
|
|
69991a5827 | ||
|
|
20c37f213a | ||
|
|
3ded9a63e3 | ||
|
|
e0c471a9e6 | ||
|
|
6b44f458f2 | ||
|
|
01c56de45c | ||
|
|
8b3ba7ff05 | ||
|
|
d1a6f01efb | ||
|
|
c2a6d50e58 | ||
|
|
f294a2c217 | ||
|
|
4358321afa | ||
|
|
45a44d49bf | ||
|
|
fecc10cd95 | ||
|
|
01e5c81773 | ||
|
|
eaff5ee3c5 | ||
|
|
aef1ffd56f | ||
|
|
51dec47b37 | ||
|
|
007a50a493 | ||
|
|
491bdd7ae5 | ||
|
|
73b0698996 | ||
|
|
06446ccf94 | ||
|
|
62a3e4f0c5 | ||
|
|
355e7c1cd1 | ||
|
|
bb88b0fc9e | ||
|
|
9a636f47ce | ||
|
|
0e95c1ddc1 | ||
|
|
df33b92836 | ||
|
|
680e8701b5 | ||
|
|
817e9f41d1 | ||
|
|
5123689ba0 | ||
|
|
f3849179e5 | ||
|
|
bd02036a4e | ||
|
|
db8837cbe1 | ||
|
|
72a23c9797 | ||
|
|
280a38c306 | ||
|
|
03b31c0ce8 | ||
|
|
8b3df748a3 | ||
|
|
e601aa1d35 | ||
|
|
b0299a2ebb | ||
|
|
d7e1f00c13 | ||
|
|
cc9305dd68 | ||
|
|
b0940840ac | ||
|
|
643a599471 | ||
|
|
b4c4ccc2b3 | ||
|
|
bba97eb2c1 | ||
|
|
c3b407f430 | ||
|
|
c307773eec | ||
|
|
a31932aa0b | ||
|
|
aa96fda183 | ||
|
|
588db0a892 | ||
|
|
4416fcdb02 | ||
|
|
11652ab3dc | ||
|
|
26b23c1a49 | ||
|
|
18bcecb07d | ||
|
|
fa770c8662 | ||
|
|
d9b739c32f | ||
|
|
9901390012 | ||
|
|
e966383bf4 | ||
|
|
cd6a695eb9 | ||
|
|
0f8d586a9f | ||
|
|
8d6c48b983 | ||
|
|
b4e4c0d14a | ||
|
|
e53c632297 | ||
|
|
21db0b2a65 | ||
|
|
5b041382df | ||
|
|
9ffbeca717 | ||
|
|
cf3b4b64d0 | ||
|
|
fd6748e22c | ||
|
|
9651150243 | ||
|
|
642cb8f829 | ||
|
|
3c31a486e7 | ||
|
|
0d8bed5636 | ||
|
|
01228b70de | ||
|
|
9208d17fa9 | ||
|
|
af27eacb6a | ||
|
|
e69bfebb45 | ||
|
|
bcae0fce72 | ||
|
|
9101a31079 | ||
|
|
c3937ec780 | ||
|
|
fff9bf0b8d | ||
|
|
64dba31e7f | ||
|
|
c1a29a5b2d | ||
|
|
374f5a14de | ||
|
|
bfcf1f3af0 | ||
|
|
65ccf9fc1d | ||
|
|
d0039cbcf8 | ||
|
|
345cea780a | ||
|
|
564801f795 | ||
|
|
b23e820381 | ||
|
|
e5352bc7bf | ||
|
|
914feea9d0 | ||
|
|
f0250de62e | ||
|
|
ef01750240 | ||
|
|
7651439487 | ||
|
|
550245801e | ||
|
|
f9abaa2c4c | ||
|
|
0e721e7569 | ||
|
|
0fb1ffb1bf | ||
|
|
b86796bf87 | ||
|
|
602bbf31c1 | ||
|
|
d8a0245ce7 | ||
|
|
34ba97434f | ||
|
|
ed86e78c90 | ||
|
|
dfdb1797c3 | ||
|
|
7086e7071e | ||
|
|
98254360e3 | ||
|
|
a75c057f10 | ||
|
|
dc2546ac9f | ||
|
|
ad950f8307 | ||
|
|
2794679661 | ||
|
|
06b00abcdd | ||
|
|
70e7d534a9 | ||
|
|
0b3551fbee | ||
|
|
abe017f60d | ||
|
|
381fb12e1e | ||
|
|
10b6b2be55 | ||
|
|
6f38107f80 | ||
|
|
0179dd6542 | ||
|
|
45119af166 | ||
|
|
e4e1a4dcb4 | ||
|
|
80cce3da95 | ||
|
|
842e86794f | ||
|
|
3309b786a3 | ||
|
|
4bda3f10ca | ||
|
|
bd16a5dcf5 | ||
|
|
4162fa07ae | ||
|
|
b418ecd84f | ||
|
|
8d69a1a3ae | ||
|
|
616429b508 | ||
|
|
9b2d067768 | ||
|
|
69e2658bf6 | ||
|
|
4aacc3a71d | ||
|
|
762a801e00 | ||
|
|
4bb2bc3f61 | ||
|
|
9f007dfecc | ||
|
|
6b45a3ca82 | ||
|
|
50997c6eeb | ||
|
|
0d76958cf7 | ||
|
|
11ee57d90c | ||
|
|
ea6cfe9ebd | ||
|
|
3f3eed2770 | ||
|
|
be2a1a68ef | ||
|
|
8e86444744 | ||
|
|
beda758b1f | ||
|
|
5ece6d436f | ||
|
|
5bb18f9a19 | ||
|
|
894dd62eb2 | ||
|
|
2992e1e967 | ||
|
|
82841af7d0 | ||
|
|
318b76e913 | ||
|
|
30d2f3d50f | ||
|
|
30f8c3953f | ||
|
|
29ae55f112 | ||
|
|
2b548aa648 | ||
|
|
bb0146c2a9 | ||
|
|
4518a4baae | ||
|
|
bec30531f7 | ||
|
|
fc6edc45c0 | ||
|
|
5e5d541531 | ||
|
|
52d1aeee3d | ||
|
|
44ea3fbdf5 | ||
|
|
338963d177 | ||
|
|
e1dd105c0a | ||
|
|
a10778dc32 | ||
|
|
d9e9746c06 | ||
|
|
c57b2479ff | ||
|
|
b85810aec0 | ||
|
|
cae601224e | ||
|
|
ae40480115 | ||
|
|
22312b71e0 | ||
|
|
a67cef01b1 | ||
|
|
e9f87b5b7d | ||
|
|
2b25d624f6 | ||
|
|
3460813bdb | ||
|
|
73784c645d | ||
|
|
25d810906c | ||
|
|
a9b8959efa | ||
|
|
e2742e46ba | ||
|
|
1109455ce9 | ||
|
|
7ea5e9779b | ||
|
|
fab5b110fb | ||
|
|
aed7fd9b97 | ||
|
|
24fad99e2b | ||
|
|
a4b36db458 | ||
|
|
1239777d4f | ||
|
|
9b3add5beb | ||
|
|
3cd5bcdd19 | ||
|
|
b5b61c616b | ||
|
|
8c9a50bee1 | ||
|
|
d99361e657 | ||
|
|
b9cecb91a0 | ||
|
|
aea13e9790 | ||
|
|
931394cbc1 | ||
|
|
704a47c475 | ||
|
|
091e20bbee | ||
|
|
cce7171088 | ||
|
|
82c035a823 | ||
|
|
8419d367e1 | ||
|
|
375d580671 | ||
|
|
f51cb8ff8c | ||
|
|
29e8831621 | ||
|
|
b9f71f19cc | ||
|
|
1a2b5d37e1 | ||
|
|
1cca533e2e | ||
|
|
c03ae96659 | ||
|
|
5a670b1ed9 | ||
|
|
ad949da96b | ||
|
|
0e78e603f6 | ||
|
|
213e640e1e | ||
|
|
e7b8bef1b1 | ||
|
|
b68e774421 | ||
|
|
78d5bae94e | ||
|
|
ff44279401 | ||
|
|
610ab194c8 | ||
|
|
29d29c8fff | ||
|
|
7c6b64d023 | ||
|
|
3d4daee374 | ||
|
|
9e7f6bbd59 | ||
|
|
255ef6389e | ||
|
|
0d8a73638f | ||
|
|
5499894828 | ||
|
|
3db472b9eb | ||
|
|
b365aa0589 | ||
|
|
30171f79ab | ||
|
|
75142d452b | ||
|
|
b7c49edf13 | ||
|
|
ec2da99ffe | ||
|
|
8adfa272f7 | ||
|
|
80dac38c5e | ||
|
|
2cec70b9f1 | ||
|
|
13ca549a75 | ||
|
|
5092aba5a7 | ||
|
|
11e2becaac | ||
|
|
dac3c91005 | ||
|
|
d0b0fefa03 | ||
|
|
adc8c84856 | ||
|
|
14d293acb2 | ||
|
|
f499b06243 | ||
|
|
d945f5cd8e | ||
|
|
d200e455d0 | ||
|
|
f9507c28ae | ||
|
|
065fbd27af | ||
|
|
1b177bd731 | ||
|
|
7742ddebf1 | ||
|
|
1fa140687e | ||
|
|
b9752825a0 | ||
|
|
776209d6c7 | ||
|
|
dee049eb91 | ||
|
|
275fc3ad0f | ||
|
|
897668ee8d | ||
|
|
ab3399e0c6 | ||
|
|
4947ebdb4c | ||
|
|
c527b2d483 | ||
|
|
23a1adea4a | ||
|
|
3877f72ba2 | ||
|
|
331dbc1bb7 | ||
|
|
be750e4c49 | ||
|
|
709ae8c6ee | ||
|
|
f87685c324 | ||
|
|
837491d810 | ||
|
|
796d61fbdd | ||
|
|
64d15509b6 | ||
|
|
367c7a47d4 | ||
|
|
fbc8ecb7ef | ||
|
|
f0440388e9 | ||
|
|
a79986b830 | ||
|
|
bcb05e75f5 | ||
|
|
4ec8e00f60 | ||
|
|
5ee2aaf2fa | ||
|
|
a64d6fe0c3 | ||
|
|
1a4648ff0d | ||
|
|
8165afc445 | ||
|
|
9c2c67e6fe | ||
|
|
93ede233f5 | ||
|
|
2666f92821 | ||
|
|
428046f8d4 | ||
|
|
ea52d7066d | ||
|
|
3f96f4dc41 | ||
|
|
51576fb3c6 | ||
|
|
50d780b566 | ||
|
|
2648a72df7 | ||
|
|
92790e5bf0 | ||
|
|
927c155774 | ||
|
|
b7575ffe6f | ||
|
|
02a81e05f9 | ||
|
|
ed8e1f68e9 | ||
|
|
cb581495e6 | ||
|
|
2e729273d6 | ||
|
|
107f7dfbd0 | ||
|
|
9b53a24f31 | ||
|
|
dbfb6dcd33 | ||
|
|
c79cea6dff | ||
|
|
c3a8cbaaad | ||
|
|
c3995d9998 | ||
|
|
c25fb64881 | ||
|
|
710ddc4f18 | ||
|
|
e83d80b8ed | ||
|
|
fbbf9b3bb9 | ||
|
|
971d51580b | ||
|
|
f64b50a08c | ||
|
|
5edafffd36 | ||
|
|
0279f8e90c | ||
|
|
190c4f5f0a | ||
|
|
2a73b93df4 | ||
|
|
74392f6a54 | ||
|
|
37c82725c8 | ||
|
|
6a164e0c96 | ||
|
|
7215de245c | ||
|
|
80e25d4d46 | ||
|
|
0ab3728b12 | ||
|
|
78af9bbcd3 | ||
|
|
bdef2a413a | ||
|
|
3735969c7d | ||
|
|
49701457c2 | ||
|
|
0edad74997 | ||
|
|
5449dd0f25 | ||
|
|
a870c5670e | ||
|
|
75addd5e5f | ||
|
|
80df876864 | ||
|
|
f693ad146e | ||
|
|
74ffbcb6bf | ||
|
|
07708e1946 | ||
|
|
448b17aa3c | ||
|
|
92b16366dd | ||
|
|
076ab0334d | ||
|
|
3843c413d0 | ||
|
|
4316896018 | ||
|
|
b2872512f1 | ||
|
|
23cbcc6c19 | ||
|
|
03ec521cc5 | ||
|
|
3a7456dd96 | ||
|
|
1cbcf2e795 | ||
|
|
841822701a | ||
|
|
3f6f053ce5 | ||
|
|
7a5350baa0 | ||
|
|
5e893e1c88 | ||
|
|
35687a9d8c | ||
|
|
d954473dee | ||
|
|
9839bbe557 | ||
|
|
9f136c0720 | ||
|
|
b608206eca | ||
|
|
52afa962d1 | ||
|
|
e74dc3213f | ||
|
|
768fca8336 | ||
|
|
a17e599f81 | ||
|
|
a04bc34180 | ||
|
|
c8ea038e69 | ||
|
|
aa2aab3c16 | ||
|
|
b178c8ccc4 | ||
|
|
f67d13aa6c | ||
|
|
c2713865e3 | ||
|
|
9887c18aca | ||
|
|
4d4f699ca4 | ||
|
|
80a6975034 | ||
|
|
fe96109760 | ||
|
|
e3e4e81446 | ||
|
|
630e182b7b | ||
|
|
81b51460c9 | ||
|
|
3067fbef53 | ||
|
|
7d27c823de | ||
|
|
2729e106a7 | ||
|
|
c2bea5f96f | ||
|
|
f11966ffc5 | ||
|
|
2c8a9dfa1d | ||
|
|
f4e421e6e4 | ||
|
|
7093d0f541 | ||
|
|
fd51e5ffa2 | ||
|
|
7d13ff5f2f | ||
|
|
892a39950d | ||
|
|
68f1e3edc3 | ||
|
|
d2d1b42b07 | ||
|
|
760b53a84b | ||
|
|
002389585a | ||
|
|
396452de26 | ||
|
|
600f9b0ccc | ||
|
|
04a76783ab | ||
|
|
147e184ccc | ||
|
|
84b113cd22 | ||
|
|
426cf563bd | ||
|
|
ec93a21372 | ||
|
|
c7925b99cb | ||
|
|
5b5d192929 | ||
|
|
8850be4b1c | ||
|
|
9113b58f6f | ||
|
|
4a38e61393 | ||
|
|
4b35e1c1dd | ||
|
|
d2b04478d4 | ||
|
|
2c4c30aa95 | ||
|
|
576890b7ee | ||
|
|
cb487d7d0d | ||
|
|
6013d43f59 | ||
|
|
cb4956ee99 | ||
|
|
648185ab4a | ||
|
|
b3324f97a8 | ||
|
|
68254a0303 | ||
|
|
d2079671fb | ||
|
|
04d843a2a8 | ||
|
|
eeeb962b2f | ||
|
|
e0327bc8b4 | ||
|
|
000f1a3cb2 | ||
|
|
26cfe0be87 | ||
|
|
a12f5cabb2 | ||
|
|
f6bd542788 | ||
|
|
a220f55509 | ||
|
|
2ca209c11d | ||
|
|
0e41b407b9 | ||
|
|
e0c40012bd | ||
|
|
5e147124b5 | ||
|
|
a034c8b849 | ||
|
|
b83f0407c6 | ||
|
|
c64a20f3dc | ||
|
|
5b0d29bb52 | ||
|
|
722c4bfec2 | ||
|
|
6255b43511 | ||
|
|
b29b2ed560 | ||
|
|
b497173564 | ||
|
|
a81b1d4ad4 | ||
|
|
c1ecb3c1f5 | ||
|
|
cc72668cfb | ||
|
|
fbe01355c8 | ||
|
|
81e895c01e | ||
|
|
d38d6e7c76 | ||
|
|
6bb1878b51 | ||
|
|
d9ec2d0749 | ||
|
|
720e5c1bc3 | ||
|
|
fb9087861f | ||
|
|
125ecb5684 | ||
|
|
d8cf039f97 | ||
|
|
7bec0760a8 | ||
|
|
c87d4863f6 | ||
|
|
9bfe901c33 | ||
|
|
97db7bd4a1 | ||
|
|
2c5f66eda7 | ||
|
|
300f275f23 | ||
|
|
f59c437a25 | ||
|
|
6986fd9e3b | ||
|
|
4bc30f78dc | ||
|
|
08a946e008 | ||
|
|
f047348491 | ||
|
|
e41dc70020 | ||
|
|
652a871c29 | ||
|
|
b2ed6e5826 | ||
|
|
edad70670f | ||
|
|
3feec03433 | ||
|
|
ddcd5fdff6 | ||
|
|
bb527fc271 | ||
|
|
a845a69707 | ||
|
|
f004bf6ac4 | ||
|
|
de326cc0de | ||
|
|
90b4416b5b | ||
|
|
9703cc49e0 | ||
|
|
d803322e27 | ||
|
|
3d76b07def | ||
|
|
09b503c8e1 | ||
|
|
0f37a9942f | ||
|
|
fa63c49821 | ||
|
|
d39d93b834 | ||
|
|
9edcd89542 | ||
|
|
7da99edea7 | ||
|
|
ba9dda1a2e | ||
|
|
337c5bd131 | ||
|
|
c73a41af8e | ||
|
|
0df87bb609 | ||
|
|
e4d3d4de4c | ||
|
|
6d7d248e72 | ||
|
|
e9e4c32114 | ||
|
|
5f7e08323a | ||
|
|
e3f1699f55 | ||
|
|
65be086611 | ||
|
|
e4d910bf0f | ||
|
|
1964ad8c34 | ||
|
|
951366c145 | ||
|
|
9f4503d6e9 | ||
|
|
d8988b2fff | ||
|
|
92fcb5efbe | ||
|
|
6468d18e5c | ||
|
|
6b7e85b994 | ||
|
|
cd5aafcf8c | ||
|
|
037ca2f14c | ||
|
|
270a173cf3 | ||
|
|
561f9a30af | ||
|
|
f987e9d257 | ||
|
|
de76abc1e9 | ||
|
|
4a0d893695 | ||
|
|
0846f581e8 | ||
|
|
490abf53b1 | ||
|
|
3c1a79b314 | ||
|
|
5d52e7d045 | ||
|
|
004b178558 | ||
|
|
3bcfa9dedd | ||
|
|
631aa1d3dc | ||
|
|
ee006e3a4c | ||
|
|
9449f6d3a8 | ||
|
|
c07c873533 | ||
|
|
f6ec6d13dc |
@@ -11,3 +11,11 @@ patches
|
|||||||
releases
|
releases
|
||||||
*.flc
|
*.flc
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
|
intl
|
||||||
|
Makefile.in
|
||||||
|
configure
|
||||||
|
config.hin
|
||||||
|
aclocal.m4
|
||||||
|
ABOUT-NLS
|
||||||
|
INSTALL
|
||||||
|
COPYING
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
patch_list='Bison Patches <[email protected]>'
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
-*- outline -*-
|
||||||
|
|
||||||
|
This file attempts to describe the rules to use when hacking Bison.
|
||||||
|
Don't put this file into the distribution. Don't mention it in the
|
||||||
|
ChangeLog.
|
||||||
|
|
||||||
|
Everything related to the development of Bison is on Savannah:
|
||||||
|
|
||||||
|
http://savannah.gnu.org/projects/bison/
|
||||||
|
|
||||||
|
|
||||||
|
* Administrivia
|
||||||
|
|
||||||
|
** If you incorporate a change from somebody on the net:
|
||||||
|
First, if it is a large change, you must make sure they have signed
|
||||||
|
the appropriate paperwork. Second, be sure to add their name and
|
||||||
|
email address to THANKS.
|
||||||
|
|
||||||
|
** If a change fixes a test, mention the test in the ChangeLog entry.
|
||||||
|
|
||||||
|
** Bug reports
|
||||||
|
If somebody reports a new bug, mention his name in the ChangeLog entry
|
||||||
|
and in the test case you write. Put him into THANKS.
|
||||||
|
|
||||||
|
The correct response to most actual bugs is to write a new test case
|
||||||
|
which demonstrates the bug. Then fix the bug, re-run the test suite,
|
||||||
|
and check everything in.
|
||||||
|
|
||||||
|
|
||||||
|
* Hacking
|
||||||
|
|
||||||
|
** Visible changes
|
||||||
|
Which include serious bug fixes, must be mentioned in NEWS.
|
||||||
|
|
||||||
|
** Translations
|
||||||
|
Only user visible strings are to be translated: error messages, bits
|
||||||
|
of the .output file etc. This excludes impossible error messages
|
||||||
|
(comparable to assert/abort), and all the --trace output which is
|
||||||
|
meant for the maintainers only.
|
||||||
|
|
||||||
|
|
||||||
|
* Test suite
|
||||||
|
|
||||||
|
** make check
|
||||||
|
Use liberally.
|
||||||
|
|
||||||
|
** Release checks
|
||||||
|
Try to run the test suite with more severe conditions before a
|
||||||
|
release:
|
||||||
|
|
||||||
|
- Configure the package with --enable-gcc-warnings, so that one checks
|
||||||
|
that 1. Bison compiles cleanly, 2. the parsers it produces compile
|
||||||
|
cleanly too.
|
||||||
|
|
||||||
|
- run `make maintainer-check' which:
|
||||||
|
- runs `valgrind -q bison' to run Bison under Valgrind.
|
||||||
|
- runs the parsers under Valgrind.
|
||||||
|
- runs the test suite with G++ as C compiler...
|
||||||
|
|
||||||
|
- Change tests/atlocal/CFLAGS to add your preferred options. For
|
||||||
|
instance, `-traditional' to check that the parsers are K&R. Note
|
||||||
|
that it does not make sense for glr.c, which should be ANSI,
|
||||||
|
but currently is actually GNU C, nor for lalr1.cc, which anyway is
|
||||||
|
not exercised yet in the test suite.
|
||||||
|
|
||||||
|
|
||||||
|
* Release Procedure
|
||||||
|
|
||||||
|
** Tests
|
||||||
|
See above.
|
||||||
|
|
||||||
|
** Update the foreign files
|
||||||
|
Running `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.
|
||||||
|
|
||||||
|
** Update NEWS
|
||||||
|
The version number, *and* the date of the release (including for
|
||||||
|
betas).
|
||||||
|
|
||||||
|
** Update ChangeLog
|
||||||
|
Should have an entry similar to `Version 1.49b.'.
|
||||||
|
Check all this in once `make distcheck' passes.
|
||||||
|
|
||||||
|
** make alpha
|
||||||
|
Running `make alpha' is absolutely perfect for beta releases: it makes
|
||||||
|
the tarballs, the xdeltas, and prepares (in /tmp/) a proto
|
||||||
|
announcement. It is so neat, that that's what I use anyway for
|
||||||
|
genuine releases, but adjusting things by hand (e.g., the urls in the
|
||||||
|
announcement file, the ChangeLog which is not needed etc.).
|
||||||
|
|
||||||
|
If it fails, you're on your own...
|
||||||
|
|
||||||
|
It requires GNU Make.
|
||||||
|
|
||||||
|
** Upload
|
||||||
|
Put the tarballs/xdeltas where they should be. Or put it somewhere,
|
||||||
|
and send the URL to [email protected].
|
||||||
|
|
||||||
|
** Bump the version number
|
||||||
|
In configure.ac. Run `make', check this in.
|
||||||
|
|
||||||
|
** Announce
|
||||||
|
Complete/fix the announcement file, and send it at least to
|
||||||
|
[email protected] (if a real release, or a ``serious beta''),
|
||||||
|
[email protected], 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.
|
||||||
|
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
GNU Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with 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.
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
Basic Installation
|
|
||||||
==================
|
|
||||||
|
|
||||||
These are generic installation instructions.
|
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
|
||||||
various system-dependent variables used during compilation. It uses
|
|
||||||
those values to create a `Makefile' in each directory of the package.
|
|
||||||
It may also create one or more `.h' files containing system-dependent
|
|
||||||
definitions. Finally, it creates a shell script `config.status' that
|
|
||||||
you can run in the future to recreate the current configuration, a file
|
|
||||||
`config.cache' that saves the results of its tests to speed up
|
|
||||||
reconfiguring, and a file `config.log' containing compiler output
|
|
||||||
(useful mainly for debugging `configure').
|
|
||||||
|
|
||||||
If you need to do unusual things to compile the package, please try
|
|
||||||
to figure out how `configure' could check whether to do them, and mail
|
|
||||||
diffs or instructions to the address given in the `README' so they can
|
|
||||||
be considered for the next release. If at some point `config.cache'
|
|
||||||
contains results you don't want to keep, you may remove or edit it.
|
|
||||||
|
|
||||||
The file `configure.in' is used to create `configure' by a program
|
|
||||||
called `autoconf'. You only need `configure.in' if you want to change
|
|
||||||
it or regenerate `configure' using a newer version of `autoconf'.
|
|
||||||
|
|
||||||
The simplest way to compile this package is:
|
|
||||||
|
|
||||||
1. `cd' to the directory containing the package's source code and type
|
|
||||||
`./configure' to configure the package for your system. If you're
|
|
||||||
using `csh' on an old version of System V, you might need to type
|
|
||||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
|
||||||
`configure' itself.
|
|
||||||
|
|
||||||
Running `configure' takes awhile. While running, it prints some
|
|
||||||
messages telling which features it is checking for.
|
|
||||||
|
|
||||||
2. Type `make' to compile the package.
|
|
||||||
|
|
||||||
3. Optionally, type `make check' to run any self-tests that come with
|
|
||||||
the package.
|
|
||||||
|
|
||||||
4. Type `make install' to install the programs and any data files and
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
5. You can remove the program binaries and object files from the
|
|
||||||
source code directory by typing `make clean'. To also remove the
|
|
||||||
files that `configure' created (so you can compile the package for
|
|
||||||
a different kind of computer), type `make distclean'. There is
|
|
||||||
also a `make maintainer-clean' target, but that is intended mainly
|
|
||||||
for the package's developers. If you use it, you may have to get
|
|
||||||
all sorts of other programs in order to regenerate files that came
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
Compilers and Options
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Some systems require unusual options for compilation or linking that
|
|
||||||
the `configure' script does not know about. You can give `configure'
|
|
||||||
initial values for variables by setting them in the environment. Using
|
|
||||||
a Bourne-compatible shell, you can do that on the command line like
|
|
||||||
this:
|
|
||||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
|
||||||
|
|
||||||
Or on systems that have the `env' program, you can do it like this:
|
|
||||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
|
||||||
|
|
||||||
Compiling For Multiple Architectures
|
|
||||||
====================================
|
|
||||||
|
|
||||||
You can compile the package for more than one kind of computer at the
|
|
||||||
same time, by placing the object files for each architecture in their
|
|
||||||
own directory. To do this, you must use a version of `make' that
|
|
||||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
|
||||||
directory where you want the object files and executables to go and run
|
|
||||||
the `configure' script. `configure' automatically checks for the
|
|
||||||
source code in the directory that `configure' is in and in `..'.
|
|
||||||
|
|
||||||
If you have to use a `make' that does not supports the `VPATH'
|
|
||||||
variable, you have to compile the package for one architecture at a time
|
|
||||||
in the source code directory. After you have installed the package for
|
|
||||||
one architecture, use `make distclean' before reconfiguring for another
|
|
||||||
architecture.
|
|
||||||
|
|
||||||
Installation Names
|
|
||||||
==================
|
|
||||||
|
|
||||||
By default, `make install' will install the package's files in
|
|
||||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
|
||||||
installation prefix other than `/usr/local' by giving `configure' the
|
|
||||||
option `--prefix=PATH'.
|
|
||||||
|
|
||||||
You can specify separate installation prefixes for
|
|
||||||
architecture-specific files and architecture-independent files. If you
|
|
||||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
|
||||||
PATH as the prefix for installing programs and libraries.
|
|
||||||
Documentation and other data files will still use the regular prefix.
|
|
||||||
|
|
||||||
In addition, if you use an unusual directory layout you can give
|
|
||||||
options like `--bindir=PATH' to specify different values for particular
|
|
||||||
kinds of files. Run `configure --help' for a list of the directories
|
|
||||||
you can set and what kinds of files go in them.
|
|
||||||
|
|
||||||
If the package supports it, you can cause programs to be installed
|
|
||||||
with an extra prefix or suffix on their names by giving `configure' the
|
|
||||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
|
||||||
|
|
||||||
Optional Features
|
|
||||||
=================
|
|
||||||
|
|
||||||
Some packages pay attention to `--enable-FEATURE' options to
|
|
||||||
`configure', where FEATURE indicates an optional part of the package.
|
|
||||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
|
||||||
is something like `gnu-as' or `x' (for the X Window System). The
|
|
||||||
`README' should mention any `--enable-' and `--with-' options that the
|
|
||||||
package recognizes.
|
|
||||||
|
|
||||||
For packages that use the X Window System, `configure' can usually
|
|
||||||
find the X include and library files automatically, but if it doesn't,
|
|
||||||
you can use the `configure' options `--x-includes=DIR' and
|
|
||||||
`--x-libraries=DIR' to specify their locations.
|
|
||||||
|
|
||||||
Specifying the System Type
|
|
||||||
==========================
|
|
||||||
|
|
||||||
There may be some features `configure' can not figure out
|
|
||||||
automatically, but needs to determine by the type of host the package
|
|
||||||
will run on. Usually `configure' can figure that out, but if it prints
|
|
||||||
a message saying it can not guess the host type, give it the
|
|
||||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
|
||||||
type, such as `sun4', or a canonical name with three fields:
|
|
||||||
CPU-COMPANY-SYSTEM
|
|
||||||
|
|
||||||
See the file `config.sub' for the possible values of each field. If
|
|
||||||
`config.sub' isn't included in this package, then this package doesn't
|
|
||||||
need to know the host type.
|
|
||||||
|
|
||||||
If you are building compiler tools for cross-compiling, you can also
|
|
||||||
use the `--target=TYPE' option to select the type of system they will
|
|
||||||
produce code for and the `--build=TYPE' option to select the type of
|
|
||||||
system on which you are compiling the package.
|
|
||||||
|
|
||||||
Sharing Defaults
|
|
||||||
================
|
|
||||||
|
|
||||||
If you want to set default values for `configure' scripts to share,
|
|
||||||
you can create a site shell script called `config.site' that gives
|
|
||||||
default values for variables like `CC', `cache_file', and `prefix'.
|
|
||||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
|
||||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
|
||||||
`CONFIG_SITE' environment variable to the location of the site script.
|
|
||||||
A warning: not all `configure' scripts look for a site script.
|
|
||||||
|
|
||||||
Operation Controls
|
|
||||||
==================
|
|
||||||
|
|
||||||
`configure' recognizes the following options to control how it
|
|
||||||
operates.
|
|
||||||
|
|
||||||
`--cache-file=FILE'
|
|
||||||
Use and save the results of the tests in FILE instead of
|
|
||||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
|
||||||
debugging `configure'.
|
|
||||||
|
|
||||||
`--help'
|
|
||||||
Print a summary of the options to `configure', and exit.
|
|
||||||
|
|
||||||
`--quiet'
|
|
||||||
`--silent'
|
|
||||||
`-q'
|
|
||||||
Do not print messages saying which checks are being made. To
|
|
||||||
suppress all normal output, redirect it to `/dev/null' (any error
|
|
||||||
messages will still be shown).
|
|
||||||
|
|
||||||
`--srcdir=DIR'
|
|
||||||
Look for the package's source code in directory DIR. Usually
|
|
||||||
`configure' can determine that directory automatically.
|
|
||||||
|
|
||||||
`--version'
|
|
||||||
Print the version of Autoconf used to generate the `configure'
|
|
||||||
script, and exit.
|
|
||||||
|
|
||||||
`configure' also accepts some other, not widely useful, options.
|
|
||||||
+23
-8
@@ -1,14 +1,30 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
AUTOMAKE_OPTIONS = 1.5 check-news readme-alpha dist-bzip2
|
## Copyright (C) 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 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
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = config intl po lib src doc m4 tests
|
SUBDIRS = config po lib data src doc m4 tests
|
||||||
|
|
||||||
EXTRA_DIST = REFERENCES configure.bat OChangeLog Makefile.maint GNUmakefile
|
EXTRA_DIST = REFERENCES OChangeLog Makefile.maint GNUmakefile
|
||||||
|
|
||||||
DISTCLEANFILES = intl/libintl.h
|
|
||||||
|
|
||||||
|
.PHONY: maintainer-check
|
||||||
|
maintainer-check:
|
||||||
|
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@
|
||||||
|
|
||||||
## ---------------------------- ##
|
## ---------------------------- ##
|
||||||
## Customizing Makefile.maint. ##
|
## Customizing Makefile.maint. ##
|
||||||
@@ -19,9 +35,8 @@ prev_version_file = $(srcdir)/config/prev-version.txt
|
|||||||
release_archive_dir = releases
|
release_archive_dir = releases
|
||||||
|
|
||||||
# Uploading betas.
|
# Uploading betas.
|
||||||
hosts = alpha
|
url_dir_list = \
|
||||||
alpha_host = alpha.gnu.org
|
ftp://alpha.gnu.org/gnu/bison
|
||||||
alpha_url_dir = gnu/bison
|
|
||||||
|
|
||||||
# Files to update automatically.
|
# Files to update automatically.
|
||||||
wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
|
wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
|
||||||
|
|||||||
+264
-226
@@ -2,7 +2,7 @@
|
|||||||
# This Makefile fragment is shared between fileutils, sh-utils, textutils,
|
# This Makefile fragment is shared between fileutils, sh-utils, textutils,
|
||||||
# CPPI, Bison, and Autoconf.
|
# CPPI, Bison, and Autoconf.
|
||||||
|
|
||||||
## Copyright 2001 Free Software Foundation, Inc.
|
## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
@@ -43,6 +43,237 @@ release_archive_dir ?= ../release
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## --------------- ##
|
||||||
|
## Sanity checks. ##
|
||||||
|
## --------------- ##
|
||||||
|
|
||||||
|
# Checks that don't require cvs.
|
||||||
|
# Run `changelog-check' last, as previous test may reveal problems requiring
|
||||||
|
# new ChangeLog entries.
|
||||||
|
local-check = \
|
||||||
|
po-check copyright-check writable-files m4-check author_mark_check \
|
||||||
|
changelog-check strftime-check header-check
|
||||||
|
.PHONY: $(local-check)
|
||||||
|
|
||||||
|
# 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; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure that date's --help output stays in sync with the info
|
||||||
|
# documentation for GNU strftime. The only exception is %N,
|
||||||
|
# which date accepts but GNU strftime does not.
|
||||||
|
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
|
||||||
|
strftime-check:
|
||||||
|
if test -f $(srcdir)/src/date.c; then \
|
||||||
|
grep '^ %. ' $(srcdir)/src/date.c | sort \
|
||||||
|
| $(extract_char) > $@-src; \
|
||||||
|
{ echo N; \
|
||||||
|
info libc date calendar format | grep '^ `%.'\' \
|
||||||
|
| $(extract_char); } | sort > $@-info; \
|
||||||
|
diff -u $@-src $@-info || exit 1; \
|
||||||
|
rm -f $@-src $@-info; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
changelog-check:
|
||||||
|
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
|
||||||
|
:; \
|
||||||
|
else \
|
||||||
|
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
m4-check:
|
||||||
|
@grep 'AC_DEFUN([^[]' m4/*.m4 \
|
||||||
|
&& { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
|
||||||
|
exit 1; } || :
|
||||||
|
|
||||||
|
# Verify that all source files using _() are listed in po/POTFILES.in.
|
||||||
|
po-check:
|
||||||
|
if test -f po/POTFILES.in; then \
|
||||||
|
grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
|
||||||
|
files=; \
|
||||||
|
for file in lib/*.[chly] src/*.[chly]; do \
|
||||||
|
case $$file in \
|
||||||
|
*.[ch]) \
|
||||||
|
base=`expr " $$file" : ' \(.*\)\..'`; \
|
||||||
|
{ test -f $$base.l || test -f $$base.y; } && continue;; \
|
||||||
|
esac; \
|
||||||
|
files="$$files $$file"; \
|
||||||
|
done; \
|
||||||
|
grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
|
||||||
|
diff -u $@-1 $@-2 || exit 1; \
|
||||||
|
rm -f $@-1 $@-2; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# In a definition of #define AUTHORS "... and ..." where the RHS contains
|
||||||
|
# the English word `and', the string must be marked with `N_ (...)' so that
|
||||||
|
# gettext recognizes it as a string requiring translation.
|
||||||
|
author_mark_check:
|
||||||
|
@grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
|
||||||
|
{ echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
|
||||||
|
exit 1; } || :
|
||||||
|
|
||||||
|
# Check that `make alpha' will not fail at the end of the process.
|
||||||
|
writable-files:
|
||||||
|
if test -d $(release_archive_dir); then :; else \
|
||||||
|
mkdir $(release_archive_dir); \
|
||||||
|
fi
|
||||||
|
for file in $(distdir).tar.gz $(xd-delta) \
|
||||||
|
$(release_archive_dir)/$(distdir).tar.gz \
|
||||||
|
$(release_archive_dir)/$(xd-delta); do \
|
||||||
|
test -e $$file || continue; \
|
||||||
|
test -w $$file \
|
||||||
|
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
||||||
|
done; \
|
||||||
|
test "$$fail" && exit 1 || :
|
||||||
|
|
||||||
|
v_etc_file = lib/version-etc.c
|
||||||
|
# Make sure that the copyright date in $(v_etc_file) is up to date.
|
||||||
|
copyright-check:
|
||||||
|
@if test -f $(v_etc_file); then \
|
||||||
|
grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
|
||||||
|
>/dev/null \
|
||||||
|
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
|
||||||
|
exit 1; }; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Sanity checks with the CVS repository.
|
||||||
|
cvs-tag-check:
|
||||||
|
echo $(this-cvs-tag); \
|
||||||
|
if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
|
||||||
|
echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
|
||||||
|
exit 1; \
|
||||||
|
else :; fi
|
||||||
|
|
||||||
|
cvs-diff-check:
|
||||||
|
if $(CVS) diff >cvs-diffs; then \
|
||||||
|
rm cvs-diffs; \
|
||||||
|
else \
|
||||||
|
echo "Some files are locally modified:" 1>&2; \
|
||||||
|
cat cvs-diffs; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
cvs-check: cvs-diff-check cvs-tag-check
|
||||||
|
|
||||||
|
maintainer-distcheck: changelog-check
|
||||||
|
$(MAKE) distcheck
|
||||||
|
$(MAKE) my-distcheck
|
||||||
|
|
||||||
|
|
||||||
|
# Tag before making distribution. Also, don't make a distribution if
|
||||||
|
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||||
|
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
||||||
|
cvs-dist: $(local-check) cvs-check maintainer-distcheck
|
||||||
|
$(CVS) update po
|
||||||
|
$(CVS) tag -c $(this-cvs-tag)
|
||||||
|
$(MAKE) dist
|
||||||
|
|
||||||
|
# Use this to make sure we don't run these programs when building
|
||||||
|
# from a virgin tgz file, below.
|
||||||
|
null_AM_MAKEFLAGS = \
|
||||||
|
ACLOCAL=false \
|
||||||
|
AUTOCONF=false \
|
||||||
|
AUTOMAKE=false \
|
||||||
|
AUTOHEADER=false \
|
||||||
|
MAKEINFO=false
|
||||||
|
|
||||||
|
# Detect format-string/arg-list mismatches that would normally be obscured
|
||||||
|
# by the use of _(). The --disable-nls effectively defines away that macro,
|
||||||
|
# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
|
||||||
|
# treated as a failure.
|
||||||
|
t=./=test
|
||||||
|
my-distcheck: $(local-check)
|
||||||
|
-rm -rf $(t)
|
||||||
|
mkdir $(t)
|
||||||
|
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||||
|
cd $(t)/$(distdir) \
|
||||||
|
&& ./configure --disable-nls \
|
||||||
|
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
||||||
|
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||||
|
&& $(MAKE) dvi \
|
||||||
|
&& $(MAKE) check \
|
||||||
|
&& $(MAKE) distclean
|
||||||
|
cd $(t) && mv $(distdir) $(distdir).old \
|
||||||
|
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
||||||
|
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||||
|
-rm -rf $(t)
|
||||||
|
@echo "========================"; \
|
||||||
|
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||||
|
echo "========================"
|
||||||
|
|
||||||
|
tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||||
|
tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
|
||||||
|
bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||||
|
bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
||||||
|
xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
|
||||||
|
xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
|
||||||
|
tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
|
||||||
|
bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
|
||||||
|
xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
|
||||||
|
|
||||||
|
rel-check:
|
||||||
|
tarz=/tmp/rel-check-tarz-$$$$; \
|
||||||
|
md5_tmp=/tmp/rel-check-md5-$$$$; \
|
||||||
|
set -e; \
|
||||||
|
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
|
||||||
|
wget -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
|
||||||
|
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"'; \
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Updating files. ##
|
## Updating files. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
@@ -53,6 +284,16 @@ ftp-gnu = ftp://ftp.gnu.org/gnu
|
|||||||
# Use mv, if you don't have/want move-if-change.
|
# Use mv, if you don't have/want move-if-change.
|
||||||
move_if_change ?= move-if-change
|
move_if_change ?= move-if-change
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------- #
|
||||||
|
# Updating everything. #
|
||||||
|
# --------------------- #
|
||||||
|
|
||||||
|
.PHONY: update
|
||||||
|
local_updates ?= wget-update cvs-update po-update
|
||||||
|
update: $(local_updates)
|
||||||
|
|
||||||
|
|
||||||
# ------------------- #
|
# ------------------- #
|
||||||
# Updating PO files. #
|
# Updating PO files. #
|
||||||
# ------------------- #
|
# ------------------- #
|
||||||
@@ -80,10 +321,11 @@ po-update:
|
|||||||
# The following pseudo table associates a local directory and a URL
|
# The following pseudo table associates a local directory and a URL
|
||||||
# with each of the files that belongs to some other package and is
|
# with each of the files that belongs to some other package and is
|
||||||
# regularly updated from the specified URL.
|
# regularly updated from the specified URL.
|
||||||
wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
|
wget_files ?= $(srcdir)/config/config.guess \
|
||||||
|
$(srcdir)/config/config.sub \
|
||||||
$(srcdir)/src/ansi2knr.c \
|
$(srcdir)/src/ansi2knr.c \
|
||||||
$(srcdir)/doc/texinfo.tex
|
$(srcdir)/config/texinfo.tex
|
||||||
wget-targets = $(patsubst %, get-%, $(wget_files))
|
get-targets = $(patsubst %, get-%, $(wget_files))
|
||||||
|
|
||||||
config.guess-url_prefix = $(ftp-gnu)/config/
|
config.guess-url_prefix = $(ftp-gnu)/config/
|
||||||
config.sub-url_prefix = $(ftp-gnu)/config/
|
config.sub-url_prefix = $(ftp-gnu)/config/
|
||||||
@@ -98,235 +340,31 @@ make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
|
|||||||
target = $(patsubst get-%, %, $@)
|
target = $(patsubst get-%, %, $@)
|
||||||
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
|
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
|
||||||
|
|
||||||
.PHONY: $(wget-targets)
|
.PHONY: $(get-targets)
|
||||||
$(wget-targets):
|
$(get-targets):
|
||||||
$(WGET) $(url) -O $(target).t \
|
$(WGET) $(url) -O $(target).t \
|
||||||
&& $(move_if_change) $(target).t $(target)
|
&& $(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
|
||||||
|
automake_repo=:pserver:anoncvs:[email protected]:/cvs/automake
|
||||||
.PHONY: wget-update
|
.PHONY: wget-update
|
||||||
wget-update: $(wget-targets)
|
wget-update: $(get-targets)
|
||||||
|
|
||||||
|
|
||||||
# Updating tools via CVS.
|
|
||||||
cvs_files ?= depcomp missing
|
|
||||||
cvs-targets = $(patsubst %, get-%, $(cvs_files))
|
|
||||||
|
|
||||||
automake_repo = :pserver:[email protected]:/cvs/automake
|
|
||||||
.PHONY: $(cvs-targets)
|
|
||||||
$(cvs-targets):
|
|
||||||
$(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \
|
|
||||||
>$(target).t \
|
|
||||||
&& $(move_if_change) $(target).t $(target);
|
|
||||||
|
|
||||||
.PHONY: cvs-update
|
.PHONY: cvs-update
|
||||||
cvs-update: $(cvs-targets)
|
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
|
||||||
|
|
||||||
|
define emit-upload-commands
|
||||||
# --------------------- #
|
|
||||||
# Updating everything. #
|
|
||||||
# --------------------- #
|
|
||||||
|
|
||||||
.PHONY: update
|
|
||||||
update: wget-update cvs-update po-update
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## --------------- ##
|
|
||||||
## Sanity checks. ##
|
|
||||||
## --------------- ##
|
|
||||||
|
|
||||||
# Checks that don't require cvs. Run `changelog-check' last as
|
|
||||||
# previous test may reveal problems requiring new ChangeLog entries.
|
|
||||||
local-check: po-check copyright-check writable-files changelog-check
|
|
||||||
|
|
||||||
changelog-check:
|
|
||||||
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
|
|
||||||
:; \
|
|
||||||
else \
|
|
||||||
echo "$(VERSION) not in ChangeLog" 1>&2; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Verify that all source files using _() are listed in po/POTFILES.in.
|
|
||||||
po-check:
|
|
||||||
if test -f po/POTFILES.in; then \
|
|
||||||
grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
|
|
||||||
grep -E -l '\b_\(' lib/*.c src/*.c | sort > $@-2; \
|
|
||||||
diff -u $@-1 $@-2 || exit 1; \
|
|
||||||
rm -f $@-1 $@-2; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that `make alpha' will not fail at the end of the process.
|
|
||||||
writable-files:
|
|
||||||
if test -d $(release_archive_dir); then :; else \
|
|
||||||
mkdir $(release_archive_dir); \
|
|
||||||
fi
|
|
||||||
for file in $(distdir).tar.gz $(xd-delta) \
|
|
||||||
$(release_archive_dir)/$(distdir).tar.gz \
|
|
||||||
$(release_archive_dir)/$(xd-delta); do \
|
|
||||||
test -e $$file || continue; \
|
|
||||||
test -w $$file \
|
|
||||||
|| { echo ERROR: $$file is not writable; fail=1; }; \
|
|
||||||
done; \
|
|
||||||
test "$$fail" && exit 1 || :
|
|
||||||
|
|
||||||
# Make sure that the copyright date in lib/version-etc.c is up to date.
|
|
||||||
copyright-check:
|
|
||||||
@if test -f lib/version-etc.c; then \
|
|
||||||
grep 'N_("Copyright (C) $(shell date +%Y) Free' lib/version-etc.c \
|
|
||||||
>/dev/null \
|
|
||||||
|| { echo 'out of date copyright in $<; update it' 1>&2; exit 1; }; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Sanity checks with the CVS repository.
|
|
||||||
cvs-tag-check:
|
|
||||||
echo $(this-cvs-tag); \
|
|
||||||
if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
|
|
||||||
echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
|
|
||||||
exit 1; \
|
|
||||||
else :; fi
|
|
||||||
|
|
||||||
cvs-diff-check:
|
|
||||||
if $(CVS) diff >cvs-diffs; then \
|
|
||||||
rm cvs-diffs; \
|
|
||||||
else \
|
|
||||||
echo "Some files are locally modified:" 1>&2; \
|
|
||||||
cat cvs-diffs; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
cvs-check: cvs-diff-check cvs-tag-check
|
|
||||||
|
|
||||||
maintainer-distcheck: changelog-check
|
|
||||||
$(MAKE) distcheck
|
|
||||||
$(MAKE) my-distcheck
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
|
||||||
## Making dists. ##
|
|
||||||
## -------------- ##
|
|
||||||
|
|
||||||
|
|
||||||
# Tag before making distribution. Also, don't make a distribution if
|
|
||||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
|
||||||
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
|
||||||
cvs-dist: local-check cvs-check maintainer-distcheck
|
|
||||||
$(CVS) update po
|
|
||||||
$(CVS) tag -c $(this-cvs-tag)
|
|
||||||
$(MAKE) dist
|
|
||||||
|
|
||||||
# Use this to make sure we don't run these programs when building
|
|
||||||
# from a virgin tgz file, below.
|
|
||||||
null_AM_MAKEFLAGS = \
|
|
||||||
ACLOCAL=false \
|
|
||||||
AUTOCONF=false \
|
|
||||||
AUTOM4TE=false \
|
|
||||||
AUTOMAKE=false \
|
|
||||||
AUTOHEADER=false \
|
|
||||||
MAKEINFO=false
|
|
||||||
|
|
||||||
# Detect format-string/arg-list mismatches that would normally be obscured
|
|
||||||
# by the use of _(). The --disable-nls effectively defines away that macro,
|
|
||||||
# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
|
|
||||||
# treated as a failure.
|
|
||||||
t=./=test
|
|
||||||
my-distcheck: writable-files po-check
|
|
||||||
-rm -rf $(t)
|
|
||||||
mkdir $(t)
|
|
||||||
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
|
||||||
cd $(t)/$(distdir) \
|
|
||||||
&& ./configure --disable-nls \
|
|
||||||
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
|
||||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
|
||||||
&& $(MAKE) dvi \
|
|
||||||
&& $(MAKE) check \
|
|
||||||
&& $(MAKE) distclean
|
|
||||||
cd $(t) && mv $(distdir) $(distdir).old \
|
|
||||||
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
|
||||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
|
||||||
-rm -rf $(t)
|
|
||||||
@echo "========================"; \
|
|
||||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
|
||||||
echo "========================"
|
|
||||||
|
|
||||||
# This must be the same name on both hosts.
|
|
||||||
# Make it a symlink that points to the right place.
|
|
||||||
real_dir = fetish-ftp
|
|
||||||
|
|
||||||
url_dir_list = $(foreach x,$(hosts),ftp://$($(x)_host)/$($(x)_url_dir))
|
|
||||||
|
|
||||||
tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
|
|
||||||
tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
|
|
||||||
bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
|
||||||
bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
|
|
||||||
tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([Mk]\).*/ \1B/')
|
|
||||||
bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([Mk]\).*/ \1B/')
|
|
||||||
xd-size = $(shell du --human $(xd-delta)|sed 's/\([Mk]\).*/ \1B/')
|
|
||||||
|
|
||||||
rel-check:
|
|
||||||
tarz=/tmp/rel-check-tarz-$$$$; \
|
|
||||||
md5_tmp=/tmp/rel-check-md5-$$$$; \
|
|
||||||
set -e; \
|
|
||||||
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
|
|
||||||
$(WGET) -q --output-document=$$tarz $(url); \
|
|
||||||
echo "$(md5) -" > $$md5_tmp; \
|
|
||||||
md5sum -c $$md5_tmp < $$tarz
|
|
||||||
|
|
||||||
prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
|
||||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
|
||||||
|
|
||||||
GZIP = gzip
|
|
||||||
BZIP2 = bzip2
|
|
||||||
$(my_distdir).tar.bz2: $(my_distdir).tar.gz
|
|
||||||
$(GZIP) -dc $< > $(my_distdir).tar
|
|
||||||
rm -f $@
|
|
||||||
$(BZIP2) -9 $(my_distdir).tar
|
|
||||||
|
|
||||||
rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
|
|
||||||
announcement: NEWS ChangeLog $(rel-files)
|
|
||||||
@( \
|
|
||||||
echo Subject: $(my_distdir) released; \
|
|
||||||
echo; \
|
|
||||||
echo FIXME: put comments here; \
|
|
||||||
echo; \
|
|
||||||
for url in $(url_dir_list); do \
|
|
||||||
echo " $$url/$(my_distdir).tar.gz ($(tgz-size))"; \
|
|
||||||
echo " $$url/$(my_distdir).tar.bz2 ($(bz2-size))"; \
|
|
||||||
done; \
|
|
||||||
echo; \
|
|
||||||
echo And here are xdelta-style diffs; \
|
|
||||||
echo; \
|
|
||||||
for url in $(url_dir_list); do \
|
|
||||||
echo " $$url/$(xd-delta) ($(xd-size))"; \
|
|
||||||
done; \
|
|
||||||
echo; \
|
|
||||||
echo "Here are the MD5 and SHA1 signatures for the compressed tar files:"; \
|
|
||||||
echo; \
|
|
||||||
echo "$(tgz-md5) $(my_distdir).tar.gz"; \
|
|
||||||
echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
|
|
||||||
echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
|
|
||||||
echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
|
|
||||||
echo; \
|
|
||||||
echo NEWS:; \
|
|
||||||
sed -n "/$(THIS_VERSION_REGEXP)[]:]/,/$(PREV_VERSION_REGEXP)[]:]/p" NEWS \
|
|
||||||
| grep -v '^\['; \
|
|
||||||
echo; \
|
|
||||||
echo ChangeLog entries:; \
|
|
||||||
find . -name ChangeLog -maxdepth 2 \
|
|
||||||
| xargs $(CVS) diff -up -r$(prev-cvs-tag) -rHEAD \
|
|
||||||
| sed -n 's/^+//p' \
|
|
||||||
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
|
|
||||||
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
|
|
||||||
)
|
|
||||||
|
|
||||||
define emit-rsync-commands
|
|
||||||
echo =====================================
|
echo =====================================
|
||||||
echo =====================================
|
echo =====================================
|
||||||
echo 'for host in $(a_host) $(b_host); do \'
|
echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
|
||||||
echo ' rsync -e ssh --pro -av $(xd-delta) $(my_distdir).tar.bz2 \'
|
|
||||||
echo ' $(my_distdir).tar.gz $$host:$(real_dir); done'
|
|
||||||
echo '# send the /tmp/announcement e-mail'
|
echo '# send the /tmp/announcement e-mail'
|
||||||
echo =====================================
|
echo =====================================
|
||||||
echo =====================================
|
echo =====================================
|
||||||
@@ -335,7 +373,7 @@ endef
|
|||||||
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
|
||||||
xdelta delta -9 $^ $@ || :
|
xdelta delta -9 $^ $@ || :
|
||||||
|
|
||||||
alpha:
|
alpha: $(local-check)
|
||||||
$(MAKE) cvs-dist
|
$(MAKE) cvs-dist
|
||||||
$(MAKE) $(xd-delta)
|
$(MAKE) $(xd-delta)
|
||||||
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
|
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
|
||||||
@@ -343,4 +381,4 @@ alpha:
|
|||||||
chmod a-w $(rel-files)
|
chmod a-w $(rel-files)
|
||||||
echo $(VERSION) > $(prev_version_file)
|
echo $(VERSION) > $(prev_version_file)
|
||||||
$(CVS) ci -m. $(prev_version_file)
|
$(CVS) ci -m. $(prev_version_file)
|
||||||
@$(emit-rsync-commands)
|
@$(emit-upload-commands)
|
||||||
|
|||||||
@@ -1,20 +1,419 @@
|
|||||||
Bison News
|
Bison News
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Changes in version 1.29d:
|
Changes in version 1.875, 2003-01-01:
|
||||||
|
|
||||||
* `--defines' and `--graph' have now an optionnal argument which is the
|
* The documentation license has been upgraded to version 1.2
|
||||||
output file name. `-d' and `-g' do not change, they do not take any
|
of the GNU Free Documentation License.
|
||||||
|
|
||||||
|
* syntax error processing
|
||||||
|
|
||||||
|
- In Yacc-style parsers YYLLOC_DEFAULT is now used to compute error
|
||||||
|
locations too. This fixes bugs in error-location computation.
|
||||||
|
|
||||||
|
- %destructor
|
||||||
|
It is now possible to reclaim the memory associated to symbols
|
||||||
|
discarded during error recovery. This feature is still experimental.
|
||||||
|
|
||||||
|
- %error-verbose
|
||||||
|
This new directive is preferred over YYERROR_VERBOSE.
|
||||||
|
|
||||||
|
- #defining yyerror to steal internal variables is discouraged.
|
||||||
|
It is not guaranteed to work forever.
|
||||||
|
|
||||||
|
* POSIX conformance
|
||||||
|
|
||||||
|
- Semicolons are once again optional at the end of grammar rules.
|
||||||
|
This reverts to the behavior of Bison 1.33 and earlier, and improves
|
||||||
|
compatibility with Yacc.
|
||||||
|
|
||||||
|
- `parse error' -> `syntax error'
|
||||||
|
Bison now uniformly uses the term `syntax error'; formerly, the code
|
||||||
|
and manual sometimes used the term `parse error' instead. POSIX
|
||||||
|
requires `syntax error' in diagnostics, and it was thought better to
|
||||||
|
be consistent.
|
||||||
|
|
||||||
|
- The documentation now emphasizes that yylex and yyerror must be
|
||||||
|
declared before use. C99 requires this.
|
||||||
|
|
||||||
|
- Bison now parses C99 lexical constructs like UCNs and
|
||||||
|
backslash-newline within C escape sequences, as POSIX 1003.1-2001 requires.
|
||||||
|
|
||||||
|
- File names are properly escaped in C output. E.g., foo\bar.y is
|
||||||
|
output as "foo\\bar.y".
|
||||||
|
|
||||||
|
- Yacc command and library now available
|
||||||
|
The Bison distribution now installs a `yacc' command, as POSIX requires.
|
||||||
|
Also, Bison now installs a small library liby.a containing
|
||||||
|
implementations of Yacc-compatible yyerror and main functions.
|
||||||
|
This library is normally not useful, but POSIX requires it.
|
||||||
|
|
||||||
|
- Type clashes now generate warnings, not errors.
|
||||||
|
|
||||||
|
- If the user does not define YYSTYPE as a macro, Bison now declares it
|
||||||
|
using typedef instead of defining it as a macro.
|
||||||
|
For consistency, YYLTYPE is also declared instead of defined.
|
||||||
|
|
||||||
|
* Other compatibility issues
|
||||||
|
|
||||||
|
- %union directives can now have a tag before the `{', e.g., the
|
||||||
|
directive `%union foo {...}' now generates the C code
|
||||||
|
`typedef union foo { ... } YYSTYPE;'; this is for Yacc compatibility.
|
||||||
|
The default union tag is `YYSTYPE', for compatibility with Solaris 9 Yacc.
|
||||||
|
For consistency, YYLTYPE's struct tag is now `YYLTYPE' not `yyltype'.
|
||||||
|
This is for compatibility with both Yacc and Bison 1.35.
|
||||||
|
|
||||||
|
- `;' is output before the terminating `}' of an action, for
|
||||||
|
compatibility with Bison 1.35.
|
||||||
|
|
||||||
|
- Bison now uses a Yacc-style format for conflict reports, e.g.,
|
||||||
|
`conflicts: 2 shift/reduce, 1 reduce/reduce'.
|
||||||
|
|
||||||
|
- `yystype' and `yyltype' are now obsolescent macros instead of being
|
||||||
|
typedefs or tags; they are no longer documented and are planned to be
|
||||||
|
withdrawn in a future release.
|
||||||
|
|
||||||
|
* GLR parser notes
|
||||||
|
|
||||||
|
- GLR and inline
|
||||||
|
Users of Bison have to decide how they handle the portability of the
|
||||||
|
C keyword `inline'.
|
||||||
|
|
||||||
|
- `parsing stack overflow...' -> `parser stack overflow'
|
||||||
|
GLR parsers now report `parser stack overflow' as per the Bison manual.
|
||||||
|
|
||||||
|
* Bison now warns if it detects conflicting outputs to the same file,
|
||||||
|
e.g., it generates a warning for `bison -d -o foo.h foo.y' since
|
||||||
|
that command outputs both code and header to foo.h.
|
||||||
|
|
||||||
|
* #line in output files
|
||||||
|
- --no-line works properly.
|
||||||
|
|
||||||
|
* Bison can no longer be built by a K&R C compiler; it requires C89 or
|
||||||
|
later to be built. This change originally took place a few versions
|
||||||
|
ago, but nobody noticed until we recently asked someone to try
|
||||||
|
building Bison with a K&R C compiler.
|
||||||
|
|
||||||
|
Changes in version 1.75, 2002-10-14:
|
||||||
|
|
||||||
|
* Bison should now work on 64-bit hosts.
|
||||||
|
|
||||||
|
* Indonesian translation thanks to Tedi Heriyanto.
|
||||||
|
|
||||||
|
* GLR parsers
|
||||||
|
Fix spurious parse errors.
|
||||||
|
|
||||||
|
* Pure parsers
|
||||||
|
Some people redefine yyerror to steal yyparse' private variables.
|
||||||
|
Reenable this trick until an official feature replaces it.
|
||||||
|
|
||||||
|
* Type Clashes
|
||||||
|
In agreement with POSIX and with other Yaccs, leaving a default
|
||||||
|
action is valid when $$ is untyped, and $1 typed:
|
||||||
|
|
||||||
|
untyped: ... typed;
|
||||||
|
|
||||||
|
but the converse remains an error:
|
||||||
|
|
||||||
|
typed: ... untyped;
|
||||||
|
|
||||||
|
* Values of mid-rule actions
|
||||||
|
The following code:
|
||||||
|
|
||||||
|
foo: { ... } { $$ = $1; } ...
|
||||||
|
|
||||||
|
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||||
|
action, and is equal to the $$ of the first mid-rule action.
|
||||||
|
|
||||||
|
Changes in version 1.50, 2002-10-04:
|
||||||
|
|
||||||
|
* GLR parsing
|
||||||
|
The declaration
|
||||||
|
%glr-parser
|
||||||
|
causes Bison to produce a Generalized LR (GLR) parser, capable of handling
|
||||||
|
almost any context-free grammar, ambiguous or not. The new declarations
|
||||||
|
%dprec and %merge on grammar rules allow parse-time resolution of
|
||||||
|
ambiguities. Contributed by Paul Hilfinger.
|
||||||
|
|
||||||
|
Unfortunately Bison 1.50 does not work properly on 64-bit hosts
|
||||||
|
like the Alpha, so please stick to 32-bit hosts for now.
|
||||||
|
|
||||||
|
* Output Directory
|
||||||
|
When not in Yacc compatibility mode, when the output file was not
|
||||||
|
specified, running `bison foo/bar.y' created `foo/bar.c'. It
|
||||||
|
now creates `bar.c'.
|
||||||
|
|
||||||
|
* Undefined token
|
||||||
|
The undefined token was systematically mapped to 2 which prevented
|
||||||
|
the use of 2 by the user. This is no longer the case.
|
||||||
|
|
||||||
|
* Unknown token numbers
|
||||||
|
If yylex returned an out of range value, yyparse could die. This is
|
||||||
|
no longer the case.
|
||||||
|
|
||||||
|
* Error token
|
||||||
|
According to POSIX, the error token must be 256.
|
||||||
|
Bison extends this requirement by making it a preference: *if* the
|
||||||
|
user specified that one of her tokens is numbered 256, then error
|
||||||
|
will be mapped onto another number.
|
||||||
|
|
||||||
|
* Verbose error messages
|
||||||
|
They no longer report `..., expecting error or...' for states where
|
||||||
|
error recovery is possible.
|
||||||
|
|
||||||
|
* End token
|
||||||
|
Defaults to `$end' instead of `$'.
|
||||||
|
|
||||||
|
* Error recovery now conforms to documentation and to POSIX
|
||||||
|
When a Bison-generated parser encounters a syntax error, it now pops
|
||||||
|
the stack until it finds a state that allows shifting the error
|
||||||
|
token. Formerly, it popped the stack until it found a state that
|
||||||
|
allowed some non-error action other than a default reduction on the
|
||||||
|
error token. The new behavior has long been the documented behavior,
|
||||||
|
and has long been required by POSIX. For more details, please see
|
||||||
|
<http://mail.gnu.org/pipermail/bug-bison/2002-May/001452.html>.
|
||||||
|
|
||||||
|
* Traces
|
||||||
|
Popped tokens and nonterminals are now reported.
|
||||||
|
|
||||||
|
* Larger grammars
|
||||||
|
Larger grammars are now supported (larger token numbers, larger grammar
|
||||||
|
size (= sum of the LHS and RHS lengths), larger LALR tables).
|
||||||
|
Formerly, many of these numbers ran afoul of 16-bit limits;
|
||||||
|
now these limits are 32 bits on most hosts.
|
||||||
|
|
||||||
|
* Explicit initial rule
|
||||||
|
Bison used to play hacks with the initial rule, which the user does
|
||||||
|
not write. It is now explicit, and visible in the reports and
|
||||||
|
graphs as rule 0.
|
||||||
|
|
||||||
|
* Useless rules
|
||||||
|
Before, Bison reported the useless rules, but, although not used,
|
||||||
|
included them in the parsers. They are now actually removed.
|
||||||
|
|
||||||
|
* Useless rules, useless nonterminals
|
||||||
|
They are now reported, as a warning, with their locations.
|
||||||
|
|
||||||
|
* Rules never reduced
|
||||||
|
Rules that can never be reduced because of conflicts are now
|
||||||
|
reported.
|
||||||
|
|
||||||
|
* Incorrect `Token not used'
|
||||||
|
On a grammar such as
|
||||||
|
|
||||||
|
%token useless useful
|
||||||
|
%%
|
||||||
|
exp: '0' %prec useful;
|
||||||
|
|
||||||
|
where a token was used to set the precedence of the last rule,
|
||||||
|
bison reported both `useful' and `useless' as useless tokens.
|
||||||
|
|
||||||
|
* Revert the C++ namespace changes introduced in 1.31
|
||||||
|
as they caused too many portability hassles.
|
||||||
|
|
||||||
|
* Default locations
|
||||||
|
By an accident of design, the default computation of @$ was
|
||||||
|
performed after another default computation was performed: @$ = @1.
|
||||||
|
The latter is now removed: YYLLOC_DEFAULT is fully responsible of
|
||||||
|
the computation of @$.
|
||||||
|
|
||||||
|
* Token end-of-file
|
||||||
|
The token end of file may be specified by the user, in which case,
|
||||||
|
the user symbol is used in the reports, the graphs, and the verbose
|
||||||
|
error messages instead of `$end', which remains being the default.
|
||||||
|
For instance
|
||||||
|
%token MYEOF 0
|
||||||
|
or
|
||||||
|
%token MYEOF 0 "end of file"
|
||||||
|
|
||||||
|
* Semantic parser
|
||||||
|
This old option, which has been broken for ages, is removed.
|
||||||
|
|
||||||
|
* New translations
|
||||||
|
Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
|
||||||
|
Croatian, thanks to Denis Lackovic.
|
||||||
|
|
||||||
|
* Incorrect token definitions
|
||||||
|
When given `%token 'a' "A"', Bison used to output `#define 'a' 65'.
|
||||||
|
|
||||||
|
* Token definitions as enums
|
||||||
|
Tokens are output both as the traditional #define's, and, provided
|
||||||
|
the compiler supports ANSI C or is a C++ compiler, as enums.
|
||||||
|
This lets debuggers display names instead of integers.
|
||||||
|
|
||||||
|
* Reports
|
||||||
|
In addition to --verbose, bison supports --report=THINGS, which
|
||||||
|
produces additional information:
|
||||||
|
- itemset
|
||||||
|
complete the core item sets with their closure
|
||||||
|
- lookahead
|
||||||
|
explicitly associate lookaheads to items
|
||||||
|
- solved
|
||||||
|
describe shift/reduce conflicts solving.
|
||||||
|
Bison used to systematically output this information on top of
|
||||||
|
the report. Solved conflicts are now attached to their states.
|
||||||
|
|
||||||
|
* Type clashes
|
||||||
|
Previous versions don't complain when there is a type clash on
|
||||||
|
the default action if the rule has a mid-rule action, such as in:
|
||||||
|
|
||||||
|
%type <foo> bar
|
||||||
|
%%
|
||||||
|
bar: '0' {} '0';
|
||||||
|
|
||||||
|
This is fixed.
|
||||||
|
|
||||||
|
* GNU M4 is now required when using Bison.
|
||||||
|
|
||||||
|
Changes in version 1.35, 2002-03-25:
|
||||||
|
|
||||||
|
* C Skeleton
|
||||||
|
Some projects use Bison's C parser with C++ compilers, and define
|
||||||
|
YYSTYPE as a class. The recent adjustment of C parsers for data
|
||||||
|
alignment and 64 bit architectures made this impossible.
|
||||||
|
|
||||||
|
Because for the time being no real solution for C++ parser
|
||||||
|
generation exists, kludges were implemented in the parser to
|
||||||
|
maintain this use. In the future, when Bison has C++ parsers, this
|
||||||
|
kludge will be disabled.
|
||||||
|
|
||||||
|
This kludge also addresses some C++ problems when the stack was
|
||||||
|
extended.
|
||||||
|
|
||||||
|
Changes in version 1.34, 2002-03-12:
|
||||||
|
|
||||||
|
* File name clashes are detected
|
||||||
|
$ bison foo.y -d -o foo.x
|
||||||
|
fatal error: header and parser would both be named `foo.x'
|
||||||
|
|
||||||
|
* A missing `;' at the end of a rule triggers a warning
|
||||||
|
In accordance with POSIX, and in agreement with other
|
||||||
|
Yacc implementations, Bison will mandate this semicolon in the near
|
||||||
|
future. This eases the implementation of a Bison parser of Bison
|
||||||
|
grammars by making this grammar LALR(1) instead of LR(2). To
|
||||||
|
facilitate the transition, this release introduces a warning.
|
||||||
|
|
||||||
|
* Revert the C++ namespace changes introduced in 1.31, as they caused too
|
||||||
|
many portability hassles.
|
||||||
|
|
||||||
|
* DJGPP support added.
|
||||||
|
|
||||||
|
* Fix test suite portability problems.
|
||||||
|
|
||||||
|
Changes in version 1.33, 2002-02-07:
|
||||||
|
|
||||||
|
* Fix C++ issues
|
||||||
|
Groff could not be compiled for the definition of size_t was lacking
|
||||||
|
under some conditions.
|
||||||
|
|
||||||
|
* Catch invalid @n
|
||||||
|
As is done with $n.
|
||||||
|
|
||||||
|
Changes in version 1.32, 2002-01-23:
|
||||||
|
|
||||||
|
* Fix Yacc output file names
|
||||||
|
|
||||||
|
* Portability fixes
|
||||||
|
|
||||||
|
* Italian, Dutch translations
|
||||||
|
|
||||||
|
Changes in version 1.31, 2002-01-14:
|
||||||
|
|
||||||
|
* Many Bug Fixes
|
||||||
|
|
||||||
|
* GNU Gettext and %expect
|
||||||
|
GNU Gettext asserts 10 s/r conflicts, but there are 7. Now that
|
||||||
|
Bison dies on incorrect %expectations, we fear there will be
|
||||||
|
too many bug reports for Gettext, so _for the time being_, %expect
|
||||||
|
does not trigger an error when the input file is named `plural.y'.
|
||||||
|
|
||||||
|
* Use of alloca in parsers
|
||||||
|
If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
|
||||||
|
malloc exclusively. Since 1.29, but was not NEWS'ed.
|
||||||
|
|
||||||
|
alloca is used only when compiled with GCC, to avoid portability
|
||||||
|
problems as on AIX.
|
||||||
|
|
||||||
|
* When the generated parser lacks debugging code, YYDEBUG is now 0
|
||||||
|
(as POSIX requires) instead of being undefined.
|
||||||
|
|
||||||
|
* User Actions
|
||||||
|
Bison has always permitted actions such as { $$ = $1 }: it adds the
|
||||||
|
ending semicolon. Now if in Yacc compatibility mode, the semicolon
|
||||||
|
is no longer output: one has to write { $$ = $1; }.
|
||||||
|
|
||||||
|
* Better C++ compliance
|
||||||
|
The output parsers try to respect C++ namespaces.
|
||||||
|
[This turned out to be a failed experiment, and it was reverted later.]
|
||||||
|
|
||||||
|
* Reduced Grammars
|
||||||
|
Fixed bugs when reporting useless nonterminals.
|
||||||
|
|
||||||
|
* 64 bit hosts
|
||||||
|
The parsers work properly on 64 bit hosts.
|
||||||
|
|
||||||
|
* Error messages
|
||||||
|
Some calls to strerror resulted in scrambled or missing error messages.
|
||||||
|
|
||||||
|
* %expect
|
||||||
|
When the number of shift/reduce conflicts is correct, don't issue
|
||||||
|
any warning.
|
||||||
|
|
||||||
|
* The verbose report includes the rule line numbers.
|
||||||
|
|
||||||
|
* Rule line numbers are fixed in traces.
|
||||||
|
|
||||||
|
* Swedish translation
|
||||||
|
|
||||||
|
* Parse errors
|
||||||
|
Verbose parse error messages from the parsers are better looking.
|
||||||
|
Before: parse error: unexpected `'/'', expecting `"number"' or `'-'' or `'(''
|
||||||
|
Now: parse error: unexpected '/', expecting "number" or '-' or '('
|
||||||
|
|
||||||
|
* Fixed parser memory leaks.
|
||||||
|
When the generated parser was using malloc to extend its stacks, the
|
||||||
|
previous allocations were not freed.
|
||||||
|
|
||||||
|
* Fixed verbose output file.
|
||||||
|
Some newlines were missing.
|
||||||
|
Some conflicts in state descriptions were missing.
|
||||||
|
|
||||||
|
* Fixed conflict report.
|
||||||
|
Option -v was needed to get the result.
|
||||||
|
|
||||||
|
* %expect
|
||||||
|
Was not used.
|
||||||
|
Mismatches are errors, not warnings.
|
||||||
|
|
||||||
|
* Fixed incorrect processing of some invalid input.
|
||||||
|
|
||||||
|
* Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
|
||||||
|
|
||||||
|
* Fixed some typos in the documentation.
|
||||||
|
|
||||||
|
* %token MY_EOF 0 is supported.
|
||||||
|
Before, MY_EOF was silently renumbered as 257.
|
||||||
|
|
||||||
|
* doc/refcard.tex is updated.
|
||||||
|
|
||||||
|
* %output, %file-prefix, %name-prefix.
|
||||||
|
New.
|
||||||
|
|
||||||
|
* --output
|
||||||
|
New, aliasing `--output-file'.
|
||||||
|
|
||||||
|
Changes in version 1.30, 2001-10-26:
|
||||||
|
|
||||||
|
* `--defines' and `--graph' have now an optional argument which is the
|
||||||
|
output file name. `-d' and `-g' do not change; they do not take any
|
||||||
argument.
|
argument.
|
||||||
|
|
||||||
* `%source_extension' and `%header_extension' are removed, failed
|
* `%source_extension' and `%header_extension' are removed, failed
|
||||||
experiment.
|
experiment.
|
||||||
|
|
||||||
* The test suite is more portable.
|
* Portability fixes.
|
||||||
|
|
||||||
* Better portability.
|
Changes in version 1.29, 2001-09-07:
|
||||||
|
|
||||||
Changes in version 1.29:
|
|
||||||
|
|
||||||
* The output file does not define const, as this caused problems when used
|
* The output file does not define const, as this caused problems when used
|
||||||
with common autoconfiguration schemes. If you still use ancient compilers
|
with common autoconfiguration schemes. If you still use ancient compilers
|
||||||
@@ -45,8 +444,11 @@ Changes in version 1.29:
|
|||||||
* New directives.
|
* New directives.
|
||||||
`%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose',
|
`%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose',
|
||||||
`%debug', `%source_extension' and `%header_extension'.
|
`%debug', `%source_extension' and `%header_extension'.
|
||||||
|
|
||||||
|
* @$
|
||||||
|
Automatic location tracking.
|
||||||
|
|
||||||
Changes in version 1.28:
|
Changes in version 1.28, 1999-07-06:
|
||||||
|
|
||||||
* Should compile better now with K&R compilers.
|
* Should compile better now with K&R compilers.
|
||||||
|
|
||||||
@@ -78,7 +480,7 @@ Changes in version 1.26:
|
|||||||
* Generated parsers should now work even on operating systems which do
|
* Generated parsers should now work even on operating systems which do
|
||||||
not provide alloca().
|
not provide alloca().
|
||||||
|
|
||||||
Changes in version 1.25:
|
Changes in version 1.25, 1995-10-16:
|
||||||
|
|
||||||
* Errors in the input grammar are not fatal; Bison keeps reading
|
* Errors in the input grammar are not fatal; Bison keeps reading
|
||||||
the grammar file, and reports all the errors found in it.
|
the grammar file, and reports all the errors found in it.
|
||||||
@@ -119,3 +521,29 @@ Changes in version 1.22:
|
|||||||
Changes in version 1.20:
|
Changes in version 1.20:
|
||||||
|
|
||||||
Output file does not redefine const for C++.
|
Output file does not redefine const for C++.
|
||||||
|
|
||||||
|
Local Variables:
|
||||||
|
mode: outline
|
||||||
|
End:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with autoconf; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
|||||||
@@ -15,3 +15,24 @@ 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
|
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
|
panicked users. We don't have time to spend on this, and nor do the
|
||||||
users.
|
users.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
GNU Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
|||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
-*- outline -*-
|
||||||
|
|
||||||
|
These notes intend to help people working on the CVS versions of
|
||||||
|
Bison.
|
||||||
|
|
||||||
|
* Requirements
|
||||||
|
|
||||||
|
Only the sources are installed in the CVS repository (to ease the
|
||||||
|
maintenance, merges etc.), therefore you will have to the maintainer
|
||||||
|
tools we depend upon:
|
||||||
|
|
||||||
|
- Automake 1.7
|
||||||
|
|
||||||
|
- Autoconf 2.54
|
||||||
|
|
||||||
|
- Gettext 0.11.5
|
||||||
|
|
||||||
|
Only building the initial full source tree will be a bit painful,
|
||||||
|
later, a plain `cvs update -P & make' should be sufficient.
|
||||||
|
|
||||||
|
* First CVS checkout
|
||||||
|
|
||||||
|
Obviously, if you are reading these notes, you did manage to check out
|
||||||
|
Bison from CVS. For the records, you will find all the relevant
|
||||||
|
information on:
|
||||||
|
|
||||||
|
http://savannah.gnu.org/cvs/?group_id=56
|
||||||
|
|
||||||
|
The next step is asking the installation of all the missing files:
|
||||||
|
|
||||||
|
$ ./bootstrap
|
||||||
|
|
||||||
|
And there you are! Just
|
||||||
|
|
||||||
|
$ ./configure && make && make check
|
||||||
|
|
||||||
|
At this point, there should be no difference between your local copy,
|
||||||
|
and the CVS master copy:
|
||||||
|
|
||||||
|
$ cvs diff
|
||||||
|
|
||||||
|
should output no difference, except maybe the date in po/*.po files.
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
* Troubleshooting
|
||||||
|
|
||||||
|
Unfortunately the current Gettext still does not include all the
|
||||||
|
needed tools so that the bootstrapping always perform successfully.
|
||||||
|
|
||||||
|
If you experience problems, I suggest the following:
|
||||||
|
|
||||||
|
1. Do a regular CVS checkout
|
||||||
|
|
||||||
|
2. Fetch a recent tarball in:
|
||||||
|
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.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
GNU Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
@@ -1,27 +1,68 @@
|
|||||||
Bison was originally written by Robert Corbett. It would not be what
|
Bison was originally written by Robert Corbett. It would not be what
|
||||||
it is today without the invaluable help of these people:
|
it is today without the invaluable help of these people:
|
||||||
|
|
||||||
Akim Demaille akim@epita.fr
|
Airy Andre Airy.Andre@edf.fr
|
||||||
|
Akim Demaille [email protected]
|
||||||
Albert Chin-A-Young [email protected]
|
Albert Chin-A-Young [email protected]
|
||||||
Alexander Belopolsky [email protected]
|
Alexander Belopolsky [email protected]
|
||||||
|
Andreas Schwab [email protected]
|
||||||
|
Arnold Robbins [email protected]
|
||||||
|
Art Haas [email protected]
|
||||||
|
Benoit Perrot [email protected]
|
||||||
|
Bert Deknuydt [email protected]
|
||||||
|
Bruce Lilly [email protected]
|
||||||
|
Charles-Henri de Boysson [email protected]
|
||||||
|
Cris Bailiff [email protected]
|
||||||
|
Cris van Pelt [email protected]
|
||||||
Daniel Hagerty [email protected]
|
Daniel Hagerty [email protected]
|
||||||
David J. MacKenzie [email protected]
|
David J. MacKenzie [email protected]
|
||||||
|
Dick Streefland [email protected]
|
||||||
|
Enrico Scholz [email protected]
|
||||||
|
Evgeny Stambulchik [email protected]
|
||||||
Fabrice Bauzac [email protected]
|
Fabrice Bauzac [email protected]
|
||||||
|
Florian Krohm [email protected]
|
||||||
|
H. Merijn Brand [email protected]
|
||||||
Hans Aberg [email protected]
|
Hans Aberg [email protected]
|
||||||
|
Jan Nieuwenhuizen [email protected]
|
||||||
Jesse Thilo [email protected]
|
Jesse Thilo [email protected]
|
||||||
Jim Meyering [email protected]
|
Jim Kent [email protected]
|
||||||
|
Jim Meyering [email protected]
|
||||||
Juan Manuel Guerrero [email protected]
|
Juan Manuel Guerrero [email protected]
|
||||||
|
Kees Zeelenberg [email protected]
|
||||||
Keith Browne [email protected]
|
Keith Browne [email protected]
|
||||||
Laurent Mascherpa [email protected]
|
Laurent Mascherpa [email protected]
|
||||||
|
Magnus Fromreide [email protected]
|
||||||
Marc Autret [email protected]
|
Marc Autret [email protected]
|
||||||
|
Martin Mokrejs [email protected]
|
||||||
|
Matt Kraai [email protected]
|
||||||
|
Matt Rosing [email protected]
|
||||||
|
Michael Hayes [email protected]
|
||||||
|
Mike Castle [email protected]
|
||||||
Neil Booth [email protected]
|
Neil Booth [email protected]
|
||||||
|
Nelson H. F. Beebe [email protected]
|
||||||
|
Nicolas Burrus [email protected]
|
||||||
|
Nicolas Tisserand [email protected]
|
||||||
Noah Friedman [email protected]
|
Noah Friedman [email protected]
|
||||||
Pascal Bart [email protected]
|
Pascal Bart [email protected]
|
||||||
Paul Eggert [email protected]
|
Paul Eggert [email protected]
|
||||||
|
Paul Hilfinger [email protected]
|
||||||
|
Per Allansson [email protected]
|
||||||
|
Peter Hámorský [email protected]
|
||||||
Piotr Gackiewicz [email protected]
|
Piotr Gackiewicz [email protected]
|
||||||
|
Quoc Peyrot [email protected]
|
||||||
|
R Blake [email protected]
|
||||||
|
Raja R Harinath [email protected]
|
||||||
Richard Stallman [email protected]
|
Richard Stallman [email protected]
|
||||||
Robert Anisko [email protected]
|
Robert Anisko [email protected]
|
||||||
Shura [email protected]
|
Shura [email protected]
|
||||||
|
Tim Josling [email protected]
|
||||||
|
Tim Van Holder [email protected]
|
||||||
|
Tom Lane [email protected]
|
||||||
|
Tom Tromey [email protected]
|
||||||
|
Wayne Green [email protected]
|
||||||
|
Wolfram Wagner [email protected]
|
||||||
|
Wwp [email protected]
|
||||||
|
Zack Weinberg [email protected]
|
||||||
|
|
||||||
Many people are not named here because we lost track of them. We
|
Many people are not named here because we lost track of them. We
|
||||||
thank them! Please, help us keeping this list up to date.
|
thank them! Please, help us keeping this list up to date.
|
||||||
|
|||||||
@@ -1,28 +1,344 @@
|
|||||||
-*- outline -*-
|
-*- outline -*-
|
||||||
|
|
||||||
* src/reader.c
|
* Header guards
|
||||||
Complete parse_skel_decl () with parse_dquoted_param (). []
|
|
||||||
Check and cleanup for CPP-out code. []
|
|
||||||
|
|
||||||
* src/output.c
|
From Franc,ois: should we keep the directory part in the CPP guard?
|
||||||
Synchronize `#line' directive with user file. [ok]
|
|
||||||
|
|
||||||
Cleanup dirty CPP-out code. []
|
|
||||||
** Output sub-skeleton files. []
|
|
||||||
Useful for %no_parser. []
|
|
||||||
*** New skeleton. []
|
|
||||||
|
|
||||||
* src/getargs.c src/lex.c
|
* Yacc.c: CPP Macros
|
||||||
Synchronize percent and command line options. [ok]
|
|
||||||
|
|
||||||
* src/macrotab.[ch]
|
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
|
||||||
Removing warnings when compiling. (gcc-warnings). [ok]
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
* GLR & C++
|
||||||
|
Currently, the GLR parser cannot compile with a C++ compiler.
|
||||||
|
|
||||||
|
|
||||||
|
* Report
|
||||||
|
|
||||||
|
** GLR
|
||||||
|
How would Paul like to display the conflicted actions? In particular,
|
||||||
|
what when two reductions are possible on a given lookahead, but one is
|
||||||
|
part of $default. Should we make the two reductions explicit, or just
|
||||||
|
keep $default? See the following point.
|
||||||
|
|
||||||
|
** Disabled Reductions
|
||||||
|
See `tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
|
||||||
|
what we want to do.
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
Extend with error productions. The hard part will probably be finding
|
||||||
|
the right rule so that a single state does not exhibit too many yet
|
||||||
|
undocumented ``features''. Maybe an empty action ought to be
|
||||||
|
presented too. Shall we try to make a single grammar with all these
|
||||||
|
features, or should we have several very small grammars?
|
||||||
|
|
||||||
|
** --report=conflict-path
|
||||||
|
Provide better assistance for understanding the conflicts by providing
|
||||||
|
a sample text exhibiting the (LALR) ambiguity. See the paper from
|
||||||
|
DeRemer and Penello: they already provide the algorithm.
|
||||||
|
|
||||||
|
|
||||||
|
* Extensions
|
||||||
|
|
||||||
|
** %destructor
|
||||||
|
I think we should document it as experimental, and allow its use in
|
||||||
|
the next releases. But we also need to port it to GLR. What about
|
||||||
|
lalr1.cc? Well, read what Hans reported, maybe we don't want
|
||||||
|
%detructor. On the other hand, there is no reason not to provide it:
|
||||||
|
users can avoid its use.
|
||||||
|
|
||||||
|
** $foo
|
||||||
|
Have a look at the Lemon parser generator: instead of $1, $2 etc. they
|
||||||
|
can name the values. This is much more pleasant. For instance:
|
||||||
|
|
||||||
|
exp (res): exp (a) '+' exp (b) { $res = $a + $b; };
|
||||||
|
|
||||||
|
I love this. I have been bitten too often by the removal of the
|
||||||
|
symbol, and forgetting to shift all the $n to $n-1. If you are
|
||||||
|
unlucky, it compiles...
|
||||||
|
|
||||||
|
** $-1
|
||||||
|
We should find a means to provide an access to values deep in the
|
||||||
|
stack. For instance, instead of
|
||||||
|
|
||||||
|
baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
|
||||||
|
|
||||||
|
we should be able to have:
|
||||||
|
|
||||||
|
foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
|
||||||
|
|
||||||
|
Or something like this.
|
||||||
|
|
||||||
|
|
||||||
|
** yysymprint interface
|
||||||
|
It should be improved, in particular when using Bison features such as
|
||||||
|
locations, and YYPARSE_PARAMS. For the time being, it is almost
|
||||||
|
recommended to yyprint to steal internal variables...
|
||||||
|
|
||||||
|
** Several %unions
|
||||||
|
I think this is a pleasant (but useless currently) feature, but in the
|
||||||
|
future, I want a means to %include other bits of grammars, and _then_
|
||||||
|
it will be important for the various bits to define their needs in
|
||||||
|
%union.
|
||||||
|
|
||||||
|
When implementing multiple-%union support, bare the following in mind:
|
||||||
|
|
||||||
|
- when --yacc, this must be flagged as an error. Don't make it fatal
|
||||||
|
though.
|
||||||
|
|
||||||
|
- The #line must now appear *inside* the definition of yystype.
|
||||||
|
Something like
|
||||||
|
|
||||||
|
{
|
||||||
|
#line 12 "foo.y"
|
||||||
|
int ival;
|
||||||
|
#line 23 "foo.y"
|
||||||
|
char *sval;
|
||||||
|
}
|
||||||
|
|
||||||
|
** %if and the like
|
||||||
|
It should be possible to have %if/%else/%endif. The implementation is
|
||||||
|
not clear: should it be lexical or syntactic. Vadim Maslow thinks it
|
||||||
|
must be in the scanner: we must not parse what is in a switched off
|
||||||
|
part of %if. Akim Demaille thinks it should be in the parser, so as
|
||||||
|
to avoid falling into another CPP mistake.
|
||||||
|
|
||||||
|
** -D, --define-muscle NAME=VALUE
|
||||||
|
To define muscles via cli. Or maybe support directly NAME=VALUE?
|
||||||
|
|
||||||
|
|
||||||
|
* Unit rules
|
||||||
|
Maybe we could expand unit rules, i.e., transform
|
||||||
|
|
||||||
|
exp: arith | bool;
|
||||||
|
arith: exp '+' exp;
|
||||||
|
bool: exp '&' exp;
|
||||||
|
|
||||||
|
into
|
||||||
|
|
||||||
|
exp: exp '+' exp | exp '&' exp;
|
||||||
|
|
||||||
|
when there are no actions. This can significantly speed up some
|
||||||
|
grammars. I can't find the papers. In particular the book `LR
|
||||||
|
parsing: Theory and Practice' is impossible to find, but according to
|
||||||
|
`Parsing Techniques: a Practical Guide', it includes information about
|
||||||
|
this issue. Does anybody have it?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Documentation
|
||||||
|
|
||||||
|
** History/Bibliography
|
||||||
|
Some history of Bison and some bibliography would be most welcome.
|
||||||
|
Are there any Texinfo standards for bibliography?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Java, Fortran, etc.
|
||||||
|
|
||||||
|
|
||||||
|
** Java
|
||||||
|
|
||||||
|
There are a couple of proposed outputs:
|
||||||
|
|
||||||
|
- BYACC/J
|
||||||
|
which is based on Byacc.
|
||||||
|
<http://troi.lincom-asg.com/~rjamison/byacc/>
|
||||||
|
|
||||||
|
- Bison Java
|
||||||
|
which is based on Bison.
|
||||||
|
<http://www.goice.co.jp/member/mo/hack-progs/bison-java.html>
|
||||||
|
|
||||||
|
Sébastien Serrurier ([email protected]) is working on this: he is
|
||||||
|
expected to contact the authors, design the output, and implement it
|
||||||
|
into Bison.
|
||||||
|
|
||||||
|
|
||||||
|
* Coding system independence
|
||||||
|
Paul notes:
|
||||||
|
|
||||||
|
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
|
||||||
|
255). It also assumes that the 8-bit character encoding is
|
||||||
|
the same for the invocation of 'bison' as it is for the
|
||||||
|
invocation of 'cc', but this is not necessarily true when
|
||||||
|
people run bison on an ASCII host and then use cc on an EBCDIC
|
||||||
|
host. I don't think these topics are worth our time
|
||||||
|
addressing (unless we find a gung-ho volunteer for EBCDIC or
|
||||||
|
PDP-10 ports :-) but they should probably be documented
|
||||||
|
somewhere.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* --graph
|
||||||
|
Show reductions. []
|
||||||
|
|
||||||
|
* Broken options ?
|
||||||
|
** %no-parser []
|
||||||
|
** %token-table []
|
||||||
|
** Skeleton strategy. []
|
||||||
|
Must we keep %no-parser?
|
||||||
|
%token-table?
|
||||||
|
|
||||||
* src/print_graph.c
|
* src/print_graph.c
|
||||||
Find the best graph parameters. []
|
Find the best graph parameters. []
|
||||||
|
|
||||||
* doc/bison.texinfo
|
* doc/bison.texinfo
|
||||||
Echo modifications of prologue and epilogue. []
|
** Update
|
||||||
Add informations about YYERROR_VERBOSE. []
|
informations about ERROR_VERBOSE. []
|
||||||
Add explainations about skeleton muscles. []
|
** Add explanations about
|
||||||
Add explainations about %skeleton. []
|
skeleton muscles. []
|
||||||
|
%skeleton. []
|
||||||
|
|
||||||
|
* testsuite
|
||||||
|
** tests/pure-parser.at []
|
||||||
|
New tests.
|
||||||
|
|
||||||
|
* BTYacc
|
||||||
|
See if we can integrate backtracking in Bison. Charles-Henri de
|
||||||
|
Boysson <[email protected]> is working on this, and already has some
|
||||||
|
results. Vadim Maslow, the maintainer of BTYacc was contacted, and we
|
||||||
|
stay in touch with him. Adjusting the Bison grammar parser will be
|
||||||
|
needed to support some extra BTYacc features. This is less urgent.
|
||||||
|
|
||||||
|
** Keeping the conflicted actions
|
||||||
|
First, analyze the differences between byacc and btyacc (I'm referring
|
||||||
|
to the executables). Find where the conflicts are preserved.
|
||||||
|
|
||||||
|
** Compare with the GLR tables
|
||||||
|
See how isomorphic the way BTYacc and the way the GLR adjustments in
|
||||||
|
Bison are compatible. *As much as possible* one should try to use the
|
||||||
|
same implementation in the Bison executables. I insist: it should be
|
||||||
|
very feasible to use the very same conflict tables.
|
||||||
|
|
||||||
|
** Adjust the skeletons
|
||||||
|
Import the skeletons for C and C++.
|
||||||
|
|
||||||
|
** Improve the skeletons
|
||||||
|
Have them support yysymprint, yydestruct and so forth.
|
||||||
|
|
||||||
|
|
||||||
|
* Precedence
|
||||||
|
|
||||||
|
** Partial order
|
||||||
|
It is unfortunate that there is a total order for precedence. It
|
||||||
|
makes it impossible to have modular precedence information. We should
|
||||||
|
move to partial orders (sounds like series/parallel orders to me).
|
||||||
|
|
||||||
|
This will be possible with a Bison parser for the grammar, as it will
|
||||||
|
make it much easier to extend the grammar.
|
||||||
|
|
||||||
|
** Correlation b/w precedence and associativity
|
||||||
|
Also, I fail to understand why we have to assign the same
|
||||||
|
associativity to operators with the same precedence. For instance,
|
||||||
|
why can't I decide that the precedence of * and / is the same, but the
|
||||||
|
latter is nonassoc?
|
||||||
|
|
||||||
|
If there is really no profound motivation, we should find a new syntax
|
||||||
|
to allow specifying this.
|
||||||
|
|
||||||
|
** RR conflicts
|
||||||
|
See if we can use precedence between rules to solve RR conflicts. See
|
||||||
|
what POSIX says.
|
||||||
|
|
||||||
|
|
||||||
|
* $undefined
|
||||||
|
From Hans:
|
||||||
|
- If the Bison generated parser experiences an undefined number in the
|
||||||
|
character range, that character is written out in diagnostic messages, an
|
||||||
|
addition to the $undefined value.
|
||||||
|
|
||||||
|
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
||||||
|
|
||||||
|
|
||||||
|
* Default Action
|
||||||
|
From Hans:
|
||||||
|
- For use with my C++ parser, I transported the "switch (yyn)" statement
|
||||||
|
that Bison writes to the bison.simple skeleton file. This way, I can remove
|
||||||
|
the current default rule $$ = $1 implementation, which causes a double
|
||||||
|
assignment to $$ which may not be OK under C++, replacing it with a
|
||||||
|
"default:" part within the switch statement.
|
||||||
|
|
||||||
|
Note that the default rule $$ = $1, when typed, is perfectly OK under C,
|
||||||
|
but in the C++ implementation I made, this rule is different from
|
||||||
|
$<type_name>$ = $<type_name>1. I therefore think that one should implement
|
||||||
|
a Bison option where every typed default rule is explicitly written out
|
||||||
|
(same typed ruled can of course be grouped together).
|
||||||
|
|
||||||
|
Note: Robert Anisko handles this. He knows how to do it.
|
||||||
|
|
||||||
|
|
||||||
|
* Warnings
|
||||||
|
It would be nice to have warning support. See how Autoconf handles
|
||||||
|
them, it is fairly well described there. It would be very nice to
|
||||||
|
implement this in such a way that other programs could use
|
||||||
|
lib/warnings.[ch].
|
||||||
|
|
||||||
|
Don't work on this without first announcing you do, as I already have
|
||||||
|
thought about it, and know many of the components that can be used to
|
||||||
|
implement it.
|
||||||
|
|
||||||
|
|
||||||
|
* Pre and post actions.
|
||||||
|
From: Florian Krohm <[email protected]>
|
||||||
|
Subject: YYACT_EPILOGUE
|
||||||
|
To: [email protected]
|
||||||
|
X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
|
||||||
|
|
||||||
|
The other day I had the need for explicitly building the parse tree. I
|
||||||
|
used %locations for that and defined YYLLOC_DEFAULT to call a function
|
||||||
|
that returns the tree node for the production. Easy. But I also needed
|
||||||
|
to assign the S-attribute to the tree node. That cannot be done in
|
||||||
|
YYLLOC_DEFAULT, because it is invoked before the action is executed.
|
||||||
|
The way I solved this was to define a macro YYACT_EPILOGUE that would
|
||||||
|
be invoked after the action. For reasons of symmetry I also added
|
||||||
|
YYACT_PROLOGUE. Although I had no use for that I can envision how it
|
||||||
|
might come in handy for debugging purposes.
|
||||||
|
All is needed is to add
|
||||||
|
|
||||||
|
#if YYLSP_NEEDED
|
||||||
|
YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
|
||||||
|
#else
|
||||||
|
YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
|
||||||
|
|
||||||
|
I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
|
||||||
|
to bison. If you're interested, I'll work on a patch.
|
||||||
|
|
||||||
|
* Move to Graphviz
|
||||||
|
Well, VCG seems really dead. Move to Graphviz instead. Also, equip
|
||||||
|
the parser with a means to create the (visual) parse tree.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
GNU Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
echo "Bootstrapping CVS Bison..."
|
||||||
|
|
||||||
|
echo "running: autoreconf --verbose --install --force"
|
||||||
|
autoreconf --verbose --install --force
|
||||||
+292
@@ -0,0 +1,292 @@
|
|||||||
|
/* config.hin. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||||
|
systems. This function is required for `alloca.c' support on those systems.
|
||||||
|
*/
|
||||||
|
#undef CRAY_STACKSEG_END
|
||||||
|
|
||||||
|
/* Define if using `alloca.c'. */
|
||||||
|
#undef C_ALLOCA
|
||||||
|
|
||||||
|
/* Define to 1 if translation of program messages to the user's native
|
||||||
|
language is requested. */
|
||||||
|
#undef ENABLE_NLS
|
||||||
|
|
||||||
|
/* Define if you have `alloca', as a function or macro. */
|
||||||
|
#undef HAVE_ALLOCA
|
||||||
|
|
||||||
|
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||||
|
#undef HAVE_ALLOCA_H
|
||||||
|
|
||||||
|
/* Define if you have the <argz.h> header file. */
|
||||||
|
#undef HAVE_ARGZ_H
|
||||||
|
|
||||||
|
/* Define if you have the <ctype.h> header file. */
|
||||||
|
#undef HAVE_CTYPE_H
|
||||||
|
|
||||||
|
/* Define if backslash-a works in C strings. */
|
||||||
|
#undef HAVE_C_BACKSLASH_A
|
||||||
|
|
||||||
|
/* Define if you have the `dcgettext' function. */
|
||||||
|
#undef HAVE_DCGETTEXT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `memchr', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#undef HAVE_DECL_MEMCHR
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#undef HAVE_DECL_STPCPY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_STRERROR_R
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strndup', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_STRNDUP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_STRNLEN
|
||||||
|
|
||||||
|
/* Define if the malloc check has been performed. */
|
||||||
|
#undef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||||
|
|
||||||
|
/* Define if the realloc check has been performed. */
|
||||||
|
#undef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||||
|
|
||||||
|
/* Define if you have the `doprnt' function. */
|
||||||
|
#undef HAVE_DOPRNT
|
||||||
|
|
||||||
|
/* Define if you have the `feof_unlocked' function. */
|
||||||
|
#undef HAVE_FEOF_UNLOCKED
|
||||||
|
|
||||||
|
/* Define if you have the `fgets_unlocked' function. */
|
||||||
|
#undef HAVE_FGETS_UNLOCKED
|
||||||
|
|
||||||
|
/* Define if you have the `getcwd' function. */
|
||||||
|
#undef HAVE_GETCWD
|
||||||
|
|
||||||
|
/* Define if you have the `getegid' function. */
|
||||||
|
#undef HAVE_GETEGID
|
||||||
|
|
||||||
|
/* Define if you have the `geteuid' function. */
|
||||||
|
#undef HAVE_GETEUID
|
||||||
|
|
||||||
|
/* Define if you have the `getgid' function. */
|
||||||
|
#undef HAVE_GETGID
|
||||||
|
|
||||||
|
/* Define if you have the `getpagesize' function. */
|
||||||
|
#undef HAVE_GETPAGESIZE
|
||||||
|
|
||||||
|
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||||
|
#undef HAVE_GETTEXT
|
||||||
|
|
||||||
|
/* Define if you have the `getuid' function. */
|
||||||
|
#undef HAVE_GETUID
|
||||||
|
|
||||||
|
/* Define if you have the iconv() function. */
|
||||||
|
#undef HAVE_ICONV
|
||||||
|
|
||||||
|
/* Define if you have the <inttypes.h> header file. */
|
||||||
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define if you have the `isascii' function. */
|
||||||
|
#undef HAVE_ISASCII
|
||||||
|
|
||||||
|
/* Define if you have the `iswprint' function. */
|
||||||
|
#undef HAVE_ISWPRINT
|
||||||
|
|
||||||
|
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||||
|
#undef HAVE_LANGINFO_CODESET
|
||||||
|
|
||||||
|
/* Define if your <locale.h> file defines LC_MESSAGES. */
|
||||||
|
#undef HAVE_LC_MESSAGES
|
||||||
|
|
||||||
|
/* Define if you have the <limits.h> header file. */
|
||||||
|
#undef HAVE_LIMITS_H
|
||||||
|
|
||||||
|
/* Define if you have the <locale.h> header file. */
|
||||||
|
#undef HAVE_LOCALE_H
|
||||||
|
|
||||||
|
/* Define if you have the <malloc.h> header file. */
|
||||||
|
#undef HAVE_MALLOC_H
|
||||||
|
|
||||||
|
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
|
||||||
|
#undef HAVE_MBRTOWC
|
||||||
|
|
||||||
|
/* Define if you have the `mbsinit' function. */
|
||||||
|
#undef HAVE_MBSINIT
|
||||||
|
|
||||||
|
/* Define if you have the `memchr' function. */
|
||||||
|
#undef HAVE_MEMCHR
|
||||||
|
|
||||||
|
/* Define if you have the <memory.h> header file. */
|
||||||
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define if you have the `mempcpy' function. */
|
||||||
|
#undef HAVE_MEMPCPY
|
||||||
|
|
||||||
|
/* Define if you have the `mkstemp' function. */
|
||||||
|
#undef HAVE_MKSTEMP
|
||||||
|
|
||||||
|
/* Define if you have a working `mmap' system call. */
|
||||||
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
|
/* Define if you have the `munmap' function. */
|
||||||
|
#undef HAVE_MUNMAP
|
||||||
|
|
||||||
|
/* Define if you have the <nl_types.h> header file. */
|
||||||
|
#undef HAVE_NL_TYPES_H
|
||||||
|
|
||||||
|
/* Define if you have the `putenv' function. */
|
||||||
|
#undef HAVE_PUTENV
|
||||||
|
|
||||||
|
/* Define if you have the `setenv' function. */
|
||||||
|
#undef HAVE_SETENV
|
||||||
|
|
||||||
|
/* Define if you have the `setlocale' function. */
|
||||||
|
#undef HAVE_SETLOCALE
|
||||||
|
|
||||||
|
/* Define if you have the <stddef.h> header file. */
|
||||||
|
#undef HAVE_STDDEF_H
|
||||||
|
|
||||||
|
/* Define if you have the <stdint.h> header file. */
|
||||||
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* Define if you have the <stdlib.h> header file. */
|
||||||
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
|
/* Define if you have the `stpcpy' function. */
|
||||||
|
#undef HAVE_STPCPY
|
||||||
|
|
||||||
|
/* Define if you have the `strcasecmp' function. */
|
||||||
|
#undef HAVE_STRCASECMP
|
||||||
|
|
||||||
|
/* Define if you have the `strchr' function. */
|
||||||
|
#undef HAVE_STRCHR
|
||||||
|
|
||||||
|
/* Define if you have the `strdup' function. */
|
||||||
|
#undef HAVE_STRDUP
|
||||||
|
|
||||||
|
/* Define if you have the `strerror' function. */
|
||||||
|
#undef HAVE_STRERROR
|
||||||
|
|
||||||
|
/* Define if you have the `strerror_r' function. */
|
||||||
|
#undef HAVE_STRERROR_R
|
||||||
|
|
||||||
|
/* Define if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define if you have the <string.h> header file. */
|
||||||
|
#undef HAVE_STRING_H
|
||||||
|
|
||||||
|
/* Define if you have the `strndup' function. */
|
||||||
|
#undef HAVE_STRNDUP
|
||||||
|
|
||||||
|
/* Define if you have the `strnlen' function. */
|
||||||
|
#undef HAVE_STRNLEN
|
||||||
|
|
||||||
|
/* Define if you have the `strspn' function. */
|
||||||
|
#undef HAVE_STRSPN
|
||||||
|
|
||||||
|
/* Define if you have the `strtoul' function. */
|
||||||
|
#undef HAVE_STRTOUL
|
||||||
|
|
||||||
|
/* Define if you have the <sys/param.h> header file. */
|
||||||
|
#undef HAVE_SYS_PARAM_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/types.h> header file. */
|
||||||
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define if you have the `tsearch' function. */
|
||||||
|
#undef HAVE_TSEARCH
|
||||||
|
|
||||||
|
/* Define if you have the <unistd.h> header file. */
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define if you have the `vprintf' function. */
|
||||||
|
#undef HAVE_VPRINTF
|
||||||
|
|
||||||
|
/* Define if you have the <wchar.h> header file. */
|
||||||
|
#undef HAVE_WCHAR_H
|
||||||
|
|
||||||
|
/* Define if you have the <wctype.h> header file. */
|
||||||
|
#undef HAVE_WCTYPE_H
|
||||||
|
|
||||||
|
/* Define to 1 if `strerror_r' returns a string. */
|
||||||
|
#undef HAVE_WORKING_STRERROR_R
|
||||||
|
|
||||||
|
/* Define if you have the `__argz_count' function. */
|
||||||
|
#undef HAVE___ARGZ_COUNT
|
||||||
|
|
||||||
|
/* Define if you have the `__argz_next' function. */
|
||||||
|
#undef HAVE___ARGZ_NEXT
|
||||||
|
|
||||||
|
/* Define if you have the `__argz_stringify' function. */
|
||||||
|
#undef HAVE___ARGZ_STRINGIFY
|
||||||
|
|
||||||
|
/* Define as const if the declaration of iconv() needs const. */
|
||||||
|
#undef ICONV_CONST
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#undef PACKAGE
|
||||||
|
|
||||||
|
/* Define if compiler has function prototypes */
|
||||||
|
#undef PROTOTYPES
|
||||||
|
|
||||||
|
/* If using the C implementation of alloca, define 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 */
|
||||||
|
#undef STACK_DIRECTION
|
||||||
|
|
||||||
|
/* Define if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#undef VERSION
|
||||||
|
|
||||||
|
/* Define if using the dmalloc debugging malloc package */
|
||||||
|
#undef WITH_DMALLOC
|
||||||
|
|
||||||
|
/* Define to 1 for GNU C library extensions. */
|
||||||
|
#undef _GNU_SOURCE
|
||||||
|
|
||||||
|
/* Define if on MINIX. */
|
||||||
|
#undef _MINIX
|
||||||
|
|
||||||
|
/* Define if the system does not provide POSIX.1 features except with this
|
||||||
|
defined. */
|
||||||
|
#undef _POSIX_1_SOURCE
|
||||||
|
|
||||||
|
/* Define if you need to in order for `stat' and other things to work. */
|
||||||
|
#undef _POSIX_SOURCE
|
||||||
|
|
||||||
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
#undef const
|
||||||
|
|
||||||
|
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
|
||||||
|
if it is not supported. */
|
||||||
|
#undef inline
|
||||||
|
|
||||||
|
/* Define to rpl_malloc if the replacement function should be used. */
|
||||||
|
#undef malloc
|
||||||
|
|
||||||
|
/* Define to a type if <wchar.h> does not define. */
|
||||||
|
#undef mbstate_t
|
||||||
|
|
||||||
|
/* Define to `long' if <sys/types.h> does not define. */
|
||||||
|
#undef off_t
|
||||||
|
|
||||||
|
/* Define to rpl_realloc if the replacement function should be used. */
|
||||||
|
#undef realloc
|
||||||
|
|
||||||
|
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||||
|
#undef size_t
|
||||||
@@ -1,2 +1,11 @@
|
|||||||
Makefile
|
Makefile
|
||||||
*.t
|
*.t
|
||||||
|
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-*-
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
EXTRA_DIST = move-if-change prev-version.txt
|
EXTRA_DIST = move-if-change prev-version.txt config.rpath
|
||||||
|
|||||||
+87
-75
@@ -31,7 +31,16 @@ if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
|||||||
fi
|
fi
|
||||||
# `libtool' can also be set to `yes' or `no'.
|
# `libtool' can also be set to `yes' or `no'.
|
||||||
|
|
||||||
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
|
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/'`}
|
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||||
|
|
||||||
rm -f "$tmpdepfile"
|
rm -f "$tmpdepfile"
|
||||||
@@ -198,17 +207,22 @@ aix)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
tru64)
|
tru64)
|
||||||
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
|
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
# 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
|
# 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.
|
# dependencies in `foo.d' instead, so we check for that too.
|
||||||
# Subdirectories are respected.
|
# 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$//'`
|
||||||
|
|
||||||
tmpdepfile1="$object.d"
|
|
||||||
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
|
|
||||||
if test "$libtool" = yes; then
|
if test "$libtool" = yes; then
|
||||||
|
tmpdepfile1="$dir.libs/$base.lo.d"
|
||||||
|
tmpdepfile2="$dir.libs/$base.d"
|
||||||
"$@" -Wc,-MD
|
"$@" -Wc,-MD
|
||||||
else
|
else
|
||||||
|
tmpdepfile1="$dir$base.o.d"
|
||||||
|
tmpdepfile2="$dir$base.d"
|
||||||
"$@" -MD
|
"$@" -MD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -240,34 +254,40 @@ tru64)
|
|||||||
|
|
||||||
dashmstdout)
|
dashmstdout)
|
||||||
# Important note: in order to support this mode, a compiler *must*
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
# always write the proprocessed file to stdout, regardless of -o,
|
# always write the proprocessed file to stdout, regardless of -o.
|
||||||
# because we must use -o when running libtool.
|
"$@" || exit $?
|
||||||
test -z "$dashmflag" && dashmflag=-M
|
|
||||||
( IFS=" "
|
# Remove the call to Libtool.
|
||||||
case " $* " in
|
if test "$libtool" = yes; then
|
||||||
*" --mode=compile "*) # this is libtool, let us make it quiet
|
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
|
for arg
|
||||||
do # cycle over the arguments
|
do
|
||||||
case "$arg" in
|
case $arg in
|
||||||
"--mode=compile")
|
-o)
|
||||||
# insert --quiet before "--mode=compile"
|
shift
|
||||||
set fnord "$@" --quiet
|
|
||||||
shift # fnord
|
|
||||||
;;
|
;;
|
||||||
esac
|
$object)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
set fnord "$@" "$arg"
|
set fnord "$@" "$arg"
|
||||||
shift # fnord
|
shift # fnord
|
||||||
shift # "$arg"
|
shift # $arg
|
||||||
done
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
done
|
||||||
) &
|
|
||||||
proc=$!
|
test -z "$dashmflag" && dashmflag=-M
|
||||||
"$@"
|
"$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||||
stat=$?
|
|
||||||
wait "$proc"
|
|
||||||
if test "$stat" != 0; then exit $stat; fi
|
|
||||||
rm -f "$depfile"
|
rm -f "$depfile"
|
||||||
cat < "$tmpdepfile" > "$depfile"
|
cat < "$tmpdepfile" > "$depfile"
|
||||||
tr ' ' '
|
tr ' ' '
|
||||||
@@ -285,14 +305,15 @@ dashXmstdout)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
makedepend)
|
makedepend)
|
||||||
|
"$@" || exit $?
|
||||||
# X makedepend
|
# X makedepend
|
||||||
(
|
|
||||||
shift
|
shift
|
||||||
cleared=no
|
cleared=no
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case $cleared in no)
|
case $cleared in
|
||||||
|
no)
|
||||||
set ""; shift
|
set ""; shift
|
||||||
cleared=yes
|
cleared=yes ;;
|
||||||
esac
|
esac
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
-D*|-I*)
|
-D*|-I*)
|
||||||
@@ -305,16 +326,10 @@ makedepend)
|
|||||||
done
|
done
|
||||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||||
touch "$tmpdepfile"
|
touch "$tmpdepfile"
|
||||||
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||||
) &
|
|
||||||
proc=$!
|
|
||||||
"$@"
|
|
||||||
stat=$?
|
|
||||||
wait "$proc"
|
|
||||||
if test "$stat" != 0; then exit $stat; fi
|
|
||||||
rm -f "$depfile"
|
rm -f "$depfile"
|
||||||
cat < "$tmpdepfile" > "$depfile"
|
cat < "$tmpdepfile" > "$depfile"
|
||||||
tail +3 "$tmpdepfile" | tr ' ' '
|
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||||
' | \
|
' | \
|
||||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
## correctly. Breaking it into two sed invocations is a workaround.
|
## correctly. Breaking it into two sed invocations is a workaround.
|
||||||
@@ -324,35 +339,39 @@ makedepend)
|
|||||||
|
|
||||||
cpp)
|
cpp)
|
||||||
# Important note: in order to support this mode, a compiler *must*
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
# always write the proprocessed file to stdout, regardless of -o,
|
# always write the proprocessed file to stdout.
|
||||||
# because we must use -o when running libtool.
|
"$@" || exit $?
|
||||||
( IFS=" "
|
|
||||||
case " $* " in
|
# Remove the call to Libtool.
|
||||||
*" --mode=compile "*)
|
if test "$libtool" = yes; then
|
||||||
|
while test $1 != '--mode=compile'; do
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove `-o $object'.
|
||||||
|
IFS=" "
|
||||||
for arg
|
for arg
|
||||||
do # cycle over the arguments
|
do
|
||||||
case $arg in
|
case $arg in
|
||||||
"--mode=compile")
|
-o)
|
||||||
# insert --quiet before "--mode=compile"
|
shift
|
||||||
set fnord "$@" --quiet
|
|
||||||
shift # fnord
|
|
||||||
;;
|
;;
|
||||||
esac
|
$object)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
set fnord "$@" "$arg"
|
set fnord "$@" "$arg"
|
||||||
shift # fnord
|
shift # fnord
|
||||||
shift # "$arg"
|
shift # $arg
|
||||||
done
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
"$@" -E |
|
"$@" -E |
|
||||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||||
sed '$ s: \\$::' > "$tmpdepfile"
|
sed '$ s: \\$::' > "$tmpdepfile"
|
||||||
) &
|
|
||||||
proc=$!
|
|
||||||
"$@"
|
|
||||||
stat=$?
|
|
||||||
wait "$proc"
|
|
||||||
if test "$stat" != 0; then exit $stat; fi
|
|
||||||
rm -f "$depfile"
|
rm -f "$depfile"
|
||||||
echo "$object : \\" > "$depfile"
|
echo "$object : \\" > "$depfile"
|
||||||
cat < "$tmpdepfile" >> "$depfile"
|
cat < "$tmpdepfile" >> "$depfile"
|
||||||
@@ -364,32 +383,25 @@ msvisualcpp)
|
|||||||
# Important note: in order to support this mode, a compiler *must*
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
# always write the proprocessed file to stdout, regardless of -o,
|
# always write the proprocessed file to stdout, regardless of -o,
|
||||||
# because we must use -o when running libtool.
|
# because we must use -o when running libtool.
|
||||||
( IFS=" "
|
"$@" || exit $?
|
||||||
case " $* " in
|
IFS=" "
|
||||||
*" --mode=compile "*)
|
|
||||||
for arg
|
for arg
|
||||||
do # cycle over the arguments
|
do
|
||||||
case $arg in
|
case "$arg" in
|
||||||
"--mode=compile")
|
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||||
# insert --quiet before "--mode=compile"
|
set fnord "$@"
|
||||||
set fnord "$@" --quiet
|
shift
|
||||||
shift # fnord
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
*)
|
||||||
set fnord "$@" "$arg"
|
set fnord "$@" "$arg"
|
||||||
shift # fnord
|
shift
|
||||||
shift # "$arg"
|
shift
|
||||||
done
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
"$@" -E |
|
"$@" -E |
|
||||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||||
) &
|
|
||||||
proc=$!
|
|
||||||
"$@"
|
|
||||||
stat=$?
|
|
||||||
wait "$proc"
|
|
||||||
if test "$stat" != 0; then exit $stat; fi
|
|
||||||
rm -f "$depfile"
|
rm -f "$depfile"
|
||||||
echo "$object : \\" > "$depfile"
|
echo "$object : \\" > "$depfile"
|
||||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||||
|
|||||||
+69
-44
@@ -56,7 +56,7 @@ dir_arg=""
|
|||||||
|
|
||||||
while [ x"$1" != x ]; do
|
while [ x"$1" != x ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-c) instcmd="$cpprog"
|
-c) instcmd=$cpprog
|
||||||
shift
|
shift
|
||||||
continue;;
|
continue;;
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ while [ x"$1" != x ]; do
|
|||||||
shift
|
shift
|
||||||
continue;;
|
continue;;
|
||||||
|
|
||||||
-s) stripcmd="$stripprog"
|
-s) stripcmd=$stripprog
|
||||||
shift
|
shift
|
||||||
continue;;
|
continue;;
|
||||||
|
|
||||||
@@ -106,21 +106,21 @@ done
|
|||||||
|
|
||||||
if [ x"$src" = x ]
|
if [ x"$src" = x ]
|
||||||
then
|
then
|
||||||
echo "install: no input file specified"
|
echo "$0: no input file specified" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
true
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$dir_arg" != x ]; then
|
if [ x"$dir_arg" != x ]; then
|
||||||
dst=$src
|
dst=$src
|
||||||
src=""
|
src=""
|
||||||
|
|
||||||
if [ -d $dst ]; then
|
if [ -d "$dst" ]; then
|
||||||
instcmd=:
|
instcmd=:
|
||||||
chmodcmd=""
|
chmodcmd=""
|
||||||
else
|
else
|
||||||
instcmd=mkdir
|
instcmd=$mkdirprog
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -128,35 +128,35 @@ else
|
|||||||
# might cause directories to be created, which would be especially bad
|
# might cause directories to be created, which would be especially bad
|
||||||
# if $src (and thus $dsttmp) contains '*'.
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
|
||||||
if [ -f $src -o -d $src ]
|
if [ -f "$src" ] || [ -d "$src" ]
|
||||||
then
|
then
|
||||||
true
|
:
|
||||||
else
|
else
|
||||||
echo "install: $src does not exist"
|
echo "$0: $src does not exist" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$dst" = x ]
|
if [ x"$dst" = x ]
|
||||||
then
|
then
|
||||||
echo "install: no destination specified"
|
echo "$0: no destination specified" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
true
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If destination is a directory, append the input filename; if your system
|
# 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
|
# does not like double slashes in filenames, you may need to add some logic
|
||||||
|
|
||||||
if [ -d $dst ]
|
if [ -d "$dst" ]
|
||||||
then
|
then
|
||||||
dst="$dst"/`basename $src`
|
dst=$dst/`basename "$src"`
|
||||||
else
|
else
|
||||||
true
|
:
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## this sed command emulates the dirname command
|
## this sed command emulates the dirname command
|
||||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||||
|
|
||||||
# Make sure that the destination directory exists.
|
# Make sure that the destination directory exists.
|
||||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||||
@@ -165,48 +165,48 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
|||||||
if [ ! -d "$dstdir" ]; then
|
if [ ! -d "$dstdir" ]; then
|
||||||
defaultIFS='
|
defaultIFS='
|
||||||
'
|
'
|
||||||
IFS="${IFS-${defaultIFS}}"
|
IFS="${IFS-$defaultIFS}"
|
||||||
|
|
||||||
oIFS="${IFS}"
|
oIFS=$IFS
|
||||||
# Some sh's can't handle IFS=/ for some reason.
|
# Some sh's can't handle IFS=/ for some reason.
|
||||||
IFS='%'
|
IFS='%'
|
||||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||||
IFS="${oIFS}"
|
IFS=$oIFS
|
||||||
|
|
||||||
pathcomp=''
|
pathcomp=''
|
||||||
|
|
||||||
while [ $# -ne 0 ] ; do
|
while [ $# -ne 0 ] ; do
|
||||||
pathcomp="${pathcomp}${1}"
|
pathcomp=$pathcomp$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ ! -d "${pathcomp}" ] ;
|
if [ ! -d "$pathcomp" ] ;
|
||||||
then
|
then
|
||||||
$mkdirprog "${pathcomp}"
|
$mkdirprog "$pathcomp"
|
||||||
else
|
else
|
||||||
true
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pathcomp="${pathcomp}/"
|
pathcomp=$pathcomp/
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$dir_arg" != x ]
|
if [ x"$dir_arg" != x ]
|
||||||
then
|
then
|
||||||
$doit $instcmd $dst &&
|
$doit $instcmd "$dst" &&
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
|
||||||
else
|
else
|
||||||
|
|
||||||
# If we're going to rename the final executable, determine the name now.
|
# If we're going to rename the final executable, determine the name now.
|
||||||
|
|
||||||
if [ x"$transformarg" = x ]
|
if [ x"$transformarg" = x ]
|
||||||
then
|
then
|
||||||
dstfile=`basename $dst`
|
dstfile=`basename "$dst"`
|
||||||
else
|
else
|
||||||
dstfile=`basename $dst $transformbasename |
|
dstfile=`basename "$dst" $transformbasename |
|
||||||
sed $transformarg`$transformbasename
|
sed $transformarg`$transformbasename
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -214,20 +214,24 @@ else
|
|||||||
|
|
||||||
if [ x"$dstfile" = x ]
|
if [ x"$dstfile" = x ]
|
||||||
then
|
then
|
||||||
dstfile=`basename $dst`
|
dstfile=`basename "$dst"`
|
||||||
else
|
else
|
||||||
true
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make a temp file name in the proper directory.
|
# Make a couple of temp file names in the proper directory.
|
||||||
|
|
||||||
dsttmp=$dstdir/#inst.$$#
|
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
|
# Move or copy the file name to the temp name
|
||||||
|
|
||||||
$doit $instcmd $src $dsttmp &&
|
$doit $instcmd "$src" "$dsttmp" &&
|
||||||
|
|
||||||
trap "rm -f ${dsttmp}" 0 &&
|
|
||||||
|
|
||||||
# and set any options; do chmod last to preserve setuid bits
|
# and set any options; do chmod last to preserve setuid bits
|
||||||
|
|
||||||
@@ -235,17 +239,38 @@ else
|
|||||||
# ignore errors from any of these, just make sure not to ignore
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;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.
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
|
||||||
|
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||||
|
|
||||||
exit 0
|
{
|
||||||
|
(exit 0); exit
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Get modification time of a file or directory and pretty-print it.
|
|
||||||
# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
|
||||||
# written by Ulrich Drepper <[email protected]>, June 1995
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Prevent date giving response in another language.
|
|
||||||
LANG=C
|
|
||||||
export LANG
|
|
||||||
LC_ALL=C
|
|
||||||
export LC_ALL
|
|
||||||
LC_TIME=C
|
|
||||||
export LC_TIME
|
|
||||||
|
|
||||||
# Get the extended ls output of the file or directory.
|
|
||||||
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
|
|
||||||
if ls -L /dev/null 1>/dev/null 2>&1; then
|
|
||||||
set - x`ls -L -l -d $1`
|
|
||||||
else
|
|
||||||
set - x`ls -l -d $1`
|
|
||||||
fi
|
|
||||||
# The month is at least the fourth argument
|
|
||||||
# (3 shifts here, the next inside the loop).
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
|
|
||||||
# Find the month. Next argument is day, followed by the year or time.
|
|
||||||
month=
|
|
||||||
until test $month
|
|
||||||
do
|
|
||||||
shift
|
|
||||||
case $1 in
|
|
||||||
Jan) month=January; nummonth=1;;
|
|
||||||
Feb) month=February; nummonth=2;;
|
|
||||||
Mar) month=March; nummonth=3;;
|
|
||||||
Apr) month=April; nummonth=4;;
|
|
||||||
May) month=May; nummonth=5;;
|
|
||||||
Jun) month=June; nummonth=6;;
|
|
||||||
Jul) month=July; nummonth=7;;
|
|
||||||
Aug) month=August; nummonth=8;;
|
|
||||||
Sep) month=September; nummonth=9;;
|
|
||||||
Oct) month=October; nummonth=10;;
|
|
||||||
Nov) month=November; nummonth=11;;
|
|
||||||
Dec) month=December; nummonth=12;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
day=$2
|
|
||||||
|
|
||||||
# Here we have to deal with the problem that the ls output gives either
|
|
||||||
# the time of day or the year.
|
|
||||||
case $3 in
|
|
||||||
*:*) set `date`; eval year=\$$#
|
|
||||||
case $2 in
|
|
||||||
Jan) nummonthtod=1;;
|
|
||||||
Feb) nummonthtod=2;;
|
|
||||||
Mar) nummonthtod=3;;
|
|
||||||
Apr) nummonthtod=4;;
|
|
||||||
May) nummonthtod=5;;
|
|
||||||
Jun) nummonthtod=6;;
|
|
||||||
Jul) nummonthtod=7;;
|
|
||||||
Aug) nummonthtod=8;;
|
|
||||||
Sep) nummonthtod=9;;
|
|
||||||
Oct) nummonthtod=10;;
|
|
||||||
Nov) nummonthtod=11;;
|
|
||||||
Dec) nummonthtod=12;;
|
|
||||||
esac
|
|
||||||
# For the first six month of the year the time notation can also
|
|
||||||
# be used for files modified in the last year.
|
|
||||||
if (expr $nummonth \> $nummonthtod) > /dev/null;
|
|
||||||
then
|
|
||||||
year=`expr $year - 1`
|
|
||||||
fi;;
|
|
||||||
*) year=$3;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# The result.
|
|
||||||
echo $day $month $year
|
|
||||||
@@ -1 +1 @@
|
|||||||
1.29c
|
1.75
|
||||||
|
|||||||
-6288
File diff suppressed because it is too large
Load Diff
+62
-43
@@ -1,5 +1,7 @@
|
|||||||
# Configure template for GNU Bison. -*-Autoconf-*-
|
# Configure template for GNU Bison. -*-Autoconf-*-
|
||||||
#
|
#
|
||||||
|
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
@@ -16,31 +18,21 @@
|
|||||||
# 02111-1307 USA
|
# 02111-1307 USA
|
||||||
|
|
||||||
# We need a recent Autoconf to run a recent Autotest.
|
# We need a recent Autoconf to run a recent Autotest.
|
||||||
AC_PREREQ(2.52e)
|
AC_PREREQ(2.54)
|
||||||
|
|
||||||
AC_INIT([GNU Bison], [1.29d], [[email protected]])
|
AC_INIT([GNU Bison], [1.875], [[email protected]])
|
||||||
AC_CONFIG_AUX_DIR(config)
|
AC_CONFIG_AUX_DIR(config)
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([bison], [1.29d])
|
AM_INIT_AUTOMAKE([1.7 check-news readme-alpha dist-bzip2])
|
||||||
AM_CONFIG_HEADER(config.h:config.hin)
|
AC_CONFIG_HEADERS([config.h:config.hin])
|
||||||
|
|
||||||
# Initialize the test suite.
|
# Checks for the compiler.
|
||||||
AC_CONFIG_TESTDIR(tests)
|
|
||||||
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
|
||||||
|
|
||||||
# Checks for programs.
|
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_MINIX
|
# Remove with Automake 1.8.
|
||||||
AC_ISC_POSIX
|
AC_ISC_POSIX
|
||||||
|
AC_GNU_SOURCE
|
||||||
|
AC_MINIX
|
||||||
AM_PROG_CC_STDC
|
AM_PROG_CC_STDC
|
||||||
AC_PROG_RANLIB
|
|
||||||
# GNU M4 is needed to build the testsuite.
|
|
||||||
BISON_AC_PROG_GNU_M4
|
|
||||||
if test "$ac_cv_prog_gnu_m4" != yes; then
|
|
||||||
missing_dir=`cd $ac_aux_dir && pwd`
|
|
||||||
M4="$missing_dir/missing m4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(gcc-warnings,
|
AC_ARG_ENABLE(gcc-warnings,
|
||||||
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended)],
|
[ --enable-gcc-warnings turn on lots of GCC warnings (not recommended)],
|
||||||
[case "${enableval}" in
|
[case "${enableval}" in
|
||||||
@@ -49,6 +41,9 @@ AC_ARG_ENABLE(gcc-warnings,
|
|||||||
esac],
|
esac],
|
||||||
[enableval=no])
|
[enableval=no])
|
||||||
if test "${enableval}" = yes; then
|
if test "${enableval}" = yes; then
|
||||||
|
BISON_WARNING(-Werror)
|
||||||
|
AC_SUBST([WERROR_CFLAGS], [$WARNING_CFLAGS])
|
||||||
|
WARNING_CFLAGS=
|
||||||
BISON_WARNING(-Wall)
|
BISON_WARNING(-Wall)
|
||||||
BISON_WARNING(-W)
|
BISON_WARNING(-W)
|
||||||
BISON_WARNING(-Wbad-function-cast)
|
BISON_WARNING(-Wbad-function-cast)
|
||||||
@@ -61,47 +56,71 @@ if test "${enableval}" = yes; then
|
|||||||
BISON_WARNING(-Wshadow)
|
BISON_WARNING(-Wshadow)
|
||||||
BISON_WARNING(-Wstrict-prototypes)
|
BISON_WARNING(-Wstrict-prototypes)
|
||||||
BISON_WARNING(-Wwrite-strings)
|
BISON_WARNING(-Wwrite-strings)
|
||||||
CFLAGS="$CFLAGS $WARNING_CFLAGS"
|
AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for programs.
|
||||||
AC_DEFINE([_GNU_SOURCE],1,[Define to 1 for GNU C library extensions.])
|
AC_PROG_LEX
|
||||||
|
AC_PROG_YACC
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
BISON_PROG_GNU_M4
|
||||||
|
if test x"$ac_cv_prog_gnu_m4" != xyes; then
|
||||||
|
AC_MSG_ERROR([GNU M4 1.4 is required])
|
||||||
|
fi
|
||||||
|
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(ctype.h locale.h memory.h stdlib.h string.h unistd.h)
|
AC_CHECK_HEADERS([ctype.h locale.h memory.h stdlib.h string.h unistd.h])
|
||||||
|
AC_HEADER_STDBOOL
|
||||||
# Checks for typedefs.
|
|
||||||
|
|
||||||
# Checks for structures.
|
|
||||||
|
|
||||||
# Checks for compiler characteristics.
|
# Checks for compiler characteristics.
|
||||||
AC_C_CONST
|
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
AM_C_PROTOTYPES
|
|
||||||
|
# Checks for types.
|
||||||
|
AC_CHECK_TYPES([uintptr_t])
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_CHECK_FUNCS(mkstemp setlocale)
|
AC_FUNC_OBSTACK
|
||||||
AC_CHECK_DECLS([stpcpy, strndup, strnlen, memchr])
|
AC_FUNC_ERROR_AT_LINE
|
||||||
AC_REPLACE_FUNCS(stpcpy strndup strnlen strspn memchr)
|
AC_FUNC_STRNLEN
|
||||||
jm_FUNC_MALLOC
|
AC_CHECK_FUNCS(setlocale)
|
||||||
jm_FUNC_REALLOC
|
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_PREREQ_QUOTEARG
|
||||||
|
jm_FUNC_ARGMATCH
|
||||||
jm_PREREQ_ERROR
|
jm_PREREQ_ERROR
|
||||||
AM_WITH_DMALLOC
|
AM_WITH_DMALLOC
|
||||||
|
BISON_PREREQ_SUBPIPE
|
||||||
|
BISON_PREREQ_TIMEVAR
|
||||||
|
|
||||||
ALL_LINGUAS="de es et fr ja nl tr ru"
|
# Gettext.
|
||||||
AM_GNU_GETTEXT
|
AM_GNU_GETTEXT(external, need-ngettext)
|
||||||
|
AM_GNU_GETTEXT_VERSION(0.11.5)
|
||||||
|
|
||||||
# This is necessary so that .o files in LIBOBJS are also built via
|
# Initialize the test suite.
|
||||||
# the ANSI2KNR-filtering rules.
|
AC_CONFIG_TESTDIR(tests)
|
||||||
LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
|
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
||||||
AC_SUBST(LIBOBJS)
|
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
|
||||||
|
AC_CHECK_PROGS([VALGRIND], [valgrind])
|
||||||
|
AC_CHECK_PROGS([GXX], [g++])
|
||||||
|
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||||
|
# Needed by tests/atlocal.in.
|
||||||
|
AC_SUBST([GCC])
|
||||||
|
O0CFLAGS=`echo $CFLAGS | sed 's/-O[0-9] *//'`
|
||||||
|
AC_SUBST([O0CFLAGS])
|
||||||
|
|
||||||
AC_OUTPUT([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
config/Makefile
|
config/Makefile
|
||||||
intl/Makefile po/Makefile.in
|
po/Makefile.in
|
||||||
|
data/Makefile
|
||||||
lib/Makefile src/Makefile doc/Makefile
|
lib/Makefile src/Makefile doc/Makefile
|
||||||
m4/Makefile
|
m4/Makefile])
|
||||||
tests/Makefile])
|
AC_OUTPUT
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
@echo off
|
|
||||||
echo Configuring bison for go32
|
|
||||||
rem This batch file assumes a unix-type "sed" program
|
|
||||||
|
|
||||||
echo # Makefile generated by "configure.bat"> Makefile
|
|
||||||
echo all.dos : bison >> Makefile
|
|
||||||
|
|
||||||
if exist config.sed del config.sed
|
|
||||||
|
|
||||||
echo "s/@srcdir@/./g ">> config.sed
|
|
||||||
echo "s/@CC@/gcc/g ">> config.sed
|
|
||||||
echo "s/@INSTALL@//g ">> config.sed
|
|
||||||
echo "s/@INSTALL_PROGRAM@//g ">> config.sed
|
|
||||||
echo "s/@INSTALL_DATA@//g ">> config.sed
|
|
||||||
echo "s/@DEFS@/-DHAVE_STRERROR/g ">> config.sed
|
|
||||||
echo "s/@LIBS@//g ">> config.sed
|
|
||||||
echo "s/@ALLOCA@//g ">> config.sed
|
|
||||||
|
|
||||||
echo "/^bison[ ]*:/,/-o/ { ">> config.sed
|
|
||||||
echo " s/ \$(CC)/ >bison.rf/ ">> config.sed
|
|
||||||
echo " /-o/ a\ ">> config.sed
|
|
||||||
echo " $(CC) @bison.rf ">> config.sed
|
|
||||||
echo "} ">> config.sed
|
|
||||||
|
|
||||||
sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed
|
|
||||||
sed -f config2.sed Makefile.in >> Makefile
|
|
||||||
del config.sed
|
|
||||||
del config2.sed
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Makefile.in
|
||||||
|
Makefile
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
## Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## 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
|
||||||
|
|
||||||
|
dist_pkgdata_DATA = README c.m4 yacc.c lalr1.cc glr.c
|
||||||
|
|
||||||
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
|
dist_m4sugar_DATA = m4sugar/m4sugar.m4
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
-*- outline -*-
|
||||||
|
|
||||||
|
This directory contains Bison skeletons: the general shapes of the
|
||||||
|
different parser kinds, that are specialized for specific grammars by
|
||||||
|
the bison program.
|
||||||
|
|
||||||
|
Currently, there are only three supported skeletons:
|
||||||
|
|
||||||
|
- yacc.c
|
||||||
|
It used to be named bison.simple: it corresponds to C Yacc
|
||||||
|
compatible LALR(1) parsers.
|
||||||
|
|
||||||
|
- lalr1.cc
|
||||||
|
Produces a C++ parser class. It is still very experimental, and not
|
||||||
|
yet supported. Please, subscribe to [email protected].
|
||||||
|
|
||||||
|
- glr.c
|
||||||
|
A Generalized LR C parser based on Bison's LALR(1) tables.
|
||||||
|
|
||||||
|
These skeletons are the only ones supported by the Bison team.
|
||||||
|
Because the interface between skeletons and the bison program is not
|
||||||
|
finished, *we are not bound to it*. In particular, Bison is not
|
||||||
|
mature enough for us to consider that ``foreign skeletons'' are
|
||||||
|
supported.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Bison.
|
||||||
|
|
||||||
|
GNU Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
GNU Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
@@ -0,0 +1,412 @@
|
|||||||
|
m4_divert(-1) -*- Autoconf -*-
|
||||||
|
|
||||||
|
# C M4 Macros for Bison.
|
||||||
|
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
# 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Identification. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# b4_copyright(TITLE, YEARS)
|
||||||
|
# --------------------------
|
||||||
|
m4_define([b4_copyright],
|
||||||
|
[/* A Bison parser, made by GNU Bison b4_version. */
|
||||||
|
|
||||||
|
/* $1,
|
||||||
|
Copyright (C) $2 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_identification
|
||||||
|
# -----------------
|
||||||
|
m4_define([b4_identification],
|
||||||
|
[/* Identify Bison output. */
|
||||||
|
[#]define YYBISON 1
|
||||||
|
|
||||||
|
/* Skeleton name. */
|
||||||
|
[#]define YYSKELETON_NAME b4_skeleton
|
||||||
|
|
||||||
|
/* Pure parsers. */
|
||||||
|
[#]define YYPURE b4_pure
|
||||||
|
|
||||||
|
/* Using locations. */
|
||||||
|
[#]define YYLSP_NEEDED b4_locations_flag
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
m4_define_default([b4_epilogue], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------ ##
|
||||||
|
## Pure/impure interfaces. ##
|
||||||
|
## ------------------------ ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_user_args
|
||||||
|
# ------------
|
||||||
|
m4_define([b4_user_args],
|
||||||
|
[m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_parse_param
|
||||||
|
# --------------
|
||||||
|
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||||
|
# it to be single quoted.
|
||||||
|
m4_define_default([b4_parse_param])
|
||||||
|
m4_define([b4_parse_param],
|
||||||
|
b4_parse_param))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------ ##
|
||||||
|
## Data Types. ##
|
||||||
|
## ------------ ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
||||||
|
# ---------------------------------
|
||||||
|
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
||||||
|
m4_define([b4_ints_in],
|
||||||
|
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_int_type(MIN, MAX)
|
||||||
|
# ---------------------
|
||||||
|
# Return the smallest int type able to handle numbers ranging from
|
||||||
|
# MIN to MAX (included).
|
||||||
|
m4_define([b4_int_type],
|
||||||
|
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||||
|
b4_ints_in($@, [-128], [127]), [1], [signed char],
|
||||||
|
|
||||||
|
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
||||||
|
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||||
|
|
||||||
|
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||||
|
|
||||||
|
[int])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_int_type_for(NAME)
|
||||||
|
# ---------------------
|
||||||
|
# Return the smallest int type able to handle numbers ranging from
|
||||||
|
# `NAME_min' to `NAME_max' (included).
|
||||||
|
m4_define([b4_int_type_for],
|
||||||
|
[b4_int_type($1_min, $1_max)])
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------ ##
|
||||||
|
## Decoding options. ##
|
||||||
|
## ------------------ ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_location_if(IF-TRUE, IF-FALSE)
|
||||||
|
# ---------------------------------
|
||||||
|
# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
|
||||||
|
m4_define([b4_location_if],
|
||||||
|
[m4_if(b4_locations_flag, [1],
|
||||||
|
[$1],
|
||||||
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_pure_if(IF-TRUE, IF-FALSE)
|
||||||
|
# -----------------------------
|
||||||
|
# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
|
||||||
|
m4_define([b4_pure_if],
|
||||||
|
[m4_if(b4_pure, [1],
|
||||||
|
[$1],
|
||||||
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------- ##
|
||||||
|
## Assigning token numbers. ##
|
||||||
|
## ------------------------- ##
|
||||||
|
|
||||||
|
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
|
# -----------------------------------------
|
||||||
|
# Output the definition of this token as #define.
|
||||||
|
m4_define([b4_token_define],
|
||||||
|
[#define $1 $2
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
|
# ---------------------------------------
|
||||||
|
# Output the definition of this token as an enum.
|
||||||
|
m4_define([b4_token_enum],
|
||||||
|
[$1 = $2])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Output the definition of the tokens (if there are) as enums and #define.
|
||||||
|
m4_define([b4_token_defines],
|
||||||
|
[m4_if([$@], [[]], [],
|
||||||
|
[/* Tokens. */
|
||||||
|
#ifndef YYTOKENTYPE
|
||||||
|
# define YYTOKENTYPE
|
||||||
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
|
know about them. */
|
||||||
|
enum yytokentype {
|
||||||
|
m4_map_sep([ b4_token_enum], [,
|
||||||
|
],
|
||||||
|
[$@])
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
m4_map([b4_token_define], [$@])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------------------------------- ##
|
||||||
|
## Defining C functions in both K&R and ANSI-C. ##
|
||||||
|
## --------------------------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Declare the function NAME.
|
||||||
|
m4_define([b4_c_function_def],
|
||||||
|
[#if defined (__STDC__) || defined (__cplusplus)
|
||||||
|
b4_c_ansi_function_def($@)
|
||||||
|
#else
|
||||||
|
$2
|
||||||
|
$1 (b4_c_knr_formal_names(m4_shiftn(2, $@)))
|
||||||
|
b4_c_knr_formal_decls(m4_shiftn(2, $@))
|
||||||
|
#endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Declare the function NAME in ANSI.
|
||||||
|
m4_define([b4_c_ansi_function_def],
|
||||||
|
[$2
|
||||||
|
$1 (b4_c_ansi_formals(m4_shiftn(2, $@)))[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_formals([DECL1, NAME1], ...)
|
||||||
|
# --------------------------------------
|
||||||
|
# Output the arguments ANSI-C definition.
|
||||||
|
m4_define([b4_c_ansi_formals],
|
||||||
|
[m4_case([$@],
|
||||||
|
[], [void],
|
||||||
|
[[]], [void],
|
||||||
|
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||||
|
|
||||||
|
m4_define([b4_c_ansi_formal],
|
||||||
|
[$1])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_knr_formal_names([DECL1, NAME1], ...)
|
||||||
|
# ------------------------------------------
|
||||||
|
# Output the argument names.
|
||||||
|
m4_define([b4_c_knr_formal_names],
|
||||||
|
[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_knr_formal_name],
|
||||||
|
[$2])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_knr_formal_decls([DECL1, NAME1], ...)
|
||||||
|
# ------------------------------------------
|
||||||
|
# Output the K&R argument declarations.
|
||||||
|
m4_define([b4_c_knr_formal_decls],
|
||||||
|
[m4_map_sep([b4_c_knr_formal_decl],
|
||||||
|
[
|
||||||
|
],
|
||||||
|
[$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_knr_formal_decl],
|
||||||
|
[ $1;])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ------------------------------------------------------------ ##
|
||||||
|
## Declaring (prototyping) C functions in both K&R and ANSI-C. ##
|
||||||
|
## ------------------------------------------------------------ ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
# Declare the function NAME.
|
||||||
|
m4_define([b4_c_function_decl],
|
||||||
|
[#if defined (__STDC__) || defined (__cplusplus)
|
||||||
|
b4_c_ansi_function_decl($@)
|
||||||
|
#else
|
||||||
|
$2 $1 ();
|
||||||
|
#endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# Declare the function NAME.
|
||||||
|
m4_define([b4_c_ansi_function_decl],
|
||||||
|
[$2 $1 (b4_c_ansi_formals(m4_shiftn(2, $@)));[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------- ##
|
||||||
|
## Calling C functions. ##
|
||||||
|
## --------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
# Call the function NAME with arguments NAME1, NAME2 etc.
|
||||||
|
m4_define([b4_c_function_call],
|
||||||
|
[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_args([DECL1, NAME1], ...)
|
||||||
|
# ------------------------------
|
||||||
|
# Output the arguments NAME1, NAME2...
|
||||||
|
m4_define([b4_c_args],
|
||||||
|
[m4_map_sep([b4_c_arg], [, ], [$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_arg],
|
||||||
|
[$2])
|
||||||
|
|
||||||
|
|
||||||
|
## ----------- ##
|
||||||
|
## Synclines. ##
|
||||||
|
## ----------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_syncline(LINE, FILE)
|
||||||
|
# -----------------------
|
||||||
|
m4_define([b4_syncline],
|
||||||
|
[m4_if(b4_synclines_flag, 1,
|
||||||
|
[[#]line $1 $2])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_symbol_actions(FILENAME, LINENO,
|
||||||
|
# SYMBOL-TAG, SYMBOL-NUM,
|
||||||
|
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||||
|
# -------------------------------------------------
|
||||||
|
m4_define([b4_symbol_actions],
|
||||||
|
[m4_pushdef([b4_dollar_dollar], [yyvaluep->$6])dnl
|
||||||
|
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
||||||
|
case $4: /* $3 */
|
||||||
|
b4_syncline([$2], [$1])
|
||||||
|
$5;
|
||||||
|
b4_syncline([@oline@], [@ofile@])
|
||||||
|
break;
|
||||||
|
m4_popdef([b4_at_dollar])dnl
|
||||||
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Generate the "yydestruct" function, which declaration is issued using
|
||||||
|
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||||
|
# or "b4_c_function_def" for K&R.
|
||||||
|
m4_define([b4_yydestruct_generate],
|
||||||
|
[[/*-----------------------------------------------.
|
||||||
|
| Release the memory associated to this symbol. |
|
||||||
|
`-----------------------------------------------*/
|
||||||
|
|
||||||
|
]$1([yydestruct],
|
||||||
|
[static void],
|
||||||
|
[[int yytype], [yytype]],
|
||||||
|
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
||||||
|
[[YYLTYPE *yylocationp], [yylocationp]]]))[
|
||||||
|
{
|
||||||
|
/* Pacify ``unused variable'' warnings. */
|
||||||
|
(void) yyvaluep;
|
||||||
|
]b4_location_if([ (void) yylocationp;
|
||||||
|
])[
|
||||||
|
switch (yytype)
|
||||||
|
{
|
||||||
|
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_yysymprint_generate(FUNCTION-DECLARATOR)
|
||||||
|
# -------------------------------------------
|
||||||
|
# Generate the "yysymprint" function, which declaration is issued using
|
||||||
|
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||||
|
# or "b4_c_function_def" for K&R.
|
||||||
|
m4_define([b4_yysymprint_generate],
|
||||||
|
[[/*--------------------------------.
|
||||||
|
| Print this symbol on YYOUTPUT. |
|
||||||
|
`--------------------------------*/
|
||||||
|
|
||||||
|
]$1([yysymprint],
|
||||||
|
[static void],
|
||||||
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
|
[[int yytype], [yytype]],
|
||||||
|
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
||||||
|
[[YYLTYPE *yylocationp], [yylocationp]]]))
|
||||||
|
{
|
||||||
|
/* Pacify ``unused variable'' warnings. */
|
||||||
|
(void) yyvaluep;
|
||||||
|
b4_location_if([ (void) yylocationp;
|
||||||
|
])dnl
|
||||||
|
|
||||||
|
if (yytype < YYNTOKENS)
|
||||||
|
{
|
||||||
|
YYFPRINTF (yyoutput, "token %s (", yytname[[yytype]]);
|
||||||
|
# ifdef YYPRINT
|
||||||
|
YYPRINT (yyoutput, yytoknum[[yytype]], *yyvaluep);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
YYFPRINTF (yyoutput, "nterm %s (", yytname[[yytype]]);
|
||||||
|
|
||||||
|
switch (yytype)
|
||||||
|
{
|
||||||
|
m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
YYFPRINTF (yyoutput, ")");
|
||||||
|
}
|
||||||
|
])
|
||||||
+1985
File diff suppressed because it is too large
Load Diff
+883
@@ -0,0 +1,883 @@
|
|||||||
|
m4_divert(-1)
|
||||||
|
# C++ skeleton for Bison
|
||||||
|
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## ---------------- ##
|
||||||
|
## Default values. ##
|
||||||
|
## ---------------- ##
|
||||||
|
|
||||||
|
# Stack parameters.
|
||||||
|
m4_define_default([b4_stack_depth_init], [200])
|
||||||
|
|
||||||
|
# Default Parser class name.
|
||||||
|
m4_define_default([b4_parser_class_name], [Parser])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## 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],
|
||||||
|
[semantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3])])
|
||||||
|
|
||||||
|
m4_define_default([b4_location_type], [Location])
|
||||||
|
|
||||||
|
# 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],
|
||||||
|
[location_stack_@{m4_eval([$1 - $2])@}])
|
||||||
|
|
||||||
|
|
||||||
|
m4_define([b4_inherit],
|
||||||
|
[m4_ifdef([b4_root],
|
||||||
|
[: public b4_root
|
||||||
|
],
|
||||||
|
[])])
|
||||||
|
|
||||||
|
m4_define([b4_param],
|
||||||
|
[m4_ifdef([b4_root],
|
||||||
|
[,
|
||||||
|
const Param& param],
|
||||||
|
[])])
|
||||||
|
|
||||||
|
m4_define([b4_constructor],
|
||||||
|
[m4_ifdef([b4_root],
|
||||||
|
[b4_root (param),
|
||||||
|
],
|
||||||
|
[])])
|
||||||
|
|
||||||
|
|
||||||
|
# We do want M4 expansion after # for CPP macros.
|
||||||
|
m4_changecom()
|
||||||
|
m4_divert(0)dnl
|
||||||
|
@output @output_header_name@
|
||||||
|
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
||||||
|
[2002])[
|
||||||
|
/* FIXME: This is wrong, we want computed header guards.
|
||||||
|
I don't know why the macros are missing now. :( */
|
||||||
|
#ifndef PARSER_HEADER_H
|
||||||
|
# define PARSER_HEADER_H
|
||||||
|
|
||||||
|
#include "stack.hh"
|
||||||
|
#include "location.hh"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
/* Using locations. */
|
||||||
|
#define YYLSP_NEEDED ]b4_locations_flag[
|
||||||
|
|
||||||
|
]b4_token_defines(b4_tokens)[
|
||||||
|
|
||||||
|
/* Copy the first part of user declarations. */
|
||||||
|
]b4_pre_prologue[
|
||||||
|
|
||||||
|
]/* Line __line__ of lalr1.cc. */
|
||||||
|
b4_syncline([@oline@], [@ofile@])[
|
||||||
|
|
||||||
|
/* Enabling traces. */
|
||||||
|
#ifndef YYDEBUG
|
||||||
|
# define YYDEBUG ]b4_debug[
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enabling verbose error message. */
|
||||||
|
#ifndef YYERROR_VERBOSE
|
||||||
|
# define YYERROR_VERBOSE ]b4_error_verbose[
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YYSTYPE
|
||||||
|
]m4_ifdef([b4_stype],
|
||||||
|
[b4_syncline([b4_stype_line], [b4_filename])
|
||||||
|
typedef union b4_stype yystype;
|
||||||
|
/* Line __line__ of lalr1.cc. */
|
||||||
|
b4_syncline([@oline@], [@ofile@])],
|
||||||
|
[typedef int yystype;])[
|
||||||
|
# define YYSTYPE yystype
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Copy the second part of user declarations. */
|
||||||
|
]b4_post_prologue[
|
||||||
|
|
||||||
|
]/* Line __line__ of lalr1.cc. */
|
||||||
|
b4_syncline([@oline@], [@ofile@])[
|
||||||
|
#ifndef YYLLOC_DEFAULT
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
Current.last_line = Rhs[N].last_line; \
|
||||||
|
Current.last_column = Rhs[N].last_column;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace yy
|
||||||
|
{
|
||||||
|
class ]b4_parser_class_name[;
|
||||||
|
|
||||||
|
template < typename P >
|
||||||
|
struct Traits
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template < >
|
||||||
|
struct Traits< ]b4_parser_class_name[ >
|
||||||
|
{
|
||||||
|
typedef ]b4_int_type_for([b4_translate])[ TokenNumberType;
|
||||||
|
typedef ]b4_int_type_for([b4_rhs])[ RhsNumberType;
|
||||||
|
typedef int StateType;
|
||||||
|
typedef yystype SemanticType;
|
||||||
|
typedef ]b4_location_type[ LocationType;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace yy
|
||||||
|
{
|
||||||
|
class ]b4_parser_class_name b4_inherit[
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef Traits< ]b4_parser_class_name[ >::TokenNumberType TokenNumberType;
|
||||||
|
typedef Traits< ]b4_parser_class_name[ >::RhsNumberType RhsNumberType;
|
||||||
|
typedef Traits< ]b4_parser_class_name[ >::StateType StateType;
|
||||||
|
typedef Traits< ]b4_parser_class_name[ >::SemanticType SemanticType;
|
||||||
|
typedef Traits< ]b4_parser_class_name[ >::LocationType LocationType;
|
||||||
|
|
||||||
|
typedef Stack< StateType > StateStack;
|
||||||
|
typedef Stack< SemanticType > SemanticStack;
|
||||||
|
typedef Stack< LocationType > LocationStack;
|
||||||
|
|
||||||
|
#if YYLSP_NEEDED
|
||||||
|
]b4_parser_class_name[ (bool debug,
|
||||||
|
LocationType initlocation][]b4_param[) :
|
||||||
|
]b4_constructor[][debug_ (debug),
|
||||||
|
cdebug_ (std::cerr),
|
||||||
|
initlocation_ (initlocation)
|
||||||
|
#else
|
||||||
|
]b4_parser_class_name[ (bool debug][]b4_param[) :
|
||||||
|
]b4_constructor[][debug_ (debug),
|
||||||
|
cdebug_ (std::cerr)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~]b4_parser_class_name[ ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int parse ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual void lex_ ();
|
||||||
|
virtual void error_ ();
|
||||||
|
virtual void print_ ();
|
||||||
|
|
||||||
|
/* Stacks. */
|
||||||
|
StateStack state_stack_;
|
||||||
|
SemanticStack semantic_stack_;
|
||||||
|
LocationStack location_stack_;
|
||||||
|
|
||||||
|
/* Tables. */
|
||||||
|
static const ]b4_int_type_for([b4_pact])[ pact_[];
|
||||||
|
static const ]b4_int_type_for([b4_pact])[ pact_ninf_;
|
||||||
|
static const ]b4_int_type_for([b4_defact])[ defact_[];
|
||||||
|
static const ]b4_int_type_for([b4_pgoto])[ pgoto_[];
|
||||||
|
static const ]b4_int_type_for([b4_defgoto])[ defgoto_[];
|
||||||
|
static const ]b4_int_type_for([b4_table])[ table_[];
|
||||||
|
static const ]b4_int_type_for([b4_table])[ table_ninf_;
|
||||||
|
static const ]b4_int_type_for([b4_check])[ check_[];
|
||||||
|
static const ]b4_int_type_for([b4_r1])[ r1_[];
|
||||||
|
static const ]b4_int_type_for([b4_r2])[ r2_[];
|
||||||
|
|
||||||
|
#if YYDEBUG || YYERROR_VERBOSE
|
||||||
|
static const char* const name_[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* More tables, for debugging. */
|
||||||
|
#if YYDEBUG
|
||||||
|
static const RhsNumberType rhs_[];
|
||||||
|
static const ]b4_int_type_for([b4_prhs])[ prhs_[];
|
||||||
|
static const ]b4_int_type_for([b4_rline])[ rline_[];
|
||||||
|
static const ]b4_int_type_for([b4_stos])[ stos_[];
|
||||||
|
static const ]b4_int_type_for([b4_toknum])[ token_number_[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Even more tables. */
|
||||||
|
static inline TokenNumberType translate_ (int token);
|
||||||
|
|
||||||
|
/* Constants. */
|
||||||
|
static const int eof_;
|
||||||
|
/* LAST_ -- Last index in TABLE_. */
|
||||||
|
static const int last_;
|
||||||
|
static const int nnts_;
|
||||||
|
static const int empty_;
|
||||||
|
static const int final_;
|
||||||
|
static const int terror_;
|
||||||
|
static const int errcode_;
|
||||||
|
static const int ntokens_;
|
||||||
|
static const int initdepth_;
|
||||||
|
static const unsigned user_token_number_max_;
|
||||||
|
static const TokenNumberType undef_token_;
|
||||||
|
|
||||||
|
/* State. */
|
||||||
|
int n_;
|
||||||
|
int len_;
|
||||||
|
int state_;
|
||||||
|
|
||||||
|
/* Debugging. */
|
||||||
|
int debug_;
|
||||||
|
std::ostream &cdebug_;
|
||||||
|
|
||||||
|
/* Lookahead and lookahead in internal form. */
|
||||||
|
int looka_;
|
||||||
|
int ilooka_;
|
||||||
|
|
||||||
|
/* Message. */
|
||||||
|
std::string message;
|
||||||
|
|
||||||
|
/* Semantic value and location of lookahead token. */
|
||||||
|
SemanticType value;
|
||||||
|
LocationType location;
|
||||||
|
|
||||||
|
/* @@$ and $$. */
|
||||||
|
SemanticType yyval;
|
||||||
|
LocationType yyloc;
|
||||||
|
|
||||||
|
/* Initial location. */
|
||||||
|
LocationType initlocation_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! defined PARSER_HEADER_H */]
|
||||||
|
dnl
|
||||||
|
@output @output_parser_name@
|
||||||
|
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
||||||
|
[2002])[
|
||||||
|
|
||||||
|
#include @output_header_name@
|
||||||
|
|
||||||
|
/* Enable debugging if requested. */
|
||||||
|
#if YYDEBUG
|
||||||
|
# define YYCDEBUG if (debug_) cdebug_
|
||||||
|
#else /* !YYDEBUG */
|
||||||
|
# define YYCDEBUG if (0) cdebug_
|
||||||
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
|
int
|
||||||
|
yy::]b4_parser_class_name[::parse ()
|
||||||
|
{
|
||||||
|
int nerrs = 0;
|
||||||
|
int errstatus = 0;
|
||||||
|
|
||||||
|
/* Initialize stack. */
|
||||||
|
state_stack_ = StateStack (0);
|
||||||
|
semantic_stack_ = SemanticStack (1);
|
||||||
|
location_stack_ = LocationStack (1);
|
||||||
|
|
||||||
|
/* Start. */
|
||||||
|
state_ = 0;
|
||||||
|
looka_ = empty_;
|
||||||
|
#if YYLSP_NEEDED
|
||||||
|
location = initlocation_;
|
||||||
|
#endif
|
||||||
|
YYCDEBUG << "Starting parse" << std::endl;
|
||||||
|
|
||||||
|
/* New state. */
|
||||||
|
yynewstate:
|
||||||
|
state_stack_.push (state_);
|
||||||
|
YYCDEBUG << "Entering state " << state_ << std::endl;
|
||||||
|
goto yybackup;
|
||||||
|
|
||||||
|
/* Backup. */
|
||||||
|
yybackup:
|
||||||
|
|
||||||
|
/* Try to take a decision without lookahead. */
|
||||||
|
n_ = pact_[state_];
|
||||||
|
if (n_ == pact_ninf_)
|
||||||
|
goto yydefault;
|
||||||
|
|
||||||
|
/* Read a lookahead token. */
|
||||||
|
if (looka_ == empty_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Reading a token: ";
|
||||||
|
lex_ ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert token to internal form. */
|
||||||
|
if (looka_ <= 0)
|
||||||
|
{
|
||||||
|
looka_ = eof_;
|
||||||
|
ilooka_ = 0;
|
||||||
|
YYCDEBUG << "Now at end of input." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ilooka_ = translate_ (looka_);
|
||||||
|
#if YYDEBUG
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Next token is " << looka_
|
||||||
|
<< " (" << name_[ilooka_];
|
||||||
|
print_ ();
|
||||||
|
YYCDEBUG << ')' << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
n_ += ilooka_;
|
||||||
|
if (n_ < 0 || last_ < n_ || check_[n_] != ilooka_)
|
||||||
|
goto yydefault;
|
||||||
|
|
||||||
|
/* Reduce or error. */
|
||||||
|
n_ = table_[n_];
|
||||||
|
if (n_ < 0)
|
||||||
|
{
|
||||||
|
if (n_ == table_ninf_)
|
||||||
|
goto yyerrlab;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n_ = -n_;
|
||||||
|
goto yyreduce;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (n_ == 0)
|
||||||
|
goto yyerrlab;
|
||||||
|
|
||||||
|
/* Accept? */
|
||||||
|
if (n_ == final_)
|
||||||
|
goto yyacceptlab;
|
||||||
|
|
||||||
|
/* Shift the lookahead token. */
|
||||||
|
YYCDEBUG << "Shifting token " << looka_
|
||||||
|
<< " (" << name_[ilooka_] << "), ";
|
||||||
|
|
||||||
|
/* Discard the token being shifted unless it is eof. */
|
||||||
|
if (looka_ != eof_)
|
||||||
|
looka_ = empty_;
|
||||||
|
|
||||||
|
semantic_stack_.push (value);
|
||||||
|
location_stack_.push (location);
|
||||||
|
|
||||||
|
/* Count tokens shifted since error; after three, turn off error
|
||||||
|
status. */
|
||||||
|
if (errstatus)
|
||||||
|
--errstatus;
|
||||||
|
|
||||||
|
state_ = n_;
|
||||||
|
goto yynewstate;
|
||||||
|
|
||||||
|
/* Default action. */
|
||||||
|
yydefault:
|
||||||
|
n_ = defact_[state_];
|
||||||
|
if (n_ == 0)
|
||||||
|
goto yyerrlab;
|
||||||
|
goto yyreduce;
|
||||||
|
|
||||||
|
/* Reduce. */
|
||||||
|
yyreduce:
|
||||||
|
len_ = r2_[n_];
|
||||||
|
if (len_)
|
||||||
|
{
|
||||||
|
yyval = semantic_stack_[len_ - 1];
|
||||||
|
yyloc = location_stack_[len_ - 1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yyval = semantic_stack_[0];
|
||||||
|
yyloc = location_stack_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Reducing via rule " << n_ - 1
|
||||||
|
<< " (line " << rline_[n_] << "), ";
|
||||||
|
for (]b4_int_type_for([b4_prhs])[ i = prhs_[n_];
|
||||||
|
0 <= rhs_[i]; ++i)
|
||||||
|
YYCDEBUG << name_[rhs_[i]] << ' ';
|
||||||
|
YYCDEBUG << "-> " << name_[r1_[n_]] << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (len_)
|
||||||
|
{
|
||||||
|
Slice< LocationType, LocationStack > slice (location_stack_, len_);
|
||||||
|
YYLLOC_DEFAULT (yyloc, slice, len_);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (n_)
|
||||||
|
{
|
||||||
|
]b4_actions[
|
||||||
|
}
|
||||||
|
|
||||||
|
]/* Line __line__ of lalr1.cc. */
|
||||||
|
b4_syncline([@oline@], [@ofile@])[
|
||||||
|
|
||||||
|
state_stack_.pop (len_);
|
||||||
|
semantic_stack_.pop (len_);
|
||||||
|
location_stack_.pop (len_);
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "state stack now";
|
||||||
|
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||||
|
i != state_stack_.end (); ++i)
|
||||||
|
YYCDEBUG << ' ' << *i;
|
||||||
|
YYCDEBUG << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
semantic_stack_.push (yyval);
|
||||||
|
location_stack_.push (yyloc);
|
||||||
|
|
||||||
|
/* Shift the result of the reduction. */
|
||||||
|
n_ = r1_[n_];
|
||||||
|
state_ = pgoto_[n_ - ntokens_] + state_stack_[0];
|
||||||
|
if (0 <= state_ && state_ <= last_ && check_[state_] == state_stack_[0])
|
||||||
|
state_ = table_[state_];
|
||||||
|
else
|
||||||
|
state_ = defgoto_[n_ - ntokens_];
|
||||||
|
goto yynewstate;
|
||||||
|
|
||||||
|
/* Report and recover from errors. This is very incomplete. */
|
||||||
|
yyerrlab:
|
||||||
|
/* If not already recovering from an error, report this error. */
|
||||||
|
if (!errstatus)
|
||||||
|
{
|
||||||
|
++nerrs;
|
||||||
|
|
||||||
|
#if YYERROR_VERBOSE
|
||||||
|
n_ = pact_[state_];
|
||||||
|
if (pact_ninf_ < n_ && n_ < last_)
|
||||||
|
{
|
||||||
|
message = "syntax error, unexpected ";
|
||||||
|
message += name_[ilooka_];
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||||
|
if (check_[x + n_] == x && x != terror_)
|
||||||
|
++count;
|
||||||
|
if (count < 5)
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||||
|
if (check_[x + n_] == x && x != terror_)
|
||||||
|
{
|
||||||
|
message += (!count++) ? ", expecting " : " or ";
|
||||||
|
message += name_[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
message = "syntax error";
|
||||||
|
error_ ();
|
||||||
|
}
|
||||||
|
goto yyerrlab1;
|
||||||
|
|
||||||
|
/* Error raised explicitly by an action. */
|
||||||
|
yyerrlab1:
|
||||||
|
if (errstatus == 3)
|
||||||
|
{
|
||||||
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
|
error, discard it. */
|
||||||
|
|
||||||
|
/* Return failure if at end of input. */
|
||||||
|
if (looka_ == eof_)
|
||||||
|
goto yyabortlab;
|
||||||
|
YYCDEBUG << "Discarding token " << looka_
|
||||||
|
<< " (" << name_[ilooka_] << ")." << std::endl;
|
||||||
|
looka_ = empty_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
|
token. */
|
||||||
|
|
||||||
|
errstatus = 3;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
n_ = pact_[state_];
|
||||||
|
if (n_ != pact_ninf_)
|
||||||
|
{
|
||||||
|
n_ += terror_;
|
||||||
|
if (0 <= n_ && n_ <= last_ && check_[n_] == terror_)
|
||||||
|
{
|
||||||
|
n_ = table_[n_];
|
||||||
|
if (0 < n_)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pop the current state because it cannot handle the error token. */
|
||||||
|
if (!state_stack_.height ())
|
||||||
|
goto yyabortlab;
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
if (stos_[state_] < ntokens_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Error: popping token "
|
||||||
|
<< token_number_[stos_[state_]]
|
||||||
|
<< " (" << name_[stos_[state_]];
|
||||||
|
# ifdef YYPRINT
|
||||||
|
YYPRINT (stderr, token_number_[stos_[state_]],
|
||||||
|
semantic_stack_.top ());
|
||||||
|
# endif
|
||||||
|
YYCDEBUG << ')' << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Error: popping nonterminal ("
|
||||||
|
<< name_[stos_[state_]] << ')' << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
state_ = (state_stack_.pop (), state_stack_[0]);
|
||||||
|
semantic_stack_.pop ();
|
||||||
|
location_stack_.pop ();;
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
if (debug_)
|
||||||
|
{
|
||||||
|
YYCDEBUG << "Error: state stack now";
|
||||||
|
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||||
|
i != state_stack_.end (); ++i)
|
||||||
|
YYCDEBUG << ' ' << *i;
|
||||||
|
YYCDEBUG << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n_ == final_)
|
||||||
|
goto yyacceptlab;
|
||||||
|
|
||||||
|
YYCDEBUG << "Shifting error token, ";
|
||||||
|
|
||||||
|
semantic_stack_.push (value);
|
||||||
|
location_stack_.push (location);
|
||||||
|
|
||||||
|
state_ = n_;
|
||||||
|
goto yynewstate;
|
||||||
|
|
||||||
|
/* Accept. */
|
||||||
|
yyacceptlab:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Abort. */
|
||||||
|
yyabortlab:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
yy::]b4_parser_class_name[::lex_ ()
|
||||||
|
{
|
||||||
|
#if YYLSP_NEEDED
|
||||||
|
looka_ = yylex (&value, &location);
|
||||||
|
#else
|
||||||
|
looka_ = yylex (&value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
|
STATE-NUM. */
|
||||||
|
const ]b4_int_type_for([b4_pact]) yy::b4_parser_class_name::pact_ninf_ = b4_pact_ninf[;
|
||||||
|
const ]b4_int_type_for([b4_pact])[
|
||||||
|
yy::]b4_parser_class_name[::pact_[] =
|
||||||
|
{
|
||||||
|
]b4_pact[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
||||||
|
doesn't specify something else to do. Zero means the default is an
|
||||||
|
error. */
|
||||||
|
const ]b4_int_type_for([b4_defact])[
|
||||||
|
yy::]b4_parser_class_name[::defact_[] =
|
||||||
|
{
|
||||||
|
]b4_defact[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPGOTO[NTERM-NUM]. */
|
||||||
|
const ]b4_int_type_for([b4_pgoto])[
|
||||||
|
yy::]b4_parser_class_name[::pgoto_[] =
|
||||||
|
{
|
||||||
|
]b4_pgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYDEFGOTO[NTERM-NUM]. */
|
||||||
|
const ]b4_int_type_for([b4_defgoto])[
|
||||||
|
yy::]b4_parser_class_name[::defgoto_[] =
|
||||||
|
{
|
||||||
|
]b4_defgoto[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||||
|
positive, shift that token. If negative, reduce the rule which
|
||||||
|
number is the opposite. If zero, do what YYDEFACT says. */
|
||||||
|
const ]b4_int_type_for([b4_table]) yy::b4_parser_class_name::table_ninf_ = b4_table_ninf[;
|
||||||
|
const ]b4_int_type_for([b4_table])[
|
||||||
|
yy::]b4_parser_class_name[::table_[] =
|
||||||
|
{
|
||||||
|
]b4_table[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYCHECK. */
|
||||||
|
const ]b4_int_type_for([b4_check])[
|
||||||
|
yy::]b4_parser_class_name[::check_[] =
|
||||||
|
{
|
||||||
|
]b4_check[
|
||||||
|
};
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
||||||
|
symbol of state STATE-NUM. */
|
||||||
|
const ]b4_int_type_for([b4_stos])[
|
||||||
|
yy::]b4_parser_class_name[::stos_[] =
|
||||||
|
{
|
||||||
|
]b4_stos[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal token number corresponding
|
||||||
|
to YYLEX-NUM. */
|
||||||
|
const ]b4_int_type_for([b4_toknum])[
|
||||||
|
yy::]b4_parser_class_name[::token_number_[] =
|
||||||
|
{
|
||||||
|
]b4_toknum[
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||||
|
const ]b4_int_type_for([b4_r1])[
|
||||||
|
yy::]b4_parser_class_name[::r1_[] =
|
||||||
|
{
|
||||||
|
]b4_r1[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||||
|
const ]b4_int_type_for([b4_r2])[
|
||||||
|
yy::]b4_parser_class_name[::r2_[] =
|
||||||
|
{
|
||||||
|
]b4_r2[
|
||||||
|
};
|
||||||
|
|
||||||
|
#if YYDEBUG || YYERROR_VERBOSE
|
||||||
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
|
const char*
|
||||||
|
const yy::]b4_parser_class_name[::name_[] =
|
||||||
|
{
|
||||||
|
]b4_tname[
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if YYDEBUG
|
||||||
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
|
const yy::]b4_parser_class_name[::RhsNumberType
|
||||||
|
yy::]b4_parser_class_name[::rhs_[] =
|
||||||
|
{
|
||||||
|
]b4_rhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
|
YYRHS. */
|
||||||
|
const ]b4_int_type_for([b4_prhs])[
|
||||||
|
yy::]b4_parser_class_name[::prhs_[] =
|
||||||
|
{
|
||||||
|
]b4_prhs[
|
||||||
|
};
|
||||||
|
|
||||||
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
|
const ]b4_int_type_for([b4_rline])[
|
||||||
|
yy::]b4_parser_class_name[::rline_[] =
|
||||||
|
{
|
||||||
|
]b4_rline[
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
|
yy::]b4_parser_class_name[::TokenNumberType
|
||||||
|
yy::]b4_parser_class_name[::translate_ (int token)
|
||||||
|
{
|
||||||
|
static
|
||||||
|
const TokenNumberType
|
||||||
|
translate_[] =
|
||||||
|
{
|
||||||
|
]b4_translate[
|
||||||
|
};
|
||||||
|
if ((unsigned) token <= user_token_number_max_)
|
||||||
|
return translate_[token];
|
||||||
|
else
|
||||||
|
return undef_token_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int yy::]b4_parser_class_name[::eof_ = 0;
|
||||||
|
const int yy::]b4_parser_class_name[::last_ = ]b4_last[;
|
||||||
|
const int yy::]b4_parser_class_name[::nnts_ = ]b4_nterms_number[;
|
||||||
|
const int yy::]b4_parser_class_name[::empty_ = -2;
|
||||||
|
const int yy::]b4_parser_class_name[::final_ = ]b4_final_state_number[;
|
||||||
|
const int yy::]b4_parser_class_name[::terror_ = 1;
|
||||||
|
const int yy::]b4_parser_class_name[::errcode_ = 256;
|
||||||
|
const int yy::]b4_parser_class_name[::ntokens_ = ]b4_tokens_number[;
|
||||||
|
const int yy::]b4_parser_class_name[::initdepth_ = ]b4_stack_depth_init[;
|
||||||
|
|
||||||
|
const unsigned yy::]b4_parser_class_name[::user_token_number_max_ = ]b4_user_token_number_max[;
|
||||||
|
const yy::]b4_parser_class_name[::TokenNumberType yy::]b4_parser_class_name[::undef_token_ = ]b4_undef_token_number[;
|
||||||
|
|
||||||
|
]b4_epilogue
|
||||||
|
dnl
|
||||||
|
@output stack.hh
|
||||||
|
b4_copyright([2002])[
|
||||||
|
|
||||||
|
#ifndef BISON_STACK_HH
|
||||||
|
# define BISON_STACK_HH
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
namespace yy
|
||||||
|
{
|
||||||
|
template < class T, class S = std::deque< T > >
|
||||||
|
class Stack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename S::iterator Iterator;
|
||||||
|
typedef typename S::const_iterator ConstIterator;
|
||||||
|
|
||||||
|
Stack () : seq_ ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Stack (unsigned n) : seq_ (n)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
T&
|
||||||
|
operator [] (unsigned index)
|
||||||
|
{
|
||||||
|
return seq_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
const T&
|
||||||
|
operator [] (unsigned index) const
|
||||||
|
{
|
||||||
|
return seq_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void
|
||||||
|
push (const T& t)
|
||||||
|
{
|
||||||
|
seq_.push_front (t);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void
|
||||||
|
pop (unsigned n = 1)
|
||||||
|
{
|
||||||
|
for (; n; --n)
|
||||||
|
seq_.pop_front ();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
unsigned
|
||||||
|
height () const
|
||||||
|
{
|
||||||
|
return seq_.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ConstIterator begin () const { return seq_.begin (); }
|
||||||
|
inline ConstIterator end () const { return seq_.end (); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
S seq_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class T, class S = Stack< T > >
|
||||||
|
class Slice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Slice (const S& stack,
|
||||||
|
unsigned range) : stack_ (stack),
|
||||||
|
range_ (range)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
const T&
|
||||||
|
operator [] (unsigned index) const
|
||||||
|
{
|
||||||
|
return stack_[range_ - index];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
const S& stack_;
|
||||||
|
unsigned range_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // not BISON_STACK_HH]
|
||||||
|
dnl
|
||||||
|
@output location.hh
|
||||||
|
b4_copyright([2002])[
|
||||||
|
|
||||||
|
#ifndef BISON_LOCATION_HH
|
||||||
|
# define BISON_LOCATION_HH
|
||||||
|
|
||||||
|
namespace yy
|
||||||
|
{
|
||||||
|
struct Position
|
||||||
|
{
|
||||||
|
int line;
|
||||||
|
int column;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Location
|
||||||
|
{
|
||||||
|
Position first;
|
||||||
|
Position last;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // not BISON_LOCATION_HH]
|
||||||
File diff suppressed because it is too large
Load Diff
+1248
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ bison.dvi
|
|||||||
bison.fn
|
bison.fn
|
||||||
bison.ky
|
bison.ky
|
||||||
bison.log
|
bison.log
|
||||||
|
bison.pdf
|
||||||
bison.pg
|
bison.pg
|
||||||
bison.ps
|
bison.ps
|
||||||
bison.toc
|
bison.toc
|
||||||
@@ -14,3 +15,7 @@ bison.vr
|
|||||||
refcard.dvi
|
refcard.dvi
|
||||||
refcard.log
|
refcard.log
|
||||||
refcard.ps
|
refcard.ps
|
||||||
|
Makefile.in
|
||||||
|
*.info*
|
||||||
|
stamp-vti
|
||||||
|
version.texi
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ A1. If you're looking for a guarantee or certification, I can't
|
|||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Q2. I can't build Bison because "make" complains that "msgfmt" is not
|
Q2. I can't build Bison because "make" complains that "msgfmt" is not
|
||||||
fund. What should I do?
|
found. What should I do?
|
||||||
|
|
||||||
A2. Like most GNU packages with internationalization support, that
|
A2. Like most GNU packages with internationalization support, that
|
||||||
feature is turned on by default. If you have problems building
|
feature is turned on by default. If you have problems building
|
||||||
|
|||||||
+1
-2
@@ -1,11 +1,10 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||||
AUTOMAKE_OPTIONS = 1.4
|
|
||||||
|
|
||||||
info_TEXINFOS = bison.texinfo
|
info_TEXINFOS = bison.texinfo
|
||||||
man_MANS = bison.1
|
man_MANS = bison.1
|
||||||
bison_TEXINFOS = gpl.texi fdl.texi
|
bison_TEXINFOS = gpl.texi fdl.texi
|
||||||
|
|
||||||
EXTRA_DIST = FAQ bison.1 bison.rnh refcard.tex
|
EXTRA_DIST = FAQ bison.1 refcard.tex
|
||||||
|
|
||||||
CLEANFILES = refcard.dvi refcard.log refcard.ps
|
CLEANFILES = refcard.dvi refcard.log refcard.ps
|
||||||
|
|
||||||
|
|||||||
+32
-34
@@ -59,6 +59,11 @@ bison \- GNU Project parser generator (yacc replacement)
|
|||||||
.B \-\-fixed-output-files
|
.B \-\-fixed-output-files
|
||||||
]
|
]
|
||||||
file
|
file
|
||||||
|
.br
|
||||||
|
.B yacc
|
||||||
|
[
|
||||||
|
.I "similar options and operands"
|
||||||
|
]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.I Bison
|
.I Bison
|
||||||
is a parser generator in the style of
|
is a parser generator in the style of
|
||||||
@@ -76,7 +81,7 @@ Unlike
|
|||||||
the generated files do not have fixed names, but instead use the prefix
|
the generated files do not have fixed names, but instead use the prefix
|
||||||
of the input file.
|
of the input file.
|
||||||
Moreover, if you need to put
|
Moreover, if you need to put
|
||||||
.IR C++
|
.I C++
|
||||||
code in the input file, you can end his name by a C++-like extension
|
code in the input file, you can end his name by a C++-like extension
|
||||||
(.ypp or .y++), then bison will follow your extension to name the
|
(.ypp or .y++), then bison will follow your extension to name the
|
||||||
output file (.cpp or .c++).
|
output file (.cpp or .c++).
|
||||||
@@ -86,10 +91,10 @@ would produce the generated parser in a file named
|
|||||||
.BR parse.tab.cxx ,
|
.BR parse.tab.cxx ,
|
||||||
instead of
|
instead of
|
||||||
.IR yacc 's
|
.IR yacc 's
|
||||||
.BR y.tab.c
|
.B y.tab.c
|
||||||
or old
|
or old
|
||||||
.IR Bison
|
.I Bison
|
||||||
versions
|
version's
|
||||||
.BR parse.tab.c .
|
.BR parse.tab.c .
|
||||||
.PP
|
.PP
|
||||||
This description of the options that can be given to
|
This description of the options that can be given to
|
||||||
@@ -122,7 +127,7 @@ Specify a prefix to use for all
|
|||||||
.I bison
|
.I bison
|
||||||
output file names. The names are
|
output file names. The names are
|
||||||
chosen as if the input file were named
|
chosen as if the input file were named
|
||||||
\fIfile-prefix\fB.c\fR.
|
\fIfile-prefix\fP\fB.c\fP.
|
||||||
.TP
|
.TP
|
||||||
.B \-d
|
.B \-d
|
||||||
.br
|
.br
|
||||||
@@ -135,10 +140,10 @@ as well as a few
|
|||||||
variable declarations.
|
variable declarations.
|
||||||
.sp
|
.sp
|
||||||
If the parser output file is named
|
If the parser output file is named
|
||||||
\fIname\fB.c\fR
|
.IB name .c
|
||||||
then this file
|
then this file
|
||||||
is named
|
is named
|
||||||
\fIname\fB.h\fR.
|
\fIname\fP\fB.h\fP.
|
||||||
.sp
|
.sp
|
||||||
This output file is essential if you wish to put the definition of
|
This output file is essential if you wish to put the definition of
|
||||||
.B yylex
|
.B yylex
|
||||||
@@ -148,12 +153,12 @@ needs to be able to refer to token type codes and the variable
|
|||||||
.BR yylval .
|
.BR yylval .
|
||||||
.TP
|
.TP
|
||||||
.BI \-\-defines= defines-file
|
.BI \-\-defines= defines-file
|
||||||
The behaviour of
|
The behavior of
|
||||||
.BI \-\-defines
|
.B \-\-defines
|
||||||
is the same than
|
is the same than
|
||||||
.BI \-d
|
.B \-d
|
||||||
option.
|
option.
|
||||||
The only difference is that it has an optionnal argument which is
|
The only difference is that it has an optional argument which is
|
||||||
the name of the output filename.
|
the name of the output filename.
|
||||||
.TP
|
.TP
|
||||||
.BI \-g
|
.BI \-g
|
||||||
@@ -166,11 +171,11 @@ Bison. If the grammar file is
|
|||||||
.BR foo.vcg .
|
.BR foo.vcg .
|
||||||
.TP
|
.TP
|
||||||
.BI \-\-graph= graph-file
|
.BI \-\-graph= graph-file
|
||||||
The behaviour of
|
The behavior of
|
||||||
.BI \-\-graph
|
.BI \-\-graph
|
||||||
is the same than
|
is the same than
|
||||||
.BI \-g
|
.BI \-g
|
||||||
option. The only difference is that it has an optionnal argument which
|
option. The only difference is that it has an optional argument which
|
||||||
is the name of the output graph filename.
|
is the name of the output graph filename.
|
||||||
.TP
|
.TP
|
||||||
.B \-k
|
.B \-k
|
||||||
@@ -178,7 +183,9 @@ is the name of the output graph filename.
|
|||||||
.ns
|
.ns
|
||||||
.TP
|
.TP
|
||||||
.B \-\-token-table
|
.B \-\-token-table
|
||||||
This switch causes the \fIname\fB.tab.c\fR output to include a list of
|
This switch causes the
|
||||||
|
.IB name .tab.c
|
||||||
|
output to include a list of
|
||||||
token names in order by their token numbers; this is defined in the array
|
token names in order by their token numbers; this is defined in the array
|
||||||
.IR yytname .
|
.IR yytname .
|
||||||
Also generated
|
Also generated
|
||||||
@@ -210,8 +217,12 @@ parser file, treating it an independent source file in its own right.
|
|||||||
.TP
|
.TP
|
||||||
.B \-\-no-parser
|
.B \-\-no-parser
|
||||||
Do not generate the parser code into the output; generate only
|
Do not generate the parser code into the output; generate only
|
||||||
declarations. The generated \fIname\fB.tab.c\fR file will have only
|
declarations. The generated
|
||||||
constant declarations. In addition, a \fIname\fB.act\fR file is
|
.IB name .tab.c
|
||||||
|
file will have only
|
||||||
|
constant declarations. In addition, a
|
||||||
|
.IB name .act
|
||||||
|
file is
|
||||||
generated containing a switch statement body containing all the
|
generated containing a switch statement body containing all the
|
||||||
translated actions.
|
translated actions.
|
||||||
.TP
|
.TP
|
||||||
@@ -262,9 +273,9 @@ and so on.
|
|||||||
.ns
|
.ns
|
||||||
.TP
|
.TP
|
||||||
.B \-\-debug
|
.B \-\-debug
|
||||||
Output a definition of the macro
|
In the parser file, define the macro
|
||||||
.B YYDEBUG
|
.B YYDEBUG
|
||||||
into the parser file,
|
to 1 if it is not already defined,
|
||||||
so that the debugging facilities are compiled.
|
so that the debugging facilities are compiled.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
@@ -334,29 +345,16 @@ The purpose of this switch is to imitate
|
|||||||
.IR yacc 's
|
.IR yacc 's
|
||||||
output file name conventions.
|
output file name conventions.
|
||||||
Thus, the following shell script can substitute for
|
Thus, the following shell script can substitute for
|
||||||
|
.I yacc
|
||||||
|
and is often installed as
|
||||||
.IR yacc :
|
.IR yacc :
|
||||||
.sp
|
.sp
|
||||||
.RS
|
.RS
|
||||||
.ft B
|
.ft B
|
||||||
bison \-y $*
|
bison \-y "$@"
|
||||||
.ft R
|
.ft R
|
||||||
.sp
|
.sp
|
||||||
.RE
|
.RE
|
||||||
.SH FILES
|
|
||||||
/usr/local/share/bison/bison.simple simple parser
|
|
||||||
.br
|
|
||||||
/usr/local/share/bison/bison.hairy complicated parser
|
|
||||||
.SH "ENVIRONMENT VARIABLES"
|
|
||||||
.TP
|
|
||||||
.SM BISON_SIMPLE
|
|
||||||
If this is set, it specifies the location in which the
|
|
||||||
.B bison.simple
|
|
||||||
parser can be found.
|
|
||||||
.TP
|
|
||||||
.SM BISON_HAIRY
|
|
||||||
If this is set, it specifies the location in which the
|
|
||||||
.B bison.hairy
|
|
||||||
parser can be found.
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.IR yacc (1)
|
.IR yacc (1)
|
||||||
.br
|
.br
|
||||||
|
|||||||
-191
@@ -1,191 +0,0 @@
|
|||||||
.!
|
|
||||||
.! RUNOFF source file for BISON.HLP
|
|
||||||
.!
|
|
||||||
.! This is a RUNOFF input file which will produce a VMS help file
|
|
||||||
.! for the VMS HELP library.
|
|
||||||
.!
|
|
||||||
.! Eric Youngdale and Wilfred J. Hansen ([email protected]).
|
|
||||||
.!
|
|
||||||
.literal
|
|
||||||
.end literal
|
|
||||||
.no paging
|
|
||||||
.no flags all
|
|
||||||
.right margin 70
|
|
||||||
.left margin 1
|
|
||||||
|
|
||||||
.indent -1
|
|
||||||
1 BISON
|
|
||||||
.skip
|
|
||||||
The BISON command invokes the GNU BISON parser generator.
|
|
||||||
.skip
|
|
||||||
.literal
|
|
||||||
BISON file-spec
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 Parameters
|
|
||||||
.skip
|
|
||||||
file-spec
|
|
||||||
.skip
|
|
||||||
Here file-spec is the grammar file name, which usually ends in
|
|
||||||
.y. The parser file's name is made by replacing the .y
|
|
||||||
with _tab.c. Thus, the command bison foo.y yields
|
|
||||||
foo_tab.c.
|
|
||||||
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 Qualifiers
|
|
||||||
.skip
|
|
||||||
The following is the list of available qualifiers for BISON:
|
|
||||||
.literal
|
|
||||||
/DEBUG
|
|
||||||
/DEFINES
|
|
||||||
/FILE_PREFIX=prefix
|
|
||||||
/FIXED_OUTFILES
|
|
||||||
/NAME_PREFIX=prefix
|
|
||||||
/NOLINES
|
|
||||||
/NOPARSER
|
|
||||||
/OUTPUT=outfilefile
|
|
||||||
/RAW
|
|
||||||
/TOKEN_TABLE
|
|
||||||
/VERBOSE
|
|
||||||
/VERSION
|
|
||||||
/YACC
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /DEBUG
|
|
||||||
.skip
|
|
||||||
Output a definition of the macro YYDEBUG into the parser file,
|
|
||||||
so that the debugging facilities are compiled.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /DEFINES
|
|
||||||
.skip
|
|
||||||
Write an extra output file containing macro definitions for the token
|
|
||||||
type names defined in the grammar and the semantic value type
|
|
||||||
YYSTYPE, as well as a extern variable declarations.
|
|
||||||
.skip
|
|
||||||
If the parser output file is named "name.c" then this file
|
|
||||||
is named "name.h".
|
|
||||||
.skip
|
|
||||||
This output file is essential if you wish to put the definition of
|
|
||||||
yylex in a separate source file, because yylex needs to
|
|
||||||
be able to refer to token type codes and the variable
|
|
||||||
yylval.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /FILE_PREFIX
|
|
||||||
.skip
|
|
||||||
.literal
|
|
||||||
/FILIE_PREFIX=prefix
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
Specify a prefix to use for all Bison output file names. The names are
|
|
||||||
chosen as if the input file were named prefix.c
|
|
||||||
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /FIXED_OUTFILES
|
|
||||||
.skip
|
|
||||||
Equivalent to /OUTPUT=y_tab.c; the parser output file is called
|
|
||||||
y_tab.c, and the other outputs are called y.output and
|
|
||||||
y_tab.h. The purpose of this switch is to imitate Yacc's output
|
|
||||||
file name conventions. The /YACC qualifier is functionally equivalent
|
|
||||||
to /FIXED_OUTFILES. The following command definition will
|
|
||||||
work as a substitute for Yacc:
|
|
||||||
|
|
||||||
.literal
|
|
||||||
$YACC:==BISON/FIXED_OUTFILES
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /NAME_PREFIX
|
|
||||||
.skip
|
|
||||||
.literal
|
|
||||||
/NAME_PREFIX=prefix
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
Rename the external symbols used in the parser so that they start with
|
|
||||||
"prefix" instead of "yy". The precise list of symbols renamed
|
|
||||||
is yyparse, yylex, yyerror, yylval, yychar and yydebug.
|
|
||||||
|
|
||||||
For example, if you use /NAME_PREFIX="c", the names become cparse,
|
|
||||||
clex, and so on.
|
|
||||||
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /NOLINES
|
|
||||||
.skip
|
|
||||||
Don't put any "#line" preprocessor commands in the parser file.
|
|
||||||
Ordinarily Bison puts them in the parser file so that the C compiler
|
|
||||||
and debuggers will associate errors with your source file, the
|
|
||||||
grammar file. This option causes them to associate errors with the
|
|
||||||
parser file, treating it an independent source file in its own right.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /NOPARSER
|
|
||||||
.skip
|
|
||||||
Do not generate the parser code into the output; generate only
|
|
||||||
declarations. The generated name_tab.c file will have only
|
|
||||||
constant declarations. In addition, a name.act file is
|
|
||||||
generated containing a switch statement body containing all the
|
|
||||||
translated actions.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /OUTPUT
|
|
||||||
.skip
|
|
||||||
.literal
|
|
||||||
/OUTPUT=outfile
|
|
||||||
.end literal
|
|
||||||
.skip
|
|
||||||
Specify the name "outfile" for the parser file.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /RAW
|
|
||||||
.skip
|
|
||||||
When this switch is specified, the .tab.h file defines the tokens to
|
|
||||||
have the bison token numbers rather than the yacc compatible numbers.
|
|
||||||
To employ this switch you would have to have your own parser.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /TOKEN_TABLE
|
|
||||||
.skip
|
|
||||||
This switch causes the name_tab.c output to include a list of
|
|
||||||
token names in order by their token numbers; this is defined in the array
|
|
||||||
yytname. Also generated are #defines for YYNTOKENS, YYNNTS, YYNRULES,
|
|
||||||
and YYNSTATES.
|
|
||||||
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /VERBOSE
|
|
||||||
.skip
|
|
||||||
Write an extra output file containing verbose descriptions of the
|
|
||||||
parser states and what is done for each type of look-ahead token in
|
|
||||||
that state.
|
|
||||||
.skip
|
|
||||||
This file also describes all the conflicts, both those resolved by
|
|
||||||
operator precedence and the unresolved ones.
|
|
||||||
.skip
|
|
||||||
The file's name is made by removing _tab.c or .c from
|
|
||||||
the parser output file name, and adding .output instead.
|
|
||||||
.skip
|
|
||||||
Therefore, if the input file is foo.y, then the parser file is
|
|
||||||
called foo_tab.c by default. As a consequence, the verbose
|
|
||||||
output file is called foo.output.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /VERSION
|
|
||||||
.skip
|
|
||||||
Print the version number of Bison.
|
|
||||||
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
2 /YACC
|
|
||||||
.skip
|
|
||||||
See /FIXED_OUTFILES.
|
|
||||||
.skip
|
|
||||||
.indent -1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+2102
-804
File diff suppressed because it is too large
Load Diff
+138
-87
@@ -1,11 +1,12 @@
|
|||||||
|
|
||||||
@node GNU Free Documentation License
|
@node GNU Free Documentation License
|
||||||
@appendixsec GNU Free Documentation License
|
@appendixsec GNU Free Documentation License
|
||||||
|
|
||||||
@cindex FDL, GNU Free Documentation License
|
@cindex FDL, GNU Free Documentation License
|
||||||
@center Version 1.1, March 2000
|
@center Version 1.2, November 2002
|
||||||
|
|
||||||
@display
|
@display
|
||||||
Copyright @copyright{} 2000 Free Software Foundation, Inc.
|
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
@@ -17,12 +18,12 @@ of this license document, but changing it is not allowed.
|
|||||||
PREAMBLE
|
PREAMBLE
|
||||||
|
|
||||||
The purpose of this License is to make a manual, textbook, or other
|
The purpose of this License is to make a manual, textbook, or other
|
||||||
written document @dfn{free} in the sense of freedom: to assure everyone
|
functional and useful document @dfn{free} in the sense of freedom: to
|
||||||
the effective freedom to copy and redistribute it, with or without
|
assure everyone the effective freedom to copy and redistribute it,
|
||||||
modifying it, either commercially or noncommercially. Secondarily,
|
with or without modifying it, either commercially or noncommercially.
|
||||||
this License preserves for the author and publisher a way to get
|
Secondarily, this License preserves for the author and publisher a way
|
||||||
credit for their work, while not being considered responsible for
|
to get credit for their work, while not being considered responsible
|
||||||
modifications made by others.
|
for modifications made by others.
|
||||||
|
|
||||||
This License is a kind of ``copyleft'', which means that derivative
|
This License is a kind of ``copyleft'', which means that derivative
|
||||||
works of the document must themselves be free in the same sense. It
|
works of the document must themselves be free in the same sense. It
|
||||||
@@ -40,57 +41,69 @@ principally for works whose purpose is instruction or reference.
|
|||||||
@item
|
@item
|
||||||
APPLICABILITY AND DEFINITIONS
|
APPLICABILITY AND DEFINITIONS
|
||||||
|
|
||||||
This License applies to any manual or other work that contains a
|
This License applies to any manual or other work, in any medium, that
|
||||||
notice placed by the copyright holder saying it can be distributed
|
contains a notice placed by the copyright holder saying it can be
|
||||||
under the terms of this License. The ``Document'', below, refers to any
|
distributed under the terms of this License. Such a notice grants a
|
||||||
such manual or work. Any member of the public is a licensee, and is
|
world-wide, royalty-free license, unlimited in duration, to use that
|
||||||
addressed as ``you''.
|
work under the conditions stated herein. The ``Document'', below,
|
||||||
|
refers to any such manual or work. Any member of the public is a
|
||||||
|
licensee, and is addressed as ``you''. You accept the license if you
|
||||||
|
copy, modify or distribute the work in a way requiring permission
|
||||||
|
under copyright law.
|
||||||
|
|
||||||
A ``Modified Version'' of the Document means any work containing the
|
A ``Modified Version'' of the Document means any work containing the
|
||||||
Document or a portion of it, either copied verbatim, or with
|
Document or a portion of it, either copied verbatim, or with
|
||||||
modifications and/or translated into another language.
|
modifications and/or translated into another language.
|
||||||
|
|
||||||
A ``Secondary Section'' is a named appendix or a front-matter section of
|
A ``Secondary Section'' is a named appendix or a front-matter section
|
||||||
the Document that deals exclusively with the relationship of the
|
of the Document that deals exclusively with the relationship of the
|
||||||
publishers or authors of the Document to the Document's overall subject
|
publishers or authors of the Document to the Document's overall
|
||||||
(or to related matters) and contains nothing that could fall directly
|
subject (or to related matters) and contains nothing that could fall
|
||||||
within that overall subject. (For example, if the Document is in part a
|
directly within that overall subject. (Thus, if the Document is in
|
||||||
textbook of mathematics, a Secondary Section may not explain any
|
part a textbook of mathematics, a Secondary Section may not explain
|
||||||
mathematics.) The relationship could be a matter of historical
|
any mathematics.) The relationship could be a matter of historical
|
||||||
connection with the subject or with related matters, or of legal,
|
connection with the subject or with related matters, or of legal,
|
||||||
commercial, philosophical, ethical or political position regarding
|
commercial, philosophical, ethical or political position regarding
|
||||||
them.
|
them.
|
||||||
|
|
||||||
The ``Invariant Sections'' are certain Secondary Sections whose titles
|
The ``Invariant Sections'' are certain Secondary Sections whose titles
|
||||||
are designated, as being those of Invariant Sections, in the notice
|
are designated, as being those of Invariant Sections, in the notice
|
||||||
that says that the Document is released under this License.
|
that says that the Document is released under this License. If a
|
||||||
|
section does not fit the above definition of Secondary then it is not
|
||||||
|
allowed to be designated as Invariant. The Document may contain zero
|
||||||
|
Invariant Sections. If the Document does not identify any Invariant
|
||||||
|
Sections then there are none.
|
||||||
|
|
||||||
The ``Cover Texts'' are certain short passages of text that are listed,
|
The ``Cover Texts'' are certain short passages of text that are listed,
|
||||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||||
the Document is released under this License.
|
the Document is released under this License. A Front-Cover Text may
|
||||||
|
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||||
|
|
||||||
A ``Transparent'' copy of the Document means a machine-readable copy,
|
A ``Transparent'' copy of the Document means a machine-readable copy,
|
||||||
represented in a format whose specification is available to the
|
represented in a format whose specification is available to the
|
||||||
general public, whose contents can be viewed and edited directly and
|
general public, that is suitable for revising the document
|
||||||
straightforwardly with generic text editors or (for images composed of
|
straightforwardly with generic text editors or (for images composed of
|
||||||
pixels) generic paint programs or (for drawings) some widely available
|
pixels) generic paint programs or (for drawings) some widely available
|
||||||
drawing editor, and that is suitable for input to text formatters or
|
drawing editor, and that is suitable for input to text formatters or
|
||||||
for automatic translation to a variety of formats suitable for input
|
for automatic translation to a variety of formats suitable for input
|
||||||
to text formatters. A copy made in an otherwise Transparent file
|
to text formatters. A copy made in an otherwise Transparent file
|
||||||
format whose markup has been designed to thwart or discourage
|
format whose markup, or absence of markup, has been arranged to thwart
|
||||||
subsequent modification by readers is not Transparent. A copy that is
|
or discourage subsequent modification by readers is not Transparent.
|
||||||
not ``Transparent'' is called ``Opaque''.
|
An image format is not Transparent if used for any substantial amount
|
||||||
|
of text. A copy that is not ``Transparent'' is called ``Opaque''.
|
||||||
|
|
||||||
Examples of suitable formats for Transparent copies include plain
|
Examples of suitable formats for Transparent copies include plain
|
||||||
@sc{ascii} without markup, Texinfo input format, La@TeX{} input format,
|
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
|
||||||
@acronym{SGML} or @acronym{XML} using a publicly available
|
format, @acronym{SGML} or @acronym{XML} using a publicly available
|
||||||
@acronym{DTD}, and standard-conforming simple @acronym{HTML} designed
|
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
|
||||||
for human modification. Opaque formats include PostScript,
|
PostScript or @acronym{PDF} designed for human modification. Examples
|
||||||
@acronym{PDF}, proprietary formats that can be read and edited only by
|
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
|
||||||
proprietary word processors, @acronym{SGML} or @acronym{XML} for which
|
@acronym{JPG}. Opaque formats include proprietary formats that can be
|
||||||
the @acronym{DTD} and/or processing tools are not generally available,
|
read and edited only by proprietary word processors, @acronym{SGML} or
|
||||||
and the machine-generated @acronym{HTML} produced by some word
|
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
|
||||||
processors for output purposes only.
|
not generally available, and the machine-generated @acronym{HTML},
|
||||||
|
PostScript or @acronym{PDF} produced by some word processors for
|
||||||
|
output purposes only.
|
||||||
|
|
||||||
The ``Title Page'' means, for a printed book, the title page itself,
|
The ``Title Page'' means, for a printed book, the title page itself,
|
||||||
plus such following pages as are needed to hold, legibly, the material
|
plus such following pages as are needed to hold, legibly, the material
|
||||||
@@ -99,6 +112,21 @@ formats which do not have any title page as such, ``Title Page'' means
|
|||||||
the text near the most prominent appearance of the work's title,
|
the text near the most prominent appearance of the work's title,
|
||||||
preceding the beginning of the body of the text.
|
preceding the beginning of the body of the text.
|
||||||
|
|
||||||
|
A section ``Entitled XYZ'' means a named subunit of the Document whose
|
||||||
|
title either is precisely XYZ or contains XYZ in parentheses following
|
||||||
|
text that translates XYZ in another language. (Here XYZ stands for a
|
||||||
|
specific section name mentioned below, such as ``Acknowledgements'',
|
||||||
|
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
|
||||||
|
of such a section when you modify the Document means that it remains a
|
||||||
|
section ``Entitled XYZ'' according to this definition.
|
||||||
|
|
||||||
|
The Document may include Warranty Disclaimers next to the notice which
|
||||||
|
states that this License applies to the Document. These Warranty
|
||||||
|
Disclaimers are considered to be included by reference in this
|
||||||
|
License, but only as regards disclaiming warranties: any other
|
||||||
|
implication that these Warranty Disclaimers may have is void and has
|
||||||
|
no effect on the meaning of this License.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
VERBATIM COPYING
|
VERBATIM COPYING
|
||||||
|
|
||||||
@@ -118,9 +146,10 @@ you may publicly display copies.
|
|||||||
@item
|
@item
|
||||||
COPYING IN QUANTITY
|
COPYING IN QUANTITY
|
||||||
|
|
||||||
If you publish printed copies of the Document numbering more than 100,
|
If you publish printed copies (or copies in media that commonly have
|
||||||
and the Document's license notice requires Cover Texts, you must enclose
|
printed covers) of the Document, numbering more than 100, and the
|
||||||
the copies in covers that carry, clearly and legibly, all these Cover
|
Document's license notice requires Cover Texts, you must enclose the
|
||||||
|
copies in covers that carry, clearly and legibly, all these Cover
|
||||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||||
the back cover. Both covers must also clearly and legibly identify
|
the back cover. Both covers must also clearly and legibly identify
|
||||||
you as the publisher of these copies. The front cover must present
|
you as the publisher of these copies. The front cover must present
|
||||||
@@ -138,16 +167,15 @@ pages.
|
|||||||
If you publish or distribute Opaque copies of the Document numbering
|
If you publish or distribute Opaque copies of the Document numbering
|
||||||
more than 100, you must either include a machine-readable Transparent
|
more than 100, you must either include a machine-readable Transparent
|
||||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||||
a publicly-accessible computer-network location containing a complete
|
a computer-network location from which the general network-using
|
||||||
Transparent copy of the Document, free of added material, which the
|
public has access to download using public-standard network protocols
|
||||||
general network-using public has access to download anonymously at no
|
a complete Transparent copy of the Document, free of added material.
|
||||||
charge using public-standard network protocols. If you use the latter
|
If you use the latter option, you must take reasonably prudent steps,
|
||||||
option, you must take reasonably prudent steps, when you begin
|
when you begin distribution of Opaque copies in quantity, to ensure
|
||||||
distribution of Opaque copies in quantity, to ensure that this
|
that this Transparent copy will remain thus accessible at the stated
|
||||||
Transparent copy will remain thus accessible at the stated location
|
location until at least one year after the last time you distribute an
|
||||||
until at least one year after the last time you distribute an Opaque
|
Opaque copy (directly or through your agents or retailers) of that
|
||||||
copy (directly or through your agents or retailers) of that edition to
|
edition to the public.
|
||||||
the public.
|
|
||||||
|
|
||||||
It is requested, but not required, that you contact the authors of the
|
It is requested, but not required, that you contact the authors of the
|
||||||
Document well before redistributing any large number of copies, to give
|
Document well before redistributing any large number of copies, to give
|
||||||
@@ -175,7 +203,8 @@ if the original publisher of that version gives permission.
|
|||||||
List on the Title Page, as authors, one or more persons or entities
|
List on the Title Page, as authors, one or more persons or entities
|
||||||
responsible for authorship of the modifications in the Modified
|
responsible for authorship of the modifications in the Modified
|
||||||
Version, together with at least five of the principal authors of the
|
Version, together with at least five of the principal authors of the
|
||||||
Document (all of its principal authors, if it has less than five).
|
Document (all of its principal authors, if it has fewer than five),
|
||||||
|
unless they release you from this requirement.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
State on the Title page the name of the publisher of the
|
State on the Title page the name of the publisher of the
|
||||||
@@ -201,10 +230,10 @@ and required Cover Texts given in the Document's license notice.
|
|||||||
Include an unaltered copy of this License.
|
Include an unaltered copy of this License.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Preserve the section entitled ``History'', and its title, and add to
|
Preserve the section Entitled ``History'', Preserve its Title, and add
|
||||||
it an item stating at least the title, year, new authors, and
|
to it an item stating at least the title, year, new authors, and
|
||||||
publisher of the Modified Version as given on the Title Page. If
|
publisher of the Modified Version as given on the Title Page. If
|
||||||
there is no section entitled ``History'' in the Document, create one
|
there is no section Entitled ``History'' in the Document, create one
|
||||||
stating the title, year, authors, and publisher of the Document as
|
stating the title, year, authors, and publisher of the Document as
|
||||||
given on its Title Page, then add an item describing the Modified
|
given on its Title Page, then add an item describing the Modified
|
||||||
Version as stated in the previous sentence.
|
Version as stated in the previous sentence.
|
||||||
@@ -219,10 +248,10 @@ least four years before the Document itself, or if the original
|
|||||||
publisher of the version it refers to gives permission.
|
publisher of the version it refers to gives permission.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
In any section entitled ``Acknowledgments'' or ``Dedications'',
|
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
|
||||||
preserve the section's title, and preserve in the section all the
|
the Title of the section, and preserve in the section all the
|
||||||
substance and tone of each of the contributor acknowledgments
|
substance and tone of each of the contributor acknowledgements and/or
|
||||||
and/or dedications given therein.
|
dedications given therein.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Preserve all the Invariant Sections of the Document,
|
Preserve all the Invariant Sections of the Document,
|
||||||
@@ -230,12 +259,15 @@ unaltered in their text and in their titles. Section numbers
|
|||||||
or the equivalent are not considered part of the section titles.
|
or the equivalent are not considered part of the section titles.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Delete any section entitled ``Endorsements''. Such a section
|
Delete any section Entitled ``Endorsements''. Such a section
|
||||||
may not be included in the Modified Version.
|
may not be included in the Modified Version.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Do not retitle any existing section as ``Endorsements''
|
Do not retitle any existing section to be Entitled ``Endorsements'' or
|
||||||
or to conflict in title with any Invariant Section.
|
to conflict in title with any Invariant Section.
|
||||||
|
|
||||||
|
@item
|
||||||
|
Preserve any Warranty Disclaimers.
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
If the Modified Version includes new front-matter sections or
|
If the Modified Version includes new front-matter sections or
|
||||||
@@ -245,7 +277,7 @@ of these sections as invariant. To do this, add their titles to the
|
|||||||
list of Invariant Sections in the Modified Version's license notice.
|
list of Invariant Sections in the Modified Version's license notice.
|
||||||
These titles must be distinct from any other section titles.
|
These titles must be distinct from any other section titles.
|
||||||
|
|
||||||
You may add a section entitled ``Endorsements'', provided it contains
|
You may add a section Entitled ``Endorsements'', provided it contains
|
||||||
nothing but endorsements of your Modified Version by various
|
nothing but endorsements of your Modified Version by various
|
||||||
parties---for example, statements of peer review or that the text has
|
parties---for example, statements of peer review or that the text has
|
||||||
been approved by an organization as the authoritative definition of a
|
been approved by an organization as the authoritative definition of a
|
||||||
@@ -273,7 +305,7 @@ License, under the terms defined in section 4 above for modified
|
|||||||
versions, provided that you include in the combination all of the
|
versions, provided that you include in the combination all of the
|
||||||
Invariant Sections of all of the original documents, unmodified, and
|
Invariant Sections of all of the original documents, unmodified, and
|
||||||
list them all as Invariant Sections of your combined work in its
|
list them all as Invariant Sections of your combined work in its
|
||||||
license notice.
|
license notice, and that you preserve all their Warranty Disclaimers.
|
||||||
|
|
||||||
The combined work need only contain one copy of this License, and
|
The combined work need only contain one copy of this License, and
|
||||||
multiple identical Invariant Sections may be replaced with a single
|
multiple identical Invariant Sections may be replaced with a single
|
||||||
@@ -284,11 +316,11 @@ author or publisher of that section if known, or else a unique number.
|
|||||||
Make the same adjustment to the section titles in the list of
|
Make the same adjustment to the section titles in the list of
|
||||||
Invariant Sections in the license notice of the combined work.
|
Invariant Sections in the license notice of the combined work.
|
||||||
|
|
||||||
In the combination, you must combine any sections entitled ``History''
|
In the combination, you must combine any sections Entitled ``History''
|
||||||
in the various original documents, forming one section entitled
|
in the various original documents, forming one section Entitled
|
||||||
``History''; likewise combine any sections entitled ``Acknowledgments'',
|
``History''; likewise combine any sections Entitled ``Acknowledgements'',
|
||||||
and any sections entitled ``Dedications''. You must delete all sections
|
and any sections Entitled ``Dedications''. You must delete all
|
||||||
entitled ``Endorsements.''
|
sections Entitled ``Endorsements.''
|
||||||
|
|
||||||
@item
|
@item
|
||||||
COLLECTIONS OF DOCUMENTS
|
COLLECTIONS OF DOCUMENTS
|
||||||
@@ -309,18 +341,20 @@ AGGREGATION WITH INDEPENDENT WORKS
|
|||||||
|
|
||||||
A compilation of the Document or its derivatives with other separate
|
A compilation of the Document or its derivatives with other separate
|
||||||
and independent documents or works, in or on a volume of a storage or
|
and independent documents or works, in or on a volume of a storage or
|
||||||
distribution medium, does not as a whole count as a Modified Version
|
distribution medium, is called an ``aggregate'' if the copyright
|
||||||
of the Document, provided no compilation copyright is claimed for the
|
resulting from the compilation is not used to limit the legal rights
|
||||||
compilation. Such a compilation is called an ``aggregate'', and this
|
of the compilation's users beyond what the individual works permit.
|
||||||
License does not apply to the other self-contained works thus compiled
|
When the Document is included an aggregate, this License does not
|
||||||
with the Document, on account of their being thus compiled, if they
|
apply to the other works in the aggregate which are not themselves
|
||||||
are not themselves derivative works of the Document.
|
derivative works of the Document.
|
||||||
|
|
||||||
If the Cover Text requirement of section 3 is applicable to these
|
If the Cover Text requirement of section 3 is applicable to these
|
||||||
copies of the Document, then if the Document is less than one quarter
|
copies of the Document, then if the Document is less than one half of
|
||||||
of the entire aggregate, the Document's Cover Texts may be placed on
|
the entire aggregate, the Document's Cover Texts may be placed on
|
||||||
covers that surround only the Document within the aggregate.
|
covers that bracket the Document within the aggregate, or the
|
||||||
Otherwise they must appear on covers around the whole aggregate.
|
electronic equivalent of covers if the Document is in electronic form.
|
||||||
|
Otherwise they must appear on printed covers that bracket the whole
|
||||||
|
aggregate.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
TRANSLATION
|
TRANSLATION
|
||||||
@@ -331,10 +365,17 @@ Replacing Invariant Sections with translations requires special
|
|||||||
permission from their copyright holders, but you may include
|
permission from their copyright holders, but you may include
|
||||||
translations of some or all Invariant Sections in addition to the
|
translations of some or all Invariant Sections in addition to the
|
||||||
original versions of these Invariant Sections. You may include a
|
original versions of these Invariant Sections. You may include a
|
||||||
translation of this License provided that you also include the
|
translation of this License, and all the license notices in the
|
||||||
original English version of this License. In case of a disagreement
|
Document, and any Warrany Disclaimers, provided that you also include
|
||||||
between the translation and the original English version of this
|
the original English version of this License and the original versions
|
||||||
License, the original English version will prevail.
|
of those notices and disclaimers. In case of a disagreement between
|
||||||
|
the translation and the original version of this License or a notice
|
||||||
|
or disclaimer, the original version will prevail.
|
||||||
|
|
||||||
|
If a section in the Document is Entitled ``Acknowledgements'',
|
||||||
|
``Dedications'', or ``History'', the requirement (section 4) to Preserve
|
||||||
|
its Title (section 1) will typically require changing the actual
|
||||||
|
title.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
TERMINATION
|
TERMINATION
|
||||||
@@ -377,19 +418,28 @@ license notices just after the title page:
|
|||||||
@group
|
@group
|
||||||
Copyright (C) @var{year} @var{your name}.
|
Copyright (C) @var{year} @var{your name}.
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.1
|
under the terms of the GNU Free Documentation License, Version 1.2
|
||||||
or any later version published by the Free Software Foundation;
|
or any later version published by the Free Software Foundation;
|
||||||
with the Invariant Sections being @var{list their titles}, with the
|
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||||
Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}.
|
|
||||||
A copy of the license is included in the section entitled ``GNU
|
A copy of the license is included in the section entitled ``GNU
|
||||||
Free Documentation License''.
|
Free Documentation License''.
|
||||||
@end group
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
If you have no Invariant Sections, write ``with no Invariant Sections''
|
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||||
instead of saying which ones are invariant. If you have no
|
replace the ``with...Texts.'' line with this:
|
||||||
Front-Cover Texts, write ``no Front-Cover Texts'' instead of
|
|
||||||
``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts.
|
@smallexample
|
||||||
|
@group
|
||||||
|
with the Invariant Sections being @var{list their titles}, with
|
||||||
|
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
|
||||||
|
being @var{list}.
|
||||||
|
@end group
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
|
If you have Invariant Sections without Cover Texts, or some other
|
||||||
|
combination of the three, merge those two alternatives to suit the
|
||||||
|
situation.
|
||||||
|
|
||||||
If your document contains nontrivial examples of program code, we
|
If your document contains nontrivial examples of program code, we
|
||||||
recommend releasing these examples in parallel under your choice of
|
recommend releasing these examples in parallel under your choice of
|
||||||
@@ -399,3 +449,4 @@ to permit their use in free software.
|
|||||||
@c Local Variables:
|
@c Local Variables:
|
||||||
@c ispell-local-pdict: "ispell-dict"
|
@c ispell-local-pdict: "ispell-dict"
|
||||||
@c End:
|
@c End:
|
||||||
|
|
||||||
|
|||||||
+18
-12
@@ -19,7 +19,7 @@
|
|||||||
\def\finalout{\overfullrule=0pt}
|
\def\finalout{\overfullrule=0pt}
|
||||||
%\finalout
|
%\finalout
|
||||||
|
|
||||||
% Copyright (c) 1998 Free Software Foundation, Inc.
|
% Copyright (c) 1998, 2001 Free Software Foundation, Inc.
|
||||||
%
|
%
|
||||||
% This file is part of Bison.
|
% This file is part of Bison.
|
||||||
%
|
%
|
||||||
@@ -66,11 +66,11 @@
|
|||||||
% We only change the following to change the version numbers and
|
% We only change the following to change the version numbers and
|
||||||
% such.
|
% such.
|
||||||
|
|
||||||
\def\bisonversion{1.20} % the bison version
|
\def\bisonversion{1.31} % the bison version
|
||||||
|
|
||||||
\def\refcardversion{0.4a} % reference card version
|
\def\refcardversion{0.5} % reference card version
|
||||||
\def\month{August} % month
|
\def\month{November} % month
|
||||||
\def\year{1998} % year
|
\def\year{2001} % year
|
||||||
\def\version{\month\ \year, Bison Refcard Version \refcardversion}
|
\def\version{\month\ \year, Bison Refcard Version \refcardversion}
|
||||||
|
|
||||||
% for copyright notices
|
% for copyright notices
|
||||||
@@ -316,7 +316,10 @@ Options can be used as: \kbd{bison {\it options} {\it filename}}
|
|||||||
\section{Command Line Options}
|
\section{Command Line Options}
|
||||||
%*****************************
|
%*****************************
|
||||||
|
|
||||||
|
\key{Display usage information.} {-h}
|
||||||
|
\key{Display version information.} {-V}
|
||||||
\key{Generate token and {\tt YYSTYPE} definitions.} {-d}
|
\key{Generate token and {\tt YYSTYPE} definitions.} {-d}
|
||||||
|
\key{Prepend a prefix to external symbols.} {-p {\it prefix}}
|
||||||
\key{Don't put {\tt \#line} directives in the parser.} {-l}
|
\key{Don't put {\tt \#line} directives in the parser.} {-l}
|
||||||
\key{Specify the output file.} {-o {\it filename}}
|
\key{Specify the output file.} {-o {\it filename}}
|
||||||
\key{Debug or {\it trace} mode.} {-t}
|
\key{Debug or {\it trace} mode.} {-t}
|
||||||
@@ -362,8 +365,8 @@ definition, {\it n} is a {\it terminal} symbol name, {\it m} is a
|
|||||||
\vskip .10truein
|
\vskip .10truein
|
||||||
|
|
||||||
The {\tt <{\it t\/}>} after {\tt \%token, \%left, \%right} and {\tt
|
The {\tt <{\it t\/}>} after {\tt \%token, \%left, \%right} and {\tt
|
||||||
\%nonassoc} is optional. Additionally, precedence may be overridden with
|
\%nonassoc} is optional. Additionally, precedence may be overridden
|
||||||
embedded {\tt \%prec} commands.
|
in the rules with {\tt \%prec} commands.
|
||||||
|
|
||||||
\section{Parser Definition Files}
|
\section{Parser Definition Files}
|
||||||
%*********************************
|
%*********************************
|
||||||
@@ -397,6 +400,7 @@ The general form for a parser definition is:
|
|||||||
|
|
||||||
Rules take the form:
|
Rules take the form:
|
||||||
|
|
||||||
|
\vskip -\baselineskip
|
||||||
\beginexample
|
\beginexample
|
||||||
non-terminal : {\it statement} 1
|
non-terminal : {\it statement} 1
|
||||||
| {\it statement} 2
|
| {\it statement} 2
|
||||||
@@ -439,15 +443,17 @@ For example:
|
|||||||
\key{Access data associated with a symbol.} {\$\$, \$0\dots\${\it n}}
|
\key{Access data associated with a symbol.} {\$\$, \$0\dots\${\it n}}
|
||||||
\key{Access a field of the data union.} {\$\$.{\it t},
|
\key{Access a field of the data union.} {\$\$.{\it t},
|
||||||
\$0.{\it t}\dots\${\it n}.{\it t}}
|
\$0.{\it t}\dots\${\it n}.{\it t}}
|
||||||
\key{Access data's line position.} {@{\it n}.{\it line\_spec}}
|
\key{Access symbol's location.} {@\$, @0\dots@{\it n}}
|
||||||
\key{Access data's column position.} {@{\it n}.{\it column\_spec}}
|
\key{Access data's line location.} {@{\it x}.{\it line\_spec}}
|
||||||
|
\key{Access data's column location.} {@{\it x}.{\it column\_spec}}
|
||||||
|
|
||||||
|
|
||||||
\vskip .10truein
|
\vskip .10truein
|
||||||
|
%
|
||||||
Where {\it t} is a type defined in the {\tt \%union}, {\it n} is a
|
Where {\it t} is a type defined in the {\tt \%union}, {\it n} is a
|
||||||
number, {\it line\_spec} one of {\tt first_line} and {\tt last_line},
|
number, {\it x} is a number or \$, {\it line\_spec} one of {\tt
|
||||||
and {\it column\_spec} is specified as either {\tt first_column} or {\tt
|
first_line} and {\tt last_line}, and {\it column\_spec} is specified
|
||||||
last_column}.
|
as either {\tt first_column} or {\tt last_column}.
|
||||||
|
|
||||||
\section {Variables and Types}
|
\section {Variables and Types}
|
||||||
%*****************************
|
%*****************************
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Makefile
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
*_.c
|
*_.c
|
||||||
.deps
|
.deps
|
||||||
Makefile
|
Makefile
|
||||||
ansi2knr
|
Makefile.in
|
||||||
|
|||||||
+50
-10
@@ -1,23 +1,63 @@
|
|||||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = ansi2knr
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program; if not, write to the Free Software
|
||||||
|
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
## 02111-1307 USA
|
||||||
|
|
||||||
|
AM_CFLAGS = $(WARNING_CFLAGS)
|
||||||
|
|
||||||
|
lib_LIBRARIES = liby.a
|
||||||
noinst_LIBRARIES = libbison.a
|
noinst_LIBRARIES = libbison.a
|
||||||
|
|
||||||
INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/src -I../intl
|
# config.h is in build/., and system.h is in src/src/.
|
||||||
|
INCLUDES = -I$(top_builddir) \
|
||||||
|
-I$(top_srcdir)/src \
|
||||||
|
-I$(top_srcdir)/lib
|
||||||
|
|
||||||
|
liby_a_SOURCES = main.c yyerror.c
|
||||||
|
|
||||||
# Heck, we are still using an old version of Automake which does not
|
# Heck, we are still using an old version of Automake which does not
|
||||||
# understand LIBOBJ additions using $objext...
|
# understand inner AC_LIBOBJ (i.e., from Autoconf itself, not from
|
||||||
|
# configure.in).
|
||||||
EXTRA_DIST = malloc.c realloc.c
|
EXTRA_DIST = malloc.c realloc.c strnlen.c
|
||||||
|
|
||||||
libbison_a_SOURCES = \
|
libbison_a_SOURCES = \
|
||||||
error.c error.h \
|
gettext.h \
|
||||||
|
basename.c dirname.h dirname.c \
|
||||||
|
get-errno.h get-errno.c \
|
||||||
getopt.h getopt.c getopt1.c \
|
getopt.h getopt.c getopt1.c \
|
||||||
hash.h hash.c \
|
hash.h hash.c \
|
||||||
obstack.h obstack.c \
|
mbswidth.h mbswidth.c \
|
||||||
quote.h quote.c quotearg.h quotearg.c \
|
quote.h quote.c quotearg.h quotearg.c \
|
||||||
xalloc.h xmalloc.c xstrdup.c
|
subpipe.h subpipe.c unlocked-io.h \
|
||||||
|
xalloc.h xmalloc.c xstrdup.c xstrndup.c \
|
||||||
|
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
||||||
|
|
||||||
libbison_a_LIBADD = @LIBOBJS@
|
# 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
|
||||||
|
|
||||||
|
# Additional bitset operations.
|
||||||
|
additional_bitsets_sources = \
|
||||||
|
bitsetv-print.h bitsetv-print.c
|
||||||
|
|
||||||
|
# timevars, stolen from GCC.
|
||||||
|
timevars_sources = \
|
||||||
|
timevar.h timevar.c timevar.def
|
||||||
|
|
||||||
|
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||||
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
||||||
|
|||||||
+826
@@ -0,0 +1,826 @@
|
|||||||
|
/* Array bitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "abitset.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* This file implements fixed size bitsets stored as an array
|
||||||
|
of words. Any unused bits in the last word must be zero. */
|
||||||
|
|
||||||
|
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||||
|
#define ABITSET_WORDS(X) ((X)->a.words)
|
||||||
|
#define ABITSET_N_BITS(X) ((X)->a.n_bits)
|
||||||
|
|
||||||
|
|
||||||
|
/* Return size in bits of bitset SRC. */
|
||||||
|
static bitset_bindex
|
||||||
|
abitset_size (bitset src)
|
||||||
|
{
|
||||||
|
return ABITSET_N_BITS (src);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
|
*NEXT and store in array LIST. Return with actual number of bits
|
||||||
|
found and with *NEXT indicating where search stopped. */
|
||||||
|
static bitset_bindex
|
||||||
|
abitset_small_list (bitset src, bitset_bindex *list,
|
||||||
|
bitset_bindex num, bitset_bindex *next)
|
||||||
|
{
|
||||||
|
bitset_bindex bitno;
|
||||||
|
bitset_bindex count;
|
||||||
|
bitset_windex size;
|
||||||
|
bitset_word word;
|
||||||
|
|
||||||
|
word = ABITSET_WORDS (src)[0];
|
||||||
|
|
||||||
|
/* Short circuit common case. */
|
||||||
|
if (!word)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
size = ABITSET_N_BITS (src);
|
||||||
|
bitno = *next;
|
||||||
|
if (bitno >= size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
word >>= bitno;
|
||||||
|
|
||||||
|
/* If num is 1, we could speed things up with a binary search
|
||||||
|
of the word of interest. */
|
||||||
|
|
||||||
|
if (num >= BITSET_WORD_BITS)
|
||||||
|
{
|
||||||
|
for (count = 0; word; bitno++)
|
||||||
|
{
|
||||||
|
if (word & 1)
|
||||||
|
list[count++] = bitno;
|
||||||
|
word >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (count = 0; word; bitno++)
|
||||||
|
{
|
||||||
|
if (word & 1)
|
||||||
|
{
|
||||||
|
list[count++] = bitno;
|
||||||
|
if (count >= num)
|
||||||
|
{
|
||||||
|
bitno++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*next = bitno;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set bit BITNO in bitset DST. */
|
||||||
|
static void
|
||||||
|
abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
/* This should never occur for abitsets since we should always
|
||||||
|
hit the cache. */
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Reset bit BITNO in bitset DST. */
|
||||||
|
static void
|
||||||
|
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
||||||
|
bitset_bindex bitno ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
/* This should never occur for abitsets since we should always
|
||||||
|
hit the cache. */
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Test bit BITNO in bitset SRC. */
|
||||||
|
static int
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find list of up to NUM bits set in BSET in reverse order, starting
|
||||||
|
from and including NEXT and store in array LIST. Return with
|
||||||
|
actual number of bits found and with *NEXT indicating where search
|
||||||
|
stopped. */
|
||||||
|
static bitset_bindex
|
||||||
|
abitset_list_reverse (bitset src, bitset_bindex *list,
|
||||||
|
bitset_bindex num, bitset_bindex *next)
|
||||||
|
{
|
||||||
|
bitset_bindex bitno;
|
||||||
|
bitset_bindex rbitno;
|
||||||
|
bitset_bindex count;
|
||||||
|
bitset_windex windex;
|
||||||
|
unsigned int bitcnt;
|
||||||
|
bitset_bindex bitoff;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_bindex n_bits = ABITSET_N_BITS (src);
|
||||||
|
|
||||||
|
rbitno = *next;
|
||||||
|
|
||||||
|
/* If num is 1, we could speed things up with a binary search
|
||||||
|
of the word of interest. */
|
||||||
|
|
||||||
|
if (rbitno >= n_bits)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
bitno = n_bits - (rbitno + 1);
|
||||||
|
|
||||||
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
|
bitcnt = bitno % BITSET_WORD_BITS;
|
||||||
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bitset_word word;
|
||||||
|
|
||||||
|
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
|
for (; word; bitcnt--)
|
||||||
|
{
|
||||||
|
if (word & BITSET_MSB)
|
||||||
|
{
|
||||||
|
list[count++] = bitoff + bitcnt;
|
||||||
|
if (count >= num)
|
||||||
|
{
|
||||||
|
*next = n_bits - (bitoff + bitcnt);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word <<= 1;
|
||||||
|
}
|
||||||
|
bitoff -= BITSET_WORD_BITS;
|
||||||
|
bitcnt = BITSET_WORD_BITS - 1;
|
||||||
|
}
|
||||||
|
while (windex--);
|
||||||
|
|
||||||
|
*next = n_bits - (bitoff + 1);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
|
*NEXT and store in array LIST. Return with actual number of bits
|
||||||
|
found and with *NEXT indicating where search stopped. */
|
||||||
|
static bitset_bindex
|
||||||
|
abitset_list (bitset src, bitset_bindex *list,
|
||||||
|
bitset_bindex num, bitset_bindex *next)
|
||||||
|
{
|
||||||
|
bitset_bindex bitno;
|
||||||
|
bitset_bindex count;
|
||||||
|
bitset_windex windex;
|
||||||
|
bitset_bindex bitoff;
|
||||||
|
bitset_windex size = src->b.csize;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word word;
|
||||||
|
|
||||||
|
bitno = *next;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (!bitno)
|
||||||
|
{
|
||||||
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
|
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||||
|
continue;
|
||||||
|
if (windex >= size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* If num is 1, we could speed things up with a binary search
|
||||||
|
of the current word. */
|
||||||
|
|
||||||
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bitno >= ABITSET_N_BITS (src))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
|
bitno = bitno % BITSET_WORD_BITS;
|
||||||
|
|
||||||
|
if (bitno)
|
||||||
|
{
|
||||||
|
/* Handle the case where we start within a word.
|
||||||
|
Most often, this is executed with large bitsets
|
||||||
|
with many set bits where we filled the array
|
||||||
|
on the previous call to this function. */
|
||||||
|
|
||||||
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
word = srcp[windex] >> bitno;
|
||||||
|
for (bitno = bitoff + bitno; word; bitno++)
|
||||||
|
{
|
||||||
|
if (word & 1)
|
||||||
|
{
|
||||||
|
list[count++] = bitno;
|
||||||
|
if (count >= num)
|
||||||
|
{
|
||||||
|
*next = bitno + 1;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word >>= 1;
|
||||||
|
}
|
||||||
|
windex++;
|
||||||
|
}
|
||||||
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||||
|
{
|
||||||
|
if (!(word = srcp[windex]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((count + BITSET_WORD_BITS) < num)
|
||||||
|
{
|
||||||
|
for (bitno = bitoff; word; bitno++)
|
||||||
|
{
|
||||||
|
if (word & 1)
|
||||||
|
list[count++] = bitno;
|
||||||
|
word >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (bitno = bitoff; word; bitno++)
|
||||||
|
{
|
||||||
|
if (word & 1)
|
||||||
|
{
|
||||||
|
list[count++] = bitno;
|
||||||
|
if (count >= num)
|
||||||
|
{
|
||||||
|
*next = bitno + 1;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*next = bitoff;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Ensure that any unused bits within the last word are clear. */
|
||||||
|
static inline void
|
||||||
|
abitset_unused_clear (bitset dst)
|
||||||
|
{
|
||||||
|
unsigned int last_bit;
|
||||||
|
|
||||||
|
last_bit = ABITSET_N_BITS (dst) % BITSET_WORD_BITS;
|
||||||
|
if (last_bit)
|
||||||
|
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||||
|
((bitset_word) 1 << last_bit) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_ones (bitset dst)
|
||||||
|
{
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
|
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
|
memset (dstp, -1, bytes);
|
||||||
|
abitset_unused_clear (dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_zero (bitset dst)
|
||||||
|
{
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
|
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||||
|
|
||||||
|
memset (dstp, 0, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_empty_p (bitset dst)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
|
||||||
|
for (i = 0; i < dst->b.csize; i++)
|
||||||
|
if (dstp[i])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_copy1 (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
if (srcp == dstp)
|
||||||
|
return;
|
||||||
|
memcpy (dstp, srcp, sizeof (bitset_word) * size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_not (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = ~(*srcp++);
|
||||||
|
abitset_unused_clear (dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_equal_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
if (*srcp++ != *dstp++)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_subset_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||||
|
if (*dstp != (*srcp | *dstp))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_disjoint_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *srcp = ABITSET_WORDS (src);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
if (*srcp++ & *dstp++)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_and (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = *src1p++ & *src2p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_andn (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = *src1p++ & ~(*src2p++);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_or (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = *src1p++ | *src2p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_xor (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = *src1p++ ^ *src2p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
int changed = 0;
|
||||||
|
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||||
|
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||||
|
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||||
|
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||||
|
bitset_windex size = dst->b.csize;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, dstp++)
|
||||||
|
{
|
||||||
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
|
if (*dstp != tmp)
|
||||||
|
{
|
||||||
|
changed = 1;
|
||||||
|
*dstp = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
abitset_copy (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
if (BITSET_COMPATIBLE_ (dst, src))
|
||||||
|
abitset_copy1 (dst, src);
|
||||||
|
else
|
||||||
|
bitset_copy_ (dst, src);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Vector of operations for single word bitsets. */
|
||||||
|
struct bitset_vtable abitset_small_vtable = {
|
||||||
|
abitset_set,
|
||||||
|
abitset_reset,
|
||||||
|
bitset_toggle_,
|
||||||
|
abitset_test,
|
||||||
|
abitset_size,
|
||||||
|
bitset_count_,
|
||||||
|
abitset_empty_p,
|
||||||
|
abitset_ones,
|
||||||
|
abitset_zero,
|
||||||
|
abitset_copy,
|
||||||
|
abitset_disjoint_p,
|
||||||
|
abitset_equal_p,
|
||||||
|
abitset_not,
|
||||||
|
abitset_subset_p,
|
||||||
|
abitset_and,
|
||||||
|
abitset_and_cmp,
|
||||||
|
abitset_andn,
|
||||||
|
abitset_andn_cmp,
|
||||||
|
abitset_or,
|
||||||
|
abitset_or_cmp,
|
||||||
|
abitset_xor,
|
||||||
|
abitset_xor_cmp,
|
||||||
|
abitset_and_or,
|
||||||
|
abitset_and_or_cmp,
|
||||||
|
abitset_andn_or,
|
||||||
|
abitset_andn_or_cmp,
|
||||||
|
abitset_or_and,
|
||||||
|
abitset_or_and_cmp,
|
||||||
|
abitset_small_list,
|
||||||
|
abitset_list_reverse,
|
||||||
|
NULL,
|
||||||
|
BITSET_ARRAY
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Vector of operations for multiple word bitsets. */
|
||||||
|
struct bitset_vtable abitset_vtable = {
|
||||||
|
abitset_set,
|
||||||
|
abitset_reset,
|
||||||
|
bitset_toggle_,
|
||||||
|
abitset_test,
|
||||||
|
abitset_size,
|
||||||
|
bitset_count_,
|
||||||
|
abitset_empty_p,
|
||||||
|
abitset_ones,
|
||||||
|
abitset_zero,
|
||||||
|
abitset_copy,
|
||||||
|
abitset_disjoint_p,
|
||||||
|
abitset_equal_p,
|
||||||
|
abitset_not,
|
||||||
|
abitset_subset_p,
|
||||||
|
abitset_and,
|
||||||
|
abitset_and_cmp,
|
||||||
|
abitset_andn,
|
||||||
|
abitset_andn_cmp,
|
||||||
|
abitset_or,
|
||||||
|
abitset_or_cmp,
|
||||||
|
abitset_xor,
|
||||||
|
abitset_xor_cmp,
|
||||||
|
abitset_and_or,
|
||||||
|
abitset_and_or_cmp,
|
||||||
|
abitset_andn_or,
|
||||||
|
abitset_andn_or_cmp,
|
||||||
|
abitset_or_and,
|
||||||
|
abitset_or_and_cmp,
|
||||||
|
abitset_list,
|
||||||
|
abitset_list_reverse,
|
||||||
|
NULL,
|
||||||
|
BITSET_ARRAY
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
size_t
|
||||||
|
abitset_bytes (bitset_bindex n_bits)
|
||||||
|
{
|
||||||
|
bitset_windex size;
|
||||||
|
size_t bytes;
|
||||||
|
size_t header_size = offsetof (union bitset_union, a.words);
|
||||||
|
struct bitset_align_struct { char a; union bitset_union b; };
|
||||||
|
size_t bitset_alignment = offsetof (struct bitset_align_struct, b);
|
||||||
|
|
||||||
|
size = ABITSET_N_WORDS (n_bits);
|
||||||
|
bytes = header_size + size * sizeof (bitset_word);
|
||||||
|
|
||||||
|
/* Align the size properly for a vector of abitset objects. */
|
||||||
|
if (header_size % bitset_alignment != 0
|
||||||
|
|| sizeof (bitset_word) % bitset_alignment != 0)
|
||||||
|
{
|
||||||
|
bytes += bitset_alignment - 1;
|
||||||
|
bytes -= bytes % bitset_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bitset
|
||||||
|
abitset_init (bitset bset, bitset_bindex n_bits)
|
||||||
|
{
|
||||||
|
bitset_windex size;
|
||||||
|
|
||||||
|
size = ABITSET_N_WORDS (n_bits);
|
||||||
|
ABITSET_N_BITS (bset) = n_bits;
|
||||||
|
|
||||||
|
/* Use optimized routines if bitset fits within a single word.
|
||||||
|
There is probably little merit if using caching since
|
||||||
|
the small bitset will always fit in the cache. */
|
||||||
|
if (size == 1)
|
||||||
|
bset->b.vtable = &abitset_small_vtable;
|
||||||
|
else
|
||||||
|
bset->b.vtable = &abitset_vtable;
|
||||||
|
|
||||||
|
bset->b.cindex = 0;
|
||||||
|
bset->b.csize = size;
|
||||||
|
bset->b.cdata = ABITSET_WORDS (bset);
|
||||||
|
return bset;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/* Functions to support abitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _ABITSET_H
|
||||||
|
#define _ABITSET_H
|
||||||
|
|
||||||
|
#include "bitset.h"
|
||||||
|
|
||||||
|
extern size_t abitset_bytes PARAMS ((bitset_bindex));
|
||||||
|
|
||||||
|
extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
#endif
|
||||||
+26
-22
@@ -25,15 +25,23 @@
|
|||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#if HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STDLIB_H
|
#if HAVE_STDLIB_H
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef emacs
|
#ifdef emacs
|
||||||
|
# include "lisp.h"
|
||||||
# include "blockinput.h"
|
# include "blockinput.h"
|
||||||
|
# define xalloc_die() memory_full ()
|
||||||
|
# ifdef EMACS_FREE
|
||||||
|
# undef free
|
||||||
|
# define free EMACS_FREE
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <xalloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If compiling with GCC 2, this file's not needed. */
|
/* If compiling with GCC 2, this file's not needed. */
|
||||||
@@ -53,6 +61,8 @@
|
|||||||
you
|
you
|
||||||
lose
|
lose
|
||||||
-- must know STACK_DIRECTION at compile-time
|
-- 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 /* STACK_DIRECTION undefined */
|
||||||
# endif /* static */
|
# endif /* static */
|
||||||
# endif /* emacs */
|
# endif /* emacs */
|
||||||
@@ -67,31 +77,19 @@ long i00afunc ();
|
|||||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#if __STDC__
|
# ifndef POINTER_TYPE
|
||||||
typedef void *pointer;
|
# ifdef __STDC__
|
||||||
|
# define POINTER_TYPE void
|
||||||
# else
|
# else
|
||||||
typedef char *pointer;
|
# define POINTER_TYPE char
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
typedef POINTER_TYPE *pointer;
|
||||||
|
|
||||||
# ifndef NULL
|
# ifndef NULL
|
||||||
# define NULL 0
|
# define NULL 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Different portions of Emacs need to call different versions of
|
|
||||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
|
||||||
ordinary malloc isn't protected from input signals. On the other
|
|
||||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
|
||||||
them are very simple, and don't have an xmalloc routine.
|
|
||||||
|
|
||||||
Non-Emacs programs expect this to call use xmalloc.
|
|
||||||
|
|
||||||
Callers below should use malloc. */
|
|
||||||
|
|
||||||
#ifndef emacs
|
|
||||||
#define malloc xmalloc
|
|
||||||
#endif
|
|
||||||
extern pointer malloc ();
|
|
||||||
|
|
||||||
/* Define STACK_DIRECTION if you know the direction of stack
|
/* Define STACK_DIRECTION if you know the direction of stack
|
||||||
growth for your system; otherwise it will be automatically
|
growth for your system; otherwise it will be automatically
|
||||||
deduced at run-time.
|
deduced at run-time.
|
||||||
@@ -169,7 +167,7 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
|
|||||||
|
|
||||||
pointer
|
pointer
|
||||||
alloca (size)
|
alloca (size)
|
||||||
unsigned size;
|
size_t size;
|
||||||
{
|
{
|
||||||
auto char probe; /* Probes stack depth: */
|
auto char probe; /* Probes stack depth: */
|
||||||
register char *depth = ADDRESS_FUNCTION (probe);
|
register char *depth = ADDRESS_FUNCTION (probe);
|
||||||
@@ -215,8 +213,14 @@ alloca (size)
|
|||||||
/* Allocate combined header + user data storage. */
|
/* Allocate combined header + user data storage. */
|
||||||
|
|
||||||
{
|
{
|
||||||
register pointer new = malloc (sizeof (header) + size);
|
|
||||||
/* Address of header. */
|
/* 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)
|
if (new == 0)
|
||||||
abort();
|
abort();
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
.TH ANSI2KNR 1 "19 Jan 1996"
|
|
||||||
.SH NAME
|
|
||||||
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.I ansi2knr
|
|
||||||
[--varargs] input_file [output_file]
|
|
||||||
.SH DESCRIPTION
|
|
||||||
If no output_file is supplied, output goes to stdout.
|
|
||||||
.br
|
|
||||||
There are no error messages.
|
|
||||||
.sp
|
|
||||||
.I ansi2knr
|
|
||||||
recognizes function definitions by seeing a non-keyword identifier at the left
|
|
||||||
margin, followed by a left parenthesis, with a right parenthesis as the last
|
|
||||||
character on the line, and with a left brace as the first token on the
|
|
||||||
following line (ignoring possible intervening comments). It will recognize a
|
|
||||||
multi-line header provided that no intervening line ends with a left or right
|
|
||||||
brace or a semicolon. These algorithms ignore whitespace and comments, except
|
|
||||||
that the function name must be the first thing on the line.
|
|
||||||
.sp
|
|
||||||
The following constructs will confuse it:
|
|
||||||
.br
|
|
||||||
- Any other construct that starts at the left margin and follows the
|
|
||||||
above syntax (such as a macro or function call).
|
|
||||||
.br
|
|
||||||
- Some macros that tinker with the syntax of the function header.
|
|
||||||
.sp
|
|
||||||
The --varargs switch is obsolete, and is recognized only for
|
|
||||||
backwards compatibility. The present version of
|
|
||||||
.I ansi2knr
|
|
||||||
will always attempt to convert a ... argument to va_alist and va_dcl.
|
|
||||||
.SH AUTHOR
|
|
||||||
L. Peter Deutsch <[email protected]> wrote the original ansi2knr and
|
|
||||||
continues to maintain the current version; most of the code in the current
|
|
||||||
version is his work. ansi2knr also includes contributions by Francois
|
|
||||||
Pinard <[email protected]> and Jim Avera <[email protected]>.
|
|
||||||
-609
@@ -1,609 +0,0 @@
|
|||||||
/* Copyright (C) 1989, 1997, 1998 Aladdin Enterprises. All rights reserved. */
|
|
||||||
|
|
||||||
/*$Id$*/
|
|
||||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
|
|
||||||
|
|
||||||
/*
|
|
||||||
ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY. No author or distributor accepts responsibility to anyone for the
|
|
||||||
consequences of using it or for whether it serves any particular purpose or
|
|
||||||
works at all, unless he says so in writing. Refer to the GNU General Public
|
|
||||||
License (the "GPL") for full details.
|
|
||||||
|
|
||||||
Everyone is granted permission to copy, modify and redistribute ansi2knr,
|
|
||||||
but only under the conditions described in the GPL. A copy of this license
|
|
||||||
is supposed to have been given to you along with ansi2knr so you can know
|
|
||||||
your rights and responsibilities. It should be in a file named COPYLEFT,
|
|
||||||
or, if there is no file named COPYLEFT, a file named COPYING. Among other
|
|
||||||
things, the copyright notice and this notice must be preserved on all
|
|
||||||
copies.
|
|
||||||
|
|
||||||
We explicitly state here what we believe is already implied by the GPL: if
|
|
||||||
the ansi2knr program is distributed as a separate set of sources and a
|
|
||||||
separate executable file which are aggregated on a storage medium together
|
|
||||||
with another program, this in itself does not bring the other program under
|
|
||||||
the GPL, nor does the mere fact that such a program or the procedures for
|
|
||||||
constructing it invoke the ansi2knr executable bring any other part of the
|
|
||||||
program under the GPL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Usage:
|
|
||||||
ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]
|
|
||||||
* --filename provides the file name for the #line directive in the output,
|
|
||||||
* overriding input_file (if present).
|
|
||||||
* If no input_file is supplied, input is read from stdin.
|
|
||||||
* If no output_file is supplied, output goes to stdout.
|
|
||||||
* There are no error messages.
|
|
||||||
*
|
|
||||||
* ansi2knr recognizes function definitions by seeing a non-keyword
|
|
||||||
* identifier at the left margin, followed by a left parenthesis,
|
|
||||||
* with a right parenthesis as the last character on the line,
|
|
||||||
* and with a left brace as the first token on the following line
|
|
||||||
* (ignoring possible intervening comments), except that a line
|
|
||||||
* consisting of only
|
|
||||||
* identifier1(identifier2)
|
|
||||||
* will not be considered a function definition unless identifier2 is
|
|
||||||
* the word "void". ansi2knr will recognize a multi-line header provided
|
|
||||||
* that no intervening line ends with a left or right brace or a semicolon.
|
|
||||||
* These algorithms ignore whitespace and comments, except that
|
|
||||||
* the function name must be the first thing on the line.
|
|
||||||
* The following constructs will confuse it:
|
|
||||||
* - Any other construct that starts at the left margin and
|
|
||||||
* follows the above syntax (such as a macro or function call).
|
|
||||||
* - Some macros that tinker with the syntax of the function header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The original and principal author of ansi2knr is L. Peter Deutsch
|
|
||||||
* <[email protected]>. Other authors are noted in the change history
|
|
||||||
* that follows (in reverse chronological order):
|
|
||||||
lpd 1998-11-09 added further hack to recognize identifier(void)
|
|
||||||
as being a procedure
|
|
||||||
lpd 1998-10-23 added hack to recognize lines consisting of
|
|
||||||
identifier1(identifier2) as *not* being procedures
|
|
||||||
lpd 1997-12-08 made input_file optional; only closes input and/or
|
|
||||||
output file if not stdin or stdout respectively; prints
|
|
||||||
usage message on stderr rather than stdout; adds
|
|
||||||
--filename switch (changes suggested by
|
|
||||||
<[email protected]>)
|
|
||||||
lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with
|
|
||||||
compilers that don't understand void, as suggested by
|
|
||||||
Tom Lane
|
|
||||||
lpd 1996-01-15 changed to require that the first non-comment token
|
|
||||||
on the line following a function header be a left brace,
|
|
||||||
to reduce sensitivity to macros, as suggested by Tom Lane
|
|
||||||
<[email protected]>
|
|
||||||
lpd 1995-06-22 removed #ifndefs whose sole purpose was to define
|
|
||||||
undefined preprocessor symbols as 0; changed all #ifdefs
|
|
||||||
for configuration symbols to #ifs
|
|
||||||
lpd 1995-04-05 changed copyright notice to make it clear that
|
|
||||||
including ansi2knr in a program does not bring the entire
|
|
||||||
program under the GPL
|
|
||||||
lpd 1994-12-18 added conditionals for systems where ctype macros
|
|
||||||
don't handle 8-bit characters properly, suggested by
|
|
||||||
Francois Pinard <[email protected]>;
|
|
||||||
removed --varargs switch (this is now the default)
|
|
||||||
lpd 1994-10-10 removed CONFIG_BROKETS conditional
|
|
||||||
lpd 1994-07-16 added some conditionals to help GNU `configure',
|
|
||||||
suggested by Francois Pinard <[email protected]>;
|
|
||||||
properly erase prototype args in function parameters,
|
|
||||||
contributed by Jim Avera <[email protected]>;
|
|
||||||
correct error in writeblanks (it shouldn't erase EOLs)
|
|
||||||
lpd 1989-xx-xx original version
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Most of the conditionals here are to make ansi2knr work with */
|
|
||||||
/* or without the GNU configure machinery. */
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
|
|
||||||
This will define HAVE_CONFIG_H and so, activate the following lines.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# if STDC_HEADERS || HAVE_STRING_H
|
|
||||||
# include <string.h>
|
|
||||||
# else
|
|
||||||
# include <strings.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else /* not HAVE_CONFIG_H */
|
|
||||||
|
|
||||||
/* Otherwise do it the hard way */
|
|
||||||
|
|
||||||
# ifdef BSD
|
|
||||||
# include <strings.h>
|
|
||||||
# else
|
|
||||||
# ifdef VMS
|
|
||||||
extern int strlen(), strncmp();
|
|
||||||
# else
|
|
||||||
# include <string.h>
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif /* not HAVE_CONFIG_H */
|
|
||||||
|
|
||||||
#if STDC_HEADERS
|
|
||||||
# include <stdlib.h>
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
malloc and free should be declared in stdlib.h,
|
|
||||||
but if you've got a K&R compiler, they probably aren't.
|
|
||||||
*/
|
|
||||||
# ifdef MSDOS
|
|
||||||
# include <malloc.h>
|
|
||||||
# else
|
|
||||||
# ifdef VMS
|
|
||||||
extern char *malloc();
|
|
||||||
extern void free();
|
|
||||||
# else
|
|
||||||
extern char *malloc();
|
|
||||||
extern int free();
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The ctype macros don't always handle 8-bit characters correctly.
|
|
||||||
* Compensate for this here.
|
|
||||||
*/
|
|
||||||
#ifdef isascii
|
|
||||||
# undef HAVE_ISASCII /* just in case */
|
|
||||||
# define HAVE_ISASCII 1
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
#if STDC_HEADERS || !HAVE_ISASCII
|
|
||||||
# define is_ascii(c) 1
|
|
||||||
#else
|
|
||||||
# define is_ascii(c) isascii(c)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define is_space(c) (is_ascii(c) && isspace(c))
|
|
||||||
#define is_alpha(c) (is_ascii(c) && isalpha(c))
|
|
||||||
#define is_alnum(c) (is_ascii(c) && isalnum(c))
|
|
||||||
|
|
||||||
/* Scanning macros */
|
|
||||||
#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
|
|
||||||
#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
|
|
||||||
|
|
||||||
/* Forward references */
|
|
||||||
char *skipspace();
|
|
||||||
int writeblanks();
|
|
||||||
int test1();
|
|
||||||
int convert1();
|
|
||||||
|
|
||||||
/* The main program */
|
|
||||||
int
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{ FILE *in = stdin;
|
|
||||||
FILE *out = stdout;
|
|
||||||
char *filename = 0;
|
|
||||||
#define bufsize 5000 /* arbitrary size */
|
|
||||||
char *buf;
|
|
||||||
char *line;
|
|
||||||
char *more;
|
|
||||||
char *usage =
|
|
||||||
"Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n";
|
|
||||||
/*
|
|
||||||
* In previous versions, ansi2knr recognized a --varargs switch.
|
|
||||||
* If this switch was supplied, ansi2knr would attempt to convert
|
|
||||||
* a ... argument to va_alist and va_dcl; if this switch was not
|
|
||||||
* supplied, ansi2knr would simply drop any such arguments.
|
|
||||||
* Now, ansi2knr always does this conversion, and we only
|
|
||||||
* check for this switch for backward compatibility.
|
|
||||||
*/
|
|
||||||
int convert_varargs = 1;
|
|
||||||
|
|
||||||
while ( argc > 1 && argv[1][0] == '-' ) {
|
|
||||||
if ( !strcmp(argv[1], "--varargs") ) {
|
|
||||||
convert_varargs = 1;
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( !strcmp(argv[1], "--filename") && argc > 2 ) {
|
|
||||||
filename = argv[2];
|
|
||||||
argc -= 2;
|
|
||||||
argv += 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
|
|
||||||
fprintf(stderr, usage);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
switch ( argc )
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
fprintf(stderr, usage);
|
|
||||||
exit(0);
|
|
||||||
case 3:
|
|
||||||
out = fopen(argv[2], "w");
|
|
||||||
if ( out == NULL ) {
|
|
||||||
fprintf(stderr, "Cannot open output file %s\n", argv[2]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
/* falls through */
|
|
||||||
case 2:
|
|
||||||
in = fopen(argv[1], "r");
|
|
||||||
if ( in == NULL ) {
|
|
||||||
fprintf(stderr, "Cannot open input file %s\n", argv[1]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if ( filename == 0 )
|
|
||||||
filename = argv[1];
|
|
||||||
/* falls through */
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( filename )
|
|
||||||
fprintf(out, "#line 1 \"%s\"\n", filename);
|
|
||||||
buf = malloc(bufsize);
|
|
||||||
line = buf;
|
|
||||||
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
|
||||||
{
|
|
||||||
test: line += strlen(line);
|
|
||||||
switch ( test1(buf) )
|
|
||||||
{
|
|
||||||
case 2: /* a function header */
|
|
||||||
convert1(buf, out, 1, convert_varargs);
|
|
||||||
break;
|
|
||||||
case 1: /* a function */
|
|
||||||
/* Check for a { at the start of the next line. */
|
|
||||||
more = ++line;
|
|
||||||
f: if ( line >= buf + (bufsize - 1) ) /* overflow check */
|
|
||||||
goto wl;
|
|
||||||
if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
|
|
||||||
goto wl;
|
|
||||||
switch ( *skipspace(more, 1) )
|
|
||||||
{
|
|
||||||
case '{':
|
|
||||||
/* Definitely a function header. */
|
|
||||||
convert1(buf, out, 0, convert_varargs);
|
|
||||||
fputs(more, out);
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
/* The next line was blank or a comment: */
|
|
||||||
/* keep scanning for a non-comment. */
|
|
||||||
line += strlen(line);
|
|
||||||
goto f;
|
|
||||||
default:
|
|
||||||
/* buf isn't a function header, but */
|
|
||||||
/* more might be. */
|
|
||||||
fputs(buf, out);
|
|
||||||
strcpy(buf, more);
|
|
||||||
line = buf;
|
|
||||||
goto test;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case -1: /* maybe the start of a function */
|
|
||||||
if ( line != buf + (bufsize - 1) ) /* overflow check */
|
|
||||||
continue;
|
|
||||||
/* falls through */
|
|
||||||
default: /* not a function */
|
|
||||||
wl: fputs(buf, out);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
line = buf;
|
|
||||||
}
|
|
||||||
if ( line != buf )
|
|
||||||
fputs(buf, out);
|
|
||||||
free(buf);
|
|
||||||
if ( out != stdout )
|
|
||||||
fclose(out);
|
|
||||||
if ( in != stdin )
|
|
||||||
fclose(in);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip over space and comments, in either direction. */
|
|
||||||
char *
|
|
||||||
skipspace(p, dir)
|
|
||||||
register char *p;
|
|
||||||
register int dir; /* 1 for forward, -1 for backward */
|
|
||||||
{ for ( ; ; )
|
|
||||||
{ while ( is_space(*p) )
|
|
||||||
p += dir;
|
|
||||||
if ( !(*p == '/' && p[dir] == '*') )
|
|
||||||
break;
|
|
||||||
p += dir; p += dir;
|
|
||||||
while ( !(*p == '*' && p[dir] == '/') )
|
|
||||||
{ if ( *p == 0 )
|
|
||||||
return p; /* multi-line comment?? */
|
|
||||||
p += dir;
|
|
||||||
}
|
|
||||||
p += dir; p += dir;
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write blanks over part of a string.
|
|
||||||
* Don't overwrite end-of-line characters.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
writeblanks(start, end)
|
|
||||||
char *start;
|
|
||||||
char *end;
|
|
||||||
{ char *p;
|
|
||||||
for ( p = start; p < end; p++ )
|
|
||||||
if ( *p != '\r' && *p != '\n' )
|
|
||||||
*p = ' ';
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Test whether the string in buf is a function definition.
|
|
||||||
* The string may contain and/or end with a newline.
|
|
||||||
* Return as follows:
|
|
||||||
* 0 - definitely not a function definition;
|
|
||||||
* 1 - definitely a function definition;
|
|
||||||
* 2 - definitely a function prototype (NOT USED);
|
|
||||||
* -1 - may be the beginning of a function definition,
|
|
||||||
* append another line and look again.
|
|
||||||
* The reason we don't attempt to convert function prototypes is that
|
|
||||||
* Ghostscript's declaration-generating macros look too much like
|
|
||||||
* prototypes, and confuse the algorithms.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
test1(buf)
|
|
||||||
char *buf;
|
|
||||||
{ register char *p = buf;
|
|
||||||
char *bend;
|
|
||||||
char *endfn;
|
|
||||||
int contin;
|
|
||||||
|
|
||||||
if ( !isidfirstchar(*p) )
|
|
||||||
return 0; /* no name at left margin */
|
|
||||||
bend = skipspace(buf + strlen(buf) - 1, -1);
|
|
||||||
switch ( *bend )
|
|
||||||
{
|
|
||||||
case ';': contin = 0 /*2*/; break;
|
|
||||||
case ')': contin = 1; break;
|
|
||||||
case '{': return 0; /* not a function */
|
|
||||||
case '}': return 0; /* not a function */
|
|
||||||
default: contin = -1;
|
|
||||||
}
|
|
||||||
while ( isidchar(*p) )
|
|
||||||
p++;
|
|
||||||
endfn = p;
|
|
||||||
p = skipspace(p, 1);
|
|
||||||
if ( *p++ != '(' )
|
|
||||||
return 0; /* not a function */
|
|
||||||
p = skipspace(p, 1);
|
|
||||||
if ( *p == ')' )
|
|
||||||
return 0; /* no parameters */
|
|
||||||
/* Check that the apparent function name isn't a keyword. */
|
|
||||||
/* We only need to check for keywords that could be followed */
|
|
||||||
/* by a left parenthesis (which, unfortunately, is most of them). */
|
|
||||||
{ static char *words[] =
|
|
||||||
{ "asm", "auto", "case", "char", "const", "double",
|
|
||||||
"extern", "float", "for", "if", "int", "long",
|
|
||||||
"register", "return", "short", "signed", "sizeof",
|
|
||||||
"static", "switch", "typedef", "unsigned",
|
|
||||||
"void", "volatile", "while", 0
|
|
||||||
};
|
|
||||||
char **key = words;
|
|
||||||
char *kp;
|
|
||||||
int len = endfn - buf;
|
|
||||||
|
|
||||||
while ( (kp = *key) != 0 )
|
|
||||||
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
|
||||||
return 0; /* name is a keyword */
|
|
||||||
key++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
char *id = p;
|
|
||||||
int len;
|
|
||||||
/*
|
|
||||||
* Check for identifier1(identifier2) and not
|
|
||||||
* identifier1(void).
|
|
||||||
*/
|
|
||||||
|
|
||||||
while ( isidchar(*p) )
|
|
||||||
p++;
|
|
||||||
len = p - id;
|
|
||||||
p = skipspace(p, 1);
|
|
||||||
if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) )
|
|
||||||
return 0; /* not a function */
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If the last significant character was a ), we need to count
|
|
||||||
* parentheses, because it might be part of a formal parameter
|
|
||||||
* that is a procedure.
|
|
||||||
*/
|
|
||||||
if (contin > 0) {
|
|
||||||
int level = 0;
|
|
||||||
|
|
||||||
for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1))
|
|
||||||
level += (*p == '(' ? 1 : *p == ')' ? -1 : 0);
|
|
||||||
if (level > 0)
|
|
||||||
contin = -1;
|
|
||||||
}
|
|
||||||
return contin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert a recognized function definition or header to K&R syntax. */
|
|
||||||
int
|
|
||||||
convert1(buf, out, header, convert_varargs)
|
|
||||||
char *buf;
|
|
||||||
FILE *out;
|
|
||||||
int header; /* Boolean */
|
|
||||||
int convert_varargs; /* Boolean */
|
|
||||||
{ char *endfn;
|
|
||||||
register char *p;
|
|
||||||
/*
|
|
||||||
* The breaks table contains pointers to the beginning and end
|
|
||||||
* of each argument.
|
|
||||||
*/
|
|
||||||
char **breaks;
|
|
||||||
unsigned num_breaks = 2; /* for testing */
|
|
||||||
char **btop;
|
|
||||||
char **bp;
|
|
||||||
char **ap;
|
|
||||||
char *vararg = 0;
|
|
||||||
|
|
||||||
/* Pre-ANSI implementations don't agree on whether strchr */
|
|
||||||
/* is called strchr or index, so we open-code it here. */
|
|
||||||
for ( endfn = buf; *(endfn++) != '('; )
|
|
||||||
;
|
|
||||||
top: p = endfn;
|
|
||||||
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
|
||||||
if ( breaks == 0 )
|
|
||||||
{ /* Couldn't allocate break table, give up */
|
|
||||||
fprintf(stderr, "Unable to allocate break table!\n");
|
|
||||||
fputs(buf, out);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
btop = breaks + num_breaks * 2 - 2;
|
|
||||||
bp = breaks;
|
|
||||||
/* Parse the argument list */
|
|
||||||
do
|
|
||||||
{ int level = 0;
|
|
||||||
char *lp = NULL;
|
|
||||||
char *rp;
|
|
||||||
char *end = NULL;
|
|
||||||
|
|
||||||
if ( bp >= btop )
|
|
||||||
{ /* Filled up break table. */
|
|
||||||
/* Allocate a bigger one and start over. */
|
|
||||||
free((char *)breaks);
|
|
||||||
num_breaks <<= 1;
|
|
||||||
goto top;
|
|
||||||
}
|
|
||||||
*bp++ = p;
|
|
||||||
/* Find the end of the argument */
|
|
||||||
for ( ; end == NULL; p++ )
|
|
||||||
{ switch(*p)
|
|
||||||
{
|
|
||||||
case ',':
|
|
||||||
if ( !level ) end = p;
|
|
||||||
break;
|
|
||||||
case '(':
|
|
||||||
if ( !level ) lp = p;
|
|
||||||
level++;
|
|
||||||
break;
|
|
||||||
case ')':
|
|
||||||
if ( --level < 0 ) end = p;
|
|
||||||
else rp = p;
|
|
||||||
break;
|
|
||||||
case '/':
|
|
||||||
p = skipspace(p, 1) - 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Erase any embedded prototype parameters. */
|
|
||||||
if ( lp )
|
|
||||||
writeblanks(lp + 1, rp);
|
|
||||||
p--; /* back up over terminator */
|
|
||||||
/* Find the name being declared. */
|
|
||||||
/* This is complicated because of procedure and */
|
|
||||||
/* array modifiers. */
|
|
||||||
for ( ; ; )
|
|
||||||
{ p = skipspace(p - 1, -1);
|
|
||||||
switch ( *p )
|
|
||||||
{
|
|
||||||
case ']': /* skip array dimension(s) */
|
|
||||||
case ')': /* skip procedure args OR name */
|
|
||||||
{ int level = 1;
|
|
||||||
while ( level )
|
|
||||||
switch ( *--p )
|
|
||||||
{
|
|
||||||
case ']': case ')': level++; break;
|
|
||||||
case '[': case '(': level--; break;
|
|
||||||
case '/': p = skipspace(p, -1) + 1; break;
|
|
||||||
default: ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
|
|
||||||
{ /* We found the name being declared */
|
|
||||||
while ( !isidfirstchar(*p) )
|
|
||||||
p = skipspace(p, 1) + 1;
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
|
|
||||||
{ if ( convert_varargs )
|
|
||||||
{ *bp++ = "va_alist";
|
|
||||||
vararg = p-2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ p++;
|
|
||||||
if ( bp == breaks + 1 ) /* sole argument */
|
|
||||||
writeblanks(breaks[0], p);
|
|
||||||
else
|
|
||||||
writeblanks(bp[-1] - 1, p);
|
|
||||||
bp--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ while ( isidchar(*p) ) p--;
|
|
||||||
*bp++ = p+1;
|
|
||||||
}
|
|
||||||
p = end;
|
|
||||||
}
|
|
||||||
while ( *p++ == ',' );
|
|
||||||
*bp = p;
|
|
||||||
/* Make a special check for 'void' arglist */
|
|
||||||
if ( bp == breaks+2 )
|
|
||||||
{ p = skipspace(breaks[0], 1);
|
|
||||||
if ( !strncmp(p, "void", 4) )
|
|
||||||
{ p = skipspace(p+4, 1);
|
|
||||||
if ( p == breaks[2] - 1 )
|
|
||||||
{ bp = breaks; /* yup, pretend arglist is empty */
|
|
||||||
writeblanks(breaks[0], p + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Put out the function name and left parenthesis. */
|
|
||||||
p = buf;
|
|
||||||
while ( p != endfn ) putc(*p, out), p++;
|
|
||||||
/* Put out the declaration. */
|
|
||||||
if ( header )
|
|
||||||
{ fputs(");", out);
|
|
||||||
for ( p = breaks[0]; *p; p++ )
|
|
||||||
if ( *p == '\r' || *p == '\n' )
|
|
||||||
putc(*p, out);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ for ( ap = breaks+1; ap < bp; ap += 2 )
|
|
||||||
{ p = *ap;
|
|
||||||
while ( isidchar(*p) )
|
|
||||||
putc(*p, out), p++;
|
|
||||||
if ( ap < bp - 1 )
|
|
||||||
fputs(", ", out);
|
|
||||||
}
|
|
||||||
fputs(") ", out);
|
|
||||||
/* Put out the argument declarations */
|
|
||||||
for ( ap = breaks+2; ap <= bp; ap += 2 )
|
|
||||||
(*ap)[-1] = ';';
|
|
||||||
if ( vararg != 0 )
|
|
||||||
{ *vararg = 0;
|
|
||||||
fputs(breaks[0], out); /* any prior args */
|
|
||||||
fputs("va_dcl", out); /* the final arg */
|
|
||||||
fputs(bp[0], out);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fputs(breaks[0], out);
|
|
||||||
}
|
|
||||||
free((char *)breaks);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
+274
@@ -0,0 +1,274 @@
|
|||||||
|
/* 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
@@ -0,0 +1,109 @@
|
|||||||
|
/* 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_ */
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
||||||
+282
@@ -0,0 +1,282 @@
|
|||||||
|
/* Base bitset stuff.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _BBITSET_H
|
||||||
|
#define _BBITSET_H
|
||||||
|
|
||||||
|
#include "libiberty.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
#include <limits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Currently we support three 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
|
||||||
|
for large very sparse sets).
|
||||||
|
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||||
|
(variable size, less storage for large sparse sets).
|
||||||
|
|
||||||
|
BITSET_STATS: Wrapper bitset for internal use only.
|
||||||
|
*/
|
||||||
|
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM,
|
||||||
|
BITSET_STATS};
|
||||||
|
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset"}
|
||||||
|
|
||||||
|
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)))
|
||||||
|
|
||||||
|
/* Bit index. In theory we might need a type wider than size_t, but
|
||||||
|
in practice we lose at most a factor of CHAR_BIT by going with
|
||||||
|
size_t, and that is good enough. If this type is changed to be
|
||||||
|
wider than size_t, the code needs to be modified to check for
|
||||||
|
overflow when converting bit counts to byte or word counts.
|
||||||
|
The bit and word index types must be unsigned. */
|
||||||
|
typedef size_t bitset_bindex;
|
||||||
|
|
||||||
|
/* Word index. */
|
||||||
|
typedef size_t bitset_windex;
|
||||||
|
|
||||||
|
/* Maximum values for commonly-used unsigned types. BITSET_SIZE_MAX
|
||||||
|
always equals SIZE_MAX, but some older systems lack SIZE_MAX. */
|
||||||
|
#define BITSET_BINDEX_MAX ((bitset_bindex) -1)
|
||||||
|
|
||||||
|
/* Limit max word index to the maximum value of a signed integer
|
||||||
|
to simplify cache disabling. */
|
||||||
|
#define BITSET_WINDEX_MAX (((bitset_windex) -1) >> 1)
|
||||||
|
#define BITSET_SIZE_MAX ((size_t) -1)
|
||||||
|
|
||||||
|
#define BITSET_MSB ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
|
||||||
|
|
||||||
|
#define BITSET_LIST_SIZE 1024
|
||||||
|
|
||||||
|
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||||
|
BITSET_OP_COPY, BITSET_OP_NOT,
|
||||||
|
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
||||||
|
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
||||||
|
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
||||||
|
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
||||||
|
|
||||||
|
struct bbitset_struct
|
||||||
|
{
|
||||||
|
const struct bitset_vtable * vtable;
|
||||||
|
bitset_windex cindex; /* Cache word index. */
|
||||||
|
bitset_windex csize; /* Cache size in words. */
|
||||||
|
bitset_word *cdata; /* Cache data pointer. */
|
||||||
|
/* 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.
|
||||||
|
This would speed up some of the searches but slightly slow down
|
||||||
|
bit set/reset operations of cached bits. */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef union bitset_union *bitset;
|
||||||
|
|
||||||
|
|
||||||
|
/* 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));
|
||||||
|
|
||||||
|
int (*empty_p) PARAMS ((bitset));
|
||||||
|
void (*ones) PARAMS ((bitset));
|
||||||
|
void (*zero) PARAMS ((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 (*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_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));
|
||||||
|
|
||||||
|
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));
|
||||||
|
enum bitset_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BITSET_COMPATIBLE_(BSET1, BSET2) ((BSET1)->b.vtable == (BSET2)->b.vtable)
|
||||||
|
|
||||||
|
#define BITSET_CHECK2_(DST, SRC) \
|
||||||
|
if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
|
||||||
|
|
||||||
|
#define BITSET_CHECK3_(DST, SRC1, SRC2) \
|
||||||
|
if (!BITSET_COMPATIBLE_ (DST, SRC1) \
|
||||||
|
|| !BITSET_COMPATIBLE_ (DST, SRC2)) abort ();
|
||||||
|
|
||||||
|
#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||||
|
|| !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
|
||||||
|
|
||||||
|
|
||||||
|
/* Return size in bits of bitset SRC. */
|
||||||
|
#define BITSET_SIZE_(SRC) (SRC)->b.vtable->size (SRC)
|
||||||
|
|
||||||
|
/* Return number of bits set in bitset SRC. */
|
||||||
|
#define BITSET_COUNT_(SRC) (SRC)->b.vtable->count (SRC)
|
||||||
|
|
||||||
|
/* Return type of bitset SRC. */
|
||||||
|
#define BITSET_TYPE_(DST) (DST)->b.vtable->type
|
||||||
|
|
||||||
|
/* Set bit BITNO in bitset DST. */
|
||||||
|
#define BITSET_SET_(DST, BITNO) (DST)->b.vtable->set (DST, BITNO)
|
||||||
|
|
||||||
|
/* Reset bit BITNO in bitset DST. */
|
||||||
|
#define BITSET_RESET_(DST, BITNO) (DST)->b.vtable->reset (DST, BITNO)
|
||||||
|
|
||||||
|
/* Toggle bit BITNO in bitset DST. */
|
||||||
|
#define BITSET_TOGGLE_(DST, BITNO) (DST)->b.vtable->toggle (DST, BITNO)
|
||||||
|
|
||||||
|
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||||
|
#define BITSET_TEST_(SRC, BITNO) (SRC)->b.vtable->test (SRC, BITNO)
|
||||||
|
|
||||||
|
/* Free bitset SRC. */
|
||||||
|
#define BITSET_FREE_(SRC)\
|
||||||
|
((SRC)->b.vtable->free ? (SRC)->b.vtable->free (SRC) :(void)0)
|
||||||
|
|
||||||
|
|
||||||
|
/* Return SRC == 0. */
|
||||||
|
#define BITSET_EMPTY_P_(SRC) (SRC)->b.vtable->empty_p (SRC)
|
||||||
|
|
||||||
|
/* DST = ~0. */
|
||||||
|
#define BITSET_ONES_(DST) (DST)->b.vtable->ones (DST)
|
||||||
|
|
||||||
|
/* DST = 0. */
|
||||||
|
#define BITSET_ZERO_(DST) (DST)->b.vtable->zero (DST)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = SRC. */
|
||||||
|
#define BITSET_COPY_(DST, SRC) (SRC)->b.vtable->copy (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST & SRC == 0. */
|
||||||
|
#define BITSET_DISJOINT_P_(DST, SRC) (SRC)->b.vtable->disjoint_p (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST == SRC. */
|
||||||
|
#define BITSET_EQUAL_P_(DST, SRC) (SRC)->b.vtable->equal_p (DST, SRC)
|
||||||
|
|
||||||
|
/* DST = ~SRC. */
|
||||||
|
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST == DST | SRC. */
|
||||||
|
#define BITSET_SUBSET_P_(DST, SRC) (SRC)->b.vtable->subset_p (DST, SRC)
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = SRC1 & SRC2. */
|
||||||
|
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and (DST, SRC1, SRC2)
|
||||||
|
#define BITSET_AND_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 & ~SRC2. */
|
||||||
|
#define BITSET_ANDN_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn (DST, SRC1, SRC2)
|
||||||
|
#define BITSET_ANDN_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 | SRC2. */
|
||||||
|
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or (DST, SRC1, SRC2)
|
||||||
|
#define BITSET_OR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 ^ SRC2. */
|
||||||
|
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor (DST, SRC1, SRC2)
|
||||||
|
#define BITSET_XOR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & SRC2) | SRC3. */
|
||||||
|
#define BITSET_AND_OR_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->and_or (DST, SRC1, SRC2, SRC3)
|
||||||
|
#define BITSET_AND_OR_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->and_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||||
|
#define BITSET_ANDN_OR_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->andn_or (DST, SRC1, SRC2, SRC3)
|
||||||
|
#define BITSET_ANDN_OR_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->andn_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 | SRC2) & SRC3. */
|
||||||
|
#define BITSET_OR_AND_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->or_and (DST, SRC1, SRC2, SRC3)
|
||||||
|
#define BITSET_OR_AND_CMP_(DST, SRC1, SRC2, SRC3) \
|
||||||
|
(SRC1)->b.vtable->or_and_cmp (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
|
||||||
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
|
*NEXT. Return with actual number of bits found and with *NEXT
|
||||||
|
indicating where search stopped. */
|
||||||
|
#define BITSET_LIST_(BSET, LIST, NUM, NEXT) \
|
||||||
|
(BSET)->b.vtable->list (BSET, LIST, NUM, NEXT)
|
||||||
|
|
||||||
|
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||||
|
including NEXT. Return with actual number of bits found and with
|
||||||
|
*NEXT indicating where search stopped. */
|
||||||
|
#define BITSET_LIST_REVERSE_(BSET, LIST, NUM, NEXT) \
|
||||||
|
(BSET)->b.vtable->list_reverse (BSET, LIST, NUM, NEXT)
|
||||||
|
|
||||||
|
|
||||||
|
/* Private functions for bitset implementations. */
|
||||||
|
|
||||||
|
extern int bitset_toggle_ PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
extern bitset_bindex bitset_count_ PARAMS ((bitset));
|
||||||
|
|
||||||
|
extern int bitset_copy_ PARAMS ((bitset, bitset));
|
||||||
|
|
||||||
|
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
extern int bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
extern int bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
extern int bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
|
||||||
|
|
||||||
|
#endif /* _BBITSET_H */
|
||||||
+479
@@ -0,0 +1,479 @@
|
|||||||
|
/* General bitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "bitset.h"
|
||||||
|
#include "abitset.h"
|
||||||
|
#include "lbitset.h"
|
||||||
|
#include "ebitset.h"
|
||||||
|
#include "bitset_stats.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
|
||||||
|
const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
|
||||||
|
|
||||||
|
|
||||||
|
/* Return number of bytes required to create a N_BIT bitset
|
||||||
|
of TYPE. The bitset may grow to require more bytes than this. */
|
||||||
|
size_t
|
||||||
|
bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
|
||||||
|
{
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
|
if (bitset_stats_enabled)
|
||||||
|
return bitset_stats_bytes ();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BITSET_ARRAY:
|
||||||
|
bytes = abitset_bytes (n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_LIST:
|
||||||
|
bytes = lbitset_bytes (n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_TABLE:
|
||||||
|
bytes = ebitset_bytes (n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialise bitset BSET of TYPE for N_BITS. */
|
||||||
|
bitset
|
||||||
|
bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||||
|
{
|
||||||
|
if (bitset_stats_enabled)
|
||||||
|
return bitset_stats_init (bset, n_bits, type);
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BITSET_ARRAY:
|
||||||
|
return abitset_init (bset, n_bits);
|
||||||
|
|
||||||
|
case BITSET_LIST:
|
||||||
|
return lbitset_init (bset, n_bits);
|
||||||
|
|
||||||
|
case BITSET_TABLE:
|
||||||
|
return ebitset_init (bset, n_bits);
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Select a bitset type for a set of N_BITS and with attribute hints
|
||||||
|
specified by ATTR. For variable size bitsets, N_BITS is only a
|
||||||
|
hint and may be zero. */
|
||||||
|
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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a bitset of N_BITS of type TYPE. */
|
||||||
|
bitset
|
||||||
|
bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
||||||
|
{
|
||||||
|
size_t bytes;
|
||||||
|
bitset bset;
|
||||||
|
|
||||||
|
bytes = bitset_bytes (type, n_bits);
|
||||||
|
|
||||||
|
bset = (bitset) 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
|
||||||
|
element. */
|
||||||
|
|
||||||
|
return bitset_init (bset, n_bits, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a bitset of N_BITS of type TYPE. */
|
||||||
|
bitset
|
||||||
|
bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
|
bitset_bindex n_bits, enum bitset_type type)
|
||||||
|
{
|
||||||
|
size_t bytes;
|
||||||
|
bitset bset;
|
||||||
|
|
||||||
|
bytes = bitset_bytes (type, n_bits);
|
||||||
|
|
||||||
|
bset = obstack_alloc (bobstack, bytes);
|
||||||
|
memset (bset, 0, bytes);
|
||||||
|
|
||||||
|
return bitset_init (bset, n_bits, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a bitset of N_BITS and with attribute hints specified by
|
||||||
|
ATTR. */
|
||||||
|
bitset
|
||||||
|
bitset_create (bitset_bindex n_bits, unsigned int attr)
|
||||||
|
{
|
||||||
|
enum bitset_type type;
|
||||||
|
|
||||||
|
type = bitset_type_choose (n_bits, attr);
|
||||||
|
|
||||||
|
return bitset_alloc (n_bits, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Free bitset BSET. */
|
||||||
|
void
|
||||||
|
bitset_free (bitset bset)
|
||||||
|
{
|
||||||
|
BITSET_FREE_ (bset);
|
||||||
|
free (bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Free bitset BSET allocated on obstack. */
|
||||||
|
void
|
||||||
|
bitset_obstack_free (bitset bset)
|
||||||
|
{
|
||||||
|
BITSET_FREE_ (bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return bitset type. */
|
||||||
|
enum bitset_type
|
||||||
|
bitset_type_get (bitset bset)
|
||||||
|
{
|
||||||
|
enum bitset_type type;
|
||||||
|
|
||||||
|
type = BITSET_TYPE_ (bset);
|
||||||
|
if (type != BITSET_STATS)
|
||||||
|
return type;
|
||||||
|
|
||||||
|
return bitset_stats_type_get (bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return name of bitset type. */
|
||||||
|
const char *
|
||||||
|
bitset_type_name_get (bitset bset)
|
||||||
|
{
|
||||||
|
enum bitset_type type;
|
||||||
|
|
||||||
|
type = bitset_type_get (bset);
|
||||||
|
|
||||||
|
return bitset_type_names[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find next bit set in SRC starting from and including BITNO.
|
||||||
|
Return BITSET_BINDEX_MAX if SRC empty. */
|
||||||
|
bitset_bindex
|
||||||
|
bitset_next (bitset src, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset_bindex val;
|
||||||
|
bitset_bindex next = bitno;
|
||||||
|
|
||||||
|
if (!bitset_list (src, &val, 1, &next))
|
||||||
|
return BITSET_BINDEX_MAX;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find previous bit set in SRC starting from and including BITNO.
|
||||||
|
Return BITSET_BINDEX_MAX if SRC empty. */
|
||||||
|
bitset_bindex
|
||||||
|
bitset_prev (bitset src, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset_bindex val;
|
||||||
|
bitset_bindex next = bitno;
|
||||||
|
|
||||||
|
if (!bitset_list_reverse (src, &val, 1, &next))
|
||||||
|
return BITSET_BINDEX_MAX;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find first set bit. */
|
||||||
|
bitset_bindex
|
||||||
|
bitset_first (bitset src)
|
||||||
|
{
|
||||||
|
return bitset_next (src, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find last set bit. */
|
||||||
|
bitset_bindex
|
||||||
|
bitset_last (bitset src)
|
||||||
|
{
|
||||||
|
return bitset_prev (src, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return non-zero if BITNO in SRC is the only set bit. */
|
||||||
|
int
|
||||||
|
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 val[0] == bitno;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print contents of bitset BSET to FILE. */
|
||||||
|
static void
|
||||||
|
bitset_print (FILE *file, bitset bset, int verbose)
|
||||||
|
{
|
||||||
|
unsigned int pos;
|
||||||
|
bitset_bindex i;
|
||||||
|
bitset_iterator iter;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf (file, "n_bits = %lu, set = {",
|
||||||
|
(unsigned long) bitset_size (bset));
|
||||||
|
|
||||||
|
pos = 30;
|
||||||
|
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||||
|
{
|
||||||
|
if (pos > 70)
|
||||||
|
{
|
||||||
|
fprintf (file, "\n");
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (file, "%d ", i);
|
||||||
|
pos += 1 + (i >= 10) + (i >= 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf (file, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Dump bitset BSET to FILE. */
|
||||||
|
void
|
||||||
|
bitset_dump (FILE *file, bitset bset)
|
||||||
|
{
|
||||||
|
bitset_print (file, bset, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Release memory associated with bitsets. */
|
||||||
|
void
|
||||||
|
bitset_release_memory (void)
|
||||||
|
{
|
||||||
|
lbitset_release_memory ();
|
||||||
|
ebitset_release_memory ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Toggle bit BITNO in bitset BSET and return non-zero if not set. */
|
||||||
|
int
|
||||||
|
bitset_toggle_ (bitset bset, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
/* This routine is for completeness. It could be optimized if
|
||||||
|
required. */
|
||||||
|
if (bitset_test (bset, bitno))
|
||||||
|
{
|
||||||
|
bitset_reset (bset, bitno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bitset_set (bset, bitno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return number of bits set in bitset SRC. */
|
||||||
|
bitset_bindex
|
||||||
|
bitset_count_ (bitset src)
|
||||||
|
{
|
||||||
|
bitset_bindex list[BITSET_LIST_SIZE];
|
||||||
|
bitset_bindex next;
|
||||||
|
bitset_bindex num;
|
||||||
|
bitset_bindex count;
|
||||||
|
|
||||||
|
/* This could be greatly sped up by adding a count method for each
|
||||||
|
bitset implementation that uses a direct technique (based on
|
||||||
|
masks) for counting the number of bits set in a word. */
|
||||||
|
|
||||||
|
next = 0;
|
||||||
|
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
|
||||||
|
count += num)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = SRC. Return non-zero if DST != SRC.
|
||||||
|
This is a fallback for the case where SRC and DST are different
|
||||||
|
bitset types. */
|
||||||
|
int
|
||||||
|
bitset_copy_ (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
bitset_iterator iter;
|
||||||
|
|
||||||
|
/* Convert bitset types. We assume that the DST bitset
|
||||||
|
is large enough to hold the SRC bitset. */
|
||||||
|
bitset_zero (dst);
|
||||||
|
BITSET_FOR_EACH (iter, src, i, 0)
|
||||||
|
{
|
||||||
|
bitset_set (dst, i);
|
||||||
|
};
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This is a fallback for implementations that do not support
|
||||||
|
four operand operations. */
|
||||||
|
static inline int
|
||||||
|
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
||||||
|
enum bitset_ops op)
|
||||||
|
{
|
||||||
|
int changed = 0;
|
||||||
|
int stats_enabled_save;
|
||||||
|
bitset tmp;
|
||||||
|
|
||||||
|
/* Create temporary bitset. */
|
||||||
|
stats_enabled_save = bitset_stats_enabled;
|
||||||
|
bitset_stats_enabled = 0;
|
||||||
|
tmp = bitset_alloc (0, bitset_type_get (dst));
|
||||||
|
bitset_stats_enabled = stats_enabled_save;
|
||||||
|
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case BITSET_OP_OR_AND:
|
||||||
|
bitset_or (tmp, src1, src2);
|
||||||
|
changed = bitset_and_cmp (dst, src3, tmp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_OP_AND_OR:
|
||||||
|
bitset_and (tmp, src1, src2);
|
||||||
|
changed = bitset_or_cmp (dst, src3, tmp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_OP_ANDN_OR:
|
||||||
|
bitset_andn (tmp, src1, src2);
|
||||||
|
changed = bitset_or_cmp (dst, src3, tmp);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bitset_free (tmp);
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & SRC2) | SRC3. */
|
||||||
|
void
|
||||||
|
bitset_and_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_and_or_cmp_ (dst, src1, src2, src3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & SRC2) | SRC3. */
|
||||||
|
int
|
||||||
|
bitset_and_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_AND_OR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & ~SRC2) | SRC3. */
|
||||||
|
void
|
||||||
|
bitset_andn_or_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_andn_or_cmp_ (dst, src1, src2, src3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||||
|
int
|
||||||
|
bitset_andn_or_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_ANDN_OR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 | SRC2) & SRC3. */
|
||||||
|
void
|
||||||
|
bitset_or_and_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
bitset_or_and_cmp_ (dst, src1, src2, src3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 | SRC2) & SRC3. */
|
||||||
|
int
|
||||||
|
bitset_or_and_cmp_ (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
return bitset_op4_cmp (dst, src1, src2, src3, BITSET_OP_OR_AND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to be called from debugger to print bitset. */
|
||||||
|
void
|
||||||
|
debug_bitset (bitset bset)
|
||||||
|
{
|
||||||
|
if (bset)
|
||||||
|
bitset_print (stderr, bset, 1);
|
||||||
|
}
|
||||||
+378
@@ -0,0 +1,378 @@
|
|||||||
|
/* Generic bitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _BITSET_H
|
||||||
|
#define _BITSET_H
|
||||||
|
|
||||||
|
/* This file is the public interface to the bitset abstract data type.
|
||||||
|
Only use the functions and macros defined in this file. */
|
||||||
|
|
||||||
|
#include "bbitset.h"
|
||||||
|
#include "obstack.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Attributes used to select a bitset implementation. */
|
||||||
|
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
||||||
|
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
||||||
|
BITSET_DENSE = 4, /* Bitset dense. */
|
||||||
|
BITSET_SPARSE = 8, /* Bitset sparse. */
|
||||||
|
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
||||||
|
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
||||||
|
|
||||||
|
typedef unsigned int bitset_attrs;
|
||||||
|
|
||||||
|
/* The contents of the union should be considered to be private.
|
||||||
|
While I would like to make this union opaque, it needs to be
|
||||||
|
visible for the inline bit set/test functions, and for delegation
|
||||||
|
to the proper implementation. */
|
||||||
|
union bitset_union
|
||||||
|
{
|
||||||
|
/* This must be the first member of every other structure that is a
|
||||||
|
member of this union. */
|
||||||
|
struct bbitset_struct b;
|
||||||
|
|
||||||
|
struct abitset_struct
|
||||||
|
{
|
||||||
|
struct bbitset_struct b;
|
||||||
|
bitset_bindex n_bits; /* Number of bits. */
|
||||||
|
bitset_word words[1]; /* The array of bits. */
|
||||||
|
} a;
|
||||||
|
|
||||||
|
struct ebitset_struct
|
||||||
|
{
|
||||||
|
struct bbitset_struct b;
|
||||||
|
bitset_windex size; /* Number of elements. */
|
||||||
|
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
||||||
|
} e;
|
||||||
|
|
||||||
|
struct lbitset_struct
|
||||||
|
{
|
||||||
|
struct bbitset_struct b;
|
||||||
|
struct lbitset_elt_struct *head; /* First element in linked list. */
|
||||||
|
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
||||||
|
} l;
|
||||||
|
|
||||||
|
struct bitset_stats_struct
|
||||||
|
{
|
||||||
|
struct bbitset_struct b;
|
||||||
|
bitset bset;
|
||||||
|
} s;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* The contents of this structure should be considered private.
|
||||||
|
It is used for iterating over set bits. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bitset_bindex list[BITSET_LIST_SIZE];
|
||||||
|
bitset_bindex next;
|
||||||
|
bitset_bindex num;
|
||||||
|
bitset_bindex i;
|
||||||
|
} bitset_iterator;
|
||||||
|
|
||||||
|
|
||||||
|
/* Return bytes required for bitset of desired type and size. */
|
||||||
|
extern size_t bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
|
||||||
|
|
||||||
|
/* Initialise a bitset with desired type and size. */
|
||||||
|
extern bitset bitset_init PARAMS ((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));
|
||||||
|
|
||||||
|
/* Create a bitset of desired type and size. The bitset is zeroed. */
|
||||||
|
extern bitset bitset_alloc PARAMS ((bitset_bindex, enum bitset_type));
|
||||||
|
|
||||||
|
/* Free bitset. */
|
||||||
|
extern void bitset_free PARAMS ((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));
|
||||||
|
|
||||||
|
/* Free bitset allocated on obstack. */
|
||||||
|
extern void bitset_obstack_free PARAMS ((bitset));
|
||||||
|
|
||||||
|
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
|
||||||
|
extern bitset bitset_create PARAMS ((bitset_bindex, bitset_attrs));
|
||||||
|
|
||||||
|
/* Return bitset type. */
|
||||||
|
extern enum bitset_type bitset_type_get PARAMS ((bitset));
|
||||||
|
|
||||||
|
/* Return bitset type name. */
|
||||||
|
extern const char *bitset_type_name_get PARAMS ((bitset));
|
||||||
|
|
||||||
|
|
||||||
|
/* Set bit BITNO in bitset BSET. */
|
||||||
|
static inline void
|
||||||
|
bitset_set (bitset bset, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = windex - bset->b.cindex;
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
bset->b.cdata[offset] |= ((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||||
|
else
|
||||||
|
BITSET_SET_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Reset bit BITNO in bitset BSET. */
|
||||||
|
static inline void
|
||||||
|
bitset_reset (bitset bset, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = windex - bset->b.cindex;
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
bset->b.cdata[offset] &= ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||||
|
else
|
||||||
|
BITSET_RESET_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Test bit BITNO in bitset BSET. */
|
||||||
|
static inline int
|
||||||
|
bitset_test (bitset bset, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = windex - bset->b.cindex;
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||||
|
else
|
||||||
|
return BITSET_TEST_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Toggle bit BITNO in bitset BSET and return non-zero if now set. */
|
||||||
|
#define bitset_toggle(bset, bitno) BITSET_TOGGLE_ (bset, bitno)
|
||||||
|
|
||||||
|
/* Return size in bits of bitset SRC. */
|
||||||
|
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
|
||||||
|
|
||||||
|
/* Return number of bits set in bitset SRC. */
|
||||||
|
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
|
||||||
|
|
||||||
|
|
||||||
|
/* Return SRC == 0. */
|
||||||
|
#define bitset_empty_p(SRC) BITSET_EMPTY_P_ (SRC)
|
||||||
|
|
||||||
|
/* DST = ~0. */
|
||||||
|
#define bitset_ones(DST) BITSET_ONES_ (DST)
|
||||||
|
|
||||||
|
/* DST = 0. */
|
||||||
|
#define bitset_zero(DST) BITSET_ZERO_ (DST)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = SRC. */
|
||||||
|
#define bitset_copy(DST, SRC) BITSET_COPY_ (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST & SRC == 0. */
|
||||||
|
#define bitset_disjoint_p(DST, SRC) BITSET_DISJOINT_P_ (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST == SRC. */
|
||||||
|
#define bitset_equal_p(DST, SRC) BITSET_EQUAL_P_ (DST, SRC)
|
||||||
|
|
||||||
|
/* DST = ~SRC. */
|
||||||
|
#define bitset_not(DST, SRC) BITSET_NOT_ (DST, SRC)
|
||||||
|
|
||||||
|
/* Return DST == DST | SRC. */
|
||||||
|
#define bitset_subset_p(DST, SRC) BITSET_SUBSET_P_ (DST, SRC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = SRC1 & SRC2. */
|
||||||
|
#define bitset_and(DST, SRC1, SRC2) BITSET_AND_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 & SRC2. Return non-zero if DST != SRC1 & SRC2. */
|
||||||
|
#define bitset_and_cmp(DST, SRC1, SRC2) BITSET_AND_CMP_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 & ~SRC2. */
|
||||||
|
#define bitset_andn(DST, SRC1, SRC2) BITSET_ANDN_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 & ~SRC2. Return non-zero if DST != SRC1 & ~SRC2. */
|
||||||
|
#define bitset_andn_cmp(DST, SRC1, SRC2) BITSET_ANDN_CMP_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 | SRC2. */
|
||||||
|
#define bitset_or(DST, SRC1, SRC2) BITSET_OR_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 | SRC2. Return non-zero if DST != SRC1 | SRC2. */
|
||||||
|
#define bitset_or_cmp(DST, SRC1, SRC2) BITSET_OR_CMP_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 ^ SRC2. */
|
||||||
|
#define bitset_xor(DST, SRC1, SRC2) BITSET_XOR_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* DST = SRC1 ^ SRC2. Return non-zero if DST != SRC1 ^ SRC2. */
|
||||||
|
#define bitset_xor_cmp(DST, SRC1, SRC2) BITSET_XOR_CMP_ (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* DST = (SRC1 & SRC2) | SRC3. */
|
||||||
|
#define bitset_and_or(DST, SRC1, SRC2, SRC3) \
|
||||||
|
BITSET_AND_OR_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & SRC2) | SRC3. */
|
||||||
|
#define bitset_and_or_cmp(DST, SRC1, SRC2, SRC3) \
|
||||||
|
BITSET_AND_OR_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 & ~SRC2) | SRC3. */
|
||||||
|
#define bitset_andn_or(DST, SRC1, SRC2, SRC3) \
|
||||||
|
BITSET_ANDN_OR_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||||
|
#define bitset_andn_or_cmp(DST, SRC1, SRC2, SRC3) \
|
||||||
|
BITSET_ANDN_OR_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 | SRC2) & SRC3. */
|
||||||
|
#define bitset_or_and(DST, SRC1, SRC2, SRC3)\
|
||||||
|
BITSET_OR_AND_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||||
|
DST != (SRC1 | SRC2) & SRC3. */
|
||||||
|
#define bitset_or_and_cmp(DST, SRC1, SRC2, SRC3)\
|
||||||
|
BITSET_OR_AND_CMP_ (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
/* Find list of up to NUM bits set in BSET starting from and including
|
||||||
|
*NEXT. Return with actual number of bits found and with *NEXT
|
||||||
|
indicating where search stopped. */
|
||||||
|
#define bitset_list(BSET, LIST, NUM, NEXT) \
|
||||||
|
BITSET_LIST_ (BSET, LIST, NUM, NEXT)
|
||||||
|
|
||||||
|
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||||
|
including NEXT. Return with actual number of bits found and with
|
||||||
|
*NEXT indicating where search stopped. */
|
||||||
|
#define bitset_list_reverse(BSET, LIST, NUM, NEXT) \
|
||||||
|
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
|
||||||
|
|
||||||
|
|
||||||
|
/* Find next set bit. */
|
||||||
|
extern bitset_bindex bitset_next PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
/* Find previous set bit. */
|
||||||
|
extern bitset_bindex bitset_prev PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
/* Find first set bit. */
|
||||||
|
extern bitset_bindex bitset_first PARAMS ((bitset));
|
||||||
|
|
||||||
|
/* Find last set bit. */
|
||||||
|
extern bitset_bindex bitset_last PARAMS ((bitset));
|
||||||
|
|
||||||
|
/* Return nonzero if this is the only set bit. */
|
||||||
|
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
/* Dump bitset. */
|
||||||
|
extern void bitset_dump PARAMS ((FILE *, bitset));
|
||||||
|
|
||||||
|
/* Loop over all elements of BSET, starting with MIN, setting BIT
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#define BITSET_FOR_EACH(ITER, BSET, BIT, MIN) \
|
||||||
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
|
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||||
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
|
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; 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
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, BIT, MIN) \
|
||||||
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
|
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||||
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
|
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
|
||||||
|
|
||||||
|
|
||||||
|
/* Define set operations in terms of logical operations. */
|
||||||
|
|
||||||
|
#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
|
||||||
|
#define bitset_diff_cmp(DST, SRC1, SRC2) bitset_andn_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
|
||||||
|
#define bitset_intersection_cmp(DST, SRC1, SRC2) bitset_and_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
|
||||||
|
#define bitset_union_cmp(DST, SRC1, SRC2) bitset_or_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* Symmetrical difference. */
|
||||||
|
#define bitset_symdiff(DST, SRC1, SRC2) bitset_xor (DST, SRC1, SRC2)
|
||||||
|
#define bitset_symdiff_cmp(DST, SRC1, SRC2) bitset_xor_cmp (DST, SRC1, SRC2)
|
||||||
|
|
||||||
|
/* Union of difference. */
|
||||||
|
#define bitset_diff_union(DST, SRC1, SRC2, SRC3) \
|
||||||
|
bitset_andn_or (DST, SRC1, SRC2, SRC3)
|
||||||
|
#define bitset_diff_union_cmp(DST, SRC1, SRC2, SRC3) \
|
||||||
|
bitset_andn_or_cmp (DST, SRC1, SRC2, SRC3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Release any memory tied up with bitsets. */
|
||||||
|
extern void bitset_release_memory PARAMS ((void));
|
||||||
|
|
||||||
|
/* Enable bitset stats gathering. */
|
||||||
|
extern void bitset_stats_enable PARAMS ((void));
|
||||||
|
|
||||||
|
/* Disable bitset stats gathering. */
|
||||||
|
extern void bitset_stats_disable PARAMS ((void));
|
||||||
|
|
||||||
|
/* Read bitset stats file of accummulated stats. */
|
||||||
|
void bitset_stats_read PARAMS ((const char *filename));
|
||||||
|
|
||||||
|
/* Write bitset stats file of accummulated stats. */
|
||||||
|
void bitset_stats_write PARAMS ((const char *filename));
|
||||||
|
|
||||||
|
/* Dump bitset stats. */
|
||||||
|
extern void bitset_stats_dump PARAMS ((FILE *));
|
||||||
|
|
||||||
|
/* Function to debug bitset from debugger. */
|
||||||
|
extern void debug_bitset PARAMS ((bitset));
|
||||||
|
|
||||||
|
/* Function to debug bitset stats from debugger. */
|
||||||
|
extern void debug_bitset_stats PARAMS ((void));
|
||||||
|
|
||||||
|
#endif /* _BITSET_H */
|
||||||
|
|
||||||
@@ -0,0 +1,721 @@
|
|||||||
|
/* Bitset statistics.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file is a wrapper bitset implementation for the other bitset
|
||||||
|
implementations. It provides bitset compatibility checking and
|
||||||
|
statistics gathering without having to instrument the bitset
|
||||||
|
implementations. When statistics gathering is enabled, the bitset
|
||||||
|
operations get vectored through here and we then call the appropriate
|
||||||
|
routines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "bbitset.h"
|
||||||
|
#include "abitset.h"
|
||||||
|
#include "ebitset.h"
|
||||||
|
#include "lbitset.h"
|
||||||
|
#include "bitset_stats.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
#define _(Msgid) gettext (Msgid)
|
||||||
|
|
||||||
|
/* Configuration macros. */
|
||||||
|
#define BITSET_STATS_FILE "bitset.dat"
|
||||||
|
#define BITSET_LOG_COUNT_BINS 10
|
||||||
|
#define BITSET_LOG_SIZE_BINS 16
|
||||||
|
#define BITSET_DENSITY_BINS 20
|
||||||
|
|
||||||
|
|
||||||
|
/* Accessor macros. */
|
||||||
|
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||||
|
bitset_stats_info->types[(TYPE)].allocs++
|
||||||
|
#define BITSET_STATS_FREES_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
||||||
|
#define BITSET_STATS_SETS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
||||||
|
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
||||||
|
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
||||||
|
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
||||||
|
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
||||||
|
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
||||||
|
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
||||||
|
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
||||||
|
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
||||||
|
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||||
|
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||||
|
|
||||||
|
|
||||||
|
struct bitset_type_info_struct
|
||||||
|
{
|
||||||
|
unsigned int allocs;
|
||||||
|
unsigned int frees;
|
||||||
|
unsigned int lists;
|
||||||
|
unsigned int sets;
|
||||||
|
unsigned int cache_sets;
|
||||||
|
unsigned int resets;
|
||||||
|
unsigned int cache_resets;
|
||||||
|
unsigned int tests;
|
||||||
|
unsigned int cache_tests;
|
||||||
|
unsigned int list_counts[BITSET_LOG_COUNT_BINS];
|
||||||
|
unsigned int list_sizes[BITSET_LOG_SIZE_BINS];
|
||||||
|
unsigned int list_density[BITSET_DENSITY_BINS];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bitset_stats_info_struct
|
||||||
|
{
|
||||||
|
unsigned int runs;
|
||||||
|
struct bitset_type_info_struct types[BITSET_TYPE_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct bitset_stats_info_struct bitset_stats_info_data;
|
||||||
|
struct bitset_stats_info_struct *bitset_stats_info;
|
||||||
|
int bitset_stats_enabled = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Print a percentage histogram with message MSG to FILE. */
|
||||||
|
static void
|
||||||
|
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
|
unsigned int n_bins, unsigned int *bins)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
unsigned int total;
|
||||||
|
|
||||||
|
total = 0;
|
||||||
|
for (i = 0; i < n_bins; i++)
|
||||||
|
total += bins[i];
|
||||||
|
|
||||||
|
if (!total)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fprintf (file, "%s %s", name, msg);
|
||||||
|
for (i = 0; i < n_bins; i++)
|
||||||
|
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||||
|
i * 100.0 / n_bins,
|
||||||
|
(i + 1) * 100.0 / n_bins, bins[i],
|
||||||
|
(100.0 * bins[i]) / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print a log histogram with message MSG to FILE. */
|
||||||
|
static void
|
||||||
|
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
||||||
|
unsigned int n_bins, unsigned int *bins)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
unsigned int total;
|
||||||
|
unsigned int max_width;
|
||||||
|
|
||||||
|
total = 0;
|
||||||
|
for (i = 0; i < n_bins; i++)
|
||||||
|
total += bins[i];
|
||||||
|
|
||||||
|
if (!total)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Determine number of useful bins. */
|
||||||
|
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||||
|
continue;
|
||||||
|
n_bins = i;
|
||||||
|
|
||||||
|
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
|
||||||
|
max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||||
|
|
||||||
|
fprintf (file, "%s %s", name, msg);
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
||||||
|
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||||
|
|
||||||
|
for (; i < n_bins; i++)
|
||||||
|
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||||
|
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||||
|
(unsigned long) 1 << (i - 1),
|
||||||
|
((unsigned long) 1 << i) - 1,
|
||||||
|
bins[i],
|
||||||
|
(100.0 * bins[i]) / total);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print bitset statistics to FILE. */
|
||||||
|
static void
|
||||||
|
bitset_stats_print_1 (FILE *file, const char *name,
|
||||||
|
struct bitset_type_info_struct *stats)
|
||||||
|
{
|
||||||
|
if (!stats)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fprintf (file, "%s:\n", name);
|
||||||
|
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
||||||
|
stats->allocs, stats->frees,
|
||||||
|
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
||||||
|
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
||||||
|
stats->sets, stats->cache_sets,
|
||||||
|
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
||||||
|
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
||||||
|
stats->resets, stats->cache_resets,
|
||||||
|
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
||||||
|
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
||||||
|
stats->tests, stats->cache_tests,
|
||||||
|
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
||||||
|
|
||||||
|
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
||||||
|
|
||||||
|
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
||||||
|
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
||||||
|
|
||||||
|
bitset_log_histogram_print (file, name, _("size log histogram\n"),
|
||||||
|
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
||||||
|
|
||||||
|
bitset_percent_histogram_print (file, name, _("density histogram\n"),
|
||||||
|
BITSET_DENSITY_BINS, stats->list_density);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print all bitset statistics to FILE. */
|
||||||
|
static void
|
||||||
|
bitset_stats_print (FILE *file, int verbose ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!bitset_stats_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fprintf (file, _("Bitset statistics:\n\n"));
|
||||||
|
|
||||||
|
if (bitset_stats_info->runs > 1)
|
||||||
|
fprintf (file, _("Accumulated runs = %u\n"), bitset_stats_info->runs);
|
||||||
|
|
||||||
|
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||||
|
bitset_stats_print_1 (file, bitset_type_names[i],
|
||||||
|
&bitset_stats_info->types[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialise bitset statistics logging. */
|
||||||
|
void
|
||||||
|
bitset_stats_enable (void)
|
||||||
|
{
|
||||||
|
if (!bitset_stats_info)
|
||||||
|
bitset_stats_info = &bitset_stats_info_data;
|
||||||
|
bitset_stats_enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
bitset_stats_disable (void)
|
||||||
|
{
|
||||||
|
bitset_stats_enabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Read bitset statistics file. */
|
||||||
|
void
|
||||||
|
bitset_stats_read (const char *filename)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
|
if (!bitset_stats_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
|
filename = BITSET_STATS_FILE;
|
||||||
|
|
||||||
|
file = fopen (filename, "r");
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
|
1, file) != 1)
|
||||||
|
{
|
||||||
|
if (ferror (file))
|
||||||
|
perror (_("Could not read stats file."));
|
||||||
|
else
|
||||||
|
fprintf (stderr, _("Bad stats file size.\n"));
|
||||||
|
}
|
||||||
|
if (fclose (file) != 0)
|
||||||
|
perror (_("Could not read stats file."));
|
||||||
|
}
|
||||||
|
bitset_stats_info_data.runs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Write bitset statistics file. */
|
||||||
|
void
|
||||||
|
bitset_stats_write (const char *filename)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
|
if (!bitset_stats_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
|
filename = BITSET_STATS_FILE;
|
||||||
|
|
||||||
|
file = fopen (filename, "w");
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
|
1, file) != 1)
|
||||||
|
perror (_("Could not write stats file."));
|
||||||
|
if (fclose (file) != 0)
|
||||||
|
perror (_("Could not write stats file."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
perror (_("Could not open stats file for writing."));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Dump bitset statistics to FILE. */
|
||||||
|
void
|
||||||
|
bitset_stats_dump (FILE *file)
|
||||||
|
{
|
||||||
|
bitset_stats_print (file, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to be called from debugger to print bitset stats. */
|
||||||
|
void
|
||||||
|
debug_bitset_stats (void)
|
||||||
|
{
|
||||||
|
bitset_stats_print (stderr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_set (bitset dst, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset bset = dst->s.bset;
|
||||||
|
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = wordno - bset->b.cindex;
|
||||||
|
|
||||||
|
BITSET_STATS_SETS_INC (bset);
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
{
|
||||||
|
bset->b.cdata[offset] |= (bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||||
|
BITSET_STATS_CACHE_SETS_INC (bset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BITSET_SET_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_reset (bitset dst, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset bset = dst->s.bset;
|
||||||
|
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = wordno - bset->b.cindex;
|
||||||
|
|
||||||
|
BITSET_STATS_RESETS_INC (bset);
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
{
|
||||||
|
bset->b.cdata[offset] &=
|
||||||
|
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||||
|
BITSET_STATS_CACHE_RESETS_INC (bset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BITSET_RESET_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_toggle (bitset src, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
return BITSET_TOGGLE_ (src->s.bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_test (bitset src, bitset_bindex bitno)
|
||||||
|
{
|
||||||
|
bitset bset = src->s.bset;
|
||||||
|
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||||
|
bitset_windex offset = wordno - bset->b.cindex;
|
||||||
|
|
||||||
|
BITSET_STATS_TESTS_INC (bset);
|
||||||
|
|
||||||
|
if (offset < bset->b.csize)
|
||||||
|
{
|
||||||
|
BITSET_STATS_CACHE_TESTS_INC (bset);
|
||||||
|
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return BITSET_TEST_ (bset, bitno);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bitset_bindex
|
||||||
|
bitset_stats_size (bitset src)
|
||||||
|
{
|
||||||
|
return BITSET_SIZE_ (src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bitset_bindex
|
||||||
|
bitset_stats_count (bitset src)
|
||||||
|
{
|
||||||
|
return BITSET_COUNT_ (src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_empty_p (bitset dst)
|
||||||
|
{
|
||||||
|
return BITSET_EMPTY_P_ (dst->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_ones (bitset dst)
|
||||||
|
{
|
||||||
|
BITSET_ONES_ (dst->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_zero (bitset dst)
|
||||||
|
{
|
||||||
|
BITSET_ZERO_ (dst->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_copy (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
BITSET_CHECK2_ (dst, src);
|
||||||
|
BITSET_COPY_ (dst->s.bset, src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_disjoint_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
BITSET_CHECK2_ (dst, src);
|
||||||
|
return BITSET_DISJOINT_P_ (dst->s.bset, src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_equal_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
BITSET_CHECK2_ (dst, src);
|
||||||
|
return BITSET_EQUAL_P_ (dst->s.bset, src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_not (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
BITSET_CHECK2_ (dst, src);
|
||||||
|
BITSET_NOT_ (dst->s.bset, src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_subset_p (bitset dst, bitset src)
|
||||||
|
{
|
||||||
|
BITSET_CHECK2_ (dst, src);
|
||||||
|
return BITSET_SUBSET_P_ (dst->s.bset, src->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_and (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
BITSET_AND_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_and_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
return BITSET_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_andn (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
BITSET_ANDN_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_andn_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
return BITSET_ANDN_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_or (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
BITSET_OR_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_or_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
return BITSET_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_xor (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
BITSET_XOR_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_xor_cmp (bitset dst, bitset src1, bitset src2)
|
||||||
|
{
|
||||||
|
BITSET_CHECK3_ (dst, src1, src2);
|
||||||
|
return BITSET_XOR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
BITSET_AND_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
return BITSET_AND_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
BITSET_ANDN_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
return BITSET_ANDN_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
BITSET_OR_AND_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
||||||
|
{
|
||||||
|
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||||
|
|
||||||
|
return BITSET_OR_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bitset_bindex
|
||||||
|
bitset_stats_list (bitset bset, bitset_bindex *list,
|
||||||
|
bitset_bindex num, bitset_bindex *next)
|
||||||
|
{
|
||||||
|
bitset_bindex count;
|
||||||
|
bitset_bindex tmp;
|
||||||
|
bitset_bindex size;
|
||||||
|
bitset_bindex i;
|
||||||
|
enum bitset_type type;
|
||||||
|
|
||||||
|
count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||||
|
|
||||||
|
type = BITSET_TYPE_ (bset->s.bset);
|
||||||
|
BITSET_STATS_LISTS_INC (bset->s.bset);
|
||||||
|
|
||||||
|
/* Log histogram of number of set bits. */
|
||||||
|
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||||
|
continue;
|
||||||
|
if (i >= BITSET_LOG_COUNT_BINS)
|
||||||
|
i = BITSET_LOG_COUNT_BINS - 1;
|
||||||
|
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
|
||||||
|
|
||||||
|
/* Log histogram of number of bits in set. */
|
||||||
|
size = BITSET_SIZE_ (bset->s.bset);
|
||||||
|
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||||
|
continue;
|
||||||
|
if (i >= BITSET_LOG_SIZE_BINS)
|
||||||
|
i = BITSET_LOG_SIZE_BINS - 1;
|
||||||
|
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
|
||||||
|
|
||||||
|
/* Histogram of fraction of bits set. */
|
||||||
|
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||||
|
if (i >= BITSET_DENSITY_BINS)
|
||||||
|
i = BITSET_DENSITY_BINS - 1;
|
||||||
|
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bitset_bindex
|
||||||
|
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
|
||||||
|
bitset_bindex num, bitset_bindex *next)
|
||||||
|
{
|
||||||
|
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitset_stats_free (bitset bset)
|
||||||
|
{
|
||||||
|
BITSET_STATS_FREES_INC (bset->s.bset);
|
||||||
|
BITSET_FREE_ (bset->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct bitset_vtable bitset_stats_vtable = {
|
||||||
|
bitset_stats_set,
|
||||||
|
bitset_stats_reset,
|
||||||
|
bitset_stats_toggle,
|
||||||
|
bitset_stats_test,
|
||||||
|
bitset_stats_size,
|
||||||
|
bitset_stats_count,
|
||||||
|
bitset_stats_empty_p,
|
||||||
|
bitset_stats_ones,
|
||||||
|
bitset_stats_zero,
|
||||||
|
bitset_stats_copy,
|
||||||
|
bitset_stats_disjoint_p,
|
||||||
|
bitset_stats_equal_p,
|
||||||
|
bitset_stats_not,
|
||||||
|
bitset_stats_subset_p,
|
||||||
|
bitset_stats_and,
|
||||||
|
bitset_stats_and_cmp,
|
||||||
|
bitset_stats_andn,
|
||||||
|
bitset_stats_andn_cmp,
|
||||||
|
bitset_stats_or,
|
||||||
|
bitset_stats_or_cmp,
|
||||||
|
bitset_stats_xor,
|
||||||
|
bitset_stats_xor_cmp,
|
||||||
|
bitset_stats_and_or,
|
||||||
|
bitset_stats_and_or_cmp,
|
||||||
|
bitset_stats_andn_or,
|
||||||
|
bitset_stats_andn_or_cmp,
|
||||||
|
bitset_stats_or_and,
|
||||||
|
bitset_stats_or_and_cmp,
|
||||||
|
bitset_stats_list,
|
||||||
|
bitset_stats_list_reverse,
|
||||||
|
bitset_stats_free,
|
||||||
|
BITSET_STATS
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Return enclosed bitset type. */
|
||||||
|
enum bitset_type
|
||||||
|
bitset_stats_type_get (bitset bset)
|
||||||
|
{
|
||||||
|
return BITSET_TYPE_ (bset->s.bset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t
|
||||||
|
bitset_stats_bytes (void)
|
||||||
|
{
|
||||||
|
return sizeof (struct bitset_stats_struct);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bitset
|
||||||
|
bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
|
||||||
|
{
|
||||||
|
size_t bytes;
|
||||||
|
bitset sbset;
|
||||||
|
|
||||||
|
bset->b.vtable = &bitset_stats_vtable;
|
||||||
|
|
||||||
|
/* Disable cache. */
|
||||||
|
bset->b.cindex = 0;
|
||||||
|
bset->b.csize = 0;
|
||||||
|
bset->b.cdata = 0;
|
||||||
|
|
||||||
|
/* Set up the actual bitset implementation that
|
||||||
|
we are a wrapper over. */
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BITSET_ARRAY:
|
||||||
|
bytes = abitset_bytes (n_bits);
|
||||||
|
sbset = (bitset) xcalloc (1, bytes);
|
||||||
|
abitset_init (sbset, n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_LIST:
|
||||||
|
bytes = lbitset_bytes (n_bits);
|
||||||
|
sbset = (bitset) xcalloc (1, bytes);
|
||||||
|
lbitset_init (sbset, n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BITSET_TABLE:
|
||||||
|
bytes = ebitset_bytes (n_bits);
|
||||||
|
sbset = (bitset) xcalloc (1, bytes);
|
||||||
|
ebitset_init (sbset, n_bits);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bset->s.bset = sbset;
|
||||||
|
|
||||||
|
BITSET_STATS_ALLOCS_INC (type);
|
||||||
|
|
||||||
|
return bset;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* Functions to support bitset statistics.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _BITSET_STATS_H
|
||||||
|
#define _BITSET_STATS_H
|
||||||
|
|
||||||
|
#include "bbitset.h"
|
||||||
|
|
||||||
|
extern int bitset_stats_enabled;
|
||||||
|
|
||||||
|
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
|
||||||
|
|
||||||
|
extern size_t bitset_stats_bytes PARAMS ((void));
|
||||||
|
|
||||||
|
extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex,
|
||||||
|
enum bitset_type));
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/* Bitset vectors.
|
||||||
|
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "bitsetv-print.h"
|
||||||
|
|
||||||
|
/*--------------------------------------------------------.
|
||||||
|
| Display the MATRIX array of SIZE bitsets of size SIZE. |
|
||||||
|
`--------------------------------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||||
|
{
|
||||||
|
bitset_bindex i, j;
|
||||||
|
bitset_bindex hsize = bitset_size (bset[0]);
|
||||||
|
|
||||||
|
/* Title. */
|
||||||
|
fprintf (out, "%s BEGIN\n", title);
|
||||||
|
|
||||||
|
/* Column numbers. */
|
||||||
|
fputs (" ", out);
|
||||||
|
for (i = 0; i < hsize; ++i)
|
||||||
|
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
||||||
|
putc ('\n', out);
|
||||||
|
fputs (" ", out);
|
||||||
|
for (i = 0; i < hsize; ++i)
|
||||||
|
fprintf (out, "%d", (int) (i % 10));
|
||||||
|
putc ('\n', out);
|
||||||
|
|
||||||
|
/* Bar. */
|
||||||
|
fputs (" .", out);
|
||||||
|
for (i = 0; i < hsize; ++i)
|
||||||
|
putc ('-', out);
|
||||||
|
fputs (".\n", out);
|
||||||
|
|
||||||
|
/* Contents. */
|
||||||
|
for (i = 0; bset[i]; ++i)
|
||||||
|
{
|
||||||
|
fprintf (out, "%2lu|", (unsigned long) i);
|
||||||
|
for (j = 0; j < hsize; ++j)
|
||||||
|
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||||
|
fputs ("|\n", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bar. */
|
||||||
|
fputs (" `", out);
|
||||||
|
for (i = 0; i < hsize; ++i)
|
||||||
|
putc ('-', out);
|
||||||
|
fputs ("'\n", out);
|
||||||
|
|
||||||
|
/* End title. */
|
||||||
|
fprintf (out, "%s END\n\n", title);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/* Bitset vectors.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Akim Demaille ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _BITSETV_PRINT_H
|
||||||
|
#define _BITSETV_PRINT_H
|
||||||
|
|
||||||
|
#include "bitsetv.h"
|
||||||
|
|
||||||
|
/* Dump vector of bitsets as a matrix. */
|
||||||
|
extern void bitsetv_matrix_dump PARAMS ((FILE *, const char *,
|
||||||
|
bitsetv));
|
||||||
|
|
||||||
|
#endif /* _BITSETV_H */
|
||||||
+172
@@ -0,0 +1,172 @@
|
|||||||
|
/* Bitset vectors.
|
||||||
|
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC 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.
|
||||||
|
|
||||||
|
GCC 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 GCC; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "bitsetv.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
|
||||||
|
type TYPE. */
|
||||||
|
bitset *
|
||||||
|
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||||
|
enum bitset_type type)
|
||||||
|
{
|
||||||
|
size_t vector_bytes;
|
||||||
|
size_t bytes;
|
||||||
|
bitset *bsetv;
|
||||||
|
bitset_bindex i;
|
||||||
|
|
||||||
|
/* Determine number of bytes for each set. */
|
||||||
|
bytes = bitset_bytes (type, n_bits);
|
||||||
|
|
||||||
|
/* If size calculation overflows, memory is exhausted. */
|
||||||
|
if (BITSET_SIZE_MAX / (sizeof (bitset) + bytes) <= n_vecs)
|
||||||
|
xalloc_die ();
|
||||||
|
|
||||||
|
/* Allocate vector table at head of bitset array. */
|
||||||
|
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
|
||||||
|
vector_bytes -= vector_bytes % bytes;
|
||||||
|
bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs);
|
||||||
|
|
||||||
|
for (i = 0; i < n_vecs; i++)
|
||||||
|
{
|
||||||
|
bsetv[i] = (bitset) (void *) ((char *) bsetv + vector_bytes + i * bytes);
|
||||||
|
|
||||||
|
bitset_init (bsetv[i], n_bits, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Null terminate table. */
|
||||||
|
bsetv[i] = 0;
|
||||||
|
return bsetv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
|
||||||
|
attribute hints specified by ATTR. */
|
||||||
|
bitset *
|
||||||
|
bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned int attr)
|
||||||
|
{
|
||||||
|
enum bitset_type type;
|
||||||
|
|
||||||
|
type = bitset_type_choose (n_bits, attr);
|
||||||
|
return bitsetv_alloc (n_vecs, n_bits, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Free bitset vector BSETV. */
|
||||||
|
void
|
||||||
|
bitsetv_free (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
BITSET_FREE_ (bsetv[i]);
|
||||||
|
free (bsetv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Zero a vector of bitsets. */
|
||||||
|
void
|
||||||
|
bitsetv_zero (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
bitset_zero (bsetv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set a vector of bitsets to ones. */
|
||||||
|
void
|
||||||
|
bitsetv_ones (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
bitset_ones (bsetv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Given a vector BSETV of N bitsets of size N, modify its contents to
|
||||||
|
be the transitive closure of what was given. */
|
||||||
|
void
|
||||||
|
bitsetv_transitive_closure (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
bitset_bindex j;
|
||||||
|
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
for (j = 0; bsetv[j]; j++)
|
||||||
|
if (bitset_test (bsetv[j], i))
|
||||||
|
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
void
|
||||||
|
bitsetv_reflexive_transitive_closure (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_bindex i;
|
||||||
|
|
||||||
|
bitsetv_transitive_closure (bsetv);
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
bitset_set (bsetv[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Dump the contents of a bitset vector BSETV with N_VECS elements to
|
||||||
|
FILE. */
|
||||||
|
void
|
||||||
|
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||||
|
bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
|
||||||
|
fprintf (file, "%s\n", title);
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
{
|
||||||
|
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
|
||||||
|
bitset_dump (file, bsetv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (file, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
debug_bitsetv (bitsetv bsetv)
|
||||||
|
{
|
||||||
|
bitset_windex i;
|
||||||
|
|
||||||
|
for (i = 0; bsetv[i]; i++)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%lu: ", (unsigned long) i);
|
||||||
|
debug_bitset (bsetv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/* Bitset vectors.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _BITSETV_H
|
||||||
|
#define _BITSETV_H
|
||||||
|
|
||||||
|
#include "bitset.h"
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
/* 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));
|
||||||
|
|
||||||
|
/* Free vector of bitsets. */
|
||||||
|
extern void bitsetv_free PARAMS ((bitsetv));
|
||||||
|
|
||||||
|
/* Zero vector of bitsets. */
|
||||||
|
extern void bitsetv_zero PARAMS ((bitsetv));
|
||||||
|
|
||||||
|
/* Set vector of bitsets. */
|
||||||
|
extern void bitsetv_ones PARAMS ((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));
|
||||||
|
|
||||||
|
/* 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));
|
||||||
|
|
||||||
|
/* Dump vector of bitsets. */
|
||||||
|
extern void bitsetv_dump PARAMS ((FILE *, const char *,
|
||||||
|
const char *, bitsetv));
|
||||||
|
|
||||||
|
/* Function to debug vector of bitsets from debugger. */
|
||||||
|
extern void debug_bitsetv PARAMS ((bitsetv));
|
||||||
|
|
||||||
|
#endif /* _BITSETV_H */
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
/* 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
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/* 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_ */
|
||||||
+1259
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
|||||||
|
/* Functions to support ebitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _EBITSET_H
|
||||||
|
#define _EBITSET_H
|
||||||
|
|
||||||
|
#include "bitset.h"
|
||||||
|
|
||||||
|
extern size_t ebitset_bytes PARAMS ((bitset_bindex));
|
||||||
|
|
||||||
|
extern bitset ebitset_init PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
extern void ebitset_release_memory PARAMS ((void));
|
||||||
|
|
||||||
|
#endif
|
||||||
+208
-77
@@ -1,23 +1,18 @@
|
|||||||
/* Error handler for noninteractive utilities
|
/* Error handler for noninteractive utilities
|
||||||
Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc.
|
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 file is part of the GNU C Library. Its master source is NOT part of
|
This program is distributed in the hope that it will be useful,
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU 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
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
Library General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU General Public License along
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
Boston, MA 02111-1307, USA. */
|
|
||||||
|
|
||||||
/* Written by David MacKenzie <[email protected]>. */
|
/* Written by David MacKenzie <[email protected]>. */
|
||||||
|
|
||||||
@@ -26,8 +21,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if HAVE_LIBINTL_H
|
|
||||||
|
#ifdef _LIBC
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
|
#else
|
||||||
|
# include "gettext.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <wchar.h>
|
||||||
|
# define mbsrtowcs __mbsrtowcs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||||
@@ -52,11 +55,8 @@ void exit ();
|
|||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
#ifndef HAVE_DECL_STRERROR_R
|
#if !_LIBC
|
||||||
"this configure-time declaration test was not run"
|
# include "unlocked-io.h"
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_STRERROR_R
|
|
||||||
char *strerror_r ();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _
|
#ifndef _
|
||||||
@@ -80,34 +80,52 @@ unsigned int error_message_count;
|
|||||||
|
|
||||||
# define program_name program_invocation_name
|
# define program_name program_invocation_name
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
|
# include <libio/libioP.h>
|
||||||
|
|
||||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||||
Instead make it a weak alias. */
|
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 __error
|
||||||
# define error_at_line __error_at_line
|
# define error_at_line __error_at_line
|
||||||
|
|
||||||
# ifdef USE_IN_LIBIO
|
# ifdef USE_IN_LIBIO
|
||||||
# include <libio/iolibio.h>
|
# include <libio/iolibio.h>
|
||||||
# define fflush(s) _IO_fflush (s)
|
# define fflush(s) INTUSE(_IO_fflush) (s)
|
||||||
|
# undef putc
|
||||||
|
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else /* not _LIBC */
|
#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
|
/* The calling program should define program_name and set it to the
|
||||||
name of the executing program. */
|
name of the executing program. */
|
||||||
extern char *program_name;
|
extern char *program_name;
|
||||||
|
|
||||||
# ifdef HAVE_STRERROR_R
|
# if HAVE_STRERROR_R || defined strerror_r
|
||||||
# define __strerror_r strerror_r
|
# define __strerror_r strerror_r
|
||||||
# else
|
# else
|
||||||
# if HAVE_STRERROR
|
# if HAVE_STRERROR
|
||||||
# ifndef strerror /* On some systems, strerror is a macro */
|
# ifndef HAVE_DECL_STRERROR
|
||||||
|
"this configure-time declaration test was not run"
|
||||||
|
# endif
|
||||||
|
# if !HAVE_DECL_STRERROR
|
||||||
char *strerror ();
|
char *strerror ();
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
static char *
|
static char *
|
||||||
private_strerror (errnum)
|
private_strerror (int errnum)
|
||||||
int errnum;
|
|
||||||
{
|
{
|
||||||
extern char *sys_errlist[];
|
extern char *sys_errlist[];
|
||||||
extern int sys_nerr;
|
extern int sys_nerr;
|
||||||
@@ -118,15 +136,118 @@ private_strerror (errnum)
|
|||||||
}
|
}
|
||||||
# define strerror private_strerror
|
# define strerror private_strerror
|
||||||
# endif /* HAVE_STRERROR */
|
# endif /* HAVE_STRERROR */
|
||||||
# endif /* HAVE_STRERROR_R */
|
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||||
#endif /* not _LIBC */
|
#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
|
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||||
format string with optional args.
|
format string with optional args.
|
||||||
If ERRNUM is nonzero, print its corresponding system error message.
|
If ERRNUM is nonzero, print its corresponding system error message.
|
||||||
Exit with status STATUS if it is nonzero. */
|
Exit with status STATUS if it is nonzero. */
|
||||||
/* VARARGS */
|
/* VARARGS */
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined VA_START && __STDC__
|
#if defined VA_START && __STDC__
|
||||||
error (int status, int errnum, const char *message, ...)
|
error (int status, int errnum, const char *message, ...)
|
||||||
@@ -142,47 +263,48 @@ error (status, errnum, message, va_alist)
|
|||||||
va_list args;
|
va_list args;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
fflush (stdout);
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_flockfile (stderr);
|
||||||
|
# else
|
||||||
|
__flockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (error_print_progname)
|
if (error_print_progname)
|
||||||
(*error_print_progname) ();
|
(*error_print_progname) ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fflush (stdout);
|
#if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s: ", program_name);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
fprintf (stderr, "%s: ", program_name);
|
fprintf (stderr, "%s: ", program_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VA_START
|
#ifdef VA_START
|
||||||
VA_START (args, message);
|
VA_START (args, message);
|
||||||
# if HAVE_VPRINTF || _LIBC
|
error_tail (status, errnum, message, args);
|
||||||
vfprintf (stderr, message, args);
|
|
||||||
# else
|
|
||||||
_doprnt (message, args, stderr);
|
|
||||||
# endif
|
|
||||||
va_end (args);
|
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
#endif
|
|
||||||
|
|
||||||
++error_message_count;
|
++error_message_count;
|
||||||
if (errnum)
|
if (errnum)
|
||||||
{
|
print_errno_message (errnum);
|
||||||
#if defined HAVE_STRERROR_R || _LIBC
|
|
||||||
char errbuf[1024];
|
|
||||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
|
||||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
|
||||||
# else
|
|
||||||
/* Don't use __strerror_r's return value because on some systems
|
|
||||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
|
||||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
|
||||||
fprintf (stderr, ": %s", errbuf);
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
fprintf (stderr, ": %s", strerror (errnum));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
if (status)
|
if (status)
|
||||||
exit (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
|
/* Sometimes we want to have at most one error per line. This
|
||||||
@@ -212,8 +334,9 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
|||||||
static const char *old_file_name;
|
static const char *old_file_name;
|
||||||
static unsigned int old_line_number;
|
static unsigned int old_line_number;
|
||||||
|
|
||||||
if (old_line_number == line_number &&
|
if (old_line_number == line_number
|
||||||
(file_name == old_file_name || !strcmp (old_file_name, file_name)))
|
&& (file_name == old_file_name
|
||||||
|
|| strcmp (old_file_name, file_name) == 0))
|
||||||
/* Simply return and print nothing. */
|
/* Simply return and print nothing. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -221,50 +344,58 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
|||||||
old_line_number = line_number;
|
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)
|
if (error_print_progname)
|
||||||
(*error_print_progname) ();
|
(*error_print_progname) ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fflush (stdout);
|
#if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s: ", program_name);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
fprintf (stderr, "%s:", program_name);
|
fprintf (stderr, "%s:", program_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_name != NULL)
|
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);
|
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VA_START
|
#ifdef VA_START
|
||||||
VA_START (args, message);
|
VA_START (args, message);
|
||||||
# if HAVE_VPRINTF || _LIBC
|
error_tail (status, errnum, message, args);
|
||||||
vfprintf (stderr, message, args);
|
|
||||||
# else
|
|
||||||
_doprnt (message, args, stderr);
|
|
||||||
# endif
|
|
||||||
va_end (args);
|
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
#endif
|
|
||||||
|
|
||||||
++error_message_count;
|
++error_message_count;
|
||||||
if (errnum)
|
if (errnum)
|
||||||
{
|
print_errno_message (errnum);
|
||||||
#if defined HAVE_STRERROR_R || _LIBC
|
|
||||||
char errbuf[1024];
|
|
||||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
|
||||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
|
||||||
# else
|
|
||||||
/* Don't use __strerror_r's return value because on some systems
|
|
||||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
|
||||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
|
||||||
fprintf (stderr, ": %s", errbuf);
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
fprintf (stderr, ": %s", strerror (errnum));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
if (status)
|
if (status)
|
||||||
exit (status);
|
exit (status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_funlockfile (stderr);
|
||||||
|
# else
|
||||||
|
__funlockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#ifndef __attribute__
|
#ifndef __attribute__
|
||||||
/* This feature is available in gcc versions 2.5 and later. */
|
/* This feature is available in gcc versions 2.5 and later. */
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||||
# define __attribute__(Spec) /* empty */
|
# define __attribute__(Spec) /* empty */
|
||||||
# endif
|
# endif
|
||||||
/* The __-protected variants of `format' and `printf' attributes
|
/* The __-protected variants of `format' and `printf' attributes
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/* get-errno.h - get and set errno.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
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. */
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "get-errno.h"
|
||||||
|
|
||||||
|
/* Get and set errno. A source file that needs to set or get errno,
|
||||||
|
but doesn't need to test for specific errno values, can use these
|
||||||
|
functions to avoid namespace pollution. For example, a file that
|
||||||
|
defines EQUAL should not include <errno.h>, since <errno.h> might
|
||||||
|
define EQUAL; such a file can include <get-errno.h> instead. */
|
||||||
|
|
||||||
|
int
|
||||||
|
get_errno (void)
|
||||||
|
{
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_errno (int e)
|
||||||
|
{
|
||||||
|
errno = e;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/* get-errno.h - get and set errno.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
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. */
|
||||||
|
|
||||||
|
extern int get_errno (void);
|
||||||
|
extern void set_errno (int);
|
||||||
+283
-59
@@ -1,22 +1,23 @@
|
|||||||
/* Getopt for GNU.
|
/* Getopt for GNU.
|
||||||
NOTE: The canonical source of this file is maintained with the GNU
|
NOTE: getopt is now part of the C library, so if you don't know what
|
||||||
C Library. Bugs can be reported to bug-glibc@gnu.org.
|
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
||||||
|
before changing it!
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002
|
||||||
Free Software Foundation, Inc.
|
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
|
This program is free software; you can redistribute it and/or modify
|
||||||
under the terms of the GNU General Public License as published by the
|
it under the terms of the GNU General Public License as published by
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License along
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||||
@@ -27,7 +28,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
#if !defined __STDC__ || !__STDC__
|
#if !defined __STDC__ || !__STDC__
|
||||||
/* This is a separate conditional since some stdc systems
|
/* This is a separate conditional since some stdc systems
|
||||||
reject `defined (const)'. */
|
reject `defined (const)'. */
|
||||||
@@ -35,7 +37,6 @@
|
|||||||
# define const
|
# define const
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -74,15 +75,20 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _
|
#ifdef _LIBC
|
||||||
/* This is for other GNU distributions with internationalized messages.
|
|
||||||
When compiling libc, the _ macro is predefined. */
|
|
||||||
# ifdef HAVE_LIBINTL_H
|
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# define _(msgid) gettext (msgid)
|
|
||||||
#else
|
#else
|
||||||
# define _(msgid) (msgid)
|
/* This is for other GNU distributions with internationalized messages. */
|
||||||
|
# include "gettext.h"
|
||||||
#endif
|
#endif
|
||||||
|
#define _(msgid) gettext (msgid)
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef attribute_hidden
|
||||||
|
# define attribute_hidden
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||||
@@ -128,7 +134,7 @@ int optind = 1;
|
|||||||
causes problems with re-calling getopt as programs generally don't
|
causes problems with re-calling getopt as programs generally don't
|
||||||
know that. */
|
know that. */
|
||||||
|
|
||||||
int __getopt_initialized;
|
int __getopt_initialized attribute_hidden;
|
||||||
|
|
||||||
/* The next char to be scanned in the option-element
|
/* The next char to be scanned in the option-element
|
||||||
in which the last option character we returned was found.
|
in which the last option character we returned was found.
|
||||||
@@ -247,34 +253,24 @@ static int first_nonopt;
|
|||||||
static int last_nonopt;
|
static int last_nonopt;
|
||||||
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
|
/* Stored original parameters.
|
||||||
|
XXX This is no good solution. We should rather copy the args so
|
||||||
|
that we can compare them later. But we must not use malloc(3). */
|
||||||
|
extern int __libc_argc;
|
||||||
|
extern char **__libc_argv;
|
||||||
|
|
||||||
/* Bash 2.0 gives us an environment variable containing flags
|
/* Bash 2.0 gives us an environment variable containing flags
|
||||||
indicating ARGV elements that should not be considered arguments. */
|
indicating ARGV elements that should not be considered arguments. */
|
||||||
|
|
||||||
|
# ifdef USE_NONOPTION_FLAGS
|
||||||
/* Defined in getopt_init.c */
|
/* Defined in getopt_init.c */
|
||||||
extern char *__getopt_nonoption_flags;
|
extern char *__getopt_nonoption_flags;
|
||||||
|
|
||||||
static int nonoption_flags_max_len;
|
static int nonoption_flags_max_len;
|
||||||
static int nonoption_flags_len;
|
static int nonoption_flags_len;
|
||||||
|
# endif
|
||||||
|
|
||||||
static int original_argc;
|
# ifdef USE_NONOPTION_FLAGS
|
||||||
static char *const *original_argv;
|
|
||||||
|
|
||||||
/* Make sure the environment variable bash 2.0 puts in the environment
|
|
||||||
is valid for the getopt call we must make sure that the ARGV passed
|
|
||||||
to getopt is that one passed to the process. */
|
|
||||||
static void
|
|
||||||
__attribute__ ((unused))
|
|
||||||
store_args_and_env (int argc, char *const *argv)
|
|
||||||
{
|
|
||||||
/* XXX This is no good solution. We should rather copy the args so
|
|
||||||
that we can compare them later. But we must not use malloc(3). */
|
|
||||||
original_argc = argc;
|
|
||||||
original_argv = argv;
|
|
||||||
}
|
|
||||||
# ifdef text_set_element
|
|
||||||
text_set_element (__libc_subinit, store_args_and_env);
|
|
||||||
# endif /* text_set_element */
|
|
||||||
|
|
||||||
# define SWAP_FLAGS(ch1, ch2) \
|
# define SWAP_FLAGS(ch1, ch2) \
|
||||||
if (nonoption_flags_len > 0) \
|
if (nonoption_flags_len > 0) \
|
||||||
{ \
|
{ \
|
||||||
@@ -282,6 +278,9 @@ text_set_element (__libc_subinit, store_args_and_env);
|
|||||||
__getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
|
__getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
|
||||||
__getopt_nonoption_flags[ch2] = __tmp; \
|
__getopt_nonoption_flags[ch2] = __tmp; \
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
# define SWAP_FLAGS(ch1, ch2)
|
||||||
|
# endif
|
||||||
#else /* !_LIBC */
|
#else /* !_LIBC */
|
||||||
# define SWAP_FLAGS(ch1, ch2)
|
# define SWAP_FLAGS(ch1, ch2)
|
||||||
#endif /* _LIBC */
|
#endif /* _LIBC */
|
||||||
@@ -313,7 +312,7 @@ exchange (argv)
|
|||||||
It leaves the longer segment in the right place overall,
|
It leaves the longer segment in the right place overall,
|
||||||
but it consists of two parts that need to be swapped next. */
|
but it consists of two parts that need to be swapped next. */
|
||||||
|
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
/* First make sure the handling of the `__getopt_nonoption_flags'
|
/* First make sure the handling of the `__getopt_nonoption_flags'
|
||||||
string can work normally. Our top argument must be in the range
|
string can work normally. Our top argument must be in the range
|
||||||
of the string. */
|
of the string. */
|
||||||
@@ -417,9 +416,9 @@ _getopt_initialize (argc, argv, optstring)
|
|||||||
else
|
else
|
||||||
ordering = PERMUTE;
|
ordering = PERMUTE;
|
||||||
|
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
if (posixly_correct == NULL
|
if (posixly_correct == NULL
|
||||||
&& argc == original_argc && argv == original_argv)
|
&& argc == __libc_argc && argv == __libc_argv)
|
||||||
{
|
{
|
||||||
if (nonoption_flags_max_len == 0)
|
if (nonoption_flags_max_len == 0)
|
||||||
{
|
{
|
||||||
@@ -515,6 +514,13 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
int *longind;
|
int *longind;
|
||||||
int long_only;
|
int long_only;
|
||||||
{
|
{
|
||||||
|
int print_errors = opterr;
|
||||||
|
if (optstring[0] == ':')
|
||||||
|
print_errors = 0;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
|
||||||
if (optind == 0 || !__getopt_initialized)
|
if (optind == 0 || !__getopt_initialized)
|
||||||
@@ -529,7 +535,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
Either it does not have option syntax, or there is an environment flag
|
Either it does not have option syntax, or there is an environment flag
|
||||||
from the shell indicating it is not an option. The later information
|
from the shell indicating it is not an option. The later information
|
||||||
is only used when the used in the GNU libc. */
|
is only used when the used in the GNU libc. */
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||||
|| (optind < nonoption_flags_len \
|
|| (optind < nonoption_flags_len \
|
||||||
&& __getopt_nonoption_flags[optind] == '1'))
|
&& __getopt_nonoption_flags[optind] == '1'))
|
||||||
@@ -664,16 +670,37 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
pfound = p;
|
pfound = p;
|
||||||
indfound = option_index;
|
indfound = option_index;
|
||||||
}
|
}
|
||||||
else
|
else if (long_only
|
||||||
|
|| pfound->has_arg != p->has_arg
|
||||||
|
|| pfound->flag != p->flag
|
||||||
|
|| pfound->val != p->val)
|
||||||
/* Second or later nonexact match found. */
|
/* Second or later nonexact match found. */
|
||||||
ambig = 1;
|
ambig = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
|
||||||
|
argv[0], argv[optind]) >= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
||||||
argv[0], argv[optind]);
|
argv[0], argv[optind]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optind++;
|
optind++;
|
||||||
optopt = 0;
|
optopt = 0;
|
||||||
@@ -692,18 +719,52 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = nameend + 1;
|
optarg = nameend + 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argv[optind - 1][1] == '-')
|
if (argv[optind - 1][1] == '-')
|
||||||
|
{
|
||||||
/* --option */
|
/* --option */
|
||||||
fprintf (stderr,
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
n = __asprintf (&buf, _("\
|
||||||
|
%s: option `--%s' doesn't allow an argument\n"),
|
||||||
argv[0], pfound->name);
|
argv[0], pfound->name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("\
|
||||||
|
%s: option `--%s' doesn't allow an argument\n"),
|
||||||
|
argv[0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
fprintf (stderr,
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
n = __asprintf (&buf, _("\
|
||||||
|
%s: option `%c%s' doesn't allow an argument\n"),
|
||||||
|
argv[0], argv[optind - 1][0],
|
||||||
|
pfound->name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("\
|
||||||
|
%s: option `%c%s' doesn't allow an argument\n"),
|
||||||
argv[0], argv[optind - 1][0], pfound->name);
|
argv[0], argv[optind - 1][0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
@@ -718,10 +779,28 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = argv[optind++];
|
optarg = argv[optind++];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `%s' requires an argument\n"),
|
||||||
|
argv[0], argv[optind - 1]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option `%s' requires an argument\n"),
|
||||||
argv[0], argv[optind - 1]);
|
argv[0], argv[optind - 1]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optopt = pfound->val;
|
optopt = pfound->val;
|
||||||
return optstring[0] == ':' ? ':' : '?';
|
return optstring[0] == ':' ? ':' : '?';
|
||||||
@@ -745,16 +824,47 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (!long_only || argv[optind][1] == '-'
|
if (!long_only || argv[optind][1] == '-'
|
||||||
|| my_index (optstring, *nextchar) == NULL)
|
|| my_index (optstring, *nextchar) == NULL)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argv[optind][1] == '-')
|
if (argv[optind][1] == '-')
|
||||||
|
{
|
||||||
/* --option */
|
/* --option */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
|
||||||
|
argv[0], nextchar);
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
||||||
argv[0], nextchar);
|
argv[0], nextchar);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
|
||||||
|
argv[0], argv[optind][0], nextchar);
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
|
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
|
||||||
argv[0], argv[optind][0], nextchar);
|
argv[0], argv[optind][0], nextchar);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
nextchar = (char *) "";
|
nextchar = (char *) "";
|
||||||
optind++;
|
optind++;
|
||||||
@@ -775,15 +885,44 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
|
|
||||||
if (temp == NULL || c == ':')
|
if (temp == NULL || c == ':')
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (posixly_correct)
|
if (posixly_correct)
|
||||||
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
fprintf (stderr, _("%s: illegal option -- %c\n"),
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, _("%s: invalid option -- %c\n"),
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
return '?';
|
return '?';
|
||||||
@@ -809,11 +948,27 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
else if (optind == argc)
|
else if (optind == argc)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf,
|
||||||
|
_("%s: option requires an argument -- %c\n"),
|
||||||
|
argv[0], c) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
@@ -858,9 +1013,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
|
||||||
|
argv[0], argv[optind]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
||||||
argv[0], argv[optind]);
|
argv[0], argv[optind]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optind++;
|
optind++;
|
||||||
return '?';
|
return '?';
|
||||||
@@ -876,10 +1048,28 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = nameend + 1;
|
optarg = nameend + 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `-W %s' doesn't allow an argument\n"),
|
||||||
|
argv[0], pfound->name) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("\
|
fprintf (stderr, _("\
|
||||||
%s: option `-W %s' doesn't allow an argument\n"),
|
%s: option `-W %s' doesn't allow an argument\n"),
|
||||||
argv[0], pfound->name);
|
argv[0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
return '?';
|
return '?';
|
||||||
@@ -891,10 +1081,28 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = argv[optind++];
|
optarg = argv[optind++];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `%s' requires an argument\n"),
|
||||||
|
argv[0], argv[optind - 1]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option `%s' requires an argument\n"),
|
||||||
argv[0], argv[optind - 1]);
|
argv[0], argv[optind - 1]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
return optstring[0] == ':' ? ':' : '?';
|
return optstring[0] == ':' ? ':' : '?';
|
||||||
}
|
}
|
||||||
@@ -938,12 +1146,28 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
else if (optind == argc)
|
else if (optind == argc)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option requires an argument -- %c\n"),
|
||||||
|
argv[0], c) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option requires an argument -- %c\n"),
|
_("%s: option requires an argument -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
|
|||||||
+28
-17
@@ -1,21 +1,20 @@
|
|||||||
/* Declarations for getopt.
|
/* Declarations for getopt.
|
||||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Bugs can be reported to [email protected].
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify
|
||||||
under the terms of the GNU General Public License as published by the
|
it under the terms of the GNU General Public License as published by
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License along
|
||||||
along with this program; if not, write to the Free Software
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
USA. */
|
|
||||||
|
|
||||||
#ifndef _GETOPT_H
|
#ifndef _GETOPT_H
|
||||||
|
|
||||||
@@ -23,6 +22,17 @@
|
|||||||
# define _GETOPT_H 1
|
# define _GETOPT_H 1
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -82,7 +92,7 @@ extern int optopt;
|
|||||||
|
|
||||||
struct option
|
struct option
|
||||||
{
|
{
|
||||||
# if defined __STDC__ && __STDC__
|
# if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||||
const char *name;
|
const char *name;
|
||||||
# else
|
# else
|
||||||
char *name;
|
char *name;
|
||||||
@@ -126,25 +136,26 @@ struct option
|
|||||||
arguments to the option '\0'. This behavior is specific to the GNU
|
arguments to the option '\0'. This behavior is specific to the GNU
|
||||||
`getopt'. */
|
`getopt'. */
|
||||||
|
|
||||||
#if defined __STDC__ && __STDC__
|
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||||
# ifdef __GNU_LIBRARY__
|
# ifdef __GNU_LIBRARY__
|
||||||
/* Many other libraries have conflicting prototypes for getopt, with
|
/* Many other libraries have conflicting prototypes for getopt, with
|
||||||
differences in the consts, in stdlib.h. To avoid compilation
|
differences in the consts, in stdlib.h. To avoid compilation
|
||||||
errors, only prototype getopt for the GNU C library. */
|
errors, only prototype getopt for the GNU C library. */
|
||||||
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
|
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
|
||||||
# else /* not __GNU_LIBRARY__ */
|
# else /* not __GNU_LIBRARY__ */
|
||||||
extern int getopt ();
|
extern int getopt ();
|
||||||
# endif /* __GNU_LIBRARY__ */
|
# endif /* __GNU_LIBRARY__ */
|
||||||
|
|
||||||
# ifndef __need_getopt
|
# ifndef __need_getopt
|
||||||
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
extern int getopt_long (int ___argc, char *const *___argv,
|
||||||
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind);
|
const struct option *__longopts, int *__longind);
|
||||||
extern int getopt_long_only (int __argc, char *const *__argv,
|
extern int getopt_long_only (int ___argc, char *const *___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind);
|
const struct option *__longopts, int *__longind);
|
||||||
|
|
||||||
/* Internal only. Users should not call this directly. */
|
/* Internal only. Users should not call this directly. */
|
||||||
extern int _getopt_internal (int __argc, char *const *__argv,
|
extern int _getopt_internal (int ___argc, char *const *___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
int __long_only);
|
int __long_only);
|
||||||
|
|||||||
+18
-11
@@ -1,26 +1,32 @@
|
|||||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Bugs can be reported to [email protected].
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify
|
||||||
under the terms of the GNU General Public License as published by the
|
it under the terms of the GNU General Public License as published by
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License along
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <getopt.h>
|
||||||
#else
|
#else
|
||||||
|
# include "getopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined __STDC__ || !__STDC__
|
#if !defined __STDC__ || !__STDC__
|
||||||
/* This is a separate conditional since some stdc systems
|
/* This is a separate conditional since some stdc systems
|
||||||
reject `defined (const)'. */
|
reject `defined (const)'. */
|
||||||
@@ -28,9 +34,6 @@
|
|||||||
#define const
|
#define const
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "getopt.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -90,6 +93,10 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
|
|||||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
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. */
|
#endif /* Not ELIDE_CODE. */
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/* 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 */
|
||||||
+992
-232
File diff suppressed because it is too large
Load Diff
+65
-116
@@ -1,6 +1,6 @@
|
|||||||
/* hash.h -- decls for hash table
|
/* hash - hashing table processing.
|
||||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||||
Written by Greg McGary <[email protected]>
|
Written by Jim Meyering <[email protected]>, 1998.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -13,132 +13,81 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _hash_h_
|
/* A generic hash table package. */
|
||||||
#define _hash_h_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
/* 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. */
|
||||||
|
|
||||||
typedef unsigned long (*hash_func_t) __P((void const *key));
|
#ifndef HASH_H_
|
||||||
typedef int (*hash_cmp_func_t) __P((void const *x, void const *y));
|
# define HASH_H_
|
||||||
typedef void (*hash_map_func_t) __P((void const *item));
|
|
||||||
|
|
||||||
struct hash_table
|
# 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 **ht_vec;
|
void *data;
|
||||||
unsigned long ht_size; /* total number of slots (power of 2) */
|
struct hash_entry *next;
|
||||||
unsigned long ht_capacity; /* usable slots, limited by loading-factor */
|
|
||||||
unsigned long ht_fill; /* items in table */
|
|
||||||
unsigned long ht_collisions; /* # of failed calls to comparison function */
|
|
||||||
unsigned long ht_lookups; /* # of queries */
|
|
||||||
unsigned int ht_rehashes; /* # of times we've expanded table */
|
|
||||||
hash_func_t ht_hash_1; /* primary hash function */
|
|
||||||
hash_func_t ht_hash_2; /* secondary hash function */
|
|
||||||
hash_cmp_func_t ht_compare; /* comparison function */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*qsort_cmp_t) __P((void const *, void const *));
|
struct hash_tuning
|
||||||
|
{
|
||||||
|
/* This structure is mainly used for `hash_initialize', see the block
|
||||||
|
documentation of `hash_reset_tuning' for more complete comments. */
|
||||||
|
|
||||||
void hash_init __P((struct hash_table *ht, unsigned long size,
|
float shrink_threshold; /* ratio of used buckets to trigger a shrink */
|
||||||
hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
|
float shrink_factor; /* ratio of new smaller size to original size */
|
||||||
void hash_load __P((struct hash_table *ht, void *item_table,
|
float growth_threshold; /* ratio of used buckets to trigger a growth */
|
||||||
unsigned long cardinality, unsigned long size));
|
float growth_factor; /* ratio of new bigger size to original size */
|
||||||
void **hash_find_slot __P((struct hash_table *ht, void const *key));
|
bool is_n_buckets; /* if CANDIDATE really means table size */
|
||||||
void *hash_find_item __P((struct hash_table *ht, void const *key));
|
};
|
||||||
void *hash_insert __P((struct hash_table *ht, void *item));
|
|
||||||
void *hash_insert_at __P((struct hash_table *ht, void *item, void const *slot));
|
|
||||||
void *hash_delete __P((struct hash_table *ht, void const *item));
|
|
||||||
void *hash_delete_at __P((struct hash_table *ht, void const *slot));
|
|
||||||
void hash_delete_items __P((struct hash_table *ht));
|
|
||||||
void hash_free_items __P((struct hash_table *ht));
|
|
||||||
void hash_free __P((struct hash_table *ht, int free_items));
|
|
||||||
void hash_map __P((struct hash_table *ht, hash_map_func_t map));
|
|
||||||
void hash_print_stats __P((struct hash_table *ht, FILE *out_FILE));
|
|
||||||
void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compare));
|
|
||||||
|
|
||||||
extern void *hash_deleted_item;
|
typedef struct hash_tuning Hash_tuning;
|
||||||
#define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item)
|
|
||||||
|
|
||||||
|
struct hash_table;
|
||||||
/* hash and comparison macros for string keys. */
|
|
||||||
|
|
||||||
#define STRING_HASH_1(_key_, _result_) { \
|
typedef struct hash_table Hash_table;
|
||||||
unsigned char const *kk = (unsigned char const *) (_key_) - 1; \
|
|
||||||
while (*++kk) \
|
|
||||||
(_result_) += (*kk << (kk[1] & 0xf)); \
|
|
||||||
} while (0)
|
|
||||||
#define return_STRING_HASH_1(_key_) do { \
|
|
||||||
unsigned long result = 0; \
|
|
||||||
STRING_HASH_1 ((_key_), result); \
|
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define STRING_HASH_2(_key_, _result_) do { \
|
/* Information and lookup. */
|
||||||
unsigned char const *kk = (unsigned char const *) (_key_) - 1; \
|
unsigned hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||||
while (*++kk) \
|
unsigned hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||||
(_result_) += (*kk << (kk[1] & 0x7)); \
|
unsigned hash_get_n_entries PARAMS ((const Hash_table *));
|
||||||
} while (0)
|
unsigned hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||||
#define return_STRING_HASH_2(_key_) do { \
|
bool hash_table_ok PARAMS ((const Hash_table *));
|
||||||
unsigned long result = 0; \
|
void hash_print_statistics PARAMS ((const Hash_table *, FILE *));
|
||||||
STRING_HASH_2 ((_key_), result); \
|
void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define STRING_COMPARE(_x_, _y_, _result_) do { \
|
/* Walking. */
|
||||||
unsigned char const *xx = (unsigned char const *) (_x_) - 1; \
|
void *hash_get_first PARAMS ((const Hash_table *));
|
||||||
unsigned char const *yy = (unsigned char const *) (_y_) - 1; \
|
void *hash_get_next PARAMS ((const Hash_table *, const void *));
|
||||||
do { \
|
unsigned hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
|
||||||
if (*++xx == '\0') { \
|
unsigned hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
|
||||||
yy++; \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
} while (*xx == *++yy); \
|
|
||||||
(_result_) = *xx - *yy; \
|
|
||||||
} while (0)
|
|
||||||
#define return_STRING_COMPARE(_x_, _y_) do { \
|
|
||||||
int result; \
|
|
||||||
STRING_COMPARE (_x_, _y_, result); \
|
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* hash and comparison macros for integer keys. */
|
/* 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 *));
|
||||||
|
|
||||||
#define INTEGER_HASH_1(_key_, _result_) do { \
|
/* Insertion and deletion. */
|
||||||
(_result_) += ((unsigned long)(_key_)); \
|
bool hash_rehash PARAMS ((Hash_table *, unsigned));
|
||||||
} while (0)
|
void *hash_insert PARAMS ((Hash_table *, const void *));
|
||||||
#define return_INTEGER_HASH_1(_key_) do { \
|
void *hash_delete PARAMS ((Hash_table *, const void *));
|
||||||
unsigned long result = 0; \
|
|
||||||
INTEGER_HASH_1 ((_key_), result); \
|
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define INTEGER_HASH_2(_key_, _result_) do { \
|
#endif
|
||||||
(_result_) += ~((unsigned long)(_key_)); \
|
|
||||||
} while (0)
|
|
||||||
#define return_INTEGER_HASH_2(_key_) do { \
|
|
||||||
unsigned long result = 0; \
|
|
||||||
INTEGER_HASH_2 ((_key_), result); \
|
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define INTEGER_COMPARE(_x_, _y_, _result_) do { \
|
|
||||||
(_result_) = _x_ - _y_; \
|
|
||||||
} while (0)
|
|
||||||
#define return_INTEGER_COMPARE(_x_, _y_) do { \
|
|
||||||
int result; \
|
|
||||||
INTEGER_COMPARE (_x_, _y_, result); \
|
|
||||||
return result; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* hash and comparison macros for address keys. */
|
|
||||||
|
|
||||||
#define ADDRESS_HASH_1(_key_, _result_) INTEGER_HASH_1 (((unsigned long)(_key_)) >> 3, (_result_))
|
|
||||||
#define ADDRESS_HASH_2(_key_, _result_) INTEGER_HASH_2 (((unsigned long)(_key_)) >> 3, (_result_))
|
|
||||||
#define ADDRESS_COMPARE(_x_, _y_, _result_) INTEGER_COMPARE ((_x_), (_y_), (_result_))
|
|
||||||
#define return_ADDRESS_HASH_1(_key_) return_INTEGER_HASH_1 (((unsigned long)(_key_)) >> 3)
|
|
||||||
#define return_ADDRESS_HASH_2(_key_) return_INTEGER_HASH_2 (((unsigned long)(_key_)) >> 3)
|
|
||||||
#define return_ADDRESS_COMPARE(_x_, _y_) return_INTEGER_COMPARE ((_x_), (_y_))
|
|
||||||
|
|
||||||
#endif /* not _hash_h_ */
|
|
||||||
|
|||||||
+1373
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
|||||||
|
/* Functions to support lbitsets.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Michael Hayes ([email protected]).
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef _LBITSET_H
|
||||||
|
#define _LBITSET_H
|
||||||
|
|
||||||
|
#include "bitset.h"
|
||||||
|
|
||||||
|
extern size_t lbitset_bytes PARAMS ((bitset_bindex));
|
||||||
|
|
||||||
|
extern bitset lbitset_init PARAMS ((bitset, bitset_bindex));
|
||||||
|
|
||||||
|
extern void lbitset_release_memory PARAMS ((void));
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/* Fake libiberty.h for Bison.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
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. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Bison depends on libiberty's implementation of bitsets, which
|
||||||
|
requires a `libiberty.h' file. This file provides the minimum
|
||||||
|
services. */
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
# include "xalloc.h"
|
||||||
|
|
||||||
|
#endif /* ! BISON_LIBIBERTY_H_ */
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
/* Yacc library main function.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#if HAVE_LOCALE_H
|
||||||
|
# include <locale.h>
|
||||||
|
#endif
|
||||||
|
#if ! HAVE_SETLOCALE
|
||||||
|
# define setlocale(Category, Locale)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int yyparse (void);
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
|
return yyparse ();
|
||||||
|
}
|
||||||
+213
@@ -0,0 +1,213 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/* 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);
|
||||||
+386
@@ -0,0 +1,386 @@
|
|||||||
|
/* 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
@@ -0,0 +1,209 @@
|
|||||||
|
/* 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
|
||||||
+47
-35
@@ -1,23 +1,18 @@
|
|||||||
/* obstack.c - subroutines used implicitly by object stack macros
|
/* obstack.c - subroutines used implicitly by object stack macros
|
||||||
Copyright (C) 1988-1994,96,97,98,99,2000 Free Software Foundation, Inc.
|
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 file is part of the GNU C Library. Its master source is NOT part of
|
This program is distributed in the hope that it will be useful,
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU 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
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
Library General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU General Public License along
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
Boston, MA 02111-1307, USA. */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
@@ -40,18 +35,21 @@
|
|||||||
files, it is simpler to just do this in the source for each such file. */
|
files, it is simpler to just do this in the source for each such file. */
|
||||||
|
|
||||||
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
||||||
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
|
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
|
||||||
# include <gnu-versions.h>
|
# include <gnu-versions.h>
|
||||||
# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||||
# define ELIDE_CODE
|
# define ELIDE_CODE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ELIDE_CODE
|
#ifndef ELIDE_CODE
|
||||||
|
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
# define POINTER void *
|
# define POINTER void *
|
||||||
# else
|
# else
|
||||||
# define POINTER char *
|
# define POINTER char *
|
||||||
@@ -82,7 +80,7 @@ union fooround {long x; double d;};
|
|||||||
abort gracefully or use longjump - but shouldn't return. This
|
abort gracefully or use longjump - but shouldn't return. This
|
||||||
variable by default points to the internal function
|
variable by default points to the internal function
|
||||||
`print_and_abort'. */
|
`print_and_abort'. */
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
static void print_and_abort (void);
|
static void print_and_abort (void);
|
||||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||||
# else
|
# else
|
||||||
@@ -110,7 +108,7 @@ struct obstack *_obstack;
|
|||||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||||
do not allow (expr) ? void : void. */
|
do not allow (expr) ? void : void. */
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
# define CALL_CHUNKFUN(h, size) \
|
# define CALL_CHUNKFUN(h, size) \
|
||||||
(((h) -> use_extra_arg) \
|
(((h) -> use_extra_arg) \
|
||||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||||
@@ -152,7 +150,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
POINTER (*chunkfun) (long);
|
POINTER (*chunkfun) (long);
|
||||||
void (*freefun) (void *);
|
void (*freefun) (void *);
|
||||||
# else
|
# else
|
||||||
@@ -181,7 +179,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||||
# else
|
# else
|
||||||
@@ -210,7 +208,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
POINTER (*chunkfun) (POINTER, long);
|
POINTER (*chunkfun) (POINTER, long);
|
||||||
void (*freefun) (POINTER, POINTER);
|
void (*freefun) (POINTER, POINTER);
|
||||||
# else
|
# else
|
||||||
@@ -240,7 +238,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||||
# else
|
# else
|
||||||
@@ -341,7 +339,7 @@ _obstack_newchunk (h, length)
|
|||||||
This is here for debugging.
|
This is here for debugging.
|
||||||
If you use it in a program, you are probably losing. */
|
If you use it in a program, you are probably losing. */
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||||
obstack.h because it is just for debugging. */
|
obstack.h because it is just for debugging. */
|
||||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||||
@@ -456,26 +454,40 @@ _obstack_memory_used (h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Define the error handler. */
|
/* Define the error handler. */
|
||||||
#ifndef _
|
# ifdef _LIBC
|
||||||
# if defined HAVE_LIBINTL_H || defined _LIBC
|
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# ifndef _
|
|
||||||
# define _(Str) gettext (Str)
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define _(Str) (Str)
|
# include "gettext.h"
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
# define _(msgid) gettext (msgid)
|
||||||
|
|
||||||
# if defined _LIBC && defined USE_IN_LIBIO
|
# if defined _LIBC && defined USE_IN_LIBIO
|
||||||
# include <libio/iolibio.h>
|
# include <libio/iolibio.h>
|
||||||
# define fputs(s, f) _IO_fputs (s, f)
|
# define fputs(s, f) _IO_fputs (s, f)
|
||||||
# endif
|
# 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
|
static void
|
||||||
|
__attribute__ ((noreturn))
|
||||||
print_and_abort ()
|
print_and_abort ()
|
||||||
{
|
{
|
||||||
fputs (_("memory exhausted"), stderr);
|
/* Don't change any of these strings. Yes, it would be possible to add
|
||||||
fputc ('\n', stderr);
|
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);
|
exit (obstack_exit_failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +498,7 @@ print_and_abort ()
|
|||||||
/* Now define the functional versions of the obstack macros.
|
/* Now define the functional versions of the obstack macros.
|
||||||
Define them to simply use the corresponding macros to do the job. */
|
Define them to simply use the corresponding macros to do the job. */
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
/* These function definitions do not work with non-ANSI preprocessors;
|
/* These function definitions do not work with non-ANSI preprocessors;
|
||||||
they won't pass through the macro names in parentheses. */
|
they won't pass through the macro names in parentheses. */
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -4,20 +4,23 @@
|
|||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
This file is part of the GNU C Library. Its master source is NOT part of
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
the C library, however. The master source lives in /gd/gnu/lib.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||||
modify it under the terms of the GNU Library General Public License as
|
Bugs can be reported to bug-glibc@gnu.org.
|
||||||
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,
|
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
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
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,
|
License along with this program; if not, write to the Free Software
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
Boston, MA 02111-1307, USA. */
|
USA. */
|
||||||
|
|
||||||
/* Summary:
|
/* Summary:
|
||||||
|
|
||||||
|
|||||||
+22
-2
@@ -1,12 +1,32 @@
|
|||||||
|
/* 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]> */
|
/* Written by Paul Eggert <[email protected]> */
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_STDDEF_H
|
||||||
|
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <quotearg.h>
|
#include "quotearg.h"
|
||||||
#include <quote.h>
|
#include "quote.h"
|
||||||
|
|
||||||
/* Return an unambiguous printable representated, allocated in slot N,
|
/* Return an unambiguous printable representated, allocated in slot N,
|
||||||
for NAME, suitable for diagnostics. */
|
for NAME, suitable for diagnostics. */
|
||||||
|
|||||||
+17
-1
@@ -1,4 +1,20 @@
|
|||||||
/* prototypes for quote.c */
|
/* 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
|
#ifndef PARAMS
|
||||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||||
|
|||||||
+82
-74
@@ -1,5 +1,5 @@
|
|||||||
/* quotearg.c - quote arguments for output
|
/* quotearg.c - quote arguments for output
|
||||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,46 +21,19 @@
|
|||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_STDDEF_H
|
#include "quotearg.h"
|
||||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
|
||||||
#endif
|
#include "xalloc.h"
|
||||||
#include <sys/types.h>
|
|
||||||
#include <quotearg.h>
|
|
||||||
#include <xalloc.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#if ENABLE_NLS
|
|
||||||
# include <libintl.h>
|
|
||||||
# define _(text) gettext (text)
|
|
||||||
#else
|
|
||||||
# define _(text) text
|
|
||||||
#endif
|
|
||||||
#define N_(text) text
|
|
||||||
|
|
||||||
#if HAVE_LIMITS_H
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#endif
|
|
||||||
#ifndef CHAR_BIT
|
|
||||||
# define CHAR_BIT 8
|
|
||||||
#endif
|
|
||||||
#ifndef UCHAR_MAX
|
|
||||||
# define UCHAR_MAX ((unsigned char) -1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_C_BACKSLASH_A
|
|
||||||
# define ALERT_CHAR '\a'
|
|
||||||
#else
|
|
||||||
# define ALERT_CHAR '\7'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_STRING_H
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
|
||||||
|
#include "gettext.h"
|
||||||
|
#define _(msgid) gettext (msgid)
|
||||||
|
#define N_(msgid) msgid
|
||||||
|
|
||||||
#if HAVE_WCHAR_H
|
#if HAVE_WCHAR_H
|
||||||
|
|
||||||
@@ -78,7 +51,7 @@
|
|||||||
# undef MB_CUR_MAX
|
# undef MB_CUR_MAX
|
||||||
# define MB_CUR_MAX 1
|
# define MB_CUR_MAX 1
|
||||||
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
||||||
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
|
# define iswprint(wc) isprint ((unsigned char) (wc))
|
||||||
# undef HAVE_MBSINIT
|
# undef HAVE_MBSINIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -95,17 +68,11 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
#ifndef SIZE_MAX
|
||||||
|
# define SIZE_MAX ((size_t) -1)
|
||||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
|
||||||
# define IN_CTYPE_DOMAIN(c) 1
|
|
||||||
#else
|
|
||||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
|
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||||
#undef ISPRINT
|
|
||||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
|
||||||
|
|
||||||
struct quoting_options
|
struct quoting_options
|
||||||
{
|
{
|
||||||
@@ -151,9 +118,10 @@ static struct quoting_options default_quoting_options;
|
|||||||
struct quoting_options *
|
struct quoting_options *
|
||||||
clone_quoting_options (struct quoting_options *o)
|
clone_quoting_options (struct quoting_options *o)
|
||||||
{
|
{
|
||||||
struct quoting_options *p
|
int e = errno;
|
||||||
= (struct quoting_options *) xmalloc (sizeof (struct quoting_options));
|
struct quoting_options *p = xmalloc (sizeof *p);
|
||||||
*p = *(o ? o : &default_quoting_options);
|
*p = *(o ? o : &default_quoting_options);
|
||||||
|
errno = e;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +253,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++)
|
for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
unsigned char esc;
|
unsigned char esc;
|
||||||
@@ -299,6 +267,16 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
c = arg[i];
|
c = arg[i];
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case '\0':
|
||||||
|
if (backslash_escapes)
|
||||||
|
{
|
||||||
|
STORE ('\\');
|
||||||
|
STORE ('0');
|
||||||
|
STORE ('0');
|
||||||
|
c = '0';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
switch (quoting_style)
|
switch (quoting_style)
|
||||||
{
|
{
|
||||||
@@ -314,8 +292,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
case '<': case '=': case '>':
|
case '<': case '=': case '>':
|
||||||
/* Escape the second '?' in what would otherwise be
|
/* Escape the second '?' in what would otherwise be
|
||||||
a trigraph. */
|
a trigraph. */
|
||||||
i += 2;
|
|
||||||
c = arg[i + 2];
|
c = arg[i + 2];
|
||||||
|
i += 2;
|
||||||
STORE ('?');
|
STORE ('?');
|
||||||
STORE ('\\');
|
STORE ('\\');
|
||||||
STORE ('?');
|
STORE ('?');
|
||||||
@@ -328,7 +306,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALERT_CHAR: esc = 'a'; goto c_escape;
|
case '\a': esc = 'a'; goto c_escape;
|
||||||
case '\b': esc = 'b'; goto c_escape;
|
case '\b': esc = 'b'; goto c_escape;
|
||||||
case '\f': esc = 'f'; goto c_escape;
|
case '\f': esc = 'f'; goto c_escape;
|
||||||
case '\n': esc = 'n'; goto c_and_shell_escape;
|
case '\n': esc = 'n'; goto c_and_shell_escape;
|
||||||
@@ -416,7 +394,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
if (unibyte_locale)
|
if (unibyte_locale)
|
||||||
{
|
{
|
||||||
m = 1;
|
m = 1;
|
||||||
printable = ISPRINT (c);
|
printable = isprint (c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -425,7 +403,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
|||||||
|
|
||||||
m = 0;
|
m = 0;
|
||||||
printable = 1;
|
printable = 1;
|
||||||
if (argsize == (size_t) -1)
|
if (argsize == SIZE_MAX)
|
||||||
argsize = strlen (arg);
|
argsize = strlen (arg);
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -521,24 +499,31 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
|||||||
struct quoting_options const *o)
|
struct quoting_options const *o)
|
||||||
{
|
{
|
||||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
int e = errno;
|
||||||
|
size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||||
p->style, p);
|
p->style, p);
|
||||||
|
errno = e;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use storage slot N to return a quoted version of the string ARG.
|
/* 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.
|
OPTIONS specifies the quoting options.
|
||||||
The returned value points to static storage that can be
|
The returned value points to static storage that can be
|
||||||
reused by the next call to this function with the same value of N.
|
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"
|
N must be nonnegative. N is deliberately declared with type "int"
|
||||||
to allow for future extensions (using negative values). */
|
to allow for future extensions (using negative values). */
|
||||||
static char *
|
static char *
|
||||||
quotearg_n_options (int n, char const *arg,
|
quotearg_n_options (int n, char const *arg, size_t argsize,
|
||||||
struct quoting_options const *options)
|
struct quoting_options const *options)
|
||||||
{
|
{
|
||||||
|
int e = errno;
|
||||||
|
|
||||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||||
one small component of a "memory exhausted" message in slot 0. */
|
one small component of a "memory exhausted" message in slot 0. */
|
||||||
static char slot0[256];
|
static char slot0[256];
|
||||||
static unsigned int nslots = 1;
|
static unsigned int nslots = 1;
|
||||||
|
unsigned int n0 = n;
|
||||||
struct slotvec
|
struct slotvec
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
@@ -547,42 +532,49 @@ quotearg_n_options (int n, char const *arg,
|
|||||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||||
static struct slotvec *slotvec = &slotvec0;
|
static struct slotvec *slotvec = &slotvec0;
|
||||||
|
|
||||||
if (nslots <= n)
|
if (n < 0)
|
||||||
{
|
|
||||||
int n1 = n + 1;
|
|
||||||
size_t s = n1 * sizeof (struct slotvec);
|
|
||||||
if (! (0 < n1 && n1 == s / sizeof (struct slotvec)))
|
|
||||||
abort ();
|
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)
|
if (slotvec == &slotvec0)
|
||||||
{
|
{
|
||||||
slotvec = (struct slotvec *) xmalloc (sizeof (struct slotvec));
|
slotvec = xmalloc (sizeof *slotvec);
|
||||||
*slotvec = slotvec0;
|
*slotvec = slotvec0;
|
||||||
}
|
}
|
||||||
slotvec = (struct slotvec *) xrealloc (slotvec, s);
|
slotvec = xrealloc (slotvec, s);
|
||||||
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec));
|
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof *slotvec);
|
||||||
nslots = n;
|
nslots = n1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t size = slotvec[n].size;
|
size_t size = slotvec[n].size;
|
||||||
char *val = slotvec[n].val;
|
char *val = slotvec[n].val;
|
||||||
size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options);
|
size_t qsize = quotearg_buffer (val, size, arg, argsize, options);
|
||||||
|
|
||||||
if (size <= qsize)
|
if (size <= qsize)
|
||||||
{
|
{
|
||||||
slotvec[n].size = size = qsize + 1;
|
slotvec[n].size = size = qsize + 1;
|
||||||
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
||||||
quotearg_buffer (val, size, arg, (size_t) -1, options);
|
quotearg_buffer (val, size, arg, argsize, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errno = e;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
quotearg_n (unsigned int n, char const *arg)
|
quotearg_n (int n, char const *arg)
|
||||||
{
|
{
|
||||||
return quotearg_n_options (n, arg, &default_quoting_options);
|
return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -591,13 +583,29 @@ quotearg (char const *arg)
|
|||||||
return quotearg_n (0, arg);
|
return quotearg_n (0, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
/* Return quoting options for STYLE, with no extra quoting. */
|
||||||
quotearg_n_style (unsigned int n, enum quoting_style s, char const *arg)
|
static struct quoting_options
|
||||||
|
quoting_options_from_style (enum quoting_style style)
|
||||||
{
|
{
|
||||||
struct quoting_options o;
|
struct quoting_options o;
|
||||||
o.style = s;
|
o.style = style;
|
||||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||||
return quotearg_n_options (n, arg, &o);
|
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 *
|
char *
|
||||||
@@ -612,7 +620,7 @@ quotearg_char (char const *arg, char ch)
|
|||||||
struct quoting_options options;
|
struct quoting_options options;
|
||||||
options = default_quoting_options;
|
options = default_quoting_options;
|
||||||
set_char_quoting (&options, ch, 1);
|
set_char_quoting (&options, ch, 1);
|
||||||
return quotearg_n_options (0, arg, &options);
|
return quotearg_n_options (0, arg, SIZE_MAX, &options);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|||||||
+28
-24
@@ -1,5 +1,7 @@
|
|||||||
/* quotearg.h - quote arguments for output
|
/* quotearg.h - quote arguments for output
|
||||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
|
||||||
|
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +19,11 @@
|
|||||||
|
|
||||||
/* Written by Paul Eggert <[email protected]> */
|
/* Written by Paul Eggert <[email protected]> */
|
||||||
|
|
||||||
|
#ifndef QUOTEARG_H_
|
||||||
|
# define QUOTEARG_H_ 1
|
||||||
|
|
||||||
|
# include <stddef.h>
|
||||||
|
|
||||||
/* Basic quoting styles. */
|
/* Basic quoting styles. */
|
||||||
enum quoting_style
|
enum quoting_style
|
||||||
{
|
{
|
||||||
@@ -40,37 +47,27 @@ extern enum quoting_style const quoting_style_vals[];
|
|||||||
|
|
||||||
struct quoting_options;
|
struct quoting_options;
|
||||||
|
|
||||||
#ifndef PARAMS
|
|
||||||
# if defined PROTOTYPES || defined __STDC__
|
|
||||||
# define PARAMS(Args) Args
|
|
||||||
# else
|
|
||||||
# define PARAMS(Args) ()
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The functions listed below set and use a hidden variable
|
/* The functions listed below set and use a hidden variable
|
||||||
that contains the default quoting style options. */
|
that contains the default quoting style options. */
|
||||||
|
|
||||||
/* Allocate a new set of quoting options, with contents initially identical
|
/* 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.
|
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. */
|
It is the caller's responsibility to free the result. */
|
||||||
struct quoting_options *clone_quoting_options
|
struct quoting_options *clone_quoting_options (struct quoting_options *o);
|
||||||
PARAMS ((struct quoting_options *o));
|
|
||||||
|
|
||||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||||
enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o));
|
enum quoting_style get_quoting_style (struct quoting_options *o);
|
||||||
|
|
||||||
/* In O (or in the default if O is null),
|
/* In O (or in the default if O is null),
|
||||||
set the value of the quoting style to S. */
|
set the value of the quoting style to S. */
|
||||||
void set_quoting_style PARAMS ((struct quoting_options *o,
|
void set_quoting_style (struct quoting_options *o, enum quoting_style s);
|
||||||
enum quoting_style s));
|
|
||||||
|
|
||||||
/* In O (or in the default if O is null),
|
/* In O (or in the default if O is null),
|
||||||
set the value of the quoting options for character C to I.
|
set the value of the quoting options for character C to I.
|
||||||
Return the old value. Currently, the only values defined for I are
|
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
|
0 (the default) and 1 (which means to quote the character even if
|
||||||
it would not otherwise be quoted). */
|
it would not otherwise be quoted). */
|
||||||
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
int set_char_quoting (struct quoting_options *o, char c, int i);
|
||||||
|
|
||||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||||
@@ -80,31 +77,38 @@ int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
|||||||
If BUFFERSIZE is too small to store the output string, return the
|
If BUFFERSIZE is too small to store the output string, return the
|
||||||
value that would have been returned had BUFFERSIZE been large enough.
|
value that would have been returned had BUFFERSIZE been large enough.
|
||||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||||
size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize,
|
size_t quotearg_buffer (char *buffer, size_t buffersize,
|
||||||
char const *arg, size_t argsize,
|
char const *arg, size_t argsize,
|
||||||
struct quoting_options const *o));
|
struct quoting_options const *o);
|
||||||
|
|
||||||
/* Use storage slot N to return a quoted version of the string ARG.
|
/* Use storage slot N to return a quoted version of the string ARG.
|
||||||
Use the default quoting options.
|
Use the default quoting options.
|
||||||
The returned value points to static storage that can be
|
The returned value points to static storage that can be
|
||||||
reused by the next call to this function with the same value of N.
|
reused by the next call to this function with the same value of N.
|
||||||
N must be nonnegative. */
|
N must be nonnegative. */
|
||||||
char *quotearg_n PARAMS ((unsigned int n, char const *arg));
|
char *quotearg_n (int n, char const *arg);
|
||||||
|
|
||||||
/* Equivalent to quotearg_n (0, ARG). */
|
/* Equivalent to quotearg_n (0, ARG). */
|
||||||
char *quotearg PARAMS ((char const *arg));
|
char *quotearg (char const *arg);
|
||||||
|
|
||||||
/* Use style S and storage slot N to return a quoted version of the string 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
|
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||||
options to specify the quoting method. */
|
options to specify the quoting method. */
|
||||||
char *quotearg_n_style PARAMS ((unsigned int n, enum quoting_style s,
|
char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
|
||||||
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). */
|
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||||
char *quotearg_style PARAMS ((enum quoting_style s, char const *arg));
|
char *quotearg_style (enum quoting_style s, char const *arg);
|
||||||
|
|
||||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||||
char *quotearg_char PARAMS ((char const *arg, char ch));
|
char *quotearg_char (char const *arg, char ch);
|
||||||
|
|
||||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||||
char *quotearg_colon PARAMS ((char const *arg));
|
char *quotearg_colon (char const *arg);
|
||||||
|
|
||||||
|
#endif /* !QUOTEARG_H_ */
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/* 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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#define LENGTH_LIMIT
|
||||||
|
#include "strcasecmp.c"
|
||||||
+6
-2
@@ -1,5 +1,5 @@
|
|||||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||||
Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1996, 1997, 1998, 2000-2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -25,7 +25,11 @@
|
|||||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||||
# include <memory.h>
|
# include <memory.h>
|
||||||
# endif
|
# 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>
|
# include <string.h>
|
||||||
|
# undef strnlen
|
||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -51,7 +55,7 @@ size_t
|
|||||||
__strnlen (const char *string, size_t maxlen)
|
__strnlen (const char *string, size_t maxlen)
|
||||||
{
|
{
|
||||||
const char *end = memchr (string, '\0', maxlen);
|
const char *end = memchr (string, '\0', maxlen);
|
||||||
return end ? end - string : maxlen;
|
return end ? (size_t) (end - string) : maxlen;
|
||||||
}
|
}
|
||||||
#ifdef weak_alias
|
#ifdef weak_alias
|
||||||
weak_alias (__strnlen, strnlen)
|
weak_alias (__strnlen, strnlen)
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* 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);
|
||||||
|
}
|
||||||
+11
-12
@@ -3,20 +3,19 @@
|
|||||||
NOTE: The canonical source of this file is maintained with the GNU
|
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.
|
C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or modify
|
||||||
modify it under the terms of the GNU Library General Public License
|
it under the terms of the GNU General Public License as published by
|
||||||
as published by the Free Software Foundation; either version 2 of
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
the License, or (at your option) any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
This program is distributed in the hope that it will be useful,
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
Library General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU General Public License
|
||||||
License along with this program; see the file COPYING.LIB. If not,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place -
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
Suite 330, Boston, MA 02111-1307, USA. */
|
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
|
|||||||
+472
@@ -0,0 +1,472 @@
|
|||||||
|
/* Convert string representation of a number into an integer value.
|
||||||
|
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 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@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 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 _LIBC
|
||||||
|
# define USE_NUMBER_GROUPING
|
||||||
|
# define STDC_HEADERS
|
||||||
|
# define HAVE_LIMITS_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef errno
|
||||||
|
extern int errno;
|
||||||
|
#endif
|
||||||
|
#ifndef __set_errno
|
||||||
|
# define __set_errno(Val) errno = (Val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
# include <limits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stddef.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <string.h>
|
||||||
|
#else
|
||||||
|
# ifndef NULL
|
||||||
|
# define NULL 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NUMBER_GROUPING
|
||||||
|
# include "../locale/localeinfo.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
|
||||||
|
unsigned integers. */
|
||||||
|
#ifndef UNSIGNED
|
||||||
|
# define UNSIGNED 0
|
||||||
|
# define INT LONG int
|
||||||
|
#else
|
||||||
|
# define INT unsigned LONG int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Determine the name. */
|
||||||
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
|
# if UNSIGNED
|
||||||
|
# ifdef USE_WIDE_CHAR
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol __wcstoull_l
|
||||||
|
# else
|
||||||
|
# define strtol __wcstoul_l
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol __strtoull_l
|
||||||
|
# else
|
||||||
|
# define strtol __strtoul_l
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef USE_WIDE_CHAR
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol __wcstoll_l
|
||||||
|
# else
|
||||||
|
# define strtol __wcstol_l
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol __strtoll_l
|
||||||
|
# else
|
||||||
|
# define strtol __strtol_l
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if UNSIGNED
|
||||||
|
# ifdef USE_WIDE_CHAR
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol wcstoull
|
||||||
|
# else
|
||||||
|
# define strtol wcstoul
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol strtoull
|
||||||
|
# else
|
||||||
|
# define strtol strtoul
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef USE_WIDE_CHAR
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol wcstoll
|
||||||
|
# else
|
||||||
|
# define strtol wcstol
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef QUAD
|
||||||
|
# define strtol strtoll
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
|
||||||
|
operating on `long long int's. */
|
||||||
|
#ifdef QUAD
|
||||||
|
# define LONG long long
|
||||||
|
# define STRTOL_LONG_MIN LONG_LONG_MIN
|
||||||
|
# define STRTOL_LONG_MAX LONG_LONG_MAX
|
||||||
|
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
|
||||||
|
|
||||||
|
/* The extra casts work around common compiler bugs,
|
||||||
|
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||||
|
# ifndef TYPE_SIGNED
|
||||||
|
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||||
|
# endif
|
||||||
|
# ifndef TYPE_MINIMUM
|
||||||
|
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||||
|
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||||
|
: (t) 0))
|
||||||
|
# endif
|
||||||
|
# ifndef TYPE_MAXIMUM
|
||||||
|
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ULONG_LONG_MAX
|
||||||
|
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
|
||||||
|
# endif
|
||||||
|
# ifndef LONG_LONG_MAX
|
||||||
|
# define LONG_LONG_MAX TYPE_MAXIMUM (long long int)
|
||||||
|
# endif
|
||||||
|
# ifndef LONG_LONG_MIN
|
||||||
|
# define LONG_LONG_MIN TYPE_MINIMUM (long long int)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
|
||||||
|
/* Work around gcc bug with using this constant. */
|
||||||
|
static const unsigned long long int maxquad = ULONG_LONG_MAX;
|
||||||
|
# undef STRTOL_ULONG_MAX
|
||||||
|
# define STRTOL_ULONG_MAX maxquad
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LONG long
|
||||||
|
|
||||||
|
# ifndef ULONG_MAX
|
||||||
|
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||||
|
# endif
|
||||||
|
# ifndef LONG_MAX
|
||||||
|
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||||
|
# endif
|
||||||
|
# define STRTOL_LONG_MIN LONG_MIN
|
||||||
|
# define STRTOL_LONG_MAX LONG_MAX
|
||||||
|
# define STRTOL_ULONG_MAX ULONG_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* We use this code also for the extended locale handling where the
|
||||||
|
function gets as an additional argument the locale which has to be
|
||||||
|
used. To access the values we have to redefine the _NL_CURRENT
|
||||||
|
macro. */
|
||||||
|
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
|
# undef _NL_CURRENT
|
||||||
|
# define _NL_CURRENT(category, item) \
|
||||||
|
(current->values[_NL_ITEM_INDEX (item)].string)
|
||||||
|
# define LOCALE_PARAM , loc
|
||||||
|
# define LOCALE_PARAM_DECL __locale_t loc;
|
||||||
|
#else
|
||||||
|
# define LOCALE_PARAM
|
||||||
|
# define LOCALE_PARAM_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC || defined HAVE_WCHAR_H
|
||||||
|
# include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_WIDE_CHAR
|
||||||
|
# include <wctype.h>
|
||||||
|
# define L_(Ch) L##Ch
|
||||||
|
# define UCHAR_TYPE wint_t
|
||||||
|
# define STRING_TYPE wchar_t
|
||||||
|
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
|
# define ISSPACE(Ch) __iswspace_l ((Ch), loc)
|
||||||
|
# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
|
||||||
|
# define TOUPPER(Ch) __towupper_l ((Ch), loc)
|
||||||
|
# else
|
||||||
|
# define ISSPACE(Ch) iswspace (Ch)
|
||||||
|
# define ISALPHA(Ch) iswalpha (Ch)
|
||||||
|
# define TOUPPER(Ch) towupper (Ch)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
|
||||||
|
# define IN_CTYPE_DOMAIN(c) 1
|
||||||
|
# else
|
||||||
|
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||||
|
# endif
|
||||||
|
# define L_(Ch) Ch
|
||||||
|
# define UCHAR_TYPE unsigned char
|
||||||
|
# define STRING_TYPE char
|
||||||
|
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
|
# define ISSPACE(Ch) __isspace_l ((Ch), loc)
|
||||||
|
# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
|
||||||
|
# define TOUPPER(Ch) __toupper_l ((Ch), loc)
|
||||||
|
# else
|
||||||
|
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
|
||||||
|
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
|
||||||
|
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* For compilers which are ansi but don't define __STDC__, like SGI
|
||||||
|
Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */
|
||||||
|
#if defined (__STDC__) || defined (PROTOTYPES)
|
||||||
|
# define INTERNAL(X) INTERNAL1(X)
|
||||||
|
# define INTERNAL1(X) __##X##_internal
|
||||||
|
# define WEAKNAME(X) WEAKNAME1(X)
|
||||||
|
#else
|
||||||
|
# define INTERNAL(X) __/**/X/**/_internal
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NUMBER_GROUPING
|
||||||
|
/* This file defines a function to check for correct grouping. */
|
||||||
|
# include "grouping.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
|
||||||
|
If BASE is 0 the base is determined by the presence of a leading
|
||||||
|
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
|
||||||
|
If BASE is < 2 or > 36, it is reset to 10.
|
||||||
|
If ENDPTR is not NULL, a pointer to the character after the last
|
||||||
|
one converted is stored in *ENDPTR. */
|
||||||
|
|
||||||
|
INT
|
||||||
|
INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
|
||||||
|
const STRING_TYPE *nptr;
|
||||||
|
STRING_TYPE **endptr;
|
||||||
|
int base;
|
||||||
|
int group;
|
||||||
|
LOCALE_PARAM_DECL
|
||||||
|
{
|
||||||
|
int negative;
|
||||||
|
register unsigned LONG int cutoff;
|
||||||
|
register unsigned int cutlim;
|
||||||
|
register unsigned LONG int i;
|
||||||
|
register const STRING_TYPE *s;
|
||||||
|
register UCHAR_TYPE c;
|
||||||
|
const STRING_TYPE *save, *end;
|
||||||
|
int overflow;
|
||||||
|
|
||||||
|
#ifdef USE_NUMBER_GROUPING
|
||||||
|
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||||
|
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
||||||
|
# endif
|
||||||
|
/* The thousands character of the current locale. */
|
||||||
|
wchar_t thousands = L'\0';
|
||||||
|
/* The numeric grouping specification of the current locale,
|
||||||
|
in the format described in <locale.h>. */
|
||||||
|
const char *grouping;
|
||||||
|
|
||||||
|
if (group)
|
||||||
|
{
|
||||||
|
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
||||||
|
if (*grouping <= 0 || *grouping == CHAR_MAX)
|
||||||
|
grouping = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Figure out the thousands separator character. */
|
||||||
|
# if defined _LIBC || defined _HAVE_BTOWC
|
||||||
|
thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
|
||||||
|
if (thousands == WEOF)
|
||||||
|
thousands = L'\0';
|
||||||
|
# endif
|
||||||
|
if (thousands == L'\0')
|
||||||
|
grouping = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
grouping = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (base < 0 || base == 1 || base > 36)
|
||||||
|
{
|
||||||
|
__set_errno (EINVAL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
save = s = nptr;
|
||||||
|
|
||||||
|
/* Skip white space. */
|
||||||
|
while (ISSPACE (*s))
|
||||||
|
++s;
|
||||||
|
if (*s == L_('\0'))
|
||||||
|
goto noconv;
|
||||||
|
|
||||||
|
/* Check for a sign. */
|
||||||
|
if (*s == L_('-'))
|
||||||
|
{
|
||||||
|
negative = 1;
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
else if (*s == L_('+'))
|
||||||
|
{
|
||||||
|
negative = 0;
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
negative = 0;
|
||||||
|
|
||||||
|
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
|
||||||
|
if (*s == L_('0'))
|
||||||
|
{
|
||||||
|
if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
base = 16;
|
||||||
|
}
|
||||||
|
else if (base == 0)
|
||||||
|
base = 8;
|
||||||
|
}
|
||||||
|
else if (base == 0)
|
||||||
|
base = 10;
|
||||||
|
|
||||||
|
/* Save the pointer so we can check later if anything happened. */
|
||||||
|
save = s;
|
||||||
|
|
||||||
|
#ifdef USE_NUMBER_GROUPING
|
||||||
|
if (group)
|
||||||
|
{
|
||||||
|
/* Find the end of the digit string and check its grouping. */
|
||||||
|
end = s;
|
||||||
|
for (c = *end; c != L_('\0'); c = *++end)
|
||||||
|
if ((wchar_t) c != thousands
|
||||||
|
&& ((wchar_t) c < L_('0') || (wchar_t) c > L_('9'))
|
||||||
|
&& (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base))
|
||||||
|
break;
|
||||||
|
if (*s == thousands)
|
||||||
|
end = s;
|
||||||
|
else
|
||||||
|
end = correctly_grouped_prefix (s, end, thousands, grouping);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
end = NULL;
|
||||||
|
|
||||||
|
cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
|
||||||
|
cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
|
||||||
|
|
||||||
|
overflow = 0;
|
||||||
|
i = 0;
|
||||||
|
for (c = *s; c != L_('\0'); c = *++s)
|
||||||
|
{
|
||||||
|
if (s == end)
|
||||||
|
break;
|
||||||
|
if (c >= L_('0') && c <= L_('9'))
|
||||||
|
c -= L_('0');
|
||||||
|
else if (ISALPHA (c))
|
||||||
|
c = TOUPPER (c) - L_('A') + 10;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
if ((int) c >= base)
|
||||||
|
break;
|
||||||
|
/* Check for overflow. */
|
||||||
|
if (i > cutoff || (i == cutoff && c > cutlim))
|
||||||
|
overflow = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i *= (unsigned LONG int) base;
|
||||||
|
i += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if anything actually happened. */
|
||||||
|
if (s == save)
|
||||||
|
goto noconv;
|
||||||
|
|
||||||
|
/* Store in ENDPTR the address of one character
|
||||||
|
past the last character we converted. */
|
||||||
|
if (endptr != NULL)
|
||||||
|
*endptr = (STRING_TYPE *) s;
|
||||||
|
|
||||||
|
#if !UNSIGNED
|
||||||
|
/* Check for a value that is within the range of
|
||||||
|
`unsigned LONG int', but outside the range of `LONG int'. */
|
||||||
|
if (overflow == 0
|
||||||
|
&& i > (negative
|
||||||
|
? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
|
||||||
|
: (unsigned LONG int) STRTOL_LONG_MAX))
|
||||||
|
overflow = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (overflow)
|
||||||
|
{
|
||||||
|
__set_errno (ERANGE);
|
||||||
|
#if UNSIGNED
|
||||||
|
return STRTOL_ULONG_MAX;
|
||||||
|
#else
|
||||||
|
return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the result of the appropriate sign. */
|
||||||
|
return negative ? -i : i;
|
||||||
|
|
||||||
|
noconv:
|
||||||
|
/* We must handle a special case here: the base is 0 or 16 and the
|
||||||
|
first two characters are '0' and 'x', but the rest are no
|
||||||
|
hexadecimal digits. This is no error case. We return 0 and
|
||||||
|
ENDPTR points to the `x`. */
|
||||||
|
if (endptr != NULL)
|
||||||
|
{
|
||||||
|
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
||||||
|
&& save[-2] == L_('0'))
|
||||||
|
*endptr = (STRING_TYPE *) &save[-1];
|
||||||
|
else
|
||||||
|
/* There was no number to convert. */
|
||||||
|
*endptr = (STRING_TYPE *) nptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* External user entry point. */
|
||||||
|
|
||||||
|
#if _LIBC - 0 == 0
|
||||||
|
# undef PARAMS
|
||||||
|
# if defined (__STDC__) && __STDC__
|
||||||
|
# define PARAMS(Args) Args
|
||||||
|
# else
|
||||||
|
# define PARAMS(Args) ()
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Prototype. */
|
||||||
|
INT strtol PARAMS ((const STRING_TYPE *nptr, STRING_TYPE **endptr, int base));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
INT
|
||||||
|
#ifdef weak_function
|
||||||
|
weak_function
|
||||||
|
#endif
|
||||||
|
strtol (nptr, endptr, base LOCALE_PARAM)
|
||||||
|
const STRING_TYPE *nptr;
|
||||||
|
STRING_TYPE **endptr;
|
||||||
|
int base;
|
||||||
|
LOCALE_PARAM_DECL
|
||||||
|
{
|
||||||
|
return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/* Copyright (C) 1991, 1999, 2001 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. */
|
||||||
|
|
||||||
|
#define UNSIGNED 1
|
||||||
|
|
||||||
|
#include "strtol.c"
|
||||||
+196
@@ -0,0 +1,196 @@
|
|||||||
|
/* Subprocesses with pipes.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* Written by Paul Eggert <[email protected]>
|
||||||
|
and Florian Krohm <florian@edamail.fishkill.ibm.com>. */
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef errno
|
||||||
|
extern int errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#if ! defined SIGCHLD && defined SIGCLD
|
||||||
|
# define SIGCHLD SIGCLD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
/* The following test is to work around the gross typo in
|
||||||
|
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
|
||||||
|
is defined to 0, not 1. */
|
||||||
|
#if ! EXIT_FAILURE
|
||||||
|
# undef EXIT_FAILURE
|
||||||
|
# define EXIT_FAILURE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifndef STDIN_FILENO
|
||||||
|
# define STDIN_FILENO 0
|
||||||
|
#endif
|
||||||
|
#ifndef STDOUT_FILENO
|
||||||
|
# define STDOUT_FILENO 1
|
||||||
|
#endif
|
||||||
|
#if ! HAVE_DUP2 && ! defined dup2
|
||||||
|
# if HAVE_FCNTL_H
|
||||||
|
# include <fcntl.h>
|
||||||
|
# endif
|
||||||
|
# define dup2(f, t) (close (t), fcntl (f, F_DUPFD, t))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_SYS_WAIT_H
|
||||||
|
# include <sys/wait.h>
|
||||||
|
#endif
|
||||||
|
#ifndef WEXITSTATUS
|
||||||
|
# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
|
||||||
|
#endif
|
||||||
|
#ifndef WIFEXITED
|
||||||
|
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_VFORK_H
|
||||||
|
# include <vfork.h>
|
||||||
|
#endif
|
||||||
|
#if ! HAVE_WORKING_VFORK
|
||||||
|
# define vfork fork
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
#define _(Msgid) gettext (Msgid)
|
||||||
|
|
||||||
|
#include "subpipe.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize this module. */
|
||||||
|
|
||||||
|
void
|
||||||
|
init_subpipe (void)
|
||||||
|
{
|
||||||
|
#ifdef SIGCHLD
|
||||||
|
/* System V fork+wait does not work if SIGCHLD is ignored. */
|
||||||
|
signal (SIGCHLD, SIG_DFL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a subprocess that is run as a filter. ARGV is the
|
||||||
|
NULL-terminated argument vector for the subprocess. Store read and
|
||||||
|
write file descriptors for communication with the subprocess into
|
||||||
|
FD[0] and FD[1]: input meant for the process can be written into
|
||||||
|
FD[0], and output from the process can be read from FD[1]. Return
|
||||||
|
the subprocess id.
|
||||||
|
|
||||||
|
To avoid deadlock, the invoker must not let incoming data pile up
|
||||||
|
in FD[1] while writing data to FD[0]. */
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
create_subpipe (char const * const *argv, int fd[2])
|
||||||
|
{
|
||||||
|
int pipe_fd[2];
|
||||||
|
int from_in_fd;
|
||||||
|
int from_out_fd;
|
||||||
|
int to_in_fd;
|
||||||
|
int to_out_fd;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if (pipe (pipe_fd) != 0)
|
||||||
|
error (EXIT_FAILURE, errno, "pipe");
|
||||||
|
to_in_fd = pipe_fd[0];
|
||||||
|
to_out_fd = pipe_fd[1];
|
||||||
|
|
||||||
|
if (pipe (pipe_fd) != 0)
|
||||||
|
error (EXIT_FAILURE, errno, "pipe");
|
||||||
|
from_in_fd = pipe_fd[0];
|
||||||
|
from_out_fd = pipe_fd[1];
|
||||||
|
|
||||||
|
pid = vfork ();
|
||||||
|
if (pid < 0)
|
||||||
|
error (EXIT_FAILURE, errno, "fork");
|
||||||
|
|
||||||
|
if (! pid)
|
||||||
|
{
|
||||||
|
/* Child. */
|
||||||
|
close (to_out_fd);
|
||||||
|
close (from_in_fd);
|
||||||
|
|
||||||
|
if (to_in_fd != STDIN_FILENO)
|
||||||
|
{
|
||||||
|
dup2 (to_in_fd, STDIN_FILENO);
|
||||||
|
close (to_in_fd);
|
||||||
|
}
|
||||||
|
if (from_out_fd != STDOUT_FILENO)
|
||||||
|
{
|
||||||
|
dup2 (from_out_fd, STDOUT_FILENO);
|
||||||
|
close (from_out_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The cast to (char **) rather than (char * const *) is needed
|
||||||
|
for portability to older hosts with a nonstandard prototype
|
||||||
|
for execvp. */
|
||||||
|
execvp (argv[0], (char **) argv);
|
||||||
|
|
||||||
|
_exit (errno == ENOENT ? 127 : 126);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parent. */
|
||||||
|
close (to_in_fd);
|
||||||
|
close (from_out_fd);
|
||||||
|
fd[0] = to_out_fd;
|
||||||
|
fd[1] = from_in_fd;
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Wait for the subprocess to exit. */
|
||||||
|
|
||||||
|
void
|
||||||
|
reap_subpipe (pid_t pid, char const *program)
|
||||||
|
{
|
||||||
|
#if HAVE_WAITPID || defined waitpid
|
||||||
|
int wstatus;
|
||||||
|
if (waitpid (pid, &wstatus, 0) < 0)
|
||||||
|
error (EXIT_FAILURE, errno, "waitpid");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int status = WIFEXITED (wstatus) ? WEXITSTATUS (wstatus) : -1;
|
||||||
|
if (status)
|
||||||
|
error (EXIT_FAILURE, 0,
|
||||||
|
_(status == 126
|
||||||
|
? "subsidiary program `%s' could not be invoked"
|
||||||
|
: status == 127
|
||||||
|
? "subsidiary program `%s' not found"
|
||||||
|
: status < 0
|
||||||
|
? "subsidiary program `%s' failed"
|
||||||
|
: "subsidiary program `%s' failed (exit status %d)"),
|
||||||
|
program, status);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* Subprocesses with pipes.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
02111-1307, USA. */
|
||||||
|
|
||||||
|
/* Written by Paul Eggert <[email protected]>
|
||||||
|
and Florian Krohm <florian@edamail.fishkill.ibm.com>. */
|
||||||
|
|
||||||
|
void init_subpipe (void);
|
||||||
|
pid_t create_subpipe (char const * const *, int[2]);
|
||||||
|
void reap_subpipe (pid_t, char const *);
|
||||||
+566
@@ -0,0 +1,566 @@
|
|||||||
|
/* Timing variables for measuring compiler performance.
|
||||||
|
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
02111-1307, USA. */
|
||||||
|
|
||||||
|
#if IN_GCC
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "intl.h"
|
||||||
|
#include "rtl.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* This source file is taken from the GCC source code, with slight
|
||||||
|
modifications that are under control of the IN_GCC preprocessor
|
||||||
|
variable. The !IN_GCC part of this file is specific to Bison. */
|
||||||
|
|
||||||
|
# include "../src/system.h"
|
||||||
|
# if HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
# endif
|
||||||
|
int timevar_report = 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIMES_H
|
||||||
|
# include <sys/times.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOCK_T
|
||||||
|
typedef int clock_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRUCT_TMS
|
||||||
|
struct tms
|
||||||
|
{
|
||||||
|
clock_t tms_utime;
|
||||||
|
clock_t tms_stime;
|
||||||
|
clock_t tms_cutime;
|
||||||
|
clock_t tms_cstime;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
|
||||||
|
extern int getrusage PARAMS ((int, struct rusage *));
|
||||||
|
#endif
|
||||||
|
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
|
||||||
|
extern clock_t times PARAMS ((struct tms *));
|
||||||
|
#endif
|
||||||
|
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
|
||||||
|
extern clock_t clock PARAMS ((void));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef RUSAGE_SELF
|
||||||
|
# define RUSAGE_SELF 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Calculation of scale factor to convert ticks to microseconds.
|
||||||
|
We mustn't use CLOCKS_PER_SEC except with clock(). */
|
||||||
|
#if HAVE_SYSCONF && defined _SC_CLK_TCK
|
||||||
|
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
|
||||||
|
#else
|
||||||
|
# ifdef CLK_TCK
|
||||||
|
# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
|
||||||
|
# else
|
||||||
|
# ifdef HZ
|
||||||
|
# define TICKS_PER_SECOND HZ /* traditional UNIX */
|
||||||
|
# else
|
||||||
|
# define TICKS_PER_SECOND 100 /* often the correct value */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Prefer times to getrusage to clock (each gives successively less
|
||||||
|
information). */
|
||||||
|
#ifdef HAVE_TIMES
|
||||||
|
# define USE_TIMES
|
||||||
|
# define HAVE_USER_TIME
|
||||||
|
# define HAVE_SYS_TIME
|
||||||
|
# define HAVE_WALL_TIME
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_GETRUSAGE
|
||||||
|
# define USE_GETRUSAGE
|
||||||
|
# define HAVE_USER_TIME
|
||||||
|
# define HAVE_SYS_TIME
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_CLOCK
|
||||||
|
# define USE_CLOCK
|
||||||
|
# define HAVE_USER_TIME
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* libc is very likely to have snuck a call to sysconf() into one of
|
||||||
|
the underlying constants, and that can be very slow, so we have to
|
||||||
|
precompute them. Whose wonderful idea was it to make all those
|
||||||
|
_constants_ variable at run time, anyway? */
|
||||||
|
#ifdef USE_TIMES
|
||||||
|
static float ticks_to_msec;
|
||||||
|
#define TICKS_TO_MSEC (1.0 / TICKS_PER_SECOND)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CLOCK
|
||||||
|
static float clocks_to_msec;
|
||||||
|
#define CLOCKS_TO_MSEC (1.0 / CLOCKS_PER_SEC)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if IN_GCC
|
||||||
|
#include "flags.h"
|
||||||
|
#endif
|
||||||
|
#include "timevar.h"
|
||||||
|
|
||||||
|
/* See timevar.h for an explanation of timing variables. */
|
||||||
|
|
||||||
|
/* This macro evaluates to nonzero if timing variables are enabled. */
|
||||||
|
#define TIMEVAR_ENABLE (timevar_report)
|
||||||
|
|
||||||
|
/* A timing variable. */
|
||||||
|
|
||||||
|
struct timevar_def
|
||||||
|
{
|
||||||
|
/* Elapsed time for this variable. */
|
||||||
|
struct timevar_time_def elapsed;
|
||||||
|
|
||||||
|
/* If this variable is timed independently of the timing stack,
|
||||||
|
using timevar_start, this contains the start time. */
|
||||||
|
struct timevar_time_def start_time;
|
||||||
|
|
||||||
|
/* The name of this timing variable. */
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
/* Non-zero if this timing variable is running as a standalone
|
||||||
|
timer. */
|
||||||
|
unsigned standalone : 1;
|
||||||
|
|
||||||
|
/* Non-zero if this timing variable was ever started or pushed onto
|
||||||
|
the timing stack. */
|
||||||
|
unsigned used : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* An element on the timing stack. Elapsed time is attributed to the
|
||||||
|
topmost timing variable on the stack. */
|
||||||
|
|
||||||
|
struct timevar_stack_def
|
||||||
|
{
|
||||||
|
/* The timing variable at this stack level. */
|
||||||
|
struct timevar_def *timevar;
|
||||||
|
|
||||||
|
/* The next lower timing variable context in the stack. */
|
||||||
|
struct timevar_stack_def *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Declared timing variables. Constructed from the contents of
|
||||||
|
timevar.def. */
|
||||||
|
static struct timevar_def timevars[TIMEVAR_LAST];
|
||||||
|
|
||||||
|
/* The top of the timing stack. */
|
||||||
|
static struct timevar_stack_def *stack;
|
||||||
|
|
||||||
|
/* A list of unused (i.e. allocated and subsequently popped)
|
||||||
|
timevar_stack_def instances. */
|
||||||
|
static struct timevar_stack_def *unused_stack_instances;
|
||||||
|
|
||||||
|
/* The time at which the topmost element on the timing stack was
|
||||||
|
pushed. Time elapsed since then is attributed to the topmost
|
||||||
|
element. */
|
||||||
|
static struct timevar_time_def start_time;
|
||||||
|
|
||||||
|
static void get_time
|
||||||
|
PARAMS ((struct timevar_time_def *));
|
||||||
|
static void timevar_accumulate
|
||||||
|
PARAMS ((struct timevar_time_def *, struct timevar_time_def *,
|
||||||
|
struct timevar_time_def *));
|
||||||
|
|
||||||
|
/* Fill the current times into TIME. The definition of this function
|
||||||
|
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
||||||
|
HAVE_WALL_TIME macros. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_time (now)
|
||||||
|
struct timevar_time_def *now;
|
||||||
|
{
|
||||||
|
now->user = 0;
|
||||||
|
now->sys = 0;
|
||||||
|
now->wall = 0;
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
{
|
||||||
|
#ifdef USE_TIMES
|
||||||
|
struct tms tms;
|
||||||
|
now->wall = times (&tms) * ticks_to_msec;
|
||||||
|
#if IN_GCC
|
||||||
|
now->user = tms.tms_utime * ticks_to_msec;
|
||||||
|
now->sys = tms.tms_stime * ticks_to_msec;
|
||||||
|
#else
|
||||||
|
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
|
||||||
|
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef USE_GETRUSAGE
|
||||||
|
struct rusage rusage;
|
||||||
|
#if IN_GCC
|
||||||
|
getrusage (RUSAGE_SELF, &rusage);
|
||||||
|
#else
|
||||||
|
getrusage (RUSAGE_CHILDREN, &rusage);
|
||||||
|
#endif
|
||||||
|
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||||
|
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_CLOCK
|
||||||
|
now->user = clock () * clocks_to_msec;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the difference between STOP and START to TIMER. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
timevar_accumulate (timer, start, stop)
|
||||||
|
struct timevar_time_def *timer;
|
||||||
|
struct timevar_time_def *start;
|
||||||
|
struct timevar_time_def *stop;
|
||||||
|
{
|
||||||
|
timer->user += stop->user - start->user;
|
||||||
|
timer->sys += stop->sys - start->sys;
|
||||||
|
timer->wall += stop->wall - start->wall;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize timing variables. */
|
||||||
|
|
||||||
|
void
|
||||||
|
init_timevar ()
|
||||||
|
{
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Zero all elapsed times. */
|
||||||
|
memset ((void *) timevars, 0, sizeof (timevars));
|
||||||
|
|
||||||
|
/* Initialize the names of timing variables. */
|
||||||
|
#define DEFTIMEVAR(identifier__, name__) \
|
||||||
|
timevars[identifier__].name = name__;
|
||||||
|
#include "timevar.def"
|
||||||
|
#undef DEFTIMEVAR
|
||||||
|
|
||||||
|
#ifdef USE_TIMES
|
||||||
|
ticks_to_msec = TICKS_TO_MSEC;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_CLOCK
|
||||||
|
clocks_to_msec = CLOCKS_TO_MSEC;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Push TIMEVAR onto the timing stack. No further elapsed time is
|
||||||
|
attributed to the previous topmost timing variable on the stack;
|
||||||
|
subsequent elapsed time is attributed to TIMEVAR, until it is
|
||||||
|
popped or another element is pushed on top.
|
||||||
|
|
||||||
|
TIMEVAR cannot be running as a standalone timer. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_push (timevar)
|
||||||
|
timevar_id_t timevar;
|
||||||
|
{
|
||||||
|
struct timevar_def *tv = &timevars[timevar];
|
||||||
|
struct timevar_stack_def *context;
|
||||||
|
struct timevar_time_def now;
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Mark this timing variable as used. */
|
||||||
|
tv->used = 1;
|
||||||
|
|
||||||
|
/* Can't push a standalone timer. */
|
||||||
|
if (tv->standalone)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
/* What time is it? */
|
||||||
|
get_time (&now);
|
||||||
|
|
||||||
|
/* If the stack isn't empty, attribute the current elapsed time to
|
||||||
|
the old topmost element. */
|
||||||
|
if (stack)
|
||||||
|
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||||
|
|
||||||
|
/* Reset the start time; from now on, time is attributed to
|
||||||
|
TIMEVAR. */
|
||||||
|
start_time = now;
|
||||||
|
|
||||||
|
/* See if we have a previously-allocated stack instance. If so,
|
||||||
|
take it off the list. If not, malloc a new one. */
|
||||||
|
if (unused_stack_instances != NULL)
|
||||||
|
{
|
||||||
|
context = unused_stack_instances;
|
||||||
|
unused_stack_instances = unused_stack_instances->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
context = (struct timevar_stack_def *)
|
||||||
|
xmalloc (sizeof (struct timevar_stack_def));
|
||||||
|
|
||||||
|
/* Fill it in and put it on the stack. */
|
||||||
|
context->timevar = tv;
|
||||||
|
context->next = stack;
|
||||||
|
stack = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pop the topmost timing variable element off the timing stack. The
|
||||||
|
popped variable must be TIMEVAR. Elapsed time since the that
|
||||||
|
element was pushed on, or since it was last exposed on top of the
|
||||||
|
stack when the element above it was popped off, is credited to that
|
||||||
|
timing variable. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_pop (timevar)
|
||||||
|
timevar_id_t timevar;
|
||||||
|
{
|
||||||
|
struct timevar_time_def now;
|
||||||
|
struct timevar_stack_def *popped = stack;
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (&timevars[timevar] != stack->timevar)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
/* What time is it? */
|
||||||
|
get_time (&now);
|
||||||
|
|
||||||
|
/* Attribute the elapsed time to the element we're popping. */
|
||||||
|
timevar_accumulate (&popped->timevar->elapsed, &start_time, &now);
|
||||||
|
|
||||||
|
/* Reset the start time; from now on, time is attributed to the
|
||||||
|
element just exposed on the stack. */
|
||||||
|
start_time = now;
|
||||||
|
|
||||||
|
/* Take the item off the stack. */
|
||||||
|
stack = stack->next;
|
||||||
|
|
||||||
|
/* Don't delete the stack element; instead, add it to the list of
|
||||||
|
unused elements for later use. */
|
||||||
|
popped->next = unused_stack_instances;
|
||||||
|
unused_stack_instances = popped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start timing TIMEVAR independently of the timing stack. Elapsed
|
||||||
|
time until timevar_stop is called for the same timing variable is
|
||||||
|
attributed to TIMEVAR. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_start (timevar)
|
||||||
|
timevar_id_t timevar;
|
||||||
|
{
|
||||||
|
struct timevar_def *tv = &timevars[timevar];
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Mark this timing variable as used. */
|
||||||
|
tv->used = 1;
|
||||||
|
|
||||||
|
/* Don't allow the same timing variable to be started more than
|
||||||
|
once. */
|
||||||
|
if (tv->standalone)
|
||||||
|
abort ();
|
||||||
|
tv->standalone = 1;
|
||||||
|
|
||||||
|
get_time (&tv->start_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stop timing TIMEVAR. Time elapsed since timevar_start was called
|
||||||
|
is attributed to it. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_stop (timevar)
|
||||||
|
timevar_id_t timevar;
|
||||||
|
{
|
||||||
|
struct timevar_def *tv = &timevars[timevar];
|
||||||
|
struct timevar_time_def now;
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* TIMEVAR must have been started via timevar_start. */
|
||||||
|
if (!tv->standalone)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
get_time (&now);
|
||||||
|
timevar_accumulate (&tv->elapsed, &tv->start_time, &now);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
|
||||||
|
update-to-date information even if TIMEVAR is currently running. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_get (timevar, elapsed)
|
||||||
|
timevar_id_t timevar;
|
||||||
|
struct timevar_time_def *elapsed;
|
||||||
|
{
|
||||||
|
struct timevar_def *tv = &timevars[timevar];
|
||||||
|
struct timevar_time_def now;
|
||||||
|
|
||||||
|
*elapsed = tv->elapsed;
|
||||||
|
|
||||||
|
/* Is TIMEVAR currently running as a standalone timer? */
|
||||||
|
if (tv->standalone)
|
||||||
|
{
|
||||||
|
get_time (&now);
|
||||||
|
timevar_accumulate (elapsed, &tv->start_time, &now);
|
||||||
|
}
|
||||||
|
/* Or is TIMEVAR at the top of the timer stack? */
|
||||||
|
else if (stack->timevar == tv)
|
||||||
|
{
|
||||||
|
get_time (&now);
|
||||||
|
timevar_accumulate (elapsed, &start_time, &now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Summarize timing variables to FP. The timing variable TV_TOTAL has
|
||||||
|
a special meaning -- it's considered to be the total elapsed time,
|
||||||
|
for normalizing the others, and is displayed last. */
|
||||||
|
|
||||||
|
void
|
||||||
|
timevar_print (fp)
|
||||||
|
FILE *fp;
|
||||||
|
{
|
||||||
|
/* Only print stuff if we have some sort of time information. */
|
||||||
|
#if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME)
|
||||||
|
unsigned int /* timevar_id_t */ id;
|
||||||
|
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
|
||||||
|
struct timevar_time_def now;
|
||||||
|
|
||||||
|
if (!TIMEVAR_ENABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Update timing information in case we're calling this from GDB. */
|
||||||
|
|
||||||
|
if (fp == 0)
|
||||||
|
fp = stderr;
|
||||||
|
|
||||||
|
/* What time is it? */
|
||||||
|
get_time (&now);
|
||||||
|
|
||||||
|
/* If the stack isn't empty, attribute the current elapsed time to
|
||||||
|
the old topmost element. */
|
||||||
|
if (stack)
|
||||||
|
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||||
|
|
||||||
|
/* Reset the start time; from now on, time is attributed to
|
||||||
|
TIMEVAR. */
|
||||||
|
start_time = now;
|
||||||
|
|
||||||
|
fputs (_("\nExecution times (seconds)\n"), fp);
|
||||||
|
for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id)
|
||||||
|
{
|
||||||
|
struct timevar_def *tv = &timevars[(timevar_id_t) id];
|
||||||
|
const float tiny = 5e-3;
|
||||||
|
|
||||||
|
/* Don't print the total execution time here; that goes at the
|
||||||
|
end. */
|
||||||
|
if ((timevar_id_t) id == TV_TOTAL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Don't print timing variables that were never used. */
|
||||||
|
if (!tv->used)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Don't print timing variables if we're going to get a row of
|
||||||
|
zeroes. */
|
||||||
|
if (tv->elapsed.user < tiny
|
||||||
|
&& tv->elapsed.sys < tiny
|
||||||
|
&& tv->elapsed.wall < tiny)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* The timing variable name. */
|
||||||
|
fprintf (fp, " %-22s:", tv->name);
|
||||||
|
|
||||||
|
#ifdef HAVE_USER_TIME
|
||||||
|
/* Print user-mode time for this process. */
|
||||||
|
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||||
|
tv->elapsed.user,
|
||||||
|
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||||
|
#endif /* HAVE_USER_TIME */
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIME
|
||||||
|
/* Print system-mode time for this process. */
|
||||||
|
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||||
|
tv->elapsed.sys,
|
||||||
|
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||||
|
#endif /* HAVE_SYS_TIME */
|
||||||
|
|
||||||
|
#ifdef HAVE_WALL_TIME
|
||||||
|
/* Print wall clock time elapsed. */
|
||||||
|
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||||
|
tv->elapsed.wall,
|
||||||
|
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||||
|
#endif /* HAVE_WALL_TIME */
|
||||||
|
|
||||||
|
putc ('\n', fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print total time. */
|
||||||
|
fputs (_(" TOTAL :"), fp);
|
||||||
|
#ifdef HAVE_USER_TIME
|
||||||
|
fprintf (fp, "%7.2f ", total->user);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TIME
|
||||||
|
fprintf (fp, "%7.2f ", total->sys);
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WALL_TIME
|
||||||
|
fprintf (fp, "%7.2f\n", total->wall);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
||||||
|
|| defined (HAVE_WALL_TIME) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns time (user + system) used so far by the compiler process,
|
||||||
|
in microseconds. */
|
||||||
|
|
||||||
|
long
|
||||||
|
get_run_time ()
|
||||||
|
{
|
||||||
|
struct timevar_time_def total_elapsed;
|
||||||
|
timevar_get (TV_TOTAL, &total_elapsed);
|
||||||
|
return total_elapsed.user + total_elapsed.sys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prints a message to stderr stating that time elapsed in STR is
|
||||||
|
TOTAL (given in microseconds). */
|
||||||
|
|
||||||
|
void
|
||||||
|
print_time (str, total)
|
||||||
|
const char *str;
|
||||||
|
long total;
|
||||||
|
{
|
||||||
|
long all_time = get_run_time ();
|
||||||
|
fprintf (stderr,
|
||||||
|
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||||
|
str, total / 1000000, total % 1000000,
|
||||||
|
all_time == 0 ? 0
|
||||||
|
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/* This file contains the definitions for timing variables used to -*- C -*-
|
||||||
|
measure run-time performance of the compiler.
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Akim Demaille <akim@freefriends.org>.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* This file contains timing variable definitions, used by timevar.h
|
||||||
|
and timevar.c.
|
||||||
|
|
||||||
|
Syntax:
|
||||||
|
|
||||||
|
DEFTIMEVAR (id, name)
|
||||||
|
|
||||||
|
where ID is the enumeral value used to identify the timing
|
||||||
|
variable, and NAME is a character string describing its purpose. */
|
||||||
|
|
||||||
|
/* The total execution time. */
|
||||||
|
DEFTIMEVAR (TV_TOTAL , "total time")
|
||||||
|
|
||||||
|
/* Time spent in the reader. */
|
||||||
|
DEFTIMEVAR (TV_READER , "reader")
|
||||||
|
DEFTIMEVAR (TV_SCANNING , "scanner")
|
||||||
|
DEFTIMEVAR (TV_PARSING , "parser")
|
||||||
|
|
||||||
|
/* Time spent handling the grammar. */
|
||||||
|
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
|
||||||
|
DEFTIMEVAR (TV_SETS , "computing the sets")
|
||||||
|
DEFTIMEVAR (TV_LR0 , "LR(0)")
|
||||||
|
DEFTIMEVAR (TV_LALR , "LALR(1)")
|
||||||
|
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
|
||||||
|
|
||||||
|
/* Time spent outputing results. */
|
||||||
|
DEFTIMEVAR (TV_REPORT , "outputing report")
|
||||||
|
DEFTIMEVAR (TV_GRAPH , "outputing graph")
|
||||||
|
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
|
||||||
|
DEFTIMEVAR (TV_PARSER , "outputing parser")
|
||||||
|
DEFTIMEVAR (TV_M4 , "running m4")
|
||||||
|
|
||||||
|
/* Time spent by freeing the memory :). */
|
||||||
|
DEFTIMEVAR (TV_FREE , "freeing")
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/* Timing variables for measuring compiler performance.
|
||||||
|
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
||||||
|
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to the Free
|
||||||
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef GCC_TIMEVAR_H
|
||||||
|
#define GCC_TIMEVAR_H
|
||||||
|
|
||||||
|
/* Timing variables are used to measure elapsed time in various
|
||||||
|
portions of the compiler. Each measures elapsed user, system, and
|
||||||
|
wall-clock time, as appropriate to and supported by the host
|
||||||
|
system.
|
||||||
|
|
||||||
|
Timing variables are defined using the DEFTIMEVAR macro in
|
||||||
|
timevar.def. Each has an enumeral identifier, used when referring
|
||||||
|
to the timing variable in code, and a character string name.
|
||||||
|
|
||||||
|
Timing variables can be used in two ways:
|
||||||
|
|
||||||
|
- On the timing stack, using timevar_push and timevar_pop.
|
||||||
|
Timing variables may be pushed onto the stack; elapsed time is
|
||||||
|
attributed to the topmost timing variable on the stack. When
|
||||||
|
another variable is pushed on, the previous topmost variable is
|
||||||
|
`paused' until the pushed variable is popped back off.
|
||||||
|
|
||||||
|
- As a standalone timer, using timevar_start and timevar_stop.
|
||||||
|
All time elapsed between the two calls is attributed to the
|
||||||
|
variable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This structure stores the various varieties of time that can be
|
||||||
|
measured. Times are stored in seconds. The time may be an
|
||||||
|
absolute time or a time difference; in the former case, the time
|
||||||
|
base is undefined, except that the difference between two times
|
||||||
|
produces a valid time difference. */
|
||||||
|
|
||||||
|
struct timevar_time_def
|
||||||
|
{
|
||||||
|
/* User time in this process. */
|
||||||
|
float user;
|
||||||
|
|
||||||
|
/* System time (if applicable for this host platform) in this
|
||||||
|
process. */
|
||||||
|
float sys;
|
||||||
|
|
||||||
|
/* Wall clock time. */
|
||||||
|
float wall;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* An enumeration of timing variable identifiers. Constructed from
|
||||||
|
the contents of timevar.def. */
|
||||||
|
|
||||||
|
#define DEFTIMEVAR(identifier__, name__) \
|
||||||
|
identifier__,
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
#include "timevar.def"
|
||||||
|
TIMEVAR_LAST
|
||||||
|
}
|
||||||
|
timevar_id_t;
|
||||||
|
#undef DEFTIMEVAR
|
||||||
|
|
||||||
|
extern void init_timevar PARAMS ((void));
|
||||||
|
extern void timevar_push PARAMS ((timevar_id_t));
|
||||||
|
extern void timevar_pop PARAMS ((timevar_id_t));
|
||||||
|
extern void timevar_start PARAMS ((timevar_id_t));
|
||||||
|
extern void timevar_stop PARAMS ((timevar_id_t));
|
||||||
|
extern void timevar_get PARAMS ((timevar_id_t, struct timevar_time_def *));
|
||||||
|
extern void timevar_print PARAMS ((FILE *));
|
||||||
|
|
||||||
|
/* Provided for backward compatibility. */
|
||||||
|
extern long get_run_time PARAMS ((void));
|
||||||
|
extern void print_time PARAMS ((const char *, long));
|
||||||
|
|
||||||
|
extern int timevar_report;
|
||||||
|
|
||||||
|
#endif /* ! GCC_TIMEVAR_H */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user