mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
961 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c98ea50c21 | ||
|
|
78697777d7 | ||
|
|
83696460f0 | ||
|
|
bb8acb3640 | ||
|
|
4f29f1aeb2 | ||
|
|
36a4ba8ba3 | ||
|
|
aaafa60129 | ||
|
|
866e778210 | ||
|
|
805484b693 | ||
|
|
a10e992cbc | ||
|
|
44b11d6e67 | ||
|
|
108f50670d | ||
|
|
5885cbf0d2 | ||
|
|
640cdd2df4 | ||
|
|
a4d13e4b8f | ||
|
|
12beb90e58 | ||
|
|
4623f5dca3 | ||
|
|
b124be4eb1 | ||
|
|
c8feafc2a5 | ||
|
|
84b6d13a3c | ||
|
|
fb604ebdf4 | ||
|
|
778dd49f55 | ||
|
|
3e0fdc1a0b | ||
|
|
c4610f8bb6 | ||
|
|
824081f660 | ||
|
|
417bda1b99 | ||
|
|
dbb6fa88fd | ||
|
|
013f2fe433 | ||
|
|
de75384c2b | ||
|
|
9d691ba42f | ||
|
|
744ef2d96f | ||
|
|
0d978396d7 | ||
|
|
581db2ffeb | ||
|
|
0d1de84756 | ||
|
|
c4f9b63aea | ||
|
|
0472107417 | ||
|
|
e1de1d3a93 | ||
|
|
46b486ab5b | ||
|
|
68bd38e8a0 | ||
|
|
b5c86e8130 | ||
|
|
bd54740062 | ||
|
|
8596e37d97 | ||
|
|
5eb689ade0 | ||
|
|
195f8a213e | ||
|
|
4d6b56a932 | ||
|
|
62a9c01c6d | ||
|
|
12dd329a29 | ||
|
|
4a7000742c | ||
|
|
f41e1ff806 | ||
|
|
fa5ef15197 | ||
|
|
2b1f600cbd | ||
|
|
0396e35b5a | ||
|
|
9824efff73 | ||
|
|
7fbe57368e | ||
|
|
21c0d8f1f0 | ||
|
|
316490baea | ||
|
|
bd77322580 | ||
|
|
09cf102456 | ||
|
|
f8514af7a6 | ||
|
|
6b4aadc588 | ||
|
|
e2e512d2d6 | ||
|
|
a7d29c59fa | ||
|
|
b2e339dc25 | ||
|
|
e7342330e5 | ||
|
|
3f868304cf | ||
|
|
2926167cfa | ||
|
|
84448306a4 | ||
|
|
b97436b18b | ||
|
|
db07df5448 | ||
|
|
4adeb81260 | ||
|
|
9684207d04 | ||
|
|
b467d6d513 | ||
|
|
36454232a5 | ||
|
|
ce85352146 | ||
|
|
7786c6e2cf | ||
|
|
4bd1ffa49a | ||
|
|
38762b8f78 | ||
|
|
7b2cea5ab2 | ||
|
|
b0d3bfa316 | ||
|
|
1672bf6d27 | ||
|
|
8736952b0b | ||
|
|
bd1fc1c256 | ||
|
|
bb4d193ac7 | ||
|
|
7379bd7274 | ||
|
|
1372968ab0 | ||
|
|
d2b4bca42e | ||
|
|
6dceaa1d9d | ||
|
|
b288652bbd | ||
|
|
2b37242292 | ||
|
|
afd2d8e4cf | ||
|
|
c18996947c | ||
|
|
23b80c8e30 | ||
|
|
3b92bd0090 | ||
|
|
14bc2891a8 | ||
|
|
1ebe204c2f | ||
|
|
27725d0745 | ||
|
|
8977920253 | ||
|
|
41b9ee8834 | ||
|
|
c4d50b0133 | ||
|
|
bb389bead8 | ||
|
|
326cc336af | ||
|
|
cd53ea93c5 | ||
|
|
aec69ce220 | ||
|
|
b2d08f91db | ||
|
|
50cdbb37c8 | ||
|
|
e81d02baf1 | ||
|
|
b73817cc6e | ||
|
|
0fefdeb526 | ||
|
|
8dfac9573a | ||
|
|
369361ae70 | ||
|
|
1afd3473fb | ||
|
|
117fb47f99 | ||
|
|
1bff89846b | ||
|
|
ba87d08c0e | ||
|
|
d9c0413f79 | ||
|
|
216777ea17 | ||
|
|
325411e109 | ||
|
|
e5aecd47c4 | ||
|
|
c84a7a232e | ||
|
|
16c5d19ce5 | ||
|
|
ac96f15bf3 | ||
|
|
0c0537fdce | ||
|
|
f58702e8f9 | ||
|
|
80c03e37ba | ||
|
|
71e65bb036 | ||
|
|
522141076e | ||
|
|
408a47499e | ||
|
|
30a65b1aa3 | ||
|
|
0a3fdd250a | ||
|
|
b617aa5f3f | ||
|
|
8b0cf1dde4 | ||
|
|
d392de74de | ||
|
|
e5b4feb70a | ||
|
|
af41baeb91 | ||
|
|
5540d977f4 | ||
|
|
98b663a29b | ||
|
|
e3c3d0b385 | ||
|
|
cfda609a21 | ||
|
|
229598b807 | ||
|
|
4c6221ee37 | ||
|
|
d76f7a7ce4 | ||
|
|
fc05e28803 | ||
|
|
0bbec4b26e | ||
|
|
93cff2fae1 | ||
|
|
ec0f2c34d3 | ||
|
|
e26d180b8c | ||
|
|
cb0cd6afdb | ||
|
|
b95e3d2f47 | ||
|
|
b5eadff384 | ||
|
|
a0321a68c0 | ||
|
|
9ed0e96ba7 | ||
|
|
087f809fe7 | ||
|
|
dd6c617d24 | ||
|
|
b4e8fc709e | ||
|
|
487366d091 | ||
|
|
6099222717 | ||
|
|
608e780536 | ||
|
|
0f73666749 | ||
|
|
e72e877181 | ||
|
|
4063f0aea3 | ||
|
|
0c8d33de03 | ||
|
|
e94070eb22 | ||
|
|
8aef0cde12 | ||
|
|
d355dcec62 | ||
|
|
c0a9e11235 | ||
|
|
8469bec1cc | ||
|
|
28a71c3409 | ||
|
|
85c407a740 | ||
|
|
2a01f209a6 | ||
|
|
1137a26bcf | ||
|
|
8157b18b8a | ||
|
|
c8c25a4610 | ||
|
|
031e782bb9 | ||
|
|
289ee58ce3 | ||
|
|
53af79cfe4 | ||
|
|
57beda9b45 | ||
|
|
0f3ff1725d | ||
|
|
7188179fc0 | ||
|
|
6544a589ed | ||
|
|
79ae2a4af9 | ||
|
|
b952290dc3 | ||
|
|
737f1f03a5 | ||
|
|
cf83dc5456 | ||
|
|
652ad8aaa3 | ||
|
|
5e969c1033 | ||
|
|
e42cc5be8a | ||
|
|
8cb05a6bfa | ||
|
|
4fb75ded4c | ||
|
|
1c883e2882 | ||
|
|
d6bf80ccc7 | ||
|
|
cd536776a0 | ||
|
|
f51eb4a5cc | ||
|
|
de40301f0a | ||
|
|
aa41cdbb65 | ||
|
|
4d02bdd9b0 | ||
|
|
41e8b21fb7 | ||
|
|
fe9da7ee9b | ||
|
|
bd8218fbe9 | ||
|
|
d52bc68220 | ||
|
|
090cd9f443 | ||
|
|
b6c83bbaa0 | ||
|
|
5946c46972 | ||
|
|
20522f2f5d | ||
|
|
7b297f76c4 | ||
|
|
3c467c0d22 | ||
|
|
b2ae052c6d | ||
|
|
8ee7e2c0c8 | ||
|
|
3270b340e8 | ||
|
|
22978078f7 | ||
|
|
53e41464fd | ||
|
|
86f7daf592 | ||
|
|
91e12f541f | ||
|
|
176a02c5d9 | ||
|
|
c6836cfdda | ||
|
|
090a56eb9c | ||
|
|
8c0d3621b3 | ||
|
|
86d6d4c47c | ||
|
|
f1d4b41340 | ||
|
|
ab8cec12c9 | ||
|
|
3bd31fac90 | ||
|
|
31f9f9f24c | ||
|
|
e7b4a0bced | ||
|
|
a3b44d2fd5 | ||
|
|
55dcae1c8d | ||
|
|
a01eaef0fd | ||
|
|
9da759a317 | ||
|
|
d2d2d043ff | ||
|
|
afd4dcf3b2 | ||
|
|
9b7bbe7b0b | ||
|
|
d84462d473 | ||
|
|
e3579cb231 | ||
|
|
1a34934e94 | ||
|
|
c2705c1e62 | ||
|
|
63d49273c4 | ||
|
|
2df44bba5b | ||
|
|
4b17c0b9ac | ||
|
|
71d6f09173 | ||
|
|
5faf3cd5fb | ||
|
|
b4a30ded4c | ||
|
|
e1dc14d3a1 | ||
|
|
4c8f853735 | ||
|
|
6225a43223 | ||
|
|
abda80a05a | ||
|
|
6ab8d020db | ||
|
|
5daa998b30 | ||
|
|
5840eaec8d | ||
|
|
4a6d0824c9 | ||
|
|
166523ca2b | ||
|
|
04a5f54547 | ||
|
|
8f47502291 | ||
|
|
fb71b69665 | ||
|
|
f8a5744b34 | ||
|
|
e3fa3463d6 | ||
|
|
a712177a4b | ||
|
|
b9ad7b9a9c | ||
|
|
47e20014b0 | ||
|
|
2f4e768ff4 | ||
|
|
f1aea23023 | ||
|
|
4734b96d4e | ||
|
|
faf0038376 | ||
|
|
dd7aea80f7 | ||
|
|
4ff1b892d0 | ||
|
|
22125a047d | ||
|
|
b2191ea8e1 | ||
|
|
971c5b1379 | ||
|
|
2d8de9b8ab | ||
|
|
271a7e6bb3 | ||
|
|
573c16a666 | ||
|
|
bae16cb45b | ||
|
|
b80225264a | ||
|
|
dcc145f13a | ||
|
|
51958e82aa | ||
|
|
ca0a087f3d | ||
|
|
22dc22c127 | ||
|
|
a56783bbb4 | ||
|
|
699808bcad | ||
|
|
7176037aa2 | ||
|
|
55447abbdf | ||
|
|
2c226bf49d | ||
|
|
8a623ebc61 | ||
|
|
fce70ef38b | ||
|
|
9622bd6207 | ||
|
|
f177941b93 | ||
|
|
a2c6905133 | ||
|
|
3df9acbfc9 | ||
|
|
9f58b3b3d5 | ||
|
|
e6b5a4d682 | ||
|
|
1fb27efd70 | ||
|
|
d4a3e63ec8 | ||
|
|
f64964aa1d | ||
|
|
97775c5655 | ||
|
|
483e2421c9 | ||
|
|
ac4a274dcf | ||
|
|
8b3d87d197 | ||
|
|
bee873f407 | ||
|
|
7b33a9910c | ||
|
|
d60264342d | ||
|
|
3cd2c9e1c8 | ||
|
|
c94ffee869 | ||
|
|
7da69e79df | ||
|
|
a79461545e | ||
|
|
32e36bd888 | ||
|
|
15e49fdbfb | ||
|
|
1b0419e8fd | ||
|
|
bd395b3bfc | ||
|
|
b7c1e2526a | ||
|
|
9300fb41f8 | ||
|
|
c434fa5195 | ||
|
|
7f504f2317 | ||
|
|
cafa5c1c2d | ||
|
|
73a90d1006 | ||
|
|
d4e2205ea9 | ||
|
|
8e9d1adf75 | ||
|
|
2f6c94da4c | ||
|
|
68898bb9a7 | ||
|
|
812fdadfca | ||
|
|
0e307a526c | ||
|
|
c1997cb5c3 | ||
|
|
74445dae42 | ||
|
|
fcf3192814 | ||
|
|
916861c0e8 | ||
|
|
437e9a0bc4 | ||
|
|
389c4049b3 | ||
|
|
a9ec4db8f2 | ||
|
|
9cda4e6527 | ||
|
|
cf1bd0e401 | ||
|
|
419daeb511 | ||
|
|
5555b3c9db | ||
|
|
482d5be531 | ||
|
|
87afdbeb7d | ||
|
|
a84f4f6087 | ||
|
|
12da649245 | ||
|
|
22aec49d4c | ||
|
|
6580f24783 | ||
|
|
a3c143bd82 | ||
|
|
07e148c8e7 | ||
|
|
8455ea2e13 | ||
|
|
95439d0f33 | ||
|
|
aa7d0d8c85 | ||
|
|
3ce3cb772d | ||
|
|
e08a28e045 | ||
|
|
6ea9602009 | ||
|
|
ea11fd8868 | ||
|
|
346b0368cf | ||
|
|
175585876f | ||
|
|
1ecd1b9c52 | ||
|
|
30f76e827e | ||
|
|
8b9e784e1e | ||
|
|
5a5938db82 | ||
|
|
3c57cea2ce | ||
|
|
0143b2901f | ||
|
|
527b07a1ad | ||
|
|
347c2d6d30 | ||
|
|
9af8f15624 | ||
|
|
c17caa0c0f | ||
|
|
77da45645d | ||
|
|
8b2c88998b | ||
|
|
4cf126f7ce | ||
|
|
1c4ecd2a95 | ||
|
|
56d10407e7 | ||
|
|
f3194fe603 | ||
|
|
f59d1dac46 | ||
|
|
359f885aae | ||
|
|
272f8d891e | ||
|
|
25f22cdc5d | ||
|
|
af781b708c | ||
|
|
0a9eb68f77 | ||
|
|
59d334f4d4 | ||
|
|
e6eece1575 | ||
|
|
8fbeb80792 | ||
|
|
dc98736719 | ||
|
|
3f4c6398be | ||
|
|
7e4384f810 | ||
|
|
fdd4dd9b35 | ||
|
|
bba8ab25f1 | ||
|
|
aa05c43a5f | ||
|
|
69e6145e1e | ||
|
|
fb19d01b96 | ||
|
|
b380f45a13 | ||
|
|
8e12bada8a | ||
|
|
ade410fae0 | ||
|
|
6d668c6160 | ||
|
|
78273e9d23 | ||
|
|
2b5207bc59 | ||
|
|
deeb3e0c49 | ||
|
|
2b00449aa7 | ||
|
|
98d8740ccd | ||
|
|
56bc01ab4a | ||
|
|
1d43796211 | ||
|
|
e8a641509f | ||
|
|
674180c97f | ||
|
|
c264e159a4 | ||
|
|
a5a67731da | ||
|
|
d7bf7dee47 | ||
|
|
3032beba73 | ||
|
|
50b029f4d9 | ||
|
|
c07d15973c | ||
|
|
5beebbd8da | ||
|
|
763d748cf2 | ||
|
|
0e442c97a5 | ||
|
|
2411847f16 | ||
|
|
874f418e03 | ||
|
|
0126f74936 | ||
|
|
7d956ece8c | ||
|
|
ee708ff4aa | ||
|
|
c1f1f8ac3a | ||
|
|
0aa556c39c | ||
|
|
b76ab178d1 | ||
|
|
dfbe6788b4 | ||
|
|
1d2c0959c9 | ||
|
|
fc0f5b4539 | ||
|
|
49af3f858e | ||
|
|
0528939c0a | ||
|
|
a2d90c1616 | ||
|
|
5ac0cdbfce | ||
|
|
b8654f033b | ||
|
|
f60c8ea48b | ||
|
|
dafd2cb4e2 | ||
|
|
f970591c5a | ||
|
|
d729e4cab7 | ||
|
|
cccb23f01b | ||
|
|
199923e3cc | ||
|
|
706389d9df | ||
|
|
bba21e6815 | ||
|
|
0f459ed24c | ||
|
|
c1a0ddea63 | ||
|
|
337e927dae | ||
|
|
d8ab22727f | ||
|
|
505b859fe9 | ||
|
|
e6cfa98486 | ||
|
|
93bd527109 | ||
|
|
d283aef5ca | ||
|
|
be333ac3a5 | ||
|
|
62b978f77c | ||
|
|
84e64a529a | ||
|
|
b4a20010e6 | ||
|
|
b8b9306a9a | ||
|
|
5ec32b62e5 | ||
|
|
c659704b20 | ||
|
|
ce339a4a50 | ||
|
|
53ff5566ce | ||
|
|
c1bf67ee67 | ||
|
|
5dbe03ea6c | ||
|
|
a2b6134e37 | ||
|
|
d82c2c9274 | ||
|
|
cc6711057e | ||
|
|
c60619245a | ||
|
|
a7b3ea4189 | ||
|
|
7057c83fd4 | ||
|
|
737ea4d4f9 | ||
|
|
ac22df9290 | ||
|
|
a33c222135 | ||
|
|
f6d1e06932 | ||
|
|
447a13cdd4 | ||
|
|
727a9ed970 | ||
|
|
5d5979d9a8 | ||
|
|
5eb19629b0 | ||
|
|
cbfdc4fd51 | ||
|
|
24c0303794 | ||
|
|
d9422a21e0 | ||
|
|
4be30f34c2 | ||
|
|
4da76e0c6f | ||
|
|
39c92b4dc4 | ||
|
|
c74a04a26f | ||
|
|
aedf3f9fc5 | ||
|
|
7e76b8b7da | ||
|
|
d9fe359377 | ||
|
|
c32c5775be | ||
|
|
3220407d48 | ||
|
|
45c51b256a | ||
|
|
c1505fc01f | ||
|
|
cca1377d96 | ||
|
|
8024d6459c | ||
|
|
78732c5421 | ||
|
|
0e199278c1 | ||
|
|
9d22ab92f9 | ||
|
|
8a6f26dfd6 | ||
|
|
43b84ec02e | ||
|
|
dadd9cf997 | ||
|
|
dacd5d7572 | ||
|
|
a8b09f0b0a | ||
|
|
7670167015 | ||
|
|
7f00439ebe | ||
|
|
a6263137d7 | ||
|
|
efb6a6917b | ||
|
|
987f70fee5 | ||
|
|
42a0e84308 | ||
|
|
564707901d | ||
|
|
70a316cc3d | ||
|
|
7ef62e1fda | ||
|
|
118e780f0d | ||
|
|
3c5b5b8b03 | ||
|
|
0a6412bea9 | ||
|
|
4a8b8d5f68 | ||
|
|
e00bceb7f2 | ||
|
|
58dce30461 | ||
|
|
3583bcd14d | ||
|
|
3191649a85 | ||
|
|
4325d27ddd | ||
|
|
834a0cf023 | ||
|
|
778abcac1e | ||
|
|
741c894274 | ||
|
|
651e543fd6 | ||
|
|
ae56578d18 | ||
|
|
74ca57dfe8 | ||
|
|
91aab55475 | ||
|
|
fa9c4632bb | ||
|
|
3d1c60aba7 | ||
|
|
399abab9bc | ||
|
|
908040f25e | ||
|
|
ac906fde2f | ||
|
|
57dcd53d86 | ||
|
|
45479ef311 | ||
|
|
21fb4595e6 | ||
|
|
43c812bc6a | ||
|
|
86110845b2 | ||
|
|
f9045181fd | ||
|
|
850ad58630 | ||
|
|
a95c870766 | ||
|
|
56d806cf6f | ||
|
|
c2efd628df | ||
|
|
5eceb4fed1 | ||
|
|
38457c3dac | ||
|
|
fee163dd57 | ||
|
|
f954f74302 | ||
|
|
0271d97259 | ||
|
|
9cb8617078 | ||
|
|
7c5f9f7faa | ||
|
|
053855b040 | ||
|
|
a5b5719d3b | ||
|
|
01b69091e2 | ||
|
|
d30fa5d58e | ||
|
|
b54cd94fe7 | ||
|
|
5de0b392f2 | ||
|
|
3613700a38 | ||
|
|
318a497768 | ||
|
|
7b428cdeda | ||
|
|
b28595b502 | ||
|
|
f9714aa24d | ||
|
|
a9ff449aa6 | ||
|
|
236c02759b | ||
|
|
777948e773 | ||
|
|
6e45576dd6 | ||
|
|
2bc35b0348 | ||
|
|
818d29db9b | ||
|
|
47f70113d4 | ||
|
|
2fa0c16e5e | ||
|
|
8060afb088 | ||
|
|
a1bc39d130 | ||
|
|
e6fae6c23f | ||
|
|
adb160df0f | ||
|
|
74a776f9ae | ||
|
|
12ea18c68d | ||
|
|
f870ecb4a6 | ||
|
|
6d6bfafbdd | ||
|
|
7178674807 | ||
|
|
1954f681c6 | ||
|
|
bb6a548712 | ||
|
|
403816eb85 | ||
|
|
adb7c216b2 | ||
|
|
92d78458e0 | ||
|
|
dd5db06467 | ||
|
|
b13e6b03cc | ||
|
|
a2b8387b70 | ||
|
|
4229a555fc | ||
|
|
688833b80e | ||
|
|
ca0246a4c1 | ||
|
|
c1cdafa1b4 | ||
|
|
ed960988ee | ||
|
|
3ee97d4d5b | ||
|
|
b34f300eaf | ||
|
|
2e5cc5e04e | ||
|
|
182c784a99 | ||
|
|
b14b621029 | ||
|
|
8825dba4e7 | ||
|
|
9922b56ffb | ||
|
|
6681674e3c | ||
|
|
99f35e8204 | ||
|
|
c46f149efd | ||
|
|
644d185dea | ||
|
|
6fc4ae7a28 | ||
|
|
3f92a4421a | ||
|
|
7a4a5dd66c | ||
|
|
fe456215a6 | ||
|
|
65957278ab | ||
|
|
6f2e1d1ce2 | ||
|
|
51078dff7f | ||
|
|
03824c9e29 | ||
|
|
10c96c43ac | ||
|
|
8e8fd5439a | ||
|
|
d3bcbd9968 | ||
|
|
6526b37460 | ||
|
|
9379b5aed5 | ||
|
|
f2794b3c5d | ||
|
|
f090816a3f | ||
|
|
d385bbc985 | ||
|
|
715765a548 | ||
|
|
de0fdbb080 | ||
|
|
e6800f5073 | ||
|
|
e1ff4d762b | ||
|
|
ffccedee33 | ||
|
|
8ddd60a387 | ||
|
|
eaf359df0c | ||
|
|
ff6400a018 | ||
|
|
a74458a36e | ||
|
|
e6c847ea05 | ||
|
|
c7d28e2bd8 | ||
|
|
898f3e5757 | ||
|
|
c239e82816 | ||
|
|
aaa9cb7c22 | ||
|
|
73d802bead | ||
|
|
29b0ceae9f | ||
|
|
b21af8a7dd | ||
|
|
7a888be2e5 | ||
|
|
815b5ca1d5 | ||
|
|
76118226b6 | ||
|
|
091c054eed | ||
|
|
3d2a9041f9 | ||
|
|
aeb85812a1 | ||
|
|
3a3b589b06 | ||
|
|
20c8b4db54 | ||
|
|
c44dd6ddad | ||
|
|
446976666c | ||
|
|
c997ad6f05 | ||
|
|
27a6efc25b | ||
|
|
557514f55c | ||
|
|
5ba09e9ace | ||
|
|
60ae95f973 | ||
|
|
9a181424ac | ||
|
|
4e3478c9d6 | ||
|
|
3803547285 | ||
|
|
cbdd4ce994 | ||
|
|
3749705b11 | ||
|
|
c940655b0f | ||
|
|
db18c4898e | ||
|
|
5d78a2a235 | ||
|
|
268ddc7d50 | ||
|
|
dee715bb6f | ||
|
|
edac0ff420 | ||
|
|
3f10c64fca | ||
|
|
d706ee318c | ||
|
|
a4d2c17357 | ||
|
|
6f37efd8b2 | ||
|
|
746c5e5528 | ||
|
|
6ff9e537fe | ||
|
|
b12057e3bd | ||
|
|
34e1cf8304 | ||
|
|
178d3b59d5 | ||
|
|
ce4e2493ee | ||
|
|
85f9983c19 | ||
|
|
9cb56e2980 | ||
|
|
c5134a9b13 | ||
|
|
475d6600c1 | ||
|
|
3dbdcab168 | ||
|
|
756fe67e60 | ||
|
|
23d07a32b2 | ||
|
|
9f82a64eb6 | ||
|
|
79b86f69e6 | ||
|
|
4d81490eb3 | ||
|
|
28a24ea3be | ||
|
|
6a4e9d5422 | ||
|
|
777d5f0ba8 | ||
|
|
9e7cf8346d | ||
|
|
1f37d82ce4 | ||
|
|
baf2a7b0fe | ||
|
|
73d5e9c5dd | ||
|
|
daf7870cb0 | ||
|
|
796e41bedf | ||
|
|
816194943b | ||
|
|
2eabfeeea8 | ||
|
|
5715c04ceb | ||
|
|
dd05029135 | ||
|
|
78362fb43a | ||
|
|
1723365c85 | ||
|
|
7e9524d7b9 | ||
|
|
c4b593538b | ||
|
|
0b2ebf9875 | ||
|
|
aa35ed104c | ||
|
|
737a7a7116 | ||
|
|
4634a5c628 | ||
|
|
c33725a845 | ||
|
|
e70623f196 | ||
|
|
862593b1f7 | ||
|
|
215318944a | ||
|
|
58e02de834 | ||
|
|
e02a4a825a | ||
|
|
73c74c0303 | ||
|
|
2d882a7200 | ||
|
|
d2a3720ad0 | ||
|
|
e6777f1523 | ||
|
|
41d5fb8189 | ||
|
|
3480c29030 | ||
|
|
a5c268a9f9 | ||
|
|
4f3121b654 | ||
|
|
73b2951ffe | ||
|
|
46505987ea | ||
|
|
bf58f8aea9 | ||
|
|
6c52fbcdfd | ||
|
|
e76eb59d84 | ||
|
|
5b093c28e1 | ||
|
|
9d3b949aa6 | ||
|
|
a468d7579f | ||
|
|
4eb32cb4f2 | ||
|
|
8f08533808 | ||
|
|
3b69e6514c | ||
|
|
9018ec3d41 | ||
|
|
5d16193294 | ||
|
|
61b305d30d | ||
|
|
efc9004234 | ||
|
|
ba733f2d38 | ||
|
|
34a122edc8 | ||
|
|
a5afd877aa | ||
|
|
1289479fce | ||
|
|
7bfb13dea7 | ||
|
|
744d31d57a | ||
|
|
a58305d61e | ||
|
|
3bd2561144 | ||
|
|
156a61c86d | ||
|
|
5850877aea | ||
|
|
847dcc878b | ||
|
|
84791e75cc | ||
|
|
e30230223c | ||
|
|
884e63790c | ||
|
|
a0b8bf89d3 | ||
|
|
c3e64b1b2d | ||
|
|
2131b2e9d5 | ||
|
|
6981af01ee | ||
|
|
863c253425 | ||
|
|
08d800d44e | ||
|
|
e23e3f656a | ||
|
|
4ad4b8aaec | ||
|
|
0f32a82524 | ||
|
|
2a0d3143dd | ||
|
|
6e867c19c9 | ||
|
|
c78152220a | ||
|
|
be2519d4dd | ||
|
|
9800c1597f | ||
|
|
2bf12371d8 | ||
|
|
7243acff2a | ||
|
|
bfa30819b9 | ||
|
|
ac5e053d8f | ||
|
|
13751495a1 | ||
|
|
1d2f218bff | ||
|
|
00b953713e | ||
|
|
ed4a024430 | ||
|
|
53398947a1 | ||
|
|
5e14cce7ae | ||
|
|
27276e481d | ||
|
|
7949927db6 | ||
|
|
634853cee6 | ||
|
|
0f100b0d3f | ||
|
|
83adf65c37 | ||
|
|
67b467223a | ||
|
|
2e6b75c735 | ||
|
|
0ec5eacc92 | ||
|
|
b024130dc2 | ||
|
|
aff66fa170 | ||
|
|
92e8245d90 | ||
|
|
c300ac7a4d | ||
|
|
67b836ed72 | ||
|
|
388569f846 | ||
|
|
981d081027 | ||
|
|
6a7bd50a0b | ||
|
|
f280d719f3 | ||
|
|
1d39399861 | ||
|
|
008d74220b | ||
|
|
0f0189167b | ||
|
|
bf6bcd3c16 | ||
|
|
b439039b9b | ||
|
|
2cada8c970 | ||
|
|
360b2870d8 | ||
|
|
b669dbd1ad | ||
|
|
b81692a8a9 | ||
|
|
dfa0cede72 | ||
|
|
add1d7c11f | ||
|
|
221ef68cc3 | ||
|
|
a7190a7381 | ||
|
|
f721ed2bf4 | ||
|
|
6dde9c58fe | ||
|
|
f1a5372cbc | ||
|
|
c22b040b21 | ||
|
|
0c5abc43a0 | ||
|
|
d5f4d5f22e | ||
|
|
2a5c6dea54 | ||
|
|
05d30f2715 | ||
|
|
c8d085374c | ||
|
|
9ceb93e7ff | ||
|
|
b808e70940 | ||
|
|
654ad9e596 | ||
|
|
8cff7ef2b9 | ||
|
|
137cf55755 | ||
|
|
ddc22e05ab | ||
|
|
42fcbf3950 | ||
|
|
11f5ed65ba | ||
|
|
99cf57df5f | ||
|
|
b71a140977 | ||
|
|
e49897affc | ||
|
|
2ef6cb6073 | ||
|
|
4db03fe797 | ||
|
|
8506a6bc2a | ||
|
|
8303c90f14 | ||
|
|
a530d04879 | ||
|
|
4a99368c87 | ||
|
|
46faa9979f | ||
|
|
c038102c6a | ||
|
|
23cfe44342 | ||
|
|
b3d7a51157 | ||
|
|
23f91764bc | ||
|
|
2ab1921d24 | ||
|
|
1c2d713cab | ||
|
|
395224e372 | ||
|
|
43cdd09d2d | ||
|
|
de6c7a9b78 | ||
|
|
7d7530446c | ||
|
|
208fa17ad0 | ||
|
|
5a1b7d267a | ||
|
|
1bcceb8ba4 | ||
|
|
e0bcf6c00d | ||
|
|
0a5f63aee2 | ||
|
|
2008517b36 | ||
|
|
517bef6ccd | ||
|
|
e2db29a312 | ||
|
|
a3fa97f5e3 | ||
|
|
7fc45bccbd | ||
|
|
7d3a280b7a | ||
|
|
be60b8e319 | ||
|
|
4090d52520 | ||
|
|
1f88c647cd | ||
|
|
08b596b409 | ||
|
|
e625640bd0 | ||
|
|
a6a2dbc63c | ||
|
|
5c3c1931dd | ||
|
|
d75c1aaea1 | ||
|
|
f1a905664b | ||
|
|
5cf455d736 | ||
|
|
8ef322d66f | ||
|
|
1d5b09348e | ||
|
|
5782ca8976 | ||
|
|
623ce837c7 | ||
|
|
73f21f7813 | ||
|
|
a8377ab773 | ||
|
|
5106e930d1 | ||
|
|
74b4707ea6 | ||
|
|
99b8fcfb0d | ||
|
|
5df13c9b0a | ||
|
|
5eeef11a3b | ||
|
|
cfbca54a71 | ||
|
|
f0f6a9c44e | ||
|
|
cc1a9180a7 | ||
|
|
155639bf0f | ||
|
|
c0f51577fd | ||
|
|
efac765819 | ||
|
|
1c7a2ac60f | ||
|
|
f4b094e098 | ||
|
|
e984b74461 | ||
|
|
c1e61448b3 | ||
|
|
2f077ef41f | ||
|
|
cfc48b6ee9 | ||
|
|
073c4cb543 | ||
|
|
8bacb0720c | ||
|
|
da8c36f53f | ||
|
|
83cf5efca9 | ||
|
|
4d9669b8d9 | ||
|
|
18573f3eb2 | ||
|
|
57ec0f45c9 | ||
|
|
a7830ac93b | ||
|
|
488bd9911e | ||
|
|
7956c15081 | ||
|
|
0402200daf | ||
|
|
dc0708fa82 | ||
|
|
7b9ad5a22f | ||
|
|
c4e9f56745 | ||
|
|
b69a467146 | ||
|
|
75cce0c815 | ||
|
|
546754d2e9 | ||
|
|
e8f8b7a82d | ||
|
|
c54a604289 | ||
|
|
f52e14c576 | ||
|
|
a0aef26c06 | ||
|
|
4d4a6210f7 | ||
|
|
a5ad9a2579 | ||
|
|
79d6ddd36a | ||
|
|
18da62e303 | ||
|
|
77469b714b | ||
|
|
1fbac54162 | ||
|
|
cf14c509f3 | ||
|
|
02bde8d334 | ||
|
|
e99f534046 | ||
|
|
aeac9910cb | ||
|
|
f84513b43e | ||
|
|
34fc818d7e | ||
|
|
f1e1eb58be | ||
|
|
3d6c17e94f | ||
|
|
ef3e297950 | ||
|
|
5cf3719e7b | ||
|
|
b36e366ef4 | ||
|
|
c2b86aabe0 | ||
|
|
849a1c46cf | ||
|
|
7c863aef95 | ||
|
|
cc7705fe6f | ||
|
|
e97b60d16a | ||
|
|
1b1382a3a9 | ||
|
|
ff0e048521 | ||
|
|
0af7afd19f | ||
|
|
24aec7f87f | ||
|
|
acb7c4ee48 | ||
|
|
5796c221a1 | ||
|
|
dde28b7ffe | ||
|
|
dfa21e5966 | ||
|
|
8014db4d68 | ||
|
|
c6394074a8 | ||
|
|
83ce0dcba6 | ||
|
|
9a69ea769a | ||
|
|
3044600151 | ||
|
|
da6d91f64b | ||
|
|
c6ca8a1528 | ||
|
|
8108bc26d6 | ||
|
|
908b4d6cb9 | ||
|
|
0683df4bf8 | ||
|
|
05907fc584 | ||
|
|
ca56751421 | ||
|
|
dd084ce340 | ||
|
|
92278a462b | ||
|
|
ca56be1e3e | ||
|
|
09f8e7fb03 | ||
|
|
c2e9e7a31b | ||
|
|
49f397e6e7 | ||
|
|
6161f25abc | ||
|
|
0898b54377 | ||
|
|
6f1c4b7a75 | ||
|
|
b7b00aad08 | ||
|
|
ec2a94a410 | ||
|
|
4796ddfe36 | ||
|
|
31856b16c3 | ||
|
|
6732422b97 | ||
|
|
2b3ce6fab9 | ||
|
|
b951477c80 | ||
|
|
0bf332a016 | ||
|
|
3e12088cf0 | ||
|
|
c0d94c89ec | ||
|
|
dd3a088973 | ||
|
|
5c15113c49 | ||
|
|
553eb65acd | ||
|
|
0c43179cf9 | ||
|
|
b031f89b29 | ||
|
|
b7df779b8b | ||
|
|
96ed803f48 | ||
|
|
fd798dd6fe | ||
|
|
dd8b68966f | ||
|
|
72ce8c67c5 | ||
|
|
22132a47aa | ||
|
|
0705aa7388 | ||
|
|
762769cf3b | ||
|
|
82eae6c9b5 | ||
|
|
86f04e3bb3 | ||
|
|
ce5f4177bc | ||
|
|
48f3bca87e | ||
|
|
adf0ec7008 | ||
|
|
5b4dde5a7b | ||
|
|
2224409994 | ||
|
|
30d11429a9 |
222
ABOUT-NLS
Normal file
222
ABOUT-NLS
Normal file
@@ -0,0 +1,222 @@
|
||||
Notes on the GNU Translation Project
|
||||
************************************
|
||||
|
||||
GNU is going international! The GNU Translation Project is a way to
|
||||
get maintainers, translators, and users all together, so that GNU will
|
||||
gradually become able to speak many languages. A few packages already
|
||||
provide translations for their messages.
|
||||
|
||||
If you found this `ABOUT-NLS' file inside a GNU distribution, you
|
||||
may assume that the distributed package does use GNU `gettext'
|
||||
internally, itself available at your nearest GNU archive site. But you
|
||||
do *not* need to install GNU `gettext' prior to configuring, installing
|
||||
or using this package with messages translated.
|
||||
|
||||
Installers will find here some useful hints. These notes also
|
||||
explain how users should proceed for getting the programs to use the
|
||||
available translations. They tell how people wanting to contribute and
|
||||
work at translations should contact the appropriate team.
|
||||
|
||||
When reporting bugs in the `intl/' directory or bugs which may be
|
||||
related to internationalization, you should tell about the version of
|
||||
`gettext' which is used. The information can be found in the
|
||||
`intl/VERSION' file, in internationalized packages.
|
||||
|
||||
One advise in advance
|
||||
=====================
|
||||
|
||||
If you want to exploit the full power of internationalization, you
|
||||
should configure it using
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to force usage of internationalizing routines provided within this
|
||||
package, despite the existence of internationalizing capabilities in
|
||||
the operating system where this package is being installed. So far, no
|
||||
prior implementation provides as many useful features (such as locale
|
||||
alias or message inheritance). It is also not possible to offer this
|
||||
additional functionality on top of a `catgets' implementation. Future
|
||||
versions of GNU `gettext' will very likely convey even more
|
||||
functionality. So it might be a good idea to change to GNU `gettext'
|
||||
as soon as possible.
|
||||
|
||||
INSTALL Matters
|
||||
===============
|
||||
|
||||
Some GNU packages are "localizable" when properly installed; the
|
||||
programs they contain can be made to speak your own native language.
|
||||
Most such packages use GNU `gettext'. Other packages have their own
|
||||
ways to internationalization, predating GNU `gettext'.
|
||||
|
||||
By default, this package will be installed to allow translation of
|
||||
messages. It will automatically detect whether the system provides
|
||||
usable `catgets' (if using this is selected by the installer) or
|
||||
`gettext' functions. If neither is available, the GNU `gettext' own
|
||||
library will be used. This library is wholly contained within this
|
||||
package, usually in the `intl/' subdirectory, so prior installation of
|
||||
the GNU `gettext' package is *not* required. Installers may use
|
||||
special options at configuration time for changing the default
|
||||
behaviour. The commands:
|
||||
|
||||
./configure --with-included-gettext
|
||||
./configure --with-catgets
|
||||
./configure --disable-nls
|
||||
|
||||
will respectively bypass any pre-existing `catgets' or `gettext' to use
|
||||
the internationalizing routines provided within this package, enable
|
||||
the use of the `catgets' functions (if found on the locale system), or
|
||||
else, *totally* disable translation of messages.
|
||||
|
||||
When you already have GNU `gettext' installed on your system and run
|
||||
configure without an option for your new package, `configure' will
|
||||
probably detect the previously built and installed `libintl.a' file and
|
||||
will decide to use this. This might be not what is desirable. You
|
||||
should use the more recent version of the GNU `gettext' library. I.e.
|
||||
if the file `intl/VERSION' shows that the library which comes with this
|
||||
package is more recent, you should use
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to prevent auto-detection.
|
||||
|
||||
By default the configuration process will not test for the `catgets'
|
||||
function and therefore they will not be used. The reasons are already
|
||||
given above: the emulation on top of `catgets' cannot provide all the
|
||||
extensions provided by the GNU `gettext' library. If you nevertheless
|
||||
want to use the `catgets' functions use
|
||||
|
||||
./configure --with-catgets
|
||||
|
||||
to enable the test for `catgets' (this causes no harm if `catgets' is
|
||||
not available on your system). If you really select this option we
|
||||
would like to hear about the reasons because we cannot think of any
|
||||
good one ourself.
|
||||
|
||||
Internationalized packages have usually many `po/LL.po' files, where
|
||||
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||
translations have been forbidden at `configure' time by using the
|
||||
`--disable-nls' switch, all available translations are installed
|
||||
together with the package. However, the environment variable `LINGUAS'
|
||||
may be set, prior to configuration, to limit the installed set.
|
||||
`LINGUAS' should then contain a space separated list of two-letter
|
||||
codes, stating which languages are allowed.
|
||||
|
||||
Using This Package
|
||||
==================
|
||||
|
||||
As a user, if your language has been installed for this package, you
|
||||
only have to set the `LANG' environment variable to the appropriate
|
||||
ISO 639 `LL' two-letter code prior to using the programs in the
|
||||
package. For example, let's suppose that you speak German. At the
|
||||
shell prompt, merely execute `setenv LANG de' (in `csh'),
|
||||
`export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash'). This
|
||||
can be done from your `.login' or `.profile' file, once and for all.
|
||||
|
||||
An operating system might already offer message localization for
|
||||
many of its programs, while other programs (whether GNU or not) have
|
||||
been installed locally with the full capabilities of GNU `gettext'.
|
||||
Just using `gettext' extended syntax for `LANG' would break proper
|
||||
localization of already available operating system programs. In this
|
||||
case, users should set both `LANGUAGE' and `LANG' variables in their
|
||||
environment, as programs using GNU `gettext' give preference to
|
||||
`LANGUAGE'. For example, some Swedish users would rather read
|
||||
translations in German than English for when Swedish is not available.
|
||||
This is easily accomplished by setting `LANGUAGE' to `sv:de' while
|
||||
leaving `LANG' to `sv'.
|
||||
|
||||
Translating Teams
|
||||
=================
|
||||
|
||||
For the GNU Translation Project to be a success, we need interested
|
||||
people who like their own language and write it well, and who are also
|
||||
able to synergize with other translators speaking the same language.
|
||||
Each translation team has its own mailing list, courtesy of Linux
|
||||
International. You may reach your translation team at the address
|
||||
`LL@li.org', replacing LL by the two-letter ISO 639 code for your
|
||||
language. Language codes are *not* the same as the country codes given
|
||||
in ISO 3166. The following translation teams exist, as of May 1996:
|
||||
|
||||
Arabic `ar', Chinese `zh', Czech `cs', Danish `da', Dutch `nl',
|
||||
English `en', Esperanto `eo', Finnish `fi', French `fr', German
|
||||
`de', Greek `el', Hebrew `he', Hungarian `hu', Irish `ga', Italian
|
||||
`it', Indonesian `id', Japanese `ja', Korean `ko', Latin `la',
|
||||
Norwegian `no', Persian `fa', Polish `pl', Portuguese `pt',
|
||||
Russian `ru', Slovenian `sl', Spanish `es', Swedish `sv', Telugu
|
||||
`te', Turkish `tr' and Ukrainian `uk'.
|
||||
|
||||
For example, you may reach the Chinese translation team by writing to
|
||||
`zh@li.org'.
|
||||
|
||||
If you'd like to volunteer to *work* at translating messages, you
|
||||
should become a member of the translating team for your own language.
|
||||
The subscribing address is *not* the same as the list itself, it has
|
||||
`-request' appended. For example, speakers of Swedish can send a
|
||||
message to `sv-request@li.org', having this message body:
|
||||
|
||||
subscribe
|
||||
|
||||
Keep in mind that team members are expected to participate
|
||||
*actively* in translations, or at solving translational difficulties,
|
||||
rather than merely lurking around. If your team does not exist yet and
|
||||
you want to start one, or if you are unsure about what to do or how to
|
||||
get started, please write to `gnu-translation@gnu.ai.mit.edu' to reach
|
||||
the GNU coordinator for all translator teams.
|
||||
|
||||
The English team is special. It works at improving and uniformizing
|
||||
the terminology used in GNU. Proven linguistic skill are praised more
|
||||
than programming skill, here. For the time being, please avoid
|
||||
subscribing to the English team unless explicitly invited to do so.
|
||||
|
||||
Available Packages
|
||||
==================
|
||||
|
||||
Languages are not equally supported in all GNU packages. The
|
||||
following matrix shows the current state of GNU internationalization,
|
||||
as of May 1996. The matrix shows, in regard of each package, for which
|
||||
languages PO files have been submitted to translation coordination.
|
||||
|
||||
cs de en es fi fr ja ko nl no pl pt sl sv
|
||||
.-------------------------------------------.
|
||||
bash | [] | 1
|
||||
bison | [] | 1
|
||||
clisp | [] [] [] | 3
|
||||
cpio | [] | 1
|
||||
diffutils | [] [] [] | 3
|
||||
enscript | [] [] [] [] | 4
|
||||
fileutils | [] [] [] [] | 4
|
||||
findutils | [] [] | 2
|
||||
flex | [] | 1
|
||||
gcal | [] | 1
|
||||
gettext | [] [] [] [] [] [] [] [] | 9
|
||||
glibc | [] [] [] | 3
|
||||
grep | [] [] [] [] [] [] | 6
|
||||
hello | [] [] [] [] [] [] | 6
|
||||
m4 | [] [] [] [] | 4
|
||||
make | | 0
|
||||
mkid | [] [] | 2
|
||||
music | [] | 1
|
||||
ptx | [] [] [] | 3
|
||||
recode | [] [] [] [] [] | 5
|
||||
sh-utils | [] [] | 2
|
||||
sharutils | [] [] [] [] | 4
|
||||
tar | [] [] [] [] [] [] [] | 7
|
||||
textutils | [] [] [] [] | 4
|
||||
wdiff | [] [] [] [] | 4
|
||||
`-------------------------------------------'
|
||||
cs de en es fi fr ja ko nl no pl pt sl sv
|
||||
1 17 1 3 1 22 1 6 3 3 4 3 6 10 81
|
||||
|
||||
Some counters in the preceding matrix are higher than the number of
|
||||
visible blocks let us expect. This is because a few extra PO files are
|
||||
used for implementing regional variants of languages, or language
|
||||
dialects.
|
||||
|
||||
For a PO file in the matrix above to be effective, the package to
|
||||
which it applies should also have been internationalized and
|
||||
distributed as such by its maintainer. There might be an observable
|
||||
lag between the mere existence a PO file and its wide availability in a
|
||||
GNU distribution.
|
||||
|
||||
If May 1996 seems to be old, you may fetch a more recent copy of
|
||||
this `ABOUT-NLS' file on most GNU archive sites.
|
||||
|
||||
6
COPYING
6
COPYING
@@ -2,7 +2,7 @@
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -304,8 +304,8 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
|
||||
250
INSTALL
250
INSTALL
@@ -1,111 +1,181 @@
|
||||
This is a generic INSTALL file for utilities distributions.
|
||||
If this package does not come with, e.g., installable documentation or
|
||||
data files, please ignore the references to them below.
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
To compile this package:
|
||||
These are generic installation instructions.
|
||||
|
||||
1. Configure the package for your system. In the directory that this
|
||||
file is in, type `./configure'. 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.
|
||||
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').
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation, and
|
||||
creates the Makefile(s) (one in each subdirectory of the source
|
||||
directory). In some packages it creates a C header file containing
|
||||
system-dependent definitions. It also creates a file `config.status'
|
||||
that you can run in the future to recreate the current configuration.
|
||||
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.
|
||||
|
||||
Running `configure' takes a minute or two. While it is running, it
|
||||
prints some messages that tell what it is doing. If you don't want to
|
||||
see the messages, run `configure' with its standard output redirected
|
||||
to `/dev/null'; for example, `./configure >/dev/null'.
|
||||
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'.
|
||||
|
||||
To compile the package in a different directory from the one
|
||||
containing the source code, 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
|
||||
`configure'. `configure' automatically checks for the source code in
|
||||
the directory that `configure' is in and in `..'. If for some reason
|
||||
`configure' is not in the source code directory that you are
|
||||
configuring, then it will report that it can't find the source code.
|
||||
In that case, run `configure' with the option `--srcdir=DIR', where
|
||||
DIR is the directory that contains the source code.
|
||||
The simplest way to compile this package is:
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
|
||||
an installation prefix other than /usr/local by giving `configure' the
|
||||
option `--prefix=PATH'. Alternately, you can do so by giving a value
|
||||
for the `prefix' variable when you run `make', e.g.,
|
||||
make prefix=/usr/gnu
|
||||
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.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If
|
||||
you give `configure' the option `--exec_prefix=PATH' or set the
|
||||
`make' variable `exec_prefix' to PATH, the package will use PATH as
|
||||
the prefix for installing programs and libraries. Data files and
|
||||
documentation will still use the regular prefix. Normally, all files
|
||||
are installed using the regular prefix.
|
||||
Running `configure' takes a while. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
You can tell `configure' to figure out the configuration for your
|
||||
system, and record it in `config.status', without actually configuring
|
||||
the package (creating `Makefile's and perhaps a configuration header
|
||||
file). To do this, give `configure' the `--no-create' option. Later,
|
||||
you can run `./config.status' to actually configure the package. This
|
||||
option is useful mainly in `Makefile' rules for updating `config.status'
|
||||
and `Makefile'. You can also give `config.status' the `--recheck'
|
||||
option, which makes it re-run `configure' with the same arguments you
|
||||
used before. This is useful if you change `configure'.
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
`configure' ignores any other arguments that you give it.
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
If your system requires unusual options for compilation or linking
|
||||
that `configure' doesn't know about, you can give `configure' initial
|
||||
values for some variables by setting them in the environment. In
|
||||
Bourne-compatible shells, you can do that on the command line like
|
||||
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='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
The `make' variables that you might want to override with environment
|
||||
variables when running `configure' are:
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
(For these variables, any value given in the environment overrides the
|
||||
value that `configure' would choose:)
|
||||
CC C compiler program.
|
||||
Default is `cc', or `gcc' if `gcc' is in your PATH.
|
||||
INSTALL Program to use to install files.
|
||||
Default is `install' if you have it, `cp' otherwise.
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
(For these variables, any value given in the environment is added to
|
||||
the value that `configure' chooses:)
|
||||
DEFS Configuration options, in the form `-Dfoo -Dbar ...'
|
||||
LIBS Libraries to link with, in the form `-lfoo -lbar ...'
|
||||
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 need to do unusual things to compile the package, we encourage
|
||||
you to figure out how `configure' could check whether to do them, and
|
||||
mail diffs or instructions to the address given in the README so we
|
||||
can include them in the next release.
|
||||
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.
|
||||
|
||||
2. Type `make' to compile the package. If you want, you can override
|
||||
the `make' variables CFLAGS and LDFLAGS like this:
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
make CFLAGS=-O2 LDFLAGS=-s
|
||||
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'.
|
||||
|
||||
3. If the package comes with self-tests and you want to run them,
|
||||
type `make check'. If you're not sure whether there are any, try it;
|
||||
if `make' responds with something like
|
||||
make: *** No way to make target `check'. Stop.
|
||||
then the package does not come with self-tests.
|
||||
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.
|
||||
|
||||
4. Type `make install' to install programs, data files, and
|
||||
documentation.
|
||||
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.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source directory by typing `make clean'. To also remove the
|
||||
Makefile(s), the header file containing system-dependent definitions
|
||||
(if the package uses one), and `config.status' (all the files that
|
||||
`configure' created), type `make distclean'.
|
||||
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.
|
||||
|
||||
`--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.
|
||||
|
||||
The file `configure.in' is used as a template to create `configure' by
|
||||
a program called `autoconf'. You will only need it if you want to
|
||||
regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Makefile
|
||||
fileutils.info
|
||||
version.texi
|
||||
fileutils.info*
|
||||
fileutils.log
|
||||
fileutils.dvi
|
||||
fileutils.aux
|
||||
@@ -15,3 +16,5 @@ fileutils.cm
|
||||
fileutils.fl
|
||||
fileutils.op
|
||||
fileutils.cps
|
||||
stamp-vti
|
||||
version.texi
|
||||
|
||||
6
doc/Makefile.am
Normal file
6
doc/Makefile.am
Normal file
@@ -0,0 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
info_TEXINFOS = fileutils.texi
|
||||
|
||||
# FIXME: remove texinfo.tex when automake has been fixed to include it
|
||||
# automatically
|
||||
EXTRA_DIST = perm.texi getdate.texi texinfo.tex
|
||||
247
doc/Makefile.in
247
doc/Makefile.in
@@ -1,104 +1,209 @@
|
||||
# Makefile for GNU file utilities documentation.
|
||||
# Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
# Makefile.in generated automatically by automake 1.0 from Makefile.am
|
||||
|
||||
# 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.
|
||||
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy, distribute and modify it.
|
||||
|
||||
# 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.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
info_TEXINFOS = fileutils.texi
|
||||
|
||||
# FIXME: remove texinfo.tex when automake has been fixed to include it
|
||||
# automatically
|
||||
EXTRA_DIST = perm.texi getdate.texi texinfo.tex
|
||||
mkinstalldirs = $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
|
||||
MAKEINFO = makeinfo
|
||||
TEXI2DVI = texi2dvi
|
||||
INFOS = fileutils.info*
|
||||
INFO_DEPS = fileutils.info
|
||||
DVIS = fileutils.dvi
|
||||
TEXINFOS = fileutils.texi
|
||||
|
||||
prefix = @prefix@
|
||||
infodir = $(prefix)/info
|
||||
DIST_COMMON = Makefile.am Makefile.in mdate-sh stamp-vti version.texi
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
DISTFILES = Makefile.in texinfo.tex fileutils.texi fileutils.info \
|
||||
version.texi perm.texi getdate.texi
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
all: fileutils.info
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
|
||||
$(TEXINFOS) $(INFOS) $(MANS) $(EXTRA_DIST) $(DATA)
|
||||
DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
|
||||
$(TEXINFOS) $(INFO_DEPS) $(MANS) $(EXTRA_DIST) $(DATA)
|
||||
|
||||
info: fileutils.info
|
||||
TAR = tar
|
||||
default: all
|
||||
|
||||
version.texi: ../src/version.c
|
||||
sed -e '/version_string/!d' \
|
||||
-e 's/[^0-9.]*\([0-9.a-z]*\).*/@set VERSION \1/' \
|
||||
-e q $(srcdir)/../src/version.c \
|
||||
> $@-t
|
||||
echo '@set RELEASEDATE '`date '+%B %Y'` >> $@-t
|
||||
mv $@-t $@
|
||||
|
||||
$(srcdir)/Makefile.in: @MAINT@Makefile.am $(top_srcdir)/configure.in
|
||||
cd $(top_srcdir) && automake $(subdir)/Makefile
|
||||
|
||||
Makefile: $(top_builddir)/config.status Makefile.in
|
||||
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
|
||||
|
||||
version.texi: @MAINT@stamp-vti
|
||||
|
||||
stamp-vti: fileutils.texi $(top_srcdir)/configure.in
|
||||
echo "@set UPDATED `cd $(srcdir) \
|
||||
&& $(SHELL) ./mdate-sh fileutils.texi`" > vti.tmp
|
||||
echo "@set EDITION $(VERSION)" >> vti.tmp
|
||||
echo "@set VERSION $(VERSION)" >> vti.tmp
|
||||
if cmp -s vti.tmp $(srcdir)/version.texi; then \
|
||||
rm vti.tmp; \
|
||||
else \
|
||||
mv vti.tmp $(srcdir)/version.texi; \
|
||||
fi
|
||||
echo timestamp > $(srcdir)/stamp-vti
|
||||
|
||||
mostlyclean-vti:
|
||||
rm -f vti.tmp
|
||||
|
||||
clean-vti:
|
||||
|
||||
distclean-vti:
|
||||
|
||||
maintainer-clean-vti:
|
||||
@MAINT@rm -f stamp-vti version.texi
|
||||
|
||||
fileutils.info: fileutils.texi version.texi
|
||||
$(MAKEINFO) -I$(srcdir) --no-split fileutils.texi --output=$@
|
||||
|
||||
dvi: fileutils.dvi
|
||||
|
||||
fileutils.dvi: fileutils.texi version.texi texinfo.tex
|
||||
$(TEXI2DVI) $(srcdir)/fileutils.texi
|
||||
.texi.info:
|
||||
$(MAKEINFO) -I$(srcdir) $< -o $(srcdir)/$@
|
||||
|
||||
installdirs:
|
||||
$(srcdir)/../mkinstalldirs $(infodir)
|
||||
.texi.dvi:
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS $(TEXI2DVI) $<
|
||||
|
||||
install: install-exec install-data
|
||||
install-exec:
|
||||
install-data: all installdirs
|
||||
cd $(srcdir) && for file in fileutils.info; do \
|
||||
$(INSTALL_DATA) $$file $(infodir)/$$file; \
|
||||
install-info: $(INFO_DEPS)
|
||||
$(mkinstalldirs) $(infodir)
|
||||
for file in $(INFO_DEPS); do \
|
||||
for ifile in `cd $(srcdir) && echo $$file*`; do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$ifile $(infodir)/$$ifile; \
|
||||
done; \
|
||||
done
|
||||
|
||||
uninstall:
|
||||
rm -f $(infodir)/fileutils.info
|
||||
|
||||
check:
|
||||
|
||||
texclean:
|
||||
rm -f *.aux *.cp *.dvi *.fn *.ky *.log *.pg *.toc *.tp *.vr \
|
||||
*.fl *.cm *.op *.cps
|
||||
|
||||
mostlyclean: texclean
|
||||
rm -f *.info
|
||||
|
||||
clean: mostlyclean
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
|
||||
maintainer-clean: distclean
|
||||
@echo "This command is intended for use by maintainers;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
rm -f fileutils.info version.texi
|
||||
|
||||
distdir = ../`cat ../distname`/$(subdir)
|
||||
dist: $(DISTFILES)
|
||||
for file in $(DISTFILES); do \
|
||||
ln $$file $(distdir) \
|
||||
|| { echo copying $$file instead; cp -p $$file $(distdir);}; \
|
||||
uninstall-info:
|
||||
cd $(srcdir) && for file in *.info*; do \
|
||||
rm -f $(infodir)/$$file; \
|
||||
done
|
||||
|
||||
mostlyclean-info:
|
||||
rm -f fileutils.aux fileutils.cp fileutils.cps fileutils.dvi \
|
||||
fileutils.fn fileutils.fns fileutils.ky fileutils.log \
|
||||
fileutils.pg fileutils.toc fileutils.tp fileutils.vr \
|
||||
fileutils.op
|
||||
|
||||
clean-info:
|
||||
|
||||
distclean-info:
|
||||
|
||||
maintainer-clean-info:
|
||||
rm -f $(INFOS)
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
||||
subdir = doc
|
||||
Makefile: ../config.status Makefile.in
|
||||
cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
distdir: $(DEP_DISTFILES)
|
||||
@for file in `cd $(srcdir) && echo $(DISTFILES)`; do \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \
|
||||
done
|
||||
info: $(INFO_DEPS)
|
||||
|
||||
.PHONY: all check clean dist distclean dvi info install install-data \
|
||||
install-exec installdirs maintainer-clean mostlyclean texclean uninstall
|
||||
dvi: $(DVIS)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
check: all
|
||||
|
||||
installcheck:
|
||||
|
||||
install-exec:
|
||||
|
||||
install-data: install-info
|
||||
|
||||
install: install-exec install-data all
|
||||
@:
|
||||
|
||||
uninstall: uninstall-info
|
||||
|
||||
all: $(INFO_DEPS) Makefile
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(infodir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
rm -f Makefile $(DISTCLEANFILES)
|
||||
rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
|
||||
|
||||
maintainer-clean-generic:
|
||||
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
mostlyclean: mostlyclean-vti mostlyclean-info mostlyclean-generic
|
||||
|
||||
clean: clean-vti clean-info clean-generic mostlyclean
|
||||
|
||||
distclean: distclean-vti distclean-info distclean-generic clean
|
||||
rm -f config.status
|
||||
|
||||
maintainer-clean: maintainer-clean-vti maintainer-clean-info \
|
||||
maintainer-clean-generic distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
.PHONY: default mostlyclean-vti distclean-vti clean-vti \
|
||||
maintainer-clean-vti install-info uninstall-info mostlyclean-info \
|
||||
distclean-info clean-info maintainer-clean-info tags distdir info dvi \
|
||||
check installcheck install-exec install-data install uninstall all \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .texi .info .dvi
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
@@ -94,7 +94,7 @@ specified differently, depending on whether the month is specified
|
||||
numerically or literally. All these strings specify the same calendar date:
|
||||
|
||||
@example
|
||||
1970-9-17 # ISO 8601.
|
||||
1970-09-17 # ISO 8601.
|
||||
70-9-17 # This century assumed by default.
|
||||
70-09-17 # Leading zeros are ignored.
|
||||
9/17/72 # Common U.S. writing.
|
||||
@@ -120,9 +120,10 @@ Here are the rules.
|
||||
@cindex date format, ISO 8601
|
||||
For numeric months, the ISO 8601 format
|
||||
@samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
|
||||
any positive number, @var{month} is a number between 1 and 12, and
|
||||
@var{day} is a number between 1 and 31. If @var{year} is less than 100,
|
||||
then 1900 is added to it to force a date in this century. The construct
|
||||
any positive number, @var{month} is a number between 01 and 12, and
|
||||
@var{day} is a number between 01 and 31. A leading zero must be present
|
||||
if a number is less than ten. If @var{year} is less than 100, then 1900
|
||||
is added to it to force a date in this century. The construct
|
||||
@samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
|
||||
is accepted. Also @samp{@var{month}/@var{day}}, omitting the year.
|
||||
|
||||
|
||||
92
doc/mdate-sh
Executable file
92
doc/mdate-sh
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
# mdate-sh - get modification time of a file and pretty-print it
|
||||
# Copyright (C) 1995 Software Foundation, Inc.
|
||||
# Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 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.
|
||||
if ls -L /dev/null 1>/dev/null 2>&1; then
|
||||
set - `ls -L -l $1`
|
||||
else
|
||||
set - `ls -l $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 file 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
|
||||
@@ -217,17 +217,14 @@ og-rxw
|
||||
|
||||
@cindex copying existing permissions
|
||||
@cindex permissions, copying existing
|
||||
You can base part of a file's permissions on part of its existing
|
||||
permissions. To do this, instead of using @samp{r}, @samp{w}, or
|
||||
@samp{x} after the operator, you use the letter @samp{u}, @samp{g}, or
|
||||
@samp{o}. For example, the mode
|
||||
|
||||
You can base a file's permissions on its existing permissions. To do
|
||||
this, instead of using @samp{r}, @samp{w}, or @samp{x} after the
|
||||
operator, you use the letter @samp{u}, @samp{g}, or @samp{o}. For
|
||||
example, the mode
|
||||
@example
|
||||
o+g
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@c FIXME describe the ls -l notation for showing permissions.
|
||||
adds the permissions for users who are in a file's group to the
|
||||
permissions that other users have for the file. Thus, if the file
|
||||
started out as mode 664 (@samp{rw-rw-r--}), the above mode would change
|
||||
|
||||
@@ -28,36 +28,39 @@
|
||||
@ifinfo
|
||||
@format
|
||||
START-INFO-DIR-ENTRY
|
||||
* Shell utilities: (sh-utils). GNU shell utilities.
|
||||
* basename: (sh-utils)basename invocation. Strip directory and suffix.
|
||||
* date: (sh-utils)date invocation. Print/set system date and time.
|
||||
* dirname: (sh-utils)dirname invocation. Strip non-directory suffix.
|
||||
* echo: (sh-utils)echo invocation. Print a line of text.
|
||||
* env: (sh-utils)env invocation. Modify the environment.
|
||||
* expr: (sh-utils)expr invocation. Evaluate expressions.
|
||||
* false: (sh-utils)false invocation. Do nothing, unsuccessfully.
|
||||
* groups: (sh-utils)groups invocation. Print group names a user is in.
|
||||
* hostname: (sh-utils)hostname invocation. Print or set system name.
|
||||
* id: (sh-utils)id invocation. Print real/effective uid/gid.
|
||||
* logname: (sh-utils)logname invocation. Print current login name.
|
||||
* nice: (sh-utils)nice invocation. Modify scheduling priority.
|
||||
* nohup: (sh-utils)nohup invocation. Immunize to hangups.
|
||||
* pathchk: (sh-utils)pathchk invocation. Check file name portability.
|
||||
* printenv: (sh-utils)printenv invocation. Print environment variables.
|
||||
* printf: (sh-utils)printf invocation. Format and print data.
|
||||
* pwd: (sh-utils)pwd invocation. Print working directory.
|
||||
* sleep: (sh-utils)sleep invocation. Delay for a specified time.
|
||||
* stty: (sh-utils)stty invocation. Print/change terminal settings.
|
||||
* su: (sh-utils)su invocation. Modify user and group id.
|
||||
* tee: (sh-utils)tee invocation. Redirect to multiple files.
|
||||
* test: (sh-utils)test invocation. File/string tests.
|
||||
* true: (sh-utils)true invocation. Do nothing, successfully.
|
||||
* tty: (sh-utils)tty invocation. Print terminal name.
|
||||
* uname: (sh-utils)uname invocation. Print system information.
|
||||
* users: (sh-utils)users invocation. Print current user names.
|
||||
* who: (sh-utils)who invocation. Print who is logged in.
|
||||
* whoami: (sh-utils)whoami invocation. Print effective user id.
|
||||
* yes: (sh-utils)yes invocation. Print a string indefinitely.
|
||||
* Shell utilities: (sh-utils). GNU shell utilities.
|
||||
* basename: (sh-utils)basename invocation. Strip directory and suffix.
|
||||
* chroot: (sh-utils)chroot invocation. Specify the root directory.
|
||||
* date: (sh-utils)date invocation. Print/set system date and time.
|
||||
* dirname: (sh-utils)dirname invocation. Strip non-directory suffix.
|
||||
* echo: (sh-utils)echo invocation. Print a line of text.
|
||||
* env: (sh-utils)env invocation. Modify the environment.
|
||||
* expr: (sh-utils)expr invocation. Evaluate expressions.
|
||||
* factor: (sh-utils)factor invocation. Print prime factors
|
||||
* false: (sh-utils)false invocation. Do nothing, unsuccessfully.
|
||||
* groups: (sh-utils)groups invocation. Print group names a user is in.
|
||||
* hostname: (sh-utils)hostname invocation. Print or set system name.
|
||||
* id: (sh-utils)id invocation. Print real/effective uid/gid.
|
||||
* logname: (sh-utils)logname invocation. Print current login name.
|
||||
* nice: (sh-utils)nice invocation. Modify scheduling priority.
|
||||
* nohup: (sh-utils)nohup invocation. Immunize to hangups.
|
||||
* pathchk: (sh-utils)pathchk invocation. Check file name portability.
|
||||
* printenv: (sh-utils)printenv invocation. Print environment variables.
|
||||
* printf: (sh-utils)printf invocation. Format and print data.
|
||||
* pwd: (sh-utils)pwd invocation. Print working directory.
|
||||
* seq: (sh-utils)seq invocation. Print numeric sequences
|
||||
* sleep: (sh-utils)sleep invocation. Delay for a specified time.
|
||||
* stty: (sh-utils)stty invocation. Print/change terminal settings.
|
||||
* su: (sh-utils)su invocation. Modify user and group id.
|
||||
* tee: (sh-utils)tee invocation. Redirect to multiple files.
|
||||
* test: (sh-utils)test invocation. File/string tests.
|
||||
* true: (sh-utils)true invocation. Do nothing, successfully.
|
||||
* tty: (sh-utils)tty invocation. Print terminal name.
|
||||
* uname: (sh-utils)uname invocation. Print system information.
|
||||
* users: (sh-utils)users invocation. Print current user names.
|
||||
* who: (sh-utils)who invocation. Print who is logged in.
|
||||
* whoami: (sh-utils)whoami invocation. Print effective user id.
|
||||
* yes: (sh-utils)yes invocation. Print a string indefinitely.
|
||||
END-INFO-DIR-ENTRY
|
||||
@end format
|
||||
@end ifinfo
|
||||
@@ -65,7 +68,7 @@ END-INFO-DIR-ENTRY
|
||||
@ifinfo
|
||||
This file documents the GNU shell utilities.
|
||||
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -92,12 +95,12 @@ by the Foundation.
|
||||
@titlepage
|
||||
@title GNU @code{sh-utils}
|
||||
@subtitle A set of shell utilities
|
||||
@subtitle for version @value{VERSION}, @value{RELEASEDATE}
|
||||
@subtitle for version @value{VERSION}, @value{UPDATED}
|
||||
@author David MacKenzie et al.
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1994 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -126,18 +129,21 @@ This manual minimally documents version @value{VERSION} of the GNU shell
|
||||
utilities.
|
||||
|
||||
@menu
|
||||
* Introduction:: Caveats, overview, and authors.
|
||||
* Introduction:: Caveats, overview, and authors.
|
||||
* Common options:: Common options.
|
||||
* Date input formats:: Specifying date strings.
|
||||
|
||||
* Date input formats:: Specifying date strings.
|
||||
* Printing text:: echo printf yes
|
||||
* Conditions:: false true test expr
|
||||
* Redirection:: tee
|
||||
* File name manipulation:: dirname basename pathchk
|
||||
* Working context:: pwd stty printenv tty
|
||||
* Working context:: pwd stty printenv tty
|
||||
* User information:: id logname whoami groups users who
|
||||
* System context:: date uname hostname
|
||||
* Modified command invocation:: env nice nohup su
|
||||
* Modified command invocation:: chroot env nice nohup su
|
||||
* Delaying:: sleep
|
||||
* Numeric operations:: factor seq
|
||||
|
||||
* Index:: General index.
|
||||
@end menu
|
||||
@end ifinfo
|
||||
@@ -245,15 +251,13 @@ This section describes commands that display text strings.
|
||||
@cindex text, displaying
|
||||
@cindex arbitrary text, displaying
|
||||
|
||||
Synopsis:
|
||||
@code{echo} writes each given @var{string} to standard output, with a
|
||||
space between each and a newline after the last one. Synopsis:
|
||||
|
||||
@example
|
||||
echo [@var{option}]@dots{} [@var{string}]@dots{}
|
||||
@end example
|
||||
|
||||
@code{echo} writes each given @var{string} to standard output, with a
|
||||
space between each and a newline after the last one.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@table @samp
|
||||
@@ -298,7 +302,7 @@ a valid octal number, it is printed literally.
|
||||
@section @code{printf}: Format and print data
|
||||
|
||||
@pindex printf
|
||||
Synopsis:
|
||||
@code{printf} does formatted printing of text. Synopsis:
|
||||
|
||||
@example
|
||||
printf @var{format} [@var{argument}]@dots{}
|
||||
@@ -423,7 +427,7 @@ is also allowed: @code{test} returns true if the argument is not null.
|
||||
@menu
|
||||
* File type tests:: -[bcdfhLpSt]
|
||||
* Access permission tests:: -[gkruwxOG]
|
||||
* File characteristics tests:: -e -s -nt -ot -ef
|
||||
* File characteristics tests:: -e -s -nt -ot -ef
|
||||
* String tests:: -z -n = !=
|
||||
* Numeric tests:: -eq -ne -lt -le -gt -ge
|
||||
* Connectives for test:: ! -a -o
|
||||
@@ -599,7 +603,7 @@ True if the length of @var{string} is zero.
|
||||
@itemx @var{string}
|
||||
@opindex -n
|
||||
@cindex nonzero-length string check
|
||||
True if the length of @var{string} is non-zero.
|
||||
True if the length of @var{string} is nonzero.
|
||||
|
||||
@item @var{string1} = @var{string2}
|
||||
@opindex =
|
||||
@@ -699,9 +703,9 @@ Operands are either numbers or strings. @code{expr} coerces
|
||||
anything appearing in an operand position to an integer or a string
|
||||
depending on the operation being applied to it.
|
||||
|
||||
Strings are not quoted for @code{expr}, though you may need to quote
|
||||
them to protect characters with special meaning to the shell, e.g.,
|
||||
spaces.
|
||||
Strings are not quoted for @code{expr} itself, though you may need to
|
||||
quote them to protect characters with special meaning to the shell,
|
||||
e.g., spaces.
|
||||
|
||||
@cindex parentheses for grouping
|
||||
Operators may given as infix symbols or prefix keywords. Parentheses
|
||||
@@ -869,7 +873,7 @@ To add 1 to the shell variable @code{foo}, in Bourne-compatible shells:
|
||||
foo=`expr $foo + 1`
|
||||
@end example
|
||||
|
||||
To print the non-directory part of the file name stored in
|
||||
To print the non-directory part of the file name stored in
|
||||
@code{$fname}, which need not contain a @code{/}.
|
||||
@example
|
||||
expr $fname : '.*/\(^.*\)' '^|' $fname
|
||||
@@ -897,11 +901,11 @@ to change the input source or output destination of a command. But one
|
||||
useful redirection is performed by a separate command, not by the shell;
|
||||
it's described here.
|
||||
|
||||
|
||||
@menu
|
||||
* tee invocation:: Redirect output to multiple files.
|
||||
@end menu
|
||||
|
||||
|
||||
@node tee invocation
|
||||
@section @code{tee}: Redirect output to multiple files
|
||||
|
||||
@@ -912,9 +916,7 @@ it's described here.
|
||||
|
||||
The @code{tee} command copies standard input to standard output and also
|
||||
to any files given as arguments. This is useful when you want not only
|
||||
to send some data down a pipe, but also to save a copy.
|
||||
|
||||
Synopsis:
|
||||
to send some data down a pipe, but also to save a copy. Synopsis:
|
||||
|
||||
@example
|
||||
tee [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@@ -969,16 +971,16 @@ This section describes commands that manipulate file names.
|
||||
@cindex file names, stripping directory and suffix
|
||||
@cindex leading directory components, stripping
|
||||
|
||||
Synopsis:
|
||||
@code{basename} removes any leading directory components from
|
||||
@var{name}. Synopsis:
|
||||
|
||||
@example
|
||||
basename @var{name} [@var{suffix}]
|
||||
@end example
|
||||
|
||||
The @code{basename} command removes any leading directory components
|
||||
from @var{name}. If @var{suffix} is specified and is identical
|
||||
to the end of @var{name}, it is removed from @var{name} as well.
|
||||
@code{basename} prints the result on standard output.
|
||||
If @var{suffix} is specified and is identical to the end of @var{name},
|
||||
it is removed from @var{name} as well. @code{basename} prints the
|
||||
result on standard output.
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
@@ -992,15 +994,15 @@ options}.
|
||||
@cindex stripping non-directory suffix
|
||||
@cindex non-directory suffix, stripping
|
||||
|
||||
Synopsis:
|
||||
@code{dirname} prints all but the final slash-delimited component of
|
||||
a string (presumably a filename). Synopsis:
|
||||
|
||||
@example
|
||||
dirname @var{name}
|
||||
@end example
|
||||
|
||||
@code{dirname} prints all but the final slash-delimited component
|
||||
of @var{name}. If @var{name} is a single component,
|
||||
@code{dirname} prints @samp{.} (meaning the current directory).
|
||||
If @var{name} is a single component, @code{dirname} prints @samp{.}
|
||||
(meaning the current directory).
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
@@ -1014,7 +1016,7 @@ options}.
|
||||
@cindex valid file names, checking for
|
||||
@cindex portable file names, checking for
|
||||
|
||||
Synopsis:
|
||||
@code{pathchk} checks portability of filenames. Synopsis:
|
||||
|
||||
@example
|
||||
pathchk [@var{option}]@dots{} @var{name}@dots{}
|
||||
@@ -1108,6 +1110,14 @@ The only options are a lone @samp{--help} or
|
||||
@cindex terminal settings
|
||||
@cindex line settings of terminal
|
||||
|
||||
@code{stty} prints or changes terminal characteristics, such as baud rate.
|
||||
Synopses:
|
||||
|
||||
@example
|
||||
stty [@var{setting}]@dots{}
|
||||
stty [@var{option}]
|
||||
@end example
|
||||
|
||||
If given no arguments, @code{stty} prints the baud rate, line
|
||||
discipline number (on systems that support it), and line settings
|
||||
that have been changed from the values set by @samp{stty sane}.
|
||||
@@ -1117,13 +1127,6 @@ standard input.
|
||||
@code{stty} accepts many non-option arguments that change aspects of
|
||||
the terminal line operation, as described below.
|
||||
|
||||
Synopses:
|
||||
|
||||
@example
|
||||
stty [@var{setting}]@dots{}
|
||||
stty [@var{option}]
|
||||
@end example
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@table @samp
|
||||
@@ -1232,7 +1235,7 @@ Enable RTS/CTS flow control. Non-POSIX. May be negated.
|
||||
@item ignbrk
|
||||
@opindex ignbrk
|
||||
@cindex breaks, ignoring
|
||||
Ignore breaks. May be negated.
|
||||
Ignore break characters. May be negated.
|
||||
|
||||
@item brkint
|
||||
@opindex brkint
|
||||
@@ -1242,7 +1245,7 @@ Make breaks cause an interrupt signal. May be negated.
|
||||
@item ignpar
|
||||
@opindex ignpar
|
||||
@cindex parity, ignoring
|
||||
Ignore parity errors. May be negated.
|
||||
Ignore characters with parity errors. May be negated.
|
||||
|
||||
@item parmrk
|
||||
@opindex parmrk
|
||||
@@ -1591,7 +1594,7 @@ They are set with the syntax @samp{name value}, where the names are
|
||||
listed below and the value can be given either literally, in hat
|
||||
notation (@samp{^@var{c}}), or as an integer which may start with
|
||||
@samp{0x} to indicate hexadecimal, @samp{0} to indicate octal, or
|
||||
any other digit to indicate decimal.
|
||||
any other digit to indicate decimal.
|
||||
|
||||
@cindex disabling special characters
|
||||
@kindex u@r{, and disabling special characters}
|
||||
@@ -1735,7 +1738,7 @@ of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600
|
||||
@cindex printing all or some environment variables
|
||||
@cindex environment variables, printing
|
||||
|
||||
Synopsis:
|
||||
@code{printenv} prints environment variable values. Synopsis:
|
||||
|
||||
@example
|
||||
printenv [@var{option}] [@var{variable}]@dots{}
|
||||
@@ -1767,7 +1770,6 @@ Exit status:
|
||||
|
||||
@code{tty} prints the file name of the tty connected to its standard
|
||||
input. It prints @samp{not a tty} if standard input is not a tty.
|
||||
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
@@ -1826,10 +1828,8 @@ logins, groups, and so forth.
|
||||
@cindex effective uid and gid, printing
|
||||
@cindex printing real and effective uid and gid
|
||||
|
||||
@noindent @code{id} prints information about the given user, or the process
|
||||
running it if no user is specified.
|
||||
|
||||
Synopsis:
|
||||
@code{id} prints information about the given user, or the process
|
||||
running it if no user is specified. Synopsis:
|
||||
|
||||
@example
|
||||
id [@var{option}]@dots{} [@var{username}]
|
||||
@@ -1923,11 +1923,9 @@ options}.
|
||||
@cindex supplementary groups, printing
|
||||
|
||||
@code{groups} prints the names of the primary and any supplementary
|
||||
groups that each given @var{username}, or the current process if none
|
||||
are given, is in. If user names are given, the name of each user is
|
||||
printed before the list of that user's groups.
|
||||
|
||||
Synopsis:
|
||||
groups for each given @var{username}, or the current process if no names
|
||||
are given. If names are given, the name of each user is printed before
|
||||
the list of that user's groups. Synopsis:
|
||||
|
||||
@example
|
||||
groups [@var{username}]@dots{}
|
||||
@@ -1951,9 +1949,7 @@ options}.
|
||||
names of users currently logged in to the current host. Each user name
|
||||
corresponds to a login session, so if a user has more than one login
|
||||
session, that user's name will appear the same number of times in the
|
||||
output.
|
||||
|
||||
Synopsis:
|
||||
output. Synopsis:
|
||||
|
||||
@example
|
||||
users [@var{file}]
|
||||
@@ -1976,6 +1972,7 @@ options}.
|
||||
@cindex printing current user information
|
||||
@cindex information, about current users
|
||||
|
||||
@code{who} prints information about users who are currently logged on.
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
@@ -2085,10 +2082,8 @@ information.
|
||||
@cindex time, printing or setting
|
||||
@cindex printing the current time
|
||||
|
||||
@code{date} with no arguments prints the current time and date, in
|
||||
the format of the @samp{%c} directive (described below).
|
||||
|
||||
Synopses:
|
||||
@code{date} with no arguments prints the current time and date, in the
|
||||
format of the @samp{%c} directive (described below). Synopses:
|
||||
|
||||
@example
|
||||
date [@var{option}]@dots{} [+@var{format}]
|
||||
@@ -2107,10 +2102,10 @@ directives, which start with @samp{%}, characters in the format string
|
||||
are printed unchanged. The directives are described below.
|
||||
|
||||
@menu
|
||||
* Time directives:: %[HIklMprsSTXZ]
|
||||
* Time directives:: %[HIklMprsSTXzZ]
|
||||
* Date directives:: %[aAbBcdDhjmUwWxyY]
|
||||
* Literal directives:: %[%nt]
|
||||
* Padding:: Pad with zeroes, spaces (%_), or nothing (%-).
|
||||
* Padding:: Pad with zeroes, spaces (%_), or nothing (%-).
|
||||
* Setting the time:: Changing the system clock.
|
||||
* Options for date:: Instead of the current time.
|
||||
* Examples of date:: Examples.
|
||||
@@ -2144,16 +2139,25 @@ time, 12-hour (hh:mm:ss [AP]M)
|
||||
@cindex seconds since the epoch
|
||||
@cindex beginning of time
|
||||
seconds since the epoch, i.e., 1 January 1970 00:00:00 UTC (a
|
||||
GNU extension)
|
||||
GNU extension).
|
||||
Note that this value is the number of seconds between the epoch
|
||||
and the current date as defined by the localtime system call.
|
||||
It isn't changed by the @samp{--date} option.
|
||||
@item %S
|
||||
second (00@dots{}61)
|
||||
@item %T
|
||||
time, 24-hour (hh:mm:ss)
|
||||
@item %X
|
||||
locale's time representation (%H:%M:%S)
|
||||
@item %z
|
||||
RFC-822 style numeric time zone (e.g., -0600 or +0100), or nothing if no
|
||||
time zone is determinable. This value reflects the @emph{current} time
|
||||
zone. It isn't changed by the @samp{--date} option.
|
||||
@item %Z
|
||||
timezone (e.g., EDT), or nothing if no timezone is
|
||||
determinable
|
||||
time zone (e.g., EDT), or nothing if no timezone is
|
||||
determinable.
|
||||
Note that this value reflects the @emph{current} time zone.
|
||||
It isn't changed by the @samp{--date} option.
|
||||
@end table
|
||||
|
||||
|
||||
@@ -2187,11 +2191,19 @@ day of year (001@dots{}366)
|
||||
@item %m
|
||||
month (01@dots{}12)
|
||||
@item %U
|
||||
week number of year with Sunday as first day of week (00@dots{}53)
|
||||
week number of year with Sunday as first day of week (00@dots{}53).
|
||||
Days in a new year preceding the first Sunday are in week zero.
|
||||
@item %V
|
||||
week number of year with Monday as first day of the week as a decimal
|
||||
(01@dots{}53). If the week containing January 1 has four or more days in
|
||||
the new year, then it is considered week 1; otherwise, it is week 53 of
|
||||
the previous year, and the next week is week 1. (See the ISO 8601: 1988
|
||||
standard.)
|
||||
@item %w
|
||||
day of week (0@dots{}6) with 0 corresponding to Sunday
|
||||
@item %W
|
||||
week number of year with Monday as first day of week (00@dots{}53)
|
||||
week number of year with Monday as first day of week (00@dots{}53).
|
||||
Days in a new year preceding the first Sunday are in week zero.
|
||||
@item %x
|
||||
locale's date representation (mm/dd/yy)
|
||||
@item %y
|
||||
@@ -2320,15 +2332,6 @@ current time and date. @var{datestr} can be in almost any common
|
||||
format. It can contain month names, timezones, @samp{am} and @samp{pm},
|
||||
@samp{yesterday}, @samp{ago}, @samp{next}, etc. @xref{Date input formats}.
|
||||
|
||||
@item -r @var{file}
|
||||
@itemx --reference=@var{file}
|
||||
@opindex -r
|
||||
@opindex --reference
|
||||
Display the time and date as obtained from a reference @var{file},
|
||||
instead of the current time and date. Each file has a few timestamps
|
||||
associated with it. In this context, the time and date of the last
|
||||
modification are used.
|
||||
|
||||
@item -f @var{datefile}
|
||||
@itemx --file=@var{datefile}
|
||||
@opindex -f
|
||||
@@ -2339,6 +2342,20 @@ input. This is useful when you have many dates to process, because the
|
||||
system overhead of starting up the @code{date} executable many times can
|
||||
be considerable.
|
||||
|
||||
@itemx --rfc-822
|
||||
@opindex -R
|
||||
@opindex --rfc-822
|
||||
Display the time and date using the RFC-822-specified
|
||||
format, @samp{%a, %_d %b %Y %H:%M:%S %z}.
|
||||
If @samp{--utc} is also specified, use @samp{GMT} in place of @samp{%z}.
|
||||
|
||||
@item -r @var{file}
|
||||
@itemx --reference=@var{file}
|
||||
@opindex -r
|
||||
@opindex --reference
|
||||
Display the time and date reference according to the last modification
|
||||
time of @var{file}, instead of the current time and date.
|
||||
|
||||
@item -s @var{datestr}
|
||||
@itemx --set=@var{datestr}
|
||||
@opindex -s
|
||||
@@ -2419,6 +2436,14 @@ To set the system clock forward by two minutes:
|
||||
date --set='+2 minutes'
|
||||
@end example
|
||||
|
||||
@item
|
||||
To print the date in the format specified by RFC-822,
|
||||
use @samp{date --rfc}. I just did and saw this:
|
||||
|
||||
@example
|
||||
Mon, 25 Mar 1996 23:34:17 -0600
|
||||
@end example
|
||||
|
||||
@end itemize
|
||||
|
||||
|
||||
@@ -2431,9 +2456,7 @@ date --set='+2 minutes'
|
||||
|
||||
@code{uname} prints information about the machine and operating system
|
||||
it is run on. If no options are given, @code{uname} acts as if the
|
||||
@code{-s} option were given.
|
||||
|
||||
Synopsis:
|
||||
@code{-s} option were given. Synopsis:
|
||||
|
||||
@example
|
||||
uname [@var{option}]@dots{}
|
||||
@@ -2518,9 +2541,7 @@ Print the operating system version.
|
||||
With no arguments, @code{hostname} prints the name of the current host
|
||||
system. With one argument, it sets the current host name to the
|
||||
specified string. You must have appropriate privileges to set the host
|
||||
name.
|
||||
|
||||
Synopsis:
|
||||
name. Synopsis:
|
||||
|
||||
@example
|
||||
hostname [@var{name}]
|
||||
@@ -2542,6 +2563,7 @@ different than the current one: a modified environment, as a different
|
||||
user, etc.
|
||||
|
||||
@menu
|
||||
* chroot invocation:: Modify the root directory.
|
||||
* env invocation:: Modify environment variables.
|
||||
* nice invocation:: Modify scheduling priority.
|
||||
* nohup invocation:: Immunize to hangups.
|
||||
@@ -2549,17 +2571,42 @@ user, etc.
|
||||
@end menu
|
||||
|
||||
|
||||
@node chroot invocation
|
||||
@section @code{chroot}: Run a command with a different root directory
|
||||
|
||||
@pindex chroot
|
||||
@cindex running a program in a specified root directory
|
||||
@cindex root directory, running a program in a specified
|
||||
|
||||
@code{chroot} runs a command with a specified root directory.
|
||||
On many systems, only the super-user can do this.
|
||||
Synopses:
|
||||
|
||||
@example
|
||||
chroot @var{newroot} [@var{command} [@var{args}]@dots{}]
|
||||
chroot @var{option}
|
||||
@end example
|
||||
|
||||
Ordinarily, filenames are looked up starting at the root of the
|
||||
directory structure, i.e., @file{/}. @code{chroot} changes the root to
|
||||
the directory @var{newroot} (which must exist) and then runs
|
||||
@var{command} with optional @var{args}. If @var{command} is not
|
||||
specified, the default is the value of the @code{SHELL} environment
|
||||
variable or @code{/bin/sh} if not set, invoked with the @samp{-i} option.
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
|
||||
|
||||
@node env invocation
|
||||
@section @code{env}: Run a command in a modified environment
|
||||
|
||||
@pindex env
|
||||
@cindex environment, running a program in a modified
|
||||
@cindex modified environment, running a program in
|
||||
@cindex modified environment, running a program in a
|
||||
@cindex running a program in a modified environment
|
||||
|
||||
@code{env} runs a command with an environment modified as specified
|
||||
by the command line arguments.
|
||||
|
||||
Synopses:
|
||||
@code{env} runs a command with a modified environment. Synopses:
|
||||
|
||||
@example
|
||||
env [@var{option}]@dots{} [@var{name}=@var{value}]@dots{} @c
|
||||
@@ -2614,6 +2661,13 @@ Start with an empty environment, ignoring the inherited environment.
|
||||
@cindex priority, modifying
|
||||
@cindex appropriate privileges
|
||||
|
||||
@code{nice} prints or modifies the scheduling priority of a job.
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
nice [@var{option}]@dots{} [@var{command} [@var{arg}]@dots{}]
|
||||
@end example
|
||||
|
||||
If no arguments are given, @code{nice} prints the current scheduling
|
||||
priority, which it inherited. Otherwise, @code{nice} runs the given
|
||||
@var{command} with its scheduling priority adjusted. If no
|
||||
@@ -2622,12 +2676,6 @@ priority, which it inherited. Otherwise, @code{nice} runs the given
|
||||
adjustment. The priority can be adjusted by @code{nice} over the range
|
||||
of -20 (the highest priority) to 19 (the lowest).
|
||||
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
nice [@var{option}]@dots{} [@var{command} [@var{arg}]@dots{}]
|
||||
@end example
|
||||
|
||||
@cindex conflicts with shell built-ins
|
||||
@cindex built-in shell commands, conflicts with
|
||||
Because most shells have a built-in command by the same name, using the
|
||||
@@ -2653,24 +2701,24 @@ Add @var{adjustment} instead of 10 to the command's priority.
|
||||
@pindex nohup
|
||||
@cindex hangups, immunity to
|
||||
@cindex immunity to hangups
|
||||
@cindex logging out and continuing to run
|
||||
|
||||
@flindex nohup.out
|
||||
@code{nohup} runs the given @var{command} with hangup signals ignored,
|
||||
so that the command can continue running in the background after you log
|
||||
out.
|
||||
|
||||
Synopsis:
|
||||
out. Synopsis:
|
||||
|
||||
@example
|
||||
nohup @var{command} [@var{arg}]@dots{}
|
||||
@end example
|
||||
|
||||
@flindex nohup.out
|
||||
Also, the scheduling priority is increased by 5. If standard output is a
|
||||
tty, it and standard error are redirected so that they are appended to
|
||||
the file @file{nohup.out}; if that cannot be written to, they are
|
||||
appended to the file @file{$HOME/nohup.out}. If that cannot be written
|
||||
to, the command is not run.
|
||||
@code{nohup} increases the scheduling priority of @var{command} by 5, so
|
||||
it has a slightly smaller change to run. If standard output is a tty,
|
||||
it and standard error are redirected so that they are appended to the
|
||||
file @file{nohup.out}; if that cannot be written to, they are appended
|
||||
to the file @file{$HOME/nohup.out}. If that cannot be written to, the
|
||||
command is not run.
|
||||
|
||||
If @code{nohup} creates either @file{nohup.out} or
|
||||
@file{$HOME/nohup.out}, it creates it with no ``group'' or ``other''
|
||||
@@ -2696,9 +2744,7 @@ options}.
|
||||
|
||||
@code{su} allows one user to temporarily become another user. It runs a
|
||||
command (often an interactive shell) with the real and effective user
|
||||
id, group id, and supplemental groups of a given @var{user}.
|
||||
|
||||
Synopsis:
|
||||
id, group id, and supplemental groups of a given @var{user}. Synopsis:
|
||||
|
||||
@example
|
||||
su [@var{option}]@dots{} [@var{user} [@var{arg}]@dots{}]
|
||||
@@ -2840,7 +2886,7 @@ might find this idea strange at first.
|
||||
@cindex delaying commands
|
||||
@cindex commands for delaying
|
||||
|
||||
Perhaps @code{wait} or other commands should be described here also?
|
||||
@c Perhaps @code{wait} or other commands should be described here also?
|
||||
|
||||
@menu
|
||||
* sleep invocation:: Delay for a specified time.
|
||||
@@ -2855,7 +2901,6 @@ Perhaps @code{wait} or other commands should be described here also?
|
||||
|
||||
@code{sleep} pauses for an amount of time specified by the sum of
|
||||
the values of the command line arguments.
|
||||
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
@@ -2881,6 +2926,82 @@ The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
|
||||
|
||||
@node Numeric operations
|
||||
@chapter Numeric operations
|
||||
|
||||
@cindex numeric operations
|
||||
These programs do numerically-related operations.
|
||||
|
||||
@menu
|
||||
* factor invocation:: Show factors of numbers.
|
||||
* seq invocation:: Print sequences of numbers.
|
||||
@end menu
|
||||
|
||||
|
||||
@node factor invocation
|
||||
@section @code{factor}: Print prime factors
|
||||
|
||||
@pindex factor
|
||||
@cindex prime factors
|
||||
|
||||
@code{factor} prints prime factors. Synopses:
|
||||
|
||||
@example
|
||||
factor [@var{number}]@dots{}
|
||||
factor @var{option}
|
||||
@end example
|
||||
|
||||
If no @var{number} is specified on the command line, @code{factor} reads
|
||||
numbers from standard input, delimited by newlines, tabs, or spaces.
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
|
||||
|
||||
@node seq invocation
|
||||
@section @code{seq}: Print numeric sequences
|
||||
|
||||
@pindex seq
|
||||
@cindex numeric sequences
|
||||
@cindex sequence of numbers
|
||||
|
||||
@code{seq} prints a sequence of numbers to standard output. Synopses:
|
||||
|
||||
@example
|
||||
seq [@var{option}]@dots{} [@var{first} [@var{step}]] @var{last}@dots{}
|
||||
@end example
|
||||
|
||||
@code{seq} prints the numbers from @var{first} to @var{last} by
|
||||
@var{step}. By default, @var{first} and @var{step} are both 1, and each
|
||||
number is printed on its own line. All numbers can be reals, not just
|
||||
integers.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@table @samp
|
||||
@item -f @var{format}
|
||||
@itemx --format=@var{format}
|
||||
@opindex -f @var{format}
|
||||
@opindex --format=@var{format}
|
||||
@cindex formatting of numbers in @code{seq}
|
||||
Print all numbers using @var{format}; default @samp{%g}.
|
||||
@var{format} must contain exactly one of the standarding float output
|
||||
formats @samp{%e}, @samp{%f}, or @samp{%g}.
|
||||
|
||||
@item -s @var{string}
|
||||
@itemx --separator=@var{string}
|
||||
@cindex separator for numbers in @code{seq}
|
||||
Separate numbers with @var{string}; default is a newline.
|
||||
The output always terminates with a newline.
|
||||
|
||||
@item -w
|
||||
@itemx --equal-width
|
||||
Print all numbers with the same width, by padding with leading zeroes.
|
||||
(To have other kinds of padding, use @samp{--format}).
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Index
|
||||
@unnumbered Index
|
||||
|
||||
|
||||
433
doc/texinfo.tex
433
doc/texinfo.tex
@@ -1,6 +1,7 @@
|
||||
%% TeX macros to handle texinfo files
|
||||
|
||||
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
|
||||
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
|
||||
% 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
%This texinfo.tex file is free software; you can redistribute it and/or
|
||||
%modify it under the terms of the GNU General Public License as
|
||||
@@ -14,8 +15,8 @@
|
||||
|
||||
%You should have received a copy of the GNU General Public License
|
||||
%along with this texinfo.tex file; see the file COPYING. If not, write
|
||||
%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
|
||||
%USA.
|
||||
%to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
%Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
%In other words, you are welcome to use, share and improve this program.
|
||||
@@ -34,7 +35,7 @@
|
||||
|
||||
% This automatically updates the version number based on RCS.
|
||||
\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
|
||||
\deftexinfoversion$Revision: 1.8 $
|
||||
\deftexinfoversion$Revision: 1.10 $
|
||||
\message{Loading texinfo package [Version \texinfoversion]:}
|
||||
|
||||
% If in a .fmt file, print the version number
|
||||
@@ -66,7 +67,10 @@
|
||||
% since \penalty is valid in vertical mode, we'd end up putting the
|
||||
% penalty on the vertical list instead of in the new paragraph.
|
||||
{\catcode`@ = 11
|
||||
\gdef\tie{\leavevmode\penalty\@M\ }
|
||||
% Avoid using \@M directly, because that causes trouble
|
||||
% if the definition is written into an index file.
|
||||
\global\let\tiepenalty = \@M
|
||||
\gdef\tie{\leavevmode\penalty\tiepenalty\ }
|
||||
}
|
||||
\let\~ = \tie % And make it available as @~.
|
||||
|
||||
@@ -533,17 +537,34 @@ where each line of input produces a line of output.}
|
||||
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
|
||||
\leftline{\hskip\leftskip{\rm#1}}}}
|
||||
|
||||
% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
|
||||
|
||||
\def\inmargin#1{%
|
||||
\strut\vadjust{\nobreak\kern-\strutdepth
|
||||
\vtop to \strutdepth{\baselineskip\strutdepth\vss
|
||||
\llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
|
||||
\newskip\inmarginspacing \inmarginspacing=1cm
|
||||
\def\strutdepth{\dp\strutbox}
|
||||
|
||||
%\hbox{{\rm#1}}\hfil\break}}
|
||||
|
||||
% @include file insert text of that file as input.
|
||||
|
||||
\def\include{\parsearg\includezzz}
|
||||
%Use \input\thisfile to avoid blank after \input, which may be an active
|
||||
%char (in which case the blank would become the \input argument).
|
||||
%The grouping keeps the value of \thisfile correct even when @include
|
||||
%is nested.
|
||||
\def\includezzz #1{\begingroup
|
||||
\def\thisfile{#1}\input\thisfile
|
||||
% Allow normal characters that we make active in the argument (a file name).
|
||||
\def\include{\begingroup
|
||||
\catcode`\\=12
|
||||
\catcode`~=12
|
||||
\catcode`^=12
|
||||
\catcode`_=12
|
||||
\catcode`|=12
|
||||
\catcode`<=12
|
||||
\catcode`>=12
|
||||
\catcode`+=12
|
||||
\parsearg\includezzz}
|
||||
% Restore active chars for included file.
|
||||
\def\includezzz#1{\endgroup\begingroup
|
||||
% Read the included file in a group so nested @include's work.
|
||||
\def\thisfile{#1}%
|
||||
\input\thisfile
|
||||
\endgroup}
|
||||
|
||||
\def\thisfile{}
|
||||
@@ -628,6 +649,15 @@ where each line of input produces a line of output.}
|
||||
\let\printindex = \relax
|
||||
\let\pxref = \relax
|
||||
\let\settitle = \relax
|
||||
\let\setchapternewpage = \relax
|
||||
\let\setchapterstyle = \relax
|
||||
\let\everyheading = \relax
|
||||
\let\evenheading = \relax
|
||||
\let\oddheading = \relax
|
||||
\let\everyfooting = \relax
|
||||
\let\evenfooting = \relax
|
||||
\let\oddfooting = \relax
|
||||
\let\headings = \relax
|
||||
\let\include = \relax
|
||||
\let\lowersections = \relax
|
||||
\let\down = \relax
|
||||
@@ -651,6 +681,11 @@ where each line of input produces a line of output.}
|
||||
\def\menu{\doignore{menu}}
|
||||
\def\direntry{\doignore{direntry}}
|
||||
|
||||
% @dircategory CATEGORY -- specify a category of the dir file
|
||||
% which this file should belong to. Ignore this in TeX.
|
||||
|
||||
\def\dircategory{\comment}
|
||||
|
||||
% Ignore text until a line `@end #1'.
|
||||
%
|
||||
\def\doignore#1{\begingroup
|
||||
@@ -686,7 +721,7 @@ where each line of input produces a line of output.}
|
||||
\immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
|
||||
\immediate\write16{ to use a workaround.}
|
||||
\immediate\write16{}
|
||||
\warnedobstrue
|
||||
\global\warnedobstrue
|
||||
\fi
|
||||
}
|
||||
|
||||
@@ -762,15 +797,17 @@ where each line of input produces a line of output.}
|
||||
% Since we want to separate VAR from REST-OF-LINE (which might be
|
||||
% empty), we can't just use \parsearg; we have to insert a space of our
|
||||
% own to delimit the rest of the line, and then take it out again if we
|
||||
% didn't need it.
|
||||
% didn't need it. Make sure the catcode of space is correct to avoid
|
||||
% losing inside @example, for instance.
|
||||
%
|
||||
\def\set{\parsearg\setxxx}
|
||||
\def\set{\begingroup\catcode` =10 \parsearg\setxxx}
|
||||
\def\setxxx#1{\setyyy#1 \endsetyyy}
|
||||
\def\setyyy#1 #2\endsetyyy{%
|
||||
\def\temp{#2}%
|
||||
\ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
|
||||
\else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
|
||||
\fi
|
||||
\endgroup
|
||||
}
|
||||
% Can't use \xdef to pre-expand #2 and save some time, since \temp or
|
||||
% \next or other control sequences that we've defined might get us into
|
||||
@@ -907,6 +944,21 @@ where each line of input produces a line of output.}
|
||||
\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
|
||||
node \samp{\ignorespaces#1{}}}
|
||||
|
||||
\def\macro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\macroxxx}
|
||||
\def\macroxxx#1#2 \end macro{%
|
||||
\expandafter\gdef\macrotemp#1{#2}%
|
||||
\endgroup}
|
||||
|
||||
%\def\linemacro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\linemacroxxx}
|
||||
%\def\linemacroxxx#1#2 \end linemacro{%
|
||||
%\let\parsearg=\relax
|
||||
%\edef\macrotempx{\csname M\butfirst\expandafter\string\macrotemp\endcsname}%
|
||||
%\expandafter\xdef\macrotemp{\parsearg\macrotempx}%
|
||||
%\expandafter\gdef\macrotempx#1{#2}%
|
||||
%\endgroup}
|
||||
|
||||
%\def\butfirst#1{}
|
||||
|
||||
\message{fonts,}
|
||||
|
||||
% Font-change commands.
|
||||
@@ -917,12 +969,16 @@ where each line of input produces a line of output.}
|
||||
\def\sf{\fam=\sffam \tensf}
|
||||
\let\li = \sf % Sometimes we call it \li, not \sf.
|
||||
|
||||
% We don't need math for this one.
|
||||
\def\ttsl{\tenttsl}
|
||||
|
||||
%% Try out Computer Modern fonts at \magstephalf
|
||||
\let\mainmagstep=\magstephalf
|
||||
|
||||
% Set the font macro #1 to the font named #2, adding on the
|
||||
% specified font prefix (normally `cm').
|
||||
\def\setfont#1#2{\font#1=\fontprefix#2}
|
||||
% #3 is the font's design size, #4 is a scale factor
|
||||
\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
|
||||
|
||||
% Use cm as the default font prefix.
|
||||
% To specify the font prefix, you must define \fontprefix
|
||||
@@ -930,29 +986,46 @@ where each line of input produces a line of output.}
|
||||
\ifx\fontprefix\undefined
|
||||
\def\fontprefix{cm}
|
||||
\fi
|
||||
% Support font families that don't use the same naming scheme as CM.
|
||||
\def\rmshape{r}
|
||||
\def\rmbshape{bx} %where the normal face is bold
|
||||
\def\bfshape{b}
|
||||
\def\bxshape{bx}
|
||||
\def\ttshape{tt}
|
||||
\def\ttbshape{tt}
|
||||
\def\ttslshape{sltt}
|
||||
\def\itshape{ti}
|
||||
\def\itbshape{bxti}
|
||||
\def\slshape{sl}
|
||||
\def\slbshape{bxsl}
|
||||
\def\sfshape{ss}
|
||||
\def\sfbshape{ss}
|
||||
\def\scshape{csc}
|
||||
\def\scbshape{csc}
|
||||
|
||||
\ifx\bigger\relax
|
||||
\let\mainmagstep=\magstep1
|
||||
\setfont\textrm{r12}
|
||||
\setfont\texttt{tt12}
|
||||
\setfont\textrm\rmshape{12}{1000}
|
||||
\setfont\texttt\ttshape{12}{1000}
|
||||
\else
|
||||
\setfont\textrm{r10 scaled \mainmagstep}
|
||||
\setfont\texttt{tt10 scaled \mainmagstep}
|
||||
\setfont\textrm\rmshape{10}{\mainmagstep}
|
||||
\setfont\texttt\ttshape{10}{\mainmagstep}
|
||||
\fi
|
||||
% Instead of cmb10, you many want to use cmbx10.
|
||||
% cmbx10 is a prettier font on its own, but cmb10
|
||||
% looks better when embedded in a line with cmr10.
|
||||
\setfont\textbf{b10 scaled \mainmagstep}
|
||||
\setfont\textit{ti10 scaled \mainmagstep}
|
||||
\setfont\textsl{sl10 scaled \mainmagstep}
|
||||
\setfont\textsf{ss10 scaled \mainmagstep}
|
||||
\setfont\textsc{csc10 scaled \mainmagstep}
|
||||
\setfont\textbf\bfshape{10}{\mainmagstep}
|
||||
\setfont\textit\itshape{10}{\mainmagstep}
|
||||
\setfont\textsl\slshape{10}{\mainmagstep}
|
||||
\setfont\textsf\sfshape{10}{\mainmagstep}
|
||||
\setfont\textsc\scshape{10}{\mainmagstep}
|
||||
\setfont\textttsl\ttslshape{10}{\mainmagstep}
|
||||
\font\texti=cmmi10 scaled \mainmagstep
|
||||
\font\textsy=cmsy10 scaled \mainmagstep
|
||||
|
||||
% A few fonts for @defun, etc.
|
||||
\setfont\defbf{bx10 scaled \magstep1} %was 1314
|
||||
\setfont\deftt{tt10 scaled \magstep1}
|
||||
\setfont\defbf\bxshape{10}{\magstep1} %was 1314
|
||||
\setfont\deftt\ttshape{10}{\magstep1}
|
||||
\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
|
||||
|
||||
% Fonts for indices and small examples.
|
||||
@@ -960,66 +1033,70 @@ where each line of input produces a line of output.}
|
||||
% because texinfo normally uses the slanted fonts for that.
|
||||
% Do not make many font distinctions in general in the index, since they
|
||||
% aren't very useful.
|
||||
\setfont\ninett{tt9}
|
||||
\setfont\indrm{r9}
|
||||
\setfont\indit{sl9}
|
||||
\setfont\ninett\ttshape{9}{1000}
|
||||
\setfont\indrm\rmshape{9}{1000}
|
||||
\setfont\indit\slshape{9}{1000}
|
||||
\let\indsl=\indit
|
||||
\let\indtt=\ninett
|
||||
\let\indttsl=\ninett
|
||||
\let\indsf=\indrm
|
||||
\let\indbf=\indrm
|
||||
\setfont\indsc{csc10 at 9pt}
|
||||
\setfont\indsc\scshape{10}{900}
|
||||
\font\indi=cmmi9
|
||||
\font\indsy=cmsy9
|
||||
|
||||
% Fonts for headings
|
||||
\setfont\chaprm{bx12 scaled \magstep2}
|
||||
\setfont\chapit{ti12 scaled \magstep2}
|
||||
\setfont\chapsl{sl12 scaled \magstep2}
|
||||
\setfont\chaptt{tt12 scaled \magstep2}
|
||||
\setfont\chapsf{ss12 scaled \magstep2}
|
||||
\setfont\chaprm\rmbshape{12}{\magstep2}
|
||||
\setfont\chapit\itbshape{10}{\magstep3}
|
||||
\setfont\chapsl\slbshape{10}{\magstep3}
|
||||
\setfont\chaptt\ttbshape{12}{\magstep2}
|
||||
\setfont\chapttsl\ttslshape{10}{\magstep3}
|
||||
\setfont\chapsf\sfbshape{12}{\magstep2}
|
||||
\let\chapbf=\chaprm
|
||||
\setfont\chapsc{csc10 scaled\magstep3}
|
||||
\setfont\chapsc\scbshape{10}{\magstep3}
|
||||
\font\chapi=cmmi12 scaled \magstep2
|
||||
\font\chapsy=cmsy10 scaled \magstep3
|
||||
|
||||
\setfont\secrm{bx12 scaled \magstep1}
|
||||
\setfont\secit{ti12 scaled \magstep1}
|
||||
\setfont\secsl{sl12 scaled \magstep1}
|
||||
\setfont\sectt{tt12 scaled \magstep1}
|
||||
\setfont\secsf{ss12 scaled \magstep1}
|
||||
\setfont\secbf{bx12 scaled \magstep1}
|
||||
\setfont\secsc{csc10 scaled\magstep2}
|
||||
\setfont\secrm\rmbshape{12}{\magstep1}
|
||||
\setfont\secit\itbshape{10}{\magstep2}
|
||||
\setfont\secsl\slbshape{10}{\magstep2}
|
||||
\setfont\sectt\ttbshape{12}{\magstep1}
|
||||
\setfont\secttsl\ttslshape{10}{\magstep2}
|
||||
\setfont\secsf\sfbshape{12}{\magstep1}
|
||||
\let\secbf\secrm
|
||||
\setfont\secsc\scbshape{10}{\magstep2}
|
||||
\font\seci=cmmi12 scaled \magstep1
|
||||
\font\secsy=cmsy10 scaled \magstep2
|
||||
|
||||
% \setfont\ssecrm{bx10 scaled \magstep1} % This size an font looked bad.
|
||||
% \setfont\ssecit{cmti10 scaled \magstep1} % The letters were too crowded.
|
||||
% \setfont\ssecsl{sl10 scaled \magstep1}
|
||||
% \setfont\ssectt{tt10 scaled \magstep1}
|
||||
% \setfont\ssecsf{ss10 scaled \magstep1}
|
||||
% \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad.
|
||||
% \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded.
|
||||
% \setfont\ssecsl\slshape{10}{\magstep1}
|
||||
% \setfont\ssectt\ttshape{10}{\magstep1}
|
||||
% \setfont\ssecsf\sfshape{10}{\magstep1}
|
||||
|
||||
%\setfont\ssecrm{b10 scaled 1315} % Note the use of cmb rather than cmbx.
|
||||
%\setfont\ssecit{ti10 scaled 1315} % Also, the size is a little larger than
|
||||
%\setfont\ssecsl{sl10 scaled 1315} % being scaled magstep1.
|
||||
%\setfont\ssectt{tt10 scaled 1315}
|
||||
%\setfont\ssecsf{ss10 scaled 1315}
|
||||
%\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx.
|
||||
%\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than
|
||||
%\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1.
|
||||
%\setfont\ssectt\ttshape{10}{1315}
|
||||
%\setfont\ssecsf\sfshape{10}{1315}
|
||||
|
||||
%\let\ssecbf=\ssecrm
|
||||
|
||||
\setfont\ssecrm{bx12 scaled \magstephalf}
|
||||
\setfont\ssecit{ti12 scaled \magstephalf}
|
||||
\setfont\ssecsl{sl12 scaled \magstephalf}
|
||||
\setfont\ssectt{tt12 scaled \magstephalf}
|
||||
\setfont\ssecsf{ss12 scaled \magstephalf}
|
||||
\setfont\ssecbf{bx12 scaled \magstephalf}
|
||||
\setfont\ssecsc{csc10 scaled \magstep1}
|
||||
\setfont\ssecrm\rmbshape{12}{\magstephalf}
|
||||
\setfont\ssecit\itbshape{10}{1315}
|
||||
\setfont\ssecsl\slbshape{10}{1315}
|
||||
\setfont\ssectt\ttbshape{12}{\magstephalf}
|
||||
\setfont\ssecttsl\ttslshape{10}{\magstep1}
|
||||
\setfont\ssecsf\sfbshape{12}{\magstephalf}
|
||||
\let\ssecbf\ssecrm
|
||||
\setfont\ssecsc\scbshape{10}{\magstep1}
|
||||
\font\sseci=cmmi12 scaled \magstephalf
|
||||
\font\ssecsy=cmsy10 scaled \magstep1
|
||||
% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
|
||||
% but that is not a standard magnification.
|
||||
|
||||
% Fonts for title page:
|
||||
\setfont\titlerm{bx12 scaled \magstep3}
|
||||
\setfont\titlerm\rmbshape{12}{\magstep3}
|
||||
\let\authorrm = \secrm
|
||||
|
||||
% In order for the font changes to affect most math symbols and letters,
|
||||
@@ -1038,33 +1115,33 @@ where each line of input produces a line of output.}
|
||||
% The font-changing commands redefine the meanings of \tenSTYLE, instead
|
||||
% of just \STYLE. We do this so that font changes will continue to work
|
||||
% in math mode, where it is the current \fam that is relevant in most
|
||||
% cases, not the current. Plain TeX does, for example,
|
||||
% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need
|
||||
% to redefine \bf itself.
|
||||
% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam
|
||||
% \tenbf}, for example. By redefining \tenbf, we obviate the need to
|
||||
% redefine \bf itself.
|
||||
\def\textfonts{%
|
||||
\let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
|
||||
\let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
|
||||
\let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
|
||||
\let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
|
||||
\resetmathfonts}
|
||||
\def\chapfonts{%
|
||||
\let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
|
||||
\let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
|
||||
\let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
|
||||
\let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
|
||||
\resetmathfonts}
|
||||
\def\secfonts{%
|
||||
\let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
|
||||
\let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
|
||||
\let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
|
||||
\let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
|
||||
\resetmathfonts}
|
||||
\def\subsecfonts{%
|
||||
\let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
|
||||
\let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
|
||||
\let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
|
||||
\let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
|
||||
\resetmathfonts}
|
||||
\def\indexfonts{%
|
||||
\let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
|
||||
\let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
|
||||
\let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
|
||||
\let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl
|
||||
\resetmathfonts}
|
||||
|
||||
% Set up the default fonts, so we can use them for creating boxes.
|
||||
@@ -1075,9 +1152,9 @@ where each line of input produces a line of output.}
|
||||
\newcount\fontdepth \fontdepth=0
|
||||
|
||||
% Fonts for short table of contents.
|
||||
\setfont\shortcontrm{r12}
|
||||
\setfont\shortcontbf{bx12}
|
||||
\setfont\shortcontsl{sl12}
|
||||
\setfont\shortcontrm\rmshape{12}{1000}
|
||||
\setfont\shortcontbf\bxshape{12}{1000}
|
||||
\setfont\shortcontsl\slshape{12}{1000}
|
||||
|
||||
%% Add scribe-like font environments, plus @l for inline lisp (usually sans
|
||||
%% serif) and @ii for TeX italic
|
||||
@@ -1104,16 +1181,16 @@ where each line of input produces a line of output.}
|
||||
\def\restorehyphenation{\hyphenchar\font = `- }
|
||||
|
||||
\def\t#1{%
|
||||
{\tt \nohyphenation \rawbackslash \frenchspacing #1}%
|
||||
{\tt \rawbackslash \frenchspacing #1}%
|
||||
\null
|
||||
}
|
||||
\let\ttfont = \t
|
||||
%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
|
||||
\let\ttfont=\t
|
||||
\def\samp #1{`\tclose{#1}'\null}
|
||||
\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
|
||||
\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
|
||||
\def\ctrl #1{{\tt \rawbackslash \hat}#1}
|
||||
|
||||
\let\file=\samp
|
||||
\let\url=\samp % perhaps include a hypertex \special eventually
|
||||
|
||||
% @code is a modification of @t,
|
||||
% which makes spaces the same size as normal in the surrounding text.
|
||||
@@ -1139,7 +1216,7 @@ where each line of input produces a line of output.}
|
||||
}
|
||||
|
||||
% We *must* turn on hyphenation at `-' and `_' in \code.
|
||||
% Otherwise, it is too hard to avoid overful hboxes
|
||||
% Otherwise, it is too hard to avoid overfull hboxes
|
||||
% in the Emacs manual, the Library manual, etc.
|
||||
|
||||
% Unfortunately, TeX uses one parameter (\hyphenchar) to control
|
||||
@@ -1157,6 +1234,7 @@ where each line of input produces a line of output.}
|
||||
% ever called. -- mycroft
|
||||
\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder}
|
||||
}
|
||||
|
||||
\def\realdash{-}
|
||||
\def\realunder{_}
|
||||
\def\codedash{-\discretionary{}{}{}}
|
||||
@@ -1167,12 +1245,19 @@ where each line of input produces a line of output.}
|
||||
|
||||
% @kbd is like @code, except that if the argument is just one @key command,
|
||||
% then @kbd has no effect.
|
||||
|
||||
%
|
||||
\def\xkey{\key}
|
||||
\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
|
||||
\ifx\one\xkey\ifx\threex\three \key{#2}%
|
||||
\else\tclose{\look}\fi
|
||||
\else\tclose{\look}\fi}
|
||||
\else{\tclose{\ttsl\look}}\fi
|
||||
\else{\tclose{\ttsl\look}}\fi}
|
||||
|
||||
% Check if we are currently using a typewriter font. Since all the
|
||||
% Computer Modern typewriter fonts have zero interword stretch (and
|
||||
% shrink), and it is reasonable to expect all typewriter fonts to have
|
||||
% this property, we can check that font parameter.
|
||||
%
|
||||
\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
|
||||
|
||||
% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
|
||||
% argument is to make the input look right: @dmn{pt} instead of
|
||||
@@ -1437,7 +1522,7 @@ July\or August\or September\or October\or November\or December\fi
|
||||
|
||||
\newif\ifitemxneedsnegativevskip
|
||||
|
||||
\def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi}
|
||||
\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
|
||||
|
||||
\def\internalBitem{\smallbreak \parsearg\itemzzz}
|
||||
\def\internalBitemx{\itemxpar \parsearg\itemzzz}
|
||||
@@ -1544,7 +1629,7 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\def\tablez #1#2#3#4#5#6{%
|
||||
\aboveenvbreak %
|
||||
\begingroup %
|
||||
\def\Edescription{\Etable}% Neccessary kludge.
|
||||
\def\Edescription{\Etable}% Necessary kludge.
|
||||
\let\itemindex=#1%
|
||||
\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
|
||||
\ifnum 0#4>0 \tableindent=#4\mil \fi %
|
||||
@@ -1708,10 +1793,10 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\flushcr}
|
||||
|
||||
% @multitable macros
|
||||
% Amy Hendrickson, 8/18/94
|
||||
% Amy Hendrickson, 8/18/94, 3/6/96
|
||||
%
|
||||
% @multitable ... @endmultitable will make as many columns as desired.
|
||||
% Contents of each column will wrap at width given in preamble. Width
|
||||
% @multitable ... @end multitable will make as many columns as desired.
|
||||
% Contents of each column will wrap at width given in preamble. Width
|
||||
% can be specified either with sample text given in a template line,
|
||||
% or in percent of \hsize, the current width of text on page.
|
||||
|
||||
@@ -1720,10 +1805,10 @@ July\or August\or September\or October\or November\or December\fi
|
||||
% To make preamble:
|
||||
%
|
||||
% Either define widths of columns in terms of percent of \hsize:
|
||||
% @multitable @percentofhsize .2 .3 .5
|
||||
% @multitable @columnfractions .25 .3 .45
|
||||
% @item ...
|
||||
%
|
||||
% Numbers following @percentofhsize are the percent of the total
|
||||
% Numbers following @columnfractions are the percent of the total
|
||||
% current hsize to be used for each column. You may use as many
|
||||
% columns as desired.
|
||||
|
||||
@@ -1731,7 +1816,16 @@ July\or August\or September\or October\or November\or December\fi
|
||||
% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
|
||||
% @item ...
|
||||
% using the widest term desired in each column.
|
||||
|
||||
%
|
||||
% For those who want to use more than one line's worth of words in
|
||||
% the preamble, break the line within one argument and it
|
||||
% will parse correctly, i.e.,
|
||||
%
|
||||
% @multitable {Column 1 template} {Column 2 template} {Column 3
|
||||
% template}
|
||||
% Not:
|
||||
% @multitable {Column 1 template} {Column 2 template}
|
||||
% {Column 3 template}
|
||||
|
||||
% Each new table line starts with @item, each subsequent new column
|
||||
% starts with @tab. Empty columns may be produced by supplying @tab's
|
||||
@@ -1756,71 +1850,84 @@ July\or August\or September\or October\or November\or December\fi
|
||||
%
|
||||
% They will wrap at the width determined by the template.
|
||||
% @item@tab@tab This will be in third column.
|
||||
% @endmultitable
|
||||
% @end multitable
|
||||
|
||||
% Default dimensions may be reset by user.
|
||||
% @intableparskip will set vertical space between paragraphs in table.
|
||||
% @intableparindent will set paragraph indent in table.
|
||||
% @spacebetweencols will set horizontal space to be left between columns.
|
||||
% @spacebetweenlines will set vertical space to be left between lines.
|
||||
% @multitableparskip is vertical space between paragraphs in table.
|
||||
% @multitableparindent is paragraph indent in table.
|
||||
% @multitablecolmargin is horizontal space to be left between columns.
|
||||
% @multitablelinespace is space to leave between table items;
|
||||
% 0 means it depends on current normal line spacing.
|
||||
|
||||
%%%%
|
||||
% Dimensions
|
||||
|
||||
\newdimen\intableparskip
|
||||
\newdimen\intableparindent
|
||||
\newdimen\spacebetweencols
|
||||
\newdimen\spacebetweenlines
|
||||
\intableparskip=0pt
|
||||
\intableparindent=6pt
|
||||
\spacebetweencols=12pt
|
||||
\spacebetweenlines=12pt
|
||||
\newskip\multitableparskip
|
||||
\newskip\multitableparindent
|
||||
\newdimen\multitablecolspace
|
||||
\newskip\multitablelinespace
|
||||
\multitableparskip=0pt
|
||||
\multitableparindent=6pt
|
||||
\multitablecolspace=12pt
|
||||
\multitablelinespace=0pt
|
||||
|
||||
%%%%
|
||||
% Macros used to set up halign preamble:
|
||||
\let\endsetuptable\relax
|
||||
\def\xendsetuptable{\endsetuptable}
|
||||
\let\percentofhsize\relax
|
||||
\def\xpercentofhsize{\percentofhsize}
|
||||
\let\columnfractions\relax
|
||||
\def\xcolumnfractions{\columnfractions}
|
||||
\newif\ifsetpercent
|
||||
|
||||
%% 2/1/96, to allow fractions to be given with more than one digit.
|
||||
\def\pickupwholefraction#1 {\global\advance\colcount by1 %
|
||||
\expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}%
|
||||
\setuptable}
|
||||
|
||||
\newcount\colcount
|
||||
\def\setuptable#1{\def\firstarg{#1}%
|
||||
\ifx\firstarg\xendsetuptable\let\go\relax%
|
||||
\else
|
||||
\ifx\firstarg\xpercentofhsize\global\setpercenttrue%
|
||||
\ifx\firstarg\xcolumnfractions\global\setpercenttrue%
|
||||
\else
|
||||
\ifsetpercent
|
||||
\if#1.\else%
|
||||
\global\advance\colcount by1 %
|
||||
\expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}%
|
||||
\fi
|
||||
\let\go\pickupwholefraction % In this case arg of setuptable
|
||||
% is the decimal point before the
|
||||
% number given in percent of hsize.
|
||||
% We don't need this so we don't use it.
|
||||
\else
|
||||
\global\advance\colcount by1
|
||||
\setbox0=\hbox{#1}%
|
||||
\expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
|
||||
\fi%
|
||||
\fi%
|
||||
\let\go\setuptable%
|
||||
\ifx\go\pickupwholefraction\else\let\go\setuptable\fi%
|
||||
\fi\go}
|
||||
|
||||
%%%%
|
||||
% multitable syntax
|
||||
\def\tab{&}
|
||||
\def\tab{&\hskip1sp\relax} % 2/2/96
|
||||
% tiny skip here makes sure this column space is
|
||||
% maintained, even if it is never used.
|
||||
|
||||
|
||||
%%%%
|
||||
% @multitable ... @endmultitable definitions:
|
||||
% @multitable ... @end multitable definitions:
|
||||
|
||||
\def\multitable#1\item{\bgroup
|
||||
\def\multitable{\parsearg\dotable}
|
||||
|
||||
\def\dotable#1{\bgroup
|
||||
\let\item\cr
|
||||
\tolerance=9500
|
||||
\hbadness=9500
|
||||
\parskip=\intableparskip
|
||||
\parindent=\intableparindent
|
||||
\setmultitablespacing
|
||||
\parskip=\multitableparskip
|
||||
\parindent=\multitableparindent
|
||||
\overfullrule=0pt
|
||||
\global\colcount=0\relax%
|
||||
\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}%
|
||||
% To parse everything between @multitable and @item :
|
||||
\def\one{#1}\expandafter\setuptable\one\endsetuptable
|
||||
\setuptable#1 \endsetuptable
|
||||
% Need to reset this to 0 after \setuptable.
|
||||
\global\colcount=0\relax%
|
||||
%
|
||||
@@ -1831,9 +1938,9 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\halign\bgroup&\global\advance\colcount by 1\relax%
|
||||
\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
|
||||
% In order to keep entries from bumping into each other
|
||||
% we will add a \leftskip of \spacebetweencols to all columns after
|
||||
% we will add a \leftskip of \multitablecolspace to all columns after
|
||||
% the first one.
|
||||
% If a template has been used, we will add \spacebetweencols
|
||||
% If a template has been used, we will add \multitablecolspace
|
||||
% to the width of each template entry.
|
||||
% If user has set preamble in terms of percent of \hsize
|
||||
% we will use that dimension as the width of the column, and
|
||||
@@ -1845,21 +1952,42 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\ifsetpercent
|
||||
\else
|
||||
% If user has <not> set preamble in terms of percent of \hsize
|
||||
% we will advance \hsize by \spacebetweencols
|
||||
\advance\hsize by \spacebetweencols
|
||||
% we will advance \hsize by \multitablecolspace
|
||||
\advance\hsize by \multitablecolspace
|
||||
\fi
|
||||
% In either case we will make \leftskip=\spacebetweencols:
|
||||
\leftskip=\spacebetweencols
|
||||
% In either case we will make \leftskip=\multitablecolspace:
|
||||
\leftskip=\multitablecolspace
|
||||
\fi
|
||||
\noindent##}\cr%
|
||||
\noindent##%\par
|
||||
%\vskip\multitablelinespace
|
||||
}\cr%
|
||||
% \everycr will reset column counter, \colcount, at the end of
|
||||
% each line. Every column entry will cause \colcount to advance by one.
|
||||
% The table preamble
|
||||
% looks at the current \colcount to find the correct column width.
|
||||
\global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines
|
||||
\global\everycr{\noalign{\nointerlineskip\vskip\multitablelinespace
|
||||
\filbreak%% keeps underfull box messages off when table breaks over pages.
|
||||
\global\colcount=0\relax}}}
|
||||
|
||||
\def\setmultitablespacing{% test to see if user has set \multitablelinespace.
|
||||
% If so, do nothing. If not, give it an appropriate dimension based on
|
||||
% current baselineskip.
|
||||
\ifdim\multitablelinespace=0pt
|
||||
\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
|
||||
\global\advance\multitablelinespace by-\ht0\fi
|
||||
%% Test to see if parskip is larger than space between lines of
|
||||
%% table. If not, do nothing.
|
||||
%% If so, set to same dimension as multitablelinespace.
|
||||
\ifdim\multitableparskip>\multitablelinespace
|
||||
\global\multitableparskip=\multitablelinespace
|
||||
\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
|
||||
%% than skip between lines in the table.
|
||||
\fi%
|
||||
\ifdim\multitableparskip=0pt
|
||||
\global\multitableparskip=\multitablelinespace
|
||||
\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
|
||||
%% than skip between lines in the table.
|
||||
\fi}
|
||||
\message{indexing,}
|
||||
% Index generation facilities
|
||||
|
||||
@@ -1988,8 +2116,15 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\def\kbd##1{\realbackslash kbd {##1}}%
|
||||
\def\dfn##1{\realbackslash dfn {##1}}%
|
||||
\def\emph##1{\realbackslash emph {##1}}%
|
||||
\unsepspaces
|
||||
}
|
||||
|
||||
% If an index command is used in an @example environment, any spaces
|
||||
% therein should become regular spaces in the raw index file, not the
|
||||
% expansion of \tie (\\leavevmode \penalty \@M \ ).
|
||||
{\obeyspaces
|
||||
\gdef\unsepspaces{\obeyspaces\let =\space}}
|
||||
|
||||
% \indexnofonts no-ops all font-change commands.
|
||||
% This is used when outputting the strings to sort the index by.
|
||||
\def\indexdummyfont#1{#1}
|
||||
@@ -2240,7 +2375,7 @@ July\or August\or September\or October\or November\or December\fi
|
||||
%
|
||||
% Insert the text of the index entry. TeX will do line-breaking on it.
|
||||
#1%
|
||||
% The following is kluged to not output a line of dots in the index if
|
||||
% The following is kludged to not output a line of dots in the index if
|
||||
% there are no page numbers. The next person who breaks this will be
|
||||
% cursed by a Unix daemon.
|
||||
\def\tempa{{\rm }}%
|
||||
@@ -2578,7 +2713,7 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\penalty 10000 %
|
||||
}}
|
||||
|
||||
\outer\def\appenixsection{\parsearg\appendixsecyyy}
|
||||
\outer\def\appendixsection{\parsearg\appendixsecyyy}
|
||||
\outer\def\appendixsec{\parsearg\appendixsecyyy}
|
||||
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
|
||||
\def\appendixsectionzzz #1{\seccheck{appendixsection}%
|
||||
@@ -3010,9 +3145,10 @@ July\or August\or September\or October\or November\or December\fi
|
||||
% can't do that in the \entry macro, since index entries might consist
|
||||
% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
|
||||
%
|
||||
% \turnoffactive is for the sake of @" used for umlauts.
|
||||
\def\tocentry#1#2{\begingroup
|
||||
\hyphenpenalty = 10000
|
||||
\entry{#1}{#2}%
|
||||
\entry{\turnoffactive #1}{\turnoffactive #2}%
|
||||
\endgroup}
|
||||
|
||||
% Space between chapter (or whatever) number and the title.
|
||||
@@ -3836,7 +3972,10 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\setbox0=\hbox{\printednodename}%
|
||||
\ifdim \wd0 = 0pt
|
||||
% No printed node name was explicitly given.
|
||||
\ifx\SETxref-automatic-section-title\relax %
|
||||
\expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
|
||||
% Use the node name inside the square brackets.
|
||||
\def\printednodename{\ignorespaces #1}%
|
||||
\else
|
||||
% Use the actual chapter/section title appear inside
|
||||
% the square brackets. Use the real section title if we have it.
|
||||
\ifdim \wd1>0pt%
|
||||
@@ -3845,16 +3984,12 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\else
|
||||
\ifhavexrefs
|
||||
% We know the real title if we have the xref values.
|
||||
\def\printednodename{\refx{#1-title}}%
|
||||
\def\printednodename{\refx{#1-title}{}}%
|
||||
\else
|
||||
% Otherwise just copy the Info node name.
|
||||
\def\printednodename{\ignorespaces #1}%
|
||||
\fi%
|
||||
\fi
|
||||
\def\printednodename{#1-title}%
|
||||
\else
|
||||
% Use the node name inside the square brackets.
|
||||
\def\printednodename{\ignorespaces #1}%
|
||||
\fi
|
||||
\fi
|
||||
%
|
||||
@@ -4240,11 +4375,13 @@ July\or August\or September\or October\or November\or December\fi
|
||||
}
|
||||
|
||||
% Allow control of the text dimensions. Parameters in order: textheight;
|
||||
% textwidth; \voffset; \hoffset (!); binding offset. All require a dimension;
|
||||
% textwidth; voffset; hoffset; binding offset; topskip.
|
||||
% All require a dimension;
|
||||
% header is additional; added length extends the bottom of the page.
|
||||
|
||||
\def\changepagesizes#1#2#3#4#5{
|
||||
\def\changepagesizes#1#2#3#4#5#6{
|
||||
\global\vsize= #1
|
||||
\global\topskip= #6
|
||||
\advance\vsize by \topskip
|
||||
\global\voffset= #3
|
||||
\global\hsize= #2
|
||||
@@ -4257,13 +4394,20 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\global\normaloffset= #4
|
||||
\global\bindingoffset= #5}
|
||||
|
||||
% This layout is compatible with Latex on A4 paper.
|
||||
|
||||
\def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}}
|
||||
% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin
|
||||
% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
|
||||
\def\afourlatex
|
||||
{\global\tolerance=700
|
||||
\global\hfuzz=1pt
|
||||
\setleading{12pt}
|
||||
\global\parskip 15pt plus 1pt
|
||||
\advance\baselineskip by 1.6pt
|
||||
\changepagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}
|
||||
}
|
||||
|
||||
% Use @afourwide to print on European A4 paper in wide format.
|
||||
\def\afourwide{\afourpaper
|
||||
\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}}
|
||||
\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}}
|
||||
|
||||
% Define macros to output various characters with catcode for normal text.
|
||||
\catcode`\"=\other
|
||||
@@ -4312,14 +4456,7 @@ July\or August\or September\or October\or November\or December\fi
|
||||
\catcode`\_=\active
|
||||
\def_{\ifusingtt\normalunderscore\_}
|
||||
% Subroutine for the previous macro.
|
||||
\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
|
||||
|
||||
% \lvvmode is equivalent in function to \leavevmode.
|
||||
% Using \leavevmode runs into trouble when written out to
|
||||
% an index file due to the expansion of \leavevmode into ``\unhbox
|
||||
% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
|
||||
% magic tricks with @.
|
||||
\def\lvvmode{\vbox to 0pt{}}
|
||||
\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
|
||||
|
||||
\catcode`\|=\active
|
||||
\def|{{\tt \char '174}}
|
||||
|
||||
@@ -26,31 +26,31 @@
|
||||
@ifinfo
|
||||
@format
|
||||
START-INFO-DIR-ENTRY
|
||||
* Text utilities: (textutils). GNU text utilities.
|
||||
* cat: (textutils)cat invocation. Concatenate and write files.
|
||||
* cksum: (textutils)cksum invocation. Print POSIX CRC checksum.
|
||||
* comm: (textutils)comm invocation. Compare sorted files by line.
|
||||
* csplit: (textutils)csplit invocation. Split by context.
|
||||
* cut: (textutils)cut invocation. Print selected parts of lines.
|
||||
* expand: (textutils)expand invocation. Convert tabs to spaces.
|
||||
* fmt: (textutils)fmt invocation. Reformat paragraph text.
|
||||
* fold: (textutils)fold invocation. Wrap long input lines.
|
||||
* head: (textutils)head invocation. Output the first part of files.
|
||||
* join: (textutils)join invocation. Join lines on a common field.
|
||||
* md5sum: (textutils)md5sum invocation. Print or check message-digests.
|
||||
* nl: (textutils)nl invocation. Number lines and write files.
|
||||
* od: (textutils)od invocation. Dump files in octal, etc.
|
||||
* paste: (textutils)paste invocation. Merge lines of files.
|
||||
* pr: (textutils)pr invocation. Paginate or columnate files.
|
||||
* sort: (textutils)sort invocation. Sort text files.
|
||||
* split: (textutils)split invocation. Split into fixed-size pieces.
|
||||
* sum: (textutils)sum invocation. Print traditional checksum.
|
||||
* tac: (textutils)tac invocation. Reverse files.
|
||||
* tail: (textutils)tail invocation. Output the last part of files.
|
||||
* tr: (textutils)tr invocation. Translate characters.
|
||||
* unexpand: (textutils)unexpand invocation. Convert spaces to tabs.
|
||||
* uniq: (textutils)uniq invocation. Uniqify files.
|
||||
* wc: (textutils)wc invocation. Byte, word, and line counts.
|
||||
* Text utilities: (textutils). GNU text utilities.
|
||||
* cat: (textutils)cat invocation. Concatenate and write files.
|
||||
* cksum: (textutils)cksum invocation. Print @sc{POSIX} CRC checksum.
|
||||
* comm: (textutils)comm invocation. Compare sorted files by line.
|
||||
* csplit: (textutils)csplit invocation. Split by context.
|
||||
* cut: (textutils)cut invocation. Print selected parts of lines.
|
||||
* expand: (textutils)expand invocation. Convert tabs to spaces.
|
||||
* fmt: (textutils)fmt invocation. Reformat paragraph text.
|
||||
* fold: (textutils)fold invocation. Wrap long input lines.
|
||||
* head: (textutils)head invocation. Output the first part of files.
|
||||
* join: (textutils)join invocation. Join lines on a common field.
|
||||
* md5sum: (textutils)md5sum invocation. Print or check message-digests.
|
||||
* nl: (textutils)nl invocation. Number lines and write files.
|
||||
* od: (textutils)od invocation. Dump files in octal, etc.
|
||||
* paste: (textutils)paste invocation. Merge lines of files.
|
||||
* pr: (textutils)pr invocation. Paginate or columnate files.
|
||||
* sort: (textutils)sort invocation. Sort text files.
|
||||
* split: (textutils)split invocation. Split into fixed-size pieces.
|
||||
* sum: (textutils)sum invocation. Print traditional checksum.
|
||||
* tac: (textutils)tac invocation. Reverse files.
|
||||
* tail: (textutils)tail invocation. Output the last part of files.
|
||||
* tr: (textutils)tr invocation. Translate characters.
|
||||
* unexpand: (textutils)unexpand invocation. Convert spaces to tabs.
|
||||
* uniq: (textutils)uniq invocation. Uniqify files.
|
||||
* wc: (textutils)wc invocation. Byte, word, and line counts.
|
||||
END-INFO-DIR-ENTRY
|
||||
@end format
|
||||
@end ifinfo
|
||||
@@ -58,7 +58,7 @@ END-INFO-DIR-ENTRY
|
||||
@ifinfo
|
||||
This file documents the GNU text utilities.
|
||||
|
||||
Copyright (C) 1994, 95 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -85,12 +85,12 @@ by the Foundation.
|
||||
@titlepage
|
||||
@title GNU @code{textutils}
|
||||
@subtitle A set of text utilities
|
||||
@subtitle for version @value{VERSION}, @value{RELEASEDATE}
|
||||
@subtitle for version @value{VERSION}, @value{UPDATED}
|
||||
@author David MacKenzie et al.
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1994, 95 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -145,7 +145,7 @@ involved in improving this manual. The entire GNU community will
|
||||
benefit.
|
||||
|
||||
@cindex POSIX.2
|
||||
The GNU text utilities are mostly compatible with the POSIX.2 standard.
|
||||
The GNU text utilities are mostly compatible with the @sc{POSIX.2} standard.
|
||||
|
||||
@c This paragraph appears in all of fileutils.texi, textutils.texi, and
|
||||
@c sh-utils.texi too -- so be sure to keep them consistent.
|
||||
@@ -478,9 +478,9 @@ Separate the line number from the text line in the output with
|
||||
@var{string} (default is @key{TAB}).
|
||||
|
||||
@item -v @var{number}
|
||||
@itemx --first-page=@var{number}
|
||||
@itemx --starting-line-number=@var{number}
|
||||
@opindex -v
|
||||
@opindex --first-page
|
||||
@opindex --starting-line-number
|
||||
Set the initial line number on each logical page to @var{number} (default 1).
|
||||
|
||||
@item -w @var{number}
|
||||
@@ -650,8 +650,8 @@ is not given at all, the default is 16.
|
||||
|
||||
@end table
|
||||
|
||||
The next several options map the old, pre-POSIX format specification
|
||||
options to the corresponding POSIX format specs. GNU @code{od} accepts
|
||||
The next several options map the old, pre-@sc{POSIX} format specification
|
||||
options to the corresponding @sc{POSIX} format specs. GNU @code{od} accepts
|
||||
any combination of old- and new-style options. Format specification
|
||||
options accumulate.
|
||||
|
||||
@@ -733,7 +733,7 @@ address.
|
||||
These commands reformat the contents of files.
|
||||
|
||||
@menu
|
||||
* fmt invocation:: Reformat paragraph text.
|
||||
* fmt invocation:: Reformat paragraph text.
|
||||
* pr invocation:: Paginate or columnate files for printing.
|
||||
* fold invocation:: Wrap input lines to fit in specified width.
|
||||
@end menu
|
||||
@@ -827,7 +827,7 @@ room to balance line lengths.
|
||||
@item -p @var{prefix}
|
||||
@itemx --prefix=@var{prefix}
|
||||
Only lines beginning with @var{prefix} (possibly preceded by whitespace)
|
||||
are subject to formatting. The prefix and any preceding whitespace is
|
||||
are subject to formatting. The prefix and any preceding whitespace are
|
||||
stripped for the formatting and then re-attached to each formatted output
|
||||
line. One use is to format certain kinds of program comments, while
|
||||
leaving the code unchanged.
|
||||
@@ -1259,6 +1259,10 @@ less than @var{bytes} bytes of the line are left, then continue
|
||||
normally. @var{bytes} has the same format as for the @samp{--bytes}
|
||||
option.
|
||||
|
||||
@itemx --verbose=@var{bytes}
|
||||
@opindex --verbose
|
||||
Write a diagnostic to standard error just before each output file is opened.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -1403,7 +1407,7 @@ contents of files.
|
||||
* wc invocation:: Print byte, word, and line counts.
|
||||
* sum invocation:: Print checksum and block counts.
|
||||
* cksum invocation:: Print CRC checksum and byte counts.
|
||||
* md5sum invocation:: Print or check message-digests.
|
||||
* md5sum invocation:: Print or check message-digests.
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -1535,13 +1539,13 @@ cksum [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@code{cksum} prints the CRC checksum for each file along with the number
|
||||
of bytes in the file, and the filename unless no arguments were given.
|
||||
|
||||
@code{cksum} is typically used to ensure that files have been
|
||||
@code{cksum} is typically used to ensure that files
|
||||
transferred by unreliable means (e.g., netnews) have not been corrupted,
|
||||
by comparing the @code{cksum} output for the received files with the
|
||||
@code{cksum} output for the original files (typically given in the
|
||||
distribution).
|
||||
|
||||
The CRC algorithm is specified by the POSIX.2 standard. It is not
|
||||
The CRC algorithm is specified by the @sc{POSIX.2} standard. It is not
|
||||
compatible with the BSD or System V @code{sum} algorithms (see the
|
||||
previous section); it is more robust.
|
||||
|
||||
@@ -1605,19 +1609,25 @@ one on the line with the filename, the file is noted as having
|
||||
failed the test. Otherwise, the file passes the test.
|
||||
By default, for each valid line, one line is written to standard
|
||||
output indicating whether the named file passed the test.
|
||||
After all checks have been performed, if there were any failures,
|
||||
a warning is issued to standard error.
|
||||
Use the @samp{--status} option to inhibit that output.
|
||||
If any listed file cannot be opened or read, if any valid line has
|
||||
a MD5 checksum inconsistent with the associated file, or if no valid
|
||||
line is found, exit with a non-zero status. Otherwise, exit successfully.
|
||||
an MD5 checksum inconsistent with the associated file, or if no valid
|
||||
line is found, @code{md5sum} exits with nonzero status. Otherwise,
|
||||
it exits successfully.
|
||||
|
||||
@itemx --status
|
||||
@opindex --status
|
||||
@cindex verifying MD5 checksums
|
||||
When verifying checksums, don't generate any output.
|
||||
This option is useful only when verifying checksums.
|
||||
When verifying checksums, don't generate the default one-line-per-file
|
||||
diagnostic and don't output the warning summarizing any failures.
|
||||
Failures to open or read a file still evoke individual diagnostics to
|
||||
standard error.
|
||||
If all listed files are readable and are consistent with the associated
|
||||
MD5 checksums, exit successfully. Otherwise exit with a status code
|
||||
indicating there was a failure. Failures to open or read a file still
|
||||
evoke diagnostics to standard error.
|
||||
indicating there was a failure.
|
||||
|
||||
@itemx --string=@var{string}
|
||||
@opindex --string
|
||||
@@ -1685,6 +1695,7 @@ mode:
|
||||
@cindex checking for sortedness
|
||||
Check whether the given files are already sorted: if they are not all
|
||||
sorted, print an error message and exit with a status of 1.
|
||||
Otherwise, exit successfully.
|
||||
|
||||
@item -m
|
||||
@opindex -m
|
||||
@@ -1718,6 +1729,8 @@ input line length or restrictions on bytes allowed within lines. In
|
||||
addition, if the final byte of an input file is not a newline, GNU
|
||||
@code{sort} silently supplies one.
|
||||
|
||||
Upon any error, @code{sort} exits with a status of @samp{2}.
|
||||
|
||||
@vindex TMPDIR
|
||||
If the environment variable @code{TMPDIR} is set, @code{sort} uses its
|
||||
value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@@ -1750,6 +1763,18 @@ letters, digits and blanks when sorting.
|
||||
Fold lowercase characters into the equivalent uppercase characters when
|
||||
sorting so that, for example, @samp{b} and @samp{B} sort as equal.
|
||||
|
||||
@item -g
|
||||
@opindex -g
|
||||
@cindex general numeric sort
|
||||
Sort numerically, but use strtod(3) to arrive at the numeric values.
|
||||
This allows floating point numbers to be specified in scientific notation,
|
||||
like @code{1.0e-34} and @code{10e100}. Use this option only if there
|
||||
is no alternative; it is much slower than @samp{-n} and numbers with
|
||||
too many significant digits will be compared as if they had been
|
||||
truncated. In addition, numbers outside the range of representable
|
||||
double precision floating point numbers are treated as if they were
|
||||
zeroes; overflow and underflow are not reported.
|
||||
|
||||
@item -i
|
||||
@opindex -i
|
||||
@cindex unprintable characters, ignoring
|
||||
@@ -1771,6 +1796,21 @@ Sort numerically: the number begins each line; specifically, it consists
|
||||
of optional whitespace, an optional @samp{-} sign, and zero or more
|
||||
digits, optionally followed by a decimal point and zero or more digits.
|
||||
|
||||
@code{sort -n} uses what might be considered an unconventional method
|
||||
to compare strings representing floating point numbers. Rather than
|
||||
first converting each string to the C @code{double} type and then
|
||||
comparing those values, sort aligns the decimal points in the two
|
||||
strings and compares the strings a character at a time. One benefit
|
||||
of using this approach is its speed. In practice this is much more
|
||||
efficient than performing the two corresponding string-to-double (or even
|
||||
string-to-integer) conversions and then comparing doubles. In addition,
|
||||
there is no corresponding loss of precision. Converting each string to
|
||||
@code{double} before comparison would limit precision to about 16 digits
|
||||
on most systems.
|
||||
|
||||
Neither a leading @samp{+} nor exponential notation is recognized.
|
||||
To compare such strings numerically, use the @samp{-g} option.
|
||||
|
||||
@item -r
|
||||
@opindex -r
|
||||
@cindex reverse sorting
|
||||
@@ -1812,11 +1852,21 @@ check that no pair of consecutive lines compares equal.
|
||||
@item -k @var{pos1}[,@var{pos2}]
|
||||
@opindex -k
|
||||
@cindex sort field
|
||||
The recommended, POSIX, option for specifying a sort field. The field
|
||||
The recommended, @sc{POSIX}, option for specifying a sort field. The field
|
||||
consists of the line between @var{pos1} and @var{pos2} (or the end of
|
||||
the line, if @var{pos2} is omitted), inclusive. Fields and character
|
||||
positions are numbered starting with 1. See below.
|
||||
|
||||
@item -z
|
||||
@opindex -z
|
||||
@cindex sort zero-terminated lines
|
||||
Treat the input as a set of lines, each terminated by a zero byte (@sc{ASCII}
|
||||
@sc{NUL} (Null) character) instead of a @sc{ASCII} @sc{LF} (Line Feed.)
|
||||
This option can be useful in conjunction with @samp{perl -0} or
|
||||
@samp{find -print0} and @samp{xargs -0} which do the same in order to
|
||||
reliably handle arbitrary pathnames (even those which contain Line Feed
|
||||
characters.)
|
||||
|
||||
@item +@var{pos1}[-@var{pos2}]
|
||||
The obsolete, traditional option for specifying a sort field. The field
|
||||
consists of the line between @var{pos1} and up to but @emph{not including}
|
||||
@@ -1831,9 +1881,9 @@ options}.
|
||||
|
||||
Historical (BSD and System V) implementations of @code{sort} have
|
||||
differed in their interpretation of some options, particularly
|
||||
@samp{-b}, @samp{-f}, and @samp{-n}. GNU sort follows the POSIX
|
||||
@samp{-b}, @samp{-f}, and @samp{-n}. GNU sort follows the @sc{POSIX}
|
||||
behavior, which is usually (but not always!) like the System V behavior.
|
||||
According to POSIX, @samp{-n} no longer implies @samp{-b}. For
|
||||
According to @sc{POSIX}, @samp{-n} no longer implies @samp{-b}. For
|
||||
consistency, @samp{-M} has been changed in the same way. This may
|
||||
affect the meaning of character positions in field specifications in
|
||||
obscure cases. The only fix is to add an explicit @samp{-b}.
|
||||
@@ -1861,7 +1911,7 @@ from the global options it will be attached to both. If a @samp{-n} or
|
||||
fields.
|
||||
|
||||
Here are some examples to illustrate various combinations of options.
|
||||
In them, the POSIX @samp{-k} option is used to specify sort keys rather
|
||||
In them, the @sc{POSIX} @samp{-k} option is used to specify sort keys rather
|
||||
than the obsolete @samp{+@var{pos1}-@var{pos2}} syntax.
|
||||
|
||||
@itemize @bullet
|
||||
@@ -1918,6 +1968,16 @@ An alternative is to use the global numeric modifier @samp{-n}.
|
||||
sort -t : -n -k 5b,5 -k 3,3 /etc/passwd
|
||||
@end example
|
||||
|
||||
@item
|
||||
Generate a tags file in case insensitive sorted order.
|
||||
@example
|
||||
find src -type f -print0 | sort -t / -z -f | xargs -0 etags --append
|
||||
@end example
|
||||
|
||||
The use of @samp{-print0}, @samp{-z}, and @samp{-0} in this case mean
|
||||
that pathnames that contain Line Feed characters will not get broken up
|
||||
by the sort operation.
|
||||
|
||||
Finally, to ignore both leading and trailing white space, you
|
||||
could have applied the @samp{b} modifier to the field-end specifier
|
||||
for the first key,
|
||||
@@ -1990,6 +2050,12 @@ the field and character skipping options, fields are skipped over first.
|
||||
@opindex --count
|
||||
Print the number of times each line occurred along with the line.
|
||||
|
||||
@item -i
|
||||
@itemx --ignore-case
|
||||
@opindex -i
|
||||
@opindex --ignore-case
|
||||
Ignore differences in case when comparing lines.
|
||||
|
||||
@item -d
|
||||
@itemx --repeated
|
||||
@opindex -d
|
||||
@@ -2182,7 +2248,9 @@ Either @var{file1} or @var{file2} (but not both) can be @samp{-},
|
||||
meaning standard input. @var{file1} and @var{file2} should be already
|
||||
sorted in increasing order (not numerically) on the join fields; unless
|
||||
the @samp{-t} option is given, they should be sorted ignoring blanks at
|
||||
the start of the line, as in @code{sort -b}.
|
||||
the start of the join field, as in @code{sort -b}. If the
|
||||
@samp{--ignore-case} option is given, lines should be sorted without
|
||||
regard to the case of characters in the join field, as in @code{sort -f}.
|
||||
|
||||
The defaults are: the join field is the first field in each line;
|
||||
fields in the input are separated by one or more blanks, with leading
|
||||
@@ -2204,6 +2272,14 @@ Print a line for each unpairable line in file @var{file-number} (either
|
||||
Replace those output fields that are missing in the input with
|
||||
@var{string}.
|
||||
|
||||
@item -i
|
||||
@itemx --ignore-case
|
||||
@opindex -i
|
||||
@opindex --ignore-case
|
||||
Ignore differences in case when comparing keys.
|
||||
With this option, the lines of the input files must be ordered in the same way.
|
||||
Use @samp{sort -f} to produce this ordering.
|
||||
|
||||
@item -1 @var{field}
|
||||
@itemx -j1 @var{field}
|
||||
@opindex -1
|
||||
@@ -2221,9 +2297,22 @@ Equivalent to @samp{-1 @var{field} -2 @var{field}}.
|
||||
|
||||
@item -o @var{field-list}@dots{}
|
||||
Construct each output line according to the format in @var{field-list}.
|
||||
Each element in @var{field-list} consists of a file number (either 1 or
|
||||
2), a period, and a field number (a positive integer). The elements in
|
||||
the list are separated by commas or blanks. Multiple @var{field-list}
|
||||
Each element in @var{field-list} is either the single character @samp{0} or
|
||||
has the form @var{m.n} where the file number, @var{m}, is @samp{1} or
|
||||
@samp{2} and @var{n} is a positive field number.
|
||||
|
||||
A field specification of @samp{0} denotes the join field.
|
||||
In most cases, the functionality of the @samp{0} field spec
|
||||
may be reproduced using the explicit @var{m.n} that corresponds
|
||||
to the join field. However, when printing unpairable lines
|
||||
(using either of the @samp{-a} or @samp{-v} options), there is no way
|
||||
to specify the join field using @var{m.n} in @var{field-list}
|
||||
if there are unpairable lines in both files.
|
||||
To give @code{join} that functionality, @sc{POSIX} invented the @samp{0}
|
||||
field specification notation.
|
||||
|
||||
The elements in @var{field-list}
|
||||
are separated by commas or blanks. Multiple @var{field-list}
|
||||
arguments can be given after a single @samp{-o} option; the values
|
||||
of all lists given with @samp{-o} are concatenated together.
|
||||
All output lines -- including those printed because of any -a or -v
|
||||
@@ -2234,7 +2323,7 @@ Use character @var{char} as the input and output field separator.
|
||||
|
||||
@item -v @var{file-number}
|
||||
Print a line for each unpairable line in file @var{file-number}
|
||||
(either 1 or 2), instead of the normal output.
|
||||
(either @samp{1} or @samp{2}), instead of the normal output.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -2462,7 +2551,7 @@ typically have the same length. If @var{set1} is shorter than
|
||||
@var{set2}, the extra characters at the end of @var{set2} are ignored.
|
||||
|
||||
On the other hand, making @var{set1} longer than @var{set2} is not
|
||||
portable; POSIX.2 says that the result is undefined. In this situation,
|
||||
portable; @sc{POSIX.2} says that the result is undefined. In this situation,
|
||||
BSD @code{tr} pads @var{set2} to the length of @var{set1} by repeating
|
||||
the last character of @var{set2} as many times as necessary. System V
|
||||
@code{tr} truncates @var{set1} to the length of @var{set2}.
|
||||
@@ -2542,7 +2631,7 @@ tr -s '\n'
|
||||
@vindex POSIXLY_CORRECT
|
||||
Setting the environment variable @code{POSIXLY_CORRECT} turns off the
|
||||
following warning and error messages, for strict compliance with
|
||||
POSIX.2. Otherwise, the following diagnostics are issued:
|
||||
@sc{POSIX.2}. Otherwise, the following diagnostics are issued:
|
||||
|
||||
@enumerate
|
||||
|
||||
@@ -2550,7 +2639,7 @@ POSIX.2. Otherwise, the following diagnostics are issued:
|
||||
When the @samp{--delete} option is given but @samp{--squeeze-repeats}
|
||||
is not, and @var{set2} is given, GNU @code{tr} by default prints
|
||||
a usage message and exits, because @var{set2} would not be used.
|
||||
The POSIX specification says that @var{set2} must be ignored in
|
||||
The @sc{POSIX} specification says that @var{set2} must be ignored in
|
||||
this case. Silently ignoring arguments is a bad idea.
|
||||
|
||||
@item
|
||||
@@ -2561,7 +2650,7 @@ value 400 octal does not fit into a single byte.
|
||||
@end enumerate
|
||||
|
||||
GNU @code{tr} does not provide complete BSD or System V compatibility.
|
||||
For example, it is impossible to disable interpretation of the POSIX
|
||||
For example, it is impossible to disable interpretation of the @sc{POSIX}
|
||||
constructs @samp{[:alpha:]}, @samp{[=c=]}, and @samp{[c*10]}. Also, GNU
|
||||
@code{tr} does not delete zero bytes automatically, unlike traditional
|
||||
Unix versions, which provide no way to preserve zero bytes.
|
||||
@@ -2665,8 +2754,8 @@ ones, to tabs.
|
||||
@end table
|
||||
|
||||
|
||||
@c What's GNU?
|
||||
@c Arnold Robbins
|
||||
@c What's GNU?
|
||||
@c Arnold Robbins
|
||||
@node Opening the software toolbox
|
||||
@chapter Opening the software toolbox
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@ safe-stat.c
|
||||
safe-lstat.c
|
||||
safe-lstat.h
|
||||
getdate.tab.c
|
||||
.deps
|
||||
|
||||
43
lib/Makefile.am
Normal file
43
lib/Makefile.am
Normal file
@@ -0,0 +1,43 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
noinst_LIBRARIES = fu
|
||||
|
||||
EXTRA_DIST = alloca.c basename.c euidaccess.c fnmatch.c fsusage.c \
|
||||
ftruncate.c getdate.y getopt.c getopt1.c group-member.c \
|
||||
memcmp.c memcpy.c memset.c \
|
||||
mkdir.c mktime.c mountlist.c posixtm.y rename.c rmdir.c \
|
||||
stpcpy.c strcasecmp.c strdup.c strndup.c strstr.c strtol.c strtoul.c
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir)
|
||||
|
||||
fu_SOURCES = getdate.c getline.c posixtm.c argmatch.c backupfile.c \
|
||||
dirname.c error.c fileblocks.c filemode.c \
|
||||
full-write.c getversion.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c obstack.c \
|
||||
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
fu_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
|
||||
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
|
||||
mountlist.h obstack.h pathmax.h save-cwd.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
|
||||
# Since this directory contains two parsers, we have to be careful to avoid
|
||||
# running two $(YACC)s during parallel makes. See below.
|
||||
getdate.c: @MAINT@getdate.y
|
||||
@echo expect 10 shift/reduce conflicts
|
||||
$(YACC) $(srcdir)/getdate.y
|
||||
mv y.tab.c getdate.c
|
||||
|
||||
# Make the rename atomic, in case sed is interrupted and later rerun.
|
||||
# The artificial dependency on getdate.c keeps the two parsers from being
|
||||
# built in parallel. Enforcing this little bit of sequentiality lets
|
||||
# everyone (even those without bison) still run mostly parallel builds.
|
||||
posixtm.c: @MAINT@posixtm.y getdate.c
|
||||
$(YACC) $(srcdir)/posixtm.y
|
||||
mv y.tab.c posixtm.tab.c
|
||||
sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c
|
||||
mv tposixtm.c posixtm.c
|
||||
rm -f posixtm.tab.c
|
||||
375
lib/Makefile.in
375
lib/Makefile.in
@@ -1,110 +1,284 @@
|
||||
# Makefile for library files used by GNU file utilities.
|
||||
# Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
# Makefile.in generated automatically by automake 1.0 from Makefile.am
|
||||
|
||||
# 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.
|
||||
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy, distribute and modify it.
|
||||
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
noinst_LIBRARIES = fu
|
||||
|
||||
EXTRA_DIST = alloca.c basename.c euidaccess.c fnmatch.c fsusage.c \
|
||||
ftruncate.c getdate.y getopt.c getopt1.c group-member.c \
|
||||
memcmp.c memcpy.c memset.c \
|
||||
mkdir.c mktime.c mountlist.c posixtm.y rename.c rmdir.c \
|
||||
stpcpy.c strcasecmp.c strdup.c strndup.c strstr.c strtol.c strtoul.c
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir)
|
||||
|
||||
fu_SOURCES = getdate.c getline.c posixtm.c argmatch.c backupfile.c \
|
||||
dirname.c error.c fileblocks.c filemode.c \
|
||||
full-write.c getversion.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c obstack.c \
|
||||
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
fu_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
|
||||
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
|
||||
mountlist.h obstack.h pathmax.h save-cwd.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
mkinstalldirs = $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
|
||||
noinst_LIBFILES = libfu.a
|
||||
|
||||
CC = @CC@
|
||||
AR = ar
|
||||
RANLIB = @RANLIB@
|
||||
DEFS = @DEFS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LEX = @LEX@
|
||||
YACC = @YACC@
|
||||
|
||||
exec_prefix = @exec_prefix@
|
||||
libdir = $(exec_prefix)/lib
|
||||
|
||||
SOURCES = getdate.y posixtm.y \
|
||||
argmatch.c backupfile.c basename.c dirname.c euidaccess.c \
|
||||
error.c filemode.c fsusage.c full-write.c getopt.c getopt1.c \
|
||||
getversion.c group-member.c idcache.c isdir.c makepath.c \
|
||||
modechange.c mountlist.c obstack.c safe-read.c savedir.c \
|
||||
stripslash.c xgetcwd.c xmalloc.c xstrdup.c userspec.c yesno.c \
|
||||
fileblocks.c fnmatch.c ftruncate.c mkdir.c mktime.c rename.c rmdir.c \
|
||||
save-cwd.c stpcpy.c \
|
||||
strdup.c strstr.c strtol.c strtoul.c alloca.c long-options.c \
|
||||
memcmp.c memcpy.c memset.c xstrtol.c xstrtoul.c
|
||||
|
||||
OBJECTS = getdate.o posixtm.o \
|
||||
argmatch.o backupfile.o basename.o dirname.o \
|
||||
error.o filemode.o full-write.o getopt.o getopt1.o \
|
||||
getversion.o group-member.o idcache.o isdir.o long-options.o makepath.o \
|
||||
modechange.o obstack.o safe-read.o save-cwd.o savedir.o \
|
||||
stripslash.o xgetcwd.o xmalloc.o xstrdup.o userspec.o yesno.o \
|
||||
xstrtol.o xstrtoul.o @LIBOBJS@ @ALLOCA@
|
||||
|
||||
DISTFILES = Makefile.in backupfile.h getopt.h long-options.h modechange.h \
|
||||
fnmatch.h fsusage.h group-member.h makepath.h mountlist.h obstack.h pathmax.h \
|
||||
save-cwd.h getdate.c posixtm.c error.h xstrtol.h xstrtoul.h $(SOURCES)
|
||||
|
||||
all: libfu.a
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
INCLUDES = -I.. -I$(srcdir)
|
||||
LINK = $(CC) $(LDFLAGS) -o $@
|
||||
fu_OBJECTS = getdate.o getline.o posixtm.o argmatch.o backupfile.o \
|
||||
dirname.o error.o fileblocks.o filemode.o full-write.o getversion.o \
|
||||
idcache.o isdir.o long-options.o makepath.o modechange.o obstack.o \
|
||||
safe-read.o save-cwd.o savedir.o stripslash.o userspec.o xgetcwd.o \
|
||||
xmalloc.o xstrdup.o xstrtol.o xstrtoul.o yesno.o
|
||||
EXTRA_fu_SOURCES =
|
||||
LIBFILES = libfu.a
|
||||
AR = ar
|
||||
RANLIB = @RANLIB@
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
|
||||
$(TEXINFOS) $(INFOS) $(MANS) $(EXTRA_DIST) $(DATA)
|
||||
DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
|
||||
$(TEXINFOS) $(INFO_DEPS) $(MANS) $(EXTRA_DIST) $(DATA)
|
||||
|
||||
TAR = tar
|
||||
DEP_FILES = $(srcdir)/.deps/alloca.P $(srcdir)/.deps/argmatch.P \
|
||||
$(srcdir)/.deps/backupfile.P $(srcdir)/.deps/dirname.P \
|
||||
$(srcdir)/.deps/error.P $(srcdir)/.deps/fileblocks.P \
|
||||
$(srcdir)/.deps/filemode.P $(srcdir)/.deps/fnmatch.P \
|
||||
$(srcdir)/.deps/fsusage.P $(srcdir)/.deps/ftruncate.P \
|
||||
$(srcdir)/.deps/full-write.P $(srcdir)/.deps/getdate.P \
|
||||
$(srcdir)/.deps/getline.P $(srcdir)/.deps/getopt.P \
|
||||
$(srcdir)/.deps/getopt1.P $(srcdir)/.deps/getversion.P \
|
||||
$(srcdir)/.deps/idcache.P $(srcdir)/.deps/isdir.P \
|
||||
$(srcdir)/.deps/long-options.P $(srcdir)/.deps/makepath.P \
|
||||
$(srcdir)/.deps/modechange.P $(srcdir)/.deps/mountlist.P \
|
||||
$(srcdir)/.deps/obstack.P $(srcdir)/.deps/posixtm.P \
|
||||
$(srcdir)/.deps/safe-read.P $(srcdir)/.deps/save-cwd.P \
|
||||
$(srcdir)/.deps/savedir.P $(srcdir)/.deps/stripslash.P \
|
||||
$(srcdir)/.deps/userspec.P $(srcdir)/.deps/xgetcwd.P \
|
||||
$(srcdir)/.deps/xmalloc.P $(srcdir)/.deps/xstrdup.P \
|
||||
$(srcdir)/.deps/xstrtol.P $(srcdir)/.deps/xstrtoul.P \
|
||||
$(srcdir)/.deps/yesno.P
|
||||
SOURCES = $(fu_SOURCES)
|
||||
OBJECTS = $(fu_OBJECTS)
|
||||
|
||||
default: all
|
||||
|
||||
|
||||
$(srcdir)/Makefile.in: @MAINT@Makefile.am $(top_srcdir)/configure.in
|
||||
cd $(top_srcdir) && automake $(subdir)/Makefile
|
||||
|
||||
Makefile: $(top_builddir)/config.status Makefile.in
|
||||
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
|
||||
|
||||
mostlyclean-noinstLIBRARIES:
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
rm -f $(noinst_LIBFILES)
|
||||
|
||||
distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) $<
|
||||
|
||||
mostlyclean-compile:
|
||||
rm -f *.o core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
$(fu_OBJECTS): ../config.h
|
||||
|
||||
libfu.a: $(fu_OBJECTS) $(fu_LIBADD)
|
||||
rm -f libfu.a
|
||||
$(AR) cru libfu.a $(fu_OBJECTS) $(fu_LIBADD)
|
||||
$(RANLIB) libfu.a
|
||||
|
||||
ID: $(HEADERS) $(SOURCES)
|
||||
here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES)
|
||||
here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
subdir = lib
|
||||
Makefile: ../config.status Makefile.in
|
||||
cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
|
||||
|
||||
installdirs:
|
||||
|
||||
install install-exec install-data: all
|
||||
|
||||
uninstall:
|
||||
|
||||
TAGS: $(SOURCES)
|
||||
etags $(SOURCES)
|
||||
|
||||
check:
|
||||
|
||||
clean:
|
||||
rm -f *.a *.o
|
||||
|
||||
mostlyclean: clean
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *.tab.c tposixtm.c
|
||||
rm -rf .deps
|
||||
|
||||
maintainer-clean: distclean
|
||||
rm -f TAGS getdate.c posixtm.c
|
||||
|
||||
distdir = ../`cat ../distname`/$(subdir)
|
||||
dist: $(DISTFILES)
|
||||
for file in $(DISTFILES); do \
|
||||
ln $$file $(distdir) \
|
||||
|| { echo copying $$file instead; cp -p $$file $(distdir);}; \
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
distdir: $(DEP_DISTFILES)
|
||||
@for file in `cd $(srcdir) && echo $(DISTFILES)`; do \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \
|
||||
done
|
||||
|
||||
libfu.a: $(OBJECTS)
|
||||
rm -f $@
|
||||
$(AR) cr $@ $(OBJECTS)
|
||||
-$(RANLIB) $@
|
||||
# This fragment is probably only useful for maintainers. It relies on
|
||||
# GNU make and gcc. It is only included in the generated Makefile.in
|
||||
# if `automake' is not passed the `--include-deps' flag.
|
||||
|
||||
MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
-include $(srcdir)/.deps/.P
|
||||
$(srcdir)/.deps/.P: $(BUILT_SOURCES)
|
||||
cd $(srcdir) && test -d .deps || mkdir .deps
|
||||
echo > $@
|
||||
|
||||
-include $(DEP_FILES)
|
||||
$(DEP_FILES): $(srcdir)/.deps/.P
|
||||
|
||||
$(srcdir)/.deps/%.P: $(srcdir)/%.c
|
||||
@echo "mkdeps $< > $@"
|
||||
@re=`echo 's,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g' | sed 's,\.,\\\\.,g'`; \
|
||||
$(MKDEP) $< | sed "$$re" > $@-tmp
|
||||
@if test -n "$o"; then \
|
||||
sed 's/\.o:/$$o:/' $@-tmp > $@; \
|
||||
rm $@-tmp; \
|
||||
else \
|
||||
mv $@-tmp $@; \
|
||||
fi
|
||||
|
||||
# End of maintainer-only section
|
||||
info:
|
||||
|
||||
dvi:
|
||||
|
||||
check: all
|
||||
|
||||
installcheck:
|
||||
|
||||
install-exec:
|
||||
|
||||
install-data:
|
||||
|
||||
install: install-exec install-data all
|
||||
@:
|
||||
|
||||
uninstall:
|
||||
|
||||
all: $(LIBFILES) $(HEADERS) Makefile
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
rm -f Makefile $(DISTCLEANFILES)
|
||||
rm -f config.cache config.log $(CONFIG_HEADER) stamp-h
|
||||
|
||||
maintainer-clean-generic:
|
||||
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-generic
|
||||
|
||||
clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean
|
||||
|
||||
distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \
|
||||
distclean-generic clean
|
||||
rm -f config.status
|
||||
|
||||
maintainer-clean: maintainer-clean-noinstLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
.PHONY: default mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
|
||||
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
|
||||
clean-tags maintainer-clean-tags distdir info dvi check installcheck \
|
||||
install-exec install-data install uninstall all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Since this directory contains two parsers, we have to be careful to avoid
|
||||
# running two $(YACC)s during parallel makes. See below.
|
||||
getdate.c: getdate.y
|
||||
getdate.c: @MAINT@getdate.y
|
||||
@echo expect 10 shift/reduce conflicts
|
||||
$(YACC) $(srcdir)/getdate.y
|
||||
mv y.tab.c getdate.c
|
||||
@@ -113,38 +287,15 @@ getdate.c: getdate.y
|
||||
# The artificial dependency on getdate.c keeps the two parsers from being
|
||||
# built in parallel. Enforcing this little bit of sequentiality lets
|
||||
# everyone (even those without bison) still run mostly parallel builds.
|
||||
posixtm.c: posixtm.y getdate.c
|
||||
posixtm.c: @MAINT@posixtm.y getdate.c
|
||||
$(YACC) $(srcdir)/posixtm.y
|
||||
mv y.tab.c posixtm.tab.c
|
||||
sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c
|
||||
mv tposixtm.c posixtm.c
|
||||
rm -f posixtm.tab.c
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
rename.o: rename.c
|
||||
$(CC) -c $(CPPFLAGS) -DMVDIR="\"$(libdir)/mvdir\"" $(DEFS) \
|
||||
-I.. -I$(srcdir) $(CFLAGS) $(srcdir)/rename.c
|
||||
|
||||
$(OBJECTS): ../config.h
|
||||
|
||||
backupfile.o getversion.o: backupfile.h
|
||||
fnmatch.o: fnmatch.h
|
||||
fsusage.o: fsusage.h
|
||||
getopt1.o: getopt.h
|
||||
modechange.o: modechange.h
|
||||
mountlist.o: mountlist.h
|
||||
xgetcwd.o: pathmax.h
|
||||
makepath.o: makepath.h
|
||||
obstack.o: obstack.h
|
||||
group-member.o: group-member.h
|
||||
|
||||
.PHONY: all check clean dist distclean install install-data install-exec \
|
||||
installdirs maintainer-clean mostlyclean uninstall
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
# The following include directive is uncommented automatically
|
||||
# when this package is configured with the --with-autodep option.
|
||||
# You need GNU make and a C compiler that can generate dependencies.
|
||||
@AUTODEP_COMMENT@include @top_srcdir@/mkdep-Makefile
|
||||
|
||||
@@ -37,8 +37,8 @@ extern char *program_name;
|
||||
|
||||
int
|
||||
argmatch (arg, optlist)
|
||||
char *arg;
|
||||
char **optlist;
|
||||
const char *arg;
|
||||
const char *const *optlist;
|
||||
{
|
||||
int i; /* Temporary index in OPTLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
@@ -76,8 +76,8 @@ argmatch (arg, optlist)
|
||||
|
||||
void
|
||||
invalid_arg (kind, value, problem)
|
||||
char *kind;
|
||||
char *value;
|
||||
const char *kind;
|
||||
const char *value;
|
||||
int problem;
|
||||
{
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
|
||||
18
lib/argmatch.h
Normal file
18
lib/argmatch.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ARGMATCH_H
|
||||
#define ARGMATCH_H 1
|
||||
|
||||
#ifndef __P
|
||||
# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
# define __P(args) args
|
||||
# else
|
||||
# define __P(args) ()
|
||||
# endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
int
|
||||
argmatch __P ((const char *arg, const char *const *optlist));
|
||||
|
||||
void
|
||||
invalid_arg __P ((const char *kind, const char *value, int problem));
|
||||
|
||||
#endif /* ARGMATCH_H */
|
||||
@@ -63,12 +63,12 @@ char *malloc ();
|
||||
#endif
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define ISASCII(c) 1
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define ISASCII(c) isascii(c)
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define ISDIGIT(c) (ISASCII ((unsigned char) (c)) \
|
||||
#define ISDIGIT(c) (IN_CTYPE_DOMAIN ((unsigned char) (c)) \
|
||||
&& isdigit ((unsigned char) (c)))
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
@@ -105,7 +105,7 @@ static int version_number ();
|
||||
|
||||
char *
|
||||
find_backup_file_name (file)
|
||||
char *file;
|
||||
const char *file;
|
||||
{
|
||||
char *dir;
|
||||
char *base_versions;
|
||||
@@ -137,13 +137,14 @@ find_backup_file_name (file)
|
||||
|
||||
static int
|
||||
max_backup_version (file, dir)
|
||||
char *file, *dir;
|
||||
const char *file;
|
||||
const char *dir;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
int highest_version;
|
||||
int this_version;
|
||||
int file_name_length;
|
||||
size_t file_name_length;
|
||||
|
||||
dirp = opendir (dir);
|
||||
if (!dirp)
|
||||
@@ -171,7 +172,7 @@ max_backup_version (file, dir)
|
||||
|
||||
static char *
|
||||
make_version_name (file, version)
|
||||
char *file;
|
||||
const char *file;
|
||||
int version;
|
||||
{
|
||||
char *backup_name;
|
||||
@@ -189,12 +190,12 @@ make_version_name (file, version)
|
||||
|
||||
static int
|
||||
version_number (base, backup, base_length)
|
||||
char *base;
|
||||
char *backup;
|
||||
const char *base;
|
||||
const char *backup;
|
||||
int base_length;
|
||||
{
|
||||
int version;
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
version = 0;
|
||||
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
|
||||
@@ -212,7 +213,8 @@ version_number (base, backup, base_length)
|
||||
|
||||
static char *
|
||||
concat (str1, str2)
|
||||
char *str1, *str2;
|
||||
const char *str1;
|
||||
const char *str2;
|
||||
{
|
||||
char *newstr;
|
||||
int str1_length = strlen (str1);
|
||||
|
||||
@@ -36,7 +36,7 @@ extern enum backup_type backup_type;
|
||||
extern char *simple_backup_suffix;
|
||||
|
||||
#ifdef __STDC__
|
||||
char *find_backup_file_name (char *file);
|
||||
char *find_backup_file_name (const char *file);
|
||||
#else
|
||||
char *find_backup_file_name ();
|
||||
#endif
|
||||
|
||||
@@ -19,23 +19,20 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#ifndef strrchr
|
||||
#define strrchr rindex
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Return NAME with any leading path stripped off. */
|
||||
/* Return NAME with any leading path stripped off.
|
||||
Don't use strrchr/rindex. */
|
||||
|
||||
char *
|
||||
basename (name)
|
||||
const char *name;
|
||||
{
|
||||
char *base;
|
||||
const char *base = name;
|
||||
|
||||
base = strrchr (name, '/');
|
||||
return base ? base + 1 : (char *) name;
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '/')
|
||||
base = name + 1;
|
||||
++name;
|
||||
}
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
80
lib/canon-host.c
Normal file
80
lib/canon-host.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/* Host name canonicalization
|
||||
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
|
||||
Written by Miles Bader <miles@gnu.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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
/* Returns the canonical hostname associated with HOST (allocated in a static
|
||||
buffer), or 0 if it can't be determined. */
|
||||
char *
|
||||
canon_host (host)
|
||||
char *host;
|
||||
{
|
||||
#ifdef HAVE_GETHOSTBYNAME
|
||||
struct hostent *he = gethostbyname (host);
|
||||
|
||||
if (he)
|
||||
{
|
||||
#ifdef HAVE_GETHOSTBYADDR
|
||||
char *addr = 0;
|
||||
|
||||
/* Try and get an ascii version of the numeric host address. */
|
||||
switch (he->h_addrtype)
|
||||
{
|
||||
#ifdef HAVE_INET_NTOA
|
||||
case AF_INET:
|
||||
addr = inet_ntoa (*(struct in_addr *) he->h_addr);
|
||||
break;
|
||||
#endif /* HAVE_INET_NTOA */
|
||||
}
|
||||
|
||||
if (addr && strcmp (he->h_name, addr) == 0)
|
||||
/* gethostbyname() cheated! Lookup the host name via the address
|
||||
this time to get the actual host name. */
|
||||
he = gethostbyaddr (he->h_addr, he->h_length, he->h_addrtype);
|
||||
#endif /* HAVE_GETHOSTBYADDR */
|
||||
|
||||
if (he)
|
||||
return (char *) (he->h_name);
|
||||
}
|
||||
#endif /* HAVE_GETHOSTBYNAME */
|
||||
return 0;
|
||||
}
|
||||
138
lib/error.c
138
lib/error.c
@@ -1,29 +1,29 @@
|
||||
/* error.c -- error handler for noninteractive utilities
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 96 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 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.
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||
# if __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(args, lastarg) va_start(args, lastarg)
|
||||
@@ -36,30 +36,46 @@
|
||||
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS
|
||||
#if STDC_HEADERS || _LIBC
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
void exit ();
|
||||
#endif
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) () = NULL;
|
||||
void (*error_print_progname) (
|
||||
#if __STDC__ - 0
|
||||
void
|
||||
#endif
|
||||
);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
|
||||
#else
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
#if HAVE_STRERROR
|
||||
# ifndef strerror /* On some systems, strerror is a macro */
|
||||
# if HAVE_STRERROR
|
||||
# ifndef strerror /* On some systems, strerror is a macro */
|
||||
char *strerror ();
|
||||
# endif
|
||||
#else
|
||||
# endif
|
||||
# else
|
||||
static char *
|
||||
private_strerror (errnum)
|
||||
int errnum;
|
||||
@@ -69,10 +85,11 @@ private_strerror (errnum)
|
||||
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return sys_errlist[errnum];
|
||||
return "Unknown system error";
|
||||
return _("Unknown system error");
|
||||
}
|
||||
#define strerror private_strerror
|
||||
#endif
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
#endif /* _LIBC */
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
@@ -105,7 +122,75 @@ error (status, errnum, message, va_alist)
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
# if HAVE_VPRINTF
|
||||
# if HAVE_VPRINTF || _LIBC
|
||||
vfprintf (stderr, message, args);
|
||||
# else
|
||||
_doprnt (message, args, stderr);
|
||||
# endif
|
||||
va_end (args);
|
||||
#else
|
||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
#endif
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
#if defined(VA_START) && __STDC__
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
#else
|
||||
error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
int status;
|
||||
int errnum;
|
||||
const char *file_name;
|
||||
unsigned int line_number;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number &&
|
||||
(file_name == old_file_name || !strcmp (old_file_name, file_name)))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
fflush (stdout);
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
}
|
||||
|
||||
if (file_name != NULL)
|
||||
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
# if HAVE_VPRINTF || _LIBC
|
||||
vfprintf (stderr, message, args);
|
||||
# else
|
||||
_doprnt (message, args, stderr);
|
||||
@@ -116,7 +201,6 @@ error (status, errnum, message, va_alist)
|
||||
#endif
|
||||
|
||||
++error_message_count;
|
||||
|
||||
if (errnum)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
putc ('\n', stderr);
|
||||
|
||||
51
lib/error.h
51
lib/error.h
@@ -1,19 +1,19 @@
|
||||
/* error.h -- declaration for error-reporting function
|
||||
Copyright (C) 1995 Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996 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 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.
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _error_h_
|
||||
#define _error_h_
|
||||
@@ -31,14 +31,35 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __STDC__
|
||||
void error (int, int, const char *, ...) \
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
#if defined (__STDC__) && __STDC__
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int status, int errnum, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int status, int errnum, const char *fname,
|
||||
unsigned int lineno, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
#else
|
||||
void error ();
|
||||
void error_at_line ();
|
||||
extern void (*error_print_progname) ();
|
||||
#endif
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#endif /* _error_h_ */
|
||||
|
||||
@@ -22,44 +22,44 @@ Cambridge, MA 02139, USA. */
|
||||
Adapted for GNU C library by Roland McGrath. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef S_IEXEC
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR S_IEXEC
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
#define S_IXGRP (S_IEXEC >> 3)
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
#define S_IXOTH (S_IEXEC >> 6)
|
||||
#endif
|
||||
# ifndef S_IXUSR
|
||||
# define S_IXUSR S_IEXEC
|
||||
# endif
|
||||
# ifndef S_IXGRP
|
||||
# define S_IXGRP (S_IEXEC >> 3)
|
||||
# endif
|
||||
# ifndef S_IXOTH
|
||||
# define S_IXOTH (S_IEXEC >> 6)
|
||||
# endif
|
||||
#endif /* S_IEXEC */
|
||||
|
||||
#if defined (HAVE_UNISTD_H) || defined (_LIBC)
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#include <limits.h>
|
||||
#if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1
|
||||
#undef NGROUPS_MAX
|
||||
#define NGROUPS_MAX sysconf (_SC_NGROUPS_MAX)
|
||||
#endif /* NGROUPS_MAX */
|
||||
# include <limits.h>
|
||||
# if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1
|
||||
# undef NGROUPS_MAX
|
||||
# define NGROUPS_MAX sysconf (_SC_NGROUPS_MAX)
|
||||
# endif /* NGROUPS_MAX */
|
||||
|
||||
#else /* not _POSIX_VERSION */
|
||||
uid_t getuid ();
|
||||
gid_t getgid ();
|
||||
uid_t geteuid ();
|
||||
gid_t getegid ();
|
||||
#include <sys/param.h>
|
||||
#if !defined(NGROUPS_MAX) && defined(NGROUPS)
|
||||
#define NGROUPS_MAX NGROUPS
|
||||
#endif /* not NGROUPS_MAX and NGROUPS */
|
||||
# include <sys/param.h>
|
||||
# if !defined(NGROUPS_MAX) && defined(NGROUPS)
|
||||
# define NGROUPS_MAX NGROUPS
|
||||
# endif /* not NGROUPS_MAX and NGROUPS */
|
||||
#endif /* not POSIX_VERSION */
|
||||
|
||||
#include <errno.h>
|
||||
@@ -68,20 +68,31 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined(EACCES) && !defined(EACCESS)
|
||||
#define EACCESS EACCES
|
||||
# define EACCESS EACCES
|
||||
#endif
|
||||
|
||||
#ifndef F_OK
|
||||
#define F_OK 0
|
||||
#define X_OK 1
|
||||
#define W_OK 2
|
||||
#define R_OK 4
|
||||
# define F_OK 0
|
||||
# define X_OK 1
|
||||
# define W_OK 2
|
||||
# define R_OK 4
|
||||
#endif
|
||||
|
||||
#if !defined (S_IROTH) && defined (R_OK)
|
||||
# define S_IROTH R_OK
|
||||
#endif
|
||||
|
||||
#if !defined (S_IWOTH) && defined (W_OK)
|
||||
# define S_IWOTH W_OK
|
||||
#endif
|
||||
|
||||
#if !defined (S_IXOTH) && defined (X_OK)
|
||||
# define S_IXOTH X_OK
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
|
||||
#define group_member __group_member
|
||||
# define group_member __group_member
|
||||
|
||||
#else
|
||||
|
||||
@@ -100,11 +111,11 @@ static gid_t egid;
|
||||
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
|
||||
static int have_ids = 0;
|
||||
|
||||
#ifdef HAVE_GETGROUPS
|
||||
# ifdef HAVE_GETGROUPS
|
||||
int group_member ();
|
||||
#else
|
||||
#define group_member(gid) 0
|
||||
#endif
|
||||
# else
|
||||
# define group_member(gid) 0
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,26 +18,26 @@
|
||||
/* Written by Brian L. Matthews, blm@6sceng.UUCP. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_VERSION)
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/param.h>
|
||||
|
||||
#ifndef NINDIR
|
||||
# ifndef NINDIR
|
||||
/* Some SysV's, like Irix, seem to lack these. Hope they're correct. */
|
||||
/* Size of a indirect block, in bytes. */
|
||||
#ifndef BSIZE
|
||||
#define BSIZE 1024
|
||||
#endif
|
||||
# ifndef BSIZE
|
||||
# define BSIZE 1024
|
||||
# endif
|
||||
|
||||
/* Number of inode pointers per indirect block. */
|
||||
#define NINDIR (BSIZE/sizeof(daddr_t))
|
||||
#endif /* !NINDIR */
|
||||
# define NINDIR (BSIZE/sizeof(daddr_t))
|
||||
# endif /* !NINDIR */
|
||||
|
||||
/* Number of direct block addresses in an inode. */
|
||||
#define NDIR 10
|
||||
# define NDIR 10
|
||||
|
||||
/* Return the number of 512-byte blocks in a file of SIZE bytes. */
|
||||
|
||||
@@ -63,4 +63,8 @@ st_blocks (size)
|
||||
|
||||
return datablks + indrblks;
|
||||
}
|
||||
#else
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
extern int textutils_fileblocks_unused;
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ int statfs ();
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FILSYS_H
|
||||
#if defined(HAVE_SYS_FILSYS_H) && !defined(_CRAY)
|
||||
#include <sys/filsys.h> /* SVR2. */
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,8 @@ adjust_blocks (blocks, fromsize, tosize)
|
||||
|
||||
int
|
||||
get_fs_usage (path, disk, fsp)
|
||||
char *path, *disk;
|
||||
const char *path;
|
||||
const char *disk;
|
||||
struct fs_usage *fsp;
|
||||
{
|
||||
#if defined (STAT_STATFS3_OSF1)
|
||||
|
||||
@@ -25,8 +25,13 @@ struct fs_usage
|
||||
long fsu_ffree; /* Free file nodes. */
|
||||
};
|
||||
|
||||
#if __STDC__
|
||||
int get_fs_usage (char *path, char *disk, struct fs_usage *fsp);
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
#define __P(args) args
|
||||
#else
|
||||
int get_fs_usage ();
|
||||
#endif
|
||||
#define __P(args) ()
|
||||
#endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
int get_fs_usage __P ((const char *path, const char *disk,
|
||||
struct fs_usage *fsp));
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
|
||||
#ifdef FORCE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Since the code of getdate.y is not included in the Emacs executable
|
||||
@@ -90,6 +94,7 @@ static int yylex ();
|
||||
static int yyerror ();
|
||||
|
||||
#define EPOCH 1970
|
||||
#define DOOMSDAY 2038
|
||||
#define HOUR(x) ((time_t)(x) * 60)
|
||||
#define SECSPERDAY (24L * 60L * 60L)
|
||||
|
||||
@@ -242,7 +247,7 @@ day : tDAY {
|
||||
yyDayOrdinal = 1;
|
||||
yyDayNumber = $1;
|
||||
}
|
||||
| tUNUMBER tDAY { /* FIXME */
|
||||
| tUNUMBER tDAY {
|
||||
yyDayOrdinal = $1;
|
||||
yyDayNumber = $2;
|
||||
}
|
||||
@@ -279,7 +284,6 @@ date : tUNUMBER '/' tUNUMBER {
|
||||
yyYear = $4;
|
||||
}
|
||||
| tUNUMBER tMONTH {
|
||||
/* FIXME: `date -d 'next october'' is interpreted as 2 october. */
|
||||
yyMonth = $2;
|
||||
yyDay = $1;
|
||||
}
|
||||
@@ -315,10 +319,10 @@ relunit : tUNUMBER tMINUTE_UNIT {
|
||||
| tSEC_UNIT {
|
||||
yyRelSeconds++;
|
||||
}
|
||||
| tSNUMBER tMONTH_UNIT { /* FIXME */
|
||||
| tSNUMBER tMONTH_UNIT {
|
||||
yyRelMonth += $1 * $2;
|
||||
}
|
||||
| tUNUMBER tMONTH_UNIT { /* FIXME */
|
||||
| tUNUMBER tMONTH_UNIT {
|
||||
yyRelMonth += $1 * $2;
|
||||
}
|
||||
| tMONTH_UNIT {
|
||||
@@ -613,11 +617,13 @@ Convert (Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
|
||||
|
||||
if (Year < 0)
|
||||
Year = -Year;
|
||||
if (Year < 100)
|
||||
if (Year < DOOMSDAY-2000)
|
||||
Year += 2000;
|
||||
else if (Year < 100)
|
||||
Year += 1900;
|
||||
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
|
||||
? 29 : 28;
|
||||
if (Year < EPOCH || Year > 2037
|
||||
if (Year < EPOCH || Year >= DOOMSDAY
|
||||
|| Month < 1 || Month > 12
|
||||
/* Lint fluff: "conversion from long may lose accuracy" */
|
||||
|| Day < 1 || Day > DaysInMonth[(int)--Month])
|
||||
@@ -682,7 +688,7 @@ RelativeMonth (Start, RelMonth)
|
||||
if (RelMonth == 0)
|
||||
return 0;
|
||||
tm = localtime (&Start);
|
||||
Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
|
||||
Month = 12 * (1900 + tm->tm_year) + tm->tm_mon + RelMonth;
|
||||
Year = Month / 12;
|
||||
Month = Month % 12 + 1;
|
||||
return DSTcorrect (Start,
|
||||
@@ -745,7 +751,7 @@ LookupWord (buff)
|
||||
return tp->type;
|
||||
}
|
||||
|
||||
if (strcmp (buff, "dst") == 0)
|
||||
if (strcmp (buff, "dst") == 0)
|
||||
return tDST;
|
||||
|
||||
for (tp = UnitsTable; tp->name; tp++)
|
||||
@@ -896,7 +902,7 @@ get_date (p, now)
|
||||
|
||||
if (! (tm = localtime (&ftz.time)))
|
||||
return -1;
|
||||
|
||||
|
||||
ftz.timezone = difftm (&gmt, tm) / 60;
|
||||
if (tm->tm_isdst)
|
||||
ftz.timezone += 60;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* getline.c -- Replacement for GNU C library function getline
|
||||
|
||||
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1996 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
|
||||
@@ -14,21 +14,39 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
/* The `getdelim' function is only declared if there following symbol
|
||||
is defined. */
|
||||
#define _GNU_SOURCE 1
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined __GNU_LIBRARY__ && defined HAVE_GETDELIM
|
||||
|
||||
int
|
||||
getline (lineptr, n, stream)
|
||||
char **lineptr;
|
||||
size_t *n;
|
||||
FILE *stream;
|
||||
{
|
||||
return getdelim (lineptr, n, '\n', stream);
|
||||
}
|
||||
|
||||
|
||||
#else /* ! have getdelim */
|
||||
|
||||
#define NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc (), *realloc ();
|
||||
#endif
|
||||
@@ -48,7 +66,7 @@ getstr (lineptr, n, stream, terminator, offset)
|
||||
size_t *n;
|
||||
FILE *stream;
|
||||
char terminator;
|
||||
int offset;
|
||||
size_t offset;
|
||||
{
|
||||
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||
char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||
@@ -124,3 +142,14 @@ getline (lineptr, n, stream)
|
||||
{
|
||||
return getstr (lineptr, n, stream, '\n', 0);
|
||||
}
|
||||
|
||||
int
|
||||
getdelim (lineptr, n, delimiter, stream)
|
||||
char **lineptr;
|
||||
size_t *n;
|
||||
int delimiter;
|
||||
FILE *stream;
|
||||
{
|
||||
return getstr (lineptr, n, stream, delimiter, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
/* Copyright (C) 1995 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 _getline_h_
|
||||
#define _getline_h_ 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
#define __P(args) args
|
||||
#else
|
||||
#define __P(args) ()
|
||||
#endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
#ifndef PARAMS
|
||||
# if defined (__GNUC__) || __STDC__
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif /* GCC. */
|
||||
#endif /* Not PARAMS. */
|
||||
|
||||
int
|
||||
getline __P ((char **_lineptr, size_t *_n, FILE *_stream));
|
||||
getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream));
|
||||
|
||||
#endif /* _getline_h_ */
|
||||
int
|
||||
getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream));
|
||||
|
||||
#endif
|
||||
|
||||
967
lib/getloadavg.c
Normal file
967
lib/getloadavg.c
Normal file
@@ -0,0 +1,967 @@
|
||||
/* Get the system load averages.
|
||||
Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995
|
||||
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. */
|
||||
|
||||
/* Compile-time symbols that this file uses:
|
||||
|
||||
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
|
||||
KERNEL_FILE Pathname of the kernel to nlist.
|
||||
LDAV_CVT() Scale the load average from the kernel.
|
||||
Returns a double.
|
||||
LDAV_SYMBOL Name of kernel symbol giving load average.
|
||||
LOAD_AVE_TYPE Type of the load average array in the kernel.
|
||||
Must be defined unless one of
|
||||
apollo, DGUX, NeXT, or UMAX is defined;
|
||||
otherwise, no load average is available.
|
||||
NLIST_STRUCT Include nlist.h, not a.out.h, and
|
||||
the nlist n_name element is a pointer,
|
||||
not an array.
|
||||
NLIST_NAME_UNION struct nlist has an n_un member, not n_name.
|
||||
LINUX_LDAV_FILE [__linux__]: File containing load averages.
|
||||
|
||||
Specific system predefines this file uses, aside from setting
|
||||
default values if not emacs:
|
||||
|
||||
apollo
|
||||
BSD Real BSD, not just BSD-like.
|
||||
convex
|
||||
DGUX
|
||||
eunice UNIX emulator under VMS.
|
||||
hpux
|
||||
NeXT
|
||||
sgi
|
||||
sequent Sequent Dynix 3.x.x (BSD)
|
||||
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
|
||||
sony_news NEWS-OS (works at least for 4.1C)
|
||||
UMAX
|
||||
UMAX4_3
|
||||
VMS
|
||||
__linux__ Linux: assumes /proc filesystem mounted.
|
||||
Support from Michael K. Johnson.
|
||||
__NetBSD__ NetBSD: assumes /kern filesystem mounted.
|
||||
|
||||
In addition, to avoid nesting many #ifdefs, we internally set
|
||||
LDAV_DONE to indicate that the load average has been computed.
|
||||
|
||||
We also #define LDAV_PRIVILEGED if a program will require
|
||||
special installation to be able to call getloadavg. */
|
||||
|
||||
/* This should always be first. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Both the Emacs and non-Emacs sections want this. Some
|
||||
configuration files' definitions for the LOAD_AVE_CVT macro (like
|
||||
sparc.h's) use macros like FSCALE, defined here. */
|
||||
#ifdef unix
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Exclude all the code except the test program at the end
|
||||
if the system has its own `getloadavg' function.
|
||||
|
||||
The declaration of `errno' is needed by the test program
|
||||
as well as the function itself, so it comes first. */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETLOADAVG
|
||||
|
||||
|
||||
/* The existing Emacs configuration files define a macro called
|
||||
LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
|
||||
returns the load average multiplied by 100. What we actually want
|
||||
is a macro called LDAV_CVT, which returns the load average as an
|
||||
unmultiplied double.
|
||||
|
||||
For backwards compatibility, we'll define LDAV_CVT in terms of
|
||||
LOAD_AVE_CVT, but future machine config files should just define
|
||||
LDAV_CVT directly. */
|
||||
|
||||
#if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT)
|
||||
#define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
|
||||
#endif
|
||||
|
||||
#if !defined (BSD) && defined (ultrix)
|
||||
/* Ultrix behaves like BSD on Vaxen. */
|
||||
#define BSD
|
||||
#endif
|
||||
|
||||
#ifdef NeXT
|
||||
/* NeXT in the 2.{0,1,2} releases defines BSD in <sys/param.h>, which
|
||||
conflicts with the definition understood in this file, that this
|
||||
really is BSD. */
|
||||
#undef BSD
|
||||
|
||||
/* NeXT defines FSCALE in <sys/param.h>. However, we take FSCALE being
|
||||
defined to mean that the nlist method should be used, which is not true. */
|
||||
#undef FSCALE
|
||||
#endif
|
||||
|
||||
/* Set values that are different from the defaults, which are
|
||||
set a little farther down with #ifndef. */
|
||||
|
||||
|
||||
/* Some shorthands. */
|
||||
|
||||
#if defined (HPUX) && !defined (hpux)
|
||||
#define hpux
|
||||
#endif
|
||||
|
||||
#if defined(hp300) && !defined(hpux)
|
||||
#define MORE_BSD
|
||||
#endif
|
||||
|
||||
#if defined(ultrix) && defined(mips)
|
||||
#define decstation
|
||||
#endif
|
||||
|
||||
#if (defined(sun) || defined(__sun)) && defined(SVR4)
|
||||
#define SUNOS_5
|
||||
#endif
|
||||
|
||||
#if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
|
||||
#define OSF_ALPHA
|
||||
#include <sys/table.h>
|
||||
#endif
|
||||
|
||||
#if defined (__osf__) && (defined (mips) || defined (__mips__))
|
||||
#define OSF_MIPS
|
||||
#include <sys/table.h>
|
||||
#endif
|
||||
|
||||
/* UTek's /bin/cc on the 4300 has no architecture specific cpp define by
|
||||
default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
|
||||
that with a couple of other things and we'll have a unique match. */
|
||||
#if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
|
||||
#define tek4300 /* Define by emacs, but not by other users. */
|
||||
#endif
|
||||
|
||||
|
||||
/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
|
||||
#ifndef LOAD_AVE_TYPE
|
||||
|
||||
#ifdef MORE_BSD
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef decstation
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef _SEQUENT_
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef sgi
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef SVR4
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef sony_news
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef sequent
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef OSF_ALPHA
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#if defined (ardent) && defined (titan)
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef tek4300
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
#define LOAD_AVE_TYPE long
|
||||
#endif
|
||||
|
||||
#ifdef convex
|
||||
#define LOAD_AVE_TYPE double
|
||||
#ifndef LDAV_CVT
|
||||
#define LDAV_CVT(n) (n)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* No LOAD_AVE_TYPE. */
|
||||
|
||||
#ifdef OSF_ALPHA
|
||||
/* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
|
||||
according to ghazi@noc.rutgers.edu. */
|
||||
#undef FSCALE
|
||||
#define FSCALE 1024.0
|
||||
#endif
|
||||
|
||||
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
|
||||
/* <sys/param.h> defines an incorrect value for FSCALE on an
|
||||
Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
|
||||
#undef FSCALE
|
||||
#define FSCALE 100.0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FSCALE
|
||||
|
||||
/* SunOS and some others define FSCALE in sys/param.h. */
|
||||
|
||||
#ifdef MORE_BSD
|
||||
#define FSCALE 2048.0
|
||||
#endif
|
||||
|
||||
#if defined(MIPS) || defined(SVR4) || defined(decstation)
|
||||
#define FSCALE 256
|
||||
#endif
|
||||
|
||||
#if defined (sgi) || defined (sequent)
|
||||
/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
|
||||
above under #ifdef MIPS. But we want the sgi value. */
|
||||
#undef FSCALE
|
||||
#define FSCALE 1000.0
|
||||
#endif
|
||||
|
||||
#if defined (ardent) && defined (titan)
|
||||
#define FSCALE 65536.0
|
||||
#endif
|
||||
|
||||
#ifdef tek4300
|
||||
#define FSCALE 100.0
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
#define FSCALE 65536.0
|
||||
#endif
|
||||
|
||||
#endif /* Not FSCALE. */
|
||||
|
||||
#if !defined (LDAV_CVT) && defined (FSCALE)
|
||||
#define LDAV_CVT(n) (((double) (n)) / FSCALE)
|
||||
#endif
|
||||
|
||||
/* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */
|
||||
#ifndef NLIST_STRUCT
|
||||
|
||||
#ifdef MORE_BSD
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef decstation
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef hpux
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_) || defined (sequent)
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef sgi
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef SVR4
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef sony_news
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef OSF_ALPHA
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#if defined (ardent) && defined (titan)
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef tek4300
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef butterfly
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
#define NLIST_STRUCT
|
||||
#endif
|
||||
|
||||
#endif /* defined (NLIST_STRUCT) */
|
||||
|
||||
|
||||
#if defined(sgi) || (defined(mips) && !defined(BSD))
|
||||
#define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined (KERNEL_FILE) && defined (sequent)
|
||||
#define KERNEL_FILE "/dynix"
|
||||
#endif
|
||||
|
||||
#if !defined (KERNEL_FILE) && defined (hpux)
|
||||
#define KERNEL_FILE "/hp-ux"
|
||||
#endif
|
||||
|
||||
#if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || defined(SVR4) || (defined (ardent) && defined (titan)))
|
||||
#define KERNEL_FILE "/unix"
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined (LDAV_SYMBOL) && defined (alliant)
|
||||
#define LDAV_SYMBOL "_Loadavg"
|
||||
#endif
|
||||
|
||||
#if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
|
||||
#define LDAV_SYMBOL "avenrun"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* LOAD_AVE_TYPE should only get defined if we're going to use the
|
||||
nlist method. */
|
||||
#if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL))
|
||||
#define LOAD_AVE_TYPE double
|
||||
#endif
|
||||
|
||||
#ifdef LOAD_AVE_TYPE
|
||||
|
||||
#ifndef VMS
|
||||
#ifndef NLIST_STRUCT
|
||||
#include <a.out.h>
|
||||
#else /* NLIST_STRUCT */
|
||||
#include <nlist.h>
|
||||
#endif /* NLIST_STRUCT */
|
||||
|
||||
#ifdef SUNOS_5
|
||||
#include <fcntl.h>
|
||||
#include <kvm.h>
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_FILE
|
||||
#define KERNEL_FILE "/vmunix"
|
||||
#endif /* KERNEL_FILE */
|
||||
|
||||
#ifndef LDAV_SYMBOL
|
||||
#define LDAV_SYMBOL "_avenrun"
|
||||
#endif /* LDAV_SYMBOL */
|
||||
|
||||
#else /* VMS */
|
||||
|
||||
#ifndef eunice
|
||||
#include <iodef.h>
|
||||
#include <descrip.h>
|
||||
#else /* eunice */
|
||||
#include <vms/iodef.h>
|
||||
#endif /* eunice */
|
||||
#endif /* VMS */
|
||||
|
||||
#ifndef LDAV_CVT
|
||||
#define LDAV_CVT(n) ((double) (n))
|
||||
#endif /* !LDAV_CVT */
|
||||
|
||||
#endif /* LOAD_AVE_TYPE */
|
||||
|
||||
#ifdef NeXT
|
||||
#ifdef HAVE_MACH_MACH_H
|
||||
#include <mach/mach.h>
|
||||
#else
|
||||
#include <mach.h>
|
||||
#endif
|
||||
#endif /* NeXT */
|
||||
|
||||
#ifdef sgi
|
||||
#include <sys/sysmp.h>
|
||||
#endif /* sgi */
|
||||
|
||||
#ifdef UMAX
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef UMAX_43
|
||||
#include <machine/cpu.h>
|
||||
#include <inq_stats/statistics.h>
|
||||
#include <inq_stats/sysstats.h>
|
||||
#include <inq_stats/cpustats.h>
|
||||
#include <inq_stats/procstats.h>
|
||||
#else /* Not UMAX_43. */
|
||||
#include <sys/sysdefs.h>
|
||||
#include <sys/statistics.h>
|
||||
#include <sys/sysstats.h>
|
||||
#include <sys/cpudefs.h>
|
||||
#include <sys/cpustats.h>
|
||||
#include <sys/procstats.h>
|
||||
#endif /* Not UMAX_43. */
|
||||
#endif /* UMAX */
|
||||
|
||||
#ifdef DGUX
|
||||
#include <sys/dg_sys_info.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
/* Avoid static vars inside a function since in HPUX they dump as pure. */
|
||||
|
||||
#ifdef NeXT
|
||||
static processor_set_t default_set;
|
||||
static int getloadavg_initialized;
|
||||
#endif /* NeXT */
|
||||
|
||||
#ifdef UMAX
|
||||
static unsigned int cpus = 0;
|
||||
static unsigned int samples;
|
||||
#endif /* UMAX */
|
||||
|
||||
#ifdef DGUX
|
||||
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
|
||||
#endif /* DGUX */
|
||||
|
||||
#ifdef LOAD_AVE_TYPE
|
||||
/* File descriptor open to /dev/kmem or VMS load ave driver. */
|
||||
static int channel;
|
||||
/* Nonzero iff channel is valid. */
|
||||
static int getloadavg_initialized;
|
||||
/* Offset in kmem to seek to read load average, or 0 means invalid. */
|
||||
static long offset;
|
||||
|
||||
#if !defined(VMS) && !defined(sgi)
|
||||
static struct nlist nl[2];
|
||||
#endif /* Not VMS or sgi */
|
||||
|
||||
#ifdef SUNOS_5
|
||||
static kvm_t *kd;
|
||||
#endif /* SUNOS_5 */
|
||||
|
||||
#endif /* LOAD_AVE_TYPE */
|
||||
|
||||
/* Put the 1 minute, 5 minute and 15 minute load averages
|
||||
into the first NELEM elements of LOADAVG.
|
||||
Return the number written (never more than 3, but may be less than NELEM),
|
||||
or -1 if an error occurred. */
|
||||
|
||||
int
|
||||
getloadavg (loadavg, nelem)
|
||||
double loadavg[];
|
||||
int nelem;
|
||||
{
|
||||
int elem = 0; /* Return value. */
|
||||
|
||||
#ifdef NO_GET_LOAD_AVG
|
||||
#define LDAV_DONE
|
||||
/* Set errno to zero to indicate that there was no particular error;
|
||||
this function just can't work at all on this system. */
|
||||
errno = 0;
|
||||
elem = -1;
|
||||
#endif
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (__linux__)
|
||||
#define LDAV_DONE
|
||||
#undef LOAD_AVE_TYPE
|
||||
|
||||
#ifndef LINUX_LDAV_FILE
|
||||
#define LINUX_LDAV_FILE "/proc/loadavg"
|
||||
#endif
|
||||
|
||||
char ldavgbuf[40];
|
||||
double load_ave[3];
|
||||
int fd, count;
|
||||
|
||||
fd = open (LINUX_LDAV_FILE, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
count = read (fd, ldavgbuf, 40);
|
||||
(void) close (fd);
|
||||
if (count <= 0)
|
||||
return -1;
|
||||
|
||||
count = sscanf (ldavgbuf, "%lf %lf %lf",
|
||||
&load_ave[0], &load_ave[1], &load_ave[2]);
|
||||
if (count < 1)
|
||||
return -1;
|
||||
|
||||
for (elem = 0; elem < nelem && elem < count; elem++)
|
||||
loadavg[elem] = load_ave[elem];
|
||||
|
||||
return elem;
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (__NetBSD__)
|
||||
#define LDAV_DONE
|
||||
#undef LOAD_AVE_TYPE
|
||||
|
||||
#ifndef NETBSD_LDAV_FILE
|
||||
#define NETBSD_LDAV_FILE "/kern/loadavg"
|
||||
#endif
|
||||
|
||||
unsigned long int load_ave[3], scale;
|
||||
int count;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (NETBSD_LDAV_FILE, "r");
|
||||
if (fp == NULL)
|
||||
return -1;
|
||||
count = fscanf (fp, "%lu %lu %lu %lu\n",
|
||||
&load_ave[0], &load_ave[1], &load_ave[2],
|
||||
&scale);
|
||||
(void) fclose (fp);
|
||||
if (count != 4)
|
||||
return -1;
|
||||
|
||||
for (elem = 0; elem < nelem; elem++)
|
||||
loadavg[elem] = (double) load_ave[elem] / (double) scale;
|
||||
|
||||
return elem;
|
||||
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (NeXT)
|
||||
#define LDAV_DONE
|
||||
/* The NeXT code was adapted from iscreen 3.2. */
|
||||
|
||||
host_t host;
|
||||
struct processor_set_basic_info info;
|
||||
unsigned info_count;
|
||||
|
||||
/* We only know how to get the 1-minute average for this system,
|
||||
so even if the caller asks for more than 1, we only return 1. */
|
||||
|
||||
if (!getloadavg_initialized)
|
||||
{
|
||||
if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
|
||||
getloadavg_initialized = 1;
|
||||
}
|
||||
|
||||
if (getloadavg_initialized)
|
||||
{
|
||||
info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
|
||||
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
|
||||
(processor_set_info_t) &info, &info_count)
|
||||
!= KERN_SUCCESS)
|
||||
getloadavg_initialized = 0;
|
||||
else
|
||||
{
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getloadavg_initialized)
|
||||
return -1;
|
||||
#endif /* NeXT */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (UMAX)
|
||||
#define LDAV_DONE
|
||||
/* UMAX 4.2, which runs on the Encore Multimax multiprocessor, does not
|
||||
have a /dev/kmem. Information about the workings of the running kernel
|
||||
can be gathered with inq_stats system calls.
|
||||
We only know how to get the 1-minute average for this system. */
|
||||
|
||||
struct proc_summary proc_sum_data;
|
||||
struct stat_descr proc_info;
|
||||
double load;
|
||||
register unsigned int i, j;
|
||||
|
||||
if (cpus == 0)
|
||||
{
|
||||
register unsigned int c, i;
|
||||
struct cpu_config conf;
|
||||
struct stat_descr desc;
|
||||
|
||||
desc.sd_next = 0;
|
||||
desc.sd_subsys = SUBSYS_CPU;
|
||||
desc.sd_type = CPUTYPE_CONFIG;
|
||||
desc.sd_addr = (char *) &conf;
|
||||
desc.sd_size = sizeof conf;
|
||||
|
||||
if (inq_stats (1, &desc))
|
||||
return -1;
|
||||
|
||||
c = 0;
|
||||
for (i = 0; i < conf.config_maxclass; ++i)
|
||||
{
|
||||
struct class_stats stats;
|
||||
bzero ((char *) &stats, sizeof stats);
|
||||
|
||||
desc.sd_type = CPUTYPE_CLASS;
|
||||
desc.sd_objid = i;
|
||||
desc.sd_addr = (char *) &stats;
|
||||
desc.sd_size = sizeof stats;
|
||||
|
||||
if (inq_stats (1, &desc))
|
||||
return -1;
|
||||
|
||||
c += stats.class_numcpus;
|
||||
}
|
||||
cpus = c;
|
||||
samples = cpus < 2 ? 3 : (2 * cpus / 3);
|
||||
}
|
||||
|
||||
proc_info.sd_next = 0;
|
||||
proc_info.sd_subsys = SUBSYS_PROC;
|
||||
proc_info.sd_type = PROCTYPE_SUMMARY;
|
||||
proc_info.sd_addr = (char *) &proc_sum_data;
|
||||
proc_info.sd_size = sizeof (struct proc_summary);
|
||||
proc_info.sd_sizeused = 0;
|
||||
|
||||
if (inq_stats (1, &proc_info) != 0)
|
||||
return -1;
|
||||
|
||||
load = proc_sum_data.ps_nrunnable;
|
||||
j = 0;
|
||||
for (i = samples - 1; i > 0; --i)
|
||||
{
|
||||
load += proc_sum_data.ps_nrun[j];
|
||||
if (j++ == PS_NRUNSIZE)
|
||||
j = 0;
|
||||
}
|
||||
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = load / samples / cpus;
|
||||
#endif /* UMAX */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (DGUX)
|
||||
#define LDAV_DONE
|
||||
/* This call can return -1 for an error, but with good args
|
||||
it's not supposed to fail. The first argument is for no
|
||||
apparent reason of type `long int *'. */
|
||||
dg_sys_info ((long int *) &load_info,
|
||||
DG_SYS_INFO_LOAD_INFO_TYPE,
|
||||
DG_SYS_INFO_LOAD_VERSION_0);
|
||||
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = load_info.one_minute;
|
||||
if (nelem > 1)
|
||||
loadavg[elem++] = load_info.five_minute;
|
||||
if (nelem > 2)
|
||||
loadavg[elem++] = load_info.fifteen_minute;
|
||||
#endif /* DGUX */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (apollo)
|
||||
#define LDAV_DONE
|
||||
/* Apollo code from lisch@mentorg.com (Ray Lischner).
|
||||
|
||||
This system call is not documented. The load average is obtained as
|
||||
three long integers, for the load average over the past minute,
|
||||
five minutes, and fifteen minutes. Each value is a scaled integer,
|
||||
with 16 bits of integer part and 16 bits of fraction part.
|
||||
|
||||
I'm not sure which operating system first supported this system call,
|
||||
but I know that SR10.2 supports it. */
|
||||
|
||||
extern void proc1_$get_loadav ();
|
||||
unsigned long load_ave[3];
|
||||
|
||||
proc1_$get_loadav (load_ave);
|
||||
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = load_ave[0] / 65536.0;
|
||||
if (nelem > 1)
|
||||
loadavg[elem++] = load_ave[1] / 65536.0;
|
||||
if (nelem > 2)
|
||||
loadavg[elem++] = load_ave[2] / 65536.0;
|
||||
#endif /* apollo */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (OSF_MIPS)
|
||||
#define LDAV_DONE
|
||||
|
||||
struct tbl_loadavg load_ave;
|
||||
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
|
||||
loadavg[elem++]
|
||||
= (load_ave.tl_lscale == 0
|
||||
? load_ave.tl_avenrun.d[0]
|
||||
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
|
||||
#endif /* OSF_MIPS */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined(MSDOS)
|
||||
#define LDAV_DONE
|
||||
|
||||
/* A faithful emulation is going to have to be saved for a rainy day. */
|
||||
for ( ; elem < nelem; elem++)
|
||||
{
|
||||
loadavg[elem] = 0.0;
|
||||
}
|
||||
#endif /* MSDOS */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (OSF_ALPHA)
|
||||
#define LDAV_DONE
|
||||
|
||||
struct tbl_loadavg load_ave;
|
||||
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
|
||||
for (elem = 0; elem < nelem; elem++)
|
||||
loadavg[elem]
|
||||
= (load_ave.tl_lscale == 0
|
||||
? load_ave.tl_avenrun.d[elem]
|
||||
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
|
||||
#endif /* OSF_ALPHA */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (VMS)
|
||||
/* VMS specific code -- read from the Load Ave driver. */
|
||||
|
||||
LOAD_AVE_TYPE load_ave[3];
|
||||
static int getloadavg_initialized = 0;
|
||||
#ifdef eunice
|
||||
struct
|
||||
{
|
||||
int dsc$w_length;
|
||||
char *dsc$a_pointer;
|
||||
} descriptor;
|
||||
#endif
|
||||
|
||||
/* Ensure that there is a channel open to the load ave device. */
|
||||
if (!getloadavg_initialized)
|
||||
{
|
||||
/* Attempt to open the channel. */
|
||||
#ifdef eunice
|
||||
descriptor.dsc$w_length = 18;
|
||||
descriptor.dsc$a_pointer = "$$VMS_LOAD_AVERAGE";
|
||||
#else
|
||||
$DESCRIPTOR (descriptor, "LAV0:");
|
||||
#endif
|
||||
if (sys$assign (&descriptor, &channel, 0, 0) & 1)
|
||||
getloadavg_initialized = 1;
|
||||
}
|
||||
|
||||
/* Read the load average vector. */
|
||||
if (getloadavg_initialized
|
||||
&& !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
|
||||
load_ave, 12, 0, 0, 0, 0) & 1))
|
||||
{
|
||||
sys$dassgn (channel);
|
||||
getloadavg_initialized = 0;
|
||||
}
|
||||
|
||||
if (!getloadavg_initialized)
|
||||
return -1;
|
||||
#endif /* VMS */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS)
|
||||
|
||||
/* UNIX-specific code -- read the average from /dev/kmem. */
|
||||
|
||||
#define LDAV_PRIVILEGED /* This code requires special installation. */
|
||||
|
||||
LOAD_AVE_TYPE load_ave[3];
|
||||
|
||||
/* Get the address of LDAV_SYMBOL. */
|
||||
if (offset == 0)
|
||||
{
|
||||
#ifndef sgi
|
||||
#ifndef NLIST_STRUCT
|
||||
strcpy (nl[0].n_name, LDAV_SYMBOL);
|
||||
strcpy (nl[1].n_name, "");
|
||||
#else /* NLIST_STRUCT */
|
||||
#ifdef NLIST_NAME_UNION
|
||||
nl[0].n_un.n_name = LDAV_SYMBOL;
|
||||
nl[1].n_un.n_name = 0;
|
||||
#else /* not NLIST_NAME_UNION */
|
||||
nl[0].n_name = LDAV_SYMBOL;
|
||||
nl[1].n_name = 0;
|
||||
#endif /* not NLIST_NAME_UNION */
|
||||
#endif /* NLIST_STRUCT */
|
||||
|
||||
#ifndef SUNOS_5
|
||||
if (
|
||||
#if !(defined (_AIX) && !defined (ps2))
|
||||
nlist (KERNEL_FILE, nl)
|
||||
#else /* _AIX */
|
||||
knlist (nl, 1, sizeof (nl[0]))
|
||||
#endif
|
||||
>= 0)
|
||||
/* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */
|
||||
{
|
||||
#ifdef FIXUP_KERNEL_SYMBOL_ADDR
|
||||
FIXUP_KERNEL_SYMBOL_ADDR (nl);
|
||||
#endif
|
||||
offset = nl[0].n_value;
|
||||
}
|
||||
#endif /* !SUNOS_5 */
|
||||
#else /* sgi */
|
||||
int ldav_off;
|
||||
|
||||
ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
|
||||
if (ldav_off != -1)
|
||||
offset = (long) ldav_off & 0x7fffffff;
|
||||
#endif /* sgi */
|
||||
}
|
||||
|
||||
/* Make sure we have /dev/kmem open. */
|
||||
if (!getloadavg_initialized)
|
||||
{
|
||||
#ifndef SUNOS_5
|
||||
channel = open ("/dev/kmem", 0);
|
||||
if (channel >= 0)
|
||||
{
|
||||
/* Set the channel to close on exec, so it does not
|
||||
litter any child's descriptor table. */
|
||||
#ifdef FD_SETFD
|
||||
#ifndef FD_CLOEXEC
|
||||
#define FD_CLOEXEC 1
|
||||
#endif
|
||||
(void) fcntl (channel, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
getloadavg_initialized = 1;
|
||||
}
|
||||
#else /* SUNOS_5 */
|
||||
/* We pass 0 for the kernel, corefile, and swapfile names
|
||||
to use the currently running kernel. */
|
||||
kd = kvm_open (0, 0, 0, O_RDONLY, 0);
|
||||
if (kd != 0)
|
||||
{
|
||||
/* nlist the currently running kernel. */
|
||||
kvm_nlist (kd, nl);
|
||||
offset = nl[0].n_value;
|
||||
getloadavg_initialized = 1;
|
||||
}
|
||||
#endif /* SUNOS_5 */
|
||||
}
|
||||
|
||||
/* If we can, get the load average values. */
|
||||
if (offset && getloadavg_initialized)
|
||||
{
|
||||
/* Try to read the load. */
|
||||
#ifndef SUNOS_5
|
||||
if (lseek (channel, offset, 0) == -1L
|
||||
|| read (channel, (char *) load_ave, sizeof (load_ave))
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
close (channel);
|
||||
getloadavg_initialized = 0;
|
||||
}
|
||||
#else /* SUNOS_5 */
|
||||
if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
kvm_close (kd);
|
||||
getloadavg_initialized = 0;
|
||||
}
|
||||
#endif /* SUNOS_5 */
|
||||
}
|
||||
|
||||
if (offset == 0 || !getloadavg_initialized)
|
||||
return -1;
|
||||
#endif /* LOAD_AVE_TYPE and not VMS */
|
||||
|
||||
#if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = LDAV_CVT (load_ave[0]);
|
||||
if (nelem > 1)
|
||||
loadavg[elem++] = LDAV_CVT (load_ave[1]);
|
||||
if (nelem > 2)
|
||||
loadavg[elem++] = LDAV_CVT (load_ave[2]);
|
||||
|
||||
#define LDAV_DONE
|
||||
#endif /* !LDAV_DONE && LOAD_AVE_TYPE */
|
||||
|
||||
#ifdef LDAV_DONE
|
||||
return elem;
|
||||
#else
|
||||
/* Set errno to zero to indicate that there was no particular error;
|
||||
this function just can't work at all on this system. */
|
||||
errno = 0;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ! HAVE_GETLOADAVG */
|
||||
|
||||
#ifdef TEST
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int naptime = 0;
|
||||
|
||||
if (argc > 1)
|
||||
naptime = atoi (argv[1]);
|
||||
|
||||
while (1)
|
||||
{
|
||||
double avg[3];
|
||||
int loads;
|
||||
|
||||
errno = 0; /* Don't be misled if it doesn't set errno. */
|
||||
loads = getloadavg (avg, 3);
|
||||
if (loads == -1)
|
||||
{
|
||||
perror ("Error getting load average");
|
||||
exit (1);
|
||||
}
|
||||
if (loads > 0)
|
||||
printf ("1-minute: %f ", avg[0]);
|
||||
if (loads > 1)
|
||||
printf ("5-minute: %f ", avg[1]);
|
||||
if (loads > 2)
|
||||
printf ("15-minute: %f ", avg[2]);
|
||||
if (loads > 0)
|
||||
putchar ('\n');
|
||||
|
||||
if (naptime == 0)
|
||||
break;
|
||||
sleep (naptime);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
#endif /* TEST */
|
||||
111
lib/getopt.c
111
lib/getopt.c
@@ -3,7 +3,7 @@
|
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||
before changing it!
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 1996
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||
@@ -53,12 +53,28 @@
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#include <stdlib.h>
|
||||
#if defined (_LIBC) || defined (HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif /* GNU C library. */
|
||||
|
||||
#ifdef VMS
|
||||
#include <unixlib.h>
|
||||
#if HAVE_STRING_H - 0
|
||||
#include <string.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
/* It's not Unix, really. See? Capital letters. */
|
||||
#include <windows.h>
|
||||
#define getpid() GetCurrentProcessId()
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
/* This is for other GNU distributions with internationalized messages.
|
||||
When compiling libc, the _ macro is predefined. */
|
||||
@@ -166,7 +182,7 @@ static enum
|
||||
/* Value of POSIXLY_CORRECT environment variable. */
|
||||
static char *posixly_correct;
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
@@ -217,6 +233,12 @@ extern int strlen (const char *);
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Bash 2.0 gives us an environment variable containing flags
|
||||
indicating ARGV elements that should not be considered arguments. */
|
||||
|
||||
static const char *nonoption_flags;
|
||||
static int nonoption_flags_len;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
@@ -226,6 +248,10 @@ static int last_nonopt;
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
static void exchange (char **);
|
||||
#endif
|
||||
|
||||
static void
|
||||
exchange (argv)
|
||||
char **argv;
|
||||
@@ -284,6 +310,9 @@ exchange (argv)
|
||||
|
||||
/* Initialize the internal data when the first call is made. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
static const char *_getopt_initialize (const char *);
|
||||
#endif
|
||||
static const char *
|
||||
_getopt_initialize (optstring)
|
||||
const char *optstring;
|
||||
@@ -315,6 +344,21 @@ _getopt_initialize (optstring)
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
|
||||
if (posixly_correct == NULL)
|
||||
{
|
||||
/* Bash 2.0 puts a special variable in the environment for each
|
||||
command it runs, specifying which ARGV elements are the results of
|
||||
file name wildcard expansion and therefore should not be
|
||||
considered as options. */
|
||||
char var[100];
|
||||
sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ());
|
||||
nonoption_flags = getenv (var);
|
||||
if (nonoption_flags == NULL)
|
||||
nonoption_flags_len = 0;
|
||||
else
|
||||
nonoption_flags_len = strlen (nonoption_flags);
|
||||
}
|
||||
|
||||
return optstring;
|
||||
}
|
||||
|
||||
@@ -391,10 +435,24 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
optind = 1; /* Don't scan ARGV[0], the program name. */
|
||||
}
|
||||
|
||||
/* Test whether ARGV[optind] points to a non-option argument.
|
||||
Either it does not have option syntax, or there is an environment flag
|
||||
from the shell indicating it is not an option. */
|
||||
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||
|| (optind < nonoption_flags_len \
|
||||
&& nonoption_flags[optind] == '1'))
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
/* Advance to the next ARGV-element. */
|
||||
|
||||
/* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
|
||||
moved back by the user (who may also have changed the arguments). */
|
||||
if (last_nonopt > optind)
|
||||
last_nonopt = optind;
|
||||
if (first_nonopt > optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
@@ -408,8 +466,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
/* Skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc
|
||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
while (optind < argc && NONOPTION_P)
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
@@ -447,7 +504,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
if (NONOPTION_P)
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return EOF;
|
||||
@@ -479,8 +536,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
|
||||
if (longopts != NULL
|
||||
&& (argv[optind][1] == '-'
|
||||
|| (long_only && (argv[optind][2]
|
||||
|| !my_index (optstring, argv[optind][1])))))
|
||||
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
@@ -493,8 +549,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
#ifdef lint
|
||||
indfound = 0; /* Avoid spurious compiler warning. */
|
||||
#ifdef lint /* Suppress `used before initialized' warning. */
|
||||
indfound = 0;
|
||||
#endif
|
||||
|
||||
/* Test all long options for either exact match
|
||||
@@ -528,6 +584,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
optopt = 0;
|
||||
return '?';
|
||||
}
|
||||
|
||||
@@ -544,18 +601,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
|
||||
optopt = pfound->val;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
@@ -567,9 +626,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr,
|
||||
_("%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]);
|
||||
_("%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
optopt = pfound->val;
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
@@ -604,6 +664,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
}
|
||||
nextchar = (char *) "";
|
||||
optind++;
|
||||
optopt = 0;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
@@ -663,8 +724,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr,
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c);
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
|
||||
@@ -17,36 +17,25 @@
|
||||
|
||||
/* Written by David MacKenzie. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
|
||||
#include <grp.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Even though SunOS 4, Ultrix 4, and 386BSD are mostly POSIX.1 compliant,
|
||||
their getgroups system call (except in the `System V' environment, which
|
||||
is troublesome in other ways) fills in an array of int, not gid_t
|
||||
(which is `short' on those systems). We do the same, for consistency.
|
||||
Kludge, kludge. */
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#if !defined(sun) && !defined(ultrix) && !defined(__386BSD__)
|
||||
#define GETGROUPS_T gid_t
|
||||
#else /* sun or ultrix or 386BSD */
|
||||
#define GETGROUPS_T int
|
||||
#endif /* sun or ultrix or 386BSD */
|
||||
#else /* not _POSIX_VERSION */
|
||||
#define GETGROUPS_T int
|
||||
#endif /* not _POSIX_VERSION */
|
||||
|
||||
/* setgrent, getgrent, and endgrent are not specified by POSIX.1,
|
||||
so header files might not declare them.
|
||||
If you don't have them at all, we can't implement this function.
|
||||
You lose! */
|
||||
struct group *getgrent ();
|
||||
|
||||
#if defined(USG) || defined(STDC_HEADERS)
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
|
||||
61
lib/memcasecmp.c
Normal file
61
lib/memcasecmp.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* Case-insensitive buffer comparator.
|
||||
Copyright (C) 1996 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Jim Meyering (meyering@na-net.ornl.gov) */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#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 ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
|
||||
|
||||
#if _LIBC || STDC_HEADERS
|
||||
# define TOLOWER(c) tolower (c)
|
||||
#else
|
||||
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
|
||||
#endif
|
||||
|
||||
#include "memcasecmp.h"
|
||||
|
||||
/* Like memcmp, but ignore differences in case. */
|
||||
|
||||
int
|
||||
memcasecmp (vs1, vs2, n)
|
||||
const void *vs1;
|
||||
const void *vs2;
|
||||
size_t n;
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *s1 = (unsigned char *) vs1;
|
||||
unsigned char *s2 = (unsigned char *) vs2;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
unsigned char u1 = *s1++;
|
||||
unsigned char u2 = *s2++;
|
||||
if (TOLOWER (u1) != TOLOWER (u2))
|
||||
return TOLOWER (u1) - TOLOWER (u2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
9
lib/memcasecmp.h
Normal file
9
lib/memcasecmp.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# define __P(args) args
|
||||
#else
|
||||
# define __P(args) ()
|
||||
#endif
|
||||
|
||||
int
|
||||
memcasecmp __P((const void *vs1, const void *vs2, size_t n));
|
||||
@@ -72,7 +72,7 @@ static int oatoi ();
|
||||
|
||||
struct mode_change *
|
||||
mode_compile (mode_string, masked_ops)
|
||||
register char *mode_string;
|
||||
const char *mode_string;
|
||||
unsigned masked_ops;
|
||||
{
|
||||
struct mode_change *head; /* First element of the linked list. */
|
||||
@@ -244,7 +244,7 @@ invalid:
|
||||
unsigned short
|
||||
mode_adjust (oldmode, changes)
|
||||
unsigned oldmode;
|
||||
register struct mode_change *changes;
|
||||
const struct mode_change *changes;
|
||||
{
|
||||
unsigned short newmode; /* The adjusted mode and one operand. */
|
||||
unsigned short value; /* The other operand. */
|
||||
|
||||
@@ -44,12 +44,14 @@ struct mode_change
|
||||
#define MODE_INVALID (struct mode_change *) 0
|
||||
#define MODE_MEMORY_EXHAUSTED (struct mode_change *) 1
|
||||
|
||||
#ifdef __STDC__
|
||||
struct mode_change *mode_compile (char *, unsigned);
|
||||
unsigned short mode_adjust (unsigned, struct mode_change *);
|
||||
void mode_free (struct mode_change *);
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
#define __P(args) args
|
||||
#else
|
||||
struct mode_change *mode_compile ();
|
||||
unsigned short mode_adjust ();
|
||||
void mode_free ();
|
||||
#endif
|
||||
#define __P(args) ()
|
||||
#endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
struct mode_change *mode_compile __P ((const char *, unsigned));
|
||||
unsigned short mode_adjust __P ((unsigned, const struct mode_change *));
|
||||
void mode_free __P ((struct mode_change *));
|
||||
|
||||
@@ -80,6 +80,10 @@ void error ();
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
|
||||
#include <sys/mnttab.h>
|
||||
#endif
|
||||
@@ -195,6 +199,36 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
me->me_next = NULL;
|
||||
mount_list = mtail = me;
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
{
|
||||
struct tabmntent *mntlist, *p;
|
||||
struct mntent *mnt;
|
||||
struct mount_entry *me;
|
||||
|
||||
/* the third and fourth arguments could be used to filter mounts,
|
||||
but Crays doesn't seem to have any mounts that we want to
|
||||
remove. Specifically, automount create normal NFS mounts.
|
||||
*/
|
||||
|
||||
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
p = mntlist;
|
||||
while(p){
|
||||
mnt = p->ment;
|
||||
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup(mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup(mnt->mnt_dir);
|
||||
me->me_type = xstrdup(mnt->mnt_type);
|
||||
me->me_dev = -1;
|
||||
me->me_next = NULL;
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
p = p->next;
|
||||
}
|
||||
freemntlist(mntlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
{
|
||||
struct mntent *mnt;
|
||||
|
||||
@@ -58,7 +58,8 @@ void *xrealloc ();
|
||||
/* Initialize a tokenbuffer. */
|
||||
|
||||
void
|
||||
init_tokenbuffer (token_buffer *tokenbuffer)
|
||||
init_tokenbuffer (tokenbuffer)
|
||||
token_buffer *tokenbuffer;
|
||||
{
|
||||
tokenbuffer->size = INITIAL_TOKEN_LENGTH;
|
||||
tokenbuffer->buffer = ((char *) xmalloc (INITIAL_TOKEN_LENGTH));
|
||||
@@ -76,8 +77,11 @@ init_tokenbuffer (token_buffer *tokenbuffer)
|
||||
and on files that aren't newline-terminated. */
|
||||
|
||||
long
|
||||
readtoken (FILE *stream, const char *delim, int n_delim,
|
||||
token_buffer *tokenbuffer)
|
||||
readtoken (stream, delim, n_delim, tokenbuffer)
|
||||
FILE *stream;
|
||||
const char *delim;
|
||||
int n_delim;
|
||||
token_buffer *tokenbuffer;
|
||||
{
|
||||
char *p;
|
||||
int c, i, n;
|
||||
@@ -160,9 +164,14 @@ readtoken (FILE *stream, const char *delim, int n_delim,
|
||||
%%% realloc() of `tokens' just before returning? */
|
||||
|
||||
int
|
||||
readtokens (FILE *stream, int projected_n_tokens,
|
||||
const char *delim, int n_delim,
|
||||
char ***tokens_out, long **token_lengths)
|
||||
readtokens (stream, projected_n_tokens, delim, n_delim,
|
||||
tokens_out, token_lengths)
|
||||
FILE *stream;
|
||||
int projected_n_tokens;
|
||||
const char *delim;
|
||||
int n_delim;
|
||||
char ***tokens_out;
|
||||
long **token_lengths;
|
||||
{
|
||||
token_buffer tb, *token = &tb;
|
||||
int token_length;
|
||||
|
||||
@@ -16,14 +16,21 @@ typedef struct tokenbuffer token_buffer;
|
||||
|
||||
#endif /* not TOKENBUFFER_DEFINED */
|
||||
|
||||
void init_tokenbuffer (token_buffer *tokenbuffer);
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
|
||||
void init_tokenbuffer __P ((token_buffer *tokenbuffer));
|
||||
|
||||
long
|
||||
readtoken (FILE *stream, const char *delim, int n_delim,
|
||||
token_buffer *tokenbuffer);
|
||||
readtoken __P ((FILE *stream, const char *delim, int n_delim,
|
||||
token_buffer *tokenbuffer));
|
||||
int
|
||||
readtokens (FILE *stream, int projected_n_tokens,
|
||||
readtokens __P ((FILE *stream, int projected_n_tokens,
|
||||
const char *delim, int n_delim,
|
||||
char ***tokens_out, long **token_lengths);
|
||||
char ***tokens_out, long **token_lengths));
|
||||
|
||||
#endif /* not H_READTOKENS_H */
|
||||
|
||||
705
lib/regex.c
705
lib/regex.c
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,22 @@
|
||||
/* save-cwd.c -- Save and restore current working directory.
|
||||
Copyright (C) 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Written by Jim Meyering <meyering@na-net.ornl.gov>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
129
lib/setenv.c
Normal file
129
lib/setenv.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if _LIBC || HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if _LIBC || HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if _LIBC || HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GNU_LD
|
||||
#define __environ environ
|
||||
#endif
|
||||
|
||||
int
|
||||
setenv (name, value, replace)
|
||||
const char *name;
|
||||
const char *value;
|
||||
int replace;
|
||||
{
|
||||
register char **ep;
|
||||
register size_t size;
|
||||
const size_t namelen = strlen (name);
|
||||
const size_t vallen = strlen (value) + 1;
|
||||
|
||||
size = 0;
|
||||
for (ep = __environ; *ep != NULL; ++ep)
|
||||
if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
|
||||
break;
|
||||
else
|
||||
++size;
|
||||
|
||||
if (*ep == NULL)
|
||||
{
|
||||
static char **last_environ;
|
||||
char **new_environ;
|
||||
if (__environ == last_environ)
|
||||
/* We allocated this space; we can extend it. */
|
||||
new_environ = (char **) realloc (last_environ,
|
||||
(size + 2) * sizeof (char *));
|
||||
else
|
||||
new_environ = (char **) malloc ((size + 2) * sizeof (char *));
|
||||
|
||||
if (new_environ == NULL)
|
||||
return -1;
|
||||
|
||||
new_environ[size] = malloc (namelen + 1 + vallen);
|
||||
if (new_environ[size] == NULL)
|
||||
{
|
||||
free ((char *) new_environ);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__environ != last_environ)
|
||||
memcpy ((char *) new_environ, (char *) __environ,
|
||||
size * sizeof (char *));
|
||||
|
||||
memcpy (new_environ[size], name, namelen);
|
||||
new_environ[size][namelen] = '=';
|
||||
memcpy (&new_environ[size][namelen + 1], value, vallen);
|
||||
|
||||
new_environ[size + 1] = NULL;
|
||||
|
||||
last_environ = __environ = new_environ;
|
||||
}
|
||||
else if (replace)
|
||||
{
|
||||
size_t len = strlen (*ep);
|
||||
if (len + 1 < namelen + 1 + vallen)
|
||||
{
|
||||
/* The existing string is too short; malloc a new one. */
|
||||
char *new = malloc (namelen + 1 + vallen);
|
||||
if (new == NULL)
|
||||
return -1;
|
||||
*ep = new;
|
||||
}
|
||||
memcpy (*ep, name, namelen);
|
||||
(*ep)[namelen] = '=';
|
||||
memcpy (&(*ep)[namelen + 1], value, vallen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
unsetenv (name)
|
||||
const char *name;
|
||||
{
|
||||
const size_t len = strlen (name);
|
||||
char **ep;
|
||||
|
||||
for (ep = __environ; *ep; ++ep)
|
||||
if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
|
||||
{
|
||||
/* Found it. Remove this pointer by moving later ones back. */
|
||||
char **dp = ep;
|
||||
do
|
||||
dp[0] = dp[1];
|
||||
while (*dp++);
|
||||
/* Continue the loop in case NAME appears again. */
|
||||
}
|
||||
}
|
||||
17
lib/setenv.h
Normal file
17
lib/setenv.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef SETENV_H
|
||||
#define SETENV_H 1
|
||||
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
|
||||
int
|
||||
setenv __P ((const char *name, const char *value, int replace));
|
||||
|
||||
void
|
||||
unsetenv __P ((const char *name));
|
||||
|
||||
#endif /* SETENV_H */
|
||||
864
lib/strftime.c
864
lib/strftime.c
@@ -1,469 +1,453 @@
|
||||
/* strftime - custom formatting of date and/or time
|
||||
Copyright (C) 1989, 1991, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 93, 94, 95, 96 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.
|
||||
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 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.
|
||||
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.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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.
|
||||
|
||||
/* Note: this version of strftime lacks locale support,
|
||||
but it is standalone.
|
||||
|
||||
Performs `%' substitutions similar to those in printf. Except
|
||||
where noted, substituted fields have a fixed size; numeric fields are
|
||||
padded if necessary. Padding is with zeros by default; for fields
|
||||
that display a single number, padding can be changed or inhibited by
|
||||
following the `%' with one of the modifiers described below. Unknown
|
||||
field specifiers are copied as normal characters. All other
|
||||
characters are copied to the output without change.
|
||||
|
||||
Supports a superset of the ANSI C field specifiers.
|
||||
|
||||
Literal character fields:
|
||||
% %
|
||||
n newline
|
||||
t tab
|
||||
|
||||
Numeric modifiers (a nonstandard extension):
|
||||
- do not pad the field
|
||||
_ pad the field with spaces
|
||||
|
||||
Time fields:
|
||||
%H hour (00..23)
|
||||
%I hour (01..12)
|
||||
%k hour ( 0..23)
|
||||
%l hour ( 1..12)
|
||||
%M minute (00..59)
|
||||
%p locale's AM or PM
|
||||
%r time, 12-hour (hh:mm:ss [AP]M)
|
||||
%R time, 24-hour (hh:mm)
|
||||
%s time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension)
|
||||
%S second (00..61)
|
||||
%T time, 24-hour (hh:mm:ss)
|
||||
%X locale's time representation (%H:%M:%S)
|
||||
%Z time zone (EDT), or nothing if no time zone is determinable
|
||||
|
||||
Date fields:
|
||||
%a locale's abbreviated weekday name (Sun..Sat)
|
||||
%A locale's full weekday name, variable length (Sunday..Saturday)
|
||||
%b locale's abbreviated month name (Jan..Dec)
|
||||
%B locale's full month name, variable length (January..December)
|
||||
%c locale's date and time (Sat Nov 04 12:02:33 EST 1989)
|
||||
%C century (00..99)
|
||||
%d day of month (01..31)
|
||||
%e day of month ( 1..31)
|
||||
%D date (mm/dd/yy)
|
||||
%h same as %b
|
||||
%j day of year (001..366)
|
||||
%m month (01..12)
|
||||
%U week number of year with Sunday as first day of week (00..53)
|
||||
%w day of week (0..6)
|
||||
%W week number of year with Monday as first day of week (00..53)
|
||||
%x locale's date representation (mm/dd/yy)
|
||||
%y last two digits of year (00..99)
|
||||
%Y year (1970...)
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
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>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# define HAVE_LIMITS_H 1
|
||||
# define HAVE_MBLEN 1
|
||||
# define HAVE_TM_ZONE 1
|
||||
# define STDC_HEADERS 1
|
||||
# include <ansidecl.h>
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME))
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h> /* Some systems define `time_t' here. */
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
time_t mktime ();
|
||||
#if HAVE_MBLEN
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TZNAME)
|
||||
extern char *tzname[2];
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Types of padding for numbers in date and time. */
|
||||
enum padding
|
||||
{
|
||||
none, blank, zero
|
||||
};
|
||||
|
||||
static char const* const days[] =
|
||||
{
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
||||
};
|
||||
|
||||
static char const * const months[] =
|
||||
{
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
|
||||
/* Add character C to STRING and increment LENGTH,
|
||||
unless LENGTH would exceed MAX. */
|
||||
|
||||
#define add_char(c) \
|
||||
do \
|
||||
{ \
|
||||
if (length + 1 <= max) \
|
||||
string[length++] = (c); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Add a 2 digit number to STRING, padding if specified.
|
||||
Return the number of characters added, up to MAX. */
|
||||
|
||||
static int
|
||||
add_num2 (string, num, max, pad)
|
||||
char *string;
|
||||
int num;
|
||||
int max;
|
||||
enum padding pad;
|
||||
{
|
||||
int top = num / 10;
|
||||
int length = 0;
|
||||
|
||||
if (top == 0 && pad == blank)
|
||||
add_char (' ');
|
||||
else if (top != 0 || pad == zero)
|
||||
add_char (top + '0');
|
||||
add_char (num % 10 + '0');
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Add a 3 digit number to STRING, padding if specified.
|
||||
Return the number of characters added, up to MAX. */
|
||||
|
||||
static int
|
||||
add_num3 (string, num, max, pad)
|
||||
char *string;
|
||||
int num;
|
||||
int max;
|
||||
enum padding pad;
|
||||
{
|
||||
int top = num / 100;
|
||||
int mid = (num - top * 100) / 10;
|
||||
int length = 0;
|
||||
|
||||
if (top == 0 && pad == blank)
|
||||
add_char (' ');
|
||||
else if (top != 0 || pad == zero)
|
||||
add_char (top + '0');
|
||||
if (mid == 0 && top == 0 && pad == blank)
|
||||
add_char (' ');
|
||||
else if (mid != 0 || top != 0 || pad == zero)
|
||||
add_char (mid + '0');
|
||||
add_char (num % 10 + '0');
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Like strncpy except return the number of characters copied. */
|
||||
|
||||
static int
|
||||
add_str (to, from, max)
|
||||
char *to;
|
||||
const char *from;
|
||||
int max;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; from[i] && i <= max; ++i)
|
||||
to[i] = from[i];
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
add_num_time_t (string, max, num)
|
||||
char *string;
|
||||
int max;
|
||||
time_t num;
|
||||
{
|
||||
/* This buffer is large enough to hold the character representation
|
||||
(including the trailing NUL) of any unsigned decimal quantity
|
||||
whose binary representation fits in 128 bits. */
|
||||
char buf[40];
|
||||
int length;
|
||||
|
||||
if (sizeof (num) > 16)
|
||||
abort ();
|
||||
sprintf (buf, "%lu", (unsigned long) num);
|
||||
length = add_str (string, buf, max);
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Return the week in the year of the time in TM, with the weeks
|
||||
starting on Sundays. */
|
||||
|
||||
static int
|
||||
sun_week (tm)
|
||||
struct tm *tm;
|
||||
{
|
||||
int dl;
|
||||
|
||||
/* Set `dl' to the day in the year of the last day of the week previous
|
||||
to the one containing the day specified in TM. If the day specified
|
||||
in TM is in the first week of the year, `dl' will be negative or 0.
|
||||
Otherwise, calculate the number of complete weeks before our week
|
||||
(dl / 7) and add any partial week at the start of the year (dl % 7). */
|
||||
dl = tm->tm_yday - tm->tm_wday;
|
||||
return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
|
||||
}
|
||||
|
||||
/* Return the week in the year of the time in TM, with the weeks
|
||||
starting on Mondays. */
|
||||
|
||||
static int
|
||||
mon_week (tm)
|
||||
struct tm *tm;
|
||||
{
|
||||
int dl, wday;
|
||||
|
||||
if (tm->tm_wday == 0)
|
||||
wday = 6;
|
||||
else
|
||||
wday = tm->tm_wday - 1;
|
||||
dl = tm->tm_yday - wday;
|
||||
return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
|
||||
}
|
||||
|
||||
#if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)
|
||||
char *
|
||||
zone_name (tp)
|
||||
struct tm *tp;
|
||||
{
|
||||
char *timezone ();
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
gettimeofday (&tv, &tz);
|
||||
return timezone (tz.tz_minuteswest, tp->tm_isdst);
|
||||
}
|
||||
#if STDC_HEADERS
|
||||
# include <stddef.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
# define memcpy(d, s, n) bcopy (s, d, n)
|
||||
#endif
|
||||
|
||||
/* Format the time given in TM according to FORMAT, and put the
|
||||
results in STRING.
|
||||
Return the number of characters (not including terminating null)
|
||||
that were put into STRING, or 0 if the length would have
|
||||
exceeded MAX. */
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
#define __P(args) args
|
||||
#else
|
||||
#define __P(args) ()
|
||||
#endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
#ifndef PTR
|
||||
#ifdef __STDC__
|
||||
#define PTR void *
|
||||
#else
|
||||
#define PTR char *
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static unsigned int week __P((const struct tm *const, int, int));
|
||||
|
||||
|
||||
#define add(n, f) \
|
||||
do \
|
||||
{ \
|
||||
i += (n); \
|
||||
if (i >= maxsize) \
|
||||
return 0; \
|
||||
else \
|
||||
if (p) \
|
||||
{ \
|
||||
f; \
|
||||
p += (n); \
|
||||
} \
|
||||
} while (0)
|
||||
#define cpy(n, s) add((n), memcpy((PTR) p, (PTR) (s), (n)))
|
||||
|
||||
#ifdef _LIBC
|
||||
#define fmt(n, args) add((n), if (sprintf args != (n)) return 0)
|
||||
#else
|
||||
#define fmt(n, args) add((n), sprintf args; if (strlen (p) != (n)) return 0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Return the week in the year specified by TP,
|
||||
with weeks starting on STARTING_DAY. */
|
||||
#ifdef __GNUC__
|
||||
inline
|
||||
#endif
|
||||
static unsigned int
|
||||
week (tp, starting_day, max_preceding)
|
||||
const struct tm *const tp;
|
||||
int starting_day;
|
||||
int max_preceding;
|
||||
{
|
||||
int wday, dl, base;
|
||||
|
||||
wday = tp->tm_wday - starting_day;
|
||||
if (wday < 0)
|
||||
wday += 7;
|
||||
|
||||
/* Set DL to the day in the year of the first day of the week
|
||||
containing the day specified in TP. */
|
||||
dl = tp->tm_yday - wday;
|
||||
|
||||
/* For the computation following ISO 8601:1988 we set the number of
|
||||
the week containing January 1st to 1 if this week has more than
|
||||
MAX_PRECEDING days in the new year. For ISO 8601 this number is
|
||||
3, for the other representation it is 7 (i.e., not to be
|
||||
fulfilled). */
|
||||
base = ((dl + 7) % 7) > max_preceding ? 1 : 0;
|
||||
|
||||
/* If DL is negative we compute the result as 0 unless we have to
|
||||
compute it according ISO 8601. In this case we have to return 53
|
||||
or 1 if the week containing January 1st has less than 4 days in
|
||||
the new year or not. If DL is not negative we calculate the
|
||||
number of complete weeks for our week (DL / 7) plus 1 (because
|
||||
only for DL < 0 we are in week 0/53 and plus the number of the
|
||||
first week computed in the last step. */
|
||||
return dl < 0 ? (dl < -max_preceding ? 53 : base)
|
||||
: base + 1 + dl / 7;
|
||||
}
|
||||
|
||||
#ifndef _NL_CURRENT
|
||||
static char const weekday_name[][10] =
|
||||
{
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday"
|
||||
};
|
||||
static char const month_name[][10] =
|
||||
{
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Write information from TP into S according to the format
|
||||
string FORMAT, writing no more that MAXSIZE characters
|
||||
(including the terminating '\0') and returning number of
|
||||
characters written. If S is NULL, nothing will be written
|
||||
anywhere, so to determine how many characters would be
|
||||
written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
|
||||
size_t
|
||||
strftime (string, max, format, tm)
|
||||
char *string;
|
||||
size_t max;
|
||||
const char *format;
|
||||
const struct tm *tm;
|
||||
strftime (s, maxsize, format, tp)
|
||||
char *s;
|
||||
size_t maxsize;
|
||||
const char *format;
|
||||
register const struct tm *tp;
|
||||
{
|
||||
enum padding pad; /* Type of padding to apply. */
|
||||
size_t length = 0; /* Characters put in STRING so far. */
|
||||
int hour12 = tp->tm_hour;
|
||||
#ifdef _NL_CURRENT
|
||||
const char *const a_wkday = _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday);
|
||||
const char *const f_wkday = _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday);
|
||||
const char *const a_month = _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon);
|
||||
const char *const f_month = _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon);
|
||||
const char *const ampm = _NL_CURRENT (LC_TIME,
|
||||
hour12 > 11 ? PM_STR : AM_STR);
|
||||
size_t aw_len = strlen(a_wkday);
|
||||
size_t am_len = strlen(a_month);
|
||||
size_t ap_len = strlen (ampm);
|
||||
#else
|
||||
const char *const f_wkday = weekday_name[tp->tm_wday];
|
||||
const char *const f_month = month_name[tp->tm_mon];
|
||||
const char *const a_wkday = f_wkday;
|
||||
const char *const a_month = f_month;
|
||||
const char *const ampm = "AMPM" + 2 * (hour12 > 11);
|
||||
size_t aw_len = 3;
|
||||
size_t am_len = 3;
|
||||
size_t ap_len = 2;
|
||||
#endif
|
||||
size_t wkday_len = strlen(f_wkday);
|
||||
size_t month_len = strlen(f_month);
|
||||
const unsigned int y_week0 = week (tp, 0, 7);
|
||||
const unsigned int y_week1 = week (tp, 1, 7);
|
||||
const unsigned int y_week2 = week (tp, 1, 3);
|
||||
const char *zone;
|
||||
size_t zonelen;
|
||||
register size_t i = 0;
|
||||
register char *p = s;
|
||||
register const char *f;
|
||||
char number_fmt[5];
|
||||
|
||||
for (; *format && length < max; ++format)
|
||||
/* Initialize the buffer we will use for the sprintf format for numbers. */
|
||||
number_fmt[0] = '%';
|
||||
|
||||
zone = 0;
|
||||
#if HAVE_TM_ZONE
|
||||
zone = (const char *) tp->tm_zone;
|
||||
#endif
|
||||
#if HAVE_TZNAME
|
||||
if (!(zone && *zone) && tp->tm_isdst >= 0)
|
||||
zone = tzname[tp->tm_isdst];
|
||||
#endif
|
||||
if (!(zone && *zone))
|
||||
zone = "???";
|
||||
|
||||
zonelen = strlen (zone);
|
||||
|
||||
if (hour12 > 12)
|
||||
hour12 -= 12;
|
||||
else
|
||||
if (hour12 == 0) hour12 = 12;
|
||||
|
||||
for (f = format; *f != '\0'; ++f)
|
||||
{
|
||||
if (*format != '%')
|
||||
add_char (*format);
|
||||
else
|
||||
enum { pad_zero, pad_space, pad_none } pad; /* Padding for number. */
|
||||
unsigned int maxdigits; /* Max digits for numeric format. */
|
||||
unsigned int number_value; /* Numeric value to be printed. */
|
||||
const char *subfmt;
|
||||
|
||||
#if HAVE_MBLEN
|
||||
if (!isascii(*f))
|
||||
{
|
||||
++format;
|
||||
/* Modifiers: */
|
||||
if (*format == '-')
|
||||
/* Non-ASCII, may be a multibyte. */
|
||||
int len = mblen(f, strlen(f));
|
||||
if (len > 0)
|
||||
{
|
||||
pad = none;
|
||||
++format;
|
||||
}
|
||||
else if (*format == '_')
|
||||
{
|
||||
pad = blank;
|
||||
++format;
|
||||
}
|
||||
else
|
||||
pad = zero;
|
||||
|
||||
switch (*format)
|
||||
{
|
||||
/* Literal character fields: */
|
||||
case 0:
|
||||
case '%':
|
||||
add_char ('%');
|
||||
break;
|
||||
case 'n':
|
||||
add_char ('\n');
|
||||
break;
|
||||
case 't':
|
||||
add_char ('\t');
|
||||
break;
|
||||
default:
|
||||
add_char (*format);
|
||||
break;
|
||||
|
||||
/* Time fields: */
|
||||
case 'H':
|
||||
case 'k':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_hour, max - length,
|
||||
*format == 'H' ? pad : blank);
|
||||
break;
|
||||
case 'I':
|
||||
case 'l':
|
||||
{
|
||||
int hour12;
|
||||
|
||||
if (tm->tm_hour == 0)
|
||||
hour12 = 12;
|
||||
else if (tm->tm_hour > 12)
|
||||
hour12 = tm->tm_hour - 12;
|
||||
else
|
||||
hour12 = tm->tm_hour;
|
||||
length +=
|
||||
add_num2 (&string[length], hour12, max - length,
|
||||
*format == 'I' ? pad : blank);
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_min, max - length, pad);
|
||||
break;
|
||||
case 'p':
|
||||
if (tm->tm_hour < 12)
|
||||
add_char ('A');
|
||||
else
|
||||
add_char ('P');
|
||||
add_char ('M');
|
||||
break;
|
||||
case 'r':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%I:%M:%S %p", tm);
|
||||
break;
|
||||
case 'R':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%H:%M", tm);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
{
|
||||
struct tm writable_tm;
|
||||
writable_tm = *tm;
|
||||
length += add_num_time_t (&string[length], max - length,
|
||||
mktime (&writable_tm));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_sec, max - length, pad);
|
||||
break;
|
||||
case 'T':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%H:%M:%S", tm);
|
||||
break;
|
||||
case 'X':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%H:%M:%S", tm);
|
||||
break;
|
||||
case 'Z':
|
||||
#ifdef HAVE_TM_ZONE
|
||||
length += add_str (&string[length], tm->tm_zone, max - length);
|
||||
#else
|
||||
#ifdef HAVE_TZNAME
|
||||
if (tm->tm_isdst && tzname[1] && *tzname[1])
|
||||
length += add_str (&string[length], tzname[1], max - length);
|
||||
else
|
||||
length += add_str (&string[length], tzname[0], max - length);
|
||||
#else
|
||||
length += add_str (&string[length], zone_name (tm), max - length);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
/* Date fields: */
|
||||
case 'a':
|
||||
add_char (days[tm->tm_wday][0]);
|
||||
add_char (days[tm->tm_wday][1]);
|
||||
add_char (days[tm->tm_wday][2]);
|
||||
break;
|
||||
case 'A':
|
||||
length +=
|
||||
add_str (&string[length], days[tm->tm_wday], max - length);
|
||||
break;
|
||||
case 'b':
|
||||
case 'h':
|
||||
add_char (months[tm->tm_mon][0]);
|
||||
add_char (months[tm->tm_mon][1]);
|
||||
add_char (months[tm->tm_mon][2]);
|
||||
break;
|
||||
case 'B':
|
||||
length +=
|
||||
add_str (&string[length], months[tm->tm_mon], max - length);
|
||||
break;
|
||||
case 'c':
|
||||
length +=
|
||||
strftime (&string[length], max - length,
|
||||
"%a %b %d %H:%M:%S %Z %Y", tm);
|
||||
break;
|
||||
case 'C':
|
||||
length +=
|
||||
add_num2 (&string[length], (tm->tm_year + 1900) / 100,
|
||||
max - length, pad);
|
||||
break;
|
||||
case 'd':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_mday, max - length, pad);
|
||||
break;
|
||||
case 'e':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_mday, max - length, blank);
|
||||
break;
|
||||
case 'D':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%m/%d/%y", tm);
|
||||
break;
|
||||
case 'j':
|
||||
length +=
|
||||
add_num3 (&string[length], tm->tm_yday + 1, max - length, pad);
|
||||
break;
|
||||
case 'm':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_mon + 1, max - length, pad);
|
||||
break;
|
||||
case 'U':
|
||||
length +=
|
||||
add_num2 (&string[length], sun_week (tm), max - length, pad);
|
||||
break;
|
||||
case 'w':
|
||||
add_char (tm->tm_wday + '0');
|
||||
break;
|
||||
case 'W':
|
||||
length +=
|
||||
add_num2 (&string[length], mon_week (tm), max - length, pad);
|
||||
break;
|
||||
case 'x':
|
||||
length +=
|
||||
strftime (&string[length], max - length, "%m/%d/%y", tm);
|
||||
break;
|
||||
case 'y':
|
||||
length +=
|
||||
add_num2 (&string[length], tm->tm_year % 100,
|
||||
max - length, pad);
|
||||
break;
|
||||
case 'Y':
|
||||
add_char ((tm->tm_year + 1900) / 1000 + '0');
|
||||
length +=
|
||||
add_num3 (&string[length],
|
||||
(1900 + tm->tm_year) % 1000, max - length, zero);
|
||||
break;
|
||||
cpy(len, f);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (*f != '%')
|
||||
{
|
||||
add(1, *p = *f);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check for flags that can modify a number format. */
|
||||
++f;
|
||||
switch (*f)
|
||||
{
|
||||
case '_':
|
||||
pad = pad_space;
|
||||
++f;
|
||||
break;
|
||||
case '-':
|
||||
pad = pad_none;
|
||||
++f;
|
||||
break;
|
||||
default:
|
||||
pad = pad_zero;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now do the specified format. */
|
||||
switch (*f)
|
||||
{
|
||||
case '\0':
|
||||
case '%':
|
||||
add(1, *p = *f);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
cpy(aw_len, a_wkday);
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
cpy(wkday_len, f_wkday);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
case 'h': /* GNU extension. */
|
||||
cpy(am_len, a_month);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
cpy(month_len, f_month);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
#ifdef _NL_CURRENT
|
||||
subfmt = _NL_CURRENT (LC_TIME, D_T_FMT);
|
||||
#else
|
||||
subfmt = "%a %b %d %H:%M:%S %Z %Y";
|
||||
#endif
|
||||
subformat:
|
||||
{
|
||||
size_t len = strftime (p, maxsize - i, subfmt, tp);
|
||||
if (len == 0 && *subfmt)
|
||||
return 0;
|
||||
add(len, );
|
||||
}
|
||||
break;
|
||||
|
||||
#define DO_NUMBER(digits, value) \
|
||||
maxdigits = digits; number_value = value; goto do_number
|
||||
#define DO_NUMBER_NOPAD(digits, value) \
|
||||
maxdigits = digits; number_value = value; goto do_number_nopad
|
||||
|
||||
case 'C':
|
||||
DO_NUMBER (2, (1900 + tp->tm_year) / 100);
|
||||
|
||||
case 'x':
|
||||
#ifdef _NL_CURRENT
|
||||
subfmt = _NL_CURRENT (LC_TIME, D_FMT);
|
||||
goto subformat;
|
||||
#endif
|
||||
/* Fall through. */
|
||||
case 'D': /* GNU extension. */
|
||||
subfmt = "%m/%d/%y";
|
||||
goto subformat;
|
||||
|
||||
case 'd':
|
||||
DO_NUMBER (2, tp->tm_mday);
|
||||
|
||||
case 'e': /* GNU extension: %d, but blank-padded. */
|
||||
DO_NUMBER_NOPAD (2, tp->tm_mday);
|
||||
|
||||
/* All numeric formats set MAXDIGITS and NUMBER_VALUE and then
|
||||
jump to one of these two labels. */
|
||||
|
||||
do_number_nopad:
|
||||
/* Force `-' flag. */
|
||||
pad = pad_none;
|
||||
|
||||
do_number:
|
||||
{
|
||||
/* Format the number according to the PAD flag. */
|
||||
|
||||
register char *nf = &number_fmt[1];
|
||||
int printed;
|
||||
|
||||
switch (pad)
|
||||
{
|
||||
case pad_zero:
|
||||
*nf++ = '0';
|
||||
case pad_space:
|
||||
*nf++ = '0' + maxdigits;
|
||||
case pad_none:
|
||||
*nf++ = 'u';
|
||||
*nf = '\0';
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
add (maxdigits, printed = sprintf (p, number_fmt, number_value));
|
||||
#else
|
||||
add (maxdigits, sprintf (p, number_fmt, number_value);
|
||||
printed = strlen (p));
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 'H':
|
||||
DO_NUMBER (2, tp->tm_hour);
|
||||
|
||||
case 'I':
|
||||
DO_NUMBER (2, hour12);
|
||||
|
||||
case 'k': /* GNU extension. */
|
||||
DO_NUMBER_NOPAD (2, tp->tm_hour);
|
||||
|
||||
case 'l': /* GNU extension. */
|
||||
DO_NUMBER_NOPAD (2, hour12);
|
||||
|
||||
case 'j':
|
||||
DO_NUMBER (3, 1 + tp->tm_yday);
|
||||
|
||||
case 'M':
|
||||
DO_NUMBER (2, tp->tm_min);
|
||||
|
||||
case 'm':
|
||||
DO_NUMBER (2, tp->tm_mon + 1);
|
||||
|
||||
case 'n': /* GNU extension. */
|
||||
add (1, *p = '\n');
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
cpy(ap_len, ampm);
|
||||
break;
|
||||
|
||||
case 'R': /* GNU extension. */
|
||||
subfmt = "%H:%M";
|
||||
goto subformat;
|
||||
|
||||
case 'r': /* GNU extension. */
|
||||
subfmt = "%I:%M:%S %p";
|
||||
goto subformat;
|
||||
|
||||
case 'S':
|
||||
DO_NUMBER (2, tp->tm_sec);
|
||||
|
||||
case 'X':
|
||||
#ifdef _NL_CURRENT
|
||||
subfmt = _NL_CURRENT (LC_TIME, T_FMT);
|
||||
goto subformat;
|
||||
#endif
|
||||
/* Fall through. */
|
||||
case 'T': /* GNU extenstion. */
|
||||
subfmt = "%H:%M:%S";
|
||||
goto subformat;
|
||||
|
||||
case 't': /* GNU extenstion. */
|
||||
add (1, *p = '\t');
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
DO_NUMBER (2, y_week0);
|
||||
|
||||
case 'V':
|
||||
DO_NUMBER (2, y_week2);
|
||||
|
||||
case 'W':
|
||||
DO_NUMBER (2, y_week1);
|
||||
|
||||
case 'w':
|
||||
DO_NUMBER (2, tp->tm_wday);
|
||||
|
||||
case 'Y':
|
||||
DO_NUMBER (4, 1900 + tp->tm_year);
|
||||
|
||||
case 'y':
|
||||
DO_NUMBER (2, tp->tm_year % 100);
|
||||
|
||||
case 'Z':
|
||||
cpy(zonelen, zone);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Bad format. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
add_char (0);
|
||||
return length - 1;
|
||||
|
||||
if (p)
|
||||
*p = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
49
lib/strndup.c
Normal file
49
lib/strndup.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 1996 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
/* Duplicate S, returning an identical malloc'd string. */
|
||||
char *
|
||||
strndup (s, n)
|
||||
const char *s;
|
||||
size_t n;
|
||||
{
|
||||
char *new = malloc (n + 1);
|
||||
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
memcpy (new, s, n);
|
||||
new[n] = '\0';
|
||||
|
||||
return new;
|
||||
}
|
||||
173
lib/strtol.c
173
lib/strtol.c
@@ -1,21 +1,22 @@
|
||||
/* Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 94, 95, 96 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.
|
||||
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 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.
|
||||
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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>
|
||||
@@ -33,7 +34,7 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
@@ -56,18 +57,41 @@ extern int errno;
|
||||
# define UNSIGNED 0
|
||||
# define INT LONG int
|
||||
#else
|
||||
# define strtol strtoul
|
||||
# define INT unsigned LONG int
|
||||
#endif
|
||||
|
||||
/* Determine the name. */
|
||||
#if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstouq
|
||||
# else
|
||||
# define strtol wcstoul
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtouq
|
||||
# else
|
||||
# define strtol strtoul
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoq
|
||||
# else
|
||||
# define strtol wcstol
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoq
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If QUAD is defined, we are defining `strtoq' or `strtouq',
|
||||
operating on `long long int's. */
|
||||
#ifdef QUAD
|
||||
# if UNSIGNED
|
||||
# define strtoul strtouq
|
||||
# else
|
||||
# define strtol strtoq
|
||||
# endif
|
||||
# define LONG long long
|
||||
# undef LONG_MIN
|
||||
# define LONG_MIN LONG_LONG_MIN
|
||||
@@ -83,13 +107,41 @@ extern int errno;
|
||||
# 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
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIDE_CHAR
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
# define L_(ch) L##ch
|
||||
# define UCHAR_TYPE wint_t
|
||||
# define STRING_TYPE wchar_t
|
||||
# define ISSPACE(ch) iswspace (ch)
|
||||
# define ISALPHA(ch) iswalpha (ch)
|
||||
# define TOUPPER(ch) towupper (ch)
|
||||
#else
|
||||
# define L_(ch) ch
|
||||
# define UCHAR_TYPE unsigned char
|
||||
# define STRING_TYPE char
|
||||
# define ISSPACE(ch) isspace (ch)
|
||||
# define ISALPHA(ch) isalpha (ch)
|
||||
# define TOUPPER(ch) toupper (ch)
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
# define INTERNAL(x) INTERNAL1(x)
|
||||
# define INTERNAL1(x) __##x##_internal
|
||||
# define WEAKNAME(x) WEAKNAME1(x)
|
||||
# define WEAKNAME1(x) __##x
|
||||
#else
|
||||
# define INTERNAL(x) __/**/x/**/_internal
|
||||
# define WEAKNAME(x) __/**/x
|
||||
#endif
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
@@ -107,8 +159,8 @@ extern int errno;
|
||||
|
||||
INT
|
||||
INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
int group;
|
||||
{
|
||||
@@ -116,9 +168,9 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
register unsigned LONG int cutoff;
|
||||
register unsigned int cutlim;
|
||||
register unsigned LONG int i;
|
||||
register const char *s;
|
||||
register unsigned char c;
|
||||
const char *save, *end;
|
||||
register const STRING_TYPE *s;
|
||||
register UCHAR_TYPE c;
|
||||
const STRING_TYPE *save, *end;
|
||||
int overflow;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
@@ -150,21 +202,21 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
if (base < 0 || base == 1 || base > 36)
|
||||
base = 10;
|
||||
|
||||
s = nptr;
|
||||
save = s = nptr;
|
||||
|
||||
/* Skip white space. */
|
||||
while (isspace (*s))
|
||||
while (ISSPACE (*s))
|
||||
++s;
|
||||
if (*s == '\0')
|
||||
if (*s == L_('\0'))
|
||||
goto noconv;
|
||||
|
||||
/* Check for a sign. */
|
||||
if (*s == '-')
|
||||
if (*s == L_('-'))
|
||||
{
|
||||
negative = 1;
|
||||
++s;
|
||||
}
|
||||
else if (*s == '+')
|
||||
else if (*s == L_('+'))
|
||||
{
|
||||
negative = 0;
|
||||
++s;
|
||||
@@ -172,14 +224,14 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
else
|
||||
negative = 0;
|
||||
|
||||
if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X')
|
||||
if (base == 16 && s[0] == L_('0') && TOUPPER (s[1]) == L_('X'))
|
||||
s += 2;
|
||||
|
||||
/* If BASE is zero, figure it out ourselves. */
|
||||
if (base == 0)
|
||||
if (*s == '0')
|
||||
if (*s == L_('0'))
|
||||
{
|
||||
if (toupper (s[1]) == 'X')
|
||||
if (TOUPPER (s[1]) == L_('X'))
|
||||
{
|
||||
s += 2;
|
||||
base = 16;
|
||||
@@ -198,9 +250,9 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
{
|
||||
/* Find the end of the digit string and check its grouping. */
|
||||
end = s;
|
||||
for (c = *end; c != '\0'; c = *++end)
|
||||
if (c != thousands && !isdigit (c) &&
|
||||
(!isalpha (c) || toupper (c) - 'A' + 10 >= base))
|
||||
for (c = *end; c != L_('\0'); c = *++end)
|
||||
if (c != thousands && (c < L_('0') || c > L_('9'))
|
||||
&& (!ISALPHA (c) || TOUPPER (c) - L_('A') + 10 >= base))
|
||||
break;
|
||||
if (*s == thousands)
|
||||
end = s;
|
||||
@@ -216,14 +268,14 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
|
||||
overflow = 0;
|
||||
i = 0;
|
||||
for (c = *s; c != '\0'; c = *++s)
|
||||
for (c = *s; c != L_('\0'); c = *++s)
|
||||
{
|
||||
if (s == end)
|
||||
break;
|
||||
if (isdigit (c))
|
||||
c -= '0';
|
||||
else if (isalpha (c))
|
||||
c = toupper (c) - 'A' + 10;
|
||||
if (c >= L_('0') && c <= L_('9'))
|
||||
c -= L_('0');
|
||||
else if (ISALPHA (c))
|
||||
c = TOUPPER (c) - L_('A') + 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
@@ -245,13 +297,15 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
/* Store in ENDPTR the address of one character
|
||||
past the last character we converted. */
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *) s;
|
||||
*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 (i > (negative ?
|
||||
-(unsigned LONG int) LONG_MIN : (unsigned LONG int) LONG_MAX))
|
||||
if (overflow == 0
|
||||
&& i > (negative
|
||||
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
|
||||
: (unsigned LONG int) LONG_MAX))
|
||||
overflow = 1;
|
||||
#endif
|
||||
|
||||
@@ -269,22 +323,39 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
return (negative ? -i : i);
|
||||
|
||||
noconv:
|
||||
/* There was no number to convert. */
|
||||
/* We must handle a special case here: the base is 0 or 16 and the
|
||||
first two characters and '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)
|
||||
*endptr = (char *) nptr;
|
||||
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. */
|
||||
|
||||
#ifdef weak_symbol
|
||||
weak_symbol (strtol)
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define __P(args) args
|
||||
#else
|
||||
#define __P(args) ()
|
||||
#endif
|
||||
|
||||
/* Prototype. */
|
||||
INT strtol __P ((const STRING_TYPE *nptr, STRING_TYPE **endptr,
|
||||
int base));
|
||||
|
||||
|
||||
INT
|
||||
strtol (nptr, endptr, base)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
{
|
||||
return INTERNAL (strtol) (nptr, endptr, base, 0);
|
||||
|
||||
71
lib/xstrtod.c
Normal file
71
lib/xstrtod.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/* xstrtod.c - error-checking interface to strtod
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
double strtod ();
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "xstrtod.h"
|
||||
|
||||
/* An interface to strtod that encapsulates all the error checking
|
||||
one should usually perform. Like strtod, but upon successful
|
||||
conversion put the result in *RESULT and return zero. Return
|
||||
non-zero and don't modify *RESULT upon any failure. */
|
||||
|
||||
int
|
||||
xstrtod (str, ptr, result)
|
||||
const char *str;
|
||||
const char **ptr;
|
||||
double *result;
|
||||
{
|
||||
double val;
|
||||
char *terminator;
|
||||
int fail;
|
||||
|
||||
fail = 0;
|
||||
errno = 0;
|
||||
val = strtod (str, &terminator);
|
||||
|
||||
/* Having a non-zero terminator is an error only when PTR is NULL. */
|
||||
if (terminator == str || (ptr == NULL && *terminator != '\0'))
|
||||
fail = 1;
|
||||
else
|
||||
{
|
||||
/* Allow underflow (in which case strtod returns zero),
|
||||
but flag overflow as an error. */
|
||||
if (val != 0.0 && errno == ERANGE)
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
*ptr = terminator;
|
||||
|
||||
*result = val;
|
||||
return fail;
|
||||
}
|
||||
|
||||
15
lib/xstrtod.h
Normal file
15
lib/xstrtod.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef XSTRTOD_H
|
||||
#define XSTRTOD_H 1
|
||||
|
||||
#ifndef __P
|
||||
# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
# define __P(args) args
|
||||
# else
|
||||
# define __P(args) ()
|
||||
# endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
int
|
||||
xstrtod __P ((const char *str, const char **ptr, double *result));
|
||||
|
||||
#endif /* XSTRTOD_H */
|
||||
@@ -1,3 +1,22 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright (C) 1995, 1996 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. */
|
||||
|
||||
/* Jim Meyering (meyering@na-net.ornl.gov) */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,810 @@
|
||||
Thu Jul 11 21:50:48 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 3.13.
|
||||
|
||||
* dircolors.1: New file -- but just a pointer to texinfo docs.
|
||||
* man/Makefile.am (man_MANS): Add dircolors.1.
|
||||
|
||||
* configure.in (VERSION): Bump to 3.13.
|
||||
|
||||
Wed Jul 10 22:57:29 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* aclocal.m4 (fp_PROG_CC_STDC): Include sys/stat.h in test program
|
||||
so that DYNIX/ptx V4.1.3 doesn't use `-Xc -D__EXTENSIONS__' -- with
|
||||
those options on that system, sys/stat.h gets compile errors.
|
||||
With help from Marcus Daniels.
|
||||
|
||||
* getopt.c: Update from gettext-0.10.23.
|
||||
* getopt1.c: Likewise.
|
||||
* getopt.h: Likewise.
|
||||
|
||||
Tue Jul 9 20:19:44 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/dircolors.c (usage): Improve --help message. From Karl Berry.
|
||||
(long_options): Add print-data-base and print-database.
|
||||
|
||||
* src/dircolors.c (dc_parse_stream): Don't give `unrecognized keyword'
|
||||
message unless we've processed a matching TERM directive. Reported
|
||||
by Karl Berry and François Pinard.
|
||||
|
||||
* src/install.c (UID_T_MAX): Use `(unsigned long)1' rather than
|
||||
`(uid_t)1' to avoid problems on systems where uid_t is signed.
|
||||
(GID_T_MAX): Likewise for gid_t.
|
||||
From Kjetil Torgrim Homme <kjetilho@ifi.uio.no>.
|
||||
|
||||
Sun Jul 7 22:40:08 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/ls.c: Change initial colors for `color_indicator' to match
|
||||
those currently in dircolors.hin. From Joshua Cowan.
|
||||
|
||||
* src/dircolors.hin: Recognize more filename extensions.
|
||||
From Joshua Cowan.
|
||||
|
||||
* src/Makefile.am (CLEANFILES): Add dcgen. From Joshua Cowan
|
||||
<jcowan@jcowan.reslife.okstate.edu>.
|
||||
|
||||
* src/Makefile.am (MAINTAINERCLEANFILES): Add dircolors.h.
|
||||
|
||||
* configure.in (AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL): Use it.
|
||||
* acconfig.h [GWINSZ_IN_SYS_IOCTL]: Add #undef.
|
||||
|
||||
* src/ls.c: Include termios.h.
|
||||
Guard inclusion of sys/ioctl.h with #ifdef GWINSZ_IN_SYS_IOCTL,
|
||||
rather than HAVE_SYS_IOCTL_H. Modelled after sh-utils' stty.c
|
||||
at suggestion from Chip Bennett <BennettC@j64.stratcom.af.mil>
|
||||
to make ls adjust its idea of screen width upon window resize
|
||||
on systems (SunOS, Solaris) where TIOCGWINSZ is defined in
|
||||
termios.h, and not sys/ioctl.h.
|
||||
|
||||
* aclocal.m4 (AM_SYS_POSIX_TERMIOS): New macro, derived from test
|
||||
in the configure.in from sh-utils.
|
||||
(AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL): Likewise.
|
||||
|
||||
Sat Jul 6 12:46:27 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/cp-aux.c (usage): Factor out backup-related text into
|
||||
separate string/printf statement so translators deal with only
|
||||
one corresponding string in .pot file.
|
||||
* src/install.c (usage): Likewise.
|
||||
* src/ln.c (usage): Likewise.
|
||||
* src/mv.c (usage): Likewise.
|
||||
Suggestion from Santiago Vila Doncel.
|
||||
|
||||
* configure.in (AC_REPLACE_FUNCS): Add group_member.
|
||||
(AC_LINK_FILES): Create link lib/group_member.c to lib/group-member.c.
|
||||
* lib/Makefile.am (fu_SOURCES): Remove group-member.c.
|
||||
(EXTRA_DIST): Add group-member.c here.
|
||||
|
||||
Fri Jul 5 22:16:13 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/dircolors.c [!STDC_HEADERS]: Declare free.
|
||||
From Marcus Daniels.
|
||||
|
||||
Thu Jul 4 12:34:50 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/dd.c (usage): Remove space before newline in usage message.
|
||||
* src/mknod.c (usage): Likewise.
|
||||
* src/mv.c (usage): Likewise.
|
||||
|
||||
* src/Makefile.am (libexec_PROGRAMS): Regenerate using patched
|
||||
automake-1.0 to work around rm -f bug on Solaris2.4.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* src/ls.c: Make `dir --version' and `vdir --version' print their
|
||||
names, not `ls'.
|
||||
Reported by Ulrich Drepper.
|
||||
|
||||
Wed Jul 3 17:41:15 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/dircolors.c: Include sys/types.h before system.h.
|
||||
From Jim Blandy (jimb@cyclic.com).
|
||||
|
||||
* src/chgrp.c [!MAXUID]: Define after inclusion of system.h to avoid
|
||||
warning about redefinition on SunOS4, Solaris2.4 and SGI-irix5.3.
|
||||
From Kaveh Ghazi. Also, Santiago Vila Doncel reported that defining
|
||||
MAXUID before including system.h caused a compilation failure on some
|
||||
ConvexOS system.
|
||||
|
||||
Tue Jul 2 22:56:03 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (VERSION): Bump to 3.12q.
|
||||
|
||||
* src/system.h [!EXIT_SUCCESS]: Define it.
|
||||
[!EXIT_FAILURE]: Define it.
|
||||
|
||||
* lib/strndup.c (strndup): Include stdio.h and sys/types.h to
|
||||
get definition of NULL and size_t on SunOS4.1.3.
|
||||
|
||||
Mon Jul 1 23:47:29 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/ln.c (do_link): Update messages to ease translation.
|
||||
Suggestion from Santiago Vila.
|
||||
|
||||
Sun Jun 30 16:41:45 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/install.c (usage): Fix typo, 3nd->3rd, in usage message.
|
||||
From Santiago Vila Doncel.
|
||||
|
||||
Sat Jun 29 00:33:31 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (PACKAGE_VERSION): Add `GNU ' prefix so we see
|
||||
it in the output of --version. Reported by RMS.
|
||||
|
||||
* src/Makefile.am (BUILT_SOURCES): Guard dependency on dircolors.h
|
||||
with @MAINT@ so it won't be removed with a casual disctlean.
|
||||
(EXTRA_DIST): Add dcgen.pl and dircolors.hin.
|
||||
|
||||
Fri Jun 28 22:56:00 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/dircolors.c (dc_parse_stream): Move `enum states' dcl into
|
||||
this function.
|
||||
|
||||
* src/ln.c (do_link): Allow `ln -sf --backup k k' to succeed in
|
||||
creating the self-referential symlink, since doing so doesn't
|
||||
remove the source but merely renames it.
|
||||
|
||||
Wed Jun 26 06:58:58 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* ln.c (same_name): New function.
|
||||
(do_link): Use it to test reliably whether A and B (from
|
||||
ln --force A B) are hard links to the same file.
|
||||
From Andreas Schwab.
|
||||
|
||||
Tue Jun 25 00:03:43 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* lib/getline.c: New file.
|
||||
* lib/getline.h: New file.
|
||||
* lib/Makefile.am (fu_SOURCES): Add getline.c.
|
||||
(noinst_HEADERS): Add getline.h.
|
||||
|
||||
Mon Jun 24 22:39:02 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strndup.
|
||||
(AC_PATH_PROG): Check for perl.
|
||||
|
||||
* ls.c (decode_switches): Allow 0 as argument to --tabsize (-T) option.
|
||||
Interpret as a directive to use no TAB characters to separate columns.
|
||||
(indent): Handle TABSIZE == 0.
|
||||
|
||||
* dircolors.c (dc_parse_stream): Remove spurious newline in
|
||||
error message.
|
||||
(dc_parse_stream): Give `unrecognized keyword' diagnostic for
|
||||
misspelled `TERM' keyword as well as for others.
|
||||
|
||||
Sun Jun 23 12:58:32 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* dircolors.hin: New file.
|
||||
* dcgen.pl: New file.
|
||||
* src/Makefile.am (dircolors.h): Add a rule to create this file.
|
||||
(dcgen): Likewise.
|
||||
|
||||
* dircolors.c (parse_line): Rewrite to avoid modifying LINE.
|
||||
Put LINE first in parameter list.
|
||||
Adjust caller.
|
||||
(dc_parse_stream): Free KEYWD and ARG.
|
||||
(main): Give diagnostic for unreasonable combinations of
|
||||
options/arguments.
|
||||
|
||||
* lib/Makefile.am (EXTRA_DIST): Add strndup.c.
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strndup.
|
||||
* strndup.c: New file. From id-utils-3.0k.
|
||||
(strndup): Deansify.
|
||||
[!STDC_HEADERS]: Include string.h and stdlib.h.
|
||||
|
||||
Sat Jun 22 16:57:53 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* dircolors.c: Major overhaul. No longer read from /etc/DIR_COLORS
|
||||
or from ~/.dircolors. Defaults are now compiled in. If you specify
|
||||
a file on the command line, it is used instead of the compiled-in
|
||||
defaults.
|
||||
(main): New option --print-database (-p).
|
||||
Detect write failure.
|
||||
Add --bourne-shell and --c-shell aliases for --sh and --csh resp.
|
||||
|
||||
Tue Jun 18 20:54:05 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* cp.c (copy_reg): Cast both sides of comparison to size_t
|
||||
to avoid a warning about `comparison between signed and unsigned'
|
||||
from gcc -Wall.
|
||||
Declare pointer parameters const as appropriate.
|
||||
|
||||
* ln.c (do_link): Refine last change so we don't disallow commands
|
||||
like `ln --force A B' when A and B are hard links to the same file.
|
||||
See comments in the source. Reported by Erik Naggum <erik@naggum.no>
|
||||
and Andreas Schwab.
|
||||
|
||||
* ls.c (decode_switches): Correct typo in error messages:
|
||||
enironment -> environment. From Santiago Vila Doncel
|
||||
<sanvila@unex.es>.
|
||||
|
||||
* aclocal.m4: Update from gettext-0.10.20.
|
||||
* ABOUT-NLS: Likewise.
|
||||
* intl/*: Likewise.
|
||||
|
||||
* cp.c (do_copy): Change message from `missing file argument' to
|
||||
more precise `missing destination file'. From Karl Berry.
|
||||
|
||||
* ln.c (STREQ): Remove macro definition
|
||||
* system.h (STREQ): Add it here instead.
|
||||
* cp.c (do_copy): Use STREQ here instead of strcmp(...) == 0.
|
||||
* ls.c (parse_ls_color): Likewise.
|
||||
* df.c (selected_fstype, excluded_fstype, show_disk, main): Likewise.
|
||||
|
||||
* cp.c (do_copy): When the force and backup options have been
|
||||
specified and the source and destination are the same name for an
|
||||
existing, regular file, convert the user's command, e.g.
|
||||
`cp --force --backup foo foo' to `cp --force foo fooSUFFIX'
|
||||
where SUFFIX is determined by any version control options used.
|
||||
(usage): Update --help message.
|
||||
At urging of (most recently) Karl Berry.
|
||||
|
||||
Sun Jun 16 13:40:22 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* doc/Makefile.am (EXTRA_DIST): Add texinfo.tex.
|
||||
|
||||
* Makefile.am (cvs-dist): Use -c option in cvs tag command.
|
||||
|
||||
Sat Jun 15 22:21:09 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add pt.
|
||||
(AC_REPLACE_FUNCS): Add basename.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add basename.c.
|
||||
(fu_SOURCES): Remove basename.c.
|
||||
|
||||
Thu Jun 6 21:57:08 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* po/Makefile.in.in: Update from gettext-0.10.16.
|
||||
* intl/*: Likewise.
|
||||
* ABOUT-NLS: Likewise.
|
||||
* aclocal.m4 (AC_REPLACE_GNU_GETOPT): Move definition to precede
|
||||
gettext-related ones.
|
||||
Update from gettext-0.10.16.
|
||||
|
||||
Sat Jun 1 12:44:51 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* ls.c: Rename options and internal variables to reflect change to
|
||||
--color=WHEN where WHEN is never, always, or auto (for consistency
|
||||
with e.g. cp --sparse=WHEN. For at least a while, the original
|
||||
slackware-supported arguments `none', `force', `yes', etc will be
|
||||
supported but deprecated by lack of documentation.
|
||||
(decode_switches): Use STDOUT_FILENO instead of `1' in isatty test.
|
||||
(usage): Update/add description of the --color option.
|
||||
|
||||
* ls.c: Declare pointer parameters const as appropriate.
|
||||
|
||||
Tue May 28 18:39:49 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* dd.c (print_stats): Don't mark "%u %s" as a translatable string.
|
||||
* mv.c (main): Don't mark "%s" as a translatable string.
|
||||
From Göran Uddeborg.
|
||||
|
||||
Thu May 23 07:50:38 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* ls.c (usage): Make --literal (-N) description clearer.
|
||||
|
||||
* acconfig.h (MOUNTED_LISTMNTENT): Add it.
|
||||
* fsusage [_CRAY]: Don't include sys/filsys.h because although
|
||||
Unicos-9 has it, it's not needed and would cause other problems
|
||||
because it requires inclusion of other, non-standard headers.
|
||||
* mountlist.c (read_filesystem_list) [MOUNTED_LISTMNTENT]: New
|
||||
function.
|
||||
From Johan Danielsson (joda@pdc.kth.se).
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add listmntent for Unicos-9.
|
||||
Define MOUNTED_LISTMNTENT #ifdef _CRAY and HAVE_GETMNTENT.
|
||||
With an initial patch from Johan Danielsson.
|
||||
|
||||
Wed May 22 18:58:01 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (LINGUAS): Add sv.
|
||||
|
||||
Tue May 21 07:06:30 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* lib/euidaccess.c (euidaccess) [!S_IROTH]: Define.
|
||||
[!S_IWOTH]: Define.
|
||||
[!S_IXOTH]: Define.
|
||||
Marcus Daniels <marcus@sysc.pdx.edu> reported that m68k NEXTSTEP 3.2
|
||||
doesn't define S_IROTH or S_IWOTH unless some posix compile option
|
||||
is used and associated symbols defined.
|
||||
|
||||
Sun May 19 09:32:51 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* chown.c: New option: --no-dereference (-h). Solaris 5.4's chown
|
||||
provides -h.
|
||||
(change_file_owner): Use lchown if --no-dereference (-h) was given.
|
||||
(usage): Update.
|
||||
(main): Fail if user requests --no-dereference on a system that
|
||||
doesn't have support for it.
|
||||
|
||||
* chgrp.c: New option: --no-dereference (-h).
|
||||
[!MAXUID]: Define to INT_MAX.
|
||||
(change_file_group): Use lchown if --no-dereference (-h) was given.
|
||||
(usage): Update.
|
||||
(main): Fail if user requests --no-dereference on a system that
|
||||
doesn't have support for it.
|
||||
|
||||
Wed May 15 22:54:31 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* fsusage.c (get_fs_usage): Declare parameter PATH to be const.
|
||||
* fsusage.h: Update prototype to match.
|
||||
|
||||
* chmod.c (describe_change): Declare pointer parameters to be const.
|
||||
(change_file_mode): Likewise.
|
||||
(change_dir_mode): Likewise.
|
||||
|
||||
* ln.c (do_link): Declare pointer parameters to be const.
|
||||
|
||||
* df.c (main): Fail with a diagnostic if both --human-readable and
|
||||
--portability are used.
|
||||
Likewise if --megabytes and --portability are used.
|
||||
Rearrange function definitions to precede respective uses to obviate
|
||||
all forward dcls. Remove forward dcls.
|
||||
Declare parameters const as appropriate.
|
||||
|
||||
* modechange.c (mode_compile): Declare parameter MODE_STRING const.
|
||||
Remove register attribute.
|
||||
(mode_adjust): Likewise for CHANGES.
|
||||
* modechange.h: Reflect above changes in prototypes.
|
||||
|
||||
* lib/Makefile.am (getdate.c): Disable dependencies that can
|
||||
require rerunning YACC when not in maintainer mode.
|
||||
(posixtm.c): Likewise.
|
||||
|
||||
Tue May 14 23:36:54 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* dd.c (print_stats): Restructure pluralization of error message
|
||||
so it's easier to translate. Reported by Göran Uddeborg
|
||||
<gvran@uddeborg.pp.se>.
|
||||
* mv.c (main): Likewise.
|
||||
|
||||
Tue May 7 22:10:20 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in: Require autoconf-2.10.
|
||||
|
||||
* aclocal.m4 (jm_MAINTAINER_MODE): New macro.
|
||||
* configure.in (jm_MAINTAINER_MODE): Use it.
|
||||
|
||||
Sun May 5 20:27:47 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* src/Makefile.am (bin_PROGRAMS): Add dircolors.
|
||||
(DEFS): Add -DSHAREDIR=\"$(datadir)\".
|
||||
(GNUVER): Remove definition of unused variable.
|
||||
|
||||
Sat May 4 20:54:32 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* system.h [IN_CTYPE_DOMAIN]: Rename from ISASCII.
|
||||
* backupfile.c [IN_CTYPE_DOMAIN]: Rename from ISASCII.
|
||||
|
||||
* dircolors.c: Make enumerated constants upper case.
|
||||
(main): Don't use ANSI-style string concatenation.
|
||||
Add `static' and/or `const' to some file scope variables.
|
||||
|
||||
Wed May 1 00:20:00 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* lib/Makefile.am (EXTRA_DIST): Add strcasecmp.c.
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strcasecmp.
|
||||
|
||||
* ls.c (parse_ls_color, usage): Remove support for alternate spellings:
|
||||
--colours and LS_COLOURS.
|
||||
(parse_ls_color): Reverse sense of test for LS_COLORS environment
|
||||
variable and return -- save a level of indentation on a 100+-line
|
||||
block.
|
||||
|
||||
Mon Apr 29 22:07:41 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* POTFILES.in: Add chgrp.c. From François Pinard.
|
||||
Add dircolors.c.
|
||||
* dircolors.c: New file. Written by H. Peter Anvin.
|
||||
|
||||
Sun Apr 28 16:32:38 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* ls.c: Apply color ls changes by Peter Anvin <Peter.Anvin@linux.org>
|
||||
and Dennis Flaherty <dennisf@denix.elk.miles.com> based on original
|
||||
patches by Greg Lee <lee@uhunix.uhcc.hawaii.edu>. And on top of all
|
||||
that, a few changes from Ulrich Drepper.
|
||||
|
||||
* ls.c (parse_ls_color): Use strcpy to initialize 3-character array.
|
||||
Automatic aggregate initialization isn't portable.
|
||||
Remove all ^L's.
|
||||
(get_funky_string): Declare static and move to precede single
|
||||
caller: parse_ls_color.
|
||||
Make some globals `static' and/or `const'.
|
||||
(LEN_STR_PAIR): New macro.
|
||||
(color_indicator): Use it in this declaration.
|
||||
(parse_ls_color): Use error, not fprintf.
|
||||
(decode_switches): Add a comment.
|
||||
(print_name_with_quoting): Add braces around inner if-else
|
||||
statement to clarify.
|
||||
|
||||
* configure.in: Add a comment that fp_C_PROTOTYPES must precede
|
||||
AC_C_INLINE. Otherwise, some systems lose because the value
|
||||
AC_C_INLINE choses with plain `cc' is different from that chosen
|
||||
when using the ANSI-mode C compiler. From Kaveh Ghazi.
|
||||
|
||||
* fileblocks.c [HAVE_ST_BLOCKS || _POSIX_VERSION]: Add extern dcl
|
||||
of unused variable so that after preprocessing, the file will never
|
||||
be empty. Otherwise, some compilers in ANSI mode (among them, the
|
||||
Dec Alpha OSF 2.0 C compiler) reject empty files. From Kaveh Ghazi.
|
||||
Indent CPP conditionals.
|
||||
|
||||
Fri Apr 26 05:52:03 1996 Karl Eichwalder <ke@ke.Central.DE>
|
||||
|
||||
* ls.c (usage): Add newline at end of printf format string.
|
||||
|
||||
Wed Apr 24 21:33:43 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* ln.c (do_link): Remove duplicate `if (lstat(...' block.
|
||||
|
||||
* ln.c (do_link): With --force, don't remove DEST when it's
|
||||
the same as SOURCE. Before, `ln -f FILE FILE' would remove FILE.
|
||||
Reported by Bruno Haible (haible@ilog.fr).
|
||||
|
||||
* mkdir.c (main): Use verbose_fmt_string, not string literal in
|
||||
call to make_path for --parents. Reported by Ulrich Drepper.
|
||||
|
||||
* doc/mdate-sh: Get year as last rather than 6th field in output
|
||||
of date. Otherwise, people with 2-word TZ (like `MET DST') lost.
|
||||
From Andreas Schwab.
|
||||
|
||||
Tue Apr 23 22:05:35 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* src/*.c, src/*.h: Update Copyright years to include 1996.
|
||||
|
||||
* aclocal.m4 (AC_REPLACE_GNU_GETOPT): New macro.
|
||||
* configure.in: Use it.
|
||||
* lib/Makefile.am (fu_SOURCES): Remove getopt.c and getopt1.c.
|
||||
(EXTRA_DIST): Add getopt.c and getopt1.c
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add lchown.
|
||||
* chgrp.c [HAVE_LCHOWN]: Define chown to lchown.
|
||||
* chown.c [HAVE_LCHOWN]: Likewise.
|
||||
* cp.c [HAVE_LCHOWN]: Likewise.
|
||||
* mv.c [HAVE_LCHOWN]: Likewise.
|
||||
Suggested by François Pinard.
|
||||
|
||||
* backupfile.c (find_backup_file_name, max_backup_version,
|
||||
make_version_name, version_number, concat): Const-ify decls of
|
||||
formal parameters.
|
||||
* backupfile.h: Likewise.
|
||||
|
||||
* du.c (usage): The long-named arg is --human-readable, not --human.
|
||||
* df.c: Be consistent. Accept --human-readable, not just --human.
|
||||
(usage): Reflect the change.
|
||||
From Karl Berry.
|
||||
|
||||
Sun Apr 21 08:04:51 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* df.c (usage): Reflect that now --no-sync is the default.
|
||||
|
||||
* Makefile.am (LDADD): Put @INTLLIBS@ before package library.
|
||||
|
||||
Sat Apr 20 22:48:59 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* ls.c: Include xstrtol.h.
|
||||
(decode_switches): Use xstrtol, not atoi.
|
||||
Detect and ignore invalid value for COLUMNS environment variable.
|
||||
In error about invalid TABSIZE, don't reference optarg!
|
||||
[!POSIXLY_CORRECT]: Don't consider TABSIZE environment variable.
|
||||
|
||||
* install.c: Include xstrtol.h.
|
||||
[HAVE_VALUES_H]: Include <values.h>.
|
||||
[!BITSPERBYTE]: Define.
|
||||
[!UID_T_MAX]: Define.
|
||||
[!GID_T_MAX]: Define.
|
||||
(get_ids): Use xstrtol, not atoi.
|
||||
(is_number): Remove now-unused function.
|
||||
* configure.in (AC_CHECK_HEADERS): Add values.h.
|
||||
|
||||
Fri Apr 19 00:06:02 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* Makefile.am (cvs-dist): New rule. Based on the one from
|
||||
Tom Tromey's automake.
|
||||
|
||||
* df.c: No longer call sync by default.
|
||||
|
||||
* cp.c (copy_reg): Rearrange arithmetic in conditional to avoid
|
||||
integer overflow with large files.
|
||||
|
||||
Fri Apr 12 21:40:44 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* mkdir.c (main): Add new option: --verbose.
|
||||
Remove long-deprecated and nowhere-documented --path, a synonym
|
||||
for --parents. It was confusing to get an error about `--p'
|
||||
being ambiguous.
|
||||
|
||||
Thu Apr 4 21:28:03 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (LINGUAS): Add de.
|
||||
* po/de.po: New file.
|
||||
|
||||
* src/Makefile.am (EXTRAdir): Set to $(bindir).
|
||||
|
||||
Wed Apr 3 06:12:23 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cp.c (copy_reg): Use `ST_NBLOCKS (sb) * 512', not `sb.st_blocks *
|
||||
DEV_BSIZE.' From H.J. Lu (hjl@lucon.org).
|
||||
|
||||
* mvdir.c: Protoize.
|
||||
Include save-cwd.h.
|
||||
(fullpath): Rewrite to use save_cwd, xgetcwd, and restore_cwd
|
||||
rather than explicit chdir/getcwd calls.
|
||||
|
||||
* src/Makefile.am (INCLUDES): Add -I$(srcdir) to get system.h
|
||||
when srcdir != builddir. From Kaveh Ghazi.
|
||||
|
||||
Mon Apr 1 23:50:29 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cp.c: Include assert.h (disabled).
|
||||
(path_concat): New function.
|
||||
(do_copy): Use path_concat instead of open-coding part of its
|
||||
functionality in two places. This has the additional benefit
|
||||
of avoiding forming destination names like `D//file' when the
|
||||
destination directory D includes a trailing slash -- as would
|
||||
happen when cp is used like this:
|
||||
mkdir D; touch file D/file; cp -i file D/
|
||||
Reported by François Pinard.
|
||||
|
||||
Sun Mar 31 11:18:09 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* ls.c (quote_filename): Use ISGRAPH and ISPRINT in place of
|
||||
ASCII-centric tests against literals.
|
||||
(length_of_file_name_and_frills): Likewise.
|
||||
|
||||
Thu Mar 21 16:43:13 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* src/*.c (main): Declare to be of type int, not void.
|
||||
|
||||
Sat Mar 16 10:46:23 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (PACKAGE_VERSION): New macro.
|
||||
* acconfig.h (PACKAGE_VERSION): Add it.
|
||||
* src/Makefile.am: Remove rules for generating version.c.
|
||||
Remove references to version.o, version.h, and stamp-v.
|
||||
* version.c: Remove file.
|
||||
* version.h: Remove file.
|
||||
* chgrp.c chmod.c chown.c cp.c dd.c df.c du.c install.c ln.c
|
||||
ls.c mkdir.c mkfifo.c mknod.c mv.c mvdir.c rm.c rmdir.c sync.c
|
||||
touch.c: Don't include version.h.
|
||||
(main): Use PACKAGE_VERSION instead of version_string.
|
||||
|
||||
Sun Mar 10 22:36:11 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* backupfile.c (max_backup_version): Declare file_name_length to
|
||||
be of type size_t. This avoids a warning from gcc -Wall.
|
||||
|
||||
* chmod.c chown.c cp.c dd.c df.c du.c install.c ln.c ls.c
|
||||
mkdir.c mkfifo.c mknod.c mv.c mvdir.c rm.c rmdir.c sync.c
|
||||
touch.c (main): Initialize for internationalized message support:
|
||||
call setlocale, bindtextdomain, and textdomain.
|
||||
* system.h: Add definitions and includes for NLS.
|
||||
* Makefile.am (SUBDIRS): Add intl and po.
|
||||
* src/Makefile.am (datadir): Define.
|
||||
(localedir): Define.
|
||||
(DEFS): Add LOCALEDIR definition.
|
||||
(LDADD): Add @INTLLIBS@.
|
||||
* aclocal.m4: Add NLS-related macro definitions from
|
||||
gettext distribution.
|
||||
* acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES,
|
||||
HAVE_STPCPY): New macros.
|
||||
Add PACKAGE and VERSION.
|
||||
* configure.in (PACKAGE): Define with AC_DEFINE_UNQUOTED.
|
||||
(VERSION): Likewise.
|
||||
(ALL_LINGUAS): Define.
|
||||
(ud_GNU_GETTEXT): Use it.
|
||||
Link an nls file.
|
||||
(AC_OUTPUT): Reflect addition of two new directories, intl and po.
|
||||
Create po/Makefile.
|
||||
From François Pinard.
|
||||
|
||||
Thu Mar 7 20:26:07 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* df.c (main): Tell read_filesystem_list that it should determine
|
||||
file system type when the user specifies --print-type or -T.
|
||||
From Michael Rendell <michael@cs.mun.ca>.
|
||||
|
||||
Tue Feb 27 23:13:46 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* src/Makefile.am: Adapt for automake-0.30.
|
||||
(noinst_HEADERS): Rename from HEADERS.
|
||||
(EXTRA_PROGRAMS): Set to `df mvdir'.
|
||||
(PROGRAMS): Remove definition.
|
||||
(bin_PROGRAMS): Remove hard-coded df. Use @DF_PROG@ instead.
|
||||
(libexec_PROGRAMS): Remove hard-coded mvdir. Use @MVDIR_PROG@ instead.
|
||||
* lib/Makefile.am: (noinst_HEADERS): Rename from HEADERS.
|
||||
|
||||
* configure.in (DF_PROG, MVDIR_PROG): Use these instead of bundling
|
||||
both into PROGS.
|
||||
|
||||
Mon Feb 26 21:23:58 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* dd.c (copy): Remove bogus (now that we're using full_write)
|
||||
increment of w_partial.
|
||||
Change sense of the tests (though they're equivalent) that check
|
||||
the value returned by full_write. making it clearer where errno
|
||||
is valid. full_write always writes the full amount or fails.
|
||||
|
||||
Thu Feb 15 23:08:41 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cp.c (copy): Detect (and fail) when creating backup file would
|
||||
destroy the source file. Before, running the commands
|
||||
cd /tmp; rm -f a a~; : > a; echo A > a~; cp -b -V simple a~ a
|
||||
would leave two zero-length files: a and a~.
|
||||
Reported by Martin C. Martin <mcm@cs.cmu.edu>.
|
||||
|
||||
Mon Feb 12 23:23:25 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (LIBOBJS): Split assignment into two statements to
|
||||
accomodate automake-0.29 buglet.
|
||||
|
||||
Update for automake-0.29.
|
||||
* Makefile.am (CONFIG_HEADER): Don't define. Automake now does it.
|
||||
* src/Makefile.am: Likewise.
|
||||
* lib/Makefile.am: Likewise.
|
||||
* doc/Makefile.am (info_TEXINFOS): Renamed from TEXINFOS.
|
||||
* man/Makefile.am (man_MANS): Renamed from MANS.
|
||||
|
||||
Wed Jan 31 21:50:41 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* dd.c (skip): Change type of parameter #5 from char* to
|
||||
unsigned char* to match type of argument.
|
||||
(copy): Cast first arg in memset call to char* to avoid warnings
|
||||
from SunOS's acc.
|
||||
(copy_simple): Likewise.
|
||||
|
||||
* du.c: Remove comma after last item in enum.
|
||||
|
||||
* df.c: Remove block of usage comments at beginning of file.
|
||||
|
||||
* df.c (main): New options --human-readable (-h) and --megabytes (-m).
|
||||
(human_readable_1k_blocks): New function.
|
||||
(print_header): Honor new options.
|
||||
(show_dev): Honor new options.
|
||||
Add ifdef'd-out code to avoid printing lines for mount points that
|
||||
match ^/auto/.* and ^/tmp_mnt.*. Rather than hard-coding those
|
||||
two prefixes, the code should allow the user to specify a regular
|
||||
expression. From Larry McVoy (lm@sgi.com).
|
||||
|
||||
* du.c (human_readable): Fix off-by-one error that converted
|
||||
1024*1024 to 1024K rather than 1G. Describe the function.
|
||||
* df.c (human_readable_1k_blocks): Likewise
|
||||
(usage): Update usage message to reflect additions.
|
||||
|
||||
Sat Jan 20 06:00:09 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cp-aux.c (usage): Fix description of --archive. From Andreas Schwab.
|
||||
|
||||
* install.c (copy_files): Accept backup/suffix options just as cp,
|
||||
ln, and mv do. From Marty Leisner <leisner@sdsp.mc.xerox.com>.
|
||||
|
||||
* src/Makefile.am (DISTCLEANFILES): Set to stamp-v version.c.
|
||||
(version.c): Update with rules from textutils.
|
||||
(transform): Add `s/ginstall/install/;' prefix.
|
||||
|
||||
* lib/Makefile.am (BUILT_SOURCES): Set to posixtm.c getdate.c so
|
||||
autodependencies work after `make maintainer-clean.'
|
||||
|
||||
* du.c (main): New options --human-readable (-h) and --megabytes (-m).
|
||||
(human_readable): New function.
|
||||
From Larry McVoy (lm@sgi.com).
|
||||
|
||||
Fri Dec 22 21:34:55 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* configure.in: Touch stamp-h only if config.h is remade.
|
||||
|
||||
Sat Dec 23 11:33:19 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* ls.c (decode_switches): Make -o a synonym for -lG for compatibility
|
||||
with most other versions of ls. Reported by Karl Berry.
|
||||
(usage): Update.
|
||||
|
||||
Fri Dec 22 00:48:01 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* dd.c (cleanup): New function -- broken out from quit.
|
||||
(interrupt_handler): Rewrite to reset default signal handler,
|
||||
call cleanup, then repost caught signal.
|
||||
|
||||
Thu Dec 21 23:15:06 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* argmatch.h: New file.
|
||||
* lib/Makefile.am (HEADERS): Add argmatch.h.
|
||||
* argmatch.c: (argmatch): Add const attribute to parameters.
|
||||
(invalid_arg): Add const attribute to parameters.
|
||||
|
||||
* cp.c: Include argmatch.h.
|
||||
* ls.c: Likewise.
|
||||
* touch.c: Likewise.
|
||||
|
||||
* cp.c (main): Accept new option, --sparse={never,auto,always},
|
||||
to control creation of sparse files.
|
||||
(copy_reg): Set local, make_holes, from global flag_sparse.
|
||||
* cp-aux (usage): Describe new option.
|
||||
|
||||
Mon Dec 18 22:29:49 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* ln.c: [SYMBOLIC_SPACE_STRING]: New macro.
|
||||
(do_link): Use SYMBOLIC_SPACE_STRING instead of open-coded #ifdef.
|
||||
For --verbose, output `create [symbolic ]link DEST to SRC' instead
|
||||
of ambiguous (or inconsistent with cp -v and mv -v) `SRC -> DEST.'
|
||||
|
||||
Tue Dec 5 17:38:11 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* rm.c (rm): Work around SunOS 4 bug whereby lstat doesn't fail
|
||||
when given a zero-length file name argument. Reported by
|
||||
Mark Calabretta <mcalabre@atnf.csiro.au>.
|
||||
|
||||
Wed Nov 22 23:12:47 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* Makefile.in (all et. al.): If make was invoked with -k and a
|
||||
sub-make fails, fail after the loop rather than exiting right away.
|
||||
Otherwise, make's -k option could be ineffective.
|
||||
|
||||
Thu Nov 16 21:25:45 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* Makefile.in (default): New default target. Depend on `all' to work
|
||||
around bug in AIX-3.2.5's /bin/make. Reported by Andreas Luik
|
||||
<luik@isa.de>.
|
||||
|
||||
Fri Nov 10 23:31:46 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* src/Makefile.in (.c._o, ._c._o): Remove temporary source files.
|
||||
(.c._c): Don't redirect directly to $@.
|
||||
|
||||
* src/Makefile.in (DISTFILES): Include ansi2knr.c and ansi2knr.1.
|
||||
(clean): Remove temp files generated by ansi2knr rules.
|
||||
(ansi2knr): New rule.
|
||||
Add suffixes, dependencies, and rules to convert ANSI source to K&R
|
||||
when required.
|
||||
($(OBJECTS)): Depend on $(ANSI2KNR)
|
||||
|
||||
* configure.in: Add fp_C_PROTOTYPES.
|
||||
|
||||
* Makefile.in (DISTFILES): Add aclocal.m4.
|
||||
(configure): Depend on aclocal.m4.
|
||||
(stamp.h.in): Depend on aclocal.m4 and acconfig.h.
|
||||
* acconfig.h: Add PROTOTYPES.
|
||||
|
||||
* cp.h: Remove declaration of error. Include error.h instead.
|
||||
Protoize forward dcls of functions in cp-hash.c and cp-aux.c
|
||||
* cp-aux.c: Protoize and add const attribute to parameters.
|
||||
* cp-hash.c: Likewise.
|
||||
|
||||
Thu Nov 9 23:27:05 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* system.h [__P]: Define it.
|
||||
|
||||
* src/*.c: Protoize.
|
||||
|
||||
* ls.c (enum filetype): Move dcl to precede prototypes.
|
||||
(struct fileinfo): Likewise.
|
||||
Add const attribute to some parameters.
|
||||
|
||||
* rm.c (struct pathstack): Move dcl to precede prototypes.
|
||||
|
||||
* dd.c (translate_charset): Make parameter `const'.
|
||||
|
||||
* ln.c (main): Move to the end.
|
||||
Remove most fwd dcls.
|
||||
* chmod.c: Likewise.
|
||||
* chown.c: Likewise.
|
||||
* chgrp.c: Likewise.
|
||||
* mkdir.c: Likewise.
|
||||
* mkfifo.c: Likewise.
|
||||
* mknod.c: Likewise.
|
||||
* mvdir.c: Likewise.
|
||||
* touch.c: Likewise.
|
||||
|
||||
* mv.c: Rearrange functions to obviate forward dcls.
|
||||
Remove forward dcls.
|
||||
|
||||
* cp.c: Protect prototyped forward dcls with __P.
|
||||
* dd.c: Likewise.
|
||||
* df.c: Likewise.
|
||||
* du.c: Likewise.
|
||||
* install.c: Likewise.
|
||||
* ls.c: Likewise.
|
||||
* rm.c: Likewise.
|
||||
|
||||
Wed Nov 1 23:11:05 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* cp.c (copy): Use euidaccess instead of euidaccess_stat.
|
||||
@@ -24,7 +831,7 @@ Sun Oct 29 06:06:13 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* touch.c: Change long option name `--file' to `--reference'.
|
||||
Leave --file as an alias, for now. It will be removed later.
|
||||
(usage): Reflect option name change. From Franc,ois Pinard.
|
||||
(usage): Reflect option name change. From Franc,ois Pinard.
|
||||
|
||||
Wed Oct 18 23:09:55 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
@@ -94,8 +901,8 @@ Sun Oct 1 13:22:36 1995 Jim Meyering (meyering@comco.com)
|
||||
Tue Sep 26 23:05:01 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* man/Makefile.in (install-data, uninstall): Use sed not basename.
|
||||
The GNU Coding Standard suggests that only a select set of
|
||||
relatively standard utilities be used in Makefiles. basename is
|
||||
The GNU Coding Standard suggests that only a select set of
|
||||
relatively standard utilities be used in Makefiles. basename is
|
||||
not among them. Suggested by Ulrich Drepper.
|
||||
|
||||
Mon Sep 25 23:12:37 1995 Jim Meyering <meyering@gremlin.comco.com>
|
||||
@@ -117,7 +924,7 @@ Mon Aug 7 23:27:54 1995 Jim Meyering (meyering@comco.com)
|
||||
Fri Aug 4 22:11:06 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* install.c (isnumber): Rename to is_number to avoid conflict with
|
||||
FreeBSD 2.0.5 macro definition. Reported by David O'Brien
|
||||
FreeBSD 2.0.5 macro definition. Reported by David O'Brien
|
||||
(obrien@sea.legent.com).
|
||||
|
||||
* lib/save-cwd.c: New file.
|
||||
@@ -276,9 +1083,9 @@ Mon Feb 20 22:54:39 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
Sat Feb 11 07:52:01 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* configure.in (AC_REPLACE_FUNCS): Add memcmp, memcpy, and memset.
|
||||
(AC_CHECK_FUNCS): Add strchr and strrchr.
|
||||
* lib/Makefile.in (SOURCES): Add memcmp.c, memcpy.c, and memset.c.
|
||||
* configure.in (AC_REPLACE_FUNCS): Add memcmp, memcpy, and memset.
|
||||
(AC_CHECK_FUNCS): Add strchr and strrchr.
|
||||
* lib/Makefile.in (SOURCES): Add memcmp.c, memcpy.c, and memset.c.
|
||||
|
||||
* system.h: Remove index/rindex and bcmp/bcopy/bzero references.
|
||||
Separate errno declaration from STDC_HEADERS.
|
||||
@@ -289,7 +1096,7 @@ Sat Feb 11 07:52:01 1995 Jim Meyering (meyering@comco.com)
|
||||
* fsusage.c (get_fs_usage, statfs): Use safe_read, and safe_stat
|
||||
rather than bare read and stat. From Bruno Haible.
|
||||
|
||||
* lib/Makefile.in (DISTFILES): Add error.h.
|
||||
* lib/Makefile.in (DISTFILES): Add error.h.
|
||||
|
||||
* chgrp.c, chmod.c, chown.c, cp-hash.c, cp.c, df.c, du.c, install.c,
|
||||
ln.c, ls.c, mv.c, mvdir.c, rm.c, touch.c: Rename SAFE_STAT and
|
||||
@@ -339,16 +1146,16 @@ Sun Dec 4 14:53:12 1994 Jim Meyering (meyering@comco.com)
|
||||
|
||||
Fri Nov 11 11:15:20 1994 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* mknod.c (my_strtol): New function.
|
||||
(main): Use it instead of atoi to convert argument strings to
|
||||
major and minor device numbers. Now, mknod diagnoses invalid
|
||||
device numbers and accepts octal and hexadecimal as well as
|
||||
decimal string arguments. Ralf Lammers
|
||||
<rlammers@physik.uni-osnabrueck.de> suggested that mknod accept
|
||||
hex device numbers for compatibility with HPUX's mknod program.
|
||||
* mknod.c (my_strtol): New function.
|
||||
(main): Use it instead of atoi to convert argument strings to
|
||||
major and minor device numbers. Now, mknod diagnoses invalid
|
||||
device numbers and accepts octal and hexadecimal as well as
|
||||
decimal string arguments. Ralf Lammers
|
||||
<rlammers@physik.uni-osnabrueck.de> suggested that mknod accept
|
||||
hex device numbers for compatibility with HPUX's mknod program.
|
||||
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strtol.
|
||||
* lib/Makefile.in (SOURCES): Add strtol.c.
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strtol.
|
||||
* lib/Makefile.in (SOURCES): Add strtol.c.
|
||||
|
||||
Sun Nov 06 00:18:56 1994 Jim Meyering (meyering@comco.com)
|
||||
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
User-visible changes in release 3.13:
|
||||
* rename touch long option name --file to --reference.
|
||||
Changes in release 3.13:
|
||||
* ls properly determines window size on SunOS and Solaris systems
|
||||
* ls accepts new option --color[=WHEN] where WHEN is `always', `never',
|
||||
or `auto'. --color=never is the default. --color is equivalent
|
||||
to --color=always.
|
||||
* new program: dircolors
|
||||
* ls allows 0 as argument to --tabsize (-T) option. Using --tabsize=0
|
||||
inhibits the use of TAB characters for separating columns.
|
||||
* you can create a backup of FILE with cp --force --backup FILE FILE. Before,
|
||||
that command failed saying that ``FILE' and `FILE' are the same file'.
|
||||
* uses automake-generated Makefile templates
|
||||
* chown and chgrp accept new option --no-dereference (-h)
|
||||
* ln -f FILE FILE fails with a diagnostic rather than silently removing FILE
|
||||
* when building on systems that have getopt_long (like Linux), the system-
|
||||
provided function will be used -- so executables may be a little smaller
|
||||
* cp -p, and mv modify owner and/or group of symlinks on systems
|
||||
(like Solaris) that provide the lchown system call.
|
||||
* df no longer invokes the sync system call by default. You can use the
|
||||
--sync option to make df invoke sync before getting file system sizes.
|
||||
* internationalized diagnostic messages
|
||||
* mkdir accepts new option: --verbose
|
||||
* `cp file D/' uses the full file name `D/file' instead of `D//file'.
|
||||
* cp --backup a~ a fails instead of silently destroying the source file
|
||||
* df and du have new options --human-readable (-h) and --megabytes (-m).
|
||||
* install now honors --backup (-b), --suffix=SUFFIX (-S SUFFIX), and
|
||||
--version-control=WORD (-V WORD) options just as cp, ln, and mv do.
|
||||
* ln --verbose output is less prone to misinterpretation
|
||||
* ls -o works like -lG; for compatibility with other versions of ls
|
||||
* cp has a new option to control creation of sparse files:
|
||||
--sparse={auto,always,never}. --sparse=auto is the default.
|
||||
* rm -rf '' behaves properly on SunOS 4 systems
|
||||
* touch: rename long option name, --file, to --reference.
|
||||
`touch --file' will continue to work a little longer.
|
||||
* df fails if the same file system type is both selected and excluded.
|
||||
* df works around SunOS statfs brokenness wrt filesystems larger than 2GB
|
||||
@@ -15,6 +45,7 @@ User-visible changes in release 3.13:
|
||||
* du works on SunOS 4 systems even when accounting is enabled
|
||||
* many programs that convert strings to integers now use strtol or strtoul
|
||||
and detect overflow
|
||||
|
||||
User-visible changes in release 3.12:
|
||||
* None.
|
||||
User-visible changes in release 3.11:
|
||||
@@ -27,7 +58,7 @@ User-visible changes in release 3.10:
|
||||
* Fix bug in cp that made the commands `mkdir dir; touch foo; cp -P foo dir'
|
||||
incorrectly change the permissions on directory, dir.
|
||||
* df accepts a new option, --no-sync, that inhibits the default invocation
|
||||
of the sync system call. FIXME.
|
||||
of the sync system call.
|
||||
* ls accepts a new option, --dired, that makes emacs' dired mode more efficient
|
||||
* skeletal texinfo documentation (mainly just the `invoking' nodes)
|
||||
* ln accepts a new option: --no-dereference (-n). With this option,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1710
old/sh-utils/ChangeLog.0
Normal file
1710
old/sh-utils/ChangeLog.0
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,21 @@
|
||||
User visible changes in release 1.13
|
||||
* New utilities: factor, seq.
|
||||
Changes in release 1.13
|
||||
* when matching, expr warns about non-portability when the first character
|
||||
of the basic regular expression is `^'
|
||||
* `id user' no longer prints bogus group list
|
||||
* uses automake-generated Makefile templates
|
||||
* date accepts new %V format
|
||||
* date's %U and %W formats work properly
|
||||
* nice option handling works with 2-digit old-style-option adjustments.
|
||||
Now, `nice -18 -- nice' prints `18'. Before it printed `8'.
|
||||
* internationalized diagnostic messages
|
||||
* `date -d "01/01/1998 3 years" +%Y' now works properly. It prints 2001.
|
||||
* New programs: chroot, factor, seq, uptime.
|
||||
* date accepts new option: --rfc-822 (-R)
|
||||
* date accepts new format, %z, for RFC-822 style numeric timezone (-0500)
|
||||
* date: fix bugs in the handling of date -u +'%s %Z'.
|
||||
* date accepts new option --reference=FILE (-r FILE) analogous to the
|
||||
like-named touch option.
|
||||
* date can now format dates up to and including ones in the year 2037
|
||||
User visible changes in release 1.12
|
||||
* None.
|
||||
User visible changes in release 1.11
|
||||
|
||||
@@ -1,3 +1,817 @@
|
||||
Thu Jul 11 22:04:36 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.19.
|
||||
|
||||
* configure.in (VERSION): Bump to 1.19.
|
||||
|
||||
Wed Jul 10 22:57:29 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* aclocal.m4 (fp_PROG_CC_STDC): Include sys/stat.h in test program
|
||||
so that DYNIX/ptx V4.1.3 doesn't use `-Xc -D__EXTENSIONS__' -- with
|
||||
those options on that system, sys/stat.h gets compile errors.
|
||||
With help from Marcus Daniels.
|
||||
|
||||
* getopt.c: Update from gettext-0.10.23.
|
||||
* getopt1.c: Likewise.
|
||||
* getopt.h: Likewise.
|
||||
|
||||
Tue Jul 9 18:07:23 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/fmt.c (MAXCOST): Use `(unsigned long)1' rather than `(COST)1'
|
||||
so the left operand of the << isn't signed.
|
||||
From Kjetil Torgrim Homme.
|
||||
|
||||
* po/Makefile.in.in (install-data): Don't install NLS files when
|
||||
they're not requested. From Ulrich Drepper. Reported by
|
||||
Kjetil Torgrim Homme <kjetilho@ifi.uio.no>.
|
||||
|
||||
Fri Jul 5 21:55:58 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* po/Makefile.in.in ($(PACKAGE).pot): Merge from gettext-0.10.23.
|
||||
* ABOUT-NLS: Likewise.
|
||||
* intl/*: Likewise.
|
||||
* aclocal.m4: Likewise.
|
||||
|
||||
Thu Jul 4 07:24:54 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/uniq.c (usage): Remove space before newline in usage message.
|
||||
|
||||
* src/md5sum.c (MIN_DIGEST_LINE_LENGTH): New macro.
|
||||
[NEWLINE_REPLACEMENT_STRING*]: Remove macros.
|
||||
(main): Output a leading backslash for a line describing a file
|
||||
whose name contains a newline. Then translate each NEWLINE byte
|
||||
in the file name to the string, "\\n", and each backslash to "\\\\".
|
||||
File names that don't contain NEWLINE aren't translated.
|
||||
(split_3): Rewrite to handle file names with embedded newlines.
|
||||
Miles Bader and Jim Blandy suggested this new encoding scheme.
|
||||
|
||||
* src/md5sum.c (md5_file): Replace obsolete comment with a description
|
||||
of the function.
|
||||
(md5_check): Don't use "s"-adding trick to form the plural of
|
||||
`checksum.' That doesn't work well with translation.
|
||||
Suggestions from Ulrich Drepper.
|
||||
(split_3): Add missing semicolon so it compiles. From Jim Blandy.
|
||||
|
||||
Wed Jul 3 23:21:09 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/md5sum.c (split_3): Correct test for 35-byte line to accomodate
|
||||
fact that leading blanks may be stripped.
|
||||
|
||||
Tue Jul 2 21:51:40 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add dutch (nl).
|
||||
|
||||
Mon Jul 1 23:50:19 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/md5sum.c [NEWLINE_REPLACEMENT_STRING]: Define.
|
||||
(split_3): Translate NL bytes not to NUL, but to
|
||||
NEWLINE_REPLACEMENT_STRING.
|
||||
Suggested by Ulrich Drepper.
|
||||
(main): Translate back to NL-containing filename.
|
||||
|
||||
Sun Jun 30 22:42:17 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/md5sum.c (split_3): Take an additional parameter, S_LEN.
|
||||
Adapt caller.
|
||||
Map translated NEWLINE-containing filename back into the original
|
||||
NEWLINE-containing name.
|
||||
(md5_check): Translate NEWLINE bytes to NUL bytes in filename.
|
||||
|
||||
Sat Jun 29 18:59:07 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (PACKAGE_VERSION): Add `GNU ' prefix so it
|
||||
appears in the output of --version. Reported by RMS.
|
||||
|
||||
Wed Jun 26 21:35:10 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/Makefile.am (LDADD): Remove sort-specific hack to link
|
||||
with -lm.
|
||||
* aclocal.m4 (AM_FUNC_STRTOD): New macro.
|
||||
* configure.in (AM_FUNC_STRTOD): Use it.
|
||||
(AC_REPLACE_FUNCS): Remove strtod.
|
||||
Suggested by Tom Tromey.
|
||||
|
||||
* po/Makefile.in.in (install-data): Add `else true;' to avoid
|
||||
letting failing if-condition cause make failure.
|
||||
From Fred Fish (fnf@ninemoons.com).
|
||||
|
||||
Tue Jun 25 21:55:18 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.18a.
|
||||
|
||||
Tue Jun 18 20:43:20 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* aclocal.m4: Update from gettext-0.10.20.
|
||||
* ABOUT-NLS: Likewise.
|
||||
* intl/*: Likewise.
|
||||
|
||||
Thu Jun 13 22:31:39 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (VERSION): Bump to 1.18a.
|
||||
|
||||
* po/Makefile.in.in ($(PACKAGE).pot): Reapply change of May 30.
|
||||
Depend on POTFILES only when using maintainer mode.
|
||||
|
||||
* intl/*: Update from gettext-0.10.18.
|
||||
|
||||
Tue Jun 11 23:32:10 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.18.
|
||||
|
||||
* po/Makefile.in.in: Update from gettext-0.10.17.
|
||||
* intl/*: Likewise.
|
||||
* ABOUT-NLS: Likewise.
|
||||
|
||||
Mon Jun 10 18:22:29 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Makefile.am (cvs-dist): Use -c option in cvs tag command.
|
||||
|
||||
Fri Jun 7 22:06:46 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (VERSION): Set to 1.18.
|
||||
|
||||
* src/Makefile.am (sort_LDADD): Set this to -lm to get pow when using
|
||||
the strtod supplied with this package. Otherwise, linking failed on
|
||||
Solaris-2.4 systems. Reported by Wayne Stewart <wstewa@atl.com>.
|
||||
|
||||
Thu Jun 6 21:57:08 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* po/Makefile.in.in: Update from gettext-0.10.16.
|
||||
* intl/*: Likewise.
|
||||
* ABOUT-NLS: Likewise.
|
||||
* aclocal.m4 (AC_REPLACE_GNU_GETOPT): Move definition to precede
|
||||
gettext-related ones.
|
||||
Update from gettext-0.10.16.
|
||||
|
||||
Fri May 31 22:04:51 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.17.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Set to texinfo.tex so that file is
|
||||
distributed.
|
||||
|
||||
Thu May 30 00:07:48 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.16.
|
||||
|
||||
* tail.c (main): Interpret the old-style +VALUE and -VALUE options
|
||||
like -c VALUE and -c +VALUE (resp) when VALUE has one of the [bkm]
|
||||
suffix multipliers. This makes the code consistent with --help
|
||||
output. Reported by Karl Heuer.
|
||||
|
||||
* sort.c (limfield): #ifdef-out a block of code that makes
|
||||
GNU sort incompatible with Unix sort when a key-end spec refers
|
||||
to the N'th character in a field that has fewer than N characters.
|
||||
The POSIX spec doesn't appear to specify behavior for this case.
|
||||
From Karl Heuer.
|
||||
|
||||
* po/Makefile.in.in (stamp-cat-id): Avoid using temp filename
|
||||
longer than 14 characters.
|
||||
(mostlyclean): Likewise.
|
||||
From Karl Heuer.
|
||||
|
||||
* po/Makefile.in.in ($(PACKAGE).pot): Depend on POTFILES only
|
||||
when using maintainer mode. Reported by Karl Heuer.
|
||||
|
||||
* po/Makefile.in.in (.po.mo): Reenable dependency and rule.
|
||||
It is required when using native NLS, e.g. on Solaris.
|
||||
From Marcus Daniels.
|
||||
|
||||
* od.c (decode_one_format): Use %lu (not %d) printf format
|
||||
corresponding to unsigned long, SIZE.
|
||||
|
||||
* Version 1.15.
|
||||
|
||||
* intl/Makefile.in (installcheck): New target.
|
||||
* po/Makefile.in.in (installcheck): New target.
|
||||
|
||||
* od.c (decode_one_format): Take another parameter.
|
||||
Give a specific diagnostic for invalid format spec here rather
|
||||
than an overly general one from caller's caller.
|
||||
(decode_format_string): Update caller.
|
||||
(main): Don't give diagnostic here when decode_format_string fails.
|
||||
Remove assertions that could fail on some Crays because they don't
|
||||
have a two-byte type.
|
||||
Johan Danielsson (joda@pdc.kth.se) reported the failed assertions.
|
||||
|
||||
Mon May 27 17:43:31 1996 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* cat.c (main): Use STDIN_FILENO and STDOUT_FILENO instead of
|
||||
less portable fileno (stdin) and fileno (stdout).
|
||||
* sort.c (main): Use STDIN_FILENO instead of less portable
|
||||
fileno (stdin).
|
||||
|
||||
Mon May 20 21:50:23 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* Makefile.am (distcheck): Remove target and rule -- automake-0.33
|
||||
adds it automatically.
|
||||
|
||||
Sun May 19 13:15:49 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (LINGUAS): Add ko.
|
||||
* Makefile.am (distcheck): Remove @MAINT@ prefix from first command.
|
||||
|
||||
Thu May 16 22:18:41 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* Makefile.am (distcheck): New target. From Gord Matzigkeit.
|
||||
|
||||
Fri May 10 20:46:13 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* po/Makefile.in.in (all-yes): Always depend on CATALOGS. Otherwise
|
||||
they won't be built and install could fail. From Ulrich Drepper.
|
||||
(.po.mo): Disable dependency and rule when not in maintainer mode.
|
||||
|
||||
* aclocal.m4 (ud_WITH_NLS): Make DATADIRNAME and CATOBJEXT depend
|
||||
on whether we're using GNU gettext. From Ulrich Drepper.
|
||||
|
||||
Wed May 8 21:10:43 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* intl/Makefile.in (distdir): Renamed from dist. For compatibility
|
||||
with automake-0.32.
|
||||
* po/Makefile.in.in (distdir): Likewise.
|
||||
|
||||
* po/Makefile.in.in (all-yes): Depend on GMOFILES.
|
||||
Depend on CATALOGS and GMOFILES files only in maintainer mode.
|
||||
|
||||
Tue May 7 22:10:20 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in: Require autoconf-2.10.
|
||||
|
||||
* aclocal.m4 (jm_MAINTAINER_MODE): New macro.
|
||||
* configure.in (jm_MAINTAINER_MODE): Use it.
|
||||
|
||||
Sat May 4 20:40:01 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (LINGUAS): Add de.
|
||||
* po/de.po: New file.
|
||||
|
||||
* memcasecmp.c [IN_CTYPE_DOMAIN]: Rename from ISASCII.
|
||||
* regex.c [IN_CTYPE_DOMAIN]: Likewise.
|
||||
* system.h [IN_CTYPE_DOMAIN]: Likewise.
|
||||
|
||||
Sun Apr 28 17:10:03 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* fmt.c (copy_rest): Don't copy past end of prefix. Output
|
||||
trailing spaces if the prefix had any. Before, fmt would
|
||||
improperly output NUL bytes. The command
|
||||
perl -e 'print "| S";' |fmt -p' | '|tr '\0' @
|
||||
output `|@S'. Reported by François Pinard.
|
||||
|
||||
* sort.c (main): Give a better diagnostic for `sort -0'.
|
||||
Reported by Karl Berry.
|
||||
|
||||
* configure.in: Make fp_C_PROTOTYPES precede AC_C_INLINE.
|
||||
Otherwise, some systems lose because the value AC_C_INLINE choses
|
||||
with plain `cc' is different from that chosen when using the ANSI-mode
|
||||
C compiler. From Kaveh Ghazi.
|
||||
|
||||
Tue Apr 23 22:05:35 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* aclocal.m4 (AC_REPLACE_GNU_GETOPT): New macro.
|
||||
* configure.in: Use it.
|
||||
* lib/Makefile.am (tu_SOURCES): Remove getopt.c and getopt1.c.
|
||||
(EXTRA_DIST): Add getopt.c and getopt1.c
|
||||
|
||||
* src/*.c, src/*.h: Update Copyright years to include 1996.
|
||||
|
||||
Sun Apr 21 08:04:51 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* getline.c: New version from gettext-0.10.12.
|
||||
* getline.h: Likewise.
|
||||
* configure.in (AC_CHECK_FUNCS): Add getdelim.
|
||||
Suggested by Ulrich Drepper.
|
||||
|
||||
* md5sum.c (md5_check): Remove spurious newline at end of error
|
||||
format string.
|
||||
|
||||
* od.c (decode_one_format): Use printf's L modifier for long doubles,
|
||||
not `l'. From Eric Backus.
|
||||
|
||||
* Makefile.am (LDADD): Put @INTLLIBS@ before package library.
|
||||
|
||||
* od.c: Include <values.h>.
|
||||
[!BITSPERBYTE]: Define.
|
||||
[OFF_T_MAX]: Use BITSPERBYTE, not 8, and cast the result to off_t.
|
||||
* configure.in (AC_CHECK_HEADERS): Add values.h.
|
||||
|
||||
Fri Apr 19 23:48:53 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* Makefile.am (cvs-dist): New rule. Based on the one from
|
||||
Tom Tromey's automake.
|
||||
|
||||
Thu Apr 18 22:13:14 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* tail.c (main): Make code clearer: use new variable `n_files' in
|
||||
place of `argc - optind'. Use `file' instead of `argv + optind'.
|
||||
|
||||
Sat Apr 13 13:08:29 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* lib/Makefile.am (noinst_HEADERS): Include memcasecmp.h,
|
||||
not memcasecmp.c.
|
||||
|
||||
* memcasecmp.c: Unprotoize.
|
||||
[ISASCII]: Define.
|
||||
[ISUPPER]: Define.
|
||||
|
||||
* join.c (decode_field_spec): Rename local variable `valid'
|
||||
to invalid (and reverse sense) to avoid conflict with the
|
||||
macro definition in /usr/include/locale.h on SunOS 4.1.3.
|
||||
|
||||
Tue Apr 9 22:43:57 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* uniq.c: Add new option --ignore-case (-i).
|
||||
Include memcasecmp.h.
|
||||
(different): Compare with memcasecmp if ignoring case.
|
||||
(main): Handle 'i'.
|
||||
|
||||
* join.c (memcasecmp): Remove static definition of function.
|
||||
Include memcasecmp.h instead.
|
||||
|
||||
* memcasecmp.c: New file.
|
||||
* memcasecmp.h: New file.
|
||||
* lib/Makefile.am (tu_SOURCES): Add memcasecmp.c.
|
||||
(noinst_HEADERS): Add memcasecmp.h.
|
||||
|
||||
Thu Apr 4 17:05:33 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* tr.c: The following commands all failed unnecessarily.
|
||||
tr -cs '[:upper:]' '[X*]'
|
||||
tr -dcs '[:lower:]' n-rs-z
|
||||
tr -ds '[:xdigit:]' [:alnum:]'
|
||||
tr -dcs '[:alnum:]' [:digit:]'
|
||||
tr -dc '[:upper:]'
|
||||
Reported by Ross Ridge (ross@worf.mks.com).
|
||||
(validate): Add missing conjunct (translating) in test for
|
||||
`translating and complementing character classes' error. Before,
|
||||
valid uses of tr could fail. E.g. `tr -dcs '[:cntrl:]' '[:alnum:]''.
|
||||
(homogeneous_spec_list): New function.
|
||||
(validate): Use it to relax the old (overly restrictive) restriction
|
||||
that prohibited use of complemented character classes when translating.
|
||||
Now, that is allowed as long as the translation maps many to one.
|
||||
(get_spec_stats): Rename and redefine global has_char_class from
|
||||
has_upper_or_lower.
|
||||
|
||||
Wed Apr 3 07:08:57 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* aclocal.m4: Update NLS macros from gettext-0.10.11.
|
||||
|
||||
* src/Makefile.am (INCLUDES): Add -I$(srcdir) to get system.h
|
||||
when srcdir != builddir. From Kaveh Ghazi.
|
||||
|
||||
Wed Mar 27 23:33:36 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cksum.c (cksum): Use format "%lu %ld" (instead of "%10lu %8ld")
|
||||
to be POSIX compliant. From Stephen Gildea <gildea@x.org>.
|
||||
|
||||
Sun Mar 24 08:47:40 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* join.c (main): Use EXIT_FAILURE, not 2, as exit code in error call.
|
||||
* od.c (skip, main): Likewise.
|
||||
* tr.c (main): Likewise.
|
||||
|
||||
* cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c fold.c head.c
|
||||
join.c md5sum.c nl.c od.c paste.c pr.c split.c sum.c tac.c tail.c
|
||||
tr.c unexpand.c uniq.c wc.c: Exit with status EXIT_SUCCESS or
|
||||
EXIT_FAILURE, rather than 0 or 1.
|
||||
|
||||
Sat Mar 23 23:14:40 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* system.h [EXIT_FAILURE]: Undefine and define to 1 also if it
|
||||
is defined to zero. Suggested by Paul Eggert.
|
||||
|
||||
* sort.c [SORT_FAILURE]: New macro.
|
||||
Be careful to exit with 1 only when -c is used and the
|
||||
input is not properly sorted. In all other cases, use
|
||||
SORT_FAILURE as required by POSIX.
|
||||
(main): Change some `error (1, ...' to use SORT_FAILURE.
|
||||
Upon successful termination, exit with EXIT_SUCCESS instead of `0'.
|
||||
Replace all uses of `2' (as exit code) with SORT_FAILURE.
|
||||
|
||||
Thu Mar 21 22:47:50 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* csplit.c: Include assert.h, but disable assertions.
|
||||
(process_line_count): Replace if-abort with a slightly relaxed
|
||||
assertion. Before, `echo |csplit - 1 1' would abort.
|
||||
Reported by Samuli.Karkkainen@hut.fi.
|
||||
(parse_patterns): Disallow uses like `csplit FILE 0' with zero
|
||||
line number, `csplit FILE 2 1' with decreasing line numbers, and
|
||||
warn about uses like `csplit FILE 3 3' that have equal line numbers.
|
||||
|
||||
* sort.c (main): Declare to be of type int, not void.
|
||||
From Peter Seebach <seebs@taniemarie.solon.com>.
|
||||
* cat.c cksum.c comm.c csplit.c cut.c expand.c fold.c head.c join.c
|
||||
nl.c paste.c pr.c split.c sum.c tac.c tail.c tr.c unexpand.c uniq.c
|
||||
wc.c (main): Likewise.
|
||||
|
||||
Sat Mar 16 16:30:07 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (PACKAGE_VERSION): New macro.
|
||||
* acconfig.h (PACKAGE_VERSION): Add it.
|
||||
* src/Makefile.am: Remove rules for generating version.c.
|
||||
Remove references to version.o, version.h, and stamp-v.
|
||||
* version.c: Remove file.
|
||||
* version.h: Remove file.
|
||||
* cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c fold.c
|
||||
head.c join.c md5sum.c nl.c od.c paste.c pr.c sort.c split.c
|
||||
sum.c tac.c tail.c tr.c unexpand.c uniq.c wc.c: Don't include
|
||||
version.h.
|
||||
(main): Use PACKAGE_VERSION instead of version_string.
|
||||
|
||||
Mon Mar 11 16:07:08 CST 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* sort.c (write_bytes): Renamed from xfwrite.
|
||||
Remove SIZE parameter. It was always 1. Update all callers.
|
||||
Rename NELEM parameter to N_BYTES and change its type to size_t.
|
||||
|
||||
Sat Mar 9 13:30:12 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* cat.c cksum.c comm.c csplit.c cut.c expand.c fmt.c
|
||||
fold.c head.c join.c md5sum.c nl.c od.c paste.c pr.c sort.c
|
||||
split.c sum.c tac.c tail.c tr.c unexpand.c uniq.c wc.c (main):
|
||||
Initialize for internationalized message support: call setlocale,
|
||||
bindtextdomain, and textdomain.
|
||||
* system.h: Add definitions and includes for NLS.
|
||||
* Makefile.am (SUBDIRS): Add intl and po.
|
||||
* src/Makefile.am (datadir): Define.
|
||||
(localedir): Define.
|
||||
(DEFS): Add LOCALEDIR definition.
|
||||
(LDADD): Add @INTLLIBS@.
|
||||
* aclocal.m4: Add NLS-related macro definitions from
|
||||
gettext distribution.
|
||||
* acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES,
|
||||
HAVE_STPCPY): New macros.
|
||||
Add PACKAGE and VERSION.
|
||||
* configure.in (PACKAGE): Define with AC_DEFINE_UNQUOTED.
|
||||
(VERSION): Likewise.
|
||||
(ALL_LINGUAS): Define.
|
||||
(AC_CHECK_HEADERS): Add float.h.
|
||||
(ud_GNU_GETTEXT): Use it.
|
||||
Link an nls file.
|
||||
(AC_OUTPUT): Reflect addition of two new directories, intl and po.
|
||||
Create po/Makefile.
|
||||
From François Pinard.
|
||||
|
||||
* tr.c (star_digits_closebracket): Declare formal param, IDX,
|
||||
and local I to be of type size_t (rather than int) to avoid
|
||||
warnings from gcc -Wall.
|
||||
|
||||
Wed Feb 28 20:32:48 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* src/Makefile.am: Adapt for automake-0.30.
|
||||
(noinst_HEADERS): Rename from HEADERS.
|
||||
(INCLUDES): Remove -I.. and -I$(srcdir). automake-0.30 adds these
|
||||
to DEFS automatically.
|
||||
* lib/Makefile.am: (noinst_HEADERS): Rename from HEADERS.
|
||||
|
||||
Wed Feb 21 18:56:27 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* join.c (xfields) [without -t]: Ignore leading blanks.
|
||||
From David Dyck (dcd@tc.fluke.COM).
|
||||
|
||||
Sun Feb 18 12:07:27 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* join.c [TOLOWER]: Define.
|
||||
(usage): Briefly describe new --ignore-case (-i) option.
|
||||
(memcasecmp): New function.
|
||||
(main): Set IGNORE_CASE for -i.
|
||||
(keycmp): Compare with memcasecmp if IGNORE_CASE is set.
|
||||
Suggestion and an initial patch from Alberto Accomazzi
|
||||
<alberto@cfa0.harvard.edu>.
|
||||
|
||||
Sat Feb 17 18:54:40 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* sort.c: Add -z option. Change all occurrences of '\n' to `eolchar'.
|
||||
(usage): Describe it.
|
||||
(main): Set eolchar to 0 for -z.
|
||||
From Mark W. Eichin <eichin@cygnus.com>.
|
||||
|
||||
Fri Feb 16 21:44:14 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* join.c (main): Mark two strings for translation.
|
||||
* md5sum.c (md5_check): Mark a string for translation.
|
||||
From François Pinard.
|
||||
|
||||
Mon Feb 12 21:12:28 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
Update for automake-0.29.
|
||||
* Makefile.am (CONFIG_HEADER): Don't define. Automake now does it.
|
||||
* src/Makefile.am: Likewise.
|
||||
* lib/Makefile.am: Likewise.
|
||||
* doc/Makefile.am (info_TEXINFOS): Renamed from TEXINFOS.
|
||||
* man/Makefile.am (man_MANS): Renamed from MANS.
|
||||
|
||||
* fmt.c [TRUE]: Undefine before defining to avoid warning on NeXT.
|
||||
[FALSE]: Likewise.
|
||||
From Derek Clegg (dclegg@next.com).
|
||||
|
||||
Sat Feb 3 16:20:40 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* Version 1.14.
|
||||
|
||||
Wed Jan 31 23:26:13 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* tail.c (dump_remainder): Flush stdout when tailing-forever on
|
||||
multiple files. From Carlos Canau <Carlos.Canau@relay.puug.pt>.
|
||||
|
||||
Fri Jan 5 18:30:28 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* aclocal.m4: For SVR4 systems, use -Xc -D_POSIX_C_SOURCE in CFLAGS,
|
||||
not just -Xc. From François Pinard.
|
||||
|
||||
* doc/Makefile.am (DIST_OTHER): Don't set to mdate-sh. mdate-sh is
|
||||
distributed automatically. From Tom Tromey.
|
||||
|
||||
Thu Jan 4 20:32:52 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* nl.c: Include rx.h after limit.h (not before) to avoid warning
|
||||
about the redeclaration of RE_DUP_MAX in limit.h. rx.h protects
|
||||
its definition. From Kaveh Ghazi.
|
||||
|
||||
* src/Makefile.am (DIST_OTHER): Include md5-test.rfc so make check
|
||||
works again. Reported by François Pinard and Kaveh Ghazi.
|
||||
|
||||
* rx.c [SYNTAX]: Rename from SYNTAX_TABLE.
|
||||
[SYNTAX_TABLE]: Remove extern dcl of re_syntax_table.
|
||||
(RE_SEARCH_2_FN): Cast string1 and string2 to avoid pointer type
|
||||
mismatch errors from e.g. SunOS's /bin/cc.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
Wed Jan 3 23:34:39 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* configure.in (VERSION): Set variable directly rather than from
|
||||
a separate file.
|
||||
* Makefile.am (DIST_OTHER): Remove VERSION.
|
||||
* src/Makefile.am (version.c): Depend on Makefile, not ../VERSION.
|
||||
(stamp-v): New target; depend on Makefile.
|
||||
(DISTCLEANFILES): Add stamp-v, version.c.
|
||||
|
||||
Tue Jan 2 00:08:08 1996 Jim Meyering (meyering@na-net.ornl.gov)
|
||||
|
||||
* sort.c (keycompare): Rewrite cases handling ignored characters
|
||||
so that they really are ignored. Reported by Carl Johnson
|
||||
<carlj@cjlinux.home.org>.
|
||||
|
||||
Fri Dec 22 21:34:55 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* configure.in: Touch stamp-h only if config.h is remade.
|
||||
|
||||
* csplit.c (extract_regexp) [!WITH_REGEX]: Intialize
|
||||
syntax_parens field.
|
||||
|
||||
Mon Dec 18 21:42:44 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
Use automake to generate Makefile.in files.
|
||||
* Makefile.am: New file.
|
||||
* doc/Makefile.am: New file.
|
||||
* lib/Makefile.am: New file.
|
||||
* man/Makefile.am: New file.
|
||||
* src/Makefile.am: New file.
|
||||
|
||||
Thu Dec 14 21:13:22 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* fmt.c (main): Use xstrtol instead of atoi.
|
||||
|
||||
* fold.c (main): Use xstrtol instead of atoi.
|
||||
(fold_file): Make a couple locals `int', not size_t, and cast
|
||||
fwrite's third parameter to size_t.
|
||||
|
||||
* nl.c (main): Use xstrtol instead of atoi.
|
||||
Rename misleading --first-page=N option to --starting-line-number=N.
|
||||
(usage): Update.
|
||||
|
||||
* uniq.c (main): Use xstrtol instead of atoi.
|
||||
|
||||
Fri Dec 8 20:48:00 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* aclocal.m4 (fp_C_PROTOTYPES): Set ANSI2KNR to ./ansi2knr.
|
||||
|
||||
Thu Dec 7 19:55:03 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* aclocal.m4 (ud_WITH_REGEX): New macro.
|
||||
* configure.in: Use it.
|
||||
* rx.c, rx.h: New files.
|
||||
* lib/Makefile.in (REGEX): Set to @REGEXOBJ@, not regex.o.
|
||||
(SOURCES, DISTFILES): Add rx.c, rx.h.
|
||||
* acconfig.h (WITH_REGEX): Add it.
|
||||
* csplit.c [!WITH_REGEX]: Include rx.h.
|
||||
* nl.c [!WITH_REGEX]: Likewise.
|
||||
* tac.c [!WITH_REGEX]: Likewise.
|
||||
From Ulrich Drepper and François Pinard.
|
||||
|
||||
Tue Dec 5 17:49:53 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* sort.c (main): Diagnose invalid arguments to -k, then fail.
|
||||
|
||||
* sort.c (numcompare): Properly handle all cases in which signs differ.
|
||||
From Karl Heuer.
|
||||
|
||||
* Makefile.in (mandir): @mandir@ is just $(prefix)/man.
|
||||
Append `/man1'. Reported by Karl Heuer.
|
||||
|
||||
* sum.c (bsd_sum_file): Remove misleading comment. From Karl Heuer.
|
||||
|
||||
* src/Makefile.in [.c._o]: Don't create $<-tmp. From Kaveh Ghazi.
|
||||
|
||||
Fri Dec 1 01:02:36 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* lib/Makefile.in (default): New target.
|
||||
|
||||
* sort.c (numcompare): Properly order `-' and valid integers;
|
||||
treat `-' as if it were zero. Reported by Ross Alexander
|
||||
<r.alexander@auckland.ac.nz>.
|
||||
|
||||
* Makefile.in (DISTFILES): Remove unused mkdep-Makefile.
|
||||
(.PHONY): Depend on default.
|
||||
|
||||
Wed Nov 29 21:50:53 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* aclocal.m4 (jm_PROG_C_MKDEP): Remove, for now.
|
||||
(jm_AUTODEPS): Likewise.
|
||||
(jm_WITH_GNU_MAKE): Likewise.
|
||||
* configure.in (jm_AUTODEPS): Remove.
|
||||
|
||||
* sort.c (begfield): Replace loop with equivalent if-else.
|
||||
(limfield): Fix bug that made field specs like -k1.5 return a
|
||||
pointer into LINE beyond the first field.
|
||||
Don't try to trim trailing blanks here; it's not
|
||||
possible because we don't know where the field begins.
|
||||
Replace loop with equivalent if-else.
|
||||
(trim_trailing_blanks): New function.
|
||||
(findlines): Call it.
|
||||
(keycompare): Likewise.
|
||||
(main): Don't decrement T2 corresponding to `x' in field
|
||||
specs like -ku.v,w.x.
|
||||
|
||||
Sun Nov 26 15:50:23 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* csplit.c [!UINT_MAX]: Define.
|
||||
[!INT_MAX]: Define.
|
||||
Include xstrtoul.h.
|
||||
(string_to_number): Remove function.
|
||||
(check_for_offset): Use xstrtoul instead of string_to_number.
|
||||
(parse_repeat_count): Likewise.
|
||||
(parse_patterns): Likewise.
|
||||
(main): Likewise.
|
||||
|
||||
Wed Nov 22 23:12:47 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* Makefile.in (all et. al.): If make was invoked with -k and a
|
||||
sub-make fails, fail after the loop rather than exiting right away.
|
||||
Otherwise, make's -k option could be ineffective.
|
||||
|
||||
Sat Nov 18 12:04:30 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* src/Makefile.in (version.c): Depend on ../VERSION, not Makefile.
|
||||
|
||||
Update for autoconf-2.5:
|
||||
* src/Makefile.in (libdir): Set to @libdir@.
|
||||
(bindir): Set to @bindir@.
|
||||
* doc/Makefile.in (infodir): Set to @infodir@.
|
||||
* man/Makefile.in (exec_prefix): Remove it.
|
||||
(mandir): Set to @mandir@.
|
||||
(bindir): Remove it.
|
||||
|
||||
Thu Nov 16 21:25:45 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* Makefile.in (default): New default target. Depend on `all' to
|
||||
work around bug in AIX-3.2.5's /bin/make. Reported by Andreas Luik
|
||||
<luik@isa.de>.
|
||||
|
||||
Wed Nov 15 23:48:31 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* mkdep-Makefile (.deps/empty.P): Depend on BUILT-HEADERS.
|
||||
|
||||
* aclocal.m4 (jm_PROG_C_MKDEP): Rename from jm_PROG_MKDEP.
|
||||
* src/Makefile.in (C_MKDEP): Rename from MKDEP.
|
||||
* lib/Makefile.in (C_MKDEP): Likewise.
|
||||
* mkdep-Makefile (C_MKDEP): Likewise.
|
||||
Add comments.
|
||||
|
||||
* csplit.c [__P]: Don't define it here.
|
||||
* pr.c [__P]: Don't define it here.
|
||||
* fmt.c [__P]: Don't define it here.
|
||||
* system.h [__P]: Define it here.
|
||||
|
||||
* aclocal.m4 (jm_AUTODEPS): Rename from jm_WITH_AUTODEPS.
|
||||
Revamp, with suggestions from Franc,ois Pinard.
|
||||
(jm_WITH_GNU_MAKE): New macro.
|
||||
(jm_PROG_MKDEP): New macro.
|
||||
* configure.in (jm_PROG_MKDEP): Use it.
|
||||
* src/Makefile.in (MKDEP): Set it.
|
||||
* lib/Makefile.in (MKDEP): Likewise.
|
||||
* mkdep-Makefile: Use MKDEP, not DEP_CC.
|
||||
(DEP_CFLAGS): Remove it.
|
||||
|
||||
Tue Nov 14 23:10:54 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* sort.c: Add support for sorting numbers in scientific notation.
|
||||
Include xstrtod.h.
|
||||
(struct keyfield): Add field: general_numeric.
|
||||
(usage): Describe -g option.
|
||||
(general_numcompare): New function.
|
||||
(keycompare): Use new comparison function when general_numeric
|
||||
flag is set.
|
||||
(set_ordering): Honor `g' flag.
|
||||
(main): Initialize and use new field.
|
||||
From Marcus Daniels <marcus@sysc.pdx.edu>.
|
||||
|
||||
* configure.in (AC_REPLACE_FUNCS): Add strtod.
|
||||
* lib/Makefile.in (SOURCES): Add xstrtod.c.
|
||||
(OBJECTS): Add xstrtod.o.
|
||||
(DISTFILES): Add xstrtod.h.
|
||||
|
||||
* csplit.c (cleanup): Don't exit.
|
||||
(interrupt_handler): Rewrite to reset default signal handler
|
||||
then repost caught signal.
|
||||
(xmalloc, xrealloc, read_input, write_to_file, handle_line_error,
|
||||
process_line_count, process_regexp, create_output_file,
|
||||
close_output_file): Call cleanup_fatal, not cleanup.
|
||||
Add const attribute to lots of parameters.
|
||||
(cleanup_fatal): Renamed from cleanup. Call cleanup, then exit.
|
||||
Update callers.
|
||||
|
||||
* tac.c: (cleanup): Don't exit.
|
||||
(cleanup_fatal): New function. Call cleanup, then exit.
|
||||
(sighandler): New function.
|
||||
(cleanup_fatal): Renamed from cleanup. Call cleanup, then exit.
|
||||
Update callers.
|
||||
(tac_stdin): Set up sighandler as signal handler, not `cleanup'.
|
||||
|
||||
Sat Nov 11 15:46:02 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* od.c (skip): Cast fseek's offset argument to `long'.
|
||||
Erik Bennett <bennett@cvo.oneworld.com> reported that this is
|
||||
necessary on BSDI systems. And if offset doesn't fit in a long,
|
||||
then try using lseek instead.
|
||||
|
||||
* sort.c (xmalloc): Declare static.
|
||||
(xrealloc): Likewise.
|
||||
|
||||
* tac.c (cleanup): Add signal number parameter.
|
||||
Update callers.
|
||||
|
||||
* cat.c (main): Don't die when dev/ino of input and output are
|
||||
the same and the file descriptors correspond to stdin and stdout.
|
||||
This is necessary on at least Digital UNIX (aka OSF1) 3.2C.
|
||||
Otherwise, running `cat << X > $$' would fail with `cat: -: input
|
||||
file is output file'. From Jarkko Hietaniemi <jhi@epsilon.hut.fi>.
|
||||
|
||||
* Makefile.in (DISTFILES): Add @README_ALPHA@.
|
||||
(config.status) Depend on VERSION.
|
||||
* configure.in: Set README_ALPHA if the version number ends in [a-z].
|
||||
|
||||
Fri Nov 10 21:13:42 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* fold.c (usage): Clarify meaning of --spaces. From Karl Berry.
|
||||
|
||||
src/Makefile.in (.c._c): Don't redirect directly to $@.
|
||||
(._c._o, .c._o): Remove temporary src file.
|
||||
|
||||
Tue Nov 7 23:55:24 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* VERSION: New file.
|
||||
* configure.in (VERSION): New variable.
|
||||
(PACKAGE): New variable.
|
||||
|
||||
* Makefile.in (DISTFILES): Add VERSION.
|
||||
(distdir): Use @PACKAGE@-@VERSION@, not distname.
|
||||
Remove all references to distname.
|
||||
* src/Makefile.in (version.c): Generate it.
|
||||
(SOURCES): Remove now-generated version.c.
|
||||
(distclean): Delete version.c.
|
||||
* doc/Makefile.in (version.texi): Use @PACKAGE@-@VERSION@,
|
||||
not version.c
|
||||
|
||||
* */Makefile.in (distdir): Use @PACKAGE@-@VERSION@, not distname.
|
||||
Remove all references to distname.
|
||||
|
||||
* split.c: New option: --verbose.
|
||||
(main): Recognize it.
|
||||
(usage): Document it.
|
||||
From Marty Leisner <leisner@sdsp.mc.xerox.com>.
|
||||
|
||||
Sun Nov 5 06:59:27 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* src/Makefile.in: Reflect protoization of csplit.c, fmt.c, pr.c,
|
||||
and unexpand.c.
|
||||
|
||||
* pr.c: Protoize.
|
||||
(store_columns): Remove spurious 2nd argument in call to read_line.
|
||||
[__P]: Define. Use it in prototyped forward decls.
|
||||
|
||||
* csplit.c: Move prototypes after struct declarations.
|
||||
Remove prototypes for xmalloc, xrealloc.
|
||||
Protect prototypes with __P.
|
||||
(new_control_record): Cast arg 1 to realloc.
|
||||
|
||||
* fmt.c [__P]: Test PROTOTYPES, not __STDC__.
|
||||
Protoize.
|
||||
|
||||
Sat Nov 4 23:51:30 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* csplit.c (close_output_file): Set output_stream to NULL so we
|
||||
don't recurse endlessly between this function and cleanup.
|
||||
|
||||
* unexpand.c: Reorder functions to obviate forward dcls. Remove
|
||||
forward dcls. Protoize. Add `const' attribute to some parameters.
|
||||
|
||||
@@ -33,8 +847,9 @@ Sun Oct 29 14:04:36 1995 Jim Meyering (meyering@comco.com)
|
||||
Sat Oct 28 16:02:39 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* md5sum.c (md5_check): Use the same message format when there is
|
||||
a single file and it gets a read error or checksum mismatch as when
|
||||
there are more. Suggestion from Greg Troxel (gdt@b-sgi.bbn.com).
|
||||
a single file and it gets a read error or checksum mismatch as when
|
||||
there are more. Write that warning to standard error, not standard
|
||||
output. Suggestions from Greg Troxel (gdt@b-sgi.bbn.com).
|
||||
|
||||
Thu Oct 26 00:11:35 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
@@ -59,7 +874,7 @@ Mon Oct 23 23:17:04 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
Thu Oct 19 17:38:28 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* od.c: Indent cpp directives.
|
||||
* od.c: Indent cpp directives.
|
||||
|
||||
* tr.c (BEGIN_STATE): Use INT_MAX - 1 so as not to interfere
|
||||
with large repeat counts.
|
||||
@@ -155,8 +970,8 @@ Thu Sep 28 23:16:05 1995 Jim Meyering (meyering@comco.com)
|
||||
Tue Sep 26 23:05:01 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* man/Makefile.in (install-data, uninstall): Use sed not basename.
|
||||
The GNU Coding Standard suggests that only a select set of
|
||||
relatively standard utilities be used in Makefiles. basename is
|
||||
The GNU Coding Standard suggests that only a select set of
|
||||
relatively standard utilities be used in Makefiles. basename is
|
||||
not among them. Suggested by Ulrich Drepper.
|
||||
|
||||
Sun Sep 24 08:36:47 1995 Jim Meyering (meyering@comco.com)
|
||||
@@ -355,7 +1170,6 @@ Tue Jul 11 21:56:02 1995 Jim Meyering (meyering@comco.com)
|
||||
|
||||
* md5sum.c Add #else block after #ifdef VMS.
|
||||
(main): Rename local variable.
|
||||
Add FIXME: allow newlines in filenames.
|
||||
Detect and report failed fclose calls on stdout and checkfile_stream.
|
||||
|
||||
* tr.c (unqote): Comment out unreachable break stmts.
|
||||
@@ -398,7 +1212,7 @@ Thu Jul 6 23:44:20 1995 Jim Meyering (meyering@comco.com)
|
||||
* od.c (dump): Correct loop-termination criterion.
|
||||
Before, running `printf 1234| ./od --width=4 --read-bytes=4'
|
||||
printed output for 8 bytes -- the last four were garbage.
|
||||
This happened only when the dump limit, N, was specified (with
|
||||
This happened only when the dump limit, N, was specified (with
|
||||
--read-bytes=N) and N was a multiple of bytes_per_block
|
||||
(usually 16, but 4 in this example). From Andreas Schwab.
|
||||
|
||||
|
||||
@@ -1,8 +1,49 @@
|
||||
Changes in release 1.19
|
||||
* md5sum can verify digests of files with names containing newline characters
|
||||
* update from gettext-0.10.20.
|
||||
|
||||
Changes in release 1.18
|
||||
* when building sort, link with -lm on systems that use the replacement strtod
|
||||
* update from gettext-0.10.17.
|
||||
|
||||
Changes in release 1.17
|
||||
* include texinfo.tex in the distribution
|
||||
|
||||
Changes in release 1.16
|
||||
* sort is compatible with Unix sort when a key-end spec refers to the N'th
|
||||
character in a field that has fewer than N characters
|
||||
* tail with old-style options like -20k and +31m operates on units of bytes,
|
||||
as the --help usage message says. Before, it used units of lines.
|
||||
|
||||
Changes in release 1.15
|
||||
* od gives better diagnostics for invalid format specs
|
||||
* uses automake-generated Makefile templates
|
||||
* configure takes a new option: --enable-maintainer-mode
|
||||
* fix a bug in fmt when prefix has trailing white space
|
||||
* internationalized diagnostic messages
|
||||
* fix a couple bugs in tr involving use of -c and/or -d flags -- see ChangeLog
|
||||
* diagnose some improper or questionable invocations of csplit
|
||||
* properly handle `echo |csplit - 1 1', rather than aborting
|
||||
* fix join: without -t it now ignores leading blanks
|
||||
* sort accepts new option: -z for NUL terminated records
|
||||
* join accepts new option: --ignore-case, -i
|
||||
* uniq accepts new option: --ignore-case, -i
|
||||
|
||||
User-visible changes in release 1.14
|
||||
* sort -i and sort -d properly order strings containing ignored characters
|
||||
* nl: rename misleading --first-page=N option to --starting-line-number=N.
|
||||
* sort diagnoses invalid arguments to -k, then fails
|
||||
* sort -n properly orders invalid integers with respect to valid integers
|
||||
* sorting works with character offsets larger than corresponding field width
|
||||
* sort's -b option and `b' modifier work
|
||||
* sort -k2,2 works.
|
||||
* csplit detects integer overflow when converting command line arguments
|
||||
* sort accepts new option/flag, -g, for sorting numbers in scientific notation
|
||||
* join accepts POSIX `-o 0' field specifier.
|
||||
* tr 'a[b*512]' '[a*]' < /dev/null terminates
|
||||
* tr '[:*3][:digit:]' 'a-m' and tr 'a[=*2][=c=]' 'xyyz' no longer fail
|
||||
* special characters in tr's string1 and string2 may be escaped with backslash
|
||||
|
||||
User-visible changes in release 1.13
|
||||
* md5sum: with --check, distinguish between open/read failure and bad checksum
|
||||
* md5sum: remove -h, -s, -v short options
|
||||
@@ -15,6 +56,7 @@ User-visible changes in release 1.13
|
||||
* sort accepts -.1 +.2 options for compatibility
|
||||
* od works properly when dump limit is specified and is a multiple of
|
||||
bytes_per_block (set by --width, 16 by default).
|
||||
|
||||
User-visible changes in release 1.12
|
||||
* sort no longer reports spurious errors on Ultrix systems
|
||||
* new program: md5sum
|
||||
@@ -31,8 +73,10 @@ User-visible changes in release 1.12
|
||||
* wc is faster when not counting words
|
||||
* wc now works even when file pointer isn't at beginning of file
|
||||
* expand no longer seg faults with very long tab lists
|
||||
|
||||
User-visible changes in release 1.11
|
||||
* fmt is built
|
||||
|
||||
User-visible changes in release 1.10
|
||||
* skeletal texinfo documentation (mainly just the `invoking' nodes)
|
||||
* new program: fmt
|
||||
|
||||
253
po/Makefile.in.in
Normal file
253
po/Makefile.in.in
Normal file
@@ -0,0 +1,253 @@
|
||||
# Makefile for program source directory in GNU NLS utilities package.
|
||||
# Copyright (C) 1995, 1996 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.
|
||||
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SHELL = /bin/sh
|
||||
@SET_MAKE@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datadir = $(prefix)/@DATADIRNAME@
|
||||
localedir = $(datadir)/locale
|
||||
gnulocaledir = $(prefix)/share/locale
|
||||
gettextsrcdir = $(prefix)/share/gettext/po
|
||||
subdir = po
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
|
||||
CC = @CC@
|
||||
GENCAT = @GENCAT@
|
||||
GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
|
||||
MSGFMT = @MSGFMT@
|
||||
XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
|
||||
MSGMERGE = PATH=../src:$$PATH msgmerge
|
||||
|
||||
DEFS = @DEFS@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
INCLUDES = -I.. -I$(top_srcdir)/intl
|
||||
|
||||
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
|
||||
|
||||
SOURCES = cat-id-tbl.c
|
||||
POFILES = @POFILES@
|
||||
GMOFILES = @GMOFILES@
|
||||
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
|
||||
stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
|
||||
|
||||
POTFILES = \
|
||||
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
INSTOBJEXT = @INSTOBJEXT@
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) $<
|
||||
|
||||
.po.pox:
|
||||
$(MAKE) $(PACKAGE).pot
|
||||
$(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
|
||||
|
||||
.po.mo:
|
||||
$(MSGFMT) -o $@ $<
|
||||
|
||||
.po.gmo:
|
||||
file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
|
||||
&& rm -f $$file && $(GMSGFMT) -o $$file $<
|
||||
|
||||
.po.cat:
|
||||
sed -f ../intl/po2msg.sed < $< > $*.msg \
|
||||
&& rm -f $@ && $(GENCAT) $@ $*.msg
|
||||
|
||||
|
||||
all: all-@USE_NLS@
|
||||
|
||||
all-yes: cat-id-tbl.c $(CATALOGS)
|
||||
all-no:
|
||||
|
||||
$(PACKAGE).pot: @MAINT@$(POTFILES)
|
||||
$(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \
|
||||
--add-comments --keyword=_ --keyword=N_ \
|
||||
--files-from=$(srcdir)/POTFILES.in
|
||||
if [ ! -s $(PACKAGE).po ] \
|
||||
|| cmp -s $(PACKAGE).po $(srcdir)/$(PACKAGE).pot; then \
|
||||
rm -f $(PACKAGE).po; \
|
||||
else \
|
||||
rm -f $(srcdir)/$(PACKAGE).pot \
|
||||
&& mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot; \
|
||||
fi
|
||||
|
||||
cat-id-tbl.c: stamp-cat-id
|
||||
stamp-cat-id: $(PACKAGE).pot
|
||||
rm -f cat-id-tbl.tmp
|
||||
sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
|
||||
| sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
|
||||
if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \
|
||||
rm cat-id-tbl.tmp; \
|
||||
else \
|
||||
echo cat-id-tbl.c changed; \
|
||||
rm -f $(srcdir)/cat-id-tbl.c; \
|
||||
mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \
|
||||
fi
|
||||
cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id
|
||||
|
||||
|
||||
install: install-exec install-data
|
||||
install-exec:
|
||||
install-data: install-data-@USE_NLS@
|
||||
install-data-no: all
|
||||
install-data-yes: all
|
||||
if test -r $(MKINSTALLDIRS); then \
|
||||
$(MKINSTALLDIRS) $(datadir); \
|
||||
else \
|
||||
$(top_srcdir)/mkinstalldirs $(datadir); \
|
||||
fi
|
||||
@catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
case "$$cat" in \
|
||||
*.gmo) destdir=$(gnulocaledir);; \
|
||||
*) destdir=$(localedir);; \
|
||||
esac; \
|
||||
lang=`echo $$cat | sed 's/$(CATOBJEXT)$$//'`; \
|
||||
dir=$$destdir/$$lang/LC_MESSAGES; \
|
||||
if test -r $(MKINSTALLDIRS); then \
|
||||
$(MKINSTALLDIRS) $$dir; \
|
||||
else \
|
||||
$(top_srcdir)/mkinstalldirs $$dir; \
|
||||
fi; \
|
||||
if test -r $$cat; then \
|
||||
$(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
else \
|
||||
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
echo "installing $(srcdir)/$$cat as" \
|
||||
"$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
fi; \
|
||||
if test -r $$cat.m; then \
|
||||
$(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
else \
|
||||
if test -r $(srcdir)/$$cat.m ; then \
|
||||
$(INSTALL_DATA) $(srcdir)/$$cat.m \
|
||||
$$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
echo "installing $(srcdir)/$$cat as" \
|
||||
"$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
else \
|
||||
true; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
if test "$(PACKAGE)" = "gettext"; then \
|
||||
if test -r $(MKINSTALLDIRS); then \
|
||||
$(MKINSTALLDIRS) $(gettextsrcdir); \
|
||||
else \
|
||||
$(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
|
||||
fi; \
|
||||
cd $(srcdir) && \
|
||||
$(INSTALL_DATA) Makefile.in.in $(gettextsrcdir)/Makefile.in.in; \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
|
||||
# Define this as empty until I found a useful application.
|
||||
installcheck:
|
||||
|
||||
uninstall:
|
||||
catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
lang=`echo $$cat | sed 's/$(CATOBJEXT)$$//'`; \
|
||||
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
done
|
||||
rm -f $(gettextsrcdir)/po-Makefile.in.in
|
||||
|
||||
check: all
|
||||
|
||||
cat-id-tbl.o: ../intl/libgettext.h
|
||||
|
||||
dvi info tags TAGS ID:
|
||||
|
||||
mostlyclean:
|
||||
rm -f core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp
|
||||
rm -fr *.o
|
||||
|
||||
clean: mostlyclean
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
|
||||
|
||||
maintainer-clean: distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
dist distdir: update-po $(DISTFILES)
|
||||
for file in $(DISTFILES); do \
|
||||
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
|
||||
|| cp -p $(srcdir)/$$file $(distdir); \
|
||||
done
|
||||
|
||||
update-po: Makefile
|
||||
$(MAKE) $(PACKAGE).pot
|
||||
PATH=`pwd`/../src:$$PATH; \
|
||||
cd $(srcdir); \
|
||||
catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
lang=`echo $$cat | sed 's/$(CATOBJEXT)$$//'`; \
|
||||
mv $$lang.po $$lang.old.po; \
|
||||
echo "$$lang:"; \
|
||||
if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \
|
||||
rm -f $$lang.old.po; \
|
||||
else \
|
||||
echo "msgmerge for $$cat failed!"; \
|
||||
rm -f $$lang.po; \
|
||||
mv $$lang.old.po $$lang.po; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
POTFILES: POTFILES.in
|
||||
( if test 'x$(srcdir)' != 'x.'; then \
|
||||
posrcprefix='$(top_srcdir)/'; \
|
||||
else \
|
||||
posrcprefix="../"; \
|
||||
fi; \
|
||||
sed -e '/^#/d' -e '/^[ ]*$$/d' \
|
||||
-e "s@.*@ $$posrcprefix& \\\\@" \
|
||||
-e '$$s/\(.*\) \\/\1/' < $(srcdir)/POTFILES.in > POTFILES )
|
||||
|
||||
Makefile: Makefile.in.in ../config.status POTFILES
|
||||
cd .. \
|
||||
&& CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
|
||||
$(SHELL) ./config.status
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
264
src/asa.c
Normal file
264
src/asa.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
TODO
|
||||
mark translatable strings
|
||||
add usage function
|
||||
call parse_long_options
|
||||
dcl, set program_name
|
||||
do fclose/error checking
|
||||
*/
|
||||
|
||||
/* asa.c - interpret ASA carriage control characters
|
||||
Copyright (C) 94, 1996 Thomas Koenig
|
||||
|
||||
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. */
|
||||
|
||||
/* System Headers */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define LINESIZE 135
|
||||
#define NUMLINES 5
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* Structures and unions */
|
||||
|
||||
struct Str
|
||||
{
|
||||
char *chr;
|
||||
size_t len;
|
||||
};
|
||||
typedef struct Str str;
|
||||
|
||||
/* File scope variables */
|
||||
|
||||
static str *line_buffer = (str *) 0;
|
||||
static size_t line_num = 0;
|
||||
static size_t linebuf_size;
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static size_t readline (FILE *fp, char **a);
|
||||
static void add_line (str *);
|
||||
static void flush (void);
|
||||
static void copy_file (FILE *fp);
|
||||
|
||||
/* Local functions */
|
||||
|
||||
static void
|
||||
form_feed ()
|
||||
{
|
||||
putchar ('\f');
|
||||
}
|
||||
|
||||
static void
|
||||
new_line ()
|
||||
{
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
static void
|
||||
add_line (str *line)
|
||||
{
|
||||
if (line_num >= linebuf_size)
|
||||
{
|
||||
linebuf_size += NUMLINES;
|
||||
line_buffer = (str *) xrealloc (line_buffer, linebuf_size * sizeof (str *));
|
||||
}
|
||||
line_buffer[line_num] = *line;
|
||||
line_num++;
|
||||
}
|
||||
|
||||
static void
|
||||
flush ()
|
||||
{
|
||||
size_t i, j;
|
||||
size_t max_len;
|
||||
|
||||
if (line_num == 0)
|
||||
return;
|
||||
if (line_num == 1)
|
||||
{
|
||||
printf ("%s\n", line_buffer[0].chr + 1);
|
||||
line_num = 0;
|
||||
return;
|
||||
}
|
||||
max_len = 0;
|
||||
for (j = 0; j < line_num; j++)
|
||||
max_len = MAX (max_len, line_buffer[j].len);
|
||||
|
||||
for (i = 1; i <= max_len; i++)
|
||||
{
|
||||
int printed = 0;
|
||||
|
||||
for (j = 0; j < line_num; j++)
|
||||
{
|
||||
if (line_buffer[j].len > i)
|
||||
{
|
||||
int ch = line_buffer[j].chr[i];
|
||||
|
||||
if (ch != ' ')
|
||||
{
|
||||
if (printed)
|
||||
putchar ('\b');
|
||||
putchar (ch);
|
||||
printed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!printed)
|
||||
putchar (' ');
|
||||
}
|
||||
for (j = 0; j < line_num; j++)
|
||||
free (line_buffer[j].chr);
|
||||
|
||||
line_num = 0;
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
static size_t
|
||||
readline (FILE *fp, char **ret)
|
||||
{
|
||||
static char *buffer = (char *) 0;
|
||||
char *ret_buff;
|
||||
static int bufsize = LINESIZE;
|
||||
int ch;
|
||||
size_t len = 0;
|
||||
int inc;
|
||||
int i;
|
||||
|
||||
if (buffer == (char *) 0)
|
||||
buffer = (char *) xmalloc (LINESIZE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ch = fgetc (fp);
|
||||
if (ch == EOF)
|
||||
break;
|
||||
if (ch == '\t')
|
||||
{
|
||||
ch = ' ';
|
||||
inc = 8 - (len % 8);
|
||||
}
|
||||
else
|
||||
inc = 1;
|
||||
|
||||
if (len + inc > bufsize - 2)
|
||||
{
|
||||
bufsize += LINESIZE;
|
||||
buffer = xrealloc (buffer, bufsize);
|
||||
}
|
||||
for (i = 0; i < inc; i++)
|
||||
buffer[len + i] = ch;
|
||||
len += inc;
|
||||
if (ch == '\n')
|
||||
break;
|
||||
}
|
||||
buffer[len] = '\0';
|
||||
ret_buff = xmalloc (len + 1);
|
||||
strcpy (ret_buff, buffer);
|
||||
*ret = ret_buff;
|
||||
return len;
|
||||
}
|
||||
|
||||
static void
|
||||
copy_file (FILE *fp)
|
||||
{
|
||||
str line;
|
||||
static first_line = 1;
|
||||
|
||||
while ((line.len = readline (fp, &(line.chr))))
|
||||
{
|
||||
if (line.chr[line.len - 1] == '\n')
|
||||
{
|
||||
line.chr[line.len - 1] = '\0';
|
||||
line.len--;
|
||||
}
|
||||
|
||||
switch (line.chr[0])
|
||||
{
|
||||
case '+':
|
||||
add_line (&line);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
flush ();
|
||||
new_line ();
|
||||
add_line (&line);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
flush ();
|
||||
if (!first_line)
|
||||
form_feed ();
|
||||
add_line (&line);
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
flush ();
|
||||
add_line (&line);
|
||||
break;
|
||||
|
||||
default:
|
||||
flush ();
|
||||
add_line (&line);
|
||||
break;
|
||||
}
|
||||
first_line = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Global functions */
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int err;
|
||||
line_buffer = (str *) xmalloc (NUMLINES * sizeof (str *));
|
||||
linebuf_size = NUMLINES;
|
||||
|
||||
err = 0;
|
||||
if (argc == 1)
|
||||
copy_file (stdin);
|
||||
else
|
||||
{
|
||||
FILE *fp;
|
||||
char *fname;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
fname = *++argv;
|
||||
if ((fp = fopen (fname, "r")) == NULL)
|
||||
{
|
||||
err = 1;
|
||||
error (0, errno, "%s", fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy_file (fp);
|
||||
fclose (fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
flush ();
|
||||
exit (err ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from filenames
|
||||
Copyright (C) 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Usage: basename name [suffix]
|
||||
NAME is a pathname; SUFFIX is a suffix to strip from it.
|
||||
@@ -30,57 +30,74 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
char *basename ();
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
static void remove_suffix ();
|
||||
extern char *basename ();
|
||||
extern void strip_trailing_slashes ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Usage: %s NAME [SUFFIX]\n\
|
||||
or: %s OPTION\n\
|
||||
",
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Print NAME with any leading directory components removed.\n\
|
||||
If specified, also remove a trailing SUFFIX.\n\
|
||||
\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
");
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
/* Remove SUFFIX from the end of NAME if it is there, unless NAME
|
||||
consists entirely of SUFFIX. */
|
||||
|
||||
static void
|
||||
remove_suffix (char *name, const char *suffix)
|
||||
{
|
||||
char *np;
|
||||
const char *sp;
|
||||
|
||||
np = name + strlen (name);
|
||||
sp = suffix + strlen (suffix);
|
||||
|
||||
while (np > name && sp > suffix)
|
||||
if (*--np != *--sp)
|
||||
return;
|
||||
if (np > name)
|
||||
*np = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *name;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "basename", version_string, usage);
|
||||
parse_long_options (argc, argv, "basename", PACKAGE_VERSION, usage);
|
||||
|
||||
if (argc == 1 || argc > 3)
|
||||
{
|
||||
error (0, 0, "too %s arguments", argc == 1 ? "few" : "many");
|
||||
error (0, 0, (argc == 1 ? _("too few arguments")
|
||||
: _("too many arguments")));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -95,22 +112,3 @@ main (argc, argv)
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/* Remove SUFFIX from the end of NAME if it is there, unless NAME
|
||||
consists entirely of SUFFIX. */
|
||||
|
||||
static void
|
||||
remove_suffix (name, suffix)
|
||||
register char *name, *suffix;
|
||||
{
|
||||
register char *np, *sp;
|
||||
|
||||
np = name + strlen (name);
|
||||
sp = suffix + strlen (suffix);
|
||||
|
||||
while (np > name && sp > suffix)
|
||||
if (*--np != *--sp)
|
||||
return;
|
||||
if (np > name)
|
||||
*np = '\0';
|
||||
}
|
||||
|
||||
55
src/cat.c
55
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 1988, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 95, 1996 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
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
@@ -73,7 +72,7 @@ static char *line_num_end = line_buf + 10;
|
||||
static int newlines2 = 0;
|
||||
|
||||
/* Count of non-fatal error conditions. */
|
||||
static int exit_stat = 0;
|
||||
static int exit_status = 0;
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
@@ -106,7 +105,7 @@ Concatenate FILE(s), or standard input, to standard output.\n\
|
||||
With no FILE, or when FILE is -, read standard input.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Compute the next line number. */
|
||||
@@ -152,7 +151,7 @@ simple_cat (
|
||||
if (n_read < 0)
|
||||
{
|
||||
error (0, errno, "%s", infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +163,7 @@ simple_cat (
|
||||
/* Write this block out. */
|
||||
|
||||
if (full_write (output_desc, buf, n_read) < 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +244,7 @@ cat (
|
||||
do
|
||||
{
|
||||
if (full_write (output_desc, wp, outsize) < 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
wp += outsize;
|
||||
}
|
||||
while (bpout - wp >= outsize);
|
||||
@@ -287,7 +286,7 @@ cat (
|
||||
else
|
||||
{
|
||||
error (0, errno, _("cannot do ioctl on `%s'"), infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
newlines2 = newlines;
|
||||
return;
|
||||
}
|
||||
@@ -298,7 +297,7 @@ cat (
|
||||
int n_write = bpout - outbuf;
|
||||
|
||||
if (full_write (output_desc, outbuf, n_write) < 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
bpout = outbuf;
|
||||
}
|
||||
|
||||
@@ -308,7 +307,7 @@ cat (
|
||||
if (n_read < 0)
|
||||
{
|
||||
error (0, errno, "%s", infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
newlines2 = newlines;
|
||||
return;
|
||||
}
|
||||
@@ -439,7 +438,7 @@ cat (
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
/* Optimal size of i/o operations of output. */
|
||||
@@ -481,13 +480,13 @@ main (int argc, char **argv)
|
||||
int quote = 0;
|
||||
int output_tabs = 1;
|
||||
|
||||
/* If non-zero, call cat, otherwise call simple_cat to do the actual work. */
|
||||
/* If nonzero, call cat, otherwise call simple_cat to do the actual work. */
|
||||
int options = 0;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -505,6 +504,9 @@ main (int argc, char **argv)
|
||||
};
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* Parse command line options. */
|
||||
|
||||
@@ -571,14 +573,14 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (2);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cat - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("cat - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -589,7 +591,7 @@ main (int argc, char **argv)
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
if (fstat (output_desc, &stat_buf) < 0)
|
||||
error (1, errno, _("standard output"));
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
outsize = ST_BLKSIZE (stat_buf);
|
||||
/* Input file can be output file for non-regular files.
|
||||
@@ -635,7 +637,7 @@ main (int argc, char **argv)
|
||||
if (input_desc < 0)
|
||||
{
|
||||
error (0, errno, "%s", infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -643,7 +645,7 @@ main (int argc, char **argv)
|
||||
if (fstat (input_desc, &stat_buf) < 0)
|
||||
{
|
||||
error (0, errno, "%s", infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
goto contin;
|
||||
}
|
||||
insize = ST_BLKSIZE (stat_buf);
|
||||
@@ -654,10 +656,11 @@ main (int argc, char **argv)
|
||||
files cannot be redirected to themselves. */
|
||||
|
||||
if (check_redirection
|
||||
&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino)
|
||||
&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino
|
||||
&& (input_desc != STDIN_FILENO || output_desc != STDOUT_FILENO))
|
||||
{
|
||||
error (0, 0, _("%s: input file is output file"), infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
goto contin;
|
||||
}
|
||||
|
||||
@@ -707,15 +710,15 @@ main (int argc, char **argv)
|
||||
if (strcmp (infile, "-") && close (input_desc) < 0)
|
||||
{
|
||||
error (0, errno, "%s", infile);
|
||||
exit_stat = 1;
|
||||
exit_status = 1;
|
||||
}
|
||||
}
|
||||
while (++argind < argc);
|
||||
|
||||
if (have_read_stdin && close (0) < 0)
|
||||
error (1, errno, "-");
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
if (close (1) < 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (exit_stat);
|
||||
exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
229
src/chgrp.c
229
src/chgrp.c
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
@@ -36,10 +36,14 @@
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "error.h"
|
||||
|
||||
/* MAXUID may come from limits.h *or* sys/params.h (via system.h) above. */
|
||||
#ifndef MAXUID
|
||||
# define MAXUID INT_MAX
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct group *getgrnam ();
|
||||
#endif
|
||||
@@ -48,20 +52,26 @@ struct group *getgrnam ();
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
|
||||
#else
|
||||
# define LCHOWN(FILE, OWNER, GROUP) 1
|
||||
#endif
|
||||
|
||||
char *group_member ();
|
||||
char *savedir ();
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static int change_file_group ();
|
||||
static int change_dir_group ();
|
||||
static void describe_change ();
|
||||
static void parse_group ();
|
||||
static void usage ();
|
||||
static int change_dir_group __P ((char *dir, int group, struct stat *statp));
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, and the systems has support for it, change the ownership
|
||||
of symbolic links rather than any files they point to. */
|
||||
static int change_symlinks;
|
||||
|
||||
/* If nonzero, change the ownership of directories recursively. */
|
||||
static int recurse;
|
||||
|
||||
@@ -77,16 +87,17 @@ static int changes_only;
|
||||
/* The name of the group to which ownership of the files is being given. */
|
||||
static char *groupname;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
{"changes", no_argument, 0, 'c'},
|
||||
{"no-dereference", no_argument, 0, 'h'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
@@ -95,78 +106,28 @@ static struct option const long_options[] =
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
/* Tell the user the group name to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE was that group already. */
|
||||
|
||||
static void
|
||||
describe_change (char *file, int changed)
|
||||
{
|
||||
int group;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind <= 1)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
usage (1);
|
||||
}
|
||||
|
||||
parse_group (argv[optind++], &group);
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (argv[optind], group);
|
||||
|
||||
exit (errors);
|
||||
if (changed)
|
||||
printf (_("group of %s changed to %s\n"), file, groupname);
|
||||
else
|
||||
printf (_("group of %s retained as %s\n"), file, groupname);
|
||||
}
|
||||
|
||||
/* Set *G according to NAME. */
|
||||
|
||||
static void
|
||||
parse_group (name, g)
|
||||
char *name;
|
||||
int *g;
|
||||
parse_group (char *name, int *g)
|
||||
{
|
||||
struct group *grp;
|
||||
|
||||
groupname = name;
|
||||
if (*name == '\0')
|
||||
error (1, 0, "can not change to null group");
|
||||
error (1, 0, _("can not change to null group"));
|
||||
|
||||
grp = getgrnam (name);
|
||||
if (grp == NULL)
|
||||
@@ -178,7 +139,7 @@ parse_group (name, g)
|
||||
*g = tmp_long;
|
||||
if (s_err == LONGINT_OVERFLOW || tmp_long > INT_MAX)
|
||||
{
|
||||
STRTOL_FATAL_ERROR (name, "group number", s_err);
|
||||
STRTOL_FATAL_ERROR (name, _("group number"), s_err);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -191,9 +152,7 @@ parse_group (name, g)
|
||||
Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_file_group (file, group)
|
||||
char *file;
|
||||
int group;
|
||||
change_file_group (char *file, int group)
|
||||
{
|
||||
struct stat file_stats;
|
||||
int errors = 0;
|
||||
@@ -207,9 +166,17 @@ change_file_group (file, group)
|
||||
|
||||
if (group != file_stats.st_gid)
|
||||
{
|
||||
int fail;
|
||||
|
||||
if (verbose)
|
||||
describe_change (file, 1);
|
||||
if (chown (file, file_stats.st_uid, group))
|
||||
|
||||
if (change_symlinks)
|
||||
fail = LCHOWN (file, file_stats.st_uid, group);
|
||||
else
|
||||
fail = chown (file, file_stats.st_uid, group);
|
||||
|
||||
if (fail)
|
||||
{
|
||||
errors = 1;
|
||||
if (force_silent == 0)
|
||||
@@ -219,15 +186,13 @@ change_file_group (file, group)
|
||||
of the specified group' errors. */
|
||||
if (errno == EPERM && !group_member (group))
|
||||
{
|
||||
error (0, errno, "you are not a member of group `%s'",
|
||||
error (0, errno, _("you are not a member of group `%s'"),
|
||||
groupname);
|
||||
}
|
||||
#ifdef MAXUID
|
||||
else if (errno == EINVAL && group > MAXUID)
|
||||
{
|
||||
error (0, 0, "%s: invalid group number", groupname);
|
||||
error (0, 0, _("%s: invalid group number"), groupname);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
error (0, errno, "%s", file);
|
||||
@@ -249,10 +214,7 @@ change_file_group (file, group)
|
||||
Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_dir_group (dir, group, statp)
|
||||
char *dir;
|
||||
int group;
|
||||
struct stat *statp;
|
||||
change_dir_group (char *dir, int group, struct stat *statp)
|
||||
{
|
||||
char *name_space, *namep;
|
||||
char *path; /* Full path of each entry to process. */
|
||||
@@ -272,7 +234,7 @@ change_dir_group (dir, group, statp)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
|
||||
@@ -298,39 +260,94 @@ change_dir_group (dir, group, statp)
|
||||
return errors;
|
||||
}
|
||||
|
||||
/* Tell the user the group name to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE was that group already. */
|
||||
|
||||
static void
|
||||
describe_change (file, changed)
|
||||
char *file;
|
||||
int changed;
|
||||
{
|
||||
if (changed)
|
||||
printf ("group of %s changed to %s\n", file, groupname);
|
||||
else
|
||||
printf ("group of %s retained as %s\n", file, groupname);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION]... GROUP FILE...\n", program_name);
|
||||
printf ("\
|
||||
printf (_("Usage: %s [OPTION]... GROUP FILE...\n"), program_name);
|
||||
printf (_("\
|
||||
Change the group membership of each FILE to GROUP.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
||||
(available only on systems with lchown system call)\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose output a diagnostic for every file processed\n\
|
||||
-R, --recursive change files and directories recursively\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
--version output version information and exit\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int group;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfnv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'h':
|
||||
change_symlinks = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCHOWN
|
||||
if (change_symlinks)
|
||||
{
|
||||
error (1, 0, _("--no-dereference (-h) is not supported on this system"));
|
||||
}
|
||||
#endif
|
||||
|
||||
parse_group (argv[optind++], &group);
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (argv[optind], group);
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
278
src/chmod.c
278
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Options:
|
||||
-R Recursively change modes of directory contents.
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "modechange.h"
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
void mode_string ();
|
||||
@@ -39,10 +38,9 @@ void strip_trailing_slashes ();
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static int change_file_mode ();
|
||||
static int change_dir_mode ();
|
||||
static void describe_change ();
|
||||
static void usage ();
|
||||
static int change_dir_mode __P ((const char *dir,
|
||||
const struct mode_change *changes,
|
||||
const struct stat *statp));
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
@@ -59,10 +57,10 @@ static int verbose;
|
||||
/* If nonzero, describe only modes that change. */
|
||||
static int changes_only;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -77,116 +75,32 @@ static struct option const long_options[] =
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Parse the ASCII mode given on the command line into a linked list
|
||||
of `struct mode_change' and apply that to each file argument. */
|
||||
/* Tell the user the mode MODE that file FILE has been set to;
|
||||
if CHANGED is zero, FILE had that mode already. */
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
static void
|
||||
describe_change (const char *file, short unsigned int mode, int changed)
|
||||
{
|
||||
struct mode_change *changes;
|
||||
int errors = 0;
|
||||
int modeind = 0; /* Index of the mode argument in `argv'. */
|
||||
int thisind;
|
||||
int c;
|
||||
char perms[11]; /* "-rwxrwxrwx" ls-style modes. */
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
thisind = optind ? optind : 1;
|
||||
|
||||
c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options,
|
||||
(int *) 0);
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'r':
|
||||
case 'w':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 's':
|
||||
case 't':
|
||||
case 'u':
|
||||
case 'g':
|
||||
case 'o':
|
||||
case 'a':
|
||||
case ',':
|
||||
case '+':
|
||||
case '-':
|
||||
case '=':
|
||||
if (modeind != 0 && modeind != thisind)
|
||||
error (1, 0, "invalid mode");
|
||||
modeind = thisind;
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chmod - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (modeind == 0)
|
||||
modeind = optind++;
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
usage (1);
|
||||
}
|
||||
|
||||
changes = mode_compile (argv[modeind],
|
||||
MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS);
|
||||
if (changes == MODE_INVALID)
|
||||
error (1, 0, "invalid mode");
|
||||
else if (changes == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
{
|
||||
strip_trailing_slashes (argv[optind]);
|
||||
errors |= change_file_mode (argv[optind], changes, 1);
|
||||
}
|
||||
|
||||
exit (errors);
|
||||
mode_string (mode, perms);
|
||||
perms[10] = '\0'; /* `mode_string' does not null terminate. */
|
||||
if (changed)
|
||||
printf (_("mode of %s changed to %04o (%s)\n"),
|
||||
file, mode & 07777, &perms[1]);
|
||||
else
|
||||
printf (_("mode of %s retained as %04o (%s)\n"),
|
||||
file, mode & 07777, &perms[1]);
|
||||
}
|
||||
|
||||
/* Change the mode of FILE according to the list of operations CHANGES.
|
||||
If DEREF_SYMLINK is non-zero and FILE is a symbolic link, change the
|
||||
If DEREF_SYMLINK is nonzero and FILE is a symbolic link, change the
|
||||
mode of the referenced file. If DEREF_SYMLINK is zero, ignore symbolic
|
||||
links. Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_file_mode (file, changes, deref_symlink)
|
||||
char *file;
|
||||
struct mode_change *changes;
|
||||
int deref_symlink;
|
||||
change_file_mode (const char *file, const struct mode_change *changes,
|
||||
const int deref_symlink)
|
||||
{
|
||||
struct stat file_stats;
|
||||
unsigned short newmode;
|
||||
@@ -240,10 +154,8 @@ change_file_mode (file, changes, deref_symlink)
|
||||
Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_dir_mode (dir, changes, statp)
|
||||
char *dir;
|
||||
struct mode_change *changes;
|
||||
struct stat *statp;
|
||||
change_dir_mode (const char *dir, const struct mode_change *changes,
|
||||
const struct stat *statp)
|
||||
{
|
||||
char *name_space, *namep;
|
||||
char *path; /* Full path of each entry to process. */
|
||||
@@ -263,7 +175,7 @@ change_dir_mode (dir, changes, statp)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
|
||||
@@ -289,42 +201,20 @@ change_dir_mode (dir, changes, statp)
|
||||
return errors;
|
||||
}
|
||||
|
||||
/* Tell the user the mode MODE that file FILE has been set to;
|
||||
if CHANGED is zero, FILE had that mode already. */
|
||||
|
||||
static void
|
||||
describe_change (file, mode, changed)
|
||||
char *file;
|
||||
unsigned short mode;
|
||||
int changed;
|
||||
{
|
||||
char perms[11]; /* "-rwxrwxrwx" ls-style modes. */
|
||||
|
||||
mode_string (mode, perms);
|
||||
perms[10] = '\0'; /* `mode_string' does not null terminate. */
|
||||
if (changed)
|
||||
printf ("mode of %s changed to %04o (%s)\n",
|
||||
file, mode & 07777, &perms[1]);
|
||||
else
|
||||
printf ("mode of %s retained as %04o (%s)\n",
|
||||
file, mode & 07777, &perms[1]);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
|
||||
or: %s [OPTION]... OCTAL_MODE FILE...\n\
|
||||
",
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf ("\
|
||||
printf (_("\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
@@ -334,7 +224,109 @@ Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n\
|
||||
one or more of the letters rwxXstugo.\n");
|
||||
one or more of the letters rwxXstugo.\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Parse the ASCII mode given on the command line into a linked list
|
||||
of `struct mode_change' and apply that to each file argument. */
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct mode_change *changes;
|
||||
int errors = 0;
|
||||
int modeind = 0; /* Index of the mode argument in `argv'. */
|
||||
int thisind;
|
||||
int c;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
thisind = optind ? optind : 1;
|
||||
|
||||
c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options,
|
||||
(int *) 0);
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'r':
|
||||
case 'w':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 's':
|
||||
case 't':
|
||||
case 'u':
|
||||
case 'g':
|
||||
case 'o':
|
||||
case 'a':
|
||||
case ',':
|
||||
case '+':
|
||||
case '-':
|
||||
case '=':
|
||||
if (modeind != 0 && modeind != thisind)
|
||||
error (1, 0, _("invalid mode"));
|
||||
modeind = thisind;
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chmod - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (modeind == 0)
|
||||
modeind = optind++;
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
changes = mode_compile (argv[modeind],
|
||||
MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS);
|
||||
if (changes == MODE_INVALID)
|
||||
error (1, 0, _("invalid mode"));
|
||||
else if (changes == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
{
|
||||
strip_trailing_slashes (argv[optind]);
|
||||
errors |= change_file_mode (argv[optind], changes, 1);
|
||||
}
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
258
src/chown.c
258
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
| user
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
@@ -49,20 +48,28 @@ struct group *getgrgid ();
|
||||
# define endpwent() ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
|
||||
#else
|
||||
# define LCHOWN(FILE, OWNER, GROUP) 1
|
||||
#endif
|
||||
|
||||
char *savedir ();
|
||||
char *parse_user_spec ();
|
||||
void strip_trailing_slashes ();
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static int change_file_owner ();
|
||||
static int change_dir_owner ();
|
||||
static void describe_change ();
|
||||
static void usage ();
|
||||
static int change_dir_owner __P ((char *dir, uid_t user, gid_t group,
|
||||
struct stat *statp));
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, and the systems has support for it, change the ownership
|
||||
of symbolic links rather than any files they point to. */
|
||||
static int change_symlinks;
|
||||
|
||||
/* If nonzero, change the ownership of directories recursively. */
|
||||
static int recurse;
|
||||
|
||||
@@ -81,91 +88,39 @@ static char *username;
|
||||
/* The name of the group to which ownership of the files is being given. */
|
||||
static char *groupname;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
{"changes", no_argument, 0, 'c'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"no-dereference", no_argument, 0, 'h'},
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
/* Tell the user the user and group names to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE had those owners already. */
|
||||
|
||||
static void
|
||||
describe_change (char *file, int changed)
|
||||
{
|
||||
uid_t user = (uid_t) -1; /* New uid; -1 if not to be changed. */
|
||||
gid_t group = (uid_t) -1; /* New gid; -1 if not to be changed. */
|
||||
int errors = 0;
|
||||
int optc;
|
||||
char *e;
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chown - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind >= argc - 1)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
usage (1);
|
||||
}
|
||||
|
||||
e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
|
||||
if (e)
|
||||
error (1, 0, "%s: %s", argv[optind], e);
|
||||
if (username == NULL)
|
||||
username = "";
|
||||
|
||||
for (++optind; optind < argc; ++optind)
|
||||
{
|
||||
strip_trailing_slashes (argv[optind]);
|
||||
errors |= change_file_owner (argv[optind], user, group);
|
||||
}
|
||||
|
||||
exit (errors);
|
||||
if (changed)
|
||||
printf (_("owner of %s changed to "), file);
|
||||
else
|
||||
printf (_("owner of %s retained as "), file);
|
||||
if (groupname)
|
||||
printf ("%s.%s\n", username, groupname);
|
||||
else
|
||||
printf ("%s\n", username);
|
||||
}
|
||||
|
||||
/* Change the ownership of FILE to UID USER and GID GROUP.
|
||||
@@ -173,10 +128,7 @@ main (argc, argv)
|
||||
Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_file_owner (file, user, group)
|
||||
char *file;
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
change_file_owner (char *file, uid_t user, gid_t group)
|
||||
{
|
||||
struct stat file_stats;
|
||||
uid_t newuser;
|
||||
@@ -194,9 +146,17 @@ change_file_owner (file, user, group)
|
||||
newgroup = group == (gid_t) -1 ? file_stats.st_gid : group;
|
||||
if (newuser != file_stats.st_uid || newgroup != file_stats.st_gid)
|
||||
{
|
||||
int fail;
|
||||
|
||||
if (verbose)
|
||||
describe_change (file, 1);
|
||||
if (chown (file, newuser, newgroup))
|
||||
|
||||
if (change_symlinks)
|
||||
fail = LCHOWN (file, newuser, newgroup);
|
||||
else
|
||||
fail = chown (file, newuser, newgroup);
|
||||
|
||||
if (fail)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
@@ -217,11 +177,7 @@ change_file_owner (file, user, group)
|
||||
Return 0 if successful, 1 if errors occurred. */
|
||||
|
||||
static int
|
||||
change_dir_owner (dir, user, group, statp)
|
||||
char *dir;
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
struct stat *statp;
|
||||
change_dir_owner (char *dir, uid_t user, gid_t group, struct stat *statp)
|
||||
{
|
||||
char *name_space, *namep;
|
||||
char *path; /* Full path of each entry to process. */
|
||||
@@ -241,7 +197,7 @@ change_dir_owner (dir, user, group, statp)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
|
||||
@@ -267,50 +223,114 @@ change_dir_owner (dir, user, group, statp)
|
||||
return errors;
|
||||
}
|
||||
|
||||
/* Tell the user the user and group names to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE had those owners already. */
|
||||
|
||||
static void
|
||||
describe_change (file, changed)
|
||||
char *file;
|
||||
int changed;
|
||||
{
|
||||
if (changed)
|
||||
printf ("owner of %s changed to ", file);
|
||||
else
|
||||
printf ("owner of %s retained as ", file);
|
||||
if (groupname)
|
||||
printf ("%s.%s\n", username, groupname);
|
||||
else
|
||||
printf ("%s\n", username);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... OWNER[.[GROUP]] FILE...\n\
|
||||
or: %s [OPTION]... .[GROUP] FILE...\n\
|
||||
",
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Change the owner and/or group of each FILE to OWNER and/or GROUP.\n\
|
||||
\n\
|
||||
-c, --changes be verbose whenever change occurs\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose explain what is being done\n\
|
||||
-R, --recursive change files and directories recursively\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
-c, --changes be verbose whenever change occurs\n\
|
||||
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
||||
(available only on systems with lchown system call)\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
-v, --verbose explain what is being done\n\
|
||||
-R, --recursive change files and directories recursively\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
Owner is unchanged if missing. Group is unchanged if missing, but changed\n\
|
||||
to login group if implied by a period. A colon may replace the period.\n");
|
||||
to login group if implied by a period. A colon may replace the period.\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
uid_t user = (uid_t) -1; /* New uid; -1 if not to be changed. */
|
||||
gid_t group = (uid_t) -1; /* New gid; -1 if not to be changed. */
|
||||
int errors = 0;
|
||||
int optc;
|
||||
char *e;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'h':
|
||||
change_symlinks = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chown - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind >= argc - 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCHOWN
|
||||
if (change_symlinks)
|
||||
{
|
||||
error (1, 0, _("--no-dereference (-h) is not supported on this system"));
|
||||
}
|
||||
#endif
|
||||
|
||||
e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
|
||||
if (e)
|
||||
error (1, 0, "%s: %s", argv[optind], e);
|
||||
if (username == NULL)
|
||||
username = "";
|
||||
|
||||
for (++optind; optind < argc; ++optind)
|
||||
{
|
||||
strip_trailing_slashes (argv[optind]);
|
||||
errors |= change_file_owner (argv[optind], user, group);
|
||||
}
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
89
src/chroot.c
Normal file
89
src/chroot.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/* chroot -- run command or shell with special root directory
|
||||
Copyright (C) 1995, 96 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 Roland McGrath. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION] NEWROOT [COMMAND...]\n
|
||||
or: %s OPTION\n\
|
||||
"), program_name, program_name);
|
||||
printf (_("\
|
||||
Run COMMAND with root directory set to NEWROOT.\n\
|
||||
\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
program_name = argv[0];
|
||||
|
||||
parse_long_options (argc, argv, "chroot", PACKAGE_VERSION, usage);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (chroot (argv[1]))
|
||||
error (1, errno, _("cannot change root directory to %s"), argv[1]);
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
/* No command. Run an interactive shell. */
|
||||
char *shell = getenv ("SHELL");
|
||||
if (shell == NULL)
|
||||
shell = "/bin/sh";
|
||||
argv[0] = shell;
|
||||
argv[1] = "-i";
|
||||
}
|
||||
else
|
||||
/* The following arguments give the command. */
|
||||
argv += 2;
|
||||
|
||||
/* Execute the given command. */
|
||||
execvp (argv[0], argv);
|
||||
error (1, errno, _("cannot execute %s"), argv[0]);
|
||||
|
||||
exit (1);
|
||||
return 1;
|
||||
}
|
||||
29
src/cksum.c
29
src/cksum.c
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX.2 checksums and sizes of files
|
||||
Copyright (C) 1992, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 95, 1996 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
|
||||
@@ -85,7 +85,7 @@ remainder (m)
|
||||
return rem & 0xFFFFFFFF; /* Make it run on 64-bit machine. */
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int i;
|
||||
@@ -99,7 +99,7 @@ main ()
|
||||
remainder (i * 5 + 4), remainder (i * 5 + 5));
|
||||
}
|
||||
printf ("\n};\n");
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#else /* !CRCTAB */
|
||||
@@ -108,7 +108,6 @@ main ()
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
@@ -117,10 +116,10 @@ main ()
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -250,7 +249,7 @@ cksum (char *file, int print_name)
|
||||
|
||||
crc = ~crc & 0xFFFFFFFF;
|
||||
|
||||
printf ("%10lu %8ld", crc, length);
|
||||
printf ("%lu %ld", crc, length);
|
||||
if (print_name)
|
||||
printf (" %s", file);
|
||||
putchar ('\n');
|
||||
@@ -277,16 +276,20 @@ Print CRC checksum and byte counts of each FILE.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i, c;
|
||||
int errors = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
have_read_stdin = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
|
||||
@@ -303,8 +306,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cksum - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("cksum - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -323,8 +326,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (1, errno, "-");
|
||||
exit (errors);
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#endif /* !CRCTAB */
|
||||
|
||||
21
src/comm.c
21
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 1986, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1990, 1991, 1995, 1996 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
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "linebuffer.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
@@ -43,10 +42,10 @@ static int only_file_2;
|
||||
/* If nonzero, print lines that are found in both files. */
|
||||
static int both;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -80,7 +79,7 @@ Compare sorted files LEFT_FILE and RIGHT_FILE line by line.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Output the line in linebuffer LINE to stream STREAM
|
||||
@@ -212,12 +211,15 @@ compare_files (char **infiles)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
only_file_1 = 1;
|
||||
only_file_2 = 1;
|
||||
@@ -247,8 +249,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("comm - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("comm - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -257,5 +259,6 @@ main (int argc, char **argv)
|
||||
if (optind + 2 != argc)
|
||||
usage (1);
|
||||
|
||||
exit (compare_files (argv + optind));
|
||||
exit (compare_files (argv + optind) == 0
|
||||
? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cp-hash.c -- file copying (hash search routines)
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
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 Torbjorn Granlund, Sweden (tege@sics.se). */
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
#include <stdio.h>
|
||||
#include "cp.h"
|
||||
|
||||
char *hash_insert ();
|
||||
char *hash_insert2 ();
|
||||
|
||||
struct htab *htab;
|
||||
char new_file;
|
||||
|
||||
@@ -31,8 +28,7 @@ char new_file;
|
||||
Return 0 if successful, 1 if not. */
|
||||
|
||||
int
|
||||
remember_created (path)
|
||||
char *path;
|
||||
remember_created (const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
@@ -51,10 +47,7 @@ remember_created (path)
|
||||
Return NULL if inserted, otherwise non-NULL. */
|
||||
|
||||
char *
|
||||
remember_copied (node, ino, dev)
|
||||
char *node;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
remember_copied (const char *node, ino_t ino, dev_t dev)
|
||||
{
|
||||
return hash_insert (ino, dev, node);
|
||||
}
|
||||
@@ -67,9 +60,7 @@ remember_copied (node, ino, dev)
|
||||
doubled.) */
|
||||
|
||||
void
|
||||
hash_init (modulus, entry_tab_size)
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
|
||||
@@ -90,7 +81,7 @@ hash_init (modulus, entry_tab_size)
|
||||
contain no entries. */
|
||||
|
||||
void
|
||||
forget_all ()
|
||||
forget_all (void)
|
||||
{
|
||||
int i;
|
||||
struct entry **p;
|
||||
@@ -108,10 +99,7 @@ forget_all ()
|
||||
Return NULL if inserted, otherwise non-NULL. */
|
||||
|
||||
char *
|
||||
hash_insert (ino, dev, node)
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char *node;
|
||||
hash_insert (ino_t ino, dev_t dev, const char *node)
|
||||
{
|
||||
struct htab *htab_r = htab;
|
||||
|
||||
@@ -178,11 +166,7 @@ hash_insert (ino, dev, node)
|
||||
Return NULL if inserted, otherwise non-NULL. */
|
||||
|
||||
char *
|
||||
hash_insert2 (htab, ino, dev, node)
|
||||
struct htab *htab;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char *node;
|
||||
hash_insert2 (struct htab *htab, ino_t ino, dev_t dev, const char *node)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &htab->hash[ino % htab->modulus];
|
||||
@@ -211,7 +195,7 @@ hash_insert2 (htab, ino, dev, node)
|
||||
ep = *hp = &htab->entry_tab[htab->first_free_entry++];
|
||||
ep->ino = ino;
|
||||
ep->dev = dev;
|
||||
ep->node = node;
|
||||
ep->node = (char *) node;
|
||||
ep->coll_link = ep2; /* ep2 is NULL if not collision. */
|
||||
|
||||
return NULL;
|
||||
|
||||
301
src/cp.c
301
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
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 Torbjorn Granlund, David MacKenzie, and Jim Meyering. */
|
||||
|
||||
@@ -23,15 +23,23 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include "cp.h"
|
||||
#include "backupfile.h"
|
||||
#include "version.h"
|
||||
#include "argmatch.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
uid_t geteuid ();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
# define chown(PATH, OWNER, GROUP) lchown(PATH, OWNER, GROUP)
|
||||
#endif
|
||||
|
||||
/* Used by do_copy, make_path_private, and re_protect
|
||||
to keep a list of leading directories whose protections
|
||||
need to be fixed after copying. */
|
||||
@@ -42,6 +50,25 @@ struct dir_attr
|
||||
struct dir_attr *next;
|
||||
};
|
||||
|
||||
/* Control creation of sparse files (files with holes). */
|
||||
enum Sparse_type
|
||||
{
|
||||
/* Never create holes in DEST. */
|
||||
SPARSE_NEVER,
|
||||
|
||||
/* This is the default. Use a crude (and sometimes inaccurate)
|
||||
heuristic to determine if SOURCE has holes. If so, try to create
|
||||
holes in DEST. */
|
||||
SPARSE_AUTO,
|
||||
|
||||
/* For every sufficiently long sequence of bytes in SOURCE, try to
|
||||
create a corresponding hole in DEST. There is a performance penalty
|
||||
here because CP has to search for holes in SRC. But if the holes are
|
||||
big enough, that penalty can be offset by the decrease in the amount
|
||||
of data written to disk. */
|
||||
SPARSE_ALWAYS
|
||||
};
|
||||
|
||||
int stat ();
|
||||
int lstat ();
|
||||
|
||||
@@ -51,12 +78,18 @@ enum backup_type get_version ();
|
||||
int euidaccess ();
|
||||
int full_write ();
|
||||
|
||||
static int do_copy ();
|
||||
static int copy ();
|
||||
static int copy_dir ();
|
||||
static int make_path_private ();
|
||||
static int copy_reg ();
|
||||
static int re_protect ();
|
||||
static int do_copy __P ((int argc, char **argv));
|
||||
static int copy __P ((const char *src_path, const char *dst_path, int new_dst,
|
||||
dev_t device, struct dir_list *ancestors));
|
||||
static int copy_dir __P ((const char *src_path_in, const char *dst_path_in,
|
||||
int new_dst, const struct stat *src_sb,
|
||||
struct dir_list *ancestors));
|
||||
static int make_path_private __P ((const char *const_dirpath, int src_offset,
|
||||
int mode, const char *verbose_fmt_string,
|
||||
struct dir_attr **attr_list, int *new_dst));
|
||||
static int copy_reg __P ((const char *src_path, const char *dst_path));
|
||||
static int re_protect __P ((const char *const_dst_path, int src_offset,
|
||||
struct dir_attr *attr_list));
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
@@ -116,6 +149,19 @@ static int flag_update = 0;
|
||||
/* If nonzero, display the names of the files before copying them. */
|
||||
static int flag_verbose = 0;
|
||||
|
||||
static char const *const sparse_type_string[] =
|
||||
{
|
||||
"never", "auto", "always", 0
|
||||
};
|
||||
|
||||
static enum Sparse_type const sparse_type[] =
|
||||
{
|
||||
SPARSE_NEVER, SPARSE_AUTO, SPARSE_ALWAYS
|
||||
};
|
||||
|
||||
/* Control creation of sparse files. */
|
||||
static int flag_sparse = SPARSE_AUTO;
|
||||
|
||||
/* The error code to return to the system. */
|
||||
static int exit_status = 0;
|
||||
|
||||
@@ -125,10 +171,10 @@ static int umask_kill;
|
||||
/* This process's effective user ID. */
|
||||
static uid_t myeuid;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_opts[] =
|
||||
@@ -136,6 +182,7 @@ static struct option const long_opts[] =
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"sparse", required_argument, NULL, 2},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"link", no_argument, NULL, 'l'},
|
||||
{"no-dereference", no_argument, &flag_dereference, 0},
|
||||
@@ -153,17 +200,19 @@ static struct option const long_opts[] =
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
myeuid = geteuid ();
|
||||
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
@@ -186,6 +235,21 @@ main (argc, argv)
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
int i;
|
||||
|
||||
/* --sparse={never,auto,always} */
|
||||
i = argmatch (optarg, sparse_type_string);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg (_("sparse type"), optarg, i);
|
||||
usage (2, NULL);
|
||||
}
|
||||
flag_sparse = sparse_type[i];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a': /* Like -dpR. */
|
||||
flag_dereference = 0;
|
||||
flag_preserve = 1;
|
||||
@@ -237,7 +301,7 @@ main (argc, argv)
|
||||
#ifdef S_ISLNK
|
||||
flag_symbolic_link = 1;
|
||||
#else
|
||||
error (1, 0, "symbolic links are not supported on this system");
|
||||
error (1, 0, _("symbolic links are not supported on this system"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -268,7 +332,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cp - %s\n", version_string);
|
||||
printf ("cp - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -276,7 +340,7 @@ main (argc, argv)
|
||||
usage (0, NULL);
|
||||
|
||||
if (flag_hard_link && flag_symbolic_link)
|
||||
usage (2, "cannot make both hard and symbolic links");
|
||||
usage (2, _("cannot make both hard and symbolic links"));
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
@@ -300,14 +364,34 @@ main (argc, argv)
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
|
||||
/* Concatenate two pathname components, DIR and BASE, in newly-allocated
|
||||
storage and return the result. Be careful that in the result they are
|
||||
separated by a slash. That is, if DIR ends with a slash or if BASE
|
||||
begins with one, don't add a separating slash. Otherwise, add one. */
|
||||
|
||||
static char *
|
||||
path_concat (const char *dir, const char *base)
|
||||
{
|
||||
char *dir_end;
|
||||
char *p_concat;
|
||||
|
||||
assert (strlen (dir) > 0);
|
||||
p_concat = xmalloc (strlen (dir) + strlen (base) + 2);
|
||||
dir_end = stpcpy (p_concat, dir);
|
||||
if (*(dir_end - 1) == '/')
|
||||
--dir_end;
|
||||
else if (*base == '/')
|
||||
++base;
|
||||
stpcpy (stpcpy (dir_end, "/"), base);
|
||||
return p_concat;
|
||||
}
|
||||
|
||||
/* Scan the arguments, and copy each by calling copy.
|
||||
Return 0 if successful, 1 if any errors occur. */
|
||||
|
||||
static int
|
||||
do_copy (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
do_copy (int argc, char **argv)
|
||||
{
|
||||
char *dest;
|
||||
struct stat sb;
|
||||
@@ -315,9 +399,9 @@ do_copy (argc, argv)
|
||||
int ret = 0;
|
||||
|
||||
if (optind >= argc)
|
||||
usage (2, "missing file arguments");
|
||||
usage (2, _("missing file arguments"));
|
||||
if (optind >= argc - 1)
|
||||
usage (2, "missing file argument");
|
||||
usage (2, _("missing destination file"));
|
||||
|
||||
dest = argv[argc - 1];
|
||||
|
||||
@@ -363,17 +447,16 @@ do_copy (argc, argv)
|
||||
if (flag_path)
|
||||
{
|
||||
/* Append all of `arg' to `dest'. */
|
||||
dst_path = xmalloc (strlen (dest) + strlen (arg) + 2);
|
||||
stpcpy (stpcpy (stpcpy (dst_path, dest), "/"), arg);
|
||||
dst_path = path_concat (dest, arg);
|
||||
|
||||
/* For --parents, we have to make sure that the directory
|
||||
dirname (dst_path) exists. We may have to create a few
|
||||
leading directories. */
|
||||
parent_exists = !make_path_private (dst_path,
|
||||
strlen (dest) + 1, 0700,
|
||||
flag_verbose ? "%s -> %s\n" :
|
||||
(char *) NULL,
|
||||
&attr_list, &new_dst);
|
||||
strlen (dest) + 1, 0700,
|
||||
(flag_verbose
|
||||
? "%s -> %s\n" : NULL),
|
||||
&attr_list, &new_dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -381,18 +464,14 @@ do_copy (argc, argv)
|
||||
|
||||
ap = basename (arg);
|
||||
/* For `cp -R source/.. dest', don't copy into `dest/..'. */
|
||||
if (!strcmp (ap, ".."))
|
||||
dst_path = xstrdup (dest);
|
||||
else
|
||||
{
|
||||
dst_path = xmalloc (strlen (dest) + strlen (ap) + 2);
|
||||
stpcpy (stpcpy (stpcpy (dst_path, dest), "/"), ap);
|
||||
}
|
||||
dst_path = (STREQ (ap, "..")
|
||||
? xstrdup (dest)
|
||||
: path_concat (dest, ap));
|
||||
}
|
||||
|
||||
if (!parent_exists)
|
||||
{
|
||||
/* make_path_private failed, so we shouldn't even attempt the copy. */
|
||||
/* make_path_private failed, so don't even attempt the copy. */
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
@@ -402,8 +481,7 @@ do_copy (argc, argv)
|
||||
|
||||
if (flag_path)
|
||||
{
|
||||
ret |= re_protect (dst_path, strlen (dest) + 1,
|
||||
attr_list);
|
||||
ret |= re_protect (dst_path, strlen (dest) + 1, attr_list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,15 +499,33 @@ do_copy (argc, argv)
|
||||
struct stat source_stats;
|
||||
|
||||
if (flag_path)
|
||||
usage (2, "when preserving paths, last argument must be a directory");
|
||||
usage (2,
|
||||
_("when preserving paths, last argument must be a directory"));
|
||||
|
||||
source = argv[optind];
|
||||
|
||||
/* When the force and backup options have been specified and
|
||||
the source and destination are the same name for an existing
|
||||
regular file, convert the user's command, e.g.,
|
||||
`cp --force --backup foo foo' to `cp --force foo fooSUFFIX'
|
||||
where SUFFIX is determined by any version control options used. */
|
||||
|
||||
if (flag_force
|
||||
&& backup_type != none
|
||||
&& STREQ (source, dest)
|
||||
&& !new_dst && S_ISREG (sb.st_mode))
|
||||
{
|
||||
backup_type = none;
|
||||
new_dest = find_backup_file_name (dest);
|
||||
if (new_dest == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
/* When the destination is specified with a trailing slash and the
|
||||
source exists but is not a directory, convert the user's command
|
||||
`cp source dest/' to `cp source dest/basename(source)'. */
|
||||
|
||||
if (dest[strlen (dest) - 1] == '/'
|
||||
else if (dest[strlen (dest) - 1] == '/'
|
||||
&& lstat (source, &source_stats) == 0
|
||||
&& !S_ISDIR (source_stats.st_mode))
|
||||
{
|
||||
@@ -454,11 +550,11 @@ do_copy (argc, argv)
|
||||
}
|
||||
else
|
||||
usage (2,
|
||||
"when copying multiple files, last argument must be a directory");
|
||||
_("when copying multiple files, last argument must be a directory"));
|
||||
}
|
||||
|
||||
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
|
||||
any type. NEW_DST should be non-zero if the file DST_PATH cannot
|
||||
any type. NEW_DST should be nonzero if the file DST_PATH cannot
|
||||
exist because its parent directory was just created; NEW_DST should
|
||||
be zero if DST_PATH might already exist. DEVICE is the device
|
||||
number of the parent directory, or 0 if the parent of this file is
|
||||
@@ -467,12 +563,8 @@ do_copy (argc, argv)
|
||||
Return 0 if successful, 1 if an error occurs. */
|
||||
|
||||
static int
|
||||
copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
char *src_path;
|
||||
char *dst_path;
|
||||
int new_dst;
|
||||
dev_t device;
|
||||
struct dir_list *ancestors;
|
||||
copy (const char *src_path, const char *dst_path, int new_dst, dev_t device,
|
||||
struct dir_list *ancestors)
|
||||
{
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
@@ -508,7 +600,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
|
||||
if (S_ISDIR (src_type) && !flag_recursive)
|
||||
{
|
||||
error (0, 0, "%s: omitting directory", src_path);
|
||||
error (0, 0, _("%s: omitting directory"), src_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -533,7 +625,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
if (flag_hard_link)
|
||||
return 0;
|
||||
|
||||
error (0, 0, "`%s' and `%s' are the same file",
|
||||
error (0, 0, _("`%s' and `%s' are the same file"),
|
||||
src_path, dst_path);
|
||||
return 1;
|
||||
}
|
||||
@@ -543,7 +635,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
if (S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
error (0, 0,
|
||||
"%s: cannot overwrite directory with non-directory",
|
||||
_("%s: cannot overwrite directory with non-directory"),
|
||||
dst_path);
|
||||
return 1;
|
||||
}
|
||||
@@ -558,11 +650,11 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (euidaccess (dst_path, W_OK) != 0)
|
||||
fprintf (stderr,
|
||||
"%s: overwrite `%s', overriding mode %04o? ",
|
||||
_("%s: overwrite `%s', overriding mode %04o? "),
|
||||
program_name, dst_path,
|
||||
(unsigned int) (dst_sb.st_mode & 07777));
|
||||
else
|
||||
fprintf (stderr, "%s: overwrite `%s'? ",
|
||||
fprintf (stderr, _("%s: overwrite `%s'? "),
|
||||
program_name, dst_path);
|
||||
if (!yesno ())
|
||||
return 0;
|
||||
@@ -573,7 +665,20 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dst_path);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
/* Detect (and fail) when creating the backup file would
|
||||
destroy the source file. Before, running the commands
|
||||
cd /tmp; rm -f a a~; : > a; echo A > a~; cp -b -V simple a~ a
|
||||
would leave two zero-length files: a and a~. */
|
||||
if (STREQ (tmp_backup, src_path))
|
||||
{
|
||||
error (0, 0,
|
||||
_("backing up `%s' would destroy source; `%s' not copied"),
|
||||
dst_path, src_path);
|
||||
return 1;
|
||||
|
||||
}
|
||||
dst_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
strcpy (dst_backup, tmp_backup);
|
||||
free (tmp_backup);
|
||||
@@ -581,7 +686,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "cannot backup `%s'", dst_path);
|
||||
error (0, errno, _("cannot backup `%s'"), dst_path);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -609,7 +714,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (unlink (dst_path) && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "cannot remove old link to `%s'",
|
||||
error (0, errno, _("cannot remove old link to `%s'"),
|
||||
dst_path);
|
||||
return 1;
|
||||
}
|
||||
@@ -649,7 +754,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
|
||||
if (is_ancestor (&src_sb, ancestors))
|
||||
{
|
||||
error (0, 0, "%s: cannot copy cyclic symbolic link", src_path);
|
||||
error (0, 0, _("%s: cannot copy cyclic symbolic link"), src_path);
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
@@ -667,7 +772,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
|
||||
if (mkdir (dst_path, (src_mode & umask_kill) | 0700))
|
||||
{
|
||||
error (0, errno, "cannot create directory `%s'", dst_path);
|
||||
error (0, errno, _("cannot create directory `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
@@ -704,7 +809,8 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
else
|
||||
{
|
||||
error (0, 0,
|
||||
"%s: can only make relative symbolic links in current directory", dst_path);
|
||||
_("%s: can make relative symbolic links only in current directory"),
|
||||
dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
@@ -713,7 +819,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (link (src_path, dst_path))
|
||||
{
|
||||
error (0, errno, "cannot create link `%s'", dst_path);
|
||||
error (0, errno, _("cannot create link `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
return 0;
|
||||
@@ -734,7 +840,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (mkfifo (dst_path, src_mode & umask_kill))
|
||||
{
|
||||
error (0, errno, "cannot create fifo `%s'", dst_path);
|
||||
error (0, errno, _("cannot create fifo `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
@@ -748,7 +854,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
{
|
||||
if (mknod (dst_path, src_mode & umask_kill, src_sb.st_rdev))
|
||||
{
|
||||
error (0, errno, "cannot create special file `%s'", dst_path);
|
||||
error (0, errno, _("cannot create special file `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
@@ -763,14 +869,14 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
link_size = readlink (src_path, link_val, PATH_MAX + 1);
|
||||
if (link_size < 0)
|
||||
{
|
||||
error (0, errno, "cannot read symbolic link `%s'", src_path);
|
||||
error (0, errno, _("cannot read symbolic link `%s'"), src_path);
|
||||
goto un_backup;
|
||||
}
|
||||
link_val[link_size] = '\0';
|
||||
|
||||
if (symlink (link_val, dst_path))
|
||||
{
|
||||
error (0, errno, "cannot create symbolic link `%s'", dst_path);
|
||||
error (0, errno, _("cannot create symbolic link `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
return 0;
|
||||
@@ -778,7 +884,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
error (0, 0, "%s: unknown file type", src_path);
|
||||
error (0, 0, _("%s: unknown file type"), src_path);
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
@@ -836,7 +942,7 @@ un_backup:
|
||||
if (dst_backup)
|
||||
{
|
||||
if (rename (dst_backup, dst_path))
|
||||
error (0, errno, "cannot un-backup `%s'", dst_path);
|
||||
error (0, errno, _("cannot un-backup `%s'"), dst_path);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -860,14 +966,9 @@ un_backup:
|
||||
permissions when done, otherwise 1. */
|
||||
|
||||
static int
|
||||
make_path_private (const_dirpath, src_offset, mode, verbose_fmt_string,
|
||||
attr_list, new_dst)
|
||||
char *const_dirpath;
|
||||
int src_offset;
|
||||
int mode;
|
||||
char *verbose_fmt_string;
|
||||
struct dir_attr **attr_list;
|
||||
int *new_dst;
|
||||
make_path_private (const char *const_dirpath, int src_offset, int mode,
|
||||
const char *verbose_fmt_string, struct dir_attr **attr_list,
|
||||
int *new_dst)
|
||||
{
|
||||
struct stat stats;
|
||||
char *dirpath; /* A copy of CONST_DIRPATH we can change. */
|
||||
@@ -918,7 +1019,7 @@ make_path_private (const_dirpath, src_offset, mode, verbose_fmt_string,
|
||||
new->is_new_dir = 1;
|
||||
if (mkdir (dirpath, mode))
|
||||
{
|
||||
error (0, errno, "cannot make directory `%s'", dirpath);
|
||||
error (0, errno, _("cannot make directory `%s'"), dirpath);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -929,7 +1030,7 @@ make_path_private (const_dirpath, src_offset, mode, verbose_fmt_string,
|
||||
}
|
||||
else if (!S_ISDIR (stats.st_mode))
|
||||
{
|
||||
error (0, 0, "`%s' exists but is not a directory", dirpath);
|
||||
error (0, 0, _("`%s' exists but is not a directory"), dirpath);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -950,7 +1051,7 @@ make_path_private (const_dirpath, src_offset, mode, verbose_fmt_string,
|
||||
|
||||
else if (!S_ISDIR (stats.st_mode))
|
||||
{
|
||||
error (0, 0, "`%s' exists but is not a directory", dst_dirname);
|
||||
error (0, 0, _("`%s' exists but is not a directory"), dst_dirname);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -981,10 +1082,8 @@ make_path_private (const_dirpath, src_offset, mode, verbose_fmt_string,
|
||||
when done, otherwise 1. */
|
||||
|
||||
static int
|
||||
re_protect (const_dst_path, src_offset, attr_list)
|
||||
char *const_dst_path;
|
||||
int src_offset;
|
||||
struct dir_attr *attr_list;
|
||||
re_protect (const char *const_dst_path, int src_offset,
|
||||
struct dir_attr *attr_list)
|
||||
{
|
||||
struct dir_attr *p;
|
||||
char *dst_path; /* A copy of CONST_DST_PATH we can change. */
|
||||
@@ -1048,18 +1147,14 @@ re_protect (const_dst_path, src_offset, attr_list)
|
||||
}
|
||||
|
||||
/* Read the contents of the directory SRC_PATH_IN, and recursively
|
||||
copy the contents to DST_PATH_IN. NEW_DST is non-zero if
|
||||
copy the contents to DST_PATH_IN. NEW_DST is nonzero if
|
||||
DST_PATH_IN is a directory that was created previously in the
|
||||
recursion. SRC_SB and ANCESTORS describe SRC_PATH_IN.
|
||||
Return 0 if successful, -1 if an error occurs. */
|
||||
|
||||
static int
|
||||
copy_dir (src_path_in, dst_path_in, new_dst, src_sb, ancestors)
|
||||
char *src_path_in;
|
||||
char *dst_path_in;
|
||||
int new_dst;
|
||||
struct stat *src_sb;
|
||||
struct dir_list *ancestors;
|
||||
copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
const struct stat *src_sb, struct dir_list *ancestors)
|
||||
{
|
||||
char *name_space;
|
||||
char *namep;
|
||||
@@ -1077,7 +1172,7 @@ copy_dir (src_path_in, dst_path_in, new_dst, src_sb, ancestors)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
namep = name_space;
|
||||
@@ -1112,9 +1207,7 @@ copy_dir (src_path_in, dst_path_in, new_dst, src_sb, ancestors)
|
||||
Return 0 if successful, -1 if an error occurred. */
|
||||
|
||||
static int
|
||||
copy_reg (src_path, dst_path)
|
||||
char *src_path;
|
||||
char *dst_path;
|
||||
copy_reg (const char *src_path, const char *dst_path)
|
||||
{
|
||||
char *buf;
|
||||
int buf_size;
|
||||
@@ -1127,7 +1220,7 @@ copy_reg (src_path, dst_path)
|
||||
int return_val = 0;
|
||||
long n_read_total = 0;
|
||||
int last_write_made_hole = 0;
|
||||
int make_holes = 0;
|
||||
int make_holes = (flag_sparse == SPARSE_ALWAYS);
|
||||
|
||||
source_desc = open (src_path, O_RDONLY);
|
||||
if (source_desc < 0)
|
||||
@@ -1142,7 +1235,7 @@ copy_reg (src_path, dst_path)
|
||||
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
if (dest_desc < 0)
|
||||
{
|
||||
error (0, errno, "cannot create regular file `%s'", dst_path);
|
||||
error (0, errno, _("cannot create regular file `%s'"), dst_path);
|
||||
return_val = -1;
|
||||
goto ret2;
|
||||
}
|
||||
@@ -1159,9 +1252,10 @@ copy_reg (src_path, dst_path)
|
||||
buf_size = ST_BLKSIZE (sb);
|
||||
|
||||
#ifdef HAVE_ST_BLOCKS
|
||||
if (S_ISREG (sb.st_mode))
|
||||
if (flag_sparse == SPARSE_AUTO && S_ISREG (sb.st_mode))
|
||||
{
|
||||
/* Find out whether the file contains any sparse blocks. */
|
||||
/* Use a heuristic to determine whether SRC_PATH contains any
|
||||
sparse blocks. */
|
||||
|
||||
if (fstat (source_desc, &sb))
|
||||
{
|
||||
@@ -1173,7 +1267,8 @@ copy_reg (src_path, dst_path)
|
||||
/* If the file has fewer blocks than would normally
|
||||
be needed for a file of its size, then
|
||||
at least one of the blocks in the file is a hole. */
|
||||
if (S_ISREG (sb.st_mode) && sb.st_size > sb.st_blocks * DEV_BSIZE)
|
||||
if (S_ISREG (sb.st_mode)
|
||||
&& (size_t) (sb.st_size / 512) > (size_t) ST_NBLOCKS (sb))
|
||||
make_holes = 1;
|
||||
}
|
||||
#endif
|
||||
@@ -1205,13 +1300,13 @@ copy_reg (src_path, dst_path)
|
||||
{
|
||||
buf[n_read] = 1; /* Sentinel to stop loop. */
|
||||
|
||||
/* Find first non-zero *word*, or the word with the sentinel. */
|
||||
/* Find first nonzero *word*, or the word with the sentinel. */
|
||||
|
||||
ip = (int *) buf;
|
||||
while (*ip++ == 0)
|
||||
;
|
||||
|
||||
/* Find the first non-zero *byte*, or the sentinel. */
|
||||
/* Find the first nonzero *byte*, or the sentinel. */
|
||||
|
||||
cp = (char *) (ip - 1);
|
||||
while (*cp++ == 0)
|
||||
|
||||
418
src/csplit.c
418
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 95, 1996 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
|
||||
@@ -21,16 +21,34 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Disable assertions. Some systems have broken assert macros. */
|
||||
#define NDEBUG 1
|
||||
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif /* HAVE_LIMITS_H */
|
||||
#include "regex.h"
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
@@ -43,16 +61,6 @@ char *realloc ();
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
int safe_read ();
|
||||
|
||||
static char *xrealloc ();
|
||||
static char *xmalloc ();
|
||||
static void cleanup ();
|
||||
static void close_output_file ();
|
||||
static void create_output_file ();
|
||||
static void save_line_to_file ();
|
||||
static void usage ();
|
||||
|
||||
#ifndef TRUE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
@@ -129,6 +137,14 @@ struct buffer_record
|
||||
struct buffer_record *next;
|
||||
};
|
||||
|
||||
int safe_read ();
|
||||
|
||||
static void close_output_file __P ((void));
|
||||
static void create_output_file __P ((void));
|
||||
static void delete_all_files __P ((void));
|
||||
static void save_line_to_file __P ((const struct cstring *line));
|
||||
static void usage __P ((int status));
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
@@ -206,10 +222,10 @@ static struct control *controls;
|
||||
/* Number of elements in `controls'. */
|
||||
static unsigned int control_used;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -226,11 +242,47 @@ static struct option const longopts[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Optionally remove files created so far; then exit.
|
||||
Called when an error detected. */
|
||||
|
||||
static void
|
||||
cleanup (void)
|
||||
{
|
||||
if (output_stream)
|
||||
close_output_file ();
|
||||
|
||||
if (remove_files)
|
||||
delete_all_files ();
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_fatal (void)
|
||||
{
|
||||
cleanup ();
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
interrupt_handler (int sig)
|
||||
{
|
||||
#ifdef SA_INTERRUPT
|
||||
struct sigaction sigact;
|
||||
|
||||
sigact.sa_handler = SIG_DFL;
|
||||
sigemptyset (&sigact.sa_mask);
|
||||
sigact.sa_flags = 0;
|
||||
sigaction (sig, &sigact, NULL);
|
||||
#else /* !SA_INTERRUPT */
|
||||
signal (sig, SIG_DFL);
|
||||
#endif /* SA_INTERRUPT */
|
||||
cleanup ();
|
||||
kill (getpid (), sig);
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
static char *
|
||||
xmalloc (n)
|
||||
unsigned int n;
|
||||
xmalloc (unsigned int n)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -238,7 +290,7 @@ xmalloc (n)
|
||||
if (p == NULL)
|
||||
{
|
||||
error (0, 0, _("virtual memory exhausted"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -249,9 +301,7 @@ xmalloc (n)
|
||||
If N is 0, run free and return NULL. */
|
||||
|
||||
static char *
|
||||
xrealloc (p, n)
|
||||
char *p;
|
||||
unsigned int n;
|
||||
xrealloc (char *p, unsigned int n)
|
||||
{
|
||||
if (p == NULL)
|
||||
return xmalloc (n);
|
||||
@@ -264,7 +314,7 @@ xrealloc (p, n)
|
||||
if (p == NULL)
|
||||
{
|
||||
error (0, 0, _("virtual memory exhausted"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -278,9 +328,7 @@ xrealloc (p, n)
|
||||
start of the new buffer. */
|
||||
|
||||
static void
|
||||
save_to_hold_area (start, num)
|
||||
char *start;
|
||||
unsigned int num;
|
||||
save_to_hold_area (char *start, unsigned int num)
|
||||
{
|
||||
hold_area = start;
|
||||
hold_count = num;
|
||||
@@ -290,9 +338,7 @@ save_to_hold_area (start, num)
|
||||
Return the number of chars read. */
|
||||
|
||||
static int
|
||||
read_input (dest, max_n_bytes)
|
||||
char *dest;
|
||||
unsigned int max_n_bytes;
|
||||
read_input (char *dest, unsigned int max_n_bytes)
|
||||
{
|
||||
int bytes_read;
|
||||
|
||||
@@ -307,7 +353,7 @@ read_input (dest, max_n_bytes)
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
error (0, errno, _("read error"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
return bytes_read;
|
||||
@@ -316,8 +362,7 @@ read_input (dest, max_n_bytes)
|
||||
/* Initialize existing line record P. */
|
||||
|
||||
static void
|
||||
clear_line_control (p)
|
||||
struct line *p;
|
||||
clear_line_control (struct line *p)
|
||||
{
|
||||
p->used = 0;
|
||||
p->insert_index = 0;
|
||||
@@ -327,8 +372,7 @@ clear_line_control (p)
|
||||
/* Initialize all line records in B. */
|
||||
|
||||
static void
|
||||
clear_all_line_control (b)
|
||||
struct buffer_record *b;
|
||||
clear_all_line_control (struct buffer_record *b)
|
||||
{
|
||||
struct line *l;
|
||||
|
||||
@@ -339,7 +383,7 @@ clear_all_line_control (b)
|
||||
/* Return a new, initialized line record. */
|
||||
|
||||
static struct line *
|
||||
new_line_control ()
|
||||
new_line_control (void)
|
||||
{
|
||||
struct line *p;
|
||||
|
||||
@@ -355,10 +399,7 @@ new_line_control ()
|
||||
of length LINE_LEN in the large buffer, in the lines buffer of B. */
|
||||
|
||||
static void
|
||||
keep_new_line (b, line_start, line_len)
|
||||
struct buffer_record *b;
|
||||
char *line_start;
|
||||
int line_len;
|
||||
keep_new_line (struct buffer_record *b, char *line_start, int line_len)
|
||||
{
|
||||
struct line *l;
|
||||
|
||||
@@ -391,8 +432,7 @@ keep_new_line (b, line_start, line_len)
|
||||
the next buffer is filled. */
|
||||
|
||||
static unsigned int
|
||||
record_line_starts (b)
|
||||
struct buffer_record *b;
|
||||
record_line_starts (struct buffer_record *b)
|
||||
{
|
||||
char *line_start; /* Start of current line. */
|
||||
char *line_end; /* End of each line found. */
|
||||
@@ -442,8 +482,7 @@ record_line_starts (b)
|
||||
an extra byte for safety. */
|
||||
|
||||
static struct buffer_record *
|
||||
create_new_buffer (size)
|
||||
unsigned int size;
|
||||
create_new_buffer (unsigned int size)
|
||||
{
|
||||
struct buffer_record *new_buffer;
|
||||
|
||||
@@ -462,8 +501,7 @@ create_new_buffer (size)
|
||||
least that size is currently free, use it, otherwise create a new one. */
|
||||
|
||||
static struct buffer_record *
|
||||
get_new_buffer (min_size)
|
||||
unsigned int min_size;
|
||||
get_new_buffer (unsigned int min_size)
|
||||
{
|
||||
struct buffer_record *p, *q;
|
||||
struct buffer_record *new_buffer; /* Buffer to return. */
|
||||
@@ -513,8 +551,7 @@ get_new_buffer (min_size)
|
||||
/* Add buffer BUF to the list of free buffers. */
|
||||
|
||||
static void
|
||||
free_buffer (buf)
|
||||
struct buffer_record *buf;
|
||||
free_buffer (struct buffer_record *buf)
|
||||
{
|
||||
buf->next = free_list;
|
||||
free_list = buf;
|
||||
@@ -524,8 +561,7 @@ free_buffer (buf)
|
||||
some data yet to be processed. */
|
||||
|
||||
static void
|
||||
save_buffer (buf)
|
||||
struct buffer_record *buf;
|
||||
save_buffer (struct buffer_record *buf)
|
||||
{
|
||||
struct buffer_record *p;
|
||||
|
||||
@@ -556,7 +592,7 @@ save_buffer (buf)
|
||||
(in which case end-of-file must have been encountered). */
|
||||
|
||||
static boolean
|
||||
load_buffer ()
|
||||
load_buffer (void)
|
||||
{
|
||||
struct buffer_record *b;
|
||||
unsigned int bytes_wanted = START_SIZE; /* Minimum buffer size. */
|
||||
@@ -607,10 +643,10 @@ load_buffer ()
|
||||
/* Return the line number of the first line that has not yet been retrieved. */
|
||||
|
||||
static unsigned int
|
||||
get_first_line_in_buffer ()
|
||||
get_first_line_in_buffer (void)
|
||||
{
|
||||
if (head == NULL && !load_buffer ())
|
||||
error (1, errno, _("input disappeared"));
|
||||
error (EXIT_FAILURE, errno, _("input disappeared"));
|
||||
|
||||
return head->first_available;
|
||||
}
|
||||
@@ -620,7 +656,7 @@ get_first_line_in_buffer ()
|
||||
Return NULL if there is no more input. */
|
||||
|
||||
static struct cstring *
|
||||
remove_line ()
|
||||
remove_line (void)
|
||||
{
|
||||
struct cstring *line; /* Return value. */
|
||||
struct line *l; /* For convenience. */
|
||||
@@ -658,8 +694,7 @@ remove_line ()
|
||||
Return a pointer to the line, or NULL if it is not found in the file. */
|
||||
|
||||
static struct cstring *
|
||||
find_line (linenum)
|
||||
unsigned int linenum;
|
||||
find_line (unsigned int linenum)
|
||||
{
|
||||
struct buffer_record *b;
|
||||
|
||||
@@ -696,7 +731,7 @@ find_line (linenum)
|
||||
/* Return TRUE if at least one more line is available for input. */
|
||||
|
||||
static boolean
|
||||
no_more_lines ()
|
||||
no_more_lines (void)
|
||||
{
|
||||
return (find_line (current_line + 1) == NULL) ? TRUE : FALSE;
|
||||
}
|
||||
@@ -704,8 +739,7 @@ no_more_lines ()
|
||||
/* Set the name of the input file to NAME and open it. */
|
||||
|
||||
static void
|
||||
set_input_file (name)
|
||||
char *name;
|
||||
set_input_file (const char *name)
|
||||
{
|
||||
if (!strcmp (name, "-"))
|
||||
input_desc = 0;
|
||||
@@ -713,7 +747,7 @@ set_input_file (name)
|
||||
{
|
||||
input_desc = open (name, O_RDONLY);
|
||||
if (input_desc < 0)
|
||||
error (1, errno, "%s", name);
|
||||
error (EXIT_FAILURE, errno, "%s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,10 +757,7 @@ set_input_file (name)
|
||||
ARGNUM is the index in ARGV of the current pattern. */
|
||||
|
||||
static void
|
||||
write_to_file (last_line, ignore, argnum)
|
||||
unsigned int last_line;
|
||||
boolean ignore;
|
||||
int argnum;
|
||||
write_to_file (unsigned int last_line, boolean ignore, int argnum)
|
||||
{
|
||||
struct cstring *line;
|
||||
unsigned int first_line; /* First available input line. */
|
||||
@@ -738,7 +769,7 @@ write_to_file (last_line, ignore, argnum)
|
||||
if (first_line > last_line)
|
||||
{
|
||||
error (0, 0, _("%s: line number out of range"), global_argv[argnum]);
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
lines = last_line - first_line;
|
||||
@@ -749,7 +780,7 @@ write_to_file (last_line, ignore, argnum)
|
||||
if (line == NULL)
|
||||
{
|
||||
error (0, 0, _("%s: line number out of range"), global_argv[argnum]);
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (!ignore)
|
||||
save_line_to_file (line);
|
||||
@@ -759,7 +790,7 @@ write_to_file (last_line, ignore, argnum)
|
||||
/* Output any lines left after all regexps have been processed. */
|
||||
|
||||
static void
|
||||
dump_rest_of_file ()
|
||||
dump_rest_of_file (void)
|
||||
{
|
||||
struct cstring *line;
|
||||
|
||||
@@ -771,9 +802,7 @@ dump_rest_of_file ()
|
||||
on iteration REPETITION if nonzero. */
|
||||
|
||||
static void
|
||||
handle_line_error (p, repetition)
|
||||
struct control *p;
|
||||
int repetition;
|
||||
handle_line_error (const struct control *p, int repetition)
|
||||
{
|
||||
fprintf (stderr, _("%s: `%d': line number out of range"),
|
||||
program_name, p->lines_required);
|
||||
@@ -782,7 +811,7 @@ handle_line_error (p, repetition)
|
||||
else
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
/* Determine the line number that marks the end of this file,
|
||||
@@ -791,9 +820,7 @@ handle_line_error (p, repetition)
|
||||
REPETITION is the repetition number. */
|
||||
|
||||
static void
|
||||
process_line_count (p, repetition)
|
||||
struct control *p;
|
||||
int repetition;
|
||||
process_line_count (const struct control *p, int repetition)
|
||||
{
|
||||
unsigned int linenum;
|
||||
unsigned int last_line_to_save = p->lines_required * (repetition + 1);
|
||||
@@ -803,10 +830,11 @@ process_line_count (p, repetition)
|
||||
|
||||
linenum = get_first_line_in_buffer ();
|
||||
|
||||
/* Check for requesting a line that has already been written out.
|
||||
If this ever happens, it's due to a bug in csplit. */
|
||||
if (linenum >= last_line_to_save)
|
||||
abort ();
|
||||
/* Initially, I wanted to assert linenum < last_line_to_save, but that
|
||||
condition is false for the valid command: echo | csplit - 1 '{*}'.
|
||||
So, relax it just a little. */
|
||||
assert ((linenum == 1 && last_line_to_save == 1)
|
||||
|| linenum < last_line_to_save);
|
||||
|
||||
while (linenum++ < last_line_to_save)
|
||||
{
|
||||
@@ -825,10 +853,7 @@ process_line_count (p, repetition)
|
||||
}
|
||||
|
||||
static void
|
||||
regexp_error (p, repetition, ignore)
|
||||
struct control *p;
|
||||
int repetition;
|
||||
boolean ignore;
|
||||
regexp_error (struct control *p, int repetition, boolean ignore)
|
||||
{
|
||||
fprintf (stderr, _("%s: `%s': match not found"),
|
||||
program_name, global_argv[p->argnum]);
|
||||
@@ -843,7 +868,7 @@ regexp_error (p, repetition, ignore)
|
||||
dump_rest_of_file ();
|
||||
close_output_file ();
|
||||
}
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
/* Read the input until a line matches the regexp in P, outputting
|
||||
@@ -851,9 +876,7 @@ regexp_error (p, repetition, ignore)
|
||||
REPETITION is this repeat-count; 0 means the first time. */
|
||||
|
||||
static void
|
||||
process_regexp (p, repetition)
|
||||
struct control *p;
|
||||
int repetition;
|
||||
process_regexp (struct control *p, int repetition)
|
||||
{
|
||||
struct cstring *line; /* From input file. */
|
||||
unsigned int line_len; /* To make "$" in regexps work. */
|
||||
@@ -881,7 +904,7 @@ process_regexp (p, repetition)
|
||||
dump_rest_of_file ();
|
||||
close_output_file ();
|
||||
}
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
regexp_error (p, repetition, ignore);
|
||||
@@ -894,7 +917,7 @@ process_regexp (p, repetition)
|
||||
if (ret == -2)
|
||||
{
|
||||
error (0, 0, _("error in regular expression search"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (ret == -1)
|
||||
{
|
||||
@@ -921,7 +944,7 @@ process_regexp (p, repetition)
|
||||
dump_rest_of_file ();
|
||||
close_output_file ();
|
||||
}
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
regexp_error (p, repetition, ignore);
|
||||
@@ -934,7 +957,7 @@ process_regexp (p, repetition)
|
||||
if (ret == -2)
|
||||
{
|
||||
error (0, 0, _("error in regular expression search"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (ret >= 0)
|
||||
break;
|
||||
@@ -955,7 +978,7 @@ process_regexp (p, repetition)
|
||||
/* Split the input file according to the control records we have built. */
|
||||
|
||||
static void
|
||||
split_file ()
|
||||
split_file (void)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
@@ -983,8 +1006,7 @@ split_file ()
|
||||
/* Return the name of output file number NUM. */
|
||||
|
||||
static char *
|
||||
make_filename (num)
|
||||
unsigned int num;
|
||||
make_filename (unsigned int num)
|
||||
{
|
||||
strcpy (filename_space, prefix);
|
||||
if (suffix)
|
||||
@@ -997,14 +1019,14 @@ make_filename (num)
|
||||
/* Create the next output file. */
|
||||
|
||||
static void
|
||||
create_output_file ()
|
||||
create_output_file (void)
|
||||
{
|
||||
output_filename = make_filename (files_created);
|
||||
output_stream = fopen (output_filename, "w");
|
||||
if (output_stream == NULL)
|
||||
{
|
||||
error (0, errno, "%s", output_filename);
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
files_created++;
|
||||
bytes_written = 0;
|
||||
@@ -1013,7 +1035,7 @@ create_output_file ()
|
||||
/* Delete all the files we have created. */
|
||||
|
||||
static void
|
||||
delete_all_files ()
|
||||
delete_all_files (void)
|
||||
{
|
||||
unsigned int i;
|
||||
char *name;
|
||||
@@ -1030,14 +1052,15 @@ delete_all_files ()
|
||||
of characters in this file. */
|
||||
|
||||
static void
|
||||
close_output_file ()
|
||||
close_output_file (void)
|
||||
{
|
||||
if (output_stream)
|
||||
{
|
||||
if (fclose (output_stream) == EOF)
|
||||
{
|
||||
error (0, errno, _("write error for `%s'"), output_filename);
|
||||
cleanup ();
|
||||
output_stream = NULL;
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (bytes_written == 0 && elide_empty_files)
|
||||
{
|
||||
@@ -1052,27 +1075,11 @@ close_output_file ()
|
||||
}
|
||||
}
|
||||
|
||||
/* Optionally remove files created so far; then exit.
|
||||
Called when an error detected. */
|
||||
|
||||
static void
|
||||
cleanup ()
|
||||
{
|
||||
if (output_stream)
|
||||
close_output_file ();
|
||||
|
||||
if (remove_files)
|
||||
delete_all_files ();
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Save line LINE to the output file and
|
||||
increment the character count for the current file. */
|
||||
|
||||
static void
|
||||
save_line_to_file (line)
|
||||
struct cstring *line;
|
||||
save_line_to_file (const struct cstring *line)
|
||||
{
|
||||
fwrite (line->str, sizeof (char), line->len, output_stream);
|
||||
bytes_written += line->len;
|
||||
@@ -1081,7 +1088,7 @@ save_line_to_file (line)
|
||||
/* Return a new, initialized control record. */
|
||||
|
||||
static struct control *
|
||||
new_control_record ()
|
||||
new_control_record (void)
|
||||
{
|
||||
static unsigned control_allocated = 0; /* Total space allocated. */
|
||||
struct control *p;
|
||||
@@ -1096,7 +1103,8 @@ new_control_record ()
|
||||
{
|
||||
control_allocated += ALLOC_SIZE;
|
||||
controls = (struct control *)
|
||||
xrealloc (controls, sizeof (struct control) * control_allocated);
|
||||
xrealloc ((char *) controls,
|
||||
sizeof (struct control) * control_allocated);
|
||||
}
|
||||
p = &controls[control_used++];
|
||||
p->regexpr = NULL;
|
||||
@@ -1107,49 +1115,23 @@ new_control_record ()
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Convert string NUM to an integer and put the value in *RESULT.
|
||||
Return a TRUE if the string consists entirely of digits,
|
||||
FALSE if not. */
|
||||
/* FIXME: use xstrtoul in place of this function. */
|
||||
|
||||
static boolean
|
||||
string_to_number (result, num)
|
||||
int *result;
|
||||
char *num;
|
||||
{
|
||||
char ch;
|
||||
int val = 0;
|
||||
|
||||
if (*num == '\0')
|
||||
return FALSE;
|
||||
|
||||
while ((ch = *num++))
|
||||
{
|
||||
if (!ISDIGIT (ch))
|
||||
return FALSE;
|
||||
val = val * 10 + ch - '0';
|
||||
}
|
||||
|
||||
*result = val;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Check if there is a numeric offset after a regular expression.
|
||||
STR is the entire command line argument.
|
||||
P is the control record for this regular expression.
|
||||
NUM is the numeric part of STR. */
|
||||
|
||||
static void
|
||||
check_for_offset (p, str, num)
|
||||
struct control *p;
|
||||
char *str;
|
||||
char *num;
|
||||
check_for_offset (struct control *p, const char *str, const char *num)
|
||||
{
|
||||
if (*num != '-' && *num != '+')
|
||||
error (1, 0, _("%s: `+' or `-' expected after delimeter"), str);
|
||||
unsigned long val;
|
||||
|
||||
if (!string_to_number (&p->offset, num + 1))
|
||||
error (1, 0, _("%s: integer expected after `%c'"), str, *num);
|
||||
if (*num != '-' && *num != '+')
|
||||
error (EXIT_FAILURE, 0, _("%s: `+' or `-' expected after delimeter"), str);
|
||||
|
||||
if (xstrtoul (num + 1, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val > UINT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("%s: integer expected after `%c'"), str, *num);
|
||||
p->offset = (unsigned int) val;
|
||||
|
||||
if (*num == '-')
|
||||
p->offset = -p->offset;
|
||||
@@ -1161,24 +1143,29 @@ check_for_offset (p, str, num)
|
||||
ARGNUM is the ARGV index of STR. */
|
||||
|
||||
static void
|
||||
parse_repeat_count (argnum, p, str)
|
||||
int argnum;
|
||||
struct control *p;
|
||||
char *str;
|
||||
parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
{
|
||||
unsigned long val;
|
||||
char *end;
|
||||
|
||||
end = str + strlen (str) - 1;
|
||||
if (*end != '}')
|
||||
error (1, 0, _("%s: `}' is required in repeat count"), str);
|
||||
error (EXIT_FAILURE, 0, _("%s: `}' is required in repeat count"), str);
|
||||
*end = '\0';
|
||||
|
||||
if (str+1 == end-1 && *(str+1) == '*')
|
||||
p->repeat_forever = 1;
|
||||
else
|
||||
if (!string_to_number (&p->repeat, str + 1))
|
||||
error (1, 0, _("%s}: integer required between `{' and `}'"),
|
||||
global_argv[argnum]);
|
||||
{
|
||||
if (xstrtoul (str + 1, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val > UINT_MAX)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s}: integer required between `{' and `}'"),
|
||||
global_argv[argnum]);
|
||||
}
|
||||
p->repeat = (unsigned int) val;
|
||||
}
|
||||
|
||||
*end = '}';
|
||||
}
|
||||
@@ -1190,10 +1177,7 @@ parse_repeat_count (argnum, p, str)
|
||||
Unless IGNORE is TRUE, mark these lines for output. */
|
||||
|
||||
static struct control *
|
||||
extract_regexp (argnum, ignore, str)
|
||||
int argnum;
|
||||
boolean ignore;
|
||||
char *str;
|
||||
extract_regexp (int argnum, boolean ignore, char *str)
|
||||
{
|
||||
int len; /* Number of chars in this regexp. */
|
||||
char delim = *str;
|
||||
@@ -1203,7 +1187,8 @@ extract_regexp (argnum, ignore, str)
|
||||
|
||||
closing_delim = strrchr (str + 1, delim);
|
||||
if (closing_delim == NULL)
|
||||
error (1, 0, _("%s: closing delimeter `%c' missing"), str, delim);
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: closing delimeter `%c' missing"), str, delim);
|
||||
|
||||
len = closing_delim - str - 1;
|
||||
p = new_control_record ();
|
||||
@@ -1216,11 +1201,14 @@ extract_regexp (argnum, ignore, str)
|
||||
p->re_compiled.buffer = (unsigned char *) xmalloc (p->re_compiled.allocated);
|
||||
p->re_compiled.fastmap = xmalloc (256);
|
||||
p->re_compiled.translate = 0;
|
||||
#if !WITH_REGEX
|
||||
p->re_compiled.syntax_parens = 0;
|
||||
#endif
|
||||
err = re_compile_pattern (p->regexpr, len, &p->re_compiled);
|
||||
if (err)
|
||||
{
|
||||
error (0, 0, _("%s: invalid regular expression: %s"), str, err);
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
if (closing_delim[1])
|
||||
@@ -1233,13 +1221,12 @@ extract_regexp (argnum, ignore, str)
|
||||
After each pattern, check if the next argument is a repeat count. */
|
||||
|
||||
static void
|
||||
parse_patterns (argc, start, argv)
|
||||
int argc;
|
||||
int start;
|
||||
char **argv;
|
||||
parse_patterns (int argc, int start, char **argv)
|
||||
{
|
||||
int i; /* Index into ARGV. */
|
||||
struct control *p; /* New control record created. */
|
||||
unsigned long val;
|
||||
static unsigned long last_val = 0;
|
||||
|
||||
for (i = start; i < argc; i++)
|
||||
{
|
||||
@@ -1251,8 +1238,26 @@ parse_patterns (argc, start, argv)
|
||||
{
|
||||
p = new_control_record ();
|
||||
p->argnum = i;
|
||||
if (!string_to_number (&p->lines_required, argv[i]))
|
||||
error (1, 0, _("%s: invalid pattern"), argv[i]);
|
||||
|
||||
if (xstrtoul (argv[i], NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val > INT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]);
|
||||
if (val == 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: line number must be greater than zero"),
|
||||
argv[i]);
|
||||
if (val < last_val)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("line number `%s' is smaller than preceding line number, %lu"),
|
||||
argv[i], last_val);
|
||||
|
||||
if (val == last_val)
|
||||
error (0, 0,
|
||||
_("warning: line number `%s' is the same as preceding line number"),
|
||||
argv[i]);
|
||||
last_val = val;
|
||||
|
||||
p->lines_required = (int) val;
|
||||
}
|
||||
|
||||
if (i + 1 < argc && *argv[i + 1] == '{')
|
||||
@@ -1265,8 +1270,7 @@ parse_patterns (argc, start, argv)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_format_flags (format_ptr)
|
||||
char **format_ptr;
|
||||
get_format_flags (char **format_ptr)
|
||||
{
|
||||
unsigned count = 0;
|
||||
|
||||
@@ -1294,8 +1298,7 @@ get_format_flags (format_ptr)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_format_width (format_ptr)
|
||||
char **format_ptr;
|
||||
get_format_width (char **format_ptr)
|
||||
{
|
||||
unsigned count = 0;
|
||||
char *start;
|
||||
@@ -1318,8 +1321,7 @@ get_format_width (format_ptr)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_format_prec (format_ptr)
|
||||
char **format_ptr;
|
||||
get_format_prec (char **format_ptr)
|
||||
{
|
||||
unsigned count = 0;
|
||||
char *start;
|
||||
@@ -1359,8 +1361,7 @@ get_format_prec (format_ptr)
|
||||
}
|
||||
|
||||
static void
|
||||
get_format_conv_type (format_ptr)
|
||||
char **format_ptr;
|
||||
get_format_conv_type (char **format_ptr)
|
||||
{
|
||||
int ch = *((*format_ptr)++);
|
||||
|
||||
@@ -1375,20 +1376,21 @@ get_format_conv_type (format_ptr)
|
||||
break;
|
||||
|
||||
case 0:
|
||||
error (1, 0, _("missing conversion specifier in suffix"));
|
||||
error (EXIT_FAILURE, 0, _("missing conversion specifier in suffix"));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ISPRINT (ch))
|
||||
error (1, 0, _("invalid conversion specifier in suffix: %c"), ch);
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: %c"), ch);
|
||||
else
|
||||
error (1, 0, _("invalid conversion specifier in suffix: \\%.3o"), ch);
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: \\%.3o"), ch);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
max_out (format)
|
||||
char *format;
|
||||
max_out (char *format)
|
||||
{
|
||||
unsigned out_count = 0;
|
||||
unsigned percents = 0;
|
||||
@@ -1414,32 +1416,29 @@ max_out (format)
|
||||
}
|
||||
|
||||
if (percents == 0)
|
||||
error (1, 0, _("missing %% conversion specification in suffix"));
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("missing %% conversion specification in suffix"));
|
||||
else if (percents > 1)
|
||||
error (1, 0, _("too many %% conversion specifications in suffix"));
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("too many %% conversion specifications in suffix"));
|
||||
|
||||
return out_count;
|
||||
}
|
||||
|
||||
static void
|
||||
interrupt_handler (signum)
|
||||
int signum;
|
||||
{
|
||||
error (0, 0, _("interrupted"));
|
||||
cleanup ();
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
unsigned long val;
|
||||
#ifdef SA_INTERRUPT
|
||||
struct sigaction oldact, newact;
|
||||
#endif /* SA_INTERRUPT */
|
||||
#endif
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
global_argv = argv;
|
||||
controls = NULL;
|
||||
control_used = 0;
|
||||
@@ -1467,7 +1466,7 @@ main (argc, argv)
|
||||
sigaction (SIGTERM, NULL, &oldact);
|
||||
if (oldact.sa_handler != SIG_IGN)
|
||||
sigaction (SIGTERM, &newact, NULL);
|
||||
#else
|
||||
#else /* not SA_INTERRUPT */
|
||||
if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
|
||||
signal (SIGHUP, interrupt_handler);
|
||||
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
|
||||
@@ -1476,7 +1475,7 @@ main (argc, argv)
|
||||
signal (SIGQUIT, interrupt_handler);
|
||||
if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
|
||||
signal (SIGTERM, interrupt_handler);
|
||||
#endif
|
||||
#endif /* not SA_INTERRUPT */
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, (int *) 0))
|
||||
!= EOF)
|
||||
@@ -1498,8 +1497,10 @@ main (argc, argv)
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (!string_to_number (&digits, optarg))
|
||||
error (1, 0, _("%s: invalid number"), optarg);
|
||||
if (xstrtoul (optarg, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val > INT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
|
||||
digits = (int) val;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -1517,8 +1518,8 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("csplit - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("csplit - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -1544,15 +1545,14 @@ main (argc, argv)
|
||||
if (close (input_desc) < 0)
|
||||
{
|
||||
error (0, errno, _("read error"));
|
||||
cleanup ();
|
||||
cleanup_fatal ();
|
||||
}
|
||||
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -1587,5 +1587,5 @@ Read standard input if FILE is -. Each PATTERN may be:\n\
|
||||
A line OFFSET is a required `+' or `-' followed by a positive integer.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
24
src/cut.c
24
src/cut.c
@@ -72,7 +72,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
#define FATAL_ERROR(s) \
|
||||
@@ -158,7 +157,7 @@ char *program_name;
|
||||
|
||||
static enum operating_mode operating_mode;
|
||||
|
||||
/* If non-zero do not output lines containing no delimeter characters.
|
||||
/* If nonzero do not output lines containing no delimeter characters.
|
||||
Otherwise, all such lines are printed. This option is valid only
|
||||
with field mode. */
|
||||
static int suppress_non_delimited;
|
||||
@@ -169,10 +168,10 @@ static int delim;
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -222,7 +221,7 @@ range, or many ranges separated by commas. Each range is one of:\n\
|
||||
With no FILE, or when FILE is -, read standard input.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* The following function was copied from getline.c, but with these changes:
|
||||
@@ -321,7 +320,7 @@ print_kth (unsigned int k)
|
||||
to its starting index. FIELDSTR should be composed of one or more
|
||||
numbers or ranges of numbers, separated by blanks or commas.
|
||||
Incomplete ranges may be given: `-m' means `1-m'; `n-' means `n'
|
||||
through end of line. Return non-zero if FIELDSTR contains at least
|
||||
through end of line. Return nonzero if FIELDSTR contains at least
|
||||
one field specification, zero otherwise. */
|
||||
|
||||
/* FIXME-someday: What if the user wants to cut out the 1,000,000-th field
|
||||
@@ -670,12 +669,15 @@ cut_file (char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc, exit_status = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
operating_mode = undefined_mode;
|
||||
|
||||
@@ -734,8 +736,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cut - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("cut - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -766,7 +768,7 @@ main (int argc, char **argv)
|
||||
exit_status = 1;
|
||||
}
|
||||
if (ferror (stdout) || fclose (stdout) == EOF)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (exit_status);
|
||||
exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
82
src/date.c
82
src/date.c
@@ -1,5 +1,5 @@
|
||||
/* date - print or set the system date and time
|
||||
Copyright (C) 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "system.h"
|
||||
#include "getline.h"
|
||||
#include "error.h"
|
||||
@@ -38,25 +37,29 @@ size_t strftime ();
|
||||
time_t time ();
|
||||
#endif
|
||||
|
||||
int putenv ();
|
||||
int stime ();
|
||||
|
||||
char *xrealloc ();
|
||||
time_t get_date ();
|
||||
time_t posixtime ();
|
||||
|
||||
static void show_date ();
|
||||
static void usage ();
|
||||
static void show_date __P ((const char *format, time_t when));
|
||||
static void usage __P ((int status));
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If non-zero, print or set Coordinated Universal Time. */
|
||||
/* If non-zero, display time in RFC-822 format for mail or news. */
|
||||
static int rfc_format = 0;
|
||||
|
||||
/* If nonzero, print or set Coordinated Universal Time. */
|
||||
static int universal_time = 0;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -65,6 +68,7 @@ static struct option const long_options[] =
|
||||
{"file", required_argument, NULL, 'f'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"reference", required_argument, NULL, 'r'},
|
||||
{"rfc-822", no_argument, NULL, 'R'},
|
||||
{"set", required_argument, NULL, 's'},
|
||||
{"uct", no_argument, NULL, 'u'},
|
||||
{"utc", no_argument, NULL, 'u'},
|
||||
@@ -76,18 +80,16 @@ static struct option const long_options[] =
|
||||
/* Parse each line in INPUT_FILENAME as with --date and display the
|
||||
each resulting time and date. If the file cannot be opened, tell why
|
||||
then exit. Issue a diagnostic for any lines that cannot be parsed.
|
||||
If any line cannot be parsed, return non-zero; otherwise return zero. */
|
||||
If any line cannot be parsed, return nonzero; otherwise return zero. */
|
||||
|
||||
static int
|
||||
batch_convert (input_filename, format)
|
||||
const char *input_filename;
|
||||
const char *format;
|
||||
batch_convert (const char *input_filename, const char *format)
|
||||
{
|
||||
int status;
|
||||
FILE *in_stream;
|
||||
char *line;
|
||||
int line_length;
|
||||
int buflen;
|
||||
size_t buflen;
|
||||
time_t when;
|
||||
|
||||
if (strcmp (input_filename, "-") == 0)
|
||||
@@ -100,7 +102,7 @@ batch_convert (input_filename, format)
|
||||
in_stream = fopen (input_filename, "r");
|
||||
if (in_stream == NULL)
|
||||
{
|
||||
error (0, errno, "%s", input_filename);
|
||||
error (1, errno, "`%s'", input_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +141,8 @@ batch_convert (input_filename, format)
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
const char *datestr = NULL;
|
||||
@@ -158,9 +158,12 @@ main (argc, argv)
|
||||
int option_specified_date;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while (optc = getopt_long (argc, argv, "d:f:r:s:u", long_options, (int *) 0),
|
||||
optc != EOF)
|
||||
while ((optc = getopt_long (argc, argv, "d:f:r:Rs:u", long_options, NULL))
|
||||
!= EOF)
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
@@ -174,12 +177,20 @@ main (argc, argv)
|
||||
case 'r':
|
||||
reference = optarg;
|
||||
break;
|
||||
case 'R':
|
||||
rfc_format = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_datestr = optarg;
|
||||
set_date = 1;
|
||||
break;
|
||||
case 'u':
|
||||
universal_time = 1;
|
||||
universal_time = 1;
|
||||
if (putenv ("TZ=UTC0") != 0)
|
||||
error (1, 0, "memory exhausted");
|
||||
#if LOCALTIME_CACHE
|
||||
tzset ();
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
@@ -187,7 +198,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("date - %s\n", version_string);
|
||||
printf ("date - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -299,23 +310,27 @@ non-option argument must be a format string beginning with `+'"));
|
||||
standard output format (ctime style but with a timezone inserted). */
|
||||
|
||||
static void
|
||||
show_date (format, when)
|
||||
const char *format;
|
||||
time_t when;
|
||||
show_date (const char *format, time_t when)
|
||||
{
|
||||
struct tm *tm;
|
||||
char *out = NULL;
|
||||
size_t out_length = 0;
|
||||
|
||||
tm = (universal_time ? gmtime : localtime) (&when);
|
||||
tm = localtime (&when);
|
||||
|
||||
if (format == NULL)
|
||||
{
|
||||
/* Print the date in the default format. Vanilla ANSI C strftime
|
||||
doesn't support %e, but POSIX requires it. If you don't use
|
||||
a GNU strftime, make sure yours supports %e. */
|
||||
format = (universal_time
|
||||
? "%a %b %e %H:%M:%S UTC %Y"
|
||||
a GNU strftime, make sure yours supports %e.
|
||||
If you are not using GNU strftime, you want to change %z
|
||||
in the RFC format to %Z; this gives, however, an invalid
|
||||
RFC time format outside the continental United States and GMT. */
|
||||
|
||||
format = (rfc_format
|
||||
? (universal_time
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
}
|
||||
else if (*format == '\0')
|
||||
@@ -336,8 +351,7 @@ show_date (format, when)
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -355,6 +369,7 @@ Display the current time in the given FORMAT, or set the system date.\n\
|
||||
-d, --date=STRING display time described by STRING, not `now'\n\
|
||||
-f, --file=DATEFILE like --date once for each line of DATEFILE\n\
|
||||
-r, --reference=FILE display the last modification time of FILE\n\
|
||||
-R, --rfc-822 output RFC-822 compliant date string\n\
|
||||
-s, --set=STRING set time described by STRING\n\
|
||||
-u, --utc, --universal print or set Coordinated Universal Time\n\
|
||||
--help display this help and exit\n\
|
||||
@@ -373,6 +388,7 @@ specifies Coordinated Universal Time. Interpreted sequences are:\n\
|
||||
%%c locale's date and time (Sat Nov 04 12:02:33 EST 1989)\n\
|
||||
%%d day of month (01..31)\n\
|
||||
%%D date (mm/dd/yy)\n\
|
||||
%%e day of month, blank padded ( 1..31)\n\
|
||||
%%h same as %%b\n\
|
||||
%%H hour (00..23)\n\
|
||||
%%I hour (01..12)\n\
|
||||
@@ -389,12 +405,14 @@ specifies Coordinated Universal Time. Interpreted sequences are:\n\
|
||||
%%t a horizontal tab\n\
|
||||
%%T time, 24-hour (hh:mm:ss)\n\
|
||||
%%U week number of year with Sunday as first day of week (00..53)\n\
|
||||
%%V week number of year with Monday as first day of week (01..52)\n\
|
||||
%%w day of week (0..6); 0 represents Sunday\n\
|
||||
%%W week number of year with Monday as first day of week (00..53)\n\
|
||||
%%x locale's date representation (mm/dd/yy)\n\
|
||||
%%X locale's time representation (%%H:%%M:%%S)\n\
|
||||
%%y last two digits of year (00..99)\n\
|
||||
%%Y year (1970...)\n\
|
||||
%%z RFC-822 style numeric timezone (-0500) (a nonstandard extension)\n\
|
||||
%%Z time zone (e.g., EDT), or nothing if no time zone is determinable\n\
|
||||
\n\
|
||||
By default, date pads numeric fields with zeroes. GNU date recognizes\n\
|
||||
|
||||
191
src/dd.c
191
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 1985, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 Rubin, David MacKenzie, and Stuart Kemp. */
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
#define equal(p, q) (strcmp ((p),(q)) == 0)
|
||||
@@ -95,22 +94,23 @@ char *xmalloc ();
|
||||
int safe_read ();
|
||||
int full_write ();
|
||||
|
||||
static RETSIGTYPE interrupt_handler ();
|
||||
static int bit_count ();
|
||||
static int parse_integer ();
|
||||
static void apply_translations ();
|
||||
static void copy ();
|
||||
static void copy_simple ();
|
||||
static void copy_with_block ();
|
||||
static void copy_with_unblock ();
|
||||
static void parse_conversion ();
|
||||
static void print_stats ();
|
||||
static void translate_charset ();
|
||||
static void quit ();
|
||||
static void scanargs ();
|
||||
static void skip ();
|
||||
static void usage ();
|
||||
static void write_output ();
|
||||
static RETSIGTYPE interrupt_handler __P ((int));
|
||||
static int bit_count __P ((register unsigned int i));
|
||||
static int parse_integer __P ((char *str));
|
||||
static void apply_translations __P ((void));
|
||||
static void copy __P ((void));
|
||||
static void copy_simple __P ((unsigned char *buf, int nread));
|
||||
static void copy_with_block __P ((unsigned char *buf, int nread));
|
||||
static void copy_with_unblock __P ((unsigned char *buf, int nread));
|
||||
static void parse_conversion __P ((char *str));
|
||||
static void print_stats __P ((void));
|
||||
static void translate_charset __P ((const unsigned char *new_trans));
|
||||
static void quit __P ((int code));
|
||||
static void scanargs __P ((int argc, char **argv));
|
||||
static void skip __P ((int fdesc, char *file, long int records,
|
||||
long int blocksize, unsigned char *buf));
|
||||
static void usage __P ((int status));
|
||||
static void write_output __P ((void));
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -304,10 +304,10 @@ static unsigned char const ebcdic_to_ascii[] =
|
||||
070, 071, 0372, 0373, 0374, 0375, 0376, 0377
|
||||
};
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -317,10 +317,8 @@ static struct option const long_options[] =
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
#ifdef _POSIX_VERSION
|
||||
struct sigaction sigact;
|
||||
@@ -328,6 +326,9 @@ main (argc, argv)
|
||||
int i;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* Initialize translation table to identity translation. */
|
||||
for (i = 0; i < 256; i++)
|
||||
@@ -338,7 +339,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("dd - %s\n", version_string);
|
||||
printf ("dd - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -354,10 +355,12 @@ main (argc, argv)
|
||||
error (1, errno, "%s", input_file);
|
||||
}
|
||||
else
|
||||
input_file = "standard input";
|
||||
input_file = _("standard input");
|
||||
|
||||
if (input_fd == output_fd)
|
||||
error (1, 0, "standard %s is closed", input_fd == 0 ? "input" : "output");
|
||||
error (1, 0, _("%s is closed"), (input_fd == 0
|
||||
? _("standard input")
|
||||
: _("standard output")));
|
||||
|
||||
if (output_file != NULL)
|
||||
{
|
||||
@@ -377,7 +380,7 @@ main (argc, argv)
|
||||
#endif
|
||||
}
|
||||
else
|
||||
output_file = "standard output";
|
||||
output_file = _("standard output");
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
sigaction (SIGINT, NULL, &sigact);
|
||||
@@ -410,12 +413,8 @@ main (argc, argv)
|
||||
bytes of the data at a time in BUF, if necessary. */
|
||||
|
||||
static void
|
||||
skip (fdesc, file, records, blocksize, buf)
|
||||
int fdesc;
|
||||
char *file;
|
||||
long records;
|
||||
long blocksize;
|
||||
char *buf;
|
||||
skip (int fdesc, char *file, long int records, long int blocksize,
|
||||
unsigned char *buf)
|
||||
{
|
||||
struct stat stats;
|
||||
|
||||
@@ -465,9 +464,7 @@ skip (fdesc, file, records, blocksize, buf)
|
||||
to the NREAD bytes in BUF. */
|
||||
|
||||
static void
|
||||
translate_buffer (buf, nread)
|
||||
unsigned char *buf;
|
||||
int nread;
|
||||
translate_buffer (unsigned char *buf, int nread)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register int i;
|
||||
@@ -488,9 +485,7 @@ static unsigned char saved_char;
|
||||
next call. Return the new start of the BUF buffer. */
|
||||
|
||||
static unsigned char *
|
||||
swab_buffer (buf, nread)
|
||||
unsigned char *buf;
|
||||
int *nread;
|
||||
swab_buffer (unsigned char *buf, int *nread)
|
||||
{
|
||||
unsigned char *bufstart = buf;
|
||||
register unsigned char *cp;
|
||||
@@ -534,7 +529,7 @@ static int col = 0;
|
||||
/* The main loop. */
|
||||
|
||||
static void
|
||||
copy ()
|
||||
copy (void)
|
||||
{
|
||||
unsigned char *ibuf, *bufstart; /* Input buffer. */
|
||||
int nread; /* Bytes read in the current block. */
|
||||
@@ -571,7 +566,7 @@ copy ()
|
||||
whatever data we are able to read is followed by zeros.
|
||||
This minimizes data loss. */
|
||||
if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR))
|
||||
memset (ibuf, 0, input_blocksize);
|
||||
memset ((char *) ibuf, 0, input_blocksize);
|
||||
|
||||
nread = safe_read (input_fd, ibuf, input_blocksize);
|
||||
|
||||
@@ -608,7 +603,7 @@ copy ()
|
||||
{
|
||||
if (!(conversions_mask & C_NOERROR))
|
||||
/* If C_NOERROR, we zeroed the block before reading. */
|
||||
memset (ibuf + nread, 0, input_blocksize - nread);
|
||||
memset ((char *) (ibuf + nread), 0, input_blocksize - nread);
|
||||
nread = input_blocksize;
|
||||
}
|
||||
}
|
||||
@@ -618,11 +613,9 @@ copy ()
|
||||
if (ibuf == obuf) /* If not C_TWOBUFS. */
|
||||
{
|
||||
int nwritten = full_write (output_fd, obuf, nread);
|
||||
if (nwritten != nread)
|
||||
if (nwritten < 0)
|
||||
{
|
||||
error (0, errno, "%s", output_file);
|
||||
if (nwritten > 0)
|
||||
w_partial++;
|
||||
quit (1);
|
||||
}
|
||||
else if (nread == input_blocksize)
|
||||
@@ -684,7 +677,7 @@ copy ()
|
||||
int nwritten = full_write (output_fd, obuf, oc);
|
||||
if (nwritten > 0)
|
||||
w_partial++;
|
||||
if (nwritten != oc)
|
||||
if (nwritten < 0)
|
||||
{
|
||||
error (0, errno, "%s", output_file);
|
||||
quit (1);
|
||||
@@ -701,9 +694,7 @@ copy ()
|
||||
/* Copy NREAD bytes of BUF, with no conversions. */
|
||||
|
||||
static void
|
||||
copy_simple (buf, nread)
|
||||
unsigned char *buf;
|
||||
int nread;
|
||||
copy_simple (unsigned char *buf, int nread)
|
||||
{
|
||||
int nfree; /* Number of unused bytes in `obuf'. */
|
||||
unsigned char *start = buf; /* First uncopied char in BUF. */
|
||||
@@ -714,7 +705,7 @@ copy_simple (buf, nread)
|
||||
if (nfree > nread)
|
||||
nfree = nread;
|
||||
|
||||
memcpy (obuf + oc, start, nfree);
|
||||
memcpy ((char *) (obuf + oc), (char *) start, nfree);
|
||||
|
||||
nread -= nfree; /* Update the number of bytes left to copy. */
|
||||
start += nfree;
|
||||
@@ -730,9 +721,7 @@ copy_simple (buf, nread)
|
||||
replacing the newline with trailing spaces). */
|
||||
|
||||
static void
|
||||
copy_with_block (buf, nread)
|
||||
unsigned char *buf;
|
||||
int nread;
|
||||
copy_with_block (unsigned char *buf, int nread)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -764,9 +753,7 @@ copy_with_block (buf, nread)
|
||||
with a newline). */
|
||||
|
||||
static void
|
||||
copy_with_unblock (buf, nread)
|
||||
unsigned char *buf;
|
||||
int nread;
|
||||
copy_with_unblock (unsigned char *buf, int nread)
|
||||
{
|
||||
register int i;
|
||||
register unsigned char c;
|
||||
@@ -801,7 +788,7 @@ copy_with_unblock (buf, nread)
|
||||
/* Write, then empty, the output buffer `obuf'. */
|
||||
|
||||
static void
|
||||
write_output ()
|
||||
write_output (void)
|
||||
{
|
||||
int nwritten = full_write (output_fd, obuf, output_blocksize);
|
||||
if (nwritten != output_blocksize)
|
||||
@@ -817,9 +804,7 @@ write_output ()
|
||||
}
|
||||
|
||||
static void
|
||||
scanargs (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
scanargs (int argc, char **argv)
|
||||
{
|
||||
int i, n;
|
||||
int c;
|
||||
@@ -844,7 +829,7 @@ scanargs (argc, argv)
|
||||
val = strchr (name, '=');
|
||||
if (val == NULL)
|
||||
{
|
||||
error (0, 0, "unrecognized option `%s'", name);
|
||||
error (0, 0, _("unrecognized option `%s'"), name);
|
||||
usage (1);
|
||||
}
|
||||
*val++ = '\0';
|
||||
@@ -859,7 +844,7 @@ scanargs (argc, argv)
|
||||
{
|
||||
n = parse_integer (val);
|
||||
if (n < 0)
|
||||
error (1, 0, "invalid number `%s'", val);
|
||||
error (1, 0, _("invalid number `%s'"), val);
|
||||
|
||||
if (equal (name, "ibs"))
|
||||
{
|
||||
@@ -883,7 +868,7 @@ scanargs (argc, argv)
|
||||
max_records = n;
|
||||
else
|
||||
{
|
||||
error (0, 0, "unrecognized option `%s=%s'", name, val);
|
||||
error (0, 0, _("unrecognized option `%s=%s'"), name, val);
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
@@ -909,8 +894,7 @@ scanargs (argc, argv)
|
||||
/* FIXME: use xstrtou?l */
|
||||
|
||||
static int
|
||||
parse_integer (str)
|
||||
char *str;
|
||||
parse_integer (char *str)
|
||||
{
|
||||
register int n = 0;
|
||||
register int temp;
|
||||
@@ -952,8 +936,7 @@ loop:
|
||||
/* Interpret one "conv=..." option. */
|
||||
|
||||
static void
|
||||
parse_conversion (str)
|
||||
char *str;
|
||||
parse_conversion (char *str)
|
||||
{
|
||||
char *new;
|
||||
int i;
|
||||
@@ -971,7 +954,7 @@ parse_conversion (str)
|
||||
}
|
||||
if (conversions[i].convname == NULL)
|
||||
{
|
||||
error (0, 0, "%s: invalid conversion", str);
|
||||
error (0, 0, _("%s: invalid conversion"), str);
|
||||
usage (1);
|
||||
}
|
||||
str = new;
|
||||
@@ -981,7 +964,7 @@ parse_conversion (str)
|
||||
/* Fix up translation table. */
|
||||
|
||||
static void
|
||||
apply_translations ()
|
||||
apply_translations (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -991,8 +974,8 @@ apply_translations ()
|
||||
|| (MX (C_LCASE | C_UCASE) > 1)
|
||||
|| (MX (C_UNBLOCK | C_SYNC) > 1))
|
||||
{
|
||||
error (1, 0, "\
|
||||
only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sync}");
|
||||
error (1, 0, _("\
|
||||
only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sync}"));
|
||||
}
|
||||
#undef MX
|
||||
|
||||
@@ -1029,8 +1012,7 @@ only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sy
|
||||
}
|
||||
|
||||
static void
|
||||
translate_charset (new_trans)
|
||||
unsigned char *new_trans;
|
||||
translate_charset (const unsigned char *new_trans)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1042,8 +1024,7 @@ translate_charset (new_trans)
|
||||
/* Return the number of 1 bits in `i'. */
|
||||
|
||||
static int
|
||||
bit_count (i)
|
||||
register unsigned int i;
|
||||
bit_count (register unsigned int i)
|
||||
{
|
||||
register int set_bits;
|
||||
|
||||
@@ -1053,45 +1034,61 @@ bit_count (i)
|
||||
}
|
||||
|
||||
static void
|
||||
print_stats ()
|
||||
print_stats (void)
|
||||
{
|
||||
fprintf (stderr, "%u+%u records in\n", r_full, r_partial);
|
||||
fprintf (stderr, "%u+%u records out\n", w_full, w_partial);
|
||||
fprintf (stderr, _("%u+%u records in\n"), r_full, r_partial);
|
||||
fprintf (stderr, _("%u+%u records out\n"), w_full, w_partial);
|
||||
if (r_truncate > 0)
|
||||
fprintf (stderr, "%u truncated record%s\n", r_truncate,
|
||||
r_truncate == 1 ? "" : "s");
|
||||
fprintf (stderr, "%u %s\n", r_truncate,
|
||||
(r_truncate == 1
|
||||
? _("truncated record")
|
||||
: _("truncated records")));
|
||||
}
|
||||
|
||||
static void
|
||||
quit (code)
|
||||
int code;
|
||||
cleanup (void)
|
||||
{
|
||||
int errcode = code ? code : 1;
|
||||
print_stats ();
|
||||
if (close (input_fd) < 0)
|
||||
error (errcode, errno, "%s", input_file);
|
||||
error (1, errno, "%s", input_file);
|
||||
if (close (output_fd) < 0)
|
||||
error (errcode, errno, "%s", output_file);
|
||||
error (1, errno, "%s", output_file);
|
||||
}
|
||||
|
||||
static void
|
||||
quit (int code)
|
||||
{
|
||||
cleanup ();
|
||||
exit (code);
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
interrupt_handler ()
|
||||
interrupt_handler (int sig)
|
||||
{
|
||||
quit (1);
|
||||
#ifdef SA_INTERRUPT
|
||||
struct sigaction sigact;
|
||||
|
||||
sigact.sa_handler = SIG_DFL;
|
||||
sigemptyset (&sigact.sa_mask);
|
||||
sigact.sa_flags = 0;
|
||||
sigaction (sig, &sigact, NULL);
|
||||
#else /* !SA_INTERRUPT */
|
||||
signal (sig, SIG_DFL);
|
||||
#endif /* SA_INTERRUPT */
|
||||
cleanup ();
|
||||
kill (getpid (), sig);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION]...\n", program_name);
|
||||
printf ("\
|
||||
printf (_("Usage: %s [OPTION]...\n"), program_name);
|
||||
printf (_("\
|
||||
Copy a file, converting and formatting according to the options.\n\
|
||||
\n\
|
||||
bs=BYTES force ibs=BYTES and obs=BYTES\n\
|
||||
@@ -1113,13 +1110,13 @@ by w for x2, by b for x512, by k for x1024. Each KEYWORD may be:\n\
|
||||
ascii from EBCDIC to ASCII\n\
|
||||
ebcdic from ASCII to EBCDIC\n\
|
||||
ibm from ASCII to alternated EBCDIC\n\
|
||||
block pad newline-terminated records with spaces to cbs-size \n\
|
||||
block pad newline-terminated records with spaces to cbs-size\n\
|
||||
unblock replace trailing spaces in cbs-size records with newline\n\
|
||||
lcase change upper case to lower case\n\
|
||||
ucase change lower case to upper case\n\
|
||||
swab swap every pair of input bytes\n\
|
||||
noerror continue after read errors\n\
|
||||
sync pad every input block with NULs to ibs-size\n");
|
||||
sync pad every input block with NULs to ibs-size\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
749
src/df.c
749
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,52 +12,31 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Usage: df [-aikPT] [-t fstype] [-x fstype] [--all] [--inodes] [--print-type]
|
||||
[--type fstype] [--exclude-type fstype] [--kilobytes] [--portability]
|
||||
[file...]
|
||||
|
||||
Options:
|
||||
-a, --all List all filesystems, even zero-size ones.
|
||||
-i, --inodes List inode usage information instead of block usage.
|
||||
-k, --kilobytes Print sizes in 1K blocks instead of 512-byte blocks.
|
||||
-P, --portability Use the POSIX output format (one line per filesystem).
|
||||
-T, --print-type Print filesystem type.
|
||||
-t, --type fstype Limit the listing to filesystems of type `fstype'.
|
||||
-x, --exclude-type=fstype
|
||||
Limit the listing to filesystems not of type `fstype'.
|
||||
Multiple -t and/or -x options can be given.
|
||||
By default, all filesystem types are listed.
|
||||
|
||||
Written by David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
--human-readable and --megabyte options added by lm@sgi.com. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "mountlist.h"
|
||||
#include "fsusage.h"
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
char *xmalloc ();
|
||||
char *xstrdup ();
|
||||
|
||||
static int selected_fstype ();
|
||||
static int excluded_fstype ();
|
||||
static void add_excluded_fs_type ();
|
||||
static void add_fs_type ();
|
||||
static void print_header ();
|
||||
static void show_entry ();
|
||||
static void show_all_entries ();
|
||||
static void show_dev ();
|
||||
static void show_disk ();
|
||||
static void show_point ();
|
||||
static void usage ();
|
||||
/* The maximum length of a human-readable string. Be pessimistic
|
||||
and assume `int' is 64-bits wide. Converting 2^63 - 1 gives the
|
||||
14-character string, 8796093022208G. The number being converted
|
||||
is the number of 1024-byte blocks, so we divide by 1024 * 1024. */
|
||||
#define LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS 14
|
||||
|
||||
/* Name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -73,19 +52,23 @@ static int show_all_fs;
|
||||
command line argument -- even if it's a dummy (automounter) entry. */
|
||||
static int show_listed_fs;
|
||||
|
||||
/* If nonzero, use variable sized printouts instead of 512-byte blocks. */
|
||||
static int human_blocks;
|
||||
|
||||
/* If nonzero, use 1K blocks instead of 512-byte blocks. */
|
||||
static int kilobyte_blocks;
|
||||
|
||||
/* If nonzero, use 1M blocks instead of 512-byte blocks. */
|
||||
static int megabyte_blocks;
|
||||
|
||||
/* If nonzero, use the POSIX output format. */
|
||||
static int posix_format;
|
||||
|
||||
/* If nonzero, invoke the `sync' system call before getting any usage data.
|
||||
Using this option can make df very slow, especially with many or very
|
||||
busy disks. Default to non-zero because the sync call does make a
|
||||
difference on some systems -- SunOs4.1.3, for one. I have been assured
|
||||
that it is *not* necessary on Linux, so there should be a way to
|
||||
configure this. FIXME. */
|
||||
static int require_sync = 1;
|
||||
busy disks. Note that this may make a difference on some systems --
|
||||
SunOs4.1.3, for one. It is *not* necessary on Linux. */
|
||||
static int require_sync = 0;
|
||||
|
||||
/* Nonzero if errors have occurred. */
|
||||
static int exit_status;
|
||||
@@ -119,20 +102,22 @@ static struct fs_type_list *fs_exclude_list;
|
||||
/* Linked list of mounted filesystems. */
|
||||
static struct mount_entry *mount_list;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If non-zero, print filesystem type as well. */
|
||||
/* If nonzero, print filesystem type as well. */
|
||||
static int print_type;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, &show_all_fs, 1},
|
||||
{"inodes", no_argument, &inode_format, 1},
|
||||
{"kilobytes", no_argument, &kilobyte_blocks, 1},
|
||||
{"human-readable", no_argument, 0, 'h'},
|
||||
{"kilobytes", no_argument, 0, 'k'},
|
||||
{"megabytes", no_argument, 0, 'm'},
|
||||
{"portability", no_argument, &posix_format, 1},
|
||||
{"print-type", no_argument, &print_type, 1},
|
||||
{"sync", no_argument, 0, 129},
|
||||
@@ -144,148 +129,8 @@ static struct option const long_options[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i;
|
||||
struct stat *stats;
|
||||
|
||||
program_name = argv[0];
|
||||
fs_select_list = NULL;
|
||||
fs_exclude_list = NULL;
|
||||
inode_format = 0;
|
||||
show_all_fs = 0;
|
||||
show_listed_fs = 0;
|
||||
kilobyte_blocks = getenv ("POSIXLY_CORRECT") == 0;
|
||||
print_type = 0;
|
||||
posix_format = 0;
|
||||
exit_status = 0;
|
||||
|
||||
while ((i = getopt_long (argc, argv, "aikPTt:vx:", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
case 'a':
|
||||
show_all_fs = 1;
|
||||
break;
|
||||
case 'i':
|
||||
inode_format = 1;
|
||||
break;
|
||||
case 'k':
|
||||
kilobyte_blocks = 1;
|
||||
break;
|
||||
case 'T':
|
||||
print_type = 1;
|
||||
break;
|
||||
case 'P':
|
||||
posix_format = 1;
|
||||
break;
|
||||
case 129:
|
||||
require_sync = 1;
|
||||
break;
|
||||
case 130:
|
||||
require_sync = 0;
|
||||
break;
|
||||
case 't':
|
||||
add_fs_type (optarg);
|
||||
break;
|
||||
case 'v': /* For SysV compatibility. */
|
||||
break;
|
||||
case 'x':
|
||||
add_excluded_fs_type (optarg);
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("df - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
int match = 0;
|
||||
struct fs_type_list *i;
|
||||
for (i = fs_select_list; i; i = i->fs_next)
|
||||
{
|
||||
struct fs_type_list *j;
|
||||
for (j = fs_exclude_list; j; j = j->fs_next)
|
||||
{
|
||||
if (strcmp (i->fs_name, j->fs_name) == 0)
|
||||
{
|
||||
error (0, 0,
|
||||
"file system type `%s' both selected and excluded",
|
||||
i->fs_name);
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
#ifdef lint
|
||||
/* Suppress `used before initialized' warning. */
|
||||
stats = NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* stat all the given entries to make sure they get automounted,
|
||||
if necessary, before reading the filesystem table. */
|
||||
stats = (struct stat *)
|
||||
xmalloc ((argc - optind) * sizeof (struct stat));
|
||||
for (i = optind; i < argc; ++i)
|
||||
if (stat (argv[i], &stats[i - optind]))
|
||||
{
|
||||
error (0, errno, "%s", argv[i]);
|
||||
exit_status = 1;
|
||||
argv[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mount_list =
|
||||
read_filesystem_list ((fs_select_list != NULL || fs_exclude_list != NULL),
|
||||
show_all_fs);
|
||||
|
||||
if (mount_list == NULL)
|
||||
error (1, errno, "cannot read table of mounted filesystems");
|
||||
|
||||
print_header ();
|
||||
if (require_sync)
|
||||
sync ();
|
||||
|
||||
if (optind == argc)
|
||||
show_all_entries ();
|
||||
else
|
||||
{
|
||||
/* Display explicitly requested empty filesystems. */
|
||||
show_listed_fs = 1;
|
||||
|
||||
for (i = optind; i < argc; ++i)
|
||||
if (argv[i])
|
||||
show_entry (argv[i], &stats[i - optind]);
|
||||
}
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
static void
|
||||
print_header ()
|
||||
print_header (void)
|
||||
{
|
||||
printf ("Filesystem ");
|
||||
|
||||
@@ -297,114 +142,112 @@ print_header ()
|
||||
if (inode_format)
|
||||
printf (" Inodes IUsed IFree %%IUsed");
|
||||
else
|
||||
printf (" %s Used Available Capacity",
|
||||
if (megabyte_blocks)
|
||||
printf (" MB-blocks Used Available Capacity");
|
||||
else if (human_blocks)
|
||||
printf (" Size Used Avail Capacity");
|
||||
else
|
||||
printf (" %s Used Available Capacity",
|
||||
kilobyte_blocks ? "1024-blocks" : " 512-blocks");
|
||||
printf (" Mounted on\n");
|
||||
}
|
||||
|
||||
/* Show all mounted filesystems, except perhaps those that are of
|
||||
an unselected type or are empty. */
|
||||
|
||||
static void
|
||||
show_all_entries ()
|
||||
/* Convert N_1K_BYTE_BLOCKS to a more readable string than %d would.
|
||||
Most people visually process strings of 3-4 digits effectively,
|
||||
but longer strings of digits are more prone to misinterpretation.
|
||||
Hence, converting to an abbreviated form usually improves readability.
|
||||
Use a suffix indicating multiples of 1024 (M) and 1024*1024 (G).
|
||||
For example, 8500 would be converted to 8.3M, 133456345 to 127G,
|
||||
and so on. Numbers smaller than 1024 get the `K' suffix. */
|
||||
|
||||
static char *
|
||||
human_readable_1k_blocks (int n_1k_byte_blocks, char *buf, int buf_len)
|
||||
{
|
||||
struct mount_entry *me;
|
||||
const char *suffix;
|
||||
double amt;
|
||||
char *p;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
}
|
||||
assert (buf_len > LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS);
|
||||
|
||||
/* Determine what kind of node PATH is and show the disk usage
|
||||
for it. STATP is the results of `stat' on PATH. */
|
||||
p = buf;
|
||||
amt = n_1k_byte_blocks;
|
||||
|
||||
static void
|
||||
show_entry (path, statp)
|
||||
char *path;
|
||||
struct stat *statp;
|
||||
{
|
||||
if (S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
|
||||
show_disk (path);
|
||||
else
|
||||
show_point (path, statp);
|
||||
}
|
||||
|
||||
/* Identify the directory, if any, that device
|
||||
DISK is mounted on, and show its disk usage. */
|
||||
|
||||
static void
|
||||
show_disk (disk)
|
||||
char *disk;
|
||||
{
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
if (!strcmp (disk, me->me_devname))
|
||||
{
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
return;
|
||||
}
|
||||
/* No filesystem is mounted on DISK. */
|
||||
show_dev (disk, (char *) NULL, (char *) NULL);
|
||||
}
|
||||
|
||||
/* Figure out which device file or directory POINT is mounted on
|
||||
and show its disk usage.
|
||||
STATP is the results of `stat' on POINT. */
|
||||
|
||||
static void
|
||||
show_point (point, statp)
|
||||
char *point;
|
||||
struct stat *statp;
|
||||
{
|
||||
struct stat disk_stats;
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
if (amt >= 1024 * 1024)
|
||||
{
|
||||
if (me->me_dev == (dev_t) -1)
|
||||
{
|
||||
if (stat (me->me_mountdir, &disk_stats) == 0)
|
||||
me->me_dev = disk_stats.st_dev;
|
||||
else
|
||||
{
|
||||
error (0, errno, "%s", me->me_mountdir);
|
||||
exit_status = 1;
|
||||
/* So we won't try and fail repeatedly. */
|
||||
me->me_dev = (dev_t) -2;
|
||||
}
|
||||
}
|
||||
|
||||
if (statp->st_dev == me->me_dev)
|
||||
{
|
||||
/* Skip bogus mtab entries. */
|
||||
if (stat (me->me_mountdir, &disk_stats) != 0 ||
|
||||
disk_stats.st_dev != me->me_dev)
|
||||
continue;
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
return;
|
||||
}
|
||||
amt /= (1024 * 1024);
|
||||
suffix = "G";
|
||||
}
|
||||
error (0, 0, "cannot find mount point for %s", point);
|
||||
exit_status = 1;
|
||||
else if (amt >= 1024)
|
||||
{
|
||||
amt /= 1024;
|
||||
suffix = "M";
|
||||
}
|
||||
else
|
||||
{
|
||||
suffix = "K";
|
||||
}
|
||||
|
||||
if (amt >= 10)
|
||||
{
|
||||
sprintf (p, "%4.0f%s", amt, suffix);
|
||||
}
|
||||
else if (amt == 0)
|
||||
{
|
||||
strcpy (p, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (p, "%4.1f%s", amt, suffix);
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* If FSTYPE is a type of filesystem that should be listed,
|
||||
return nonzero, else zero. */
|
||||
|
||||
static int
|
||||
selected_fstype (const char *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
|
||||
if (fs_select_list == NULL || fstype == NULL)
|
||||
return 1;
|
||||
for (fsp = fs_select_list; fsp; fsp = fsp->fs_next)
|
||||
if (STREQ (fstype, fsp->fs_name))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If FSTYPE is a type of filesystem that should be omitted,
|
||||
return nonzero, else zero. */
|
||||
|
||||
static int
|
||||
excluded_fstype (const char *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
|
||||
if (fs_exclude_list == NULL || fstype == NULL)
|
||||
return 0;
|
||||
for (fsp = fs_exclude_list; fsp; fsp = fsp->fs_next)
|
||||
if (STREQ (fstype, fsp->fs_name))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Display a space listing for the disk device with absolute path DISK.
|
||||
If MOUNT_POINT is non-NULL, it is the path of the root of the
|
||||
filesystem on DISK.
|
||||
If FSTYPE is non-NULL, it is the type of the filesystem on DISK. */
|
||||
|
||||
static void
|
||||
show_dev (disk, mount_point, fstype)
|
||||
char *disk;
|
||||
char *mount_point;
|
||||
char *fstype;
|
||||
show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
{
|
||||
struct fs_usage fsu;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
long inodes_used;
|
||||
long inodes_percent_used;
|
||||
char *stat_file;
|
||||
const char *stat_file;
|
||||
|
||||
if (!selected_fstype (fstype) || excluded_fstype (fstype))
|
||||
return;
|
||||
@@ -422,7 +265,13 @@ show_dev (disk, mount_point, fstype)
|
||||
return;
|
||||
}
|
||||
|
||||
if (kilobyte_blocks)
|
||||
if (megabyte_blocks)
|
||||
{
|
||||
fsu.fsu_blocks /= 2*1024;
|
||||
fsu.fsu_bfree /= 2*1024;
|
||||
fsu.fsu_bavail /= 2*1024;
|
||||
}
|
||||
else if (kilobyte_blocks)
|
||||
{
|
||||
fsu.fsu_blocks /= 2;
|
||||
fsu.fsu_bfree /= 2;
|
||||
@@ -463,25 +312,128 @@ show_dev (disk, mount_point, fstype)
|
||||
if (inode_format)
|
||||
printf (" %7ld %7ld %7ld %5ld%%",
|
||||
fsu.fsu_files, inodes_used, fsu.fsu_ffree, inodes_percent_used);
|
||||
else if (human_blocks)
|
||||
{
|
||||
char buf[3][LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS + 1];
|
||||
printf (" %4s %4s %5s %5ld%% ",
|
||||
human_readable_1k_blocks (fsu.fsu_blocks, buf[0],
|
||||
LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS + 1),
|
||||
human_readable_1k_blocks (blocks_used, buf[1],
|
||||
LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS + 1),
|
||||
human_readable_1k_blocks (fsu.fsu_bavail, buf[2],
|
||||
LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS + 1),
|
||||
blocks_percent_used);
|
||||
}
|
||||
else
|
||||
printf (" %7ld %7ld %7ld %5ld%% ",
|
||||
fsu.fsu_blocks, blocks_used, fsu.fsu_bavail, blocks_percent_used);
|
||||
|
||||
if (mount_point)
|
||||
printf (" %s", mount_point);
|
||||
{
|
||||
#ifdef HIDE_AUTOMOUNT_PREFIX
|
||||
/* Don't print the first directory name in MOUNT_POINT if it's an
|
||||
artifact of an automounter. This is a bit too aggressive to be
|
||||
the default. */
|
||||
if (strncmp ("/auto/", mount_point, 6) == 0)
|
||||
mount_point += 5;
|
||||
else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0)
|
||||
mount_point += 8;
|
||||
#endif
|
||||
printf (" %s", mount_point);
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
|
||||
/* Identify the directory, if any, that device
|
||||
DISK is mounted on, and show its disk usage. */
|
||||
|
||||
static void
|
||||
show_disk (const char *disk)
|
||||
{
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
if (STREQ (disk, me->me_devname))
|
||||
{
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
return;
|
||||
}
|
||||
/* No filesystem is mounted on DISK. */
|
||||
show_dev (disk, (char *) NULL, (char *) NULL);
|
||||
}
|
||||
|
||||
/* Figure out which device file or directory POINT is mounted on
|
||||
and show its disk usage.
|
||||
STATP is the results of `stat' on POINT. */
|
||||
|
||||
static void
|
||||
show_point (const char *point, const struct stat *statp)
|
||||
{
|
||||
struct stat disk_stats;
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
{
|
||||
if (me->me_dev == (dev_t) -1)
|
||||
{
|
||||
if (stat (me->me_mountdir, &disk_stats) == 0)
|
||||
me->me_dev = disk_stats.st_dev;
|
||||
else
|
||||
{
|
||||
error (0, errno, "%s", me->me_mountdir);
|
||||
exit_status = 1;
|
||||
/* So we won't try and fail repeatedly. */
|
||||
me->me_dev = (dev_t) -2;
|
||||
}
|
||||
}
|
||||
|
||||
if (statp->st_dev == me->me_dev)
|
||||
{
|
||||
/* Skip bogus mtab entries. */
|
||||
if (stat (me->me_mountdir, &disk_stats) != 0 ||
|
||||
disk_stats.st_dev != me->me_dev)
|
||||
continue;
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
error (0, 0, _("cannot find mount point for %s"), point);
|
||||
exit_status = 1;
|
||||
}
|
||||
|
||||
/* Determine what kind of node PATH is and show the disk usage
|
||||
for it. STATP is the results of `stat' on PATH. */
|
||||
|
||||
static void
|
||||
show_entry (const char *path, const struct stat *statp)
|
||||
{
|
||||
if (S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
|
||||
show_disk (path);
|
||||
else
|
||||
show_point (path, statp);
|
||||
}
|
||||
|
||||
/* Show all mounted filesystems, except perhaps those that are of
|
||||
an unselected type or are empty. */
|
||||
|
||||
static void
|
||||
show_all_entries (void)
|
||||
{
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
}
|
||||
|
||||
/* Add FSTYPE to the list of filesystem types to display. */
|
||||
|
||||
static void
|
||||
add_fs_type (fstype)
|
||||
char *fstype;
|
||||
add_fs_type (const char *fstype)
|
||||
{
|
||||
struct fs_type_list *fsp;
|
||||
|
||||
fsp = (struct fs_type_list *) xmalloc (sizeof (struct fs_type_list));
|
||||
fsp->fs_name = fstype;
|
||||
fsp->fs_name = (char *) fstype;
|
||||
fsp->fs_next = fs_select_list;
|
||||
fs_select_list = fsp;
|
||||
}
|
||||
@@ -489,78 +441,221 @@ add_fs_type (fstype)
|
||||
/* Add FSTYPE to the list of filesystem types to be omitted. */
|
||||
|
||||
static void
|
||||
add_excluded_fs_type (fstype)
|
||||
char *fstype;
|
||||
add_excluded_fs_type (const char *fstype)
|
||||
{
|
||||
struct fs_type_list *fsp;
|
||||
|
||||
fsp = (struct fs_type_list *) xmalloc (sizeof (struct fs_type_list));
|
||||
fsp->fs_name = fstype;
|
||||
fsp->fs_name = (char *) fstype;
|
||||
fsp->fs_next = fs_exclude_list;
|
||||
fs_exclude_list = fsp;
|
||||
}
|
||||
|
||||
/* If FSTYPE is a type of filesystem that should be listed,
|
||||
return nonzero, else zero. */
|
||||
|
||||
static int
|
||||
selected_fstype (fstype)
|
||||
char *fstype;
|
||||
{
|
||||
struct fs_type_list *fsp;
|
||||
|
||||
if (fs_select_list == NULL || fstype == NULL)
|
||||
return 1;
|
||||
for (fsp = fs_select_list; fsp; fsp = fsp->fs_next)
|
||||
if (!strcmp (fstype, fsp->fs_name))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* If FSTYPE is a type of filesystem that should be omitted,
|
||||
return nonzero, else zero. */
|
||||
|
||||
static int
|
||||
excluded_fstype (fstype)
|
||||
char *fstype;
|
||||
{
|
||||
struct fs_type_list *fsp;
|
||||
|
||||
if (fs_exclude_list == NULL || fstype == NULL)
|
||||
return 0;
|
||||
for (fsp = fs_exclude_list; fsp; fsp = fsp->fs_next)
|
||||
if (!strcmp (fstype, fsp->fs_name))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
|
||||
printf ("\
|
||||
printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
|
||||
printf (_("\
|
||||
Show information about the filesystem on which each FILE resides,\n\
|
||||
or all filesystems by default.\n\
|
||||
\n\
|
||||
-a, --all include filesystems having 0 blocks\n\
|
||||
-i, --inodes list inode information instead of block usage\n\
|
||||
-k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
--sync invoke sync before getting usage info (default)\n\
|
||||
--no-sync do not invoke sync before getting usage info\n\
|
||||
-t, --type=TYPE limit listing to filesystems of type TYPE\n\
|
||||
-a, --all include filesystems having 0 blocks\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g. 1K 234M 2G)\n\
|
||||
-i, --inodes list inode information instead of block usage\n\
|
||||
-k, --kilobytes use 1024-byte blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
-m, --megabytes use 1024K-byte blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
--no-sync do not invoke sync before getting usage info (default)\n\
|
||||
--sync invoke sync before getting usage info\n\
|
||||
-t, --type=TYPE limit listing to filesystems of type TYPE\n\
|
||||
-x, --exclude-type=TYPE limit listing to filesystems not of type TYPE\n\
|
||||
-v (ignored)\n\
|
||||
-P, --portability use the POSIX output format\n\
|
||||
-T, --print-type print filesystem type\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
-v (ignored)\n\
|
||||
-P, --portability use the POSIX output format\n\
|
||||
-T, --print-type print filesystem type\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct stat *stats;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
fs_select_list = NULL;
|
||||
fs_exclude_list = NULL;
|
||||
inode_format = 0;
|
||||
show_all_fs = 0;
|
||||
show_listed_fs = 0;
|
||||
|
||||
if (getenv ("POSIXLY_CORRECT"))
|
||||
kilobyte_blocks = 0;
|
||||
else
|
||||
{
|
||||
char *bs;
|
||||
kilobyte_blocks = 1;
|
||||
if ((bs = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
human_blocks = 1;
|
||||
}
|
||||
|
||||
print_type = 0;
|
||||
posix_format = 0;
|
||||
exit_status = 0;
|
||||
|
||||
while ((i = getopt_long (argc, argv, "aihkmPTt:vx:", long_options, NULL))
|
||||
!= EOF)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
case 'a':
|
||||
show_all_fs = 1;
|
||||
break;
|
||||
case 'i':
|
||||
inode_format = 1;
|
||||
break;
|
||||
case 'h':
|
||||
human_blocks = 1;
|
||||
kilobyte_blocks = 1;
|
||||
megabyte_blocks = 0;
|
||||
break;
|
||||
case 'k':
|
||||
human_blocks = 0;
|
||||
kilobyte_blocks = 1;
|
||||
megabyte_blocks = 0;
|
||||
break;
|
||||
case 'm':
|
||||
human_blocks = 0;
|
||||
kilobyte_blocks = 0;
|
||||
megabyte_blocks = 1;
|
||||
break;
|
||||
case 'T':
|
||||
print_type = 1;
|
||||
break;
|
||||
case 'P':
|
||||
posix_format = 1;
|
||||
break;
|
||||
case 129:
|
||||
require_sync = 1;
|
||||
break;
|
||||
case 130:
|
||||
require_sync = 0;
|
||||
break;
|
||||
case 't':
|
||||
add_fs_type (optarg);
|
||||
break;
|
||||
case 'v': /* For SysV compatibility. */
|
||||
/* ignore */
|
||||
break;
|
||||
case 'x':
|
||||
add_excluded_fs_type (optarg);
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("df - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (posix_format && megabyte_blocks)
|
||||
error (1, 0, _("the option for counting 1MB blocks may not be used\n\
|
||||
with the portable output format"));
|
||||
|
||||
if (posix_format && human_blocks)
|
||||
error (1, 0,
|
||||
_("the option for printing with adaptive units may not be used\n\
|
||||
with the portable output format"));
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
int match = 0;
|
||||
struct fs_type_list *i;
|
||||
for (i = fs_select_list; i; i = i->fs_next)
|
||||
{
|
||||
struct fs_type_list *j;
|
||||
for (j = fs_exclude_list; j; j = j->fs_next)
|
||||
{
|
||||
if (STREQ (i->fs_name, j->fs_name))
|
||||
{
|
||||
error (0, 0,
|
||||
_("file system type `%s' both selected and excluded"),
|
||||
i->fs_name);
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
#ifdef lint
|
||||
/* Suppress `used before initialized' warning. */
|
||||
stats = NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* stat all the given entries to make sure they get automounted,
|
||||
if necessary, before reading the filesystem table. */
|
||||
stats = (struct stat *)
|
||||
xmalloc ((argc - optind) * sizeof (struct stat));
|
||||
for (i = optind; i < argc; ++i)
|
||||
if (stat (argv[i], &stats[i - optind]))
|
||||
{
|
||||
error (0, errno, "%s", argv[i]);
|
||||
exit_status = 1;
|
||||
argv[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mount_list =
|
||||
read_filesystem_list ((fs_select_list != NULL
|
||||
|| fs_exclude_list != NULL
|
||||
|| print_type),
|
||||
show_all_fs);
|
||||
|
||||
if (mount_list == NULL)
|
||||
error (1, errno, _("cannot read table of mounted filesystems"));
|
||||
|
||||
print_header ();
|
||||
if (require_sync)
|
||||
sync ();
|
||||
|
||||
if (optind == argc)
|
||||
show_all_entries ();
|
||||
else
|
||||
{
|
||||
/* Display explicitly requested empty filesystems. */
|
||||
show_listed_fs = 1;
|
||||
|
||||
for (i = optind; i < argc; ++i)
|
||||
if (argv[i])
|
||||
show_entry (argv[i], &stats[i - optind]);
|
||||
}
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
|
||||
527
src/dircolors.c
Normal file
527
src/dircolors.c
Normal file
@@ -0,0 +1,527 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1994, 1995 H. Peter Anvin
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "getline.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "dircolors.h"
|
||||
|
||||
#define obstack_chunk_alloc xmalloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
char *xmalloc ();
|
||||
char *basename ();
|
||||
char *strndup();
|
||||
|
||||
enum Shell_syntax
|
||||
{
|
||||
SHELL_SYNTAX_BOURNE,
|
||||
SHELL_SYNTAX_C,
|
||||
SHELL_SYNTAX_UNKNOWN
|
||||
};
|
||||
|
||||
#define APPEND_CHAR(C) obstack_1grow (&lsc_obstack, C)
|
||||
#define APPEND_TWO_CHAR_STRING(S) \
|
||||
do \
|
||||
{ \
|
||||
APPEND_CHAR (S[0]); \
|
||||
APPEND_CHAR (S[1]); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Accumulate in this obstack the value for the LS_COLORS environment
|
||||
variable. */
|
||||
static struct obstack lsc_obstack;
|
||||
|
||||
/* Nonzero if the input file was the standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* FIXME: associate with ls_codes? */
|
||||
static const char *const slack_codes[] =
|
||||
{
|
||||
"NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK",
|
||||
"SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
|
||||
"CHR", "CHAR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE", "END",
|
||||
"ENDCODE", NULL
|
||||
};
|
||||
|
||||
static const char *const ls_codes[] =
|
||||
{
|
||||
"no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
|
||||
"so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", "rc", "ec", "ec"
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"bourne-shell", no_argument, NULL, 'b'},
|
||||
{"sh", no_argument, NULL, 'b'},
|
||||
{"csh", no_argument, NULL, 'c'},
|
||||
{"c-shell", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"print-data-base", no_argument, NULL, 'p'},
|
||||
{"print-database", no_argument, NULL, 'p'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
};
|
||||
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [OPTION]... [FILE]\n"), program_name);
|
||||
printf (_("\
|
||||
Output commands to set the LS_COLOR environment variable.\n\
|
||||
\n\
|
||||
Determine format of output:\n\
|
||||
-b, --sh, --bourne-shell output Bourne shell code to set LS_COLOR\n\
|
||||
-c, --csh, --c-shell output C shell code to set LS_COLOR\n\
|
||||
-p, --print-data-base output defaults\n\
|
||||
-h, --help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
}
|
||||
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void *
|
||||
xstrndup (const char *s, size_t n)
|
||||
{
|
||||
char *new = strndup (s, n);
|
||||
if (new == NULL)
|
||||
error (EXIT_FAILURE, 0, _("Memory exhausted"));
|
||||
return new;
|
||||
}
|
||||
|
||||
/* If the SHELL environment variable is set to `csh' or `tcsh,'
|
||||
assume C shell. Else Bourne shell. */
|
||||
|
||||
static enum Shell_syntax
|
||||
guess_shell_syntax (void)
|
||||
{
|
||||
char *shell;
|
||||
|
||||
shell = getenv ("SHELL");
|
||||
if (shell == NULL || *shell == '\0')
|
||||
return SHELL_SYNTAX_UNKNOWN;
|
||||
|
||||
shell = basename (shell);
|
||||
|
||||
if (STREQ (shell, "csh") || STREQ (shell, "tcsh"))
|
||||
return SHELL_SYNTAX_C;
|
||||
|
||||
return SHELL_SYNTAX_BOURNE;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_line (const char *line, char **keyword, char **arg)
|
||||
{
|
||||
const char *p;
|
||||
const char *keyword_start;
|
||||
const char *arg_start;
|
||||
|
||||
*keyword = NULL;
|
||||
*arg = NULL;
|
||||
|
||||
for (p = line; isspace (*p); ++p)
|
||||
;
|
||||
|
||||
/* Ignore blank lines and shell-style comments. */
|
||||
if (*p == '\0' || *p == '#')
|
||||
return;
|
||||
|
||||
keyword_start = p;
|
||||
|
||||
while (!isspace (*p) && *p != '\0')
|
||||
{
|
||||
++p;
|
||||
}
|
||||
|
||||
*keyword = xstrndup (keyword_start, p - keyword_start);
|
||||
if (*p == '\0')
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
++p;
|
||||
}
|
||||
while (isspace (*p));
|
||||
|
||||
if (*p == '\0' || *p == '#')
|
||||
return;
|
||||
|
||||
arg_start = p;
|
||||
|
||||
while (*p != '\0' && *p != '#')
|
||||
++p;
|
||||
|
||||
for (--p; isspace (*p); --p)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
++p;
|
||||
|
||||
*arg = xstrndup (arg_start, p - arg_start);
|
||||
}
|
||||
|
||||
/* FIXME: Write a string to standard out, while watching for "dangerous"
|
||||
sequences like unescaped : and = characters. */
|
||||
|
||||
static void
|
||||
append_quoted (const char *str)
|
||||
{
|
||||
int need_backslash = 1;
|
||||
|
||||
while (*str != '\0')
|
||||
{
|
||||
switch (*str)
|
||||
{
|
||||
case '\\':
|
||||
case '^':
|
||||
need_backslash = !need_backslash;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
case '=':
|
||||
if (need_backslash)
|
||||
APPEND_CHAR ('\\');
|
||||
/* Fall through */
|
||||
|
||||
default:
|
||||
need_backslash = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
APPEND_CHAR (*str);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the file open on FP (with name FILENAME). First, look for a
|
||||
`TERM name' directive where name matches the current terminal type.
|
||||
Once found, translate and accumulate the associated directives onto
|
||||
the global obstack LSC_OBSTACK. Give a diagnostic and return nonzero
|
||||
upon failure (unrecognized keyword is the only way to fail here).
|
||||
Return zero otherwise. */
|
||||
|
||||
static int
|
||||
dc_parse_stream (FILE *fp, const char *filename)
|
||||
{
|
||||
size_t line_number = 0;
|
||||
char *line = NULL;
|
||||
size_t line_chars_allocated = 0;
|
||||
int state;
|
||||
char *term;
|
||||
int err = 0;
|
||||
|
||||
/* State for the parser. */
|
||||
enum states { ST_TERMNO, ST_TERMYES, ST_TERMSURE, ST_GLOBAL };
|
||||
|
||||
state = ST_GLOBAL;
|
||||
|
||||
/* Get terminal type */
|
||||
term = getenv ("TERM");
|
||||
if (term == NULL || *term == '\0')
|
||||
term = "none";
|
||||
|
||||
while (1)
|
||||
{
|
||||
int line_length;
|
||||
char *keywd, *arg;
|
||||
int unrecognized;
|
||||
|
||||
++line_number;
|
||||
|
||||
if (fp)
|
||||
{
|
||||
line_length = getline (&line, &line_chars_allocated, fp);
|
||||
if (line_length <= 0)
|
||||
{
|
||||
if (line)
|
||||
free (line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line = (char *) (G_line[line_number - 1]);
|
||||
line_length = G_line_length[line_number - 1];
|
||||
if (line_number > G_N_LINES)
|
||||
break;
|
||||
}
|
||||
|
||||
parse_line (line, &keywd, &arg);
|
||||
|
||||
if (keywd == NULL)
|
||||
continue;
|
||||
|
||||
unrecognized = 0;
|
||||
if (strcasecmp (keywd, "TERM") == 0)
|
||||
{
|
||||
if (strcmp (arg, term) == 0)
|
||||
state = ST_TERMSURE;
|
||||
else if (state != ST_TERMSURE)
|
||||
state = ST_TERMNO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state == ST_TERMSURE)
|
||||
state = ST_TERMYES; /* Another TERM can cancel */
|
||||
|
||||
if (state != ST_TERMNO)
|
||||
{
|
||||
if (keywd[0] == '.')
|
||||
{
|
||||
APPEND_CHAR ('*');
|
||||
append_quoted (keywd);
|
||||
APPEND_CHAR ('=');
|
||||
append_quoted (arg);
|
||||
APPEND_CHAR (':');
|
||||
}
|
||||
else if (keywd[0] == '*')
|
||||
{
|
||||
append_quoted (keywd);
|
||||
APPEND_CHAR ('=');
|
||||
append_quoted (arg);
|
||||
APPEND_CHAR (':');
|
||||
}
|
||||
else if (strcasecmp (keywd, "OPTIONS") == 0
|
||||
|| strcasecmp (keywd, "COLOR") == 0
|
||||
|| strcasecmp (keywd, "EIGHTBIT") == 0)
|
||||
{
|
||||
/* Ignore. */
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; slack_codes[i] != NULL; ++i)
|
||||
if (strcasecmp (keywd, slack_codes[i]) == 0)
|
||||
break;
|
||||
|
||||
if (slack_codes[i] != NULL)
|
||||
{
|
||||
APPEND_TWO_CHAR_STRING (ls_codes[i]);
|
||||
APPEND_CHAR ('=');
|
||||
append_quoted (arg);
|
||||
APPEND_CHAR (':');
|
||||
}
|
||||
else
|
||||
{
|
||||
unrecognized = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unrecognized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES))
|
||||
{
|
||||
error (0, 0, _("%s:%lu: unrecognized keyword `%s'"),
|
||||
filename, (long unsigned) line_number, keywd);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
free (keywd);
|
||||
if (arg)
|
||||
free (arg);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
dc_parse_file (const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
int err;
|
||||
|
||||
if (strcmp (filename, "-") == 0)
|
||||
{
|
||||
have_read_stdin = 1;
|
||||
fp = stdin;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* OPENOPTS is a macro. It varies with the system.
|
||||
Some systems distinguish between internal and
|
||||
external text representations. */
|
||||
|
||||
fp = fopen (filename, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
error (0, errno, "%s", filename);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
err = dc_parse_stream (fp, filename);
|
||||
|
||||
if (fp != stdin && fclose (fp) == EOF)
|
||||
{
|
||||
error (0, errno, "%s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int err = 0;
|
||||
int optc;
|
||||
enum Shell_syntax syntax = SHELL_SYNTAX_UNKNOWN;
|
||||
int print_database = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dircolors", PACKAGE_VERSION, usage);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL))
|
||||
!= EOF)
|
||||
switch (optc)
|
||||
{
|
||||
case 'b': /* Bourne shell syntax. */
|
||||
syntax = SHELL_SYNTAX_BOURNE;
|
||||
break;
|
||||
|
||||
case 'c': /* C shell syntax. */
|
||||
syntax = SHELL_SYNTAX_C;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
print_database = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
/* It doesn't make sense to use --print with either of
|
||||
--bourne or --c-shell. */
|
||||
if (print_database && syntax != SHELL_SYNTAX_UNKNOWN)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the options to output dircolors' internal database and\n\
|
||||
to select a shell syntax are mutually exclusive"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (print_database && argc > 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("no FILE arguments may be used with the option to output\n\
|
||||
dircolors' internal database"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (!print_database && argc > 1)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (print_database)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < G_N_LINES; i++)
|
||||
{
|
||||
fwrite (G_line[i], 1, G_line_length[i], stdout);
|
||||
fputc ('\n', stdout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If shell syntax was not explicitly specified, try to guess it. */
|
||||
if (syntax == SHELL_SYNTAX_UNKNOWN)
|
||||
{
|
||||
syntax = guess_shell_syntax ();
|
||||
if (syntax == SHELL_SYNTAX_UNKNOWN)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("no SHELL environment variable, and no shell type option given"));
|
||||
}
|
||||
}
|
||||
|
||||
obstack_init (&lsc_obstack);
|
||||
if (argc == 0)
|
||||
err = dc_parse_stream (NULL, NULL);
|
||||
else
|
||||
err = dc_parse_file (argv[0]);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
size_t len = obstack_object_size (&lsc_obstack);
|
||||
char *s = obstack_finish (&lsc_obstack);
|
||||
const char *prefix;
|
||||
const char *suffix;
|
||||
|
||||
if (syntax == SHELL_SYNTAX_BOURNE)
|
||||
{
|
||||
prefix = "LS_COLORS='";
|
||||
suffix = "';\nexport LS_COLORS\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = "setenv LS_COLORS '";
|
||||
suffix = "'\n";
|
||||
}
|
||||
fputs (prefix, stdout);
|
||||
fwrite (s, 1, len, stdout);
|
||||
fputs (suffix, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
exit (err == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
72
src/dircolors.hin
Normal file
72
src/dircolors.hin
Normal file
@@ -0,0 +1,72 @@
|
||||
# Configuration file for dircolors, a utility to help you set the
|
||||
# LS_COLORS environment variable used by GNU ls with the --color option.
|
||||
|
||||
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
|
||||
# slackware version of dircolors) are recognized but ignored.
|
||||
|
||||
# Below, there should be one TERM entry for each termtype that is colorizable
|
||||
TERM linux
|
||||
TERM console
|
||||
TERM con132x25
|
||||
TERM con132x30
|
||||
TERM con132x43
|
||||
TERM con132x60
|
||||
TERM con80x25
|
||||
TERM con80x28
|
||||
TERM con80x30
|
||||
TERM con80x43
|
||||
TERM con80x50
|
||||
TERM con80x60
|
||||
TERM xterm
|
||||
TERM vt100
|
||||
|
||||
# Below are the color init strings for the basic file types. A color init
|
||||
# string consists of one or more of the following numeric codes:
|
||||
# Attribute codes:
|
||||
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
||||
# Text color codes:
|
||||
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
||||
# Background color codes:
|
||||
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
||||
NORMAL 00 # global default, although everything should be something.
|
||||
FILE 00 # normal file
|
||||
DIR 01;34 # directory
|
||||
LINK 01;36 # symbolic link
|
||||
FIFO 40;33 # pipe
|
||||
SOCK 01;35 # socket
|
||||
BLK 40;33;01 # block device driver
|
||||
CHR 40;33;01 # character device driver
|
||||
|
||||
# This is for files with execute permission:
|
||||
EXEC 01;32
|
||||
|
||||
# List any file extensions like '.gz' or '.tar' that you would like ls
|
||||
# to colorize below. Put the extension, a space, and the color init string.
|
||||
# (and any comments you want to add after a '#')
|
||||
.cmd 01;32 # executables (bright green)
|
||||
.exe 01;32
|
||||
.com 01;32
|
||||
.btm 01;32
|
||||
.bat 01;32
|
||||
.tar 01;31 # archives or compressed (bright red)
|
||||
.tgz 01;31
|
||||
.arj 01;31
|
||||
.taz 01;31
|
||||
.lzh 01;31
|
||||
.zip 01;31
|
||||
.z 01;31
|
||||
.Z 01;31
|
||||
.gz 01;31
|
||||
.deb 01;31
|
||||
.jpg 01;35 # image formats
|
||||
.gif 01;35
|
||||
.bmp 01;35
|
||||
.ppm 01;35
|
||||
.tga 01;35
|
||||
.xbm 01;35
|
||||
.xpm 01;35
|
||||
.tif 01;35
|
||||
.mpg 01;37
|
||||
.avi 01;37
|
||||
.gl 01;37
|
||||
.dl 01;37
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dirname -- strip filename suffix from pathname
|
||||
Copyright (C) 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 and Jim Meyering. */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -32,8 +31,7 @@ void strip_trailing_slashes ();
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -56,21 +54,23 @@ output `.' (meaning the current directory).\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
register char *path;
|
||||
register char *slash;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dirname", version_string, usage);
|
||||
parse_long_options (argc, argv, "dirname", PACKAGE_VERSION, usage);
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
error (0, 0, _("too %s arguments"), argc < 2 ? _("few") : _("many"));
|
||||
error (0, 0, argc < 2 ? _("too few arguments")
|
||||
: _("too many arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
|
||||
306
src/du.c
306
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Differences from the Unix du:
|
||||
* Doesn't simply ignore the names of regular files given as arguments
|
||||
@@ -25,8 +25,10 @@
|
||||
-c Write a grand total of all of the arguments after all
|
||||
arguments have been processed. This can be used to find
|
||||
out the disk usage of a directory, with some files excluded.
|
||||
-h Print sizes in human readable format (1k 234M 2G, etc).
|
||||
-k Print sizes in kilobytes instead of 512 byte blocks
|
||||
(the default required by POSIX).
|
||||
-m Print sizes in megabytes instead of 512 byte blocks
|
||||
-b Print sizes in bytes.
|
||||
-S Count the size of each directory separately, not including
|
||||
the sizes of subdirectories.
|
||||
@@ -34,7 +36,9 @@
|
||||
-L Dereference all symbolic links.
|
||||
|
||||
By tege@sics.se, Torbjorn Granlund,
|
||||
and djm@ai.mit.edu, David MacKenzie. */
|
||||
and djm@ai.mit.edu, David MacKenzie.
|
||||
Variable blocks added by lm@sgi.com.
|
||||
*/
|
||||
|
||||
#ifdef _AIX
|
||||
#pragma alloca
|
||||
@@ -44,12 +48,16 @@
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "save-cwd.h"
|
||||
#include "error.h"
|
||||
|
||||
#undef convert_blocks
|
||||
#define convert_blocks(b, size) (size == size_kilobytes ? ((b) + 1) / 2 : \
|
||||
size == size_megabytes ? ((b) + 1024) / 2048 : (b))
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
|
||||
@@ -59,6 +67,11 @@
|
||||
/* Initial size to allocate for `path'. */
|
||||
#define INITIAL_PATH_SIZE 100
|
||||
|
||||
/* The maximum length of a human-readable string. Be pessimistic
|
||||
and assume `int' is 64-bits wide. Converting 2^63 - 1 gives the
|
||||
11-character string, 8589934592G. */
|
||||
#define LONGEST_HUMAN_READABLE 11
|
||||
|
||||
/* Hash structure for inode and device numbers. The separate entry
|
||||
structure makes it easier to rehash "in place". */
|
||||
|
||||
@@ -97,16 +110,17 @@ char *savedir ();
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static int hash_insert ();
|
||||
static int hash_insert2 ();
|
||||
static long count_entry ();
|
||||
static void du_files ();
|
||||
static void hash_init ();
|
||||
static void hash_reset ();
|
||||
static void str_concatc ();
|
||||
static void str_copyc ();
|
||||
static void str_init ();
|
||||
static void str_trunc ();
|
||||
static int hash_insert __P ((ino_t ino, dev_t dev));
|
||||
static int hash_insert2 __P ((struct htab *htab, ino_t ino, dev_t dev));
|
||||
static long count_entry __P ((char *ent, int top, dev_t last_dev));
|
||||
static void du_files __P ((char **files));
|
||||
static void hash_init __P ((unsigned int modulus,
|
||||
unsigned int entry_tab_size));
|
||||
static void hash_reset __P ((void));
|
||||
static void str_concatc __P ((string s1, char *cstr));
|
||||
static void str_copyc __P ((string s1, char *cstr));
|
||||
static void str_init __P ((string *s1, unsigned int size));
|
||||
static void str_trunc __P ((string s1, unsigned int length));
|
||||
|
||||
/* Name under which this program was invoked. */
|
||||
char *program_name;
|
||||
@@ -136,9 +150,13 @@ enum output_size
|
||||
{
|
||||
size_blocks, /* 512-byte blocks. */
|
||||
size_kilobytes, /* 1K blocks. */
|
||||
size_megabytes, /* 1024K blocks. */
|
||||
size_bytes /* 1-byte blocks. */
|
||||
};
|
||||
|
||||
/* human style output */
|
||||
static int opt_human_readable;
|
||||
|
||||
/* The units to count in. */
|
||||
static enum output_size output_size;
|
||||
|
||||
@@ -158,10 +176,10 @@ static int (*xstat) ();
|
||||
/* The exit status to use if we don't get any fatal errors. */
|
||||
static int exit_status;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* Grand total size of all args. */
|
||||
@@ -174,7 +192,9 @@ static struct option const long_options[] =
|
||||
{"count-links", no_argument, &opt_count_all, 1},
|
||||
{"dereference", no_argument, NULL, 'L'},
|
||||
{"dereference-args", no_argument, &opt_dereference_arguments, 1},
|
||||
{"human-readable", no_argument, NULL, 'h'},
|
||||
{"kilobytes", no_argument, NULL, 'k'},
|
||||
{"megabytes", no_argument, NULL, 'm'},
|
||||
{"one-file-system", no_argument, &opt_one_file_system, 1},
|
||||
{"separate-dirs", no_argument, &opt_separate_dirs, 1},
|
||||
{"summarize", no_argument, &opt_summarize_only, 1},
|
||||
@@ -185,55 +205,69 @@ static struct option const long_options[] =
|
||||
};
|
||||
|
||||
static void
|
||||
usage (status, reason)
|
||||
int status;
|
||||
char *reason;
|
||||
usage (int status, char *reason)
|
||||
{
|
||||
if (reason != NULL)
|
||||
fprintf (status == 0 ? stdout : stderr, "%s: %s\n",
|
||||
program_name, reason);
|
||||
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
|
||||
printf ("\
|
||||
printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
|
||||
printf (_("\
|
||||
Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
\n\
|
||||
-a, --all write counts for all files, not just directories\n\
|
||||
-b, --bytes print size in bytes\n\
|
||||
-c, --total produce a grand total\n\
|
||||
-k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
-l, --count-links count sizes many times if hard linked\n\
|
||||
-s, --summarize display only a total for each argument\n\
|
||||
-x, --one-file-system skip directories on different filesystems\n\
|
||||
-D, --dereference-args dereference PATHs when symbolic link\n\
|
||||
-L, --dereference dereference all symbolic links\n\
|
||||
-S, --separate-dirs do not include size of subdirectories\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
-a, --all write counts for all files, not just directories\n\
|
||||
-b, --bytes print size in bytes\n\
|
||||
-c, --total produce a grand total\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g. 1K 234M 2G)\n\
|
||||
-k, --kilobytes use 1024-byte blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
-l, --count-links count sizes many times if hard linked\n\
|
||||
-m, --megabytes use 1024K-byte blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
-s, --summarize display only a total for each argument\n\
|
||||
-x, --one-file-system skip directories on different filesystems\n\
|
||||
-D, --dereference-args dereference PATHs when symbolic link\n\
|
||||
-L, --dereference dereference all symbolic links\n\
|
||||
-S, --separate-dirs do not include size of subdirectories\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
char *bs;
|
||||
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
program_name = argv[0];
|
||||
xstat = lstat;
|
||||
output_size = getenv ("POSIXLY_CORRECT") ? size_blocks : size_kilobytes;
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abcklsxDLS", long_options, (int *) 0))
|
||||
xstat = lstat;
|
||||
|
||||
if (getenv ("POSIXLY_CORRECT"))
|
||||
output_size = size_blocks;
|
||||
else if ((bs = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
{
|
||||
opt_human_readable = 1;
|
||||
output_size = size_bytes;
|
||||
}
|
||||
else
|
||||
output_size = size_kilobytes;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchklmsxDLS", long_options,
|
||||
(int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (c)
|
||||
@@ -247,14 +281,26 @@ main (argc, argv)
|
||||
|
||||
case 'b':
|
||||
output_size = size_bytes;
|
||||
opt_human_readable = 0;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
opt_combined_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
output_size = size_bytes;
|
||||
opt_human_readable = 1;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_size = size_kilobytes;
|
||||
opt_human_readable = 0;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
output_size = size_megabytes;
|
||||
opt_human_readable = 0;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
@@ -288,7 +334,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("du - %s\n", version_string);
|
||||
printf ("du - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -296,7 +342,7 @@ main (argc, argv)
|
||||
usage (0, NULL);
|
||||
|
||||
if (opt_all && opt_summarize_only)
|
||||
usage (2, "cannot both summarize and show all entries");
|
||||
usage (2, _("cannot both summarize and show all entries"));
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
@@ -307,13 +353,68 @@ main (argc, argv)
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
|
||||
/* Convert N_BYTES to a more readable string than %d would.
|
||||
Most people visually process strings of 3-4 digits effectively,
|
||||
but longer strings of digits are more prone to misinterpretation.
|
||||
Hence, converting to an abbreviated form usually improves readability.
|
||||
Use a suffix indicating multiples of 1024 (K), 1024*1024 (M), and
|
||||
1024*1024*1024 (G). For example, 8500 would be converted to 8.3K,
|
||||
133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller
|
||||
than 1024 aren't modified. */
|
||||
|
||||
static char *
|
||||
human_readable (int n_bytes, char *buf, int buf_len)
|
||||
{
|
||||
const char *suffix;
|
||||
double amt;
|
||||
char *p;
|
||||
|
||||
assert (buf_len > LONGEST_HUMAN_READABLE);
|
||||
|
||||
p = buf;
|
||||
amt = n_bytes;
|
||||
|
||||
if (amt >= 1024 * 1024 * 1024)
|
||||
{
|
||||
amt /= (1024 * 1024 * 1024);
|
||||
suffix = "G";
|
||||
}
|
||||
else if (amt >= 1024 * 1024)
|
||||
{
|
||||
amt /= (1024 * 1024);
|
||||
suffix = "M";
|
||||
}
|
||||
else if (amt >= 1024)
|
||||
{
|
||||
amt /= 1024;
|
||||
suffix = "K";
|
||||
}
|
||||
else
|
||||
{
|
||||
suffix = "";
|
||||
}
|
||||
|
||||
if (amt >= 10)
|
||||
{
|
||||
sprintf (p, "%.0f%s", amt, suffix);
|
||||
}
|
||||
else if (amt == 0)
|
||||
{
|
||||
strcpy (p, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (p, "%.1f%s", amt, suffix);
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL. */
|
||||
|
||||
static void
|
||||
du_files (files)
|
||||
char **files;
|
||||
du_files (char **files)
|
||||
{
|
||||
struct saved_cwd cwd;
|
||||
ino_t initial_ino; /* Initial directory's inode. */
|
||||
@@ -325,7 +426,7 @@ du_files (files)
|
||||
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, "current directory");
|
||||
error (1, errno, _("current directory"));
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
|
||||
@@ -360,31 +461,37 @@ du_files (files)
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
{
|
||||
if (restore_cwd (&cwd, "starting directory", NULL))
|
||||
if (restore_cwd (&cwd, _("starting directory"), NULL))
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_combined_arguments)
|
||||
{
|
||||
printf ("%ld\ttotal\n", output_size == size_bytes ? tot_size
|
||||
: convert_blocks (tot_size, output_size == size_kilobytes));
|
||||
if (opt_human_readable)
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
printf("%s\ttotal\n", human_readable (tot_size, buf,
|
||||
LONGEST_HUMAN_READABLE + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (_("%ld\ttotal\n"), output_size == size_bytes ? tot_size
|
||||
: convert_blocks (tot_size, output_size == size_kilobytes));
|
||||
}
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
|
||||
|
||||
/* Print (if appropriate) and return the size
|
||||
(in units determined by `output_size') of file or directory ENT.
|
||||
TOP is one for external calls, zero for recursive calls.
|
||||
LAST_DEV is the device that the parent directory of ENT is on. */
|
||||
|
||||
static long
|
||||
count_entry (ent, top, last_dev)
|
||||
char *ent;
|
||||
int top;
|
||||
dev_t last_dev;
|
||||
count_entry (char *ent, int top, dev_t last_dev)
|
||||
{
|
||||
long size;
|
||||
|
||||
@@ -439,7 +546,7 @@ count_entry (ent, top, last_dev)
|
||||
|
||||
if (chdir (ent) < 0)
|
||||
{
|
||||
error (0, errno, "cannot change to directory %s", path->text);
|
||||
error (0, errno, _("cannot change to directory %s"), path->text);
|
||||
exit_status = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -458,13 +565,13 @@ count_entry (ent, top, last_dev)
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
else if (chdir ("..") < 0)
|
||||
error (1, errno, "cannot change to `..' from directory %s",
|
||||
error (1, errno, _("cannot change to `..' from directory %s"),
|
||||
path->text);
|
||||
exit_status = 1;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
|
||||
/* Remember the current path. */
|
||||
@@ -489,14 +596,26 @@ count_entry (ent, top, last_dev)
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
else if (chdir ("..") < 0)
|
||||
error (1, errno, "cannot change to `..' from directory %s", path->text);
|
||||
error (1, errno,
|
||||
_("cannot change to `..' from directory %s"), path->text);
|
||||
|
||||
str_trunc (path, pathlen - 1); /* Remove the "/" we added. */
|
||||
if (!opt_summarize_only || top)
|
||||
{
|
||||
printf ("%ld\t%s\n", output_size == size_bytes ? size
|
||||
: convert_blocks (size, output_size == size_kilobytes),
|
||||
path->length > 0 ? path->text : "/");
|
||||
if (opt_human_readable)
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
printf("%s\t%s\n",
|
||||
human_readable (size, buf, LONGEST_HUMAN_READABLE + 1),
|
||||
path->length > 0 ? path->text : "/");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%ld\t%s\n", (output_size == size_bytes
|
||||
? size
|
||||
: convert_blocks (size, output_size)),
|
||||
path->length > 0 ? path->text : "/");
|
||||
}
|
||||
fflush (stdout);
|
||||
}
|
||||
return opt_separate_dirs ? 0 : size;
|
||||
@@ -507,16 +626,26 @@ count_entry (ent, top, last_dev)
|
||||
int print_only_dir_size = 0;
|
||||
if (!print_only_dir_size)
|
||||
{
|
||||
printf ("%ld\t%s\n", output_size == size_bytes ? size
|
||||
: convert_blocks (size, output_size == size_kilobytes),
|
||||
path->text);
|
||||
if (opt_human_readable)
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
printf("%s\t%s\n",
|
||||
human_readable (size, buf, LONGEST_HUMAN_READABLE + 1),
|
||||
path->length > 0 ? path->text : "/");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%ld\t%s\n", output_size == size_bytes ? size
|
||||
: convert_blocks (size, output_size == size_kilobytes),
|
||||
path->text);
|
||||
}
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate space for the hash structures, and set the global
|
||||
variable `htab' to point to it. The initial hash module is specified in
|
||||
MODULUS, and the number of entries are specified in ENTRY_TAB_SIZE. (The
|
||||
@@ -525,9 +654,7 @@ count_entry (ent, top, last_dev)
|
||||
doubled.) */
|
||||
|
||||
static void
|
||||
hash_init (modulus, entry_tab_size)
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
|
||||
@@ -548,7 +675,7 @@ hash_init (modulus, entry_tab_size)
|
||||
contain no entries. */
|
||||
|
||||
static void
|
||||
hash_reset ()
|
||||
hash_reset (void)
|
||||
{
|
||||
int i;
|
||||
struct entry **p;
|
||||
@@ -562,13 +689,11 @@ hash_reset ()
|
||||
|
||||
/* Insert an item (inode INO and device DEV) in the hash
|
||||
structure in the global variable `htab', if an entry with the same data
|
||||
was not found already. Return zero if the item was inserted and non-zero
|
||||
was not found already. Return zero if the item was inserted and nonzero
|
||||
if it wasn't. */
|
||||
|
||||
static int
|
||||
hash_insert (ino, dev)
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
hash_insert (ino_t ino, dev_t dev)
|
||||
{
|
||||
struct htab *htab_r = htab; /* Initially a copy of the global `htab'. */
|
||||
|
||||
@@ -631,14 +756,11 @@ hash_insert (ino, dev)
|
||||
}
|
||||
|
||||
/* Insert INO and DEV in the hash structure HTAB, if not
|
||||
already present. Return zero if inserted and non-zero if it
|
||||
already present. Return zero if inserted and nonzero if it
|
||||
already existed. */
|
||||
|
||||
static int
|
||||
hash_insert2 (htab, ino, dev)
|
||||
struct htab *htab;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
hash_insert2 (struct htab *htab, ino_t ino, dev_t dev)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &htab->hash[ino % htab->modulus];
|
||||
@@ -671,13 +793,11 @@ hash_insert2 (htab, ino, dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the struct string S1 for holding SIZE characters. */
|
||||
|
||||
static void
|
||||
str_init (s1, size)
|
||||
string *s1;
|
||||
unsigned size;
|
||||
str_init (string *s1, unsigned int size)
|
||||
{
|
||||
string s;
|
||||
|
||||
@@ -689,9 +809,7 @@ str_init (s1, size)
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_space (s, size)
|
||||
string s;
|
||||
unsigned size;
|
||||
ensure_space (string s, unsigned int size)
|
||||
{
|
||||
if (s->alloc < size)
|
||||
{
|
||||
@@ -703,9 +821,7 @@ ensure_space (s, size)
|
||||
/* Assign the null-terminated C-string CSTR to S1. */
|
||||
|
||||
static void
|
||||
str_copyc (s1, cstr)
|
||||
string s1;
|
||||
char *cstr;
|
||||
str_copyc (string s1, char *cstr)
|
||||
{
|
||||
unsigned l = strlen (cstr);
|
||||
ensure_space (s1, l);
|
||||
@@ -714,9 +830,7 @@ str_copyc (s1, cstr)
|
||||
}
|
||||
|
||||
static void
|
||||
str_concatc (s1, cstr)
|
||||
string s1;
|
||||
char *cstr;
|
||||
str_concatc (string s1, char *cstr)
|
||||
{
|
||||
unsigned l1 = s1->length;
|
||||
unsigned l2 = strlen (cstr);
|
||||
@@ -730,9 +844,7 @@ str_concatc (s1, cstr)
|
||||
/* Truncate the string S1 to have length LENGTH. */
|
||||
|
||||
static void
|
||||
str_trunc (s1, length)
|
||||
string s1;
|
||||
unsigned length;
|
||||
str_trunc (string s1, unsigned int length)
|
||||
{
|
||||
if (s1->length > length)
|
||||
{
|
||||
|
||||
46
src/echo.c
46
src/echo.c
@@ -1,27 +1,24 @@
|
||||
/* echo.c, taken from Bash.
|
||||
Copyright (C) 87, 89, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
/* echo.c, derived from code echo.c in Bash.
|
||||
Copyright (C) 87, 89, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
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.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* echo [-neE] [arg ...]
|
||||
@@ -64,8 +61,7 @@ on System V systems with the -E option.
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -102,16 +98,20 @@ Without -E, the following sequences are recognized and interpolated:\n\
|
||||
/* Print the words in LIST to standard output. If the first word is
|
||||
`-n', then don't print a trailing newline. We also support the
|
||||
echo syntax from Version 9 unix systems. */
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int display_return = 1, do_v9 = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "echo", version_string, usage);
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, "echo", PACKAGE_VERSION, usage);
|
||||
|
||||
/* System V machines already have a /bin/sh with a v9 behaviour. We
|
||||
use the identical behaviour for these machines so that the
|
||||
|
||||
30
src/env.c
30
src/env.c
@@ -1,5 +1,5 @@
|
||||
/* env - run a program in a modified environment
|
||||
Copyright (C) 86, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Richard Mlynarik and David MacKenzie */
|
||||
|
||||
@@ -83,23 +83,22 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
int putenv ();
|
||||
|
||||
static void usage ();
|
||||
static void usage __P ((int status));
|
||||
|
||||
extern char **environ;
|
||||
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -111,17 +110,17 @@ static struct option const longopts[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv, envp)
|
||||
register int argc;
|
||||
register char **argv;
|
||||
char **envp;
|
||||
int
|
||||
main (register int argc, register char **argv, char **envp)
|
||||
{
|
||||
char *dummy_environ[1];
|
||||
int optc;
|
||||
int ignore_environment = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "+iu:", longopts, (int *) 0)) != EOF)
|
||||
{
|
||||
@@ -141,7 +140,7 @@ main (argc, argv, envp)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("env - %s\n", version_string);
|
||||
printf ("env - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ main (argc, argv, envp)
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "-"))
|
||||
ignore_environment = 1;
|
||||
|
||||
|
||||
environ = dummy_environ;
|
||||
environ[0] = NULL;
|
||||
|
||||
@@ -182,8 +181,7 @@ main (argc, argv, envp)
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
|
||||
30
src/expand.c
30
src/expand.c
@@ -1,5 +1,5 @@
|
||||
/* expand - convert tabs to spaces
|
||||
Copyright (C) 1989, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 91, 95, 1996 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
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The number of bytes added at a time to the amount of memory
|
||||
@@ -90,10 +89,10 @@ static int have_read_stdin;
|
||||
/* Status to return to the system. */
|
||||
static int exit_status;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -130,7 +129,7 @@ With no FILE, or when FILE is -, read standard input.\n\
|
||||
Instead of -t NUMBER or -t LIST, -NUMBER or -LIST may be used.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Add tab stop TABVAL to the end of `tab_list', except
|
||||
@@ -169,7 +168,7 @@ parse_tabstops (char *stops)
|
||||
tabval = tabval * 10 + *stops - '0';
|
||||
}
|
||||
else
|
||||
error (1, 0, _("tab size contains an invalid character"));
|
||||
error (EXIT_FAILURE, 0, _("tab size contains an invalid character"));
|
||||
}
|
||||
|
||||
add_tabstop (tabval);
|
||||
@@ -187,9 +186,9 @@ validate_tabstops (int *tabs, int entries)
|
||||
for (i = 0; i < entries; i++)
|
||||
{
|
||||
if (tabs[i] == 0)
|
||||
error (1, 0, _("tab size cannot be 0"));
|
||||
error (EXIT_FAILURE, 0, _("tab size cannot be 0"));
|
||||
if (tabs[i] <= prev_tab)
|
||||
error (1, 0, _("tab sizes must be ascending"));
|
||||
error (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
|
||||
prev_tab = tabs[i];
|
||||
}
|
||||
}
|
||||
@@ -322,7 +321,7 @@ expand (void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int tabval = -1; /* Value of tabstop being read, or -1. */
|
||||
@@ -334,6 +333,9 @@ main (int argc, char **argv)
|
||||
tab_list = NULL;
|
||||
first_free_tab = 0;
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "it:,0123456789", longopts, (int *) 0))
|
||||
!= EOF)
|
||||
@@ -365,8 +367,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("expand - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("expand - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -391,9 +393,9 @@ main (int argc, char **argv)
|
||||
expand ();
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (1, errno, "-");
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
if (ferror (stdout) || fclose (stdout) == EOF)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (exit_status);
|
||||
exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
131
src/expr.c
131
src/expr.c
@@ -1,5 +1,5 @@
|
||||
/* expr -- evaluate expressions.
|
||||
Copyright (C) 86, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Author: Mike Parker.
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <regex.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -71,26 +70,25 @@ char *xstrdup ();
|
||||
char *strstr ();
|
||||
char *xmalloc ();
|
||||
|
||||
static VALUE *docolon ();
|
||||
static VALUE *eval ();
|
||||
static VALUE *int_value ();
|
||||
static VALUE *str_value ();
|
||||
static int isstring ();
|
||||
static int nextarg ();
|
||||
static int nomoreargs ();
|
||||
static int null ();
|
||||
static int toarith ();
|
||||
static void freev ();
|
||||
static void printv ();
|
||||
static void tostring ();
|
||||
static VALUE *docolon __P ((VALUE *sv, VALUE *pv));
|
||||
static VALUE *eval __P ((void));
|
||||
static VALUE *int_value __P ((int i));
|
||||
static VALUE *str_value __P ((char *s));
|
||||
static int isstring __P ((VALUE *v));
|
||||
static int nextarg __P ((char *str));
|
||||
static int nomoreargs __P ((void));
|
||||
static int null __P ((VALUE *v));
|
||||
static int toarith __P ((VALUE *v));
|
||||
static void freev __P ((VALUE *v));
|
||||
static void printv __P ((VALUE *v));
|
||||
static void tostring __P ((VALUE *v));
|
||||
|
||||
#ifdef EVAL_TRACE
|
||||
static void trace ();
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -150,16 +148,19 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "expr", version_string, usage);
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, "expr", PACKAGE_VERSION, usage);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
@@ -180,8 +181,7 @@ main (argc, argv)
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *
|
||||
int_value (i)
|
||||
int i;
|
||||
int_value (int i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
@@ -194,8 +194,7 @@ int_value (i)
|
||||
/* Return a VALUE for S. */
|
||||
|
||||
static VALUE *
|
||||
str_value (s)
|
||||
char *s;
|
||||
str_value (char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
@@ -208,8 +207,7 @@ str_value (s)
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void
|
||||
freev (v)
|
||||
VALUE *v;
|
||||
freev (VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
free (v->u.s);
|
||||
@@ -219,8 +217,7 @@ freev (v)
|
||||
/* Print VALUE V. */
|
||||
|
||||
static void
|
||||
printv (v)
|
||||
VALUE *v;
|
||||
printv (VALUE *v)
|
||||
{
|
||||
switch (v->type)
|
||||
{
|
||||
@@ -238,8 +235,7 @@ printv (v)
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int
|
||||
null (v)
|
||||
VALUE *v;
|
||||
null (VALUE *v)
|
||||
{
|
||||
switch (v->type)
|
||||
{
|
||||
@@ -255,8 +251,7 @@ null (v)
|
||||
/* Return nonzero if V is a string value. */
|
||||
|
||||
static int
|
||||
isstring (v)
|
||||
VALUE *v;
|
||||
isstring (VALUE *v)
|
||||
{
|
||||
return v->type == string;
|
||||
}
|
||||
@@ -264,8 +259,7 @@ isstring (v)
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
|
||||
static void
|
||||
tostring (v)
|
||||
VALUE *v;
|
||||
tostring (VALUE *v)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
@@ -287,8 +281,7 @@ tostring (v)
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static int
|
||||
toarith (v)
|
||||
VALUE *v;
|
||||
toarith (VALUE *v)
|
||||
{
|
||||
int i;
|
||||
int neg;
|
||||
@@ -327,8 +320,7 @@ toarith (v)
|
||||
STR must not be NULL. */
|
||||
|
||||
static int
|
||||
nextarg (str)
|
||||
char *str;
|
||||
nextarg (char *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
return 0;
|
||||
@@ -338,7 +330,7 @@ nextarg (str)
|
||||
/* Return nonzero if there no more tokens. */
|
||||
|
||||
static int
|
||||
nomoreargs ()
|
||||
nomoreargs (void)
|
||||
{
|
||||
return *args == 0;
|
||||
}
|
||||
@@ -358,12 +350,12 @@ int name (l, r) VALUE *l; VALUE *r; \
|
||||
else \
|
||||
return l->u.i rel r->u.i; \
|
||||
}
|
||||
cmpf (less_than, <)
|
||||
cmpf (less_equal, <=)
|
||||
cmpf (equal, ==)
|
||||
cmpf (not_equal, !=)
|
||||
cmpf (greater_equal, >=)
|
||||
cmpf (greater_than, >)
|
||||
cmpf (less_than, <)
|
||||
cmpf (less_equal, <=)
|
||||
cmpf (equal, ==)
|
||||
cmpf (not_equal, !=)
|
||||
cmpf (greater_equal, >=)
|
||||
cmpf (greater_than, >)
|
||||
|
||||
#undef cmpf
|
||||
|
||||
@@ -388,11 +380,11 @@ int name (l, r) VALUE *l; VALUE *r; \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
arithf (plus, +)
|
||||
arithf (minus, -)
|
||||
arithf (multiply, *)
|
||||
arithdivf (divide, /)
|
||||
arithdivf (mod, %)
|
||||
arithf (plus, +)
|
||||
arithf (minus, -)
|
||||
arithf (multiply, *)
|
||||
arithdivf (divide, /)
|
||||
arithdivf (mod, %)
|
||||
|
||||
#undef arithf
|
||||
#undef arithdivf
|
||||
@@ -418,9 +410,7 @@ trace (fxn)
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *
|
||||
docolon (sv, pv)
|
||||
VALUE *sv;
|
||||
VALUE *pv;
|
||||
docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
const char *errmsg;
|
||||
@@ -431,12 +421,21 @@ docolon (sv, pv)
|
||||
tostring (sv);
|
||||
tostring (pv);
|
||||
|
||||
if (pv->u.s[0] == '^')
|
||||
{
|
||||
error (0, 0, _("\
|
||||
warning: unportable BRE: `%s': using `^' as the first character\n\
|
||||
of the basic regular expression is not portable; it is being ignored"),
|
||||
pv->u.s);
|
||||
}
|
||||
|
||||
len = strlen (pv->u.s);
|
||||
memset (&re_buffer, 0, sizeof (re_buffer));
|
||||
memset (&re_regs, 0, sizeof (re_regs));
|
||||
re_buffer.allocated = 2 * len;
|
||||
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
|
||||
re_buffer.translate = 0;
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg)
|
||||
error (2, 0, "%s", errmsg);
|
||||
@@ -468,7 +467,7 @@ docolon (sv, pv)
|
||||
/* Handle bare operands and ( expr ) syntax. */
|
||||
|
||||
static VALUE *
|
||||
eval7 ()
|
||||
eval7 (void)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
@@ -497,7 +496,7 @@ eval7 ()
|
||||
/* Handle match, substr, index, and length keywords. */
|
||||
|
||||
static VALUE *
|
||||
eval6 ()
|
||||
eval6 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -535,7 +534,7 @@ eval6 ()
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
v = int_value (strcspn (l->u.s, r->u.s) + 1);
|
||||
if (v->u.i == strlen (l->u.s) + 1)
|
||||
if (v->u.i == (int) strlen (l->u.s) + 1)
|
||||
v->u.i = 0;
|
||||
freev (l);
|
||||
freev (r);
|
||||
@@ -549,7 +548,7 @@ eval6 ()
|
||||
i2 = eval6 ();
|
||||
tostring (l);
|
||||
if (!toarith (i1) || !toarith (i2)
|
||||
|| i1->u.i > strlen (l->u.s)
|
||||
|| i1->u.i > (int) strlen (l->u.s)
|
||||
|| i1->u.i <= 0 || i2->u.i <= 0)
|
||||
v = str_value ("");
|
||||
else
|
||||
@@ -573,7 +572,7 @@ eval6 ()
|
||||
Calls docolon to do the real work. */
|
||||
|
||||
static VALUE *
|
||||
eval5 ()
|
||||
eval5 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -602,7 +601,7 @@ eval5 ()
|
||||
/* Handle *, /, % operators. */
|
||||
|
||||
static VALUE *
|
||||
eval4 ()
|
||||
eval4 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -635,7 +634,7 @@ eval4 ()
|
||||
/* Handle +, - operators. */
|
||||
|
||||
static VALUE *
|
||||
eval3 ()
|
||||
eval3 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -666,7 +665,7 @@ eval3 ()
|
||||
/* Handle comparisons. */
|
||||
|
||||
static VALUE *
|
||||
eval2 ()
|
||||
eval2 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -707,7 +706,7 @@ eval2 ()
|
||||
/* Handle &. */
|
||||
|
||||
static VALUE *
|
||||
eval1 ()
|
||||
eval1 (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
@@ -739,7 +738,7 @@ eval1 ()
|
||||
/* Handle |. */
|
||||
|
||||
static VALUE *
|
||||
eval ()
|
||||
eval (void)
|
||||
{
|
||||
VALUE *l;
|
||||
VALUE *r;
|
||||
|
||||
111
src/factor.c
111
src/factor.c
@@ -1,5 +1,5 @@
|
||||
/* factor -- print factors of n. lose if n > 2^32.
|
||||
Copyright (C) 86, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1995, 96 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,37 +12,50 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 Rubin <phr@ocf.berkeley.edu>. */
|
||||
/* Written by Paul Rubin <phr@ocf.berkeley.edu>.
|
||||
Adapted for GNU, fixed to factor UINT_MAX by Jim Meyering. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <assert.h>
|
||||
#define NDEBUG 1
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif /* HAVE_LIMITS_H */
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "readtokens.h"
|
||||
|
||||
/* Token delimiters when reading from a file. */
|
||||
#define DELIM "\n\t "
|
||||
|
||||
/* FIXME: if this program is ever modified to factor integers larger
|
||||
than 2^128, this (and the algorithm :-) will have to change. */
|
||||
than 2^128, this constant (and the algorithm :-) will have to change. */
|
||||
#define MAX_N_FACTORS 128
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -50,27 +63,31 @@ usage (status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [NUMBER]\n\
|
||||
Usage: %s [NUMBER]...\n\
|
||||
or: %s OPTION\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf (_("\
|
||||
Print factors of each NUMBER; read standard input with no arguments.\n\
|
||||
\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
Print the prime factors of all specified integer NUMBERs. If no arguments\n\
|
||||
are specified on the command line, they are read from standard input.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* FIXME: comment */
|
||||
|
||||
static int
|
||||
factor (n0, max_n_factors, factors)
|
||||
unsigned long n0;
|
||||
int max_n_factors;
|
||||
unsigned long *factors;
|
||||
factor (long unsigned int n0, int max_n_factors, long unsigned int *factors)
|
||||
{
|
||||
register unsigned long n = n0, d;
|
||||
int n_factors = 0;
|
||||
unsigned int sqrt_n;
|
||||
|
||||
if (n < 1)
|
||||
return n_factors;
|
||||
@@ -89,7 +106,8 @@ factor (n0, max_n_factors, factors)
|
||||
(3) n is composite but has no factors less than d.
|
||||
If (1) or (2) obviously the right thing happens.
|
||||
If (3), then since n is composite it is >= d^2. */
|
||||
for (d = 3; d * d <= n; d += 2)
|
||||
sqrt_n = (unsigned int) sqrt ((double) n);
|
||||
for (d = 3; d <= sqrt_n; d += 2)
|
||||
{
|
||||
while (n % d == 0)
|
||||
{
|
||||
@@ -107,23 +125,33 @@ factor (n0, max_n_factors, factors)
|
||||
return n_factors;
|
||||
}
|
||||
|
||||
static void
|
||||
print_factors (n)
|
||||
unsigned long int n;
|
||||
/* FIXME: comment */
|
||||
|
||||
static int
|
||||
print_factors (const char *s)
|
||||
{
|
||||
unsigned long int factors[MAX_N_FACTORS];
|
||||
unsigned long n;
|
||||
int n_factors;
|
||||
int i;
|
||||
|
||||
if (xstrtoul (s, NULL, 10, &n, NULL) != LONGINT_OK)
|
||||
{
|
||||
error (0, 0, _("`%s' is not a valid positive integer"), s);
|
||||
return 1;
|
||||
}
|
||||
n_factors = factor (n, MAX_N_FACTORS, factors);
|
||||
printf ("%lu:", n);
|
||||
for (i = 0; i < n_factors; i++)
|
||||
printf (" %lu\n", factors[i]);
|
||||
printf (" %lu", factors[i]);
|
||||
putchar ('\n');
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
do_stdin ()
|
||||
static int
|
||||
do_stdin (void)
|
||||
{
|
||||
int fail = 0;
|
||||
token_buffer tokenbuffer;
|
||||
|
||||
init_tokenbuffer (&tokenbuffer);
|
||||
@@ -136,37 +164,36 @@ do_stdin ()
|
||||
&tokenbuffer);
|
||||
if (token_length < 0)
|
||||
break;
|
||||
/* FIXME: Use xstrtoul, not atoi. */
|
||||
print_factors ((unsigned long) atoi (tokenbuffer.buffer));
|
||||
fail |= print_factors (tokenbuffer.buffer);
|
||||
}
|
||||
free (tokenbuffer.buffer);
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int fail;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "factor", version_string, usage);
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
usage (1);
|
||||
}
|
||||
parse_long_options (argc, argv, "factor", PACKAGE_VERSION, usage);
|
||||
|
||||
fail = 0;
|
||||
if (argc == 1)
|
||||
do_stdin ();
|
||||
else if (argc == 2)
|
||||
{
|
||||
print_factors ((unsigned long) atoi (argv[1]));
|
||||
}
|
||||
fail = do_stdin ();
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Usage: %s [number]\n"), argv[0]);
|
||||
exit (1);
|
||||
int i;
|
||||
for (i = 1; i < argc; i++)
|
||||
fail |= print_factors (argv[i]);
|
||||
}
|
||||
exit (0);
|
||||
if (fail)
|
||||
usage (1);
|
||||
|
||||
exit (fail);
|
||||
}
|
||||
|
||||
124
src/fmt.c
124
src/fmt.c
@@ -1,5 +1,5 @@
|
||||
/* GNU fmt -- simple text formatter.
|
||||
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 94, 95, 1996 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
|
||||
@@ -23,13 +23,25 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
/* Redefine. Otherwise, systems (Unicos for one) with headers that define
|
||||
it to be a type get syntax errors for the variable declaration below. */
|
||||
#define word unused_word_type
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The following parameters represent the program's idea of what is
|
||||
"best". Adjust to taste, subject to the caveats given. */
|
||||
@@ -53,7 +65,7 @@
|
||||
|
||||
typedef long COST;
|
||||
|
||||
#define MAXCOST (~(((COST) 1) << (8 * sizeof (COST) -1)))
|
||||
#define MAXCOST (~(((unsigned long) 1) << (8 * sizeof (COST) -1)))
|
||||
|
||||
#define SQR(n) ((n) * (n))
|
||||
#define EQUIV(n) SQR ((COST) (n))
|
||||
@@ -113,8 +125,10 @@ typedef long COST;
|
||||
/* Miscellaneous definitions. */
|
||||
|
||||
typedef unsigned int bool;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#undef TRUE
|
||||
#define TRUE 1
|
||||
#undef FALSE
|
||||
#define FALSE 0
|
||||
|
||||
/* Word descriptor structure. */
|
||||
|
||||
@@ -142,15 +156,6 @@ struct Word
|
||||
|
||||
/* Forward declarations. */
|
||||
|
||||
/* My fp_PROTOTYPES would be better than __STDC__. FIXME :-). */
|
||||
#ifndef __P
|
||||
# if __STDC__
|
||||
# define __P(Args) Args
|
||||
# else
|
||||
# define __P(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static void set_prefix __P ((char *p));
|
||||
static void fmt __P ((FILE *f));
|
||||
static bool get_paragraph __P ((FILE *f));
|
||||
@@ -172,10 +177,10 @@ static void put_space __P ((int space));
|
||||
/* The name this program was run with. */
|
||||
const char *program_name;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help = 0;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version = 0;
|
||||
|
||||
/* Option values. */
|
||||
@@ -265,14 +270,13 @@ static int next_char;
|
||||
after the current paragraph. */
|
||||
static int next_prefix_indent;
|
||||
|
||||
/* If non-zero, the length of the last line output in the current
|
||||
/* If nonzero, the length of the last line output in the current
|
||||
paragraph, used to charge for raggedness at the split point for long
|
||||
paragraphs chosen by fmt_paragraph(). */
|
||||
static int last_line_length;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -297,7 +301,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
In -wNUMBER, the letter `w' may be omitted.\n"),
|
||||
stdout);
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Decode options and launch execution. */
|
||||
@@ -316,14 +320,15 @@ static const struct option long_options[] =
|
||||
};
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
register int argc;
|
||||
register char *argv[];
|
||||
main (register int argc, register char **argv)
|
||||
{
|
||||
int optchar;
|
||||
FILE *infile;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
crown = tagged = split = uniform = FALSE;
|
||||
max_width = WIDTH;
|
||||
@@ -374,8 +379,14 @@ main (argc, argv)
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
/* FIXME: use strtol. */
|
||||
max_width = atoi (optarg);
|
||||
{
|
||||
long int tmp_long;
|
||||
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long <= 0 || tmp_long > INT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("invalid line number increment: `%s'"),
|
||||
optarg);
|
||||
max_width = (int) tmp_long;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@@ -386,8 +397,8 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fmt - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("fmt - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -413,15 +424,14 @@ main (argc, argv)
|
||||
error (0, errno, argv[optind]);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Trim space from the front and back of the string P, yielding the prefix,
|
||||
and record the lengths of the prefix and the space trimmed. */
|
||||
|
||||
static void
|
||||
set_prefix (p)
|
||||
register char *p;
|
||||
set_prefix (register char *p)
|
||||
{
|
||||
register char *s;
|
||||
|
||||
@@ -443,8 +453,7 @@ set_prefix (p)
|
||||
/* read file F and send formatted output to stdout. */
|
||||
|
||||
static void
|
||||
fmt (f)
|
||||
FILE *f;
|
||||
fmt (FILE *f)
|
||||
{
|
||||
tabs = FALSE;
|
||||
other_indent = 0;
|
||||
@@ -472,8 +481,7 @@ fmt (f)
|
||||
paragraph, else TRUE. */
|
||||
|
||||
static bool
|
||||
get_paragraph (f)
|
||||
FILE *f;
|
||||
get_paragraph (FILE *f)
|
||||
{
|
||||
register int c;
|
||||
|
||||
@@ -559,9 +567,7 @@ get_paragraph (f)
|
||||
Return the character (\n or EOF) ending the line. */
|
||||
|
||||
static int
|
||||
copy_rest (f, c)
|
||||
FILE *f;
|
||||
register int c;
|
||||
copy_rest (FILE *f, register int c)
|
||||
{
|
||||
register const char *s;
|
||||
|
||||
@@ -569,8 +575,9 @@ copy_rest (f, c)
|
||||
if (in_column > next_prefix_indent && c != '\n' && c != EOF)
|
||||
{
|
||||
put_space (next_prefix_indent);
|
||||
for (s = prefix; out_column != in_column; out_column++)
|
||||
for (s = prefix; out_column != in_column && *s; out_column++)
|
||||
putchar (*s++);
|
||||
put_space (in_column - out_column);
|
||||
}
|
||||
while (c != '\n' && c != EOF)
|
||||
{
|
||||
@@ -585,8 +592,7 @@ copy_rest (f, c)
|
||||
otherwise FALSE. */
|
||||
|
||||
static bool
|
||||
same_para (c)
|
||||
register int c;
|
||||
same_para (register int c)
|
||||
{
|
||||
return (next_prefix_indent == prefix_indent
|
||||
&& in_column >= next_prefix_indent + prefix_full_length
|
||||
@@ -602,9 +608,7 @@ same_para (c)
|
||||
Return the first non-blank character of the next line. */
|
||||
|
||||
static int
|
||||
get_line (f, c)
|
||||
FILE *f;
|
||||
register int c;
|
||||
get_line (FILE *f, register int c)
|
||||
{
|
||||
int start;
|
||||
register char *end_of_parabuf;
|
||||
@@ -654,8 +658,7 @@ get_line (f, c)
|
||||
character, or first non-blank character after the prefix. */
|
||||
|
||||
static int
|
||||
get_prefix (f)
|
||||
FILE *f;
|
||||
get_prefix (FILE *f)
|
||||
{
|
||||
register int c;
|
||||
register const char *p;
|
||||
@@ -684,9 +687,7 @@ get_prefix (f)
|
||||
in_column up-to-date. Return first non-blank character. */
|
||||
|
||||
static int
|
||||
get_space (f, c)
|
||||
FILE *f;
|
||||
register int c;
|
||||
get_space (FILE *f, register int c)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -706,8 +707,7 @@ get_space (f, c)
|
||||
/* Set extra fields in word W describing any attached punctuation. */
|
||||
|
||||
static void
|
||||
check_punctuation (w)
|
||||
register WORD *w;
|
||||
check_punctuation (register WORD *w)
|
||||
{
|
||||
register const char *start, *finish;
|
||||
|
||||
@@ -724,7 +724,7 @@ check_punctuation (w)
|
||||
hitting the limit on the number of words or characters. */
|
||||
|
||||
static void
|
||||
flush_paragraph ()
|
||||
flush_paragraph (void)
|
||||
{
|
||||
WORD *split_point;
|
||||
register WORD *w;
|
||||
@@ -789,7 +789,7 @@ flush_paragraph ()
|
||||
one to the whole paragraph. */
|
||||
|
||||
static void
|
||||
fmt_paragraph ()
|
||||
fmt_paragraph (void)
|
||||
{
|
||||
register WORD *start, *w;
|
||||
register int len;
|
||||
@@ -837,8 +837,7 @@ fmt_paragraph ()
|
||||
word THIS. */
|
||||
|
||||
static COST
|
||||
base_cost (this)
|
||||
register WORD *this;
|
||||
base_cost (register WORD *this)
|
||||
{
|
||||
register COST cost;
|
||||
|
||||
@@ -871,9 +870,7 @@ base_cost (this)
|
||||
depends on LEN, the length of the line beginning there. */
|
||||
|
||||
static COST
|
||||
line_cost (next, len)
|
||||
register WORD *next;
|
||||
register int len;
|
||||
line_cost (register WORD *next, register int len)
|
||||
{
|
||||
register int n;
|
||||
register COST cost;
|
||||
@@ -894,8 +891,7 @@ line_cost (next, len)
|
||||
FINISH, which must be in the next_break chain from word. */
|
||||
|
||||
static void
|
||||
put_paragraph (finish)
|
||||
register WORD *finish;
|
||||
put_paragraph (register WORD *finish)
|
||||
{
|
||||
register WORD *w;
|
||||
|
||||
@@ -908,9 +904,7 @@ put_paragraph (finish)
|
||||
INDENT, including the prefix (if any). */
|
||||
|
||||
static void
|
||||
put_line (w, indent)
|
||||
register WORD *w;
|
||||
int indent;
|
||||
put_line (register WORD *w, int indent)
|
||||
{
|
||||
register WORD *endline;
|
||||
|
||||
@@ -934,8 +928,7 @@ put_line (w, indent)
|
||||
/* Output to stdout the word W. */
|
||||
|
||||
static void
|
||||
put_word (w)
|
||||
register WORD *w;
|
||||
put_word (register WORD *w)
|
||||
{
|
||||
register const char *s;
|
||||
register int n;
|
||||
@@ -949,8 +942,7 @@ put_word (w)
|
||||
/* Output to stdout SPACE spaces, or equivalent tabs. */
|
||||
|
||||
static void
|
||||
put_space (space)
|
||||
int space;
|
||||
put_space (int space)
|
||||
{
|
||||
register int space_target, tab_target;
|
||||
|
||||
|
||||
65
src/fold.c
65
src/fold.c
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 95, 1996 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
|
||||
@@ -25,8 +25,21 @@
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
|
||||
char *xrealloc ();
|
||||
@@ -44,10 +57,10 @@ static int count_bytes;
|
||||
/* If nonzero, at least one of the files we read was standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -77,11 +90,11 @@ Wrap input lines in each FILE (standard input by default), writing to\n\
|
||||
standard output.\n\
|
||||
\n\
|
||||
-b, --bytes count bytes rather than columns\n\
|
||||
-s, --spaces break at word boundaries\n\
|
||||
-s, --spaces break at spaces\n\
|
||||
-w, --width=WIDTH use WIDTH columns instead of 80\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Assuming the current column is COLUMN, return the column that
|
||||
@@ -120,9 +133,9 @@ fold_file (char *filename, int width)
|
||||
FILE *istream;
|
||||
register int c;
|
||||
int column = 0; /* Screen column where next char will go. */
|
||||
size_t offset_out = 0; /* Index in `line_out' for next char. */
|
||||
int offset_out = 0; /* Index in `line_out' for next char. */
|
||||
static char *line_out = NULL;
|
||||
static size_t allocated_out = 0;
|
||||
static int allocated_out = 0;
|
||||
|
||||
if (!strcmp (filename, "-"))
|
||||
{
|
||||
@@ -149,7 +162,7 @@ fold_file (char *filename, int width)
|
||||
if (c == '\n')
|
||||
{
|
||||
line_out[offset_out++] = c;
|
||||
fwrite (line_out, sizeof (char), offset_out, stdout);
|
||||
fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
|
||||
column = offset_out = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -177,7 +190,8 @@ fold_file (char *filename, int width)
|
||||
|
||||
/* Found a blank. Don't output the part after it. */
|
||||
logical_end++;
|
||||
fwrite (line_out, sizeof (char), logical_end, stdout);
|
||||
fwrite (line_out, sizeof (char), (size_t) logical_end,
|
||||
stdout);
|
||||
putchar ('\n');
|
||||
/* Move the remainder to the beginning of the next line.
|
||||
The areas being copied here might overlap. */
|
||||
@@ -198,7 +212,7 @@ fold_file (char *filename, int width)
|
||||
}
|
||||
}
|
||||
line_out[offset_out++] = '\n';
|
||||
fwrite (line_out, sizeof (char), offset_out, stdout);
|
||||
fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
|
||||
column = offset_out = 0;
|
||||
goto rescan;
|
||||
}
|
||||
@@ -207,7 +221,7 @@ fold_file (char *filename, int width)
|
||||
}
|
||||
|
||||
if (offset_out)
|
||||
fwrite (line_out, sizeof (char), offset_out, stdout);
|
||||
fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
|
||||
|
||||
if (ferror (istream))
|
||||
{
|
||||
@@ -231,7 +245,7 @@ fold_file (char *filename, int width)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int width = 80;
|
||||
@@ -240,6 +254,10 @@ main (int argc, char **argv)
|
||||
int errs = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
break_spaces = count_bytes = have_read_stdin = 0;
|
||||
|
||||
/* Turn any numeric options into -w options. */
|
||||
@@ -274,9 +292,14 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'w': /* Line width. */
|
||||
width = atoi (optarg);
|
||||
if (width < 1)
|
||||
error (1, 0, _("%s: invalid line width"), optarg);
|
||||
{
|
||||
long int tmp_long;
|
||||
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long <= 0 || tmp_long > INT_MAX)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid number of columns: `%s'"), optarg);
|
||||
width = (int) tmp_long;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -286,8 +309,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fold - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("fold - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -300,9 +323,9 @@ main (int argc, char **argv)
|
||||
errs |= fold_file (argv[i], width);
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (1, errno, "-");
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
if (fclose (stdout) == EOF)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (errs);
|
||||
exit (errs == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
# 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 <djm@gnu.ai.mit.edu>.
|
||||
|
||||
@@ -31,11 +31,11 @@ Same as id -Gn. If no USERNAME, use current process."
|
||||
|
||||
case $# in
|
||||
1 )
|
||||
case "z${1}" in
|
||||
case "z${1}" in
|
||||
z--help )
|
||||
echo "$usage"; exit 0 ;;
|
||||
z--version )
|
||||
echo "groups - @VERSION@"; exit 0 ;;
|
||||
echo "groups - @PKG_VERSION@"; exit 0 ;;
|
||||
* ) ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
33
src/head.c
33
src/head.c
@@ -1,5 +1,5 @@
|
||||
/* head -- output first part of file(s)
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 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
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Number of lines/chars/blocks to head. */
|
||||
@@ -60,10 +59,10 @@ char *program_name;
|
||||
/* Have we ever read standard input? */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output then exit. */
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -96,7 +95,7 @@ With more than one FILE, precede each with a header giving the file name.\n\
|
||||
With no FILE, or when FILE is -, read standard input.\n\
|
||||
\n\
|
||||
-c, --bytes=SIZE print first SIZE bytes\n\
|
||||
-n, --lines=NUMBER print first NUMBER lines instead of first 10\n\
|
||||
-n, --lines=NUMBER print first NUMBER lines instead of first 10\n\
|
||||
-q, --quiet, --silent never print headers giving file names\n\
|
||||
-v, --verbose always print headers giving file names\n\
|
||||
--help display this help and exit\n\
|
||||
@@ -107,7 +106,7 @@ If -VALUE is used as first OPTION, read -c VALUE when one of\n\
|
||||
multipliers bkm follows concatenated, else read -n VALUE.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Convert STR, a string of ASCII digits, into an unsigned integer.
|
||||
@@ -176,7 +175,7 @@ head_bytes (const char *filename, int fd, long int bytes_to_write)
|
||||
if (bytes_read > bytes_to_write)
|
||||
bytes_read = bytes_to_write;
|
||||
if (fwrite (buffer, 1, bytes_read, stdout) == 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
bytes_to_write -= bytes_read;
|
||||
}
|
||||
return 0;
|
||||
@@ -204,7 +203,7 @@ head_lines (const char *filename, int fd, long int lines_to_write)
|
||||
if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0)
|
||||
break;
|
||||
if (fwrite (buffer, 1, bytes_to_write, stdout) == 0)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -249,7 +248,7 @@ head_file (const char *filename, long int number)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
enum header_mode header_mode = multiple_files;
|
||||
@@ -258,6 +257,10 @@ main (int argc, char **argv)
|
||||
int c; /* Option character. */
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
have_read_stdin = 0;
|
||||
unit_size = 0;
|
||||
print_headers = 0;
|
||||
@@ -331,7 +334,7 @@ main (int argc, char **argv)
|
||||
/* FIXME: use xstrtoul instead. */
|
||||
number = atou (optarg);
|
||||
if (number == -1)
|
||||
error (1, 0, _("invalid number `%s'"), optarg);
|
||||
error (EXIT_FAILURE, 0, _("invalid number `%s'"), optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
@@ -349,8 +352,8 @@ main (int argc, char **argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("head - %s\n", version_string);
|
||||
exit (0);
|
||||
printf ("head - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
@@ -373,9 +376,9 @@ main (int argc, char **argv)
|
||||
exit_status |= head_file (argv[optind], number);
|
||||
|
||||
if (have_read_stdin && close (0) < 0)
|
||||
error (1, errno, "-");
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
if (fclose (stdout) == EOF)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (exit_status);
|
||||
exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hostname - set or print the name of current host system
|
||||
Copyright (C) 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Jim Meyering <meyering@comco.com> */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -38,9 +37,9 @@ sethostname (name, namelen)
|
||||
{
|
||||
/* Using sysinfo() is the SVR4 mechanism to set a hostname. */
|
||||
int result;
|
||||
|
||||
|
||||
result = sysinfo (SI_SET_HOSTNAME, name, namelen);
|
||||
|
||||
|
||||
return (result == -1 ? result : 0);
|
||||
}
|
||||
|
||||
@@ -53,8 +52,7 @@ char *xgethostname ();
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -74,16 +72,17 @@ Print the hostname of the current system.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *hostname;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "hostname", version_string, usage);
|
||||
parse_long_options (argc, argv, "hostname", PACKAGE_VERSION, usage);
|
||||
|
||||
#ifdef HAVE_SETHOSTNAME
|
||||
if (argc == 2)
|
||||
|
||||
132
src/id.c
132
src/id.c
@@ -1,5 +1,5 @@
|
||||
/* id -- print real and effective UIDs and GIDs
|
||||
Copyright (C) 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 Arnold Robbins, arnold@audiofax.com.
|
||||
Major rewrite by David MacKenzie, djm@gnu.ai.mit.edu. */
|
||||
@@ -26,16 +26,11 @@
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#include <limits.h>
|
||||
#if !defined(NGROUPS_MAX) || NGROUPS_MAX < 1
|
||||
#undef NGROUPS_MAX
|
||||
#define NGROUPS_MAX sysconf (_SC_NGROUPS_MAX)
|
||||
#endif /* !NGROUPS_MAX */
|
||||
|
||||
#else /* not _POSIX_VERSION */
|
||||
struct passwd *getpwuid ();
|
||||
@@ -45,19 +40,16 @@ gid_t getgid ();
|
||||
uid_t geteuid ();
|
||||
gid_t getegid ();
|
||||
#include <sys/param.h>
|
||||
#if !defined(NGROUPS_MAX) && defined(NGROUPS)
|
||||
#define NGROUPS_MAX NGROUPS
|
||||
#endif /* not NGROUPS_MAX and NGROUPS */
|
||||
#endif /* not _POSIX_VERSION */
|
||||
|
||||
char *xmalloc ();
|
||||
int getugroups ();
|
||||
|
||||
static void print_user ();
|
||||
static void print_group ();
|
||||
static void print_group_list ();
|
||||
static void print_full_info ();
|
||||
static void usage ();
|
||||
static void print_user __P ((int uid));
|
||||
static void print_group __P ((int gid));
|
||||
static void print_group_list __P ((char *username));
|
||||
static void print_full_info __P ((char *username));
|
||||
static void usage __P ((int status));
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -84,10 +76,10 @@ static gid_t rgid, egid;
|
||||
/* The number of errors encountered so far. */
|
||||
static int problems = 0;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -102,14 +94,15 @@ static struct option const longopts[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "gnruG", longopts, (int *) 0))
|
||||
!= EOF)
|
||||
@@ -140,7 +133,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("id - %s\n", version_string);
|
||||
printf ("id - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -188,8 +181,7 @@ main (argc, argv)
|
||||
/* Print the name or value of user ID UID. */
|
||||
|
||||
static void
|
||||
print_user (uid)
|
||||
int uid;
|
||||
print_user (int uid)
|
||||
{
|
||||
struct passwd *pwd = NULL;
|
||||
|
||||
@@ -209,8 +201,7 @@ print_user (uid)
|
||||
/* Print the name or value of group ID GID. */
|
||||
|
||||
static void
|
||||
print_group (gid)
|
||||
int gid;
|
||||
print_group (int gid)
|
||||
{
|
||||
struct group *grp = NULL;
|
||||
|
||||
@@ -227,11 +218,44 @@ print_group (gid)
|
||||
printf ("%s", grp->gr_name);
|
||||
}
|
||||
|
||||
/* Print all of the distinct groups the user is in . */
|
||||
static int
|
||||
xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
{
|
||||
int max_n_groups;
|
||||
int ng;
|
||||
GETGROUPS_T *g;
|
||||
int fail = 0;
|
||||
|
||||
if (username == 0)
|
||||
max_n_groups = getgroups (0, NULL);
|
||||
else
|
||||
max_n_groups = getugroups (0, NULL, username);
|
||||
|
||||
/* Add 1 just in case max_n_groups is zero. */
|
||||
g = (GETGROUPS_T *) xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1);
|
||||
if (username == 0)
|
||||
ng = getgroups (max_n_groups, g);
|
||||
else
|
||||
ng = getugroups (max_n_groups, g, username);
|
||||
|
||||
if (ng < 0)
|
||||
{
|
||||
error (0, errno, _("cannot get supplemental group list"));
|
||||
++fail;
|
||||
free (groups);
|
||||
}
|
||||
if (!fail)
|
||||
{
|
||||
*n_groups = ng;
|
||||
*groups = g;
|
||||
}
|
||||
return fail;
|
||||
}
|
||||
|
||||
/* Print all of the distinct groups the user is in. */
|
||||
|
||||
static void
|
||||
print_group_list (username)
|
||||
char *username;
|
||||
print_group_list (char *username)
|
||||
{
|
||||
print_group (rgid);
|
||||
if (egid != rgid)
|
||||
@@ -240,26 +264,19 @@ print_group_list (username)
|
||||
print_group (egid);
|
||||
}
|
||||
|
||||
#if defined(NGROUPS_MAX) && defined(HAVE_GETGROUPS)
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
int ngroups;
|
||||
int n_groups;
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
groups = (GETGROUPS_T *) xmalloc (NGROUPS_MAX * sizeof (GETGROUPS_T));
|
||||
if (username == 0)
|
||||
ngroups = getgroups (NGROUPS_MAX, groups);
|
||||
else
|
||||
ngroups = getugroups (NGROUPS_MAX, groups, username);
|
||||
if (ngroups < 0)
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
{
|
||||
error (0, errno, _("cannot get supplemental group list"));
|
||||
problems++;
|
||||
free (groups);
|
||||
++problems;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ngroups; i++)
|
||||
for (i = 0; i < n_groups; i++)
|
||||
if (groups[i] != rgid && groups[i] != egid)
|
||||
{
|
||||
putchar (' ');
|
||||
@@ -273,8 +290,7 @@ print_group_list (username)
|
||||
/* Print all of the info about the user's user and group IDs. */
|
||||
|
||||
static void
|
||||
print_full_info (username)
|
||||
char *username;
|
||||
print_full_info (char *username)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
struct group *grp;
|
||||
@@ -285,14 +301,14 @@ print_full_info (username)
|
||||
problems++;
|
||||
else
|
||||
printf ("(%s)", pwd->pw_name);
|
||||
|
||||
|
||||
printf (" gid=%u", (unsigned) rgid);
|
||||
grp = getgrgid (rgid);
|
||||
if (grp == NULL)
|
||||
problems++;
|
||||
else
|
||||
printf ("(%s)", grp->gr_name);
|
||||
|
||||
|
||||
if (euid != ruid)
|
||||
{
|
||||
printf (" euid=%u", (unsigned) euid);
|
||||
@@ -302,7 +318,7 @@ print_full_info (username)
|
||||
else
|
||||
printf ("(%s)", pwd->pw_name);
|
||||
}
|
||||
|
||||
|
||||
if (egid != rgid)
|
||||
{
|
||||
printf (" egid=%u", (unsigned) egid);
|
||||
@@ -313,28 +329,21 @@ print_full_info (username)
|
||||
printf ("(%s)", grp->gr_name);
|
||||
}
|
||||
|
||||
#if defined(NGROUPS_MAX) && defined(HAVE_GETGROUPS)
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
int ngroups;
|
||||
int n_groups;
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
groups = (GETGROUPS_T *) xmalloc (NGROUPS_MAX * sizeof (GETGROUPS_T));
|
||||
if (username == 0)
|
||||
ngroups = getgroups (NGROUPS_MAX, groups);
|
||||
else
|
||||
ngroups = getugroups (NGROUPS_MAX, groups, username);
|
||||
if (ngroups < 0)
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
{
|
||||
error (0, errno, _("cannot get supplemental group list"));
|
||||
problems++;
|
||||
free (groups);
|
||||
++problems;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ngroups > 0)
|
||||
if (n_groups > 0)
|
||||
fputs (_(" groups="), stdout);
|
||||
for (i = 0; i < ngroups; i++)
|
||||
for (i = 0; i < n_groups; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
putchar (',');
|
||||
@@ -351,8 +360,7 @@ print_full_info (username)
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
|
||||
210
src/install.c
210
src/install.c
@@ -1,5 +1,5 @@
|
||||
/* install - copy files and set attributes
|
||||
Copyright (C) 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Copy files and set their permission modes and, if possible,
|
||||
their owner and group. Used similarly to `cp'; typically
|
||||
@@ -60,13 +60,22 @@
|
||||
#include <grp.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "backupfile.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_VALUES_H
|
||||
# include <values.h>
|
||||
#endif
|
||||
|
||||
#ifndef BITSPERBYTE
|
||||
# define BITSPERBYTE 8
|
||||
#endif
|
||||
|
||||
struct passwd *getpwnam ();
|
||||
@@ -92,20 +101,31 @@ int wait ();
|
||||
/* Number of bytes of a file to copy at a time. */
|
||||
#define READ_SIZE (32 * 1024)
|
||||
|
||||
#ifndef UID_T_MAX
|
||||
# define UID_T_MAX ((uid_t)(~((unsigned long)1 << ((sizeof (uid_t) \
|
||||
* BITSPERBYTE - 1)))))
|
||||
#endif
|
||||
|
||||
#ifndef GID_T_MAX
|
||||
# define GID_T_MAX ((gid_t)(~((unsigned long)1 << ((sizeof (gid_t) \
|
||||
* BITSPERBYTE - 1)))))
|
||||
#endif
|
||||
|
||||
char *basename ();
|
||||
char *stpcpy ();
|
||||
char *xmalloc ();
|
||||
int safe_read ();
|
||||
int full_write ();
|
||||
int isdir ();
|
||||
enum backup_type get_version ();
|
||||
|
||||
static int change_attributes ();
|
||||
static int copy_file ();
|
||||
static int install_file_in_dir ();
|
||||
static int install_file_in_file ();
|
||||
static void get_ids ();
|
||||
static void strip ();
|
||||
static void usage ();
|
||||
static int change_attributes __P ((char *path, int no_need_to_chown));
|
||||
static int copy_file __P ((char *from, char *to, int *to_created));
|
||||
static int install_file_in_dir __P ((char *from, char *to_dir));
|
||||
static int install_file_in_file __P ((char *from, char *to));
|
||||
static void get_ids __P ((void));
|
||||
static void strip __P ((char *path));
|
||||
static void usage __P ((int status));
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
@@ -134,10 +154,10 @@ static int strip_files;
|
||||
/* If nonzero, install a directory instead of a regular file. */
|
||||
static int dir_arg;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -147,21 +167,27 @@ static struct option const long_options[] =
|
||||
{"group", required_argument, NULL, 'g'},
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"owner", required_argument, NULL, 'o'},
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
int errors = 0;
|
||||
char *symbolic_mode = NULL;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
owner_name = NULL;
|
||||
group_name = NULL;
|
||||
mode = 0755;
|
||||
@@ -169,13 +195,21 @@ main (argc, argv)
|
||||
dir_arg = 0;
|
||||
umask (0);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "csdg:m:o:", long_options,
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (version)
|
||||
simple_backup_suffix = version;
|
||||
version = getenv ("VERSION_CONTROL");
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcsdg:m:o:V:S:", long_options,
|
||||
(int *) 0)) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'b':
|
||||
make_backups = 1;
|
||||
break;
|
||||
case 'c':
|
||||
break;
|
||||
case 's':
|
||||
@@ -193,6 +227,12 @@ main (argc, argv)
|
||||
case 'o':
|
||||
owner_name = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
simple_backup_suffix = optarg;
|
||||
break;
|
||||
case 'V':
|
||||
version = optarg;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
@@ -200,7 +240,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("install - %s\n", version_string);
|
||||
printf ("install - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -210,11 +250,14 @@ main (argc, argv)
|
||||
/* Check for invalid combinations of arguments. */
|
||||
if (dir_arg && strip_files)
|
||||
error (1, 0,
|
||||
"the strip option may not be used when installing a directory");
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
|
||||
if (optind == argc || (optind == argc - 1 && !dir_arg))
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -222,9 +265,9 @@ main (argc, argv)
|
||||
{
|
||||
struct mode_change *change = mode_compile (symbolic_mode, 0);
|
||||
if (change == MODE_INVALID)
|
||||
error (1, 0, "invalid mode `%s'", symbolic_mode);
|
||||
error (1, 0, _("invalid mode `%s'"), symbolic_mode);
|
||||
else if (change == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
mode = mode_adjust (0, change);
|
||||
}
|
||||
|
||||
@@ -266,9 +309,7 @@ main (argc, argv)
|
||||
Return 0 if successful, 1 if an error occurs. */
|
||||
|
||||
static int
|
||||
install_file_in_file (from, to)
|
||||
char *from;
|
||||
char *to;
|
||||
install_file_in_file (char *from, char *to)
|
||||
{
|
||||
int to_created;
|
||||
int no_need_to_chown;
|
||||
@@ -288,9 +329,7 @@ install_file_in_file (from, to)
|
||||
Return 0 if successful, 1 if not. */
|
||||
|
||||
static int
|
||||
install_file_in_dir (from, to_dir)
|
||||
char *from;
|
||||
char *to_dir;
|
||||
install_file_in_dir (char *from, char *to_dir)
|
||||
{
|
||||
char *from_base;
|
||||
char *to;
|
||||
@@ -309,15 +348,12 @@ static char buffer[READ_SIZE];
|
||||
|
||||
/* Copy file FROM onto file TO, creating TO if necessary.
|
||||
Return 0 if the copy is successful, 1 if not. If the copy is
|
||||
successful, set *TO_CREATED to non-zero if TO was created (if it did
|
||||
successful, set *TO_CREATED to nonzero if TO was created (if it did
|
||||
not exist or did, but was unlinked) and to zero otherwise. If the
|
||||
copy fails, don't modify *TO_CREATED. */
|
||||
|
||||
static int
|
||||
copy_file (from, to, to_created)
|
||||
char *from;
|
||||
char *to;
|
||||
int *to_created;
|
||||
copy_file (char *from, char *to, int *to_created)
|
||||
{
|
||||
int fromfd, tofd;
|
||||
int bytes;
|
||||
@@ -332,22 +368,44 @@ copy_file (from, to, to_created)
|
||||
}
|
||||
if (!S_ISREG (from_stats.st_mode))
|
||||
{
|
||||
error (0, 0, "`%s' is not a regular file", from);
|
||||
error (0, 0, _("`%s' is not a regular file"), from);
|
||||
return 1;
|
||||
}
|
||||
if (stat (to, &to_stats) == 0)
|
||||
{
|
||||
if (!S_ISREG (to_stats.st_mode))
|
||||
{
|
||||
error (0, 0, "`%s' is not a regular file", to);
|
||||
error (0, 0, _("`%s' is not a regular file"), to);
|
||||
return 1;
|
||||
}
|
||||
if (from_stats.st_dev == to_stats.st_dev
|
||||
&& from_stats.st_ino == to_stats.st_ino)
|
||||
{
|
||||
error (0, 0, "`%s' and `%s' are the same file", from, to);
|
||||
error (0, 0, _("`%s' and `%s' are the same file"), from, to);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* The destination file exists. Try to back it up if required. */
|
||||
if (backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (to);
|
||||
char *dst_backup;
|
||||
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
dst_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
strcpy (dst_backup, tmp_backup);
|
||||
free (tmp_backup);
|
||||
if (rename (to, dst_backup))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "cannot backup `%s'", to);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If unlink fails, try to proceed anyway. */
|
||||
if (unlink (to))
|
||||
target_created = 0;
|
||||
@@ -403,13 +461,11 @@ copy_file (from, to, to_created)
|
||||
}
|
||||
|
||||
/* Set the attributes of file or directory PATH.
|
||||
If NO_NEED_TO_CHOWN is non-zero, don't call chown.
|
||||
If NO_NEED_TO_CHOWN is nonzero, don't call chown.
|
||||
Return 0 if successful, 1 if not. */
|
||||
|
||||
static int
|
||||
change_attributes (path, no_need_to_chown)
|
||||
char *path;
|
||||
int no_need_to_chown;
|
||||
change_attributes (char *path, int no_need_to_chown)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -452,8 +508,7 @@ change_attributes (path, no_need_to_chown)
|
||||
it portable would be very difficult. Not worth the effort. */
|
||||
|
||||
static void
|
||||
strip (path)
|
||||
char *path;
|
||||
strip (char *path)
|
||||
{
|
||||
int pid, status;
|
||||
|
||||
@@ -461,11 +516,11 @@ strip (path)
|
||||
switch (pid)
|
||||
{
|
||||
case -1:
|
||||
error (1, errno, "cannot fork");
|
||||
error (1, errno, _("cannot fork"));
|
||||
break;
|
||||
case 0: /* Child. */
|
||||
execlp ("strip", "strip", path, (char *) NULL);
|
||||
error (1, errno, "cannot run strip");
|
||||
error (1, errno, _("cannot run strip"));
|
||||
break;
|
||||
default: /* Parent. */
|
||||
/* Parent process. */
|
||||
@@ -475,25 +530,10 @@ strip (path)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return nonzero if STR is an ASCII representation of a nonzero
|
||||
decimal integer, zero if not. */
|
||||
|
||||
static int
|
||||
is_number (str)
|
||||
char *str;
|
||||
{
|
||||
if (*str == 0)
|
||||
return 0;
|
||||
for (; *str; str++)
|
||||
if (!ISDIGIT (*str))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize the user and group ownership of the files to install. */
|
||||
|
||||
static void
|
||||
get_ids ()
|
||||
get_ids (void)
|
||||
{
|
||||
struct passwd *pw;
|
||||
struct group *gr;
|
||||
@@ -503,11 +543,11 @@ get_ids ()
|
||||
pw = getpwnam (owner_name);
|
||||
if (pw == NULL)
|
||||
{
|
||||
if (!is_number (owner_name))
|
||||
error (1, 0, "invalid user `%s'", owner_name);
|
||||
/* FIXME: atoi won't warn about overflow. Use xstrtoul. */
|
||||
/* FIXME: eliminate is_number altogether! */
|
||||
owner_id = atoi (owner_name);
|
||||
long int tmp_long;
|
||||
if (xstrtol (owner_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > UID_T_MAX)
|
||||
error (1, 0, _("invalid user `%s'"), owner_name);
|
||||
owner_id = (uid_t) tmp_long;
|
||||
}
|
||||
else
|
||||
owner_id = pw->pw_uid;
|
||||
@@ -521,10 +561,11 @@ get_ids ()
|
||||
gr = getgrnam (group_name);
|
||||
if (gr == NULL)
|
||||
{
|
||||
if (!is_number (group_name))
|
||||
error (1, 0, "invalid group `%s'", group_name);
|
||||
/* FIXME: atoi won't warn about overflow. Use xstrtoul. */
|
||||
group_id = atoi (group_name);
|
||||
long int tmp_long;
|
||||
if (xstrtol (group_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > (long) GID_T_MAX)
|
||||
error (1, 0, _("invalid group `%s'"), group_name);
|
||||
group_id = (gid_t) tmp_long;
|
||||
}
|
||||
else
|
||||
group_id = gr->gr_gid;
|
||||
@@ -535,21 +576,20 @@ get_ids ()
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("\
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... SOURCE DEST (1st format)\n\
|
||||
or: %s [OPTION]... SOURCE... DIRECTORY (2nd format)\n\
|
||||
or: %s -d [OPTION]... DIRECTORY... (3nd format)\n\
|
||||
",
|
||||
or: %s -d [OPTION]... DIRECTORY... (3rd format)\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
printf ("\
|
||||
printf (_("\
|
||||
In first two formats, copy SOURCE to DEST or multiple SOURCE(s) to\n\
|
||||
DIRECTORY, while setting permission modes and owner/group. In third\n\
|
||||
format, make all components of the given DIRECTORY(ies).\n\
|
||||
@@ -560,8 +600,20 @@ format, make all components of the given DIRECTORY(ies).\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), instead of rw-r--r--\n\
|
||||
-o, --owner=OWNER set ownership (super-user only)\n\
|
||||
-s, --strip strip symbol tables, only for 1st and 2nd formats\n\
|
||||
-b, --backup make backup before removal\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
"));
|
||||
printf (_("\
|
||||
The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
|
||||
version control may be set with VERSION_CONTROL, values are:\n\
|
||||
\n\
|
||||
t, numbered make numbered backups\n\
|
||||
nil, existing numbered if numbered backups exist, simple otherwise\n\
|
||||
never, simple always make simple backups\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
97
src/join.c
97
src/join.c
@@ -1,5 +1,5 @@
|
||||
/* join - join lines of two files on a common field
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 95, 1996 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
|
||||
@@ -54,11 +54,17 @@ char *alloca ();
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#if _LIBC || STDC_HEADERS
|
||||
# define TOLOWER(c) tolower (c)
|
||||
#else
|
||||
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "long-options.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
#include "memcasecmp.h"
|
||||
|
||||
#define join system_join
|
||||
|
||||
@@ -141,6 +147,7 @@ static char tab;
|
||||
a character that is a short option. */
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"ignore-case", no_argument, NULL, 'i'},
|
||||
{"j", required_argument, NULL, 'j'},
|
||||
{"j1", required_argument, NULL, '1'},
|
||||
{"j2", required_argument, NULL, '2'},
|
||||
@@ -150,6 +157,9 @@ static struct option const longopts[] =
|
||||
/* Used to print non-joining lines */
|
||||
static struct line uni_blank;
|
||||
|
||||
/* If nonzero, ignore case when comparing join fields. */
|
||||
static int ignore_case;
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -169,6 +179,7 @@ by whitespace. When FILE1 or FILE2 (not both) is -, read standard input.\n\
|
||||
\n\
|
||||
-a SIDE print unpairable lines coming from file SIDE\n\
|
||||
-e EMPTY replace missing input fields with EMPTY\n\
|
||||
-i, --ignore-case ignore differences in case when comparing fields\n\
|
||||
-j FIELD (Obsolescent) equivalent to `-1 FIELD -2 FIELD'\n\
|
||||
-j1 FIELD (Obsolescent) equivalent to `-1 FIELD'\n\
|
||||
-j2 FIELD (Obsolescent) equivalent to `-2 FIELD'\n\
|
||||
@@ -188,7 +199,7 @@ the remaining fields from FILE1, the remaining fields from FILE2, all\n\
|
||||
separated by CHAR.\n\
|
||||
"));
|
||||
}
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -217,6 +228,13 @@ xfields (struct line *line)
|
||||
ptr = line->beg;
|
||||
lim = line->lim;
|
||||
|
||||
if (!tab)
|
||||
{
|
||||
/* Skip leading blanks before the first field. */
|
||||
while (ptr < lim && ISSPACE (*ptr))
|
||||
++ptr;
|
||||
}
|
||||
|
||||
for (i = 0; ptr < lim; ++i)
|
||||
{
|
||||
if (tab)
|
||||
@@ -373,7 +391,15 @@ keycmp (struct line *line1, struct line *line2)
|
||||
return len2 == 0 ? 0 : -1;
|
||||
if (len2 == 0)
|
||||
return 1;
|
||||
diff = memcmp (beg1, beg2, min (len1, len2));
|
||||
|
||||
/* Use an if-statement here rather than a function variable to
|
||||
avoid portability hassles of getting a non-conflicting declaration
|
||||
of memcmp. */
|
||||
if (ignore_case)
|
||||
diff = memcasecmp (beg1, beg2, min (len1, len2));
|
||||
else
|
||||
diff = memcmp (beg1, beg2, min (len1, len2));
|
||||
|
||||
if (diff)
|
||||
return diff;
|
||||
return len1 - len2;
|
||||
@@ -483,9 +509,7 @@ prjoin (struct line *line1, struct line *line2)
|
||||
/* Print the join of the files in FP1 and FP2. */
|
||||
|
||||
static void
|
||||
join (fp1, fp2)
|
||||
FILE *fp1;
|
||||
FILE *fp2;
|
||||
join (FILE *fp1, FILE *fp2)
|
||||
{
|
||||
struct seq seq1, seq2;
|
||||
struct line line;
|
||||
@@ -620,12 +644,12 @@ add_field (int file, int field)
|
||||
/* Convert a single field specifier string, S, to a *FILE_INDEX, *FIELD_INDEX
|
||||
pair. In S, the field index string is 1-based; *FIELD_INDEX is zero-based.
|
||||
If S is valid, return zero. Otherwise, give a diagnostic, don't update
|
||||
*FILE_INDEX or *FIELD_INDEX, and return non-zero. */
|
||||
*FILE_INDEX or *FIELD_INDEX, and return nonzero. */
|
||||
|
||||
static int
|
||||
decode_field_spec (const char *s, int *file_index, int *field_index)
|
||||
{
|
||||
int valid = 0;
|
||||
int invalid = 1;
|
||||
|
||||
/* The first character must be 0, 1, or 2. */
|
||||
switch (s[0])
|
||||
@@ -635,7 +659,7 @@ decode_field_spec (const char *s, int *file_index, int *field_index)
|
||||
{
|
||||
*file_index = 0;
|
||||
/* Leave *field_index undefined. */
|
||||
valid = 1;
|
||||
invalid = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -661,7 +685,7 @@ decode_field_spec (const char *s, int *file_index, int *field_index)
|
||||
*file_index = s[0] - '0';
|
||||
/* Convert to a zero-based index. */
|
||||
*field_index = (int) tmp_long - 1;
|
||||
valid = 1;
|
||||
invalid = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -670,11 +694,11 @@ decode_field_spec (const char *s, int *file_index, int *field_index)
|
||||
error (0, 0, _("invalid file number in field spec: `%s'"), s);
|
||||
break;
|
||||
}
|
||||
return !valid;
|
||||
return invalid;
|
||||
}
|
||||
|
||||
/* Add the comma or blank separated field spec(s) in STR to `outlist'.
|
||||
Return non-zero to indicate failure. */
|
||||
Return nonzero to indicate failure. */
|
||||
|
||||
static int
|
||||
add_field_list (const char *c_str)
|
||||
@@ -724,7 +748,7 @@ make_blank (struct line *blank, int count)
|
||||
blank->lim = &blank->beg[i];
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *names[2];
|
||||
@@ -732,17 +756,20 @@ main (int argc, char **argv)
|
||||
int optc, prev_optc = 0, nfiles;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* Initialize this before parsing options. In parsing options,
|
||||
it may be increased. */
|
||||
uni_blank.nfields = 1;
|
||||
|
||||
parse_long_options (argc, argv, "join", version_string, usage);
|
||||
parse_long_options (argc, argv, "join", PACKAGE_VERSION, usage);
|
||||
|
||||
nfiles = 0;
|
||||
print_pairables = 1;
|
||||
|
||||
while ((optc = getopt_long_only (argc, argv, "-a:e:1:2:o:t:v:", longopts,
|
||||
while ((optc = getopt_long_only (argc, argv, "-a:e:i1:2:o:t:v:", longopts,
|
||||
(int *) 0)) != EOF)
|
||||
{
|
||||
long int val;
|
||||
@@ -759,7 +786,7 @@ main (int argc, char **argv)
|
||||
case 'a':
|
||||
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| (val != 1 && val != 2))
|
||||
error (2, 0, _("invalid field number: `%s'"), optarg);
|
||||
error (EXIT_FAILURE, 0, _("invalid field number: `%s'"), optarg);
|
||||
if (val == 1)
|
||||
print_unpairables_1 = 1;
|
||||
else
|
||||
@@ -770,11 +797,16 @@ main (int argc, char **argv)
|
||||
empty_filler = optarg;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
ignore_case = 1;
|
||||
break;
|
||||
|
||||
case '1':
|
||||
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val <= 0 || val > INT_MAX)
|
||||
{
|
||||
error (2, 0, _("invalid field number for file 1: `%s'"), optarg);
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid field number for file 1: `%s'"), optarg);
|
||||
}
|
||||
join_field_1 = (int) val - 1;
|
||||
break;
|
||||
@@ -782,20 +814,21 @@ main (int argc, char **argv)
|
||||
case '2':
|
||||
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val <= 0 || val > INT_MAX)
|
||||
error (2, 0, _("invalid field number for file 2: `%s'"), optarg);
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid field number for file 2: `%s'"), optarg);
|
||||
join_field_2 = (int) val - 1;
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
|
||||
|| val <= 0 || val > INT_MAX)
|
||||
error (2, 0, _("invalid field number: `%s'"), optarg);
|
||||
error (EXIT_FAILURE, 0, _("invalid field number: `%s'"), optarg);
|
||||
join_field_1 = join_field_2 = (int) val - 1;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (add_field_list (optarg))
|
||||
exit (1);
|
||||
exit (EXIT_FAILURE);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
@@ -806,7 +839,7 @@ main (int argc, char **argv)
|
||||
if (prev_optc == 'o' && optind <= argc - 2)
|
||||
{
|
||||
if (add_field_list (optarg))
|
||||
exit (1);
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
/* Might be continuation of args to -o. */
|
||||
continue; /* Don't change `prev_optc'. */
|
||||
@@ -814,7 +847,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (nfiles > 1)
|
||||
{
|
||||
error (0, 0, "too many non-option arguments");
|
||||
error (0, 0, _("too many non-option arguments"));
|
||||
usage (1);
|
||||
}
|
||||
names[nfiles++] = optarg;
|
||||
@@ -832,28 +865,28 @@ main (int argc, char **argv)
|
||||
|
||||
if (nfiles != 2)
|
||||
{
|
||||
error (0, 0, "too few non-option arguments");
|
||||
error (0, 0, _("too few non-option arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
fp1 = strcmp (names[0], "-") ? fopen (names[0], "r") : stdin;
|
||||
if (!fp1)
|
||||
error (1, errno, "%s", names[0]);
|
||||
error (EXIT_FAILURE, errno, "%s", names[0]);
|
||||
fp2 = strcmp (names[1], "-") ? fopen (names[1], "r") : stdin;
|
||||
if (!fp2)
|
||||
error (1, errno, "%s", names[1]);
|
||||
error (EXIT_FAILURE, errno, "%s", names[1]);
|
||||
if (fp1 == fp2)
|
||||
error (1, errno, _("both files cannot be standard input"));
|
||||
error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
|
||||
join (fp1, fp2);
|
||||
|
||||
if (fp1 != stdin && fclose (fp1) == EOF)
|
||||
error (1, errno, "%s", names[0]);
|
||||
error (EXIT_FAILURE, errno, "%s", names[0]);
|
||||
if (fp2 != stdin && fclose (fp2) == EOF)
|
||||
error (1, errno, "%s", names[1]);
|
||||
error (EXIT_FAILURE, errno, "%s", names[1]);
|
||||
if ((fp1 == stdin || fp2 == stdin) && fclose (stdin) == EOF)
|
||||
error (1, errno, "-");
|
||||
error (EXIT_FAILURE, errno, "-");
|
||||
if (ferror (stdout) || fclose (stdout) == EOF)
|
||||
error (1, errno, _("write error"));
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
exit (0);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
460
src/ln.c
460
src/ln.c
@@ -1,5 +1,5 @@
|
||||
/* `ln' program to create links between files.
|
||||
Copyright (C) 1986, 1989, 1990, 1991, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
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 Mike Parker and David MacKenzie. */
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
int link (); /* Some systems don't declare this anywhere. */
|
||||
@@ -37,6 +36,12 @@ int link (); /* Some systems don't declare this anywhere. */
|
||||
int symlink ();
|
||||
#endif
|
||||
|
||||
#ifdef S_ISLNK
|
||||
# define LINK_TYPE symbolic_link ? _("symbolic link") : _("hard link")
|
||||
#else
|
||||
# define LINK_TYPE ""
|
||||
#endif
|
||||
|
||||
/* Construct a string NEW_DEST by concatenating DEST, a slash, and
|
||||
basename(SOURCE) in alloca'd memory. Don't modify DEST or SOURCE. */
|
||||
|
||||
@@ -58,15 +63,13 @@ int symlink ();
|
||||
while (0)
|
||||
|
||||
char *basename ();
|
||||
char *dirname ();
|
||||
enum backup_type get_version ();
|
||||
int isdir ();
|
||||
int yesno ();
|
||||
void strip_trailing_slashes ();
|
||||
char *stpcpy ();
|
||||
|
||||
static void usage ();
|
||||
static int do_link ();
|
||||
|
||||
/* The name by which the program was run, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
@@ -95,10 +98,10 @@ static int hard_dir_link;
|
||||
symlink-to-dir before creating the new link. */
|
||||
static int dereference_dest_dir_symlinks = 1;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -117,27 +120,261 @@ static struct option const long_options[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
/* Return nonzero if SOURCE and DEST point to the same name in the same
|
||||
directory. */
|
||||
|
||||
static int
|
||||
same_name (const char *source, const char *dest)
|
||||
{
|
||||
struct stat source_dir_stats;
|
||||
struct stat dest_dir_stats;
|
||||
char *source_dirname, *dest_dirname;
|
||||
|
||||
source_dirname = dirname (source);
|
||||
dest_dirname = dirname (dest);
|
||||
if (source_dirname == NULL || dest_dirname == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
if (stat (source_dirname, &source_dir_stats))
|
||||
/* Shouldn't happen. */
|
||||
error (1, errno, "%s", source_dirname);
|
||||
|
||||
if (stat (dest_dirname, &dest_dir_stats))
|
||||
/* Shouldn't happen. */
|
||||
error (1, errno, "%s", dest_dirname);
|
||||
|
||||
free (source_dirname);
|
||||
free (dest_dirname);
|
||||
|
||||
return (source_dir_stats.st_dev == dest_dir_stats.st_dev
|
||||
&& source_dir_stats.st_ino == dest_dir_stats.st_ino
|
||||
&& STREQ (basename (source), basename (dest)));
|
||||
}
|
||||
|
||||
/* Make a link DEST to the (usually) existing file SOURCE.
|
||||
Symbolic links to nonexistent files are allowed.
|
||||
If DEST is a directory, put the link to SOURCE in that directory.
|
||||
Return 1 if there is an error, otherwise 0. */
|
||||
|
||||
static int
|
||||
do_link (const char *source, const char *dest)
|
||||
{
|
||||
struct stat source_stats;
|
||||
struct stat dest_stats;
|
||||
char *dest_backup = NULL;
|
||||
int lstat_status;
|
||||
|
||||
/* Use stat here instead of lstat.
|
||||
On SVR4, link does not follow symlinks, so this check disallows
|
||||
making hard links to symlinks that point to directories. Big deal.
|
||||
On other systems, link follows symlinks, so this check is right. */
|
||||
if (!symbolic_link)
|
||||
{
|
||||
if (stat (source, &source_stats) != 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
return 1;
|
||||
}
|
||||
if (!hard_dir_link && S_ISDIR (source_stats.st_mode))
|
||||
{
|
||||
error (0, 0, _("%s: hard link not allowed for directory"), source);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
lstat_status = lstat (dest, &dest_stats);
|
||||
|
||||
if (lstat_status != 0 && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If --force (-f) has been specified without --backup, then before
|
||||
making a link ln must remove the destination file if it exists.
|
||||
(with --backup, it just renames any existing destination file)
|
||||
But if the source and destination are the same, don't remove
|
||||
anything and fail right here. */
|
||||
if (remove_existing_files
|
||||
&& lstat_status == 0
|
||||
/* Allow `ln -sf --backup k k' to succeed in creating the
|
||||
self-referential symlink, but don't allow the hard-linking
|
||||
equivalent: `ln -f k k' (with or without --backup) to get
|
||||
beyond this point, because the error message you'd get is
|
||||
misleading. */
|
||||
&& (backup_type == none || !symlink)
|
||||
&& (!symlink || stat (source, &source_stats) == 0)
|
||||
&& source_stats.st_dev == dest_stats.st_dev
|
||||
&& source_stats.st_ino == dest_stats.st_ino
|
||||
/* The following detects whether removing DEST will also remove
|
||||
SOURCE. If the file has only one link then both are surely
|
||||
the same link. Otherwise check whether they point to the same
|
||||
name in the same directory. */
|
||||
&& (source_stats.st_nlink == 1 || same_name (source, dest)))
|
||||
{
|
||||
error (0, 0, _("`%s' and `%s' are the same file"), source, dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If the destination is a directory or (it is a symlink to a directory
|
||||
and the user has not specified --no-dereference), then form the
|
||||
actual destination name by appending basename (source) to the
|
||||
specified destination directory. */
|
||||
if ((lstat_status == 0
|
||||
&& S_ISDIR (dest_stats.st_mode))
|
||||
#ifdef S_ISLNK
|
||||
|| (dereference_dest_dir_symlinks
|
||||
&& (S_ISLNK (dest_stats.st_mode)
|
||||
&& isdir (dest)))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* Target is a directory; build the full filename. */
|
||||
char *new_dest;
|
||||
PATH_BASENAME_CONCAT (new_dest, dest, source);
|
||||
dest = new_dest;
|
||||
/* Set this to nonzero to force another call to lstat
|
||||
with the new destination. */
|
||||
lstat_status = 1;
|
||||
}
|
||||
|
||||
if (lstat_status == 0 || lstat (dest, &dest_stats) == 0)
|
||||
{
|
||||
if (S_ISDIR (dest_stats.st_mode))
|
||||
{
|
||||
error (0, 0, _("%s: cannot overwrite directory"), dest);
|
||||
return 1;
|
||||
}
|
||||
if (interactive)
|
||||
{
|
||||
fprintf (stderr, _("%s: replace `%s'? "), program_name, dest);
|
||||
if (!yesno ())
|
||||
return 0;
|
||||
}
|
||||
else if (!remove_existing_files)
|
||||
{
|
||||
error (0, 0, _("%s: File exists"), dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dest);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
dest_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
strcpy (dest_backup, tmp_backup);
|
||||
free (tmp_backup);
|
||||
if (rename (dest, dest_backup))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("cannot backup `%s'"), dest);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
dest_backup = NULL;
|
||||
}
|
||||
}
|
||||
else if (unlink (dest) && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("cannot remove `%s'"), dest);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf (_("create %s %s to %s\n"), LINK_TYPE,
|
||||
dest, source);
|
||||
|
||||
if ((*linkfunc) (source, dest) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
error (0, errno, _("cannot create %s `%s' to `%s'"), LINK_TYPE,
|
||||
dest, source);
|
||||
|
||||
if (dest_backup)
|
||||
{
|
||||
if (rename (dest_backup, dest))
|
||||
error (0, errno, _("cannot un-backup `%s'"), dest);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... SOURCE [DEST]\n\
|
||||
or: %s [OPTION]... SOURCE... DIRECTORY\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf (_("\
|
||||
Link SOURCE to DEST (. by default), or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
Makes hard links by default, symbolic links with -s.\n\
|
||||
\n\
|
||||
-b, --backup make backups for removed files\n\
|
||||
-d, -F, --directory hard link directories (super-user only)\n\
|
||||
-f, --force remove existing destinations\n\
|
||||
-n, --no-dereference treat destination that is a symlink to a\n\
|
||||
directory as if it were a normal file\n\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-s, --symbolic make symbolic links instead of hard links\n\
|
||||
-v, --verbose print name of each file before linking\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
"));
|
||||
printf (_("\
|
||||
The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
|
||||
version control may be set with VERSION_CONTROL, values are:\n\
|
||||
\n\
|
||||
t, numbered make numbered backups\n\
|
||||
nil, existing numbered if numbered backups exist, simple otherwise\n\
|
||||
never, simple always make simple backups\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int errors;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (version)
|
||||
simple_backup_suffix = version;
|
||||
version = getenv ("VERSION_CONTROL");
|
||||
program_name = argv[0];
|
||||
|
||||
linkfunc = link;
|
||||
symbolic_link = remove_existing_files = interactive = verbose
|
||||
= hard_dir_link = 0;
|
||||
errors = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bdfinsvFS:V:", long_options, (int *) 0))
|
||||
while ((c = getopt_long (argc, argv,
|
||||
"bdfinsvFS:V:", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (c)
|
||||
@@ -166,7 +403,7 @@ main (argc, argv)
|
||||
#ifdef S_ISLNK
|
||||
symbolic_link = 1;
|
||||
#else
|
||||
error (1, 0, "symbolic links are not supported on this system");
|
||||
error (1, 0, _("symbolic links are not supported on this system"));
|
||||
#endif
|
||||
break;
|
||||
case 'v':
|
||||
@@ -186,7 +423,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("ln - %s\n", version_string);
|
||||
printf ("ln - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -195,7 +432,7 @@ main (argc, argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, "missing file argument");
|
||||
error (0, 0, _("missing file argument"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -242,195 +479,10 @@ main (argc, argv)
|
||||
|
||||
to = argv[argc - 1];
|
||||
if (!isdir (to))
|
||||
error (1, 0, "when making multiple links, last argument must be a directory");
|
||||
error (1, 0, _("when making multiple links, last argument must be a directory"));
|
||||
for (; optind < argc - 1; ++optind)
|
||||
errors += do_link (argv[optind], to);
|
||||
}
|
||||
|
||||
exit (errors != 0);
|
||||
}
|
||||
|
||||
/* Make a link DEST to the (usually) existing file SOURCE.
|
||||
Symbolic links to nonexistent files are allowed.
|
||||
If DEST is a directory, put the link to SOURCE in that directory.
|
||||
Return 1 if there is an error, otherwise 0. */
|
||||
|
||||
static int
|
||||
do_link (source, dest)
|
||||
char *source;
|
||||
char *dest;
|
||||
{
|
||||
struct stat dest_stats;
|
||||
char *dest_backup = NULL;
|
||||
int lstat_status;
|
||||
|
||||
/* Use stat here instead of lstat.
|
||||
On SVR4, link does not follow symlinks, so this check disallows
|
||||
making hard links to symlinks that point to directories. Big deal.
|
||||
On other systems, link follows symlinks, so this check is right. */
|
||||
if (!symbolic_link)
|
||||
{
|
||||
struct stat source_stats;
|
||||
|
||||
if (stat (source, &source_stats) != 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
return 1;
|
||||
}
|
||||
if (!hard_dir_link && S_ISDIR (source_stats.st_mode))
|
||||
{
|
||||
error (0, 0, "%s: hard link not allowed for directory", source);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat (dest, &dest_stats) != 0 && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If the destination is a directory or (it is a symlink to a directory
|
||||
and the user has not specified --no-dereference), then form the
|
||||
actual destination name by appending basename (source) to the
|
||||
specified destination directory. */
|
||||
lstat_status = lstat (dest, &dest_stats);
|
||||
|
||||
if (lstat_status != 0 && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((lstat_status == 0
|
||||
&& S_ISDIR (dest_stats.st_mode))
|
||||
#ifdef S_ISLNK
|
||||
|| (dereference_dest_dir_symlinks
|
||||
&& (S_ISLNK (dest_stats.st_mode)
|
||||
&& isdir (dest)))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* Target is a directory; build the full filename. */
|
||||
char *new_dest;
|
||||
PATH_BASENAME_CONCAT (new_dest, dest, source);
|
||||
dest = new_dest;
|
||||
/* Set this to non-zero to force another call to lstat
|
||||
with the new destination. */
|
||||
lstat_status = 1;
|
||||
}
|
||||
|
||||
if (lstat_status == 0 || lstat (dest, &dest_stats) == 0)
|
||||
{
|
||||
if (S_ISDIR (dest_stats.st_mode))
|
||||
{
|
||||
error (0, 0, "%s: cannot overwrite directory", dest);
|
||||
return 1;
|
||||
}
|
||||
if (interactive)
|
||||
{
|
||||
fprintf (stderr, "%s: replace `%s'? ", program_name, dest);
|
||||
if (!yesno ())
|
||||
return 0;
|
||||
}
|
||||
else if (!remove_existing_files)
|
||||
{
|
||||
error (0, 0, "%s: File exists", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dest);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
dest_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
strcpy (dest_backup, tmp_backup);
|
||||
free (tmp_backup);
|
||||
if (rename (dest, dest_backup))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "cannot backup `%s'", dest);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
dest_backup = NULL;
|
||||
}
|
||||
}
|
||||
else if (unlink (dest) && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "cannot remove `%s'", dest);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf ("%s -> %s\n", source, dest);
|
||||
|
||||
if ((*linkfunc) (source, dest) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
error (0, errno, "cannot %slink `%s' to `%s'",
|
||||
#ifdef S_ISLNK
|
||||
symbolic_link ? "symbolic " : "",
|
||||
#else
|
||||
"",
|
||||
#endif
|
||||
source, dest);
|
||||
|
||||
if (dest_backup)
|
||||
{
|
||||
if (rename (dest_backup, dest))
|
||||
error (0, errno, "cannot un-backup `%s'", dest);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... SOURCE [DEST]\n\
|
||||
or: %s [OPTION]... SOURCE... DIRECTORY\n\
|
||||
",
|
||||
program_name, program_name);
|
||||
printf ("\
|
||||
Link SOURCE to DEST (. by default), or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
Makes hard links by default, symbolic links with -s.\n\
|
||||
\n\
|
||||
-b, --backup make backups for removed files\n\
|
||||
-d, -F, --directory hard link directories (super-user only)\n\
|
||||
-f, --force remove existing destinations\n\
|
||||
-n, --no-dereference with --force, remove destination that is a\n\
|
||||
symlink to a directory\n\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-s, --symbolic make symbolic links instead of hard links\n\
|
||||
-v, --verbose print name of each file before linking\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
|
||||
version control may be set with VERSION_CONTROL, values are:\n\
|
||||
\n\
|
||||
t, numbered make numbered backups\n\
|
||||
nil, existing numbered if numbered backups exist, simple otherwise\n\
|
||||
never, simple always make simple backups\n");
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* logname -- print user's login name
|
||||
Copyright (C) 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,24 +12,23 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "system.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -40,8 +39,7 @@ static struct option const long_options[] =
|
||||
};
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
@@ -59,15 +57,16 @@ Print the name of the current user.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
register char *cp;
|
||||
int c;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
|
||||
{
|
||||
@@ -83,7 +82,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("logname - %s\n", version_string);
|
||||
printf ("logname - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
185
src/md5sum.c
185
src/md5sum.c
@@ -1,6 +1,6 @@
|
||||
/* Compute MD5 checksum of files or strings according to the definition
|
||||
of MD5 in RFC 1321 from April 1992.
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 95, 1996 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
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "getline.h"
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "version.h"
|
||||
|
||||
/* Most systems do not distinguish between external and internal
|
||||
text representations. */
|
||||
@@ -60,6 +59,13 @@
|
||||
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
|
||||
#endif
|
||||
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum --check'. This length does
|
||||
not include any newline character at the end of a line. */
|
||||
#define MIN_DIGEST_LINE_LENGTH (32 /* message digest length */ \
|
||||
+ 2 /* blank and binary indicator */ \
|
||||
+ 1 /* minimum filename length */ )
|
||||
|
||||
/* Nonzero if any of the files read were the standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
@@ -116,19 +122,17 @@ The following two options are useful only when verifying checksums:\n\
|
||||
The sums are computed as described in RFC 1321. When checking, the input\n\
|
||||
should be a former output of this program. The default mode is to print\n\
|
||||
a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
|
||||
text), and name for each FILE. The --status and --warn options are\n\
|
||||
meaningful only when verifying checksums.\n"),
|
||||
text), and name for each FILE.\n"),
|
||||
program_name, program_name, program_name);
|
||||
|
||||
exit (status);
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* FIXME: this format loses with filenames containing newline. */
|
||||
|
||||
static int
|
||||
split_3 (char *s, char **u, int *binary, char **w)
|
||||
split_3 (char *s, size_t s_len, char **u, int *binary, char **w)
|
||||
{
|
||||
size_t i;
|
||||
int filename_has_newline = 0;
|
||||
|
||||
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
|
||||
|
||||
@@ -136,34 +140,82 @@ split_3 (char *s, char **u, int *binary, char **w)
|
||||
while (ISWHITE (s[i]))
|
||||
++i;
|
||||
|
||||
/* The line has to be at least 35 characters long to contain correct
|
||||
message digest information. */
|
||||
if (strlen (&s[i]) >= 35)
|
||||
/* The line must have at least 35 (36 if the first is a backslash)
|
||||
more characters to contain correct message digest information.
|
||||
Ignore this line if it is too short. */
|
||||
if (!(s_len - i >= MIN_DIGEST_LINE_LENGTH
|
||||
|| (s[i] == '\\' && s_len - i >= 1 + MIN_DIGEST_LINE_LENGTH)))
|
||||
return 1;
|
||||
|
||||
if (s[i] == '\\')
|
||||
{
|
||||
*u = &s[i];
|
||||
|
||||
/* The first field has to be the 32-character hexadecimal
|
||||
representation of the message digest. If it not immediately
|
||||
followed by a white space it's an error. */
|
||||
i += 32;
|
||||
if (!ISWHITE (s[i]))
|
||||
return 1;
|
||||
|
||||
s[i++] = '\0';
|
||||
|
||||
if (s[i] != ' ' && s[i] != '*')
|
||||
return 1;
|
||||
*binary = s[i++] == '*';
|
||||
|
||||
/* All characters between the type indicator and end of line are
|
||||
significant -- that includes leading and trailing white space. */
|
||||
*w = &s[i];
|
||||
|
||||
/* So this line is valid as long as there is at least one character
|
||||
for the filename. */
|
||||
return (**w ? 0 : 1);
|
||||
++i;
|
||||
filename_has_newline = 1;
|
||||
}
|
||||
return 1;
|
||||
*u = &s[i];
|
||||
|
||||
/* The first field has to be the 32-character hexadecimal
|
||||
representation of the message digest. If it is not followed
|
||||
immediately by a white space it's an error. */
|
||||
i += 32;
|
||||
if (!ISWHITE (s[i]))
|
||||
return 1;
|
||||
|
||||
s[i++] = '\0';
|
||||
|
||||
if (s[i] != ' ' && s[i] != '*')
|
||||
return 1;
|
||||
*binary = (s[i++] == '*');
|
||||
|
||||
/* All characters between the type indicator and end of line are
|
||||
significant -- that includes leading and trailing white space. */
|
||||
*w = &s[i];
|
||||
|
||||
if (filename_has_newline)
|
||||
{
|
||||
/* Translate each `\n' string in the file name to a NEWLINE,
|
||||
and each `\\' string to a backslash. */
|
||||
|
||||
char *dst = &s[i];
|
||||
|
||||
while (i < s_len)
|
||||
{
|
||||
switch (s[i])
|
||||
{
|
||||
case '\\':
|
||||
if (i == s_len - 1)
|
||||
{
|
||||
/* A valid line does not end with a backslash. */
|
||||
return 1;
|
||||
}
|
||||
++i;
|
||||
switch (s[i++])
|
||||
{
|
||||
case 'n':
|
||||
*dst++ = '\n';
|
||||
break;
|
||||
case '\\':
|
||||
*dst++ = '\\';
|
||||
break;
|
||||
default:
|
||||
/* Only `\' or `n' may follow a backslash. */
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
/* The file name may not contain a NUL. */
|
||||
return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
*dst++ = s[i++];
|
||||
break;
|
||||
}
|
||||
}
|
||||
*dst = '\0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -178,9 +230,9 @@ hex_digits (const char *s)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* FIXME: allow newline in filename by encoding it. */
|
||||
/* FIXME: distinguish between file open/read failure and inconsistent
|
||||
checksum. */
|
||||
/* An interface to md5_stream. Operate on FILENAME (it may be "-") and
|
||||
put the result in *MD5_RESULT. Return non-zero upon failure, zero
|
||||
to indicate success. */
|
||||
|
||||
static int
|
||||
md5_file (const char *filename, int binary, unsigned char *md5_result)
|
||||
@@ -278,7 +330,7 @@ md5_check (const char *checkfile_name, int binary)
|
||||
if (line[line_length - 1] == '\n')
|
||||
line[--line_length] = '\0';
|
||||
|
||||
err = split_3 (line, &md5num, &type_flag, &filename);
|
||||
err = split_3 (line, line_length, &md5num, &type_flag, &filename);
|
||||
if (err || !hex_digits (md5num))
|
||||
{
|
||||
if (warn)
|
||||
@@ -340,7 +392,7 @@ md5_check (const char *checkfile_name, int binary)
|
||||
|
||||
if (ferror (checkfile_stream))
|
||||
{
|
||||
error (0, 0, "%s: read error", checkfile_name);
|
||||
error (0, 0, _("%s: read error"), checkfile_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -366,17 +418,19 @@ md5_check (const char *checkfile_name, int binary)
|
||||
if (n_open_or_read_failures > 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("WARNING: %d of %d listed file%s could not be read\n"),
|
||||
_("WARNING: %d of %d listed %s could not be read\n"),
|
||||
n_open_or_read_failures, n_properly_formated_lines,
|
||||
(n_properly_formated_lines == 1 ? "" : "s"));
|
||||
(n_properly_formated_lines == 1
|
||||
? _("file") : _("files")));
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("WARNING: %d of %d computed checksum%s did NOT match\n"),
|
||||
_("WARNING: %d of %d computed %s did NOT match"),
|
||||
n_mismatched_checksums, n_computed_checkums,
|
||||
(n_computed_checkums == 1 ? "" : "s"));
|
||||
(n_computed_checkums == 1
|
||||
? _("checksum") : _("checksums")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -402,8 +456,11 @@ main (int argc, char **argv)
|
||||
|
||||
/* Setting values of global variables. */
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "md5sum", version_string, usage);
|
||||
parse_long_options (argc, argv, "md5sum", PACKAGE_VERSION, usage);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL))
|
||||
!= EOF)
|
||||
@@ -444,7 +501,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (do_version)
|
||||
{
|
||||
printf ("md5sum - %s\n", version_string);
|
||||
printf ("md5sum - %s\n", PACKAGE_VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -505,17 +562,49 @@ main (int argc, char **argv)
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
{
|
||||
size_t i;
|
||||
int fail;
|
||||
char *file = argv[optind];
|
||||
|
||||
fail = md5_file (argv[optind], binary, md5buffer);
|
||||
fail = md5_file (file, binary, md5buffer);
|
||||
err |= fail;
|
||||
if (!fail)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
/* Output a leading backslash if the file name contains
|
||||
a newline. */
|
||||
if (strchr (file, '\n'))
|
||||
putchar ('\\');
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
|
||||
printf (" %c%s\n", binary ? '*' : ' ', argv[optind]);
|
||||
putchar (' ');
|
||||
if (binary)
|
||||
putchar ('*');
|
||||
else
|
||||
putchar (' ');
|
||||
|
||||
/* Translate each NEWLINE byte to the string, "\\n",
|
||||
and each backslash to "\\\\". */
|
||||
for (i = 0; i < strlen (file); ++i)
|
||||
{
|
||||
switch (file[i])
|
||||
{
|
||||
case '\n':
|
||||
fputs ("\\n", stdout);
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
fputs ("\\\\", stdout);
|
||||
break;
|
||||
|
||||
default:
|
||||
putchar (file[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
88
src/mkdir.c
88
src/mkdir.c
@@ -1,5 +1,5 @@
|
||||
/* mkdir -- make directories
|
||||
Copyright (C) 1990, 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Options:
|
||||
-p, --parent Ensure that the given path(s) exist:
|
||||
@@ -35,45 +35,66 @@
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
static void usage ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, ensure that all parents of the specified directory exist. */
|
||||
static int path_mode;
|
||||
|
||||
/* If non-zero, display usage information and exit. */
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If non-zero, print the version on standard output and exit. */
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"path", no_argument, &path_mode, 1},
|
||||
{"parents", no_argument, &path_mode, 1},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"verbose", no_argument, NULL, 2},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [OPTION] DIRECTORY...\n"), program_name);
|
||||
printf (_("\
|
||||
Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
\n\
|
||||
-p, --parents no error if existing, make parent directories as needed\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask\n\
|
||||
--verbose print a message for each created directory\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n"));
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
unsigned int newmode;
|
||||
unsigned int parent_mode;
|
||||
char *symbolic_mode = NULL;
|
||||
const char *verbose_fmt_string = NULL;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
path_mode = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "pm:", longopts, (int *) 0)) != EOF)
|
||||
@@ -88,6 +109,9 @@ main (argc, argv)
|
||||
case 'm':
|
||||
symbolic_mode = optarg;
|
||||
break;
|
||||
case 2: /* --verbose */
|
||||
verbose_fmt_string = _("created directory `%s'");
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
@@ -95,7 +119,7 @@ main (argc, argv)
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mkdir - %s\n", version_string);
|
||||
printf ("mkdir - %s\n", PACKAGE_VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -104,7 +128,7 @@ main (argc, argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
error (0, 0, _("too few arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -114,9 +138,9 @@ main (argc, argv)
|
||||
{
|
||||
struct mode_change *change = mode_compile (symbolic_mode, 0);
|
||||
if (change == MODE_INVALID)
|
||||
error (1, 0, "invalid mode `%s'", symbolic_mode);
|
||||
error (1, 0, _("invalid mode `%s'"), symbolic_mode);
|
||||
else if (change == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, "virtual memory exhausted");
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
newmode = mode_adjust (newmode, change);
|
||||
}
|
||||
|
||||
@@ -125,36 +149,18 @@ main (argc, argv)
|
||||
if (path_mode)
|
||||
{
|
||||
errors |= make_path (argv[optind], newmode, parent_mode,
|
||||
-1, -1, 1, NULL);
|
||||
-1, -1, 1, verbose_fmt_string);
|
||||
}
|
||||
else if (mkdir (argv[optind], newmode))
|
||||
{
|
||||
error (0, errno, "cannot make directory `%s'", argv[optind]);
|
||||
error (0, errno, _("cannot make directory `%s'"), argv[optind]);
|
||||
errors = 1;
|
||||
}
|
||||
else if (verbose_fmt_string)
|
||||
{
|
||||
error (0, 0, verbose_fmt_string, argv[optind]);
|
||||
}
|
||||
}
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (status)
|
||||
int status;
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION] DIRECTORY...\n", program_name);
|
||||
printf ("\
|
||||
Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
\n\
|
||||
-p, --parents no error if existing, make parent directories as needed\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user