mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
529 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94323ee2a7 | ||
|
|
c250ac3ddc | ||
|
|
badacafb98 | ||
|
|
d0672fcf74 | ||
|
|
91e23a4607 | ||
|
|
60d62033fb | ||
|
|
d02a83cba4 | ||
|
|
359c6f7e38 | ||
|
|
1554d14ce1 | ||
|
|
11f093839f | ||
|
|
d1520cea68 | ||
|
|
9cc8d1f6a9 | ||
|
|
48d1df6825 | ||
|
|
3a7457ae6c | ||
|
|
fe76db396c | ||
|
|
dd992130c6 | ||
|
|
02d760e232 | ||
|
|
4905751e2f | ||
|
|
d103085de3 | ||
|
|
9bc1a80b4e | ||
|
|
99ed77dea6 | ||
|
|
bda57be904 | ||
|
|
07053344dc | ||
|
|
f31052628d | ||
|
|
8e03e30c05 | ||
|
|
0ef3c5d7fc | ||
|
|
a06a563ea4 | ||
|
|
9250d1a34f | ||
|
|
a8d7df994f | ||
|
|
b10e58db1b | ||
|
|
a440742330 | ||
|
|
f466b6448a | ||
|
|
9f8bc128f0 | ||
|
|
b0cc976ab9 | ||
|
|
632b63d59c | ||
|
|
1db78f41bf | ||
|
|
7c48860ed8 | ||
|
|
1b0901bb9e | ||
|
|
76a9b4dc10 | ||
|
|
19d33cea2b | ||
|
|
c4ddb7f83a | ||
|
|
431db6c847 | ||
|
|
207d6b3cda | ||
|
|
bbefeb160b | ||
|
|
89d0895332 | ||
|
|
cb5153fefa | ||
|
|
b08eca15fd | ||
|
|
6f922edf2d | ||
|
|
85514c7e0b | ||
|
|
e060631c35 | ||
|
|
cac31ff114 | ||
|
|
f0e23dcff9 | ||
|
|
b3faad27ed | ||
|
|
38121144b2 | ||
|
|
73bc7f0777 | ||
|
|
99571c629e | ||
|
|
4f40ac7422 | ||
|
|
1610efe2fd | ||
|
|
1c70e83474 | ||
|
|
9a06759937 | ||
|
|
6161d60dde | ||
|
|
e3cd439763 | ||
|
|
5e1ffee4d6 | ||
|
|
910287474f | ||
|
|
6faa50c135 | ||
|
|
9fca49f67c | ||
|
|
8a3c0671e0 | ||
|
|
2f7eb5cdf5 | ||
|
|
8fb3745a09 | ||
|
|
aaba44e639 | ||
|
|
1cd88b2b5e | ||
|
|
60695039c0 | ||
|
|
806520fdc0 | ||
|
|
25a8d1f1e9 | ||
|
|
f0e50d53d5 | ||
|
|
40d99818ef | ||
|
|
0d6a1583c6 | ||
|
|
6f48de44ae | ||
|
|
9622d45140 | ||
|
|
890a087101 | ||
|
|
bc2e8cb6ce | ||
|
|
22cce6dadc | ||
|
|
82893aff55 | ||
|
|
c262673191 | ||
|
|
d8071546b1 | ||
|
|
d1e59e17e7 | ||
|
|
9afd1dd692 | ||
|
|
c1e3742914 | ||
|
|
157b3ef61f | ||
|
|
73e540ea1b | ||
|
|
12dd796d8a | ||
|
|
d1c7f62ba8 | ||
|
|
5d76644c3e | ||
|
|
750e5969ff | ||
|
|
6fc1cc1b6a | ||
|
|
9e37b40aa1 | ||
|
|
ebb207dc5a | ||
|
|
d0eeabbc32 | ||
|
|
259838277b | ||
|
|
0b6ee7158e | ||
|
|
3baa7fa854 | ||
|
|
0d13ededce | ||
|
|
a3a4a31c22 | ||
|
|
bf73dd5297 | ||
|
|
6002b5a2ed | ||
|
|
1c9a7ba541 | ||
|
|
e3a368948e | ||
|
|
12bf2f8f8b | ||
|
|
d12ba36443 | ||
|
|
007f495c2f | ||
|
|
0de4165e66 | ||
|
|
f90a5e94b8 | ||
|
|
88fc9ef946 | ||
|
|
fc6db4f55a | ||
|
|
a279b3a84b | ||
|
|
a56886d93d | ||
|
|
82105f5876 | ||
|
|
ea07044f83 | ||
|
|
b67ee7857a | ||
|
|
6796615496 | ||
|
|
88c9f81346 | ||
|
|
55865fda6c | ||
|
|
bdb9cd3f2c | ||
|
|
cef6937705 | ||
|
|
34942b9da8 | ||
|
|
4cbb965035 | ||
|
|
62edaf0b55 | ||
|
|
c274f255c3 | ||
|
|
e7fa925898 | ||
|
|
b003c8fdfa | ||
|
|
2279aec4a3 | ||
|
|
1f74a371e0 | ||
|
|
ae295f9bab | ||
|
|
28a81b47c1 | ||
|
|
9b56140087 | ||
|
|
8907976270 | ||
|
|
3354e7502c | ||
|
|
64bae48df6 | ||
|
|
9d3c3cb2c7 | ||
|
|
9a16aa9fde | ||
|
|
a6f5dd6269 | ||
|
|
9174cee25d | ||
|
|
7d98d28569 | ||
|
|
e441de9acc | ||
|
|
36ca174d81 | ||
|
|
76659f726f | ||
|
|
42a64ac80e | ||
|
|
6783ad7832 | ||
|
|
e8b570e45a | ||
|
|
cf6eaeb03b | ||
|
|
42ccae28c6 | ||
|
|
c850864a19 | ||
|
|
c93a59ac4f | ||
|
|
abc54153b1 | ||
|
|
c4a52014f7 | ||
|
|
c7a0b8f429 | ||
|
|
154588d722 | ||
|
|
f9270b650f | ||
|
|
5f724e01b9 | ||
|
|
c37f2f6355 | ||
|
|
dcf32e94d2 | ||
|
|
3e47e246f8 | ||
|
|
d5c056d478 | ||
|
|
da96ede53c | ||
|
|
6a9f42807f | ||
|
|
36564cbefd | ||
|
|
95836befb3 | ||
|
|
0b8e81aab9 | ||
|
|
a0119464b8 | ||
|
|
00811477e8 | ||
|
|
e144c80776 | ||
|
|
ac4f985ac9 | ||
|
|
560d7d9dac | ||
|
|
e7a7a48ee6 | ||
|
|
95e8d410ff | ||
|
|
d3b1ca9174 | ||
|
|
d70fb569fb | ||
|
|
e5e1c6d4fd | ||
|
|
d17b6bc300 | ||
|
|
114946fdb0 | ||
|
|
30edff7a36 | ||
|
|
d3ffbea816 | ||
|
|
cc7d631369 | ||
|
|
4e8d80cad7 | ||
|
|
a1d8c38553 | ||
|
|
0501984933 | ||
|
|
f8474e2421 | ||
|
|
ddd5fa0ce5 | ||
|
|
a7a7424b8b | ||
|
|
69b1c4026c | ||
|
|
0fe4e6b443 | ||
|
|
8cee2c6772 | ||
|
|
eb4109b66e | ||
|
|
e0cbae44cd | ||
|
|
8f913cc64f | ||
|
|
64dec9fafb | ||
|
|
a625377e8c | ||
|
|
c5027d831c | ||
|
|
f4143898b2 | ||
|
|
5101382ec6 | ||
|
|
dd886e9690 | ||
|
|
6a821331eb | ||
|
|
d679966505 | ||
|
|
f01319465c | ||
|
|
1dbd1aff6f | ||
|
|
69e1d626bd | ||
|
|
609582a161 | ||
|
|
bc95e393d8 | ||
|
|
379dcf4c48 | ||
|
|
ffd4e9684a | ||
|
|
809b33b2ff | ||
|
|
2a8c4e283e | ||
|
|
e6bc0dccbc | ||
|
|
b6d265e347 | ||
|
|
4de61e5f98 | ||
|
|
1f6f06f7de | ||
|
|
69d1c5772e | ||
|
|
d577eef9e4 | ||
|
|
a36f86a13e | ||
|
|
924b7e2291 | ||
|
|
2e2161c97a | ||
|
|
f3df8336ae | ||
|
|
a66cc3009b | ||
|
|
cf3d3f1e6e | ||
|
|
832dfa7e1f | ||
|
|
35af2e8613 | ||
|
|
de9d4e9f91 | ||
|
|
fb059dc67c | ||
|
|
12562e897d | ||
|
|
cc40ff77a8 | ||
|
|
294b139566 | ||
|
|
54047adacd | ||
|
|
4d062fbe6d | ||
|
|
23dfcdb368 | ||
|
|
e6a9ce41b6 | ||
|
|
03e24361ee | ||
|
|
24c8bc7107 | ||
|
|
4ab8ea3cb7 | ||
|
|
75e403b3b3 | ||
|
|
367c2367a6 | ||
|
|
1ff7d4be9b | ||
|
|
43dcc7ef21 | ||
|
|
b655fc9cf7 | ||
|
|
b6dfae5d0e | ||
|
|
1f8c95df83 | ||
|
|
2af4373a90 | ||
|
|
20203a77e1 | ||
|
|
d712631a71 | ||
|
|
2d9a947471 | ||
|
|
47a4b79f74 | ||
|
|
b967ecb86b | ||
|
|
4fa4d097bd | ||
|
|
5050912be0 | ||
|
|
a147c61141 | ||
|
|
4afd87dd11 | ||
|
|
339497e1f4 | ||
|
|
62528b9cf8 | ||
|
|
50c573d457 | ||
|
|
96309d1da7 | ||
|
|
d815c152df | ||
|
|
25abb410d4 | ||
|
|
baa8cd4493 | ||
|
|
d008b48e3b | ||
|
|
5b86bf7cde | ||
|
|
54ec5153c5 | ||
|
|
6369a887ba | ||
|
|
42edc330ed | ||
|
|
e0e1dc0bf8 | ||
|
|
f381610dd5 | ||
|
|
034df8db20 | ||
|
|
8fe009ed7c | ||
|
|
c21cecaea8 | ||
|
|
1d47220ab2 | ||
|
|
cf691ec714 | ||
|
|
7c2d5de6c7 | ||
|
|
db6ce0481b | ||
|
|
98327bba60 | ||
|
|
a29afcb470 | ||
|
|
bf504d2a46 | ||
|
|
ce9c687d5a | ||
|
|
eaaff3246a | ||
|
|
7ba3c38741 | ||
|
|
c69d22ae26 | ||
|
|
35aee6bf13 | ||
|
|
ac03113efe | ||
|
|
bbea0501a9 | ||
|
|
a7b641acd5 | ||
|
|
c4cf0531ff | ||
|
|
a7d0351c20 | ||
|
|
beb464c0ea | ||
|
|
d8a18c33e8 | ||
|
|
abdc079cd5 | ||
|
|
d0b9ad729c | ||
|
|
24df6275fb | ||
|
|
2500fe4079 | ||
|
|
3a3189e6c3 | ||
|
|
db3c0ffb44 | ||
|
|
8935f38d4e | ||
|
|
667799f7e2 | ||
|
|
d30f9691c1 | ||
|
|
fdd07e3d2b | ||
|
|
419aa42181 | ||
|
|
516b48e7a2 | ||
|
|
03c1b8518c | ||
|
|
39090114f0 | ||
|
|
b2513fc340 | ||
|
|
b989ccb248 | ||
|
|
2067a9fe97 | ||
|
|
a717cdf2d6 | ||
|
|
bb0631e825 | ||
|
|
9dab31b501 | ||
|
|
2080baecff | ||
|
|
69952761e1 | ||
|
|
319976a665 | ||
|
|
8137487dd7 | ||
|
|
0b1a5f6fe9 | ||
|
|
236d3671e2 | ||
|
|
ab33da4b55 | ||
|
|
34f0f5c2c9 | ||
|
|
bad53b08e6 | ||
|
|
1682163674 | ||
|
|
8ca2ea6a0e | ||
|
|
7549c10f35 | ||
|
|
45eb651902 | ||
|
|
6c9f8b17d0 | ||
|
|
771cd1f617 | ||
|
|
75cedb69be | ||
|
|
dc475b06bd | ||
|
|
581baf7d99 | ||
|
|
7ca462d865 | ||
|
|
81e166e0ce | ||
|
|
190ab69c07 | ||
|
|
9d044f6b96 | ||
|
|
713d9932c3 | ||
|
|
83bd8b5ff1 | ||
|
|
f92141140b | ||
|
|
695cdd6f6a | ||
|
|
e7f2703c47 | ||
|
|
3d308f9549 | ||
|
|
f42367c3e7 | ||
|
|
0aa9923d96 | ||
|
|
85b4cd220b | ||
|
|
f0a21a933a | ||
|
|
42884ec0c7 | ||
|
|
c227e4a167 | ||
|
|
c92de17d2f | ||
|
|
c060f16ed7 | ||
|
|
f19d194943 | ||
|
|
a721b1ac67 | ||
|
|
2a147b2b43 | ||
|
|
c004c87b6c | ||
|
|
eff1cee6e1 | ||
|
|
06303195c0 | ||
|
|
dd007634ac | ||
|
|
562f29a2a2 | ||
|
|
11212212b0 | ||
|
|
1271e5321c | ||
|
|
0b80d92d60 | ||
|
|
542d10fd71 | ||
|
|
cec649b346 | ||
|
|
04d1d85350 | ||
|
|
cdbee41fbf | ||
|
|
153de419bc | ||
|
|
bc3d22ae9b | ||
|
|
dafd051712 | ||
|
|
fde28088f4 | ||
|
|
c2db2a08d9 | ||
|
|
1424b8fd50 | ||
|
|
df3d9f6812 | ||
|
|
df570c09ee | ||
|
|
e2ff4b6e90 | ||
|
|
e16c2033b4 | ||
|
|
4159e9e2f6 | ||
|
|
a6ea4bd455 | ||
|
|
f9ce2cffec | ||
|
|
2bf19e8467 | ||
|
|
5a16e75a56 | ||
|
|
fd6c9bbcef | ||
|
|
ab589a9ada | ||
|
|
3a7f42f1a8 | ||
|
|
278e9999a9 | ||
|
|
8ee5e50927 | ||
|
|
3ae2c2ecf0 | ||
|
|
5cfbca30a9 | ||
|
|
6d97ed71b7 | ||
|
|
0a1a14a095 | ||
|
|
674d2ec393 | ||
|
|
96359cf648 | ||
|
|
855b12df1d | ||
|
|
6e8f572094 | ||
|
|
e4fd405431 | ||
|
|
e9e5d9bf3f | ||
|
|
9e1ddcbf89 | ||
|
|
2003f808c7 | ||
|
|
5c591b0e36 | ||
|
|
dac5c72090 | ||
|
|
5c8eb257ea | ||
|
|
703336d148 | ||
|
|
2bc2cc2f54 | ||
|
|
1905d5266b | ||
|
|
58bb02e74d | ||
|
|
dc82d52a02 | ||
|
|
158b19d487 | ||
|
|
e0aa18bb33 | ||
|
|
ac6d2b033e | ||
|
|
a3631a8114 | ||
|
|
5478a521d6 | ||
|
|
ff12f6ff27 | ||
|
|
ae79d1fceb | ||
|
|
45eb5dac3c | ||
|
|
95d1aad02d | ||
|
|
b910e6ea14 | ||
|
|
4ba4999328 | ||
|
|
d7176770d4 | ||
|
|
fe27c7d14e | ||
|
|
0c23f18574 | ||
|
|
fbaac7ba29 | ||
|
|
959eb64fb4 | ||
|
|
290a9e03f2 | ||
|
|
c057543e47 | ||
|
|
7456d2a652 | ||
|
|
965a1e5a94 | ||
|
|
bee00278e6 | ||
|
|
59aae8f311 | ||
|
|
097ca8427d | ||
|
|
546f3f81da | ||
|
|
e879a5a73e | ||
|
|
8eaa894f84 | ||
|
|
be65d0ad03 | ||
|
|
3a69319e76 | ||
|
|
0d24fd9224 | ||
|
|
9bf8b6b4c7 | ||
|
|
4677710c39 | ||
|
|
7fbb24fe4e | ||
|
|
c537a72db4 | ||
|
|
23b14f50e3 | ||
|
|
b9842e7300 | ||
|
|
2cd167fba1 | ||
|
|
133e0a63c5 | ||
|
|
95fe06e1ba | ||
|
|
0c3c9353ab | ||
|
|
cffac32634 | ||
|
|
b035c9078c | ||
|
|
b79cd299cb | ||
|
|
1e8f1e0863 | ||
|
|
0f8e5e93c1 | ||
|
|
4433aaa043 | ||
|
|
68bb940729 | ||
|
|
96e08503da | ||
|
|
21e69c4002 | ||
|
|
bcaa45d181 | ||
|
|
96e8d93844 | ||
|
|
104866a990 | ||
|
|
3a01605b6b | ||
|
|
13106e125b | ||
|
|
8a8a4eeab0 | ||
|
|
075ce6b479 | ||
|
|
c771f143db | ||
|
|
76b9399091 | ||
|
|
81706baebd | ||
|
|
59277d9406 | ||
|
|
73444fc778 | ||
|
|
f62a91b03e | ||
|
|
a820bf8457 | ||
|
|
1120f4c00c | ||
|
|
e2fcc9923d | ||
|
|
a7c6ba5e86 | ||
|
|
5b2aa1846b | ||
|
|
782b270314 | ||
|
|
ff743d5451 | ||
|
|
0f67dfcaa3 | ||
|
|
88cbad9817 | ||
|
|
0ae96f2361 | ||
|
|
32deb2026b | ||
|
|
8a61d8e336 | ||
|
|
6e7be7b1c6 | ||
|
|
51f63eeac9 | ||
|
|
61fa70ac19 | ||
|
|
d0bdbe00ba | ||
|
|
e35e21e280 | ||
|
|
8f443fb9c1 | ||
|
|
d48f86fb02 | ||
|
|
a877f41093 | ||
|
|
88ab6854e5 | ||
|
|
09483e6dc6 | ||
|
|
fce748fe1f | ||
|
|
878b334351 | ||
|
|
0800a11f65 | ||
|
|
37f353eb26 | ||
|
|
68cab6ea0d | ||
|
|
2e250112ee | ||
|
|
a4758241e7 | ||
|
|
4762e42042 | ||
|
|
8e42ae2cc4 | ||
|
|
824529d0aa | ||
|
|
7568de8654 | ||
|
|
16f3644da7 | ||
|
|
e2bf10d90e | ||
|
|
df7b9c808b | ||
|
|
4eb7ae21e8 | ||
|
|
07c6f5e387 | ||
|
|
e02df462ba | ||
|
|
b874c17169 | ||
|
|
e63a340c46 | ||
|
|
aa1c4f58f1 | ||
|
|
089aa98fb8 | ||
|
|
69272c2e85 | ||
|
|
421265ba29 | ||
|
|
0fbe67a146 | ||
|
|
a0a658c1f6 | ||
|
|
232eb53f42 | ||
|
|
147d933a4f | ||
|
|
6dde919c8a | ||
|
|
0bf08d23cd | ||
|
|
ed2d3ddb6b | ||
|
|
3dea3dfe03 | ||
|
|
70a87bf7ca | ||
|
|
1a4f074c9e | ||
|
|
9b1973fbd7 | ||
|
|
03b1afaa8d | ||
|
|
60979fecbb | ||
|
|
e9144d8d30 | ||
|
|
0c87b3168c | ||
|
|
3946ca7fc1 | ||
|
|
2dc3a543b1 | ||
|
|
f7bb13ecd8 | ||
|
|
68737ed84b | ||
|
|
e91bb3d2e9 | ||
|
|
5fd73cbdf3 |
@@ -11,27 +11,32 @@ maintainer-check:
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
prev-version := $(shell echo $(VERSION)|tr a-z Xa-y)
|
||||
tag-package = $(shell echo "$(PACKAGE)" | tr a-z A-Z)
|
||||
tag-this-version = $(subst .,_,$(VERSION))
|
||||
tag-prev-version = $(subst .,_,$(prev-version))
|
||||
this-cvs-tag = $(tag-package)-$(tag-this-version)
|
||||
prev-cvs-tag = $(tag-package)-$(tag-prev-version)
|
||||
|
||||
|
||||
# Tag before making distribution. Also, don't make a distribution if
|
||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
|
||||
cvs-dist: maintainer-check
|
||||
pkg=`echo "$(PACKAGE)" | tr a-z A-Z`; \
|
||||
ver=`echo "$(VERSION)" | sed 's/\./_/g'`; \
|
||||
tag="$$pkg-$$ver"; \
|
||||
echo tag=$$tag; \
|
||||
if cvs -n log -h README| grep -e $$tag: > /dev/null; then \
|
||||
echo $(this-cvs-tag); \
|
||||
if cvs -n log -h README| grep -e $(this-cvs-tag): > /dev/null; then \
|
||||
echo "VERSION not new; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
cvs update po; \
|
||||
cvs tag -c $$tag
|
||||
cvs tag -c $(this-cvs-tag)
|
||||
$(MAKE) dist
|
||||
|
||||
t=./=test
|
||||
my-distcheck:
|
||||
-rm -rf $(t)
|
||||
mkdir $(t)
|
||||
GZIP=$(GZIP) $(TAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
GZIP=$(GZIP) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
||||
@@ -39,7 +44,7 @@ my-distcheck:
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) distclean
|
||||
cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(TAR) -zxf ../$(distdir).tar.gz
|
||||
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
@@ -51,8 +56,22 @@ THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
PREV_VERSION := $(shell echo $(VERSION)|tr a-z Xa-y)
|
||||
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
|
||||
v = Version
|
||||
url-host-prefix = ftp://alpha.gnu.org
|
||||
url = $(url-host-prefix)/gnu/fetish/$(distdir).tar.gz
|
||||
|
||||
a_host=alpha.gnu.org
|
||||
b_host=tug.org
|
||||
c_host=ftp.enst.fr
|
||||
|
||||
a_url_dir=gnu/fetish
|
||||
b_url_dir=gnu/fetish
|
||||
c_url_dir=pub/gnu/gnits/fetish
|
||||
|
||||
a_real_dir=/fs/share/ftp/gnu/fetish
|
||||
b_real_dir=/home/ftp/pub/gnu/fetish
|
||||
c_real_dir=/pub/gnu/gnits/fetish
|
||||
|
||||
url_dir_list = $(foreach x,a b c,ftp://$($(x)_host)/$($(x)_url_dir))
|
||||
real_dir_list = $(foreach x,a b c,ftp://$($(x)_host)$($(x)_real_dir))
|
||||
|
||||
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
|
||||
rel-check:
|
||||
@@ -70,7 +89,9 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
echo; \
|
||||
echo FIXME: put comments here; \
|
||||
echo; \
|
||||
echo " $(url)"; \
|
||||
for url in $(url_dir_list); do \
|
||||
echo " $$url/$(distdir).tar.gz"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo "$(md5) $(distdir).tar.gz"; \
|
||||
echo; \
|
||||
@@ -79,18 +100,22 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
| grep -v '^\['; \
|
||||
echo; \
|
||||
echo ChangeLog entries:; \
|
||||
sed -n "1,/$v $(PREV_VERSION_REGEXP)/p" \
|
||||
ChangeLog; \
|
||||
find . -name ChangeLog \
|
||||
| xargs cvs diff -up -r$(prev-cvs-tag) -rHEAD \
|
||||
| sed -n 's/^+//p' \
|
||||
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
|
||||
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
|
||||
)
|
||||
|
||||
alpha:
|
||||
$(MAKE) cvs-dist
|
||||
$(MAKE) -s announcement > /tmp/announcement
|
||||
$(MAKE) -s announcement > /tmp/announce-$(distdir)
|
||||
ln $(distdir).tar.gz ../release
|
||||
chmod a-w $(distdir).tar.gz
|
||||
@echo =====================================
|
||||
@echo 'ncftp -u $(url-host-prefix)/fs/share/ftp/gnu/fetish/'
|
||||
@for url in $(real_dir_list); do \
|
||||
echo "ncftp -u $$url/"; \
|
||||
done
|
||||
@echo '# put $(distdir).tar.gz'
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo 'pot-mail $(distdir).tar.gz | bash'
|
||||
@echo =====================================
|
||||
|
||||
12
THANKS
12
THANKS
@@ -3,11 +3,14 @@ The rest of the addresses are still in the ChangeLog.
|
||||
|
||||
Achim Blumensath: blume@corona.oche.de
|
||||
aldomel: aldomel@ix.netcom.com
|
||||
Alen Muzinic: zveki@fly.cc.fer.hr
|
||||
Akim Demaille: demaille@inf.enst.fr
|
||||
Alain Magloire: alain@qnx.com
|
||||
Alexey Solovyov: alekso@math.uu.se
|
||||
Andreas Jaeger: jaeger@gnu.org
|
||||
Andreas Schwab: schwab@issan.informatik.uni-dortmund.de
|
||||
Andrew Dalke: dalke@bioreason.com
|
||||
Andrew Tridgell: tridge@samba.org
|
||||
Andries Brouwer: Andries.Brouwer@cwi.nl
|
||||
Arne Henrik Juul: arnej@imf.unit.no
|
||||
Bauke Jan Douma: bjdouma@xs4all.nl
|
||||
@@ -33,12 +36,17 @@ James: james@albion.glarp.com
|
||||
James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Tanis: jtt@soscorp.com
|
||||
Jamie Lokier: jamie@imbolc.ucc.ie
|
||||
Janos Farkas: chexum@shadow.banki.hu
|
||||
Jesse Thilo: jgt2@eecs.lehigh.edu
|
||||
Joakim Rosqvist: dvljrt@cs.umu.se
|
||||
Johan Danielsson: joda@pdc.kth.se
|
||||
John Bley: jbb6@acpub.duke.edu
|
||||
John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th
|
||||
John Gotts: jgotts@umich.edu
|
||||
jvogel: jvogel@linkny.com
|
||||
Karl Heuer: kwzh@gnu.org
|
||||
Kjetil Torgrim Homme: kjetilho@ifi.uio.no
|
||||
Larry McVoy: lm@sgi.com
|
||||
Lars Hecking: lhecking@nmrc.ucc.ie
|
||||
Lorne Baker: lbaker@nitro.avint.net
|
||||
Marcus Daniels: marcus@sysc.pdx.edu
|
||||
@@ -49,12 +57,14 @@ Marty Leisner: leisner@sdsp.mc.xerox.com
|
||||
Masami Takikawa: takikawm@CS.ORST.EDU
|
||||
Matthew S. Levine: mslevine@theory.lcs.mit.edu
|
||||
Matthew Swift: swift@alum.mit.edu
|
||||
Matthias Urlichs: smurf@noris.de
|
||||
Michiel Bacchiani: bacchian@raven.bu.edu
|
||||
Miles Bader: miles@gnu.ai.mit.edu
|
||||
Noel Cragg: noel@red-bean.com
|
||||
Olav Morkrid: olav@funcom.com
|
||||
Per Kristian Hove: perhov@math.ntnu.no
|
||||
Peter Eriksson: peter@ifm.liu.se
|
||||
Peter Samuelson: psamuels@sampo.creighton.edu
|
||||
Paul Eggert: eggert@twinsun.com
|
||||
Philippe De Muyter: phdm@macqel.be
|
||||
Rainer Orth: ro@TechFak.Uni-Bielefeld.DE
|
||||
@@ -62,9 +72,11 @@ Ross Ridge: rridge@calum.csclub.uwaterloo.ca
|
||||
Santiago Vila Doncel: sanvila@unex.es
|
||||
Stuart Kemp: skemp@peter.bmc.com
|
||||
Thomas Bushnell, n/BSG: thomas@gnu.ai.mit.edu
|
||||
Ton Hospel: thospel@mail.dma.be
|
||||
Torbjorn Lindgren: tl@funcom.no
|
||||
Tony Leneis: tony@plaza.ds.adp.com
|
||||
Ulrich Drepper: drepper@cygnus.com
|
||||
Volker Borchert: bt@teknon.de
|
||||
Michael Veksler: mveksler@techunix.technion.ac.il
|
||||
Wayne Stewart: wstewa@atl.com
|
||||
William Bader: william@nscs.fast.net
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -57,6 +57,10 @@ POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AMTAR = @AMTAR@
|
||||
AMTARFLAGS = @AMTARFLAGS@
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
@@ -64,8 +68,10 @@ CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DF_PROG = @DF_PROG@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -89,6 +95,7 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
|
||||
info_TEXINFOS = fileutils.texi
|
||||
|
||||
EXTRA_DIST = perm.texi getdate.texi
|
||||
@@ -105,6 +112,7 @@ MAKEINFO = makeinfo --no-split
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_SOURCES =
|
||||
TEXI2DVI = texi2dvi
|
||||
INFO_DEPS = fileutils.info
|
||||
DVIS = fileutils.dvi
|
||||
@@ -113,9 +121,8 @@ DIST_COMMON = Makefile.am Makefile.in mdate-sh stamp-vti texinfo.tex \
|
||||
version.texi
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
@@ -163,7 +170,7 @@ DVIPS = dvips
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texi.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.texi:
|
||||
@@ -182,7 +189,7 @@ DVIPS = dvips
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi.info:
|
||||
@@ -191,7 +198,7 @@ DVIPS = dvips
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.txi.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi:
|
||||
@@ -226,17 +233,19 @@ install-info-am: $(INFO_DEPS)
|
||||
uninstall-info:
|
||||
$(PRE_UNINSTALL)
|
||||
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
|
||||
ii=yes; \
|
||||
else ii=; fi; \
|
||||
list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
test -z "$ii" \
|
||||
|| install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
|
||||
done
|
||||
list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file"; \
|
||||
install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
|
||||
done; \
|
||||
else :; fi
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(INFO_DEPS)'; \
|
||||
@list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
(cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
|
||||
(if cd $(DESTDIR)$(infodir); then \
|
||||
echo " rm -f $$file $$file-[0-9] $$file-[0-9][0-9])"; \
|
||||
rm -f $$file $$file-[0-9] $$file-[0-9][0-9]; \
|
||||
else :; fi); \
|
||||
done
|
||||
|
||||
dist-info: $(INFO_DEPS)
|
||||
@@ -252,10 +261,11 @@ dist-info: $(INFO_DEPS)
|
||||
|
||||
mostlyclean-aminfo:
|
||||
-rm -f fileutils.aux fileutils.cp fileutils.cps fileutils.dvi \
|
||||
fileutils.fn fileutils.fns fileutils.ky fileutils.kys \
|
||||
fileutils.ps fileutils.log fileutils.pg fileutils.toc \
|
||||
fileutils.tp fileutils.tps fileutils.vr fileutils.vrs \
|
||||
fileutils.op fileutils.tr fileutils.cv fileutils.cn
|
||||
fileutils.fn fileutils.fns fileutils.pgs fileutils.ky \
|
||||
fileutils.kys fileutils.ps fileutils.log fileutils.pg \
|
||||
fileutils.toc fileutils.tp fileutils.tps fileutils.vr \
|
||||
fileutils.vrs fileutils.op fileutils.tr fileutils.cv \
|
||||
fileutils.cn
|
||||
|
||||
clean-aminfo:
|
||||
|
||||
@@ -285,13 +295,14 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
|
||||
info-am: $(INFO_DEPS)
|
||||
info: info-am
|
||||
@@ -315,7 +326,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile $(INFO_DEPS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(infodir)
|
||||
|
||||
@@ -353,8 +364,8 @@ install-info-am uninstall-info mostlyclean-aminfo distclean-aminfo \
|
||||
clean-aminfo maintainer-clean-aminfo tags distdir info-am info dvi-am \
|
||||
dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
uninstall-am uninstall all-redirect all-am all install-strip \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ the file to all users.
|
||||
@cindex numeric modes
|
||||
@cindex file permissions, numeric
|
||||
@cindex octal numbers for file modes
|
||||
File permissions are stored internally as 16 bit integers. As an
|
||||
File permissions are stored internally as integers. As an
|
||||
alternative to giving a symbolic mode, you can give an octal (base 8)
|
||||
number that corresponds to the internal representation of the new mode.
|
||||
This number is always interpreted in octal; you do not have to add a
|
||||
@@ -440,12 +440,13 @@ A numeric mode is usually shorter than the corresponding symbolic
|
||||
mode, but it is limited in that it can not take into account a file's
|
||||
previous permissions; it can only set them absolutely.
|
||||
|
||||
The permissions granted to the user, to other users in the file's group,
|
||||
On most systems, the permissions granted to the user,
|
||||
to other users in the file's group,
|
||||
and to other users not in the file's group are each stored as three
|
||||
bits, which are represented as one octal digit. The three special
|
||||
permissions are also each stored as one bit, and they are as a group
|
||||
represented as another octal digit. Here is how the bits are arranged
|
||||
in the 16 bit integer, starting with the lowest valued bit:
|
||||
represented as another octal digit. Here is how the bits are arranged,
|
||||
starting with the lowest valued bit:
|
||||
|
||||
@example
|
||||
Value in Corresponding
|
||||
|
||||
@@ -797,7 +797,7 @@ This makes it possible to test @code{expr length quote "$x"} or
|
||||
@code{expr quote "$x" : '.*/\(.\)'} and have it do the right thing even if
|
||||
the value of @var{$x} happens to be (for example) @code{/} or @code{index}.
|
||||
This operator is a GNU extension. It is disabled when
|
||||
the environment variable @var{POSIXLY_CORRECT} is set.
|
||||
the environment variable @env{POSIXLY_CORRECT} is set.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -1749,7 +1749,7 @@ Tell the kernel that the terminal has @var{n} columns. Non-POSIX.
|
||||
@vindex COLUMNS
|
||||
Print the number of rows and columns that the kernel thinks the
|
||||
terminal has. (Systems that don't support rows and cols in the kernel
|
||||
typically use the environment variables @code{LINES} and @code{COLUMNS}
|
||||
typically use the environment variables @env{LINES} and @env{COLUMNS}
|
||||
instead; however, GNU @code{stty} does not know anything about them.)
|
||||
Non-POSIX.
|
||||
|
||||
@@ -2390,6 +2390,33 @@ 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.
|
||||
|
||||
@item -I[@var{timespec}]
|
||||
@itemx --iso-8601[=@var{timespec}]
|
||||
@opindex -I[@var{timespec}]
|
||||
@opindex --iso-8601[=@var{timespec}]
|
||||
Display the date using the ISO 8601 format, @samp{%Y-%m-%d}.
|
||||
|
||||
The optional argument @var{timespec} specifies the number of additional
|
||||
terms of the time to include. It can be one of the following:
|
||||
@table @samp
|
||||
@item auto
|
||||
The default behavior: print just the date.
|
||||
|
||||
@item hours
|
||||
Append the hour of the day to the date.
|
||||
|
||||
@item minutes
|
||||
Append the hours and minutes.
|
||||
|
||||
@item seconds
|
||||
Append the hours, minutes, and seconds.
|
||||
@end table
|
||||
|
||||
If showing any time terms, then include the time zone using the format
|
||||
@samp{%z}. If @samp{--utc} is also specified, use @samp{%Z} in place of
|
||||
@samp{%z}.
|
||||
|
||||
@item -R
|
||||
@itemx --rfc-822
|
||||
@opindex -R
|
||||
@opindex --rfc-822
|
||||
@@ -2690,7 +2717,7 @@ 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
|
||||
specified, the default is the value of the @env{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
|
||||
@@ -2720,7 +2747,7 @@ to an empty value is different from unsetting it.
|
||||
|
||||
@vindex PATH
|
||||
The first remaining argument specifies the program name to invoke; it is
|
||||
searched for according to the @code{PATH} environment variable. Any
|
||||
searched for according to the @env{PATH} environment variable. Any
|
||||
remaining arguments are passed as arguments to that program.
|
||||
|
||||
@cindex environment, printing
|
||||
@@ -2864,9 +2891,9 @@ effective user id of zero (the super-user).
|
||||
@vindex LOGNAME
|
||||
@cindex login shell
|
||||
By default, @code{su} does not change the current directory.
|
||||
It sets the environment variables @code{HOME} and @code{SHELL}
|
||||
It sets the environment variables @env{HOME} and @env{SHELL}
|
||||
from the password entry for @var{user}, and if @var{user} is not
|
||||
the super-user, sets @code{USER} and @code{LOGNAME} to @var{user}.
|
||||
the super-user, sets @env{USER} and @env{LOGNAME} to @var{user}.
|
||||
By default, the shell is not a login shell.
|
||||
|
||||
Any additional @var{arg}s are passed as additional arguments to the
|
||||
@@ -2917,10 +2944,10 @@ expansion (globbing), which is not likely to be useful.
|
||||
@vindex PATH
|
||||
@cindex login shell, creating
|
||||
Make the shell a login shell. This means the following. Unset all
|
||||
environment variables except @code{TERM}, @code{HOME}, and @code{SHELL}
|
||||
(which are set as described above), and @code{USER} and @code{LOGNAME}
|
||||
environment variables except @env{TERM}, @env{HOME}, and @env{SHELL}
|
||||
(which are set as described above), and @env{USER} and @env{LOGNAME}
|
||||
(which are set, even for the super-user, as described above), and set
|
||||
@code{PATH} to a compiled-in default value. Change to @var{user}'s home
|
||||
@env{PATH} to a compiled-in default value. Change to @var{user}'s home
|
||||
directory. Prepend @samp{-} to the shell's name, intended to make it
|
||||
read its login startup file(s).
|
||||
|
||||
@@ -2933,9 +2960,9 @@ read its login startup file(s).
|
||||
@cindex environment, preserving
|
||||
@flindex /etc/shells
|
||||
@cindex restricted shell
|
||||
Do not change the environment variables @code{HOME}, @code{USER},
|
||||
@code{LOGNAME}, or @code{SHELL}. Run the shell given in the environment
|
||||
variable @code{SHELL} instead of the shell from @var{user}'s passwd
|
||||
Do not change the environment variables @env{HOME}, @env{USER},
|
||||
@env{LOGNAME}, or @env{SHELL}. Run the shell given in the environment
|
||||
variable @env{SHELL} instead of the shell from @var{user}'s passwd
|
||||
entry, unless the user running @code{su} is not the superuser and
|
||||
@var{user}'s shell is restricted. A @dfn{restricted shell} is one that
|
||||
is not listed in the file @file{/etc/shells}, or in a compiled-in list
|
||||
|
||||
1193
doc/texinfo.tex
1193
doc/texinfo.tex
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,9 @@ by the Foundation.
|
||||
@end titlepage
|
||||
|
||||
|
||||
@c If your makeinfo doesn't grok this @ifnottex directive, then either
|
||||
@c get a newer version of makeinfo or do s/ifnottex/ifinfo/ here and on
|
||||
@c the matching @end directive below.
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top GNU text utilities
|
||||
@@ -165,7 +168,7 @@ Operating on sorted files
|
||||
|
||||
@code{ptx}: Produce permuted indexes
|
||||
|
||||
* General options in ptx:: Options which affect general program behaviour.
|
||||
* General options in ptx:: Options which affect general program behavior.
|
||||
* Charset selection in ptx:: Underlying character set considerations.
|
||||
* Input processing in ptx:: Input fields, contexts, and keyword selection.
|
||||
* Output formatting in ptx:: Types of output format, and sizing the fields.
|
||||
@@ -961,23 +964,43 @@ optionally outputting in multicolumn format; optionally merges all
|
||||
pr [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@end example
|
||||
|
||||
By default, a 5-line header is printed: two blank lines; a line with the
|
||||
date, the file name, and the page count; and two more blank lines. A
|
||||
footer of five blank lines is also printed. With the @samp{-f} option, a
|
||||
3-line header is printed: the leading two blank lines are omitted; no
|
||||
footer used. The default @var{page_length} in both cases is 66 lines.
|
||||
The text line of the header takes up the full @var{page_width} in the
|
||||
form @samp{yy-mm-dd HH:MM string Page nnnn}. String is a centered
|
||||
string.
|
||||
By default, a 5-line header is printed at each page: two blank lines;
|
||||
a line with the date, the filename, and the page count; and two more
|
||||
blank lines. A footer of five blank lines is also printed. With the @samp{-F}
|
||||
option, a 3-line header is printed: the leading two blank lines are
|
||||
omitted; no footer is used. The default @var{page_length} in both cases is 66
|
||||
lines. The default number of text lines changes from 56 (without @samp{-F})
|
||||
to 63 (with @samp{-F}). The text line of the header takes up the full
|
||||
@var{page_width} in the form @samp{yyyy-mm-dd HH:MM string Page nnnn}.
|
||||
String is a centered header string.
|
||||
|
||||
Form feeds in the input cause page breaks in the output. Multiple form
|
||||
Form feeds in the input cause page breaks in the output. Multiple form
|
||||
feeds produce empty pages.
|
||||
|
||||
Columns have equal width, separated by an optional string (default
|
||||
space). Lines will always be truncated to line width (default 72),
|
||||
unless you use the @samp{-j} option. For single column output no line
|
||||
truncation occurs by default. Use @samp{-w} option to truncate lines
|
||||
in that case.
|
||||
Columns are of equal width, separated by an optional string (default
|
||||
is @samp{space}). For multicolumn output, lines will always be truncated to
|
||||
@var{page_width} (default 72), unless you use the @samp{-J} option. For single
|
||||
column output no line truncation occurs by default. Use @samp{-W} option to
|
||||
truncate lines in that case.
|
||||
|
||||
Including version 1.22i:
|
||||
|
||||
Some small @var{letter options} (@samp{-s}, @samp{-w}) has been redefined
|
||||
with the object of a better @var{posix} compliance. The output of some
|
||||
further cases has been adapted to other @var{unix}es. A violation of
|
||||
downward compatibility has to be accepted.
|
||||
|
||||
Some @var{new capital letter} options (@samp{-J}, @samp{-S}, @samp{-W})
|
||||
has been introduced to turn off unexpected interferences of small letter
|
||||
options. The @samp{-N} option and the second argument @var{last_page}
|
||||
of @samp{+FIRST_PAGE} offer more flexibility. The detailed handling of
|
||||
form feeds set in the input files requires @samp{-T} option.
|
||||
|
||||
Capital letter options dominate small letter ones.
|
||||
|
||||
Some of the option-arguments (compare @samp{-s}, @samp{-S}, @samp{-e},
|
||||
@samp{-i}, @samp{-n}) cannot be specified as separate arguments from the
|
||||
preceding option letter (already stated in the @var{posix} specification).
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@@ -987,32 +1010,39 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
@itemx --pages=@var{first_page}[:@var{last_page}]
|
||||
@opindex +@var{first_page}[:@var{last_page}]
|
||||
@opindex --pages
|
||||
Begin printing with page @var{first_page} and stop with
|
||||
@var{last_page}. Missing @samp{:@var{last_page}} implies end of file. While
|
||||
estimating the number of skipped pages each form feed in the input file
|
||||
results in a new page. Page counting with and without
|
||||
@samp{+@var{first_page}} is identical. By default, it starts with the
|
||||
first page of input file (not first page printed). Page numbering may be
|
||||
altered by @samp{-N} option.
|
||||
Begin printing with page @var{first_page} and stop with @var{last_page}.
|
||||
Missing @samp{:@var{last_page}} implies end of file. While estimating
|
||||
the number of skipped pages each form feed in the input file results
|
||||
in a new page. Page counting with and without @samp{+@var{first_page}}
|
||||
is identical. By default, counting starts with the first page of input
|
||||
file (not first page printed). Line numbering may be altered by @samp{-N}
|
||||
option.
|
||||
|
||||
@item -@var{column}
|
||||
@itemx --columns=@var{column}
|
||||
@opindex -@var{column}
|
||||
@opindex --columns
|
||||
@cindex down columns
|
||||
With each single @var{file}, produce @var{column}-column output and
|
||||
print columns down. The column width is automatically estimated from
|
||||
@var{page_width}. This option might well cause some columns to be
|
||||
truncated. The number of lines in the columns on each page will be
|
||||
balanced. @samp{-@var{column}} may not be used with @samp{-m} option.
|
||||
With each single @var{file}, produce @var{column} columns of output
|
||||
(default is 1) and print columns down, unless @samp{-a} is used. The
|
||||
column width is automatically decreased as @var{column} increases; unless
|
||||
you use the @samp{-W/-w} option to increase @var{page_width} as well.
|
||||
This option might well cause some lines to be truncated. The number of
|
||||
lines in the columns on each page are balanced. The options @samp{-e}
|
||||
and @samp{-i} are on for multiple text-column output. Together with
|
||||
@samp{-J} option column alignment and line truncation is turned off.
|
||||
Lines of full length are joined in a free field format and @samp{-S}
|
||||
option may set field separators. @samp{-@var{column}} may not be used
|
||||
with @samp{-m} option.
|
||||
|
||||
@item -a
|
||||
@itemx --across
|
||||
@opindex -a
|
||||
@opindex --across
|
||||
@cindex across columns
|
||||
With each single @var{file}, print columns across rather than down.
|
||||
@var{column} must be greater than one.
|
||||
With each single @var{file}, print columns across rather than down. The
|
||||
@samp{-@var{column}} option must be given with @var{column} greater than one.
|
||||
If a line is too long to fit in a column, it is truncated.
|
||||
|
||||
@item -c
|
||||
@itemx --show-control-chars
|
||||
@@ -1034,7 +1064,7 @@ Double space the output.
|
||||
@opindex -e
|
||||
@opindex --expand-tabs
|
||||
@cindex input tabs
|
||||
Expand tabs to spaces on input. Optional argument @var{in-tabchar} is
|
||||
Expand @var{tab}s to spaces on input. Optional argument @var{in-tabchar} is
|
||||
the input tab character (default is @key{TAB}). Second optional
|
||||
argument @var{in-tabwidth} is the input tab character's width (default
|
||||
is 8).
|
||||
@@ -1045,93 +1075,110 @@ is 8).
|
||||
@opindex -F
|
||||
@opindex -f
|
||||
@opindex --form-feed
|
||||
Use a form feed instead of newlines to separate output pages. Default
|
||||
page length of 66 lines is not altered. But the number of lines of text
|
||||
per page changes from 56 to 63 lines.
|
||||
|
||||
Use a form feed instead of newlines to separate output pages. The default
|
||||
page length of 66 lines is not altered. But the number of lines of text
|
||||
per page changes from default 56 to 63 lines.
|
||||
|
||||
@item -h @var{HEADER}
|
||||
@itemx --header=@var{HEADER}
|
||||
@opindex -h
|
||||
@opindex --header
|
||||
Replace the file name in the header with the centered string
|
||||
@var{header}. Left-hand-side truncation (marked by a @samp{*}) may occur
|
||||
if the total header line @samp{yy-mm-dd HH:MM HEADER Page nnnn}
|
||||
becomes larger than @var{page_width}. @samp{-h ""} prints a blank line
|
||||
header. Don't use @samp{-h""}. A space between the -h option and the
|
||||
argument is always peremptory.
|
||||
Replace the filename in the header with the centered string @var{header}.
|
||||
Left-hand-side truncation (marked by a @samp{*}) may occur if the total
|
||||
header line @samp{yyyy-mm-dd HH:MM HEADER Page nnnn} becomes larger than
|
||||
@var{page_width}. @samp{-h ""} prints a blank line header. Don't use
|
||||
@samp{-h""}.
|
||||
A space between the @samp{-h} option and the argument is always
|
||||
indispensable.
|
||||
|
||||
@item -i[@var{out-tabchar}[@var{out-tabwidth}]]
|
||||
@itemx --output-tabs[=@var{out-tabchar}[@var{out-tabwidth}]]
|
||||
@opindex -i
|
||||
@opindex --output-tabs
|
||||
@cindex output tabs
|
||||
Replace spaces with tabs on output. Optional argument @var{out-tabchar}
|
||||
Replace spaces with @var{tab}s on output. Optional argument @var{out-tabchar}
|
||||
is the output tab character (default is @key{TAB}). Second optional
|
||||
argument @var{out-tabwidth} is the output tab character's width (default
|
||||
is 8).
|
||||
|
||||
@item -j
|
||||
@item -J
|
||||
@itemx --join-lines
|
||||
@opindex -j
|
||||
@opindex -J
|
||||
@opindex --join-lines
|
||||
Merge lines of full length. Used together with the column options
|
||||
@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}. Turns off
|
||||
@samp{-w} line truncation; no column alignment used; may be used with
|
||||
@samp{-s[@var{separator}]}.
|
||||
Merge lines of full length. Used together with the column options
|
||||
@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}. Turns off
|
||||
@samp{-W/-w} line truncation;
|
||||
no column alignment used; may be used with @samp{-S[@var{string}]}.
|
||||
@samp{-J} has been introduced (together with @samp{-W} and @samp{-S})
|
||||
to disentangle the old (@var{posix} compliant) options @samp{-w} and
|
||||
@samp{-s} along with the three column options.
|
||||
|
||||
|
||||
@item -l @var{page_length}
|
||||
@itemx --length=@var{page_length}
|
||||
@opindex -l
|
||||
@opindex --length
|
||||
Set the page length to @var{page_length} (default 66) lines. If
|
||||
@var{page_length} is less than or equal 10 (and <= 3 with @samp{-f}),
|
||||
the headers and footers are omitted, and all form feeds set in input
|
||||
files are eliminated, as if the @samp{-T} option had been given.
|
||||
Set the page length to @var{page_length} (default 66) lines, including
|
||||
the lines of the header [and the footer]. If @var{page_length} is less
|
||||
than or equal 10 (and <= 3 with @samp{-F}), the header and footer are
|
||||
omitted, and all form feeds set in input files are eliminated, as if
|
||||
the @samp{-T} option had been given.
|
||||
|
||||
@item -m
|
||||
@itemx --merge
|
||||
@opindex -m
|
||||
@opindex --merge
|
||||
Merge and print all @var{file}s in parallel, one in each column. If a
|
||||
line is too long to fit in a column, it is truncated (but see
|
||||
@samp{-j}). @samp{-s[@var{separator}]} may be used. Empty pages in some
|
||||
@var{file}s (form feeds set) produce empty columns, still marked by
|
||||
@var{separator}. Completely empty common pages show no separators or
|
||||
line numbers. The default header becomes
|
||||
@samp{yy-mm-dd HH:MM <blanks> Page nnnn}; may be used with
|
||||
@samp{-h @var{header}} to fill up the middle part.
|
||||
|
||||
Merge and print all @var{file}s in parallel, one in each column. If a
|
||||
line is too long to fit in a column, it is truncated, unless @samp{-J}
|
||||
option is used. @samp{-S[@var{string}]} may be used. Empty pages in
|
||||
some @var{file}s (form feeds set) produce empty columns, still marked
|
||||
by @var{string}. The result is a continuous line numbering and column
|
||||
marking throughout the whole merged file. Completely empty merged pages
|
||||
show no separators or line numbers. The default header becomes
|
||||
@samp{yyyy-mm-dd HH:MM <blanks> Page nnnn}; may be used with
|
||||
@samp{-h @var{header}} to fill up the middle blank part.
|
||||
|
||||
@item -n[@var{number-separator}[@var{digits}]]
|
||||
@itemx --number-lines[=@var{number-separator}[@var{digits}]]
|
||||
@opindex -n
|
||||
@opindex --number-lines
|
||||
Precede each column with a line number; with parallel @var{file}s
|
||||
(@samp{-m}), precede only each line with a line number. Optional argument
|
||||
@var{number-separator} is the character to print after each number
|
||||
(default is @key{TAB}). Optional argument @var{digits} is the number of
|
||||
digits per line number (default is 5). Default line counting starts with
|
||||
first line of the input file (not with the first line printed, see
|
||||
@samp{-N}).
|
||||
Provide @var{digits} digit line numbering (default for @var{digits} is
|
||||
5). With multicolumn output the number occupies the first @var{digits}
|
||||
column positions of each text column or only each line of @samp{-m}
|
||||
output. With single column output the number precedes each line just as
|
||||
@samp{-m} does. Default counting of the line numbers starts with 1st
|
||||
line of the input file (not the 1st line printed, compare the
|
||||
@samp{--page} option and @samp{-N} option).
|
||||
Optional argument @var{number-separator} is the character appended to
|
||||
the line number to separate it from the text followed. The default
|
||||
separator is a @key{TAB}. In a strict sense a @key{TAB} is always
|
||||
printed with single column output only. The @var{TAB}-width varies
|
||||
with the @var{TAB}-position, e.g. with the left @var{margin} specified
|
||||
by @samp{-o} option. With multicolumn output priority is given to
|
||||
@samp{equal width of output columns} (a @var{posix} specification).
|
||||
The @var{TAB}-width is fixed to the value of the 1st column and does
|
||||
not change with different values of left @var{margin}. That means a
|
||||
fixed number of spaces is always printed in the place of the
|
||||
@var{number-separator tab}. The tabification depends upon the output
|
||||
position.
|
||||
|
||||
@item -N @var{line_number}
|
||||
@itemx --first-line-number=@var{line_number}
|
||||
@opindex -N
|
||||
@opindex --first-line-number
|
||||
Start line counting with no. @var{line_number} at first line of first
|
||||
page printed.
|
||||
Start line counting with the number @var{line_number} at first line of
|
||||
first page printed (in most cases not the first line of the input file).
|
||||
|
||||
@item -o @var{n}
|
||||
@itemx --indent=@var{n}
|
||||
@item -o @var{margin}
|
||||
@itemx --indent=@var{margin}
|
||||
@opindex -o
|
||||
@opindex --indent
|
||||
@cindex indenting lines
|
||||
@cindex left margin
|
||||
Indent each line with @var{n} (default is zero) spaces wide, i.e., set
|
||||
the left margin. The total page width is @var{n} plus the width set
|
||||
with the @samp{-w} option.
|
||||
Indent each line with a margin @var{margin} spaces wide (default is zero).
|
||||
The total page width is the size of the margin plus the @var{page_width}
|
||||
set with the @samp{-W/-w} option. A limited overflow may occur with
|
||||
numbered single column output (compare @samp{-n} option).
|
||||
|
||||
@item -r
|
||||
@itemx --no-file-warnings
|
||||
@@ -1140,34 +1187,50 @@ with the @samp{-w} option.
|
||||
Do not print a warning message when an argument @var{file} cannot be
|
||||
opened. (The exit status will still be nonzero, however.)
|
||||
|
||||
@item -s[@var{separator}]
|
||||
@itemx --separator[=@var{separator}]
|
||||
@item -s[@var{char}]
|
||||
@itemx --separator[=@var{char}]
|
||||
@opindex -s
|
||||
@opindex --separator
|
||||
Separate columns by a string @var{separator}. Don't use
|
||||
@samp{-s @var{separator}}, no space between flag and argument. If this
|
||||
option is omitted altogether, the default is @key{TAB} together with
|
||||
@samp{-j} option and space otherwise (same as @samp{-s" "}). With
|
||||
@samp{-s} only, no separator is used (same as @samp{-s""}). @samp{-s}
|
||||
does not affect line truncation or column alignment.
|
||||
Separate columns by a single character @var{char}. Default for @var{char}
|
||||
is the @key{TAB} character without @samp{-w} and @samp{no character} with
|
||||
@samp{-w}. Without @samp{-s} default separator @samp{space} is set.
|
||||
@samp{-s[char]} turns off line truncation of all three column options
|
||||
(@samp{-COLUMN}|@samp{-a -COLUMN}|@samp{-m}) except @samp{-w} is set.
|
||||
That is a @var{posix} compliant formulation.
|
||||
|
||||
|
||||
@item -S[@var{string}]
|
||||
@itemx --sep-string[=@var{string}]
|
||||
@opindex -S
|
||||
@opindex --sep-string
|
||||
Separate columns by any string @var{string}. The @samp{-S} option doesn't
|
||||
react upon the @samp{-W/-w} option (unlike @samp{-s} option does). It
|
||||
does not affect line truncation or column alignment. A separator is
|
||||
defined, nothing else. Without @samp{-S}: default separator @key{TAB}
|
||||
is used with @samp{-J} and @samp{space} otherwise (same as @samp{-S" "}).
|
||||
With @samp{-S} only: no separator is used, same as @samp{-S""}. Quotes
|
||||
should be used with blanks and some shell active characters. Some of the
|
||||
@code{pr} options don't allow the option letter to be separated from its
|
||||
argument. @samp{-S/-s} is one of them. Don't use @samp{-S "STRING"}.
|
||||
That's @var{posix} compliant.
|
||||
|
||||
@item -t
|
||||
@itemx --omit-header
|
||||
@opindex -t
|
||||
@opindex --omit-header
|
||||
Do not print the usual header [and footer] on each page, and do not fill
|
||||
out the bottoms of pages (with blank lines or a form feed). No page
|
||||
structure is produced, but retain form feeds set in the input files. The
|
||||
predefined page layout is not changed. @samp{-t} or @samp{-T} may be
|
||||
useful together with other options; e.g.: @samp{-t -e4}, expand
|
||||
@key{TAB} in the input file to 4 spaces but do not do any other changes.
|
||||
Use of @samp{-t} overrides @samp{-h}.
|
||||
out the bottom of pages (with blank lines or a form feed). No page
|
||||
structure is produced, but form feeds set in the input files are retained.
|
||||
The predefined pagination is not changed. @samp{-t} or @samp{-T} may be
|
||||
useful together with other options; e.g.: @samp{-t -e4}, expand @key{TAB}
|
||||
in the input file to 4 spaces but don't make any other changes. Use of
|
||||
@samp{-t} overrides @samp{-h}.
|
||||
|
||||
@item -T
|
||||
@itemx --omit-pagination
|
||||
@opindex -T
|
||||
@opindex --omit-pagination
|
||||
Do not print header [and footer]. In addition eliminate all form feeds
|
||||
Do not print header [and footer]. In addition eliminate all form feeds
|
||||
set in the input files.
|
||||
|
||||
@item -v
|
||||
@@ -1180,14 +1243,28 @@ Print unprintable characters in octal backslash notation.
|
||||
@itemx --width=@var{page_width}
|
||||
@opindex -w
|
||||
@opindex --width
|
||||
Set the page width to @var{page_width} (default 72) characters.
|
||||
With/without @samp{-w}, header lines are always truncated to
|
||||
@var{page_width} characters. With @samp{-w}, text lines are truncated,
|
||||
unless @samp{-j} is used. Without @samp{-w} together with one of the
|
||||
column options @samp{-@var{column}}, @samp{-a -@var{column}} or
|
||||
@samp{-m}, default truncation of text lines to 72 characters is used.
|
||||
Without @samp{-w} and without any of the column options, no line
|
||||
truncation is used. That's equivalent to @samp{-w 72 -j}.
|
||||
Set page width to @var{page_width} characters for multiple text-column
|
||||
output only (default for @var{page_width} is 72). @samp{-s[CHAR]} turns
|
||||
off the default page width and any line truncation and column alignment.
|
||||
Lines of full length are merged, regardless of the column options
|
||||
set. No @var{page_width} setting is possible with single column output.
|
||||
A @var{posix} compliant formulation.
|
||||
|
||||
@item -W @var{page_width}
|
||||
@itemx --page_width=@var{page_width}
|
||||
@opindex -W
|
||||
@opindex --page_width
|
||||
Set the page width to @var{page_width} characters. That's valid with and
|
||||
without a column option. Text lines are truncated, unless @samp{-J}
|
||||
is used. Together with one of the three column options
|
||||
(@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}) column
|
||||
alignment is always used. The separator options @samp{-S} or @samp{-s}
|
||||
don't affect the @samp{-W} option. Default is 72 characters. Without
|
||||
@samp{-W @var{page_width}} and without any of the column options NO line
|
||||
truncation is used (defined to keep downward compatibility and to meet
|
||||
most frequent tasks). That's equivalent to @samp{-W 72 -J}. With and
|
||||
without @samp{-W @var{page_width}} the header line is always truncated
|
||||
to avoid line overflow.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -1207,7 +1284,7 @@ lines. Synopsis:
|
||||
fold [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@end example
|
||||
|
||||
By default, @code{fold} breaks lines wider than 80 columns. The output
|
||||
By default, @code{fold} breaks lines wider than 80 columns. The output
|
||||
is split into as many lines as necessary.
|
||||
|
||||
@cindex screen columns
|
||||
@@ -1991,7 +2068,7 @@ addition, if the final byte of an input file is not a newline, GNU
|
||||
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
|
||||
If the environment variable @env{TMPDIR} is set, @code{sort} uses its
|
||||
value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@samp{-T @var{tempdir}} option in turn overrides the environment
|
||||
variable.
|
||||
@@ -2113,8 +2190,10 @@ check that no pair of consecutive lines compares equal.
|
||||
@cindex sort field
|
||||
The recommended, @sc{POSIX}, option for specifying a sort field. The field
|
||||
consists of the part 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.
|
||||
end of the line, if @var{pos2} is omitted), @emph{inclusive}.
|
||||
Fields and character positions are numbered starting with 1.
|
||||
So to sort on the second field, you'd use @samp{-k 2,2}
|
||||
See below for more examples.
|
||||
|
||||
@item -z
|
||||
@opindex -z
|
||||
@@ -2884,7 +2963,7 @@ line width computations.
|
||||
All 256 characters, even @kbd{NUL}s, are always read and processed from
|
||||
input file with no adverse effect, even if GNU extensions are disabled.
|
||||
However, System V @code{ptx} does not accept 8-bit characters, a few
|
||||
control characters are rejected, and the tilda @kbd{~} is condemned.
|
||||
control characters are rejected, and the tilde @kbd{~} is condemned.
|
||||
|
||||
@item
|
||||
Input line length is only limited by available memory, even if GNU
|
||||
@@ -2967,12 +3046,12 @@ take up 1 character.
|
||||
Print only the fields listed in @var{field-list}. Fields are
|
||||
separated by a @key{TAB} by default.
|
||||
|
||||
@item -d @var{delim}
|
||||
@itemx --delimiter=@var{delim}
|
||||
@item -d @var{input_delim_byte}
|
||||
@itemx --delimiter=@var{input_delim_byte}
|
||||
@opindex -d
|
||||
@opindex --delimiter
|
||||
For @samp{-f}, fields are separated by the first character in @var{delim}
|
||||
(default is @key{TAB}).
|
||||
For @samp{-f}, fields are separated in the input by the first character
|
||||
in @var{input_delim_byte} (default is @key{TAB}).
|
||||
|
||||
@item -n
|
||||
@opindex -n
|
||||
@@ -2985,6 +3064,12 @@ Do not split multi-byte characters (no-op for now).
|
||||
For @samp{-f}, do not print lines that do not contain the field separator
|
||||
character.
|
||||
|
||||
@itemx --output-delimiter=@var{output_delim_string}
|
||||
@opindex --output-delimiter
|
||||
For @samp{-f}, output fields are separated by @var{output_delim_string}
|
||||
The default is to use the input delimiter.
|
||||
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -3443,7 +3528,7 @@ cat "$@@" \
|
||||
@subsection Warning messages
|
||||
|
||||
@vindex POSIXLY_CORRECT
|
||||
Setting the environment variable @code{POSIXLY_CORRECT} turns off the
|
||||
Setting the environment variable @env{POSIXLY_CORRECT} turns off the
|
||||
following warning and error messages, for strict compliance with
|
||||
@sc{POSIX.2}. Otherwise, the following diagnostics are issued:
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
|
||||
quotearg.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
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c \
|
||||
version-etc.c xgetcwd.c xmalloc.c xstrdup.c \
|
||||
xstrtol.c xstrtoul.c xstrtoumax.c yesno.c
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
@@ -22,7 +23,7 @@ dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
version-etc.h xalloc.h xstrtol.h
|
||||
|
||||
BUILT_SOURCES = getdate.c lstat.c stat.c
|
||||
|
||||
|
||||
202
lib/Makefile.in
202
lib/Makefile.in
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -57,6 +57,10 @@ POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AMTAR = @AMTAR@
|
||||
AMTARFLAGS = @AMTARFLAGS@
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
@@ -64,8 +68,10 @@ CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DF_PROG = @DF_PROG@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -90,19 +96,32 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = ../src/ansi2knr
|
||||
|
||||
noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c addext.c argmatch.c backupfile.c basename.c closeout.c dirname.c exclude.c filemode.c full-write.c human.c idcache.c isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c quotearg.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
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c \
|
||||
addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c \
|
||||
version-etc.c xgetcwd.c xmalloc.c xstrdup.c \
|
||||
xstrtol.c xstrtoul.c xstrtoumax.c yesno.c
|
||||
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
version-etc.h xalloc.h xstrtol.h
|
||||
|
||||
|
||||
BUILT_SOURCES = getdate.c lstat.c stat.c
|
||||
@@ -119,57 +138,62 @@ CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
ANSI2KNR = ../src/ansi2knr
|
||||
libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
|
||||
am_libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
|
||||
addext$U.o argmatch$U.o backupfile$U.o basename$U.o closeout$U.o \
|
||||
dirname$U.o exclude$U.o filemode$U.o full-write$U.o human$U.o \
|
||||
idcache$U.o isdir$U.o long-options$U.o makepath$U.o modechange$U.o \
|
||||
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
|
||||
savedir$U.o stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o \
|
||||
xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
|
||||
savedir$U.o stripslash$U.o userspec$U.o version-etc$U.o xgetcwd$U.o \
|
||||
xmalloc$U.o xstrdup$U.o xstrtol$U.o xstrtoul$U.o xstrtoumax$U.o \
|
||||
yesno$U.o
|
||||
libfu_a_OBJECTS = $(am_libfu_a_OBJECTS)
|
||||
AR = ar
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_SOURCES = $(libfu_a_SOURCES)
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in TODO alloca.c chown.c error.c \
|
||||
error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
|
||||
getdate.c getgroups.c getline.c group-member.c lchown.c lstat.c \
|
||||
malloc.c memcmp.c memcpy.c memset.c mkdir.c mktime.c mountlist.c \
|
||||
obstack.c obstack.h realloc.c regex.c rename.c rmdir.c rpmatch.c stat.c \
|
||||
stpcpy.c strcasecmp.c strdup.c strftime.c strncasecmp.c strndup.c \
|
||||
strstr.c strtol.c strtoul.c strverscmp.c utime.c
|
||||
DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in TODO alloca.c \
|
||||
chown.c dup2.c error.c error.h euidaccess.c fileblocks.c fnmatch.c \
|
||||
fsusage.c ftruncate.c getdate.c getgroups.c getline.c group-member.c \
|
||||
lchown.c lstat.c malloc.c memcmp.c memcpy.c memset.c mkdir.c mktime.c \
|
||||
mountlist.c obstack.c obstack.h realloc.c regex.c rename.c rmdir.c \
|
||||
rpmatch.c stat.c stpcpy.c strcasecmp.c strdup.c strftime.c \
|
||||
strncasecmp.c strndup.c strstr.c strtol.c strtoul.c strtoull.c \
|
||||
strtoumax.c strverscmp.c utime.c
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
|
||||
.deps/backupfile.P .deps/basename.P .deps/chown.P .deps/closeout.P \
|
||||
.deps/dirname.P .deps/error.P .deps/euidaccess.P .deps/exclude.P \
|
||||
.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/fsusage.P \
|
||||
.deps/ftruncate.P .deps/full-write.P .deps/getdate.P .deps/getgroups.P \
|
||||
.deps/getline.P .deps/getopt.P .deps/getopt1.P .deps/group-member.P \
|
||||
.deps/hash.P .deps/human.P .deps/idcache.P .deps/isdir.P .deps/lchown.P \
|
||||
.deps/long-options.P .deps/lstat.P .deps/makepath.P .deps/malloc.P \
|
||||
.deps/memcmp.P .deps/memcpy.P .deps/memset.P .deps/mkdir.P \
|
||||
.deps/mktime.P .deps/modechange.P .deps/mountlist.P .deps/obstack.P \
|
||||
.deps/path-concat.P .deps/posixtm.P .deps/quotearg.P .deps/realloc.P \
|
||||
.deps/regex.P .deps/rename.P .deps/rmdir.P .deps/rpmatch.P \
|
||||
.deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stat.P \
|
||||
.deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P \
|
||||
.deps/stripslash.P .deps/strncasecmp.P .deps/strndup.P .deps/strstr.P \
|
||||
.deps/strtol.P .deps/strtoul.P .deps/strverscmp.P .deps/userspec.P \
|
||||
.deps/utime.P .deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P \
|
||||
.deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
|
||||
.deps/dirname.P .deps/dup2.P .deps/error.P .deps/euidaccess.P \
|
||||
.deps/exclude.P .deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P \
|
||||
.deps/fsusage.P .deps/ftruncate.P .deps/full-write.P .deps/getdate.P \
|
||||
.deps/getgroups.P .deps/getline.P .deps/getopt.P .deps/getopt1.P \
|
||||
.deps/group-member.P .deps/hash.P .deps/human.P .deps/idcache.P \
|
||||
.deps/isdir.P .deps/lchown.P .deps/long-options.P .deps/lstat.P \
|
||||
.deps/makepath.P .deps/malloc.P .deps/memcmp.P .deps/memcpy.P \
|
||||
.deps/memset.P .deps/mkdir.P .deps/mktime.P .deps/modechange.P \
|
||||
.deps/mountlist.P .deps/obstack.P .deps/path-concat.P .deps/posixtm.P \
|
||||
.deps/quotearg.P .deps/realloc.P .deps/regex.P .deps/rename.P \
|
||||
.deps/rmdir.P .deps/rpmatch.P .deps/safe-read.P .deps/save-cwd.P \
|
||||
.deps/savedir.P .deps/stat.P .deps/stpcpy.P .deps/strcasecmp.P \
|
||||
.deps/strdup.P .deps/strftime.P .deps/stripslash.P .deps/strncasecmp.P \
|
||||
.deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \
|
||||
.deps/strtoull.P .deps/strtoumax.P .deps/strverscmp.P .deps/userspec.P \
|
||||
.deps/utime.P .deps/version-etc.P .deps/xgetcwd.P .deps/xmalloc.P \
|
||||
.deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P .deps/xstrtoumax.P \
|
||||
.deps/yesno.P
|
||||
SOURCES = $(libfu_a_SOURCES)
|
||||
OBJECTS = $(libfu_a_OBJECTS)
|
||||
OBJECTS = $(am_libfu_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .o .s .y
|
||||
.SUFFIXES: .c .o .y
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile
|
||||
|
||||
@@ -187,12 +211,6 @@ distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
@@ -217,11 +235,49 @@ clean-kr:
|
||||
distclean-kr:
|
||||
|
||||
maintainer-clean-kr:
|
||||
getdate$U.o:
|
||||
posixtm$U.o:
|
||||
getopt$U.o:
|
||||
getopt1$U.o:
|
||||
addext$U.o:
|
||||
argmatch$U.o:
|
||||
backupfile$U.o:
|
||||
basename$U.o:
|
||||
closeout$U.o:
|
||||
dirname$U.o:
|
||||
exclude$U.o:
|
||||
filemode$U.o:
|
||||
full-write$U.o:
|
||||
human$U.o:
|
||||
idcache$U.o:
|
||||
isdir$U.o:
|
||||
long-options$U.o:
|
||||
makepath$U.o:
|
||||
modechange$U.o:
|
||||
hash$U.o:
|
||||
path-concat$U.o:
|
||||
quotearg$U.o:
|
||||
safe-read$U.o:
|
||||
save-cwd$U.o:
|
||||
savedir$U.o:
|
||||
stripslash$U.o:
|
||||
userspec$U.o:
|
||||
version-etc$U.o:
|
||||
xgetcwd$U.o:
|
||||
xmalloc$U.o:
|
||||
xstrdup$U.o:
|
||||
xstrtol$U.o:
|
||||
xstrtoul$U.o:
|
||||
xstrtoumax$U.o:
|
||||
yesno$U.o:
|
||||
|
||||
libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
|
||||
-rm -f libfu.a
|
||||
$(AR) cru libfu.a $(libfu_a_OBJECTS) $(libfu_a_LIBADD)
|
||||
$(RANLIB) libfu.a
|
||||
getdate.o:
|
||||
lstat.o:
|
||||
stat.o:
|
||||
addext_.c: addext.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/addext.c; then echo $(srcdir)/addext.c; else echo addext.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > addext_.c
|
||||
alloca_.c: alloca.c $(ANSI2KNR)
|
||||
@@ -238,6 +294,8 @@ closeout_.c: closeout.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/closeout.c; then echo $(srcdir)/closeout.c; else echo closeout.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > closeout_.c
|
||||
dirname_.c: dirname.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dirname.c; then echo $(srcdir)/dirname.c; else echo dirname.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dirname_.c
|
||||
dup2_.c: dup2.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dup2.c; then echo $(srcdir)/dup2.c; else echo dup2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dup2_.c
|
||||
error_.c: error.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/error.c; then echo $(srcdir)/error.c; else echo error.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > error_.c
|
||||
euidaccess_.c: euidaccess.c $(ANSI2KNR)
|
||||
@@ -346,12 +404,18 @@ strtol_.c: strtol.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtol.c; then echo $(srcdir)/strtol.c; else echo strtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtol_.c
|
||||
strtoul_.c: strtoul.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoul.c; then echo $(srcdir)/strtoul.c; else echo strtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoul_.c
|
||||
strtoull_.c: strtoull.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoull.c; then echo $(srcdir)/strtoull.c; else echo strtoull.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoull_.c
|
||||
strtoumax_.c: strtoumax.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoumax.c; then echo $(srcdir)/strtoumax.c; else echo strtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoumax_.c
|
||||
strverscmp_.c: strverscmp.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strverscmp.c; then echo $(srcdir)/strverscmp.c; else echo strverscmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strverscmp_.c
|
||||
userspec_.c: userspec.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/userspec.c; then echo $(srcdir)/userspec.c; else echo userspec.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > userspec_.c
|
||||
utime_.c: utime.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/utime.c; then echo $(srcdir)/utime.c; else echo utime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > utime_.c
|
||||
version-etc_.c: version-etc.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/version-etc.c; then echo $(srcdir)/version-etc.c; else echo version-etc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > version-etc_.c
|
||||
xgetcwd_.c: xgetcwd.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xgetcwd.c; then echo $(srcdir)/xgetcwd.c; else echo xgetcwd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xgetcwd_.c
|
||||
xmalloc_.c: xmalloc.c $(ANSI2KNR)
|
||||
@@ -362,26 +426,29 @@ xstrtol_.c: xstrtol.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtol.c; then echo $(srcdir)/xstrtol.c; else echo xstrtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtol_.c
|
||||
xstrtoul_.c: xstrtoul.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoul.c; then echo $(srcdir)/xstrtoul.c; else echo xstrtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoul_.c
|
||||
xstrtoumax_.c: xstrtoumax.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoumax.c; then echo $(srcdir)/xstrtoumax.c; else echo xstrtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoumax_.c
|
||||
yesno_.c: yesno.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > yesno_.c
|
||||
addext_.o alloca_.o argmatch_.o backupfile_.o basename_.o chown_.o \
|
||||
closeout_.o dirname_.o error_.o euidaccess_.o exclude_.o fileblocks_.o \
|
||||
filemode_.o fnmatch_.o fsusage_.o ftruncate_.o full-write_.o getdate_.o \
|
||||
getgroups_.o getline_.o getopt_.o getopt1_.o group-member_.o hash_.o \
|
||||
human_.o idcache_.o isdir_.o lchown_.o long-options_.o lstat_.o \
|
||||
makepath_.o malloc_.o memcmp_.o memcpy_.o memset_.o mkdir_.o mktime_.o \
|
||||
modechange_.o mountlist_.o obstack_.o path-concat_.o posixtm_.o \
|
||||
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o \
|
||||
safe-read_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
|
||||
strdup_.o strftime_.o stripslash_.o strncasecmp_.o strndup_.o strstr_.o \
|
||||
strtol_.o strtoul_.o strverscmp_.o userspec_.o utime_.o xgetcwd_.o \
|
||||
xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
|
||||
closeout_.o dirname_.o dup2_.o error_.o euidaccess_.o exclude_.o \
|
||||
fileblocks_.o filemode_.o fnmatch_.o fsusage_.o ftruncate_.o \
|
||||
full-write_.o getdate_.o getgroups_.o getline_.o getopt_.o getopt1_.o \
|
||||
group-member_.o hash_.o human_.o idcache_.o isdir_.o lchown_.o \
|
||||
long-options_.o lstat_.o makepath_.o malloc_.o memcmp_.o memcpy_.o \
|
||||
memset_.o mkdir_.o mktime_.o modechange_.o mountlist_.o obstack_.o \
|
||||
path-concat_.o posixtm_.o quotearg_.o realloc_.o regex_.o rename_.o \
|
||||
rmdir_.o rpmatch_.o safe-read_.o save-cwd_.o savedir_.o stat_.o \
|
||||
stpcpy_.o strcasecmp_.o strdup_.o strftime_.o stripslash_.o \
|
||||
strncasecmp_.o strndup_.o strstr_.o strtol_.o strtoul_.o strtoull_.o \
|
||||
strtoumax_.o strverscmp_.o userspec_.o utime_.o version-etc_.o \
|
||||
xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
|
||||
yesno_.o : $(ANSI2KNR)
|
||||
.y.c:
|
||||
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
|
||||
if test -f y.tab.h; then \
|
||||
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
|
||||
else :; fi
|
||||
getdate.h: getdate.c
|
||||
|
||||
|
||||
tags: TAGS
|
||||
@@ -426,7 +493,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
@@ -434,6 +501,7 @@ distdir: $(DISTFILES)
|
||||
fi; \
|
||||
done
|
||||
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
@@ -449,22 +517,22 @@ maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $<
|
||||
@-cp .deps/$(*D)/$(*F).pp .deps/$(*D)/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
>> .deps/$(*D)/$(*F).P; \
|
||||
rm .deps/$(*D)/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
< .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
>> .deps/$(*D)/$(*F).P; \
|
||||
rm -f .deps/$(*D)/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
@@ -487,7 +555,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
@@ -500,7 +568,7 @@ distclean-generic:
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "getdatehgetdatec$(BUILT_SOURCES)" || rm -f getdateh getdatec $(BUILT_SOURCES)
|
||||
-test -z "getdate.c$(BUILT_SOURCES)" || rm -f getdate.c $(BUILT_SOURCES)
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-kr mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
@@ -536,7 +604,7 @@ maintainer-clean-tags distdir mostlyclean-depend distclean-depend \
|
||||
clean-depend maintainer-clean-depend info-am info dvi-am dvi check \
|
||||
check-am installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
all-redirect all-am all install-strip installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename.c -- return the last element in a path
|
||||
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -29,16 +29,27 @@
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument. */
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
If NAME is all slashes, be sure to return `/'. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
int all_slashes = 1;
|
||||
char const *p;
|
||||
|
||||
for (; *name; name++)
|
||||
if (ISSLASH (*name))
|
||||
base = name + 1;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
base = p + 1;
|
||||
else
|
||||
all_slashes = 0;
|
||||
}
|
||||
|
||||
/* If NAME is all slashes, arrange to return `/'. */
|
||||
if (*base == '\0' && ISSLASH (*name) && all_slashes)
|
||||
--base;
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
void free ();
|
||||
|
||||
/* Returns the canonical hostname associated with HOST (allocated in a static
|
||||
buffer), or 0 if it can't be determined. */
|
||||
char *
|
||||
@@ -67,9 +69,23 @@ canon_host (const char *host)
|
||||
}
|
||||
|
||||
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);
|
||||
{
|
||||
/* gethostbyname has returned a string representation of the IP
|
||||
address, for example, "127.0.0.1". So now, look up the host
|
||||
name via the address. Although it may seem reasonable to look
|
||||
up the host name via the address, we must not pass `he->h_addr'
|
||||
directly to gethostbyaddr because on some systems he->h_addr
|
||||
is located in a static library buffer that is reused in the
|
||||
gethostbyaddr call. Make a copy and use that instead. */
|
||||
char *h_addr_copy = strdup (he->h_addr);
|
||||
if (h_addr_copy == NULL)
|
||||
he = NULL;
|
||||
else
|
||||
{
|
||||
he = gethostbyaddr (h_addr_copy, he->h_length, he->h_addrtype);
|
||||
free (h_addr_copy);
|
||||
}
|
||||
}
|
||||
# endif /* HAVE_GETHOSTBYADDR */
|
||||
|
||||
if (he)
|
||||
|
||||
@@ -43,14 +43,19 @@ extern int errno;
|
||||
#include "error.h"
|
||||
|
||||
/* Close standard output, exiting with status STATUS on failure.
|
||||
If a program writes *anything* to stdout, that program should close
|
||||
stdout and make sure that the close succeeds. Otherwise, suppose that
|
||||
you go to the extreme of checking the return status of every function
|
||||
that does an explicit write to stdout. The last printf can succeed in
|
||||
writing to the internal stream buffer, and yet the fclose(stdout) could
|
||||
still fail (due e.g., to a disk full error) when it tries to write
|
||||
out that buffered data. Thus, you would be left with an incomplete
|
||||
output file and the offending program would exit successfully.
|
||||
If a program writes *anything* to stdout, that program should `fflush'
|
||||
stdout and make sure that it succeeds before exiting. Otherwise,
|
||||
suppose that you go to the extreme of checking the return status
|
||||
of every function that does an explicit write to stdout. The last
|
||||
printf can succeed in writing to the internal stream buffer, and yet
|
||||
the fclose(stdout) could still fail (due e.g., to a disk full error)
|
||||
when it tries to write out that buffered data. Thus, you would be
|
||||
left with an incomplete output file and the offending program would
|
||||
exit successfully.
|
||||
|
||||
FIXME: note the fflush suggested above is implicit in the fclose
|
||||
we actually do below. Consider doing only the fflush and/or using
|
||||
setvbuf to inhibit buffering.
|
||||
|
||||
Besides, it's wasteful to check the return value from every call
|
||||
that writes to stdout -- just let the internal stream state record
|
||||
|
||||
66
lib/dup2.c
Normal file
66
lib/dup2.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Paul Eggert */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef F_DUPFD
|
||||
static int
|
||||
dupfd (int fd, int desired_fd)
|
||||
{
|
||||
int duplicated_fd = dup (fd);
|
||||
if (duplicated_fd < 0 || duplicated_fd == desired_fd)
|
||||
return duplicated_fd;
|
||||
else
|
||||
{
|
||||
int r = dupfd (fd, desired_fd);
|
||||
int e = errno;
|
||||
close (duplicated_fd);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
dup2 (int fd, int desired_fd)
|
||||
{
|
||||
if (fd == desired_fd)
|
||||
return fd;
|
||||
close (desired_fd);
|
||||
#ifdef F_DUPFD
|
||||
return fcntl (fd, F_DUPFD, desired_fd);
|
||||
#else
|
||||
return dupfd (fd, desired_fd);
|
||||
#endif
|
||||
}
|
||||
@@ -48,6 +48,25 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !S_IRGRP
|
||||
# define S_IRGRP (S_IRUSR >> 3)
|
||||
#endif
|
||||
#if !S_IWGRP
|
||||
# define S_IWGRP (S_IWUSR >> 3)
|
||||
#endif
|
||||
#if !S_IXGRP
|
||||
# define S_IXGRP (S_IXUSR >> 3)
|
||||
#endif
|
||||
#if !S_IROTH
|
||||
# define S_IROTH (S_IRUSR >> 6)
|
||||
#endif
|
||||
#if !S_IWOTH
|
||||
# define S_IWOTH (S_IWUSR >> 6)
|
||||
#endif
|
||||
#if !S_IXOTH
|
||||
# define S_IXOTH (S_IXUSR >> 6)
|
||||
#endif
|
||||
|
||||
#ifdef STAT_MACROS_BROKEN
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
@@ -93,22 +112,11 @@
|
||||
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
|
||||
#endif
|
||||
|
||||
/* Look at read, write, and execute bits in BITS and set
|
||||
flags in CHARS accordingly. */
|
||||
|
||||
static void
|
||||
rwx (short unsigned int bits, char *chars)
|
||||
{
|
||||
chars[0] = (bits & S_IRUSR) ? 'r' : '-';
|
||||
chars[1] = (bits & S_IWUSR) ? 'w' : '-';
|
||||
chars[2] = (bits & S_IXUSR) ? 'x' : '-';
|
||||
}
|
||||
|
||||
/* Set the 's' and 't' flags in file attributes string CHARS,
|
||||
according to the file mode BITS. */
|
||||
|
||||
static void
|
||||
setst (short unsigned int bits, char *chars)
|
||||
setst (mode_t bits, char *chars)
|
||||
{
|
||||
#ifdef S_ISUID
|
||||
if (bits & S_ISUID)
|
||||
@@ -157,7 +165,7 @@ setst (short unsigned int bits, char *chars)
|
||||
'?' for any other file type. */
|
||||
|
||||
static char
|
||||
ftypelet (long int bits)
|
||||
ftypelet (mode_t bits)
|
||||
{
|
||||
#ifdef S_ISBLK
|
||||
if (S_ISBLK (bits))
|
||||
@@ -216,12 +224,18 @@ ftypelet (long int bits)
|
||||
is given as an argument. */
|
||||
|
||||
void
|
||||
mode_string (short unsigned int mode, char *str)
|
||||
mode_string (mode_t mode, char *str)
|
||||
{
|
||||
str[0] = ftypelet ((long) mode);
|
||||
rwx ((mode & 0700) << 0, &str[1]);
|
||||
rwx ((mode & 0070) << 3, &str[4]);
|
||||
rwx ((mode & 0007) << 6, &str[7]);
|
||||
str[0] = ftypelet (mode);
|
||||
str[1] = mode & S_IRUSR ? 'r' : '-';
|
||||
str[2] = mode & S_IWUSR ? 'w' : '-';
|
||||
str[3] = mode & S_IXUSR ? 'x' : '-';
|
||||
str[4] = mode & S_IRGRP ? 'r' : '-';
|
||||
str[5] = mode & S_IWGRP ? 'w' : '-';
|
||||
str[6] = mode & S_IXGRP ? 'x' : '-';
|
||||
str[7] = mode & S_IROTH ? 'r' : '-';
|
||||
str[8] = mode & S_IWOTH ? 'w' : '-';
|
||||
str[9] = mode & S_IXOTH ? 'x' : '-';
|
||||
setst (mode, str);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FILEMODE_H_
|
||||
|
||||
void mode_string PARAMS ((short unsigned int mode, char *str));
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
void mode_string PARAMS ((mode_t mode, char *str));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# ifdef FORCE_ALLOCA_H
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
@@ -28,6 +28,10 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h> /* for `free'; used by Bison 1.27 */
|
||||
#endif
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
@@ -706,7 +710,7 @@ LookupWord (buff)
|
||||
|
||||
/* Make it lowercase. */
|
||||
for (p = buff; *p; p++)
|
||||
if (ISUPPER (*p))
|
||||
if (ISUPPER ((unsigned char) *p))
|
||||
*p = tolower (*p);
|
||||
|
||||
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
|
||||
@@ -787,7 +791,7 @@ LookupWord (buff)
|
||||
}
|
||||
|
||||
/* Military timezones. */
|
||||
if (buff[1] == '\0' && ISALPHA (*buff))
|
||||
if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff))
|
||||
{
|
||||
for (tp = MilitaryTable; tp->name; tp++)
|
||||
if (strcmp (buff, tp->name) == 0)
|
||||
@@ -818,7 +822,7 @@ LookupWord (buff)
|
||||
static int
|
||||
yylex ()
|
||||
{
|
||||
register char c;
|
||||
register unsigned char c;
|
||||
register char *p;
|
||||
char buff[20];
|
||||
int Count;
|
||||
@@ -826,7 +830,7 @@ yylex ()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
while (ISSPACE (*yyInput))
|
||||
while (ISSPACE ((unsigned char) *yyInput))
|
||||
yyInput++;
|
||||
|
||||
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
|
||||
@@ -877,8 +881,7 @@ yylex ()
|
||||
|
||||
/* Yield A - B, measured in seconds. */
|
||||
static long
|
||||
difftm (a, b)
|
||||
struct tm *a, *b;
|
||||
difftm (struct tm *a, struct tm *b)
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
@@ -906,12 +909,15 @@ get_date (const char *p, const time_t *now)
|
||||
yyInput = p;
|
||||
Start = now ? *now : time ((time_t *) NULL);
|
||||
tmp = localtime (&Start);
|
||||
if (!tmp)
|
||||
return -1;
|
||||
yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
|
||||
yyMonth = tmp->tm_mon + 1;
|
||||
yyDay = tmp->tm_mday;
|
||||
yyHour = tmp->tm_hour;
|
||||
yyMinutes = tmp->tm_min;
|
||||
yySeconds = tmp->tm_sec;
|
||||
tm.tm_isdst = tmp->tm_isdst;
|
||||
yyMeridian = MER24;
|
||||
yyRelSeconds = 0;
|
||||
yyRelMinutes = 0;
|
||||
@@ -947,7 +953,6 @@ get_date (const char *p, const time_t *now)
|
||||
tm.tm_hour += yyRelHour;
|
||||
tm.tm_min += yyRelMinutes;
|
||||
tm.tm_sec += yyRelSeconds;
|
||||
tm.tm_isdst = -1;
|
||||
tm0 = tm;
|
||||
|
||||
Start = mktime (&tm);
|
||||
@@ -994,7 +999,11 @@ get_date (const char *p, const time_t *now)
|
||||
|
||||
if (yyHaveZone)
|
||||
{
|
||||
long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
|
||||
long delta;
|
||||
struct tm *gmt = gmtime (&Start);
|
||||
if (!gmt)
|
||||
return -1;
|
||||
delta = yyTimezone * 60L + difftm (&tm, gmt);
|
||||
if ((Start + delta < Start) != (delta < 0))
|
||||
return -1; /* time_t overflow */
|
||||
Start += delta;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* provide consistent interface to getgroups for systems that don't allow N==0
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,14 +25,11 @@ char *xmalloc ();
|
||||
|
||||
/* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, 0) always fails.
|
||||
On other systems, it returns the number of supplemental groups for the
|
||||
process is returned.
|
||||
This function handles that special case and lets the system-
|
||||
provided function handle all others. */
|
||||
process. This function handles that special case and lets the system-
|
||||
provided function handle all others. */
|
||||
|
||||
int
|
||||
getgroups (n, group)
|
||||
size_t n;
|
||||
GETGROUPS_T *group;
|
||||
getgroups (size_t n, GETGROUPS_T *group)
|
||||
{
|
||||
int n_groups;
|
||||
GETGROUPS_T *gbuf;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* getugroups.c -- return a list of the groups a user is in
|
||||
Copyright (C) 1990, 1991, 1998 Free Software Foundation.
|
||||
Copyright (C) 1990, 1991, 1998, 1999 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
|
||||
@@ -41,16 +41,27 @@ struct group *getgrent ();
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* Like `getgroups', but for user USERNAME instead of for
|
||||
the current process. */
|
||||
/* Like `getgroups', but for user USERNAME instead of for the current
|
||||
process. Store at most MAXCOUNT group IDs in the GROUPLIST array.
|
||||
If GID is not -1, store it first (if possible). GID should be the
|
||||
group ID (pw_gid) obtained from getpwuid, in case USERNAME is not
|
||||
listed in /etc/groups.
|
||||
Always return the number of groups of which USERNAME is a member. */
|
||||
|
||||
int
|
||||
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username)
|
||||
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid)
|
||||
{
|
||||
struct group *grp;
|
||||
register char **cp;
|
||||
register int count = 0;
|
||||
|
||||
if (gid != -1)
|
||||
{
|
||||
if (maxcount != 0)
|
||||
grouplist[count] = gid;
|
||||
++count;
|
||||
}
|
||||
|
||||
setgrent ();
|
||||
while ((grp = getgrent ()) != 0)
|
||||
for (cp = grp->gr_mem; *cp; ++cp)
|
||||
|
||||
371
lib/hash.c
371
lib/hash.c
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering, 1992.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -54,10 +54,10 @@ char *malloc ();
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
/* An hash table contains many internal entries, each holding a pointer to
|
||||
/* A hash table contains many internal entries, each holding a pointer to
|
||||
some user provided data (also called a user entry). An entry indistinctly
|
||||
refers to both the internal entry and its associated user entry. A user
|
||||
entry contents may be hashed by a randomisation function (the hashing
|
||||
entry contents may be hashed by a randomization function (the hashing
|
||||
function, or just `hasher' for short) into a number (or `slot') between 0
|
||||
and the current table size. At each slot position in the hash table,
|
||||
starts a linked chain of entries for which the user data all hash to this
|
||||
@@ -66,32 +66,58 @@ char *malloc ();
|
||||
A good `hasher' function will distribute entries rather evenly in buckets.
|
||||
In the ideal case, the length of each bucket is roughly the number of
|
||||
entries divided by the table size. Finding the slot for a data is usually
|
||||
done at constant speed by the `hasher', and the later finding of a precise
|
||||
done in constant time by the `hasher', and the later finding of a precise
|
||||
entry is linear in time with the size of the bucket. Consequently, a
|
||||
bigger hash table size (that is, a bigger number of buckets) is prone to
|
||||
yielding shorter buckets, *given* the `hasher' function behaves properly.
|
||||
larger hash table size (that is, a larger number of buckets) is prone to
|
||||
yielding shorter chains, *given* the `hasher' function behaves properly.
|
||||
|
||||
Long buckets slow down the lookup algorithm. One might use big hash table
|
||||
sizes in hope to reduce the average length of buckets, but this might
|
||||
become inordinate, as unused slots in the hash table take some space. The
|
||||
best bet is to make sure you are using a good `hasher' function (beware
|
||||
that those are not that easy to write! :-), and to use a table size at
|
||||
least bigger than the actual number of entries.
|
||||
that those are not that easy to write! :-), and to use a table size
|
||||
larger than the actual number of entries. */
|
||||
|
||||
Currently, whenever the addition of an entry gets 80% of buckets to be
|
||||
non-empty, this package automatically doubles the number of buckets. */
|
||||
/* If an insertion makes the ratio of nonempty buckets to table size larger
|
||||
than the growth threshold (a number between 0.0 and 1.0), then increase
|
||||
the table size by multiplying by the growth factor (a number greater than
|
||||
1.0). The growth threshold defaults to 0.8, and the growth factor
|
||||
defaults to 1.414, meaning that the table will have doubled its size
|
||||
every second time 80% of the buckets get used. */
|
||||
#define DEFAULT_GROWTH_THRESHOLD 0.8
|
||||
#define DEFAULT_GROWTH_FACTOR 1.414
|
||||
|
||||
/* If a deletion empties a bucket and causes the ratio of used buckets to
|
||||
table size to become smaller than the shrink threshold (a number between
|
||||
0.0 and 1.0), then shrink the table by multiplying by the shrink factor (a
|
||||
number greater than the shrink threshold but smaller than 1.0). The shrink
|
||||
threshold and factor default to 0.0 and 1.0, meaning that the table never
|
||||
shrinks. */
|
||||
#define DEFAULT_SHRINK_THRESHOLD 0.0
|
||||
#define DEFAULT_SHRINK_FACTOR 1.0
|
||||
|
||||
/* Use this to initialize or reset a TUNING structure to
|
||||
some sensible values. */
|
||||
static const Hash_tuning default_tuning =
|
||||
{
|
||||
DEFAULT_SHRINK_THRESHOLD,
|
||||
DEFAULT_SHRINK_FACTOR,
|
||||
DEFAULT_GROWTH_THRESHOLD,
|
||||
DEFAULT_GROWTH_FACTOR,
|
||||
false
|
||||
};
|
||||
|
||||
/* Information and lookup. */
|
||||
|
||||
/* The following few functions provide information about the overall hash
|
||||
table organisation: the number of entries, number of buckets and maximum
|
||||
table organization: the number of entries, number of buckets and maximum
|
||||
length of buckets. */
|
||||
|
||||
/* Return the number of buckets in the hash table. The table size, the total
|
||||
number of buckets (used plus unused), or the maximum number of slots, are
|
||||
the same quantity. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_buckets (const Hash_table *table)
|
||||
{
|
||||
return table->n_buckets;
|
||||
@@ -99,7 +125,7 @@ hash_get_n_buckets (const Hash_table *table)
|
||||
|
||||
/* Return the number of slots in use (non-empty buckets). */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_buckets_used (const Hash_table *table)
|
||||
{
|
||||
return table->n_buckets_used;
|
||||
@@ -107,26 +133,26 @@ hash_get_n_buckets_used (const Hash_table *table)
|
||||
|
||||
/* Return the number of active entries. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_entries (const Hash_table *table)
|
||||
{
|
||||
return table->n_entries;
|
||||
}
|
||||
|
||||
/* Return the length of the most lenghty chain (bucket). */
|
||||
/* Return the length of the longest chain (bucket). */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_max_bucket_length (const Hash_table *table)
|
||||
{
|
||||
struct hash_entry *bucket;
|
||||
unsigned int max_bucket_length = 0;
|
||||
unsigned max_bucket_length = 0;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
if (bucket->data)
|
||||
{
|
||||
struct hash_entry *cursor = bucket;
|
||||
unsigned int bucket_length = 1;
|
||||
unsigned bucket_length = 1;
|
||||
|
||||
while (cursor = cursor->next, cursor)
|
||||
bucket_length++;
|
||||
@@ -139,15 +165,15 @@ hash_get_max_bucket_length (const Hash_table *table)
|
||||
return max_bucket_length;
|
||||
}
|
||||
|
||||
/* Do a mild validation of an hash table, by traversing it and checking two
|
||||
/* Do a mild validation of a hash table, by traversing it and checking two
|
||||
statistics. */
|
||||
|
||||
bool
|
||||
hash_table_ok (const Hash_table *table)
|
||||
{
|
||||
struct hash_entry *bucket;
|
||||
unsigned int n_buckets_used = 0;
|
||||
unsigned int n_entries = 0;
|
||||
unsigned n_buckets_used = 0;
|
||||
unsigned n_entries = 0;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
@@ -174,10 +200,10 @@ hash_table_ok (const Hash_table *table)
|
||||
void
|
||||
hash_print_statistics (const Hash_table *table, FILE *stream)
|
||||
{
|
||||
unsigned int n_entries = hash_get_n_entries (table);
|
||||
unsigned int n_buckets = hash_get_n_buckets (table);
|
||||
unsigned int n_buckets_used = hash_get_n_buckets_used (table);
|
||||
unsigned int max_bucket_length = hash_get_max_bucket_length (table);
|
||||
unsigned n_entries = hash_get_n_entries (table);
|
||||
unsigned n_buckets = hash_get_n_buckets (table);
|
||||
unsigned n_buckets_used = hash_get_n_buckets_used (table);
|
||||
unsigned max_bucket_length = hash_get_max_bucket_length (table);
|
||||
|
||||
fprintf (stream, "# entries: %u\n", n_entries);
|
||||
fprintf (stream, "# buckets: %u\n", n_buckets);
|
||||
@@ -186,8 +212,8 @@ hash_print_statistics (const Hash_table *table, FILE *stream)
|
||||
fprintf (stream, "max bucket length: %u\n", max_bucket_length);
|
||||
}
|
||||
|
||||
/* Return the user entry from the hash table, if some entry in the hash table
|
||||
compares equally with ENTRY, or NULL otherwise. */
|
||||
/* If ENTRY matches an entry already in the hash table, return the
|
||||
entry from the table. Otherwise, return NULL. */
|
||||
|
||||
void *
|
||||
hash_lookup (const Hash_table *table, const void *entry)
|
||||
@@ -229,7 +255,7 @@ hash_get_first (const Hash_table *table)
|
||||
if (bucket->data)
|
||||
return bucket->data;
|
||||
|
||||
abort ();
|
||||
assert (0);
|
||||
}
|
||||
|
||||
/* Return the user data for the entry following ENTRY, where ENTRY has been
|
||||
@@ -263,11 +289,11 @@ hash_get_next (const Hash_table *table, const void *entry)
|
||||
return the number of pointers copied. Do not copy more than BUFFER_SIZE
|
||||
pointers. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_entries (const Hash_table *table, void **buffer,
|
||||
unsigned int buffer_size)
|
||||
unsigned buffer_size)
|
||||
{
|
||||
unsigned int counter = 0;
|
||||
unsigned counter = 0;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
|
||||
@@ -287,7 +313,7 @@ hash_get_entries (const Hash_table *table, void **buffer,
|
||||
return counter;
|
||||
}
|
||||
|
||||
/* Call a PROCESSOR function for each entry of an hash table, and return the
|
||||
/* Call a PROCESSOR function for each entry of a hash table, and return the
|
||||
number of entries for which the processor function returned success. A
|
||||
pointer to some PROCESSOR_DATA which will be made available to each call to
|
||||
the processor function. The PROCESSOR accepts two arguments: the first is
|
||||
@@ -295,11 +321,11 @@ hash_get_entries (const Hash_table *table, void **buffer,
|
||||
as received. The walking continue for as long as the PROCESSOR function
|
||||
returns nonzero. When it returns zero, the walking is interrupted. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_do_for_each (const Hash_table *table, Hash_processor processor,
|
||||
void *processor_data)
|
||||
{
|
||||
unsigned int counter = 0;
|
||||
unsigned counter = 0;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
|
||||
@@ -332,8 +358,8 @@ hash_do_for_each (const Hash_table *table, Hash_processor processor,
|
||||
algorithms tend to be domain-specific, so what's good for [diffutils'] io.c
|
||||
may not be good for your application." */
|
||||
|
||||
unsigned int
|
||||
hash_string (const char *string, unsigned int n_buckets)
|
||||
unsigned
|
||||
hash_string (const char *string, unsigned n_buckets)
|
||||
{
|
||||
# ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
@@ -360,8 +386,8 @@ hash_string (const char *string, unsigned int n_buckets)
|
||||
very old Cyber `snoop', itself written in typical Greg Mansfield style.
|
||||
(By the way, what happened to this excellent man? Is he still alive?) */
|
||||
|
||||
unsigned int
|
||||
hash_string (const char *string, unsigned int n_buckets)
|
||||
unsigned
|
||||
hash_string (const char *string, unsigned n_buckets)
|
||||
{
|
||||
unsigned value = 0;
|
||||
|
||||
@@ -376,7 +402,7 @@ hash_string (const char *string, unsigned int n_buckets)
|
||||
/* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd
|
||||
number at least equal to 11. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
is_prime (unsigned long candidate)
|
||||
{
|
||||
unsigned long divisor = 3;
|
||||
@@ -393,12 +419,14 @@ is_prime (unsigned long candidate)
|
||||
}
|
||||
|
||||
/* Round a given CANDIDATE number up to the nearest prime, and return that
|
||||
prime. CANDIDATE should be at least equal to 10. */
|
||||
prime. Primes lower than 10 are merely skipped. */
|
||||
|
||||
static unsigned long
|
||||
next_prime (unsigned long candidate)
|
||||
{
|
||||
assert (candidate >= 10);
|
||||
/* Skip small primes. */
|
||||
if (candidate < 10)
|
||||
candidate = 10;
|
||||
|
||||
/* Make it definitely odd. */
|
||||
candidate |= 1;
|
||||
@@ -409,33 +437,73 @@ next_prime (unsigned long candidate)
|
||||
return candidate;
|
||||
}
|
||||
|
||||
/* Allocate and return a new hash table, or NULL if an error is met. The
|
||||
initial number of buckets would be at least CANDIDATE (which need not be
|
||||
prime).
|
||||
void
|
||||
hash_reset_tuning (Hash_tuning *tuning)
|
||||
{
|
||||
*tuning = default_tuning;
|
||||
}
|
||||
|
||||
If DATA_FREER is not NULL, this function may be later called with the data
|
||||
as an argument, just before they entry containing the data gets freed. The
|
||||
HASHER function should be supplied, and FIXME. The COMPARATOR function
|
||||
should also be supplied, and FIXME. */
|
||||
/* For the given hash TABLE, check the user supplied tuning structure for
|
||||
reasonable values, and return true if there is no gross error with it.
|
||||
Otherwise, definitvely reset the TUNING field to some acceptable default in
|
||||
the hash table (that is, the user loses the right of further modifying
|
||||
tuning arguments), and return false. */
|
||||
|
||||
/* User-supplied function for freeing datas. It is specified in
|
||||
hash_initialize. If non-null, it is used by hash_free and hash_clear.
|
||||
You should specify `free' here only if you want these functions to free
|
||||
all of your `data' data. This is typically the case when your data is
|
||||
simply an auxilliary struct that you have malloc'd to aggregate several
|
||||
values. */
|
||||
static bool
|
||||
check_tuning (Hash_table *table)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
|
||||
/* User-supplied hash function that hashes entry ENTRY to an integer in
|
||||
the range 0..TABLE_SIZE-1. */
|
||||
if (tuning->growth_threshold > 0.0
|
||||
&& tuning->growth_threshold < 1.0
|
||||
&& tuning->growth_factor > 1.0
|
||||
&& tuning->shrink_threshold >= 0.0
|
||||
&& tuning->shrink_threshold < 1.0
|
||||
&& tuning->shrink_factor > tuning->shrink_threshold
|
||||
&& tuning->shrink_factor <= 1.0
|
||||
&& tuning->shrink_threshold < tuning->growth_threshold)
|
||||
return true;
|
||||
|
||||
/* User-supplied function that determines whether a new entry is unique by
|
||||
comparing the new entry to entries that hashed to the same bucket
|
||||
index. It should return zero for a pair of entries that compare equal,
|
||||
non-zero otherwise. */
|
||||
table->tuning = &default_tuning;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Allocate and return a new hash table, or NULL upon failure. The
|
||||
initial number of buckets is automatically selected so as to _guarantee_ that
|
||||
you may insert at least CANDIDATE different user entries before any growth
|
||||
of the hash table size occurs. So, if have a reasonably tight a-priori
|
||||
upper bound on the
|
||||
number of entries you intend to insert in the hash table, you may save some
|
||||
table memory and insertion time, by specifying it here. If the
|
||||
IS_N_BUCKETS field of the TUNING structure is true, the CANDIDATE argument
|
||||
has its meaning changed to the wanted number of buckets.
|
||||
|
||||
TUNING points to a structure of user-supplied values, in case some fine
|
||||
tuning is wanted over the default behavior of the hasher. If TUNING is
|
||||
NULL, the default tuning parameters are used instead.
|
||||
|
||||
The user-supplied HASHER function should be provided. It accepts two
|
||||
arguments ENTRY and TABLE_SIZE. It computes, by hashing ENTRY contents, a
|
||||
slot number for that entry which should be in the range 0..TABLE_SIZE-1.
|
||||
This slot number is then returned.
|
||||
|
||||
The user-supplied COMPARATOR function should be provided. It accepts two
|
||||
arguments pointing to user data, it then returns true for a pair of entries
|
||||
that compare equal, or false otherwise. This function is internally called
|
||||
on entries which are already known to hash to the same bucket index.
|
||||
|
||||
The user-supplied DATA_FREER function, when not NULL, may be later called
|
||||
with the user data as an argument, just before the entry containing the
|
||||
data gets freed. This happens from within `hash_free' or `hash_clear'.
|
||||
You should specify this function only if you want these functions to free
|
||||
all of your `data' data. This is typically the case when your data is
|
||||
simply an auxiliary struct that you have malloc'd to aggregate several
|
||||
values. */
|
||||
|
||||
Hash_table *
|
||||
hash_initialize (unsigned int candidate, Hash_hasher hasher,
|
||||
Hash_comparator comparator, Hash_data_freer data_freer)
|
||||
hash_initialize (unsigned candidate, const Hash_tuning *tuning,
|
||||
Hash_hasher hasher, Hash_comparator comparator,
|
||||
Hash_data_freer data_freer)
|
||||
{
|
||||
Hash_table *table;
|
||||
struct hash_entry *bucket;
|
||||
@@ -447,7 +515,24 @@ hash_initialize (unsigned int candidate, Hash_hasher hasher,
|
||||
if (table == NULL)
|
||||
return NULL;
|
||||
|
||||
table->n_buckets = next_prime (candidate < 10 ? 10 : candidate);
|
||||
if (!tuning)
|
||||
tuning = &default_tuning;
|
||||
table->tuning = tuning;
|
||||
if (!check_tuning (table))
|
||||
{
|
||||
/* Fail if the tuning options are invalid. This is the only occasion
|
||||
when the user gets some feedback about it. Once the table is created,
|
||||
if the user provides invalid tuning options, we silently revert to
|
||||
using the defaults, and ignore further request to change the tuning
|
||||
options. */
|
||||
free (table);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table->n_buckets
|
||||
= next_prime (tuning->is_n_buckets ? candidate
|
||||
: (unsigned) (candidate / tuning->growth_threshold));
|
||||
|
||||
table->bucket = (struct hash_entry *)
|
||||
malloc (table->n_buckets * sizeof (struct hash_entry));
|
||||
if (table->bucket == NULL)
|
||||
@@ -515,7 +600,7 @@ hash_clear (Hash_table *table)
|
||||
table->n_entries = 0;
|
||||
}
|
||||
|
||||
/* Reclaim all storage associated with an hash table. If a data_freer
|
||||
/* Reclaim all storage associated with a hash table. If a data_freer
|
||||
function has been supplied by the user when the hash table was created,
|
||||
this function applies it to the data of each entry before freeing that
|
||||
entry. */
|
||||
@@ -682,21 +767,23 @@ hash_find_entry (Hash_table *table, const void *entry,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For an already existing hash table, change the number of buckets and make
|
||||
it NEW_TABLE_SIZE. The contents of the hash table are preserved. */
|
||||
/* For an already existing hash table, change the number of buckets through
|
||||
specifying CANDIDATE. The contents of the hash table are preserved. The
|
||||
new number of buckets is automatically selected so as to _guarantee_ that the
|
||||
table may receive at least CANDIDATE different user entries, including
|
||||
those already in the table, before any other growth of the hash table size
|
||||
occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
|
||||
exact number of buckets desired. */
|
||||
|
||||
bool
|
||||
hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
hash_rehash (Hash_table *table, unsigned candidate)
|
||||
{
|
||||
Hash_table *new_table;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
struct hash_entry *next;
|
||||
|
||||
if (table->n_buckets <= 0 || new_n_buckets == 0)
|
||||
return false;
|
||||
|
||||
new_table = hash_initialize (new_n_buckets, table->hasher,
|
||||
new_table = hash_initialize (candidate, table->tuning, table->hasher,
|
||||
table->comparator, table->data_freer);
|
||||
if (new_table == NULL)
|
||||
return false;
|
||||
@@ -709,26 +796,23 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
new_table->free_entry_list = table->free_entry_list;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
if (bucket->data)
|
||||
if (bucket->data)
|
||||
for (cursor = bucket; cursor; cursor = next)
|
||||
{
|
||||
for (cursor = bucket; cursor; cursor = next)
|
||||
void *data = cursor->data;
|
||||
struct hash_entry *new_bucket
|
||||
= (new_table->bucket
|
||||
+ new_table->hasher (data, new_table->n_buckets));
|
||||
|
||||
assert (new_bucket < new_table->bucket_limit);
|
||||
next = cursor->next;
|
||||
|
||||
if (new_bucket->data)
|
||||
{
|
||||
void *data = cursor->data;
|
||||
struct hash_entry *new_bucket
|
||||
= new_table->bucket + new_table->hasher (data, new_n_buckets);
|
||||
|
||||
assert (new_bucket < new_table->bucket_limit);
|
||||
|
||||
/* Free overflow entries as soon as possible, moving them from the
|
||||
old hash table into the new one, as they may be needed now. */
|
||||
next = cursor->next;
|
||||
if (cursor != bucket)
|
||||
free_entry (new_table, cursor);
|
||||
|
||||
/* Insert the entry into the new hash table. */
|
||||
if (new_bucket->data)
|
||||
if (cursor == bucket)
|
||||
{
|
||||
/* Allocate or recycle an entry, when moving from a bucket
|
||||
header into a bucket overflow. */
|
||||
struct hash_entry *new_entry = allocate_entry (new_table);
|
||||
|
||||
if (new_entry == NULL)
|
||||
@@ -740,12 +824,24 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
}
|
||||
else
|
||||
{
|
||||
new_bucket->data = data;
|
||||
new_table->n_buckets_used++;
|
||||
/* Merely relink an existing entry, when moving from a
|
||||
bucket overflow into a bucket overflow. */
|
||||
cursor->next = new_bucket->next;
|
||||
new_bucket->next = cursor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free an existing entry, when moving from a bucket
|
||||
overflow into a bucket header. Also take care of the
|
||||
simple case of moving from a bucket header into a bucket
|
||||
header. */
|
||||
new_bucket->data = data;
|
||||
new_table->n_buckets_used++;
|
||||
if (cursor != bucket)
|
||||
free_entry (new_table, cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (table->bucket);
|
||||
table->bucket = new_table->bucket;
|
||||
@@ -761,68 +857,74 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If ENTRY matches an entry already in the hash table, don't modify the table
|
||||
and return the matched entry. Otherwise, insert ENTRY and return NULL.
|
||||
*DONE is set to true in all cases, unless the storage required for
|
||||
insertion cannot be allocated. */
|
||||
/* If ENTRY matches an entry already in the hash table, return the pointer
|
||||
to the entry from the table. Otherwise, insert ENTRY and return ENTRY.
|
||||
Return NULL if the storage required for insertion cannot be allocated. */
|
||||
|
||||
void *
|
||||
hash_insert (Hash_table *table, const void *entry, bool *done)
|
||||
hash_insert (Hash_table *table, const void *entry)
|
||||
{
|
||||
void *data;
|
||||
struct hash_entry *bucket;
|
||||
|
||||
assert (entry); /* cannot insert a NULL data */
|
||||
assert (entry); /* cannot insert a NULL entry */
|
||||
|
||||
if (data = hash_find_entry (table, entry, &bucket, false), data)
|
||||
{
|
||||
*done = true;
|
||||
return data;
|
||||
}
|
||||
/* If there's a matching entry already in the table, return that. */
|
||||
if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
|
||||
return data;
|
||||
|
||||
/* ENTRY is not matched, it should be inserted. */
|
||||
|
||||
table->n_entries++;
|
||||
|
||||
if (bucket->data)
|
||||
{
|
||||
struct hash_entry *new_entry = allocate_entry (table);
|
||||
|
||||
if (new_entry == NULL)
|
||||
{
|
||||
*done = false;
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/* Add ENTRY in the overflow of the bucket. */
|
||||
|
||||
new_entry->data = (void *) entry;
|
||||
new_entry->next = bucket->next;
|
||||
bucket->next = new_entry;
|
||||
*done = true;
|
||||
return NULL;
|
||||
table->n_entries++;
|
||||
return (void *) entry;
|
||||
}
|
||||
|
||||
/* Add ENTRY right in the bucket head. */
|
||||
|
||||
bucket->data = (void *) entry;
|
||||
table->n_entries++;
|
||||
table->n_buckets_used++;
|
||||
|
||||
/* If more than 80% of the buckets are in use, rehash the table two
|
||||
times bigger. It's no real use checking the number of entries, as if
|
||||
the hashing function is ill-conditioned, rehashing is not likely to
|
||||
improve it. */
|
||||
/* If the growth threshold of the buckets in use has been reached, increase
|
||||
the table size and rehash. There's no point in checking the number of
|
||||
entries: if the hashing function is ill-conditioned, rehashing is not
|
||||
likely to improve it. */
|
||||
|
||||
if (5 * table->n_buckets_used > 4 * table->n_buckets)
|
||||
if (table->n_buckets_used
|
||||
> table->tuning->growth_threshold * table->n_buckets)
|
||||
{
|
||||
unsigned int new_n_buckets = next_prime (2 * table->n_buckets + 1);
|
||||
/* Check more fully, before starting real work. If tuning arguments
|
||||
became invalid, the second check will rely on proper defaults. */
|
||||
check_tuning (table);
|
||||
if (table->n_buckets_used
|
||||
> table->tuning->growth_threshold * table->n_buckets)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
unsigned candidate
|
||||
= (unsigned) (tuning->is_n_buckets
|
||||
? (table->n_buckets * tuning->growth_factor)
|
||||
: (table->n_buckets * tuning->growth_factor
|
||||
* tuning->growth_threshold));
|
||||
|
||||
*done = hash_rehash (table, new_n_buckets);
|
||||
return NULL;
|
||||
/* If the rehash fails, arrange to return NULL. */
|
||||
if (!hash_rehash (table, candidate))
|
||||
entry = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*done = true;
|
||||
return NULL;
|
||||
return (void *) entry;
|
||||
}
|
||||
|
||||
/* If ENTRY is already in the table, remove it and return the just-deleted
|
||||
@@ -838,9 +940,34 @@ hash_delete (Hash_table *table, const void *entry)
|
||||
if (data = hash_find_entry (table, entry, &bucket, true), !data)
|
||||
return NULL;
|
||||
|
||||
if (!bucket->data)
|
||||
table->n_buckets_used--;
|
||||
table->n_entries--;
|
||||
if (!bucket->data)
|
||||
{
|
||||
table->n_buckets_used--;
|
||||
|
||||
/* If the shrink threshold of the buckets in use has been reached,
|
||||
rehash into a smaller table. */
|
||||
|
||||
if (table->n_buckets_used
|
||||
< table->tuning->shrink_threshold * table->n_buckets)
|
||||
{
|
||||
/* Check more fully, before starting real work. If tuning arguments
|
||||
became invalid, the second check will rely on proper defaults. */
|
||||
check_tuning (table);
|
||||
if (table->n_buckets_used
|
||||
< table->tuning->shrink_threshold * table->n_buckets)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
unsigned candidate
|
||||
= (unsigned) (tuning->is_n_buckets
|
||||
? table->n_buckets * tuning->shrink_factor
|
||||
: (table->n_buckets * tuning->shrink_factor
|
||||
* tuning->growth_threshold));
|
||||
|
||||
hash_rehash (table, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
53
lib/hash.h
53
lib/hash.h
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <meyering@ascend.com>, 1998.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef unsigned int (*Hash_hasher) PARAMS ((const void *, unsigned int));
|
||||
typedef unsigned (*Hash_hasher) PARAMS ((const void *, unsigned));
|
||||
typedef bool (*Hash_comparator) PARAMS ((const void *, const void *));
|
||||
typedef void (*Hash_data_freer) PARAMS ((void *));
|
||||
typedef bool (*Hash_processor) PARAMS ((void *, void *));
|
||||
@@ -40,6 +40,20 @@ struct hash_entry
|
||||
struct hash_entry *next;
|
||||
};
|
||||
|
||||
struct hash_tuning
|
||||
{
|
||||
/* This structure is mainly used for `hash_initialize', see the block
|
||||
documentation of `hash_reset_tuning' for more complete comments. */
|
||||
|
||||
float shrink_threshold; /* ratio of used buckets to trigger a shrink */
|
||||
float shrink_factor; /* ratio of new smaller size to original size */
|
||||
float growth_threshold; /* ratio of used buckets to trigger a growth */
|
||||
float growth_factor; /* ratio of new bigger size to original size */
|
||||
bool is_n_buckets; /* if CANDIDATE really means table size */
|
||||
};
|
||||
|
||||
typedef struct hash_tuning Hash_tuning;
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
/* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
|
||||
@@ -47,9 +61,12 @@ struct hash_table
|
||||
are not empty, there are N_ENTRIES active entries in the table. */
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *bucket_limit;
|
||||
unsigned int n_buckets;
|
||||
unsigned int n_buckets_used;
|
||||
unsigned int n_entries;
|
||||
unsigned n_buckets;
|
||||
unsigned n_buckets_used;
|
||||
unsigned n_entries;
|
||||
|
||||
/* Tuning arguments, kept in a physicaly separate structure. */
|
||||
const Hash_tuning *tuning;
|
||||
|
||||
/* Three functions are given to `hash_initialize', see the documentation
|
||||
block for this function. In a word, HASHER randomizes a user entry
|
||||
@@ -74,10 +91,10 @@ struct hash_table
|
||||
typedef struct hash_table Hash_table;
|
||||
|
||||
/* Information and lookup. */
|
||||
unsigned int hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_n_entries PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_entries PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||
bool hash_table_ok PARAMS ((const Hash_table *));
|
||||
void hash_print_statistics PARAMS ((const Hash_table *, FILE *));
|
||||
void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||
@@ -85,19 +102,19 @@ void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||
/* Walking. */
|
||||
void *hash_get_first PARAMS ((const Hash_table *));
|
||||
void *hash_get_next PARAMS ((const Hash_table *, const void *));
|
||||
unsigned int hash_get_entries PARAMS ((const Hash_table *, void **,
|
||||
unsigned int));
|
||||
unsigned int hash_do_for_each PARAMS ((const Hash_table *, Hash_processor,
|
||||
void *));
|
||||
unsigned hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
|
||||
unsigned hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
|
||||
|
||||
/* Allocation and clean-up. */
|
||||
unsigned int hash_string PARAMS ((const char *, unsigned int));
|
||||
Hash_table *hash_initialize PARAMS ((unsigned int, Hash_hasher,
|
||||
Hash_comparator, Hash_data_freer));
|
||||
unsigned hash_string PARAMS ((const char *, unsigned));
|
||||
void hash_reset_tuning PARAMS ((Hash_tuning *));
|
||||
Hash_table *hash_initialize PARAMS ((unsigned, const Hash_tuning *,
|
||||
Hash_hasher, Hash_comparator,
|
||||
Hash_data_freer));
|
||||
void hash_clear PARAMS ((Hash_table *));
|
||||
void hash_free PARAMS ((Hash_table *));
|
||||
|
||||
/* Insertion and deletion. */
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned int));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *, bool *));
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *));
|
||||
void *hash_delete PARAMS ((Hash_table *, const void *));
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -54,7 +50,7 @@ char *getenv ();
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <error.h>
|
||||
#include <xstrtoul.h>
|
||||
#include <xstrtol.h>
|
||||
|
||||
#include "human.h"
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#ifndef HUMAN_H_
|
||||
# define HUMAN_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
|
||||
/* A conservative bound on the maximum length of a human-readable string.
|
||||
The output can be the product of the largest uintmax_t and the largest int,
|
||||
so add their sizes before converting to a bound on digits. */
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
#include <getopt.h>
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
@@ -37,8 +45,12 @@ static struct option const long_options[] =
|
||||
Be careful not to gobble up `--'. */
|
||||
|
||||
void
|
||||
parse_long_options (int argc, char **argv, const char *command_name,
|
||||
const char *package, const char *version,
|
||||
parse_long_options (int argc,
|
||||
char **argv,
|
||||
const char *command_name,
|
||||
const char *package,
|
||||
const char *version,
|
||||
const char *authors,
|
||||
void (*usage_func)())
|
||||
{
|
||||
int c;
|
||||
@@ -58,7 +70,7 @@ parse_long_options (int argc, char **argv, const char *command_name,
|
||||
(*usage_func) (0);
|
||||
|
||||
case 'v':
|
||||
printf ("%s (%s) %s\n", command_name, package, version);
|
||||
version_etc (stdout, command_name, package, version, authors);
|
||||
close_stdout (); /* FIXME: output failure exit status
|
||||
should be settable via an arg. */
|
||||
exit (0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* long-options.h -- declaration for --help- and --version-handling function.
|
||||
Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,7 +26,10 @@
|
||||
#endif
|
||||
|
||||
void
|
||||
parse_long_options PARAMS ((int _argc, char **_argv,
|
||||
parse_long_options PARAMS ((int _argc,
|
||||
char **_argv,
|
||||
const char *_command_name,
|
||||
const char *_package,
|
||||
const char *_version, void (*_usage) (int)));
|
||||
const char *_version,
|
||||
const char *_authors,
|
||||
void (*_usage) (int)));
|
||||
|
||||
@@ -71,16 +71,34 @@ extern int errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISUID
|
||||
# define S_ISUID 04000
|
||||
#endif
|
||||
#ifndef S_ISGID
|
||||
# define S_ISGID 02000
|
||||
#endif
|
||||
#ifndef S_ISVTX
|
||||
# define S_ISVTX 01000
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
# define S_IRUSR 0200
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
# define S_IWUSR 0200
|
||||
#endif
|
||||
|
||||
#ifndef S_IXUSR
|
||||
# define S_IXUSR 0100
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXU
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
#endif
|
||||
|
||||
#define WX_USR (S_IWUSR | S_IXUSR)
|
||||
|
||||
/* Include this before libintl.h so we get our definition of PARAMS. */
|
||||
#include "makepath.h"
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
@@ -98,7 +116,6 @@ typedef int gid_t;
|
||||
#endif
|
||||
|
||||
#include "save-cwd.h"
|
||||
#include "makepath.h"
|
||||
#include "error.h"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
@@ -145,6 +162,7 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
|
||||
if (!created_dir)
|
||||
{
|
||||
struct stat stats;
|
||||
int saved_errno = errno;
|
||||
|
||||
/* The mkdir and stat calls below may appear to be reversed.
|
||||
They are not. It is important to call mkdir first and then to
|
||||
@@ -156,7 +174,7 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
|
||||
|
||||
if (stat (dir, &stats))
|
||||
{
|
||||
error (0, errno, _("cannot create directory `%s'"), dirpath);
|
||||
error (0, saved_errno, _("cannot create directory `%s'"), dirpath);
|
||||
fail = 1;
|
||||
}
|
||||
else if (!S_ISDIR (stats.st_mode))
|
||||
@@ -223,7 +241,7 @@ make_path (const char *argpath,
|
||||
char *dirpath;
|
||||
|
||||
/* Temporarily relax umask in case it's overly restrictive. */
|
||||
int oldmask = umask (0);
|
||||
mode_t oldmask = umask (0);
|
||||
|
||||
/* Make a copy of ARGPATH that we can scribble NULs on. */
|
||||
dirpath = (char *) alloca (strlen (argpath) + 1);
|
||||
@@ -235,9 +253,9 @@ make_path (const char *argpath,
|
||||
their owners, we need to fix their permissions after making them. */
|
||||
if (((parent_mode & WX_USR) != WX_USR)
|
||||
|| ((owner != (uid_t) -1 || group != (gid_t) -1)
|
||||
&& (parent_mode & 07000) != 0))
|
||||
&& (parent_mode & (S_ISUID | S_ISGID | S_ISVTX)) != 0))
|
||||
{
|
||||
tmp_mode = 0700;
|
||||
tmp_mode = S_IRWXU;
|
||||
re_protect = 1;
|
||||
}
|
||||
else
|
||||
@@ -363,7 +381,8 @@ make_path (const char *argpath,
|
||||
retval = 1;
|
||||
}
|
||||
/* chown may have turned off some permission bits we wanted. */
|
||||
if ((mode & 07000) != 0 && chmod (basename_dir, mode))
|
||||
if ((mode & (S_ISUID | S_ISGID | S_ISVTX))
|
||||
&& chmod (basename_dir, mode))
|
||||
{
|
||||
error (0, errno, _("cannot chmod %s"), dirpath);
|
||||
retval = 1;
|
||||
|
||||
23
lib/mkdir.c
23
lib/mkdir.c
@@ -34,6 +34,16 @@ extern int errno;
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXU
|
||||
# define S_IRWXU 0700
|
||||
#endif
|
||||
#ifndef S_IRWXG
|
||||
# define S_IRWXG 0070
|
||||
#endif
|
||||
#ifndef S_IRWXO
|
||||
# define S_IRWXO 0007
|
||||
#endif
|
||||
|
||||
/* mkdir adapted from GNU tar. */
|
||||
|
||||
/* Make directory DPATH, with permission mode DMODE.
|
||||
@@ -48,9 +58,11 @@ extern int errno;
|
||||
subroutine didn't return EEXIST. It does now. */
|
||||
|
||||
int
|
||||
mkdir (const char *dpath, int dmode)
|
||||
mkdir (const char *dpath, mode_t dmode)
|
||||
{
|
||||
int cpid, status;
|
||||
pid_t cpid;
|
||||
mode_t mode;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) == 0)
|
||||
@@ -74,8 +86,9 @@ mkdir (const char *dpath, int dmode)
|
||||
process is going away anyway, we zap its umask.
|
||||
This won't suffice to set SUID, SGID, etc. on this
|
||||
directory, so the parent process calls chmod afterward. */
|
||||
status = umask (0); /* Get current umask. */
|
||||
umask (status | (0777 & ~dmode)); /* Set for mkdir. */
|
||||
mode = umask (0); /* Get current umask. */
|
||||
/* Set for mkdir. */
|
||||
umask (mode | ((S_IRWXU | S_IRWXG | S_IRWXO) & ~dmode));
|
||||
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
|
||||
_exit (1);
|
||||
|
||||
@@ -84,7 +97,7 @@ mkdir (const char *dpath, int dmode)
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status & 0xFFFF)
|
||||
if (status)
|
||||
{
|
||||
/* /bin/mkdir failed. */
|
||||
errno = EIO;
|
||||
|
||||
74
lib/mktime.c
74
lib/mktime.c
@@ -1,24 +1,22 @@
|
||||
/* mktime: convert a `struct tm' to a time_t value
|
||||
Copyright (C) 1993-1998, 1999 Free Software Foundation, Inc.
|
||||
/* Convert a `struct tm' to a time_t value.
|
||||
Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Paul Eggert (eggert@twinsun.com).
|
||||
|
||||
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.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
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,
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU 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. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Define this to have a standalone program to test this implementation of
|
||||
mktime. */
|
||||
@@ -109,14 +107,6 @@ const unsigned short int __mon_yday[2][13] =
|
||||
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
||||
};
|
||||
|
||||
static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *,
|
||||
struct tm *)),
|
||||
time_t *, struct tm *));
|
||||
static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *));
|
||||
time_t __mktime_internal __P ((struct tm *,
|
||||
struct tm *(*) (const time_t *, struct tm *),
|
||||
time_t *));
|
||||
|
||||
|
||||
#ifdef _LIBC
|
||||
# define my_mktime_localtime_r __localtime_r
|
||||
@@ -124,7 +114,6 @@ time_t __mktime_internal __P ((struct tm *,
|
||||
/* If we're a mktime substitute in a GNU program, then prefer
|
||||
localtime to localtime_r, since many localtime_r implementations
|
||||
are buggy. */
|
||||
static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *));
|
||||
static struct tm *
|
||||
my_mktime_localtime_r (const time_t *t, struct tm *tp)
|
||||
{
|
||||
@@ -172,23 +161,6 @@ ydhms_tm_diff (int year, int yday, int hour, int min, int sec,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static time_t localtime_offset;
|
||||
|
||||
/* Convert *TP to a time_t value. */
|
||||
time_t
|
||||
mktime (struct tm *tp)
|
||||
{
|
||||
#ifdef _LIBC
|
||||
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
|
||||
time zone names contained in the external variable `tzname' shall
|
||||
be set as if the tzset() function had been called. */
|
||||
__tzset ();
|
||||
#endif
|
||||
|
||||
return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
|
||||
}
|
||||
|
||||
/* Use CONVERT to convert *T to a broken down time in *TP.
|
||||
If *T is out of range for conversion, adjust it so that
|
||||
it is the nearest in-range value and then convert that. */
|
||||
@@ -389,6 +361,24 @@ __mktime_internal (struct tm *tp,
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static time_t localtime_offset;
|
||||
|
||||
/* Convert *TP to a time_t value. */
|
||||
time_t
|
||||
mktime (tp)
|
||||
struct tm *tp;
|
||||
{
|
||||
#ifdef _LIBC
|
||||
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
|
||||
time zone names contained in the external variable `tzname' shall
|
||||
be set as if the tzset() function had been called. */
|
||||
__tzset ();
|
||||
#endif
|
||||
|
||||
return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (mktime, timelocal)
|
||||
#endif
|
||||
|
||||
250
lib/modechange.c
250
lib/modechange.c
@@ -1,5 +1,5 @@
|
||||
/* modechange.c -- file mode manipulation
|
||||
Copyright (C) 1989, 1990, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,9 +28,9 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "modechange.h"
|
||||
#include <sys/stat.h>
|
||||
#include "xstrtol.h"
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
@@ -50,26 +50,93 @@ char *malloc ();
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISUID
|
||||
# define S_ISUID 04000
|
||||
#endif
|
||||
#ifndef S_ISGID
|
||||
# define S_ISGID 04000
|
||||
#endif
|
||||
#ifndef S_ISVTX
|
||||
# define S_ISVTX 01000
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
# define S_IRUSR 0400
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
# define S_IWUSR 0200
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
# define S_IXUSR 0100
|
||||
#endif
|
||||
#ifndef S_IRGRP
|
||||
# define S_IRGRP 0040
|
||||
#endif
|
||||
#ifndef S_IWGRP
|
||||
# define S_IWGRP 0020
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
# define S_IXGRP 0010
|
||||
#endif
|
||||
#ifndef S_IROTH
|
||||
# define S_IROTH 0004
|
||||
#endif
|
||||
#ifndef S_IWOTH
|
||||
# define S_IWOTH 0002
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
# define S_IXOTH 0001
|
||||
#endif
|
||||
#ifndef S_IRWXU
|
||||
# define S_IRWXU 0700
|
||||
#endif
|
||||
#ifndef S_IRWXG
|
||||
# define S_IRWXG 0070
|
||||
#endif
|
||||
#ifndef S_IRWXO
|
||||
# define S_IRWXO 0007
|
||||
#endif
|
||||
|
||||
/* All the mode bits that can be affected by chmod. */
|
||||
#define CHMOD_MODE_BITS \
|
||||
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
|
||||
/* Return newly allocated memory to hold one element of type TYPE. */
|
||||
#define talloc(type) ((type *) malloc (sizeof (type)))
|
||||
|
||||
#define isodigit(c) ((c) >= '0' && (c) <= '7')
|
||||
/* Create a mode_change entry with the specified `=ddd'-style
|
||||
mode change operation, where NEW_MODE is `ddd'. Return the
|
||||
new entry, or NULL upon failure. */
|
||||
|
||||
/* Return a positive integer containing the value of the ASCII
|
||||
octal number S. If S is not an octal number, return -1. */
|
||||
|
||||
static int
|
||||
oatoi (const char *s)
|
||||
static struct mode_change *
|
||||
make_node_op_equals (mode_t new_mode)
|
||||
{
|
||||
register int i;
|
||||
struct mode_change *p;
|
||||
p = talloc (struct mode_change);
|
||||
if (p == NULL)
|
||||
return p;
|
||||
p->next = NULL;
|
||||
p->op = '=';
|
||||
p->flags = 0;
|
||||
p->value = new_mode;
|
||||
p->affected = CHMOD_MODE_BITS; /* Affect all permissions. */
|
||||
return p;
|
||||
}
|
||||
|
||||
if (*s == 0)
|
||||
return -1;
|
||||
for (i = 0; isodigit (*s); ++s)
|
||||
i = i * 8 + *s - '0';
|
||||
if (*s)
|
||||
return -1;
|
||||
return i;
|
||||
/* Append entry E to the end of the link list with the specified
|
||||
HEAD and TAIL. */
|
||||
|
||||
static void
|
||||
mode_append_entry (struct mode_change **head,
|
||||
struct mode_change **tail,
|
||||
struct mode_change *e)
|
||||
{
|
||||
if (*head == NULL)
|
||||
*head = *tail = e;
|
||||
else
|
||||
{
|
||||
(*tail)->next = e;
|
||||
*tail = e;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a linked list of file mode change operations created from
|
||||
@@ -89,41 +156,44 @@ struct mode_change *
|
||||
mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
{
|
||||
struct mode_change *head; /* First element of the linked list. */
|
||||
struct mode_change *change; /* An element of the linked list. */
|
||||
int i; /* General purpose temporary. */
|
||||
int umask_value; /* The umask value (surprise). */
|
||||
unsigned short affected_bits; /* Which bits in the mode are operated on. */
|
||||
unsigned short affected_masked; /* `affected_bits' modified by umask. */
|
||||
unsigned ops_to_mask; /* Operators to actually use umask on. */
|
||||
struct mode_change *tail; /* An element of the linked list. */
|
||||
unsigned long mode_value; /* The mode value, if octal. */
|
||||
char *string_end; /* Pointer to end of parsed value. */
|
||||
mode_t umask_value; /* The umask value (surprise). */
|
||||
|
||||
i = oatoi (mode_string);
|
||||
if (i >= 0)
|
||||
head = NULL;
|
||||
#ifdef lint
|
||||
tail = NULL;
|
||||
#endif
|
||||
|
||||
if (xstrtoul (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK)
|
||||
{
|
||||
if (i > 07777)
|
||||
struct mode_change *p;
|
||||
if (mode_value > CHMOD_MODE_BITS)
|
||||
return MODE_INVALID;
|
||||
head = talloc (struct mode_change);
|
||||
if (head == NULL)
|
||||
p = make_node_op_equals ((mode_t) mode_value);
|
||||
if (p == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
head->next = NULL;
|
||||
head->op = '=';
|
||||
head->flags = 0;
|
||||
head->value = i;
|
||||
head->affected = 07777; /* Affect all permissions. */
|
||||
mode_append_entry (&head, &tail, p);
|
||||
return head;
|
||||
}
|
||||
|
||||
umask_value = umask (0);
|
||||
umask (umask_value); /* Restore the old value. */
|
||||
|
||||
head = NULL;
|
||||
#ifdef lint
|
||||
change = NULL;
|
||||
#endif
|
||||
--mode_string;
|
||||
|
||||
/* One loop iteration for each "ugoa...=+-rwxXstugo...[=+-rwxXstugo...]". */
|
||||
do
|
||||
{
|
||||
/* Which bits in the mode are operated on. */
|
||||
mode_t affected_bits = 0;
|
||||
/* `affected_bits' modified by umask. */
|
||||
mode_t affected_masked;
|
||||
/* Operators to actually use umask on. */
|
||||
unsigned ops_to_mask = 0;
|
||||
|
||||
int who_specified_p;
|
||||
|
||||
affected_bits = 0;
|
||||
ops_to_mask = 0;
|
||||
/* Turn on all the bits in `affected_bits' for each group given. */
|
||||
@@ -131,16 +201,16 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
switch (*mode_string)
|
||||
{
|
||||
case 'u':
|
||||
affected_bits |= 04700;
|
||||
affected_bits |= S_ISUID | S_IRWXU;
|
||||
break;
|
||||
case 'g':
|
||||
affected_bits |= 02070;
|
||||
affected_bits |= S_ISGID | S_IRWXG;
|
||||
break;
|
||||
case 'o':
|
||||
affected_bits |= 01007;
|
||||
affected_bits |= S_ISVTX | S_IRWXO;
|
||||
break;
|
||||
case 'a':
|
||||
affected_bits |= 07777;
|
||||
affected_bits |= CHMOD_MODE_BITS;
|
||||
break;
|
||||
default:
|
||||
goto no_more_affected;
|
||||
@@ -149,37 +219,39 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
no_more_affected:
|
||||
/* If none specified, affect all bits, except perhaps those
|
||||
set in the umask. */
|
||||
if (affected_bits == 0)
|
||||
if (affected_bits)
|
||||
who_specified_p = 1;
|
||||
else
|
||||
{
|
||||
affected_bits = 07777;
|
||||
who_specified_p = 0;
|
||||
affected_bits = CHMOD_MODE_BITS;
|
||||
ops_to_mask = masked_ops;
|
||||
}
|
||||
|
||||
while (*mode_string == '=' || *mode_string == '+' || *mode_string == '-')
|
||||
{
|
||||
/* Add the element to the tail of the list, so the operations
|
||||
are performed in the correct order. */
|
||||
if (head == NULL)
|
||||
struct mode_change *change = talloc (struct mode_change);
|
||||
if (change == NULL)
|
||||
{
|
||||
head = talloc (struct mode_change);
|
||||
if (head == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
change = head;
|
||||
}
|
||||
else
|
||||
{
|
||||
change->next = talloc (struct mode_change);
|
||||
if (change->next == NULL)
|
||||
{
|
||||
mode_free (change);
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
}
|
||||
change = change->next;
|
||||
mode_free (head);
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
}
|
||||
|
||||
change->next = NULL;
|
||||
change->op = *mode_string; /* One of "=+-". */
|
||||
affected_masked = affected_bits;
|
||||
|
||||
/* Per the Single Unix Spec, if `who' is not specified and the
|
||||
`=' operator is used, then clear all the bits first. */
|
||||
if (!who_specified_p &&
|
||||
ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS : 0))
|
||||
{
|
||||
struct mode_change *p = make_node_op_equals (0);
|
||||
if (p == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
mode_append_entry (&head, &tail, p);
|
||||
}
|
||||
|
||||
if (ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS
|
||||
: *mode_string == '+' ? MODE_MASK_PLUS
|
||||
: MODE_MASK_MINUS))
|
||||
@@ -188,36 +260,43 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
change->value = 0;
|
||||
change->flags = 0;
|
||||
|
||||
/* Add the element to the tail of the list, so the operations
|
||||
are performed in the correct order. */
|
||||
mode_append_entry (&head, &tail, change);
|
||||
|
||||
/* Set `value' according to the bits set in `affected_masked'. */
|
||||
for (++mode_string;; ++mode_string)
|
||||
switch (*mode_string)
|
||||
{
|
||||
case 'r':
|
||||
change->value |= 00444 & affected_masked;
|
||||
change->value |= ((S_IRUSR | S_IRGRP | S_IROTH)
|
||||
& affected_masked);
|
||||
break;
|
||||
case 'w':
|
||||
change->value |= 00222 & affected_masked;
|
||||
change->value |= ((S_IWUSR | S_IWGRP | S_IWOTH)
|
||||
& affected_masked);
|
||||
break;
|
||||
case 'X':
|
||||
change->flags |= MODE_X_IF_ANY_X;
|
||||
/* Fall through. */
|
||||
case 'x':
|
||||
change->value |= 00111 & affected_masked;
|
||||
change->value |= ((S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
& affected_masked);
|
||||
break;
|
||||
case 's':
|
||||
/* Set the setuid/gid bits if `u' or `g' is selected. */
|
||||
change->value |= 06000 & affected_masked;
|
||||
change->value |= (S_ISUID | S_ISGID) & affected_masked;
|
||||
break;
|
||||
case 't':
|
||||
/* Set the "save text image" bit if `o' is selected. */
|
||||
change->value |= 01000 & affected_masked;
|
||||
change->value |= S_ISVTX & affected_masked;
|
||||
break;
|
||||
case 'u':
|
||||
/* Set the affected bits to the value of the `u' bits
|
||||
on the same file. */
|
||||
if (change->value)
|
||||
goto invalid;
|
||||
change->value = 00700;
|
||||
change->value = S_IRWXU;
|
||||
change->flags |= MODE_COPY_EXISTING;
|
||||
break;
|
||||
case 'g':
|
||||
@@ -225,7 +304,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
on the same file. */
|
||||
if (change->value)
|
||||
goto invalid;
|
||||
change->value = 00070;
|
||||
change->value = S_IRWXG;
|
||||
change->flags |= MODE_COPY_EXISTING;
|
||||
break;
|
||||
case 'o':
|
||||
@@ -233,7 +312,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
on the same file. */
|
||||
if (change->value)
|
||||
goto invalid;
|
||||
change->value = 00007;
|
||||
change->value = S_IRWXO;
|
||||
change->flags |= MODE_COPY_EXISTING;
|
||||
break;
|
||||
default:
|
||||
@@ -268,7 +347,7 @@ mode_create_from_ref (const char *ref_file)
|
||||
|
||||
change->op = '=';
|
||||
change->flags = 0;
|
||||
change->affected = 07777;
|
||||
change->affected = CHMOD_MODE_BITS;
|
||||
change->value = ref_stats.st_mode;
|
||||
change->next = NULL;
|
||||
|
||||
@@ -280,13 +359,13 @@ mode_create_from_ref (const char *ref_file)
|
||||
change affects it even if no execute bits were set in OLDMODE.
|
||||
The returned value has the S_IFMT bits cleared. */
|
||||
|
||||
unsigned short
|
||||
mode_adjust (unsigned int oldmode, const struct mode_change *changes)
|
||||
mode_t
|
||||
mode_adjust (mode_t oldmode, const struct mode_change *changes)
|
||||
{
|
||||
unsigned short newmode; /* The adjusted mode and one operand. */
|
||||
unsigned short value; /* The other operand. */
|
||||
mode_t newmode; /* The adjusted mode and one operand. */
|
||||
mode_t value; /* The other operand. */
|
||||
|
||||
newmode = oldmode & 07777;
|
||||
newmode = oldmode & CHMOD_MODE_BITS;
|
||||
|
||||
for (; changes; changes = changes->next)
|
||||
{
|
||||
@@ -296,15 +375,21 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes)
|
||||
the mask `changes->value'. */
|
||||
value = newmode & changes->value;
|
||||
|
||||
if (changes->value & 00700)
|
||||
if (changes->value & S_IRWXU)
|
||||
/* Copy `u' permissions onto `g' and `o'. */
|
||||
value |= (value >> 3) | (value >> 6);
|
||||
else if (changes->value & 00070)
|
||||
value |= ((value & S_IRUSR ? S_IRGRP | S_IROTH : 0)
|
||||
| (value & S_IWUSR ? S_IWGRP | S_IROTH : 0)
|
||||
| (value & S_IXUSR ? S_IXGRP | S_IXOTH : 0));
|
||||
else if (changes->value & S_IRWXG)
|
||||
/* Copy `g' permissions onto `u' and `o'. */
|
||||
value |= (value << 3) | (value >> 3);
|
||||
value |= ((value & S_IRGRP ? S_IRUSR | S_IROTH : 0)
|
||||
| (value & S_IWGRP ? S_IWUSR | S_IROTH : 0)
|
||||
| (value & S_IXGRP ? S_IXUSR | S_IXOTH : 0));
|
||||
else
|
||||
/* Copy `o' permissions onto `u' and `g'. */
|
||||
value |= (value << 3) | (value << 6);
|
||||
value |= ((value & S_IROTH ? S_IRUSR | S_IRGRP : 0)
|
||||
| (value & S_IWOTH ? S_IWUSR | S_IRGRP : 0)
|
||||
| (value & S_IXOTH ? S_IXUSR | S_IXGRP : 0));
|
||||
|
||||
/* In order to change only `u', `g', or `o' permissions,
|
||||
or some combination thereof, clear unselected bits.
|
||||
@@ -320,8 +405,9 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes)
|
||||
directory and no execute bits are already set. */
|
||||
if ((changes->flags & MODE_X_IF_ANY_X)
|
||||
&& !S_ISDIR (oldmode)
|
||||
&& (newmode & 00111) == 0)
|
||||
value &= ~00111; /* Clear the execute bits. */
|
||||
&& (newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
|
||||
/* Clear the execute bits. */
|
||||
value &= ~ (S_IXUSR | S_IXGRP | S_IXOTH);
|
||||
}
|
||||
|
||||
switch (changes->op)
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
#if ! defined MODECHANGE_H_
|
||||
# define MODECHANGE_H_
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
/* Affect the execute bits only if at least one execute bit is set already,
|
||||
or if the file is a directory. */
|
||||
# define MODE_X_IF_ANY_X 01
|
||||
@@ -33,8 +39,8 @@ struct mode_change
|
||||
{
|
||||
char op; /* One of "=+-". */
|
||||
char flags; /* Special operations. */
|
||||
unsigned short affected; /* Set for u/g/o/s/s/t, if to be affected. */
|
||||
unsigned short value; /* Bits to add/remove. */
|
||||
mode_t affected; /* Set for u/g/o/s/s/t, if to be affected. */
|
||||
mode_t value; /* Bits to add/remove. */
|
||||
struct mode_change *next; /* Link to next change in list. */
|
||||
};
|
||||
|
||||
@@ -59,7 +65,7 @@ struct mode_change
|
||||
|
||||
struct mode_change *mode_compile PARAMS ((const char *, unsigned));
|
||||
struct mode_change *mode_create_from_ref PARAMS ((const char *));
|
||||
unsigned short mode_adjust PARAMS ((unsigned, const struct mode_change *));
|
||||
mode_t mode_adjust PARAMS ((mode_t, const struct mode_change *));
|
||||
void mode_free PARAMS ((struct mode_change *));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* readtokens.c -- Functions for reading tokens from an input stream.
|
||||
Copyright (C) 1990-1991 Jim Meyering.
|
||||
Copyright (C) 1990-1991, 1999 Jim Meyering.
|
||||
|
||||
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
|
||||
@@ -77,11 +77,10 @@ init_tokenbuffer (tokenbuffer)
|
||||
and on files that aren't newline-terminated. */
|
||||
|
||||
long
|
||||
readtoken (stream, delim, n_delim, tokenbuffer)
|
||||
FILE *stream;
|
||||
const char *delim;
|
||||
int n_delim;
|
||||
token_buffer *tokenbuffer;
|
||||
readtoken (FILE *stream,
|
||||
const char *delim,
|
||||
int n_delim,
|
||||
token_buffer *tokenbuffer)
|
||||
{
|
||||
char *p;
|
||||
int c, i, n;
|
||||
@@ -164,14 +163,12 @@ readtoken (stream, delim, n_delim, tokenbuffer)
|
||||
%%% realloc() of `tokens' just before returning? */
|
||||
|
||||
int
|
||||
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;
|
||||
readtokens (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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GNU's read utmp module.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
@@ -29,6 +31,7 @@
|
||||
#include "readutmp.h"
|
||||
|
||||
char *xmalloc ();
|
||||
char *realloc ();
|
||||
|
||||
/* Copy UT->ut_name into storage obtained from malloc. Then remove any
|
||||
trailing spaces from the copy, NUL terminate it, and return the copy. */
|
||||
@@ -49,70 +52,42 @@ extract_trimmed_name (const STRUCT_UTMP *ut)
|
||||
return trimmed_name;
|
||||
}
|
||||
|
||||
/* Read the utmp file FILENAME into *UTMP_BUF, set *N_ENTRIES to the
|
||||
number of entries read, and return zero. If there is any error,
|
||||
/* Read the utmp entries corresponding to file FILENAME into freshly-
|
||||
malloc'd storage, set *UTMP_BUF to that pointer, set *N_ENTRIES to
|
||||
the number of entries, and return zero. If there is any error,
|
||||
return non-zero and don't modify the parameters. */
|
||||
|
||||
#ifdef HAVE_UTMPNAME
|
||||
#if HAVE_UTMPNAME
|
||||
|
||||
int
|
||||
read_utmp (const char *filename, int *n_entries, STRUCT_UTMP **utmp_buf)
|
||||
{
|
||||
int count_utmp = 0;
|
||||
int n_read;
|
||||
STRUCT_UTMP *u;
|
||||
STRUCT_UTMP *uptr;
|
||||
STRUCT_UTMP *utmp_contents;
|
||||
STRUCT_UTMP *utmp = NULL;
|
||||
|
||||
if (utmpname (filename))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/* Ignore the return value for now.
|
||||
Solaris' utmpname returns 1 upon success -- which is contrary
|
||||
to what the GNU libc version does. In addition, older GNU libc
|
||||
versions are actually void. */
|
||||
UTMP_NAME_FUNCTION (filename);
|
||||
|
||||
/* FIXME: going through the list twice is wasteful. */
|
||||
|
||||
/* count the entries in utmp */
|
||||
setutent ();
|
||||
while ((u = getutent ()) != NULL)
|
||||
++count_utmp;
|
||||
|
||||
if (count_utmp == 0)
|
||||
return 0;
|
||||
|
||||
utmp_contents = (STRUCT_UTMP *) xmalloc (count_utmp * sizeof (STRUCT_UTMP));
|
||||
|
||||
/* read the entries in utmp */
|
||||
|
||||
/* FIXME: can this fail? */
|
||||
setutent ();
|
||||
SET_UTMP_ENT ();
|
||||
|
||||
n_read = 0;
|
||||
uptr = utmp_contents;
|
||||
while ((u = getutent ()) != NULL)
|
||||
while ((u = GET_UTMP_ENT ()) != NULL)
|
||||
{
|
||||
++n_read;
|
||||
if (n_read > count_utmp)
|
||||
{
|
||||
STRUCT_UTMP *old_utmp_contents = utmp_contents;
|
||||
++count_utmp;
|
||||
utmp_contents = (STRUCT_UTMP *) xrealloc (utmp_contents,
|
||||
(count_utmp
|
||||
* sizeof (STRUCT_UTMP)));
|
||||
uptr = utmp_contents + (uptr - old_utmp_contents);
|
||||
}
|
||||
*uptr = *u;
|
||||
++uptr;
|
||||
utmp = (STRUCT_UTMP *) realloc (utmp, n_read * sizeof (STRUCT_UTMP));
|
||||
if (utmp == NULL)
|
||||
return 1;
|
||||
utmp[n_read - 1] = *u;
|
||||
}
|
||||
|
||||
if (n_read != count_utmp)
|
||||
utmp_contents = (STRUCT_UTMP *) xrealloc (utmp_contents,
|
||||
n_read * sizeof (STRUCT_UTMP));
|
||||
|
||||
/* FIXME: can this fail? */
|
||||
endutent ();
|
||||
END_UTMP_ENT ();
|
||||
|
||||
*n_entries = n_read;
|
||||
*utmp_buf = utmp_contents;
|
||||
*utmp_buf = utmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declarations for GNU's read utmp module.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,17 +28,24 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifdef HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
# define UTMP_STRUCT_NAME utmpx
|
||||
# define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
|
||||
# define SET_UTMP_ENT setutxent
|
||||
# define GET_UTMP_ENT getutxent
|
||||
# define END_UTMP_ENT endutxent
|
||||
# define UTMP_NAME_FUNCTION utmpxname
|
||||
# else
|
||||
# include <utmp.h>
|
||||
# define UTMP_STRUCT_NAME utmp
|
||||
# define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
|
||||
# define SET_UTMP_ENT setutent
|
||||
# define GET_UTMP_ENT getutent
|
||||
# define END_UTMP_ENT endutent
|
||||
# define UTMP_NAME_FUNCTION utmpname
|
||||
# endif
|
||||
|
||||
typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;
|
||||
|
||||
15
lib/rename.c
15
lib/rename.c
@@ -41,7 +41,6 @@ int
|
||||
rename (char *from, char *to)
|
||||
{
|
||||
struct stat from_stats, to_stats;
|
||||
int pid, status;
|
||||
|
||||
if (stat (from, &from_stats))
|
||||
return -1;
|
||||
@@ -74,23 +73,27 @@ rename (char *from, char *to)
|
||||
if (S_ISDIR (from_stats.st_mode))
|
||||
{
|
||||
/* Need a setuid root process to link and unlink directories. */
|
||||
pid = fork ();
|
||||
int status;
|
||||
pid_t pid = fork ();
|
||||
switch (pid)
|
||||
{
|
||||
case -1: /* Error. */
|
||||
error (1, errno, "cannot fork");
|
||||
return -1; /* errno already set */
|
||||
|
||||
case 0: /* Child. */
|
||||
execl (MVDIR, "mvdir", from, to, (char *) 0);
|
||||
error (255, errno, "cannot run `%s'", MVDIR);
|
||||
_exit (1);
|
||||
|
||||
default: /* Parent. */
|
||||
while (wait (&status) != pid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
errno = 0; /* mvdir printed the system error message. */
|
||||
if (status)
|
||||
return -1;
|
||||
{
|
||||
/* MVDIR failed. */
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -44,7 +44,8 @@ int
|
||||
rmdir (dpath)
|
||||
char *dpath;
|
||||
{
|
||||
int cpid, status;
|
||||
pid_t cpid;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) != 0)
|
||||
@@ -73,7 +74,7 @@ rmdir (dpath)
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status & 0xFFFF)
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* /bin/rmdir failed. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
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.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
@@ -1025,7 +1025,6 @@ my_strftime (char *s, size_t maxsize, const char *format, const struct tm *tp
|
||||
add (1, *p = '\t');
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'u': /* POSIX.2 extension. */
|
||||
DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1);
|
||||
|
||||
@@ -1220,7 +1219,7 @@ my_strftime (char *s, size_t maxsize, const char *format, const struct tm *tp
|
||||
}
|
||||
}
|
||||
|
||||
if (p && i < maxsize)
|
||||
if (p && maxsize != 0)
|
||||
*p = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
252
lib/strtol.c
252
lib/strtol.c
@@ -1,7 +1,7 @@
|
||||
/* strtol - Convert string representation of a number into an integer value.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
|
||||
/* Convert string representation of a number into an integer value.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
@@ -54,7 +54,7 @@ extern int errno;
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
/* Nonzero if we are defining `strtoul' or `strtouq', operating on
|
||||
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
|
||||
unsigned integers. */
|
||||
#ifndef UNSIGNED
|
||||
# define UNSIGNED 0
|
||||
@@ -64,72 +64,154 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
/* Determine the name. */
|
||||
#if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstouq
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoull_l
|
||||
# else
|
||||
# define strtol __wcstoul_l
|
||||
# endif
|
||||
# else
|
||||
# define strtol wcstoul
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoull_l
|
||||
# else
|
||||
# define strtol __strtoul_l
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtouq
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoll_l
|
||||
# else
|
||||
# define strtol __wcstol_l
|
||||
# endif
|
||||
# else
|
||||
# define strtol strtoul
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoll_l
|
||||
# else
|
||||
# define strtol __strtol_l
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoq
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoull
|
||||
# else
|
||||
# define strtol wcstoul
|
||||
# endif
|
||||
# else
|
||||
# define strtol wcstol
|
||||
# ifdef QUAD
|
||||
# define strtol strtoull
|
||||
# else
|
||||
# define strtol strtoul
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoq
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoll
|
||||
# else
|
||||
# define strtol wcstol
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoll
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If QUAD is defined, we are defining `strtoq' or `strtouq',
|
||||
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
|
||||
operating on `long long int's. */
|
||||
#ifdef QUAD
|
||||
# define LONG long long
|
||||
# undef LONG_MIN
|
||||
# define LONG_MIN LONG_LONG_MIN
|
||||
# undef LONG_MAX
|
||||
# define LONG_MAX LONG_LONG_MAX
|
||||
# undef ULONG_MAX
|
||||
# define ULONG_MAX ULONG_LONG_MAX
|
||||
# define STRTOL_LONG_MIN LONG_LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
|
||||
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
# ifndef TYPE_SIGNED
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
# endif
|
||||
# ifndef TYPE_MINIMUM
|
||||
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
# endif
|
||||
# ifndef TYPE_MAXIMUM
|
||||
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
# endif
|
||||
|
||||
# ifndef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MAX
|
||||
# define LONG_LONG_MAX TYPE_MAXIMUM (long long int)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MIN
|
||||
# define LONG_LONG_MIN TYPE_MINIMUM (long long int)
|
||||
# endif
|
||||
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
|
||||
/* Work around gcc bug with using this constant. */
|
||||
static const unsigned long long int maxquad = ULONG_LONG_MAX;
|
||||
# undef ULONG_MAX
|
||||
# define ULONG_MAX maxquad
|
||||
# undef STRTOL_ULONG_MAX
|
||||
# define STRTOL_ULONG_MAX maxquad
|
||||
# endif
|
||||
#else
|
||||
# define LONG long
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||
# ifndef ULONG_MAX
|
||||
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||
# endif
|
||||
# ifndef LONG_MAX
|
||||
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||
# endif
|
||||
# define STRTOL_LONG_MIN LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_MAX
|
||||
#endif
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||
|
||||
|
||||
/* We use this code also for the extended locale handling where the
|
||||
function gets as an additional argument the locale which has to be
|
||||
used. To access the values we have to redefine the _NL_CURRENT
|
||||
macro. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# undef _NL_CURRENT
|
||||
# define _NL_CURRENT(category, item) \
|
||||
(current->values[_NL_ITEM_INDEX (item)].string)
|
||||
# define LOCALE_PARAM , loc
|
||||
# define LOCALE_PARAM_DECL __locale_t loc;
|
||||
#else
|
||||
# define LOCALE_PARAM
|
||||
# define LOCALE_PARAM_DECL
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIDE_CHAR
|
||||
# include <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)
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __iswspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __towupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) iswspace (Ch)
|
||||
# define ISALPHA(Ch) iswalpha (Ch)
|
||||
# define TOUPPER(Ch) towupper (Ch)
|
||||
# endif
|
||||
#else
|
||||
# if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
# else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
@@ -137,12 +219,20 @@ extern int errno;
|
||||
# define L_(Ch) Ch
|
||||
# define UCHAR_TYPE unsigned char
|
||||
# define STRING_TYPE char
|
||||
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
|
||||
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
|
||||
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __isspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __toupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
|
||||
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
|
||||
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
/* For compilers which are ansi but don't define __STDC__, like SGI
|
||||
Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */
|
||||
#if defined (__STDC__) || defined (PROTOTYPES)
|
||||
# define INTERNAL(X) INTERNAL1(X)
|
||||
# define INTERNAL1(X) __##X##_internal
|
||||
# define WEAKNAME(X) WEAKNAME1(X)
|
||||
@@ -156,6 +246,7 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
|
||||
If BASE is 0 the base is determined by the presence of a leading
|
||||
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
|
||||
@@ -164,11 +255,12 @@ extern int errno;
|
||||
one converted is stored in *ENDPTR. */
|
||||
|
||||
INT
|
||||
INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
int group;
|
||||
LOCALE_PARAM_DECL
|
||||
{
|
||||
int negative;
|
||||
register unsigned LONG int cutoff;
|
||||
@@ -180,8 +272,11 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
int overflow;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
||||
# endif
|
||||
/* The thousands character of the current locale. */
|
||||
wchar_t thousands;
|
||||
wchar_t thousands = L'\0';
|
||||
/* The numeric grouping specification of the current locale,
|
||||
in the format described in <locale.h>. */
|
||||
const char *grouping;
|
||||
@@ -194,9 +289,11 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
else
|
||||
{
|
||||
/* Figure out the thousands separator character. */
|
||||
if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
|
||||
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
|
||||
thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
|
||||
# if defined _LIBC || defined _HAVE_BTOWC
|
||||
thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
|
||||
if (thousands == WEOF)
|
||||
thousands = L'\0';
|
||||
# endif
|
||||
if (thousands == L'\0')
|
||||
grouping = NULL;
|
||||
}
|
||||
@@ -233,23 +330,19 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
else
|
||||
negative = 0;
|
||||
|
||||
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 == L_('0'))
|
||||
{
|
||||
if (TOUPPER (s[1]) == L_('X'))
|
||||
{
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
else
|
||||
base = 10;
|
||||
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
|
||||
if (*s == L_('0'))
|
||||
{
|
||||
if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
|
||||
{
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 8;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 10;
|
||||
|
||||
/* Save the pointer so we can check later if anything happened. */
|
||||
save = s;
|
||||
@@ -273,8 +366,8 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
#endif
|
||||
end = NULL;
|
||||
|
||||
cutoff = ULONG_MAX / (unsigned LONG int) base;
|
||||
cutlim = ULONG_MAX % (unsigned LONG int) base;
|
||||
cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
|
||||
cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
|
||||
|
||||
overflow = 0;
|
||||
i = 0;
|
||||
@@ -314,25 +407,23 @@ INTERNAL (strtol) (nptr, endptr, base, group)
|
||||
`unsigned LONG int', but outside the range of `LONG int'. */
|
||||
if (overflow == 0
|
||||
&& i > (negative
|
||||
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
|
||||
: (unsigned LONG int) LONG_MAX))
|
||||
? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
|
||||
: (unsigned LONG int) STRTOL_LONG_MAX))
|
||||
overflow = 1;
|
||||
#else
|
||||
overflow |= negative;
|
||||
#endif
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
#if UNSIGNED
|
||||
return ULONG_MAX;
|
||||
return STRTOL_ULONG_MAX;
|
||||
#else
|
||||
return negative ? LONG_MIN : LONG_MAX;
|
||||
return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the result of the appropriate sign. */
|
||||
return (negative ? -i : i);
|
||||
return negative ? -i : i;
|
||||
|
||||
noconv:
|
||||
/* We must handle a special case here: the base is 0 or 16 and the
|
||||
@@ -340,12 +431,14 @@ noconv:
|
||||
hexadecimal digits. This is no error case. We return 0 and
|
||||
ENDPTR points to the `x`. */
|
||||
if (endptr != NULL)
|
||||
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
||||
&& save[-2] == L_('0'))
|
||||
*endptr = (STRING_TYPE *) &save[-1];
|
||||
else
|
||||
/* There was no number to convert. */
|
||||
*endptr = (STRING_TYPE *) nptr;
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -369,10 +462,11 @@ INT
|
||||
#ifdef weak_function
|
||||
weak_function
|
||||
#endif
|
||||
strtol (nptr, endptr, base)
|
||||
strtol (nptr, endptr, base LOCALE_PARAM)
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
LOCALE_PARAM_DECL
|
||||
{
|
||||
return INTERNAL (strtol) (nptr, endptr, base, 0);
|
||||
return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
|
||||
}
|
||||
|
||||
27
lib/strtoull.c
Normal file
27
lib/strtoull.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Function to parse an `unsigned long long int' from text.
|
||||
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define QUAD 1
|
||||
|
||||
#include "strtoul.c"
|
||||
|
||||
#ifdef _LIBC
|
||||
strong_alias (__strtoull_internal, __strtouq_internal)
|
||||
weak_alias (strtoull, strtouq)
|
||||
#endif
|
||||
58
lib/strtoumax.c
Normal file
58
lib/strtoumax.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Convert string representation of a number into an uintmax_t value.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || defined __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_UNSIGNED_LONG_LONG && ! HAVE_STRTOULL
|
||||
unsigned long long strtoull PARAMS ((char const *, char **, int));
|
||||
#endif
|
||||
|
||||
uintmax_t
|
||||
strtoumax (char const *ptr, char **endptr, int base)
|
||||
{
|
||||
#define USE_IF_EQUIVALENT(function) \
|
||||
if (sizeof (uintmax_t) == sizeof function (ptr, endptr, base)) \
|
||||
return function (ptr, endptr, base);
|
||||
|
||||
#if HAVE_UNSIGNED_LONG_LONG
|
||||
USE_IF_EQUIVALENT (strtoull)
|
||||
#endif
|
||||
|
||||
USE_IF_EQUIVALENT (strtoul)
|
||||
|
||||
abort ();
|
||||
}
|
||||
@@ -54,7 +54,7 @@ utime_null (const char *file)
|
||||
int status = 0;
|
||||
struct stat sb;
|
||||
|
||||
fd = open (file, O_RDWR, 0666);
|
||||
fd = open (file, O_RDWR);
|
||||
if (fd < 0
|
||||
|| fstat (fd, &sb) < 0
|
||||
|| safe_read (fd, &c, sizeof (char)) < 0
|
||||
|
||||
47
lib/version-etc.c
Normal file
47
lib/version-etc.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
void
|
||||
version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors)
|
||||
{
|
||||
fprintf (stream, "%s (%s) %s\n", command_name, package, version);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.\n\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
||||
\n\
|
||||
"
|
||||
), stream);
|
||||
fprintf (stream, _("Written by %s.\n"), authors);
|
||||
}
|
||||
17
lib/version-etc.h
Normal file
17
lib/version-etc.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef VERSION_ETC_H
|
||||
# define VERSION_ETC_H 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
void
|
||||
version_etc PARAMS ((FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors));
|
||||
|
||||
#endif /* VERSION_ETC_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1997, 98 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 98, 99 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
|
||||
@@ -70,7 +70,7 @@ xalloc_fail (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted);
|
||||
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
|
||||
Copyright 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +21,12 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef __strtol
|
||||
# define __strtol strtol
|
||||
# define __strtol_t long int
|
||||
# define __xstrtol xstrtol
|
||||
#endif
|
||||
|
||||
/* Some pre-ANSI implementations (e.g. SunOS 4)
|
||||
need stderr defined if assertion checking is enabled. */
|
||||
#include <stdio.h>
|
||||
@@ -39,6 +45,7 @@
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
@@ -61,34 +68,22 @@ extern int errno;
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
|
||||
#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t))
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
# define ULONG_MAX TYPE_MAXIMUM (unsigned long int)
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX TYPE_MAXIMUM (long int)
|
||||
#endif
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#ifdef isblank
|
||||
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
|
||||
#else
|
||||
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
#endif
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
|
||||
#include "xstrtol.h"
|
||||
|
||||
__unsigned long int __strtol ();
|
||||
__strtol_t __strtol ();
|
||||
|
||||
static int
|
||||
bkm_scale (__unsigned long int *x, int scale_factor)
|
||||
bkm_scale (__strtol_t *x, int scale_factor)
|
||||
{
|
||||
__unsigned long int product = *x * scale_factor;
|
||||
__strtol_t product = *x * scale_factor;
|
||||
if (*x != product / scale_factor)
|
||||
return 1;
|
||||
*x = product;
|
||||
@@ -96,7 +91,7 @@ bkm_scale (__unsigned long int *x, int scale_factor)
|
||||
}
|
||||
|
||||
static int
|
||||
bkm_scale_by_power (__unsigned long int *x, int base, int power)
|
||||
bkm_scale_by_power (__strtol_t *x, int base, int power)
|
||||
{
|
||||
while (power--)
|
||||
if (bkm_scale (x, base))
|
||||
@@ -109,27 +104,24 @@ bkm_scale_by_power (__unsigned long int *x, int base, int power)
|
||||
|
||||
strtol_error
|
||||
__xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
__unsigned long int *val, const char *valid_suffixes)
|
||||
__strtol_t *val, const char *valid_suffixes)
|
||||
{
|
||||
char *t_ptr;
|
||||
char **p;
|
||||
__unsigned long int tmp;
|
||||
__strtol_t tmp;
|
||||
|
||||
assert (0 <= strtol_base && strtol_base <= 36);
|
||||
|
||||
p = (ptr ? ptr : &t_ptr);
|
||||
|
||||
#if STRING_TO_UNSIGNED
|
||||
{
|
||||
const char *q = s;
|
||||
while (ISBLANK (*q))
|
||||
{
|
||||
if (! TYPE_SIGNED (__strtol_t))
|
||||
{
|
||||
const char *q = s;
|
||||
while (ISSPACE ((unsigned char) *q))
|
||||
++q;
|
||||
}
|
||||
if (*q == '-')
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
#endif
|
||||
if (*q == '-')
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
tmp = __strtol (s, p, strtol_base);
|
||||
@@ -139,8 +131,8 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
return LONGINT_INVALID;
|
||||
|
||||
/* Let valid_suffixes == NULL mean `allow any suffix'. */
|
||||
/* FIXME: update all callers except the one in tail.c changing
|
||||
last parameter NULL to `""'. */
|
||||
/* FIXME: update all callers except the ones that allow suffixes
|
||||
after the number, changing last parameter NULL to `""'. */
|
||||
if (!valid_suffixes)
|
||||
{
|
||||
*val = tmp;
|
||||
@@ -154,7 +146,10 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
int overflow;
|
||||
|
||||
if (!strchr (valid_suffixes, **p))
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
{
|
||||
*val = tmp;
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
}
|
||||
|
||||
if (strchr (valid_suffixes, '0'))
|
||||
{
|
||||
@@ -227,6 +222,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
break;
|
||||
|
||||
default:
|
||||
*val = tmp;
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
break;
|
||||
}
|
||||
@@ -258,7 +254,7 @@ main (int argc, char** argv)
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
char *p;
|
||||
__unsigned long int val;
|
||||
__strtol_t val;
|
||||
|
||||
s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw");
|
||||
if (s_err == LONGINT_OK)
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
#ifndef XSTRTOL_H_
|
||||
# define XSTRTOL_H_ 1
|
||||
|
||||
# if STRING_TO_UNSIGNED
|
||||
# define __xstrtol xstrtoul
|
||||
# define __strtol strtoul
|
||||
# define __unsigned unsigned
|
||||
# else
|
||||
# define __xstrtol xstrtol
|
||||
# define __strtol strtol
|
||||
# define __unsigned /* empty */
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for uintmax_t */
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
@@ -27,11 +21,14 @@ enum strtol_error
|
||||
typedef enum strtol_error strtol_error;
|
||||
# endif
|
||||
|
||||
strtol_error
|
||||
__xstrtol PARAMS ((const char *s, char **ptr, int base,
|
||||
__unsigned long int *val, const char *valid_suffixes));
|
||||
# define _DECLARE_XSTRTOL(name, type) \
|
||||
strtol_error \
|
||||
name PARAMS ((const char *s, char **ptr, int base, \
|
||||
type *val, const char *valid_suffixes));
|
||||
_DECLARE_XSTRTOL (xstrtol, long int)
|
||||
_DECLARE_XSTRTOL (xstrtoul, unsigned long int)
|
||||
_DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
|
||||
|
||||
# undef _STRTOL_ERROR
|
||||
# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
|
||||
do \
|
||||
{ \
|
||||
@@ -51,8 +48,7 @@ strtol_error
|
||||
break; \
|
||||
\
|
||||
case LONGINT_OVERFLOW: \
|
||||
/* FIXME: make this message dependent on STRING_TO_UNSIGNED */\
|
||||
error ((Exit_code), 0, "%s `%s' larger than maximum long int",\
|
||||
error ((Exit_code), 0, "%s `%s' too large", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
} \
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
#define STRING_TO_UNSIGNED 1
|
||||
#define __strtol strtoul
|
||||
#define __strtol_t unsigned long int
|
||||
#define __xstrtol xstrtoul
|
||||
#include "xstrtol.c"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef XSTRTOUL_H_
|
||||
# define XSTRTOUL_H_ 1
|
||||
|
||||
# define STRING_TO_UNSIGNED 1
|
||||
|
||||
/* Undefine this symbol so we can include xstrtol.h a second time.
|
||||
Otherwise, a program that wanted both xstrtol.h and xstrtoul.h
|
||||
would never get the declaration corresponding to the header file
|
||||
included after the first one. */
|
||||
# undef XSTRTOL_H_
|
||||
# include "xstrtol.h"
|
||||
|
||||
#endif /* not XSTRTOUL_H_ */
|
||||
31
lib/xstrtoumax.c
Normal file
31
lib/xstrtoumax.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* xstrtoumax.c -- A more useful interface to strtoumax.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define __strtol strtoumax
|
||||
#define __strtol_t uintmax_t
|
||||
#define __xstrtol xstrtoumax
|
||||
#include "xstrtol.c"
|
||||
70
m4/ChangeLog
70
m4/ChangeLog
@@ -1,3 +1,73 @@
|
||||
1999-05-04 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lfs.m4 (AC_LFS): -n32, -o32, and -n64 should be in CFLAGS,
|
||||
not CPPFLAGS, so that linking works correctly in IRIX.
|
||||
|
||||
1999-04-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* jm-macros.m4 (AC_REPLACE_FUNCS): Add dup2.
|
||||
|
||||
1999-04-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* xstrtoumax.m4: Require jm_AC_TYPE_UNSIGNED_LONG_LONG.
|
||||
AC_REPLACE xstroull if necessary. From Paul Eggert.
|
||||
(AC_CHECK_FUNCS): Remove strtoull, strtoumax, strtouq.
|
||||
|
||||
1999-04-20 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* uintmax_t.m4 (jm_AC_TYPE_UINTMAX_T): Move unsigned long
|
||||
long check into new jm_AC_TYPE_UNSIGNED_LONG_LONG macro.
|
||||
* jm-macros.m4 (jm_CHECK_ALL_TYPES): Require
|
||||
jm_AC_TYPE_UNSIGNED_LONG_LONG.
|
||||
* ulonglong.m4 (jm_AC_TYPE_UNSIGNED_LONG_LONG): New file/macro.
|
||||
|
||||
* lfs.m4: Port to AIX and HP-UX. Support cross-compilation.
|
||||
|
||||
1999-04-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* xstrtoumax.m4 (jm_AC_PREREQ_XSTRTOUMAX): New file/macro.
|
||||
* jm-macros.m4: Use it.
|
||||
|
||||
1999-04-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* strftime.m4: Remove test for %f.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4 (jm_CHECK_ALL_TYPES): New macro, contains the
|
||||
superset of the AC_TYPE_* checks in the textutils, fileutils,
|
||||
and sh-utils, plus AC_TYPE_PID_T. Paul Eggert suggested adding
|
||||
AC_TYPE_PID_T.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Define GNU_PACKAGE here.
|
||||
Be sure to AC_SUBST it, once again, so that @GNU_PACKAGE@ is
|
||||
replaced e.g., in the *.sh files of the sh-utils.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: s/jm_WITH_REGEX/jm_INCLUDED_REGEX/.
|
||||
* regex.m4 (jm_INCLUDED_REGEX): Rename from jm_WITH_REGEX.
|
||||
Don't depend on AM_GLIBC. Suggestions from Alain Magloire.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-winsz1.m4 (jm_WINSIZE_IN_PTEM): New macro.
|
||||
|
||||
1999-03-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Use AC_FUNC_SETVBUF_REVERSED.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-glibc-io.m4: Use only those *_unlocked macros that are declared.
|
||||
|
||||
1999-02-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* gettext.m4 (AM_GNU_GETTEXT): Do `changequote' around use of brackets
|
||||
in macro definition. From Eli Zaretskii and Alain Magloire.
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* group-member.m4: New file -- extracted from sh-utils' configure.in.
|
||||
|
||||
@@ -46,10 +46,12 @@ st_mtim.m4 \
|
||||
stat.m4 \
|
||||
strftime.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
uptime.m4 \
|
||||
utimbuf.m4 \
|
||||
utime.m4 \
|
||||
utimes.m4
|
||||
utimes.m4 \
|
||||
xstrtoumax.m4
|
||||
##m4-files-end
|
||||
|
||||
Makefile.am: Makefile.am.in
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -57,15 +57,20 @@ POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AMTAR = @AMTAR@
|
||||
AMTARFLAGS = @AMTARFLAGS@
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
GENCAT = @GENCAT@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GETCONF = @GETCONF@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -73,42 +78,84 @@ INSTOBJEXT = @INSTOBJEXT@
|
||||
INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
NEED_SETGID = @NEED_SETGID@
|
||||
OPTIONAL_BIN_PROGS = @OPTIONAL_BIN_PROGS@
|
||||
OPTIONAL_BIN_ZCRIPTS = @OPTIONAL_BIN_ZCRIPTS@
|
||||
PACKAGE = @PACKAGE@
|
||||
PERL = @PERL@
|
||||
POFILES = @POFILES@
|
||||
POSUB = @POSUB@
|
||||
POW_LIBM = @POW_LIBM@
|
||||
RANLIB = @RANLIB@
|
||||
SEQ_LIBM = @SEQ_LIBM@
|
||||
SQRT_LIBM = @SQRT_LIBM@
|
||||
U = @U@
|
||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
EXTRA_DIST = README Makefile.am.in afs.m4 assert.m4 check-decl.m4 check-type.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fnmatch.m4 fstypename.m4 getgroups.m4 getline.m4 getloadavg.m4 gettext.m4 glibc.m4 group-member.m4 inttypes_h.m4 isc-posix.m4 jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 st_dm_mode.m4 st_mtim.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 utimes.m4
|
||||
|
||||
EXTRA_DIST = README Makefile.am.in \
|
||||
afs.m4 \
|
||||
assert.m4 \
|
||||
check-decl.m4 \
|
||||
check-type.m4 \
|
||||
chown.m4 \
|
||||
const.m4 \
|
||||
d-ino.m4 \
|
||||
d-type.m4 \
|
||||
decl.m4 \
|
||||
error.m4 \
|
||||
fnmatch.m4 \
|
||||
fstypename.m4 \
|
||||
getgroups.m4 \
|
||||
getline.m4 \
|
||||
getloadavg.m4 \
|
||||
gettext.m4 \
|
||||
glibc.m4 \
|
||||
group-member.m4 \
|
||||
inttypes_h.m4 \
|
||||
isc-posix.m4 \
|
||||
jm-glibc-io.m4 \
|
||||
jm-macros.m4 \
|
||||
jm-mktime.m4 \
|
||||
jm-winsz1.m4 \
|
||||
jm-winsz2.m4 \
|
||||
lchown.m4 \
|
||||
lcmessage.m4 \
|
||||
lfs.m4 \
|
||||
ls-mntd-fs.m4 \
|
||||
lstat.m4 \
|
||||
malloc.m4 \
|
||||
memcmp.m4 \
|
||||
perl.m4 \
|
||||
prereq.m4 \
|
||||
progtest.m4 \
|
||||
putenv.m4 \
|
||||
readdir.m4 \
|
||||
realloc.m4 \
|
||||
regex.m4 \
|
||||
st_dm_mode.m4 \
|
||||
st_mtim.m4 \
|
||||
stat.m4 \
|
||||
strftime.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
uptime.m4 \
|
||||
utimbuf.m4 \
|
||||
utime.m4 \
|
||||
utimes.m4 \
|
||||
xstrtoumax.m4
|
||||
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_SOURCES =
|
||||
DIST_COMMON = README ChangeLog Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
@@ -136,13 +183,14 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
@@ -165,7 +213,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
@@ -199,7 +247,7 @@ maintainer-clean: maintainer-clean-am
|
||||
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
all-redirect all-am all install-strip installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
@@ -314,11 +314,13 @@ strdup __argz_count __argz_stringify __argz_next])
|
||||
dnl be included in po/Makefile.
|
||||
test -d po || mkdir po
|
||||
if test "x$srcdir" != "x."; then
|
||||
changequote(, )dnl
|
||||
if test "x`echo $srcdir | sed -e 's@^[A-z]:@@' -e 's@/.*@@'`" = "x"; then
|
||||
posrcprefix="$srcdir/"
|
||||
else
|
||||
posrcprefix="../$srcdir/"
|
||||
fi
|
||||
changequote([, ])dnl
|
||||
else
|
||||
posrcprefix="../"
|
||||
fi
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if the glibc *_unlocked I/O macros are available.
|
||||
dnl Use only those *_unlocked macros that are declared.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
|
||||
[AC_CHECK_FUNCS( \
|
||||
clearerr_unlocked \
|
||||
feof_unlocked \
|
||||
ferror_unlocked \
|
||||
fflush_unlocked \
|
||||
fputc_unlocked \
|
||||
fread_unlocked \
|
||||
fwrite_unlocked \
|
||||
getc_unlocked \
|
||||
getchar_unlocked \
|
||||
putc_unlocked \
|
||||
putchar_unlocked \
|
||||
)
|
||||
[
|
||||
io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
|
||||
fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
|
||||
getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
|
||||
for jm_io_func in $io_functions; do
|
||||
# Check for the existence of each function only if its declared.
|
||||
# Otherwise, we'd get the Solaris5.5.1 functions that are not
|
||||
# declared, and that have been removed from Solaris5.6. The resulting
|
||||
# 5.5.1 binaries would not run on 5.6 due to shared library differences.
|
||||
jm_CHECK_DECLARATIONS([#include <stdio.h>
|
||||
], $jm_io_func,
|
||||
jm_declared=yes,
|
||||
jm_declared=no)
|
||||
if test $jm_declared = yes; then
|
||||
AC_CHECK_FUNCS($jm_io_func)
|
||||
fi
|
||||
done
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 6
|
||||
#serial 7
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -6,15 +6,18 @@ AC_DEFUN(jm_MACROS,
|
||||
[
|
||||
AC_PREREQ(2.13) dnl Minimum Autoconf version required.
|
||||
|
||||
GNU_PACKAGE="GNU $PACKAGE"
|
||||
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
|
||||
[The concatenation of the strings \`GNU ', and PACKAGE.])
|
||||
AC_SUBST(GNU_PACKAGE)
|
||||
|
||||
dnl This macro actually runs replacement code. See isc-posix.m4.
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
|
||||
jm_WITH_REGEX([lib/regex.c])
|
||||
jm_INCLUDED_REGEX([lib/regex.c])
|
||||
|
||||
AC_REQUIRE([jm_ASSERT])
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_REQUIRE([jm_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_TYPE])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_INO])
|
||||
@@ -34,11 +37,32 @@ AC_DEFUN(jm_MACROS,
|
||||
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
|
||||
AC_REQUIRE([jm_FUNC_FNMATCH])
|
||||
AC_REQUIRE([jm_AFS])
|
||||
AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
|
||||
AC_REPLACE_FUNCS(strcasecmp strncasecmp)
|
||||
AC_REPLACE_FUNCS(dup2)
|
||||
|
||||
# By default, argmatch should fail calling usage (1).
|
||||
AC_DEFINE(ARGMATCH_DIE, [usage (1)],
|
||||
[Define to the function xargmatch calls on failures.])
|
||||
AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
|
||||
dnl Used to define SETVBUF in sys2.h.
|
||||
AC_FUNC_SETVBUF_REVERSED
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN(jm_CHECK_ALL_TYPES,
|
||||
[
|
||||
AC_TYPE_GETGROUPS
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_UID_T
|
||||
AC_CHECK_TYPE(ino_t, unsigned long)
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
|
||||
])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
dnl From Jim Meyering.
|
||||
#serial 1
|
||||
#serial 2
|
||||
AC_DEFUN(jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H,
|
||||
[AC_REQUIRE([AM_SYS_POSIX_TERMIOS])
|
||||
AC_CACHE_CHECK([whether use of TIOCGWINSZ requires termios.h],
|
||||
@@ -17,3 +17,10 @@ AC_DEFUN(jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H,
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN(jm_WINSIZE_IN_PTEM,
|
||||
[AC_CHECK_HEADER([sys/ptem.h],
|
||||
AC_DEFINE(WINSIZE_IN_PTEM, 1,
|
||||
[Define if your system defines \`struct winsize' in sys/ptem.h.]))
|
||||
]
|
||||
)
|
||||
|
||||
143
m4/lfs.m4
143
m4/lfs.m4
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl The problem is that the default compilation flags in Solaris 2.6 won't
|
||||
dnl let programs access large files; you need to tell the compiler that
|
||||
@@ -8,50 +8,99 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_LFS.
|
||||
dnl AC_LFS_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN(AC_LFS_FLAGS,
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support], ac_cv_lfs_$1,
|
||||
[ac_cv_lfs_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
ac_cv_lfs_$1=no
|
||||
ifelse($1, CFLAGS,
|
||||
[case "$host_os" in
|
||||
# IRIX 6.2 and later
|
||||
irix6.[[2-9]]* | irix6.1[[0-9]]* | irix[[7-9]].* | irix[[1-9]][[0-9]]*)
|
||||
if test "$GCC" != yes; then
|
||||
ac_cv_lfs_CFLAGS=-n32
|
||||
fi
|
||||
ac_save_CC="$CC"
|
||||
CC="$ac_save_CC $ac_cv_lfs_CFLAGS"
|
||||
AC_TRY_LINK(, , , ac_cv_lfs_CFLAGS=no)
|
||||
CC="$ac_save_CC"
|
||||
esac])
|
||||
}])])
|
||||
|
||||
dnl Internal subroutine of AC_LFS.
|
||||
dnl AC_LFS_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN(AC_LFS_SPACE_APPEND,
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
case "[$]$1" in
|
||||
'') $1=$2 ;;
|
||||
*) $1=[$]$1' '$2 ;;
|
||||
esac ;;
|
||||
esac])
|
||||
|
||||
dnl Internal subroutine of AC_LFS.
|
||||
dnl AC_LFS_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN(AC_LFS_MACRO_VALUE,
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[[$2=no
|
||||
$4
|
||||
for ac_flag in $ac_cv_lfs_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
-D$1)
|
||||
$2=1 ;;
|
||||
-D$1=*)
|
||||
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
|
||||
esac
|
||||
done]])
|
||||
if test "[$]$2" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN(AC_LFS,
|
||||
[dnl
|
||||
# If available, prefer support for large files unless the user specified
|
||||
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
|
||||
AC_MSG_CHECKING(whether large file support needs explicit enabling)
|
||||
ac_getconfs=''
|
||||
ac_result=yes
|
||||
ac_set=''
|
||||
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
case $ac_shellvar in
|
||||
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
|
||||
*) ac_lfsvar=LFS_$ac_shellvar ;;
|
||||
esac
|
||||
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
|
||||
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
|
||||
ac_getconf=`getconf $ac_lfsvar`
|
||||
ac_getconfs=$ac_getconfs$ac_getconf
|
||||
eval ac_test_$ac_shellvar=\$ac_getconf
|
||||
done
|
||||
case "$ac_result" in
|
||||
no)
|
||||
case "`(uname -s -r) 2>/dev/null`" in
|
||||
HP-UX' '?.10.[[2-9]][[0-9]]* | HP-UX' '?.1[[1-9]]* | HP-UX' '?.[[2-9]][[0-9]]*)
|
||||
# HP-UX 10.20 and later support large files,
|
||||
# but do not support `getconf LFS_CFLAGS'.
|
||||
ac_test_CPPFLAGS='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
|
||||
ac_test_LDFLAGS=
|
||||
ac_test_LIBS=
|
||||
ac_getconfs=nonempty
|
||||
ac_result=yes ;;
|
||||
esac ;;
|
||||
esac
|
||||
case "$ac_result$ac_getconfs" in
|
||||
yes) ac_result=no ;;
|
||||
esac
|
||||
case "$ac_result$ac_set" in
|
||||
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
|
||||
esac
|
||||
AC_MSG_RESULT($ac_result)
|
||||
case $ac_result in
|
||||
yes)
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
eval $ac_shellvar=\$ac_test_$ac_shellvar
|
||||
done ;;
|
||||
esac
|
||||
])
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(lfs,
|
||||
[ --disable-lfs omit Large File Support])
|
||||
if test "$enable_lfs" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_LFS_FLAGS(CFLAGS)
|
||||
AC_LFS_FLAGS(LDFLAGS)
|
||||
AC_LFS_FLAGS(LIBS)
|
||||
for ac_flag in $ac_cv_lfs_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
-D_FILE_OFFSET_BITS=*) ;;
|
||||
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
|
||||
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
|
||||
-[[DI]]?*)
|
||||
AC_LFS_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
|
||||
*)
|
||||
AC_LFS_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
|
||||
esac
|
||||
done
|
||||
AC_LFS_SPACE_APPEND(LDFLAGS, "$ac_cv_lfs_LDFLAGS")
|
||||
AC_LFS_SPACE_APPEND(LIBS, "$ac_cv_lfs_LIBS")
|
||||
AC_LFS_MACRO_VALUE(_FILE_OFFSET_BITS, ac_cv_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable. ],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_file_offset_bits=64 ;;
|
||||
esac])
|
||||
AC_LFS_MACRO_VALUE(_LARGEFILE_SOURCE, ac_cv_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts. ],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_largefile_source=1 ;;
|
||||
esac])
|
||||
AC_LFS_MACRO_VALUE(_LARGE_FILES, ac_cv_large_files,
|
||||
[Define for large files, on AIX-style hosts. ],
|
||||
[case "$host_os" in
|
||||
# AIX 4.2 and later
|
||||
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
|
||||
ac_cv_large_files=1 ;;
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
|
||||
73
m4/regex.m4
73
m4/regex.m4
@@ -1,54 +1,51 @@
|
||||
#serial 4
|
||||
#serial 5
|
||||
|
||||
dnl Initially derived from code in GNU grep.
|
||||
dnl Mostly written by Jim Meyering.
|
||||
|
||||
AC_DEFUN(jm_WITH_REGEX,
|
||||
dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
|
||||
dnl
|
||||
AC_DEFUN(jm_INCLUDED_REGEX,
|
||||
[
|
||||
AC_REQUIRE([AM_GLIBC])
|
||||
|
||||
dnl Even packages that don't use regex.c can use this macro.
|
||||
dnl Of course, for them it doesn't do anything.
|
||||
|
||||
# By default, don't use the included regex.c on systems with a version
|
||||
# of glibc 2 that's new enough to pass the following run test.
|
||||
# If cross compiling, assume the test would fail and use the included
|
||||
# regex.c. The failing regular expression is from `Spencer ere test
|
||||
# #75' in grep-2.2f.
|
||||
# Assume we'll default to using the included regex.c.
|
||||
ac_use_included_regex=yes
|
||||
|
||||
if test "$ac_cv_glibc" = yes; then
|
||||
# Without this run-test, on older glibc2 systems we'd end up
|
||||
# using the buggy system regex.
|
||||
AC_CACHE_CHECK([for working re_compile_pattern],
|
||||
jm_cv_func_working_re_compile_pattern,
|
||||
AC_TRY_RUN(
|
||||
changequote(<<, >>)dnl
|
||||
<<
|
||||
# However, if the system regex support is good enough that it passes the
|
||||
# the following run test, then default to *not* using the included regex.c.
|
||||
# If cross compiling, assume the test would fail and use the included
|
||||
# regex.c. The failing regular expression is from `Spencer ere test #75'
|
||||
# in grep-2.3.
|
||||
AC_CACHE_CHECK([for working re_compile_pattern],
|
||||
jm_cv_func_working_re_compile_pattern,
|
||||
AC_TRY_RUN(
|
||||
changequote(<<, >>)dnl
|
||||
<<
|
||||
#include <stdio.h>
|
||||
#include <regex.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
static struct re_pattern_buffer regex;
|
||||
const char *s;
|
||||
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
|
||||
/* Add this third left square bracket, [, to balance the
|
||||
three right ones below. Otherwise autoconf-2.14 chokes. */
|
||||
s = re_compile_pattern ("a[[:]:]]b\n", 9, ®ex);
|
||||
/* This should fail with _Invalid character class name_ error. */
|
||||
exit (s ? 0 : 1);
|
||||
}
|
||||
>>,
|
||||
changequote([, ])dnl
|
||||
int
|
||||
main ()
|
||||
{
|
||||
static struct re_pattern_buffer regex;
|
||||
const char *s;
|
||||
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
|
||||
/* Add this third left square bracket, [, to balance the
|
||||
three right ones below. Otherwise autoconf-2.14 chokes. */
|
||||
s = re_compile_pattern ("a[[:]:]]b\n", 9, ®ex);
|
||||
/* This should fail with _Invalid character class name_ error. */
|
||||
exit (s ? 0 : 1);
|
||||
}
|
||||
>>,
|
||||
changequote([, ])dnl
|
||||
|
||||
jm_cv_func_working_re_compile_pattern=yes,
|
||||
jm_cv_func_working_re_compile_pattern=no,
|
||||
dnl When crosscompiling, assume it's broken.
|
||||
jm_cv_func_working_re_compile_pattern=no))
|
||||
if test $jm_cv_func_working_re_compile_pattern = yes; then
|
||||
ac_use_included_regex=no
|
||||
fi
|
||||
jm_cv_func_working_re_compile_pattern=yes,
|
||||
jm_cv_func_working_re_compile_pattern=no,
|
||||
dnl When crosscompiling, assume it's broken.
|
||||
jm_cv_func_working_re_compile_pattern=no))
|
||||
if test $jm_cv_func_working_re_compile_pattern = yes; then
|
||||
ac_use_included_regex=no
|
||||
fi
|
||||
|
||||
test -n "$1" || AC_MSG_ERROR([missing argument])
|
||||
|
||||
@@ -104,7 +104,6 @@ main ()
|
||||
CMP ("%^c", "FRI JAN 9 13:06:07 1970");
|
||||
CMP ("%d", "09");
|
||||
CMP ("%e", " 9"); /* POSIX.2 */
|
||||
CMP ("%f", "5"); /* POSIX.2 */
|
||||
CMP ("%g", "70"); /* GNU */
|
||||
CMP ("%h", "Jan"); /* POSIX.2 */
|
||||
CMP ("%^h", "JAN");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
@@ -11,11 +11,7 @@ AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
|
||||
[
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
if test $jm_ac_cv_header_inttypes_h = no; then
|
||||
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
|
||||
[AC_TRY_COMPILE([],
|
||||
[unsigned long long i = (unsigned long long) -1;],
|
||||
ac_cv_type_unsigned_long_long=yes,
|
||||
ac_cv_type_unsigned_long_long=no)])
|
||||
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
|
||||
test $ac_cv_type_unsigned_long_long = yes \
|
||||
&& ac_type='unsigned long long' \
|
||||
|| ac_type='unsigned long'
|
||||
|
||||
16
m4/ulonglong.m4
Normal file
16
m4/ulonglong.m4
Normal file
@@ -0,0 +1,16 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
|
||||
[
|
||||
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
|
||||
[AC_TRY_COMPILE([],
|
||||
[unsigned long long i = (unsigned long long) -1;],
|
||||
ac_cv_type_unsigned_long_long=yes,
|
||||
ac_cv_type_unsigned_long_long=no)])
|
||||
if test $ac_cv_type_unsigned_long_long = yes; then
|
||||
AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
|
||||
[Define if you have the unsigned long long type.])
|
||||
fi
|
||||
])
|
||||
22
m4/xstrtoumax.m4
Normal file
22
m4/xstrtoumax.m4
Normal file
@@ -0,0 +1,22 @@
|
||||
#serial 1
|
||||
|
||||
# autoconf tests required for use of xstrtoumax.c
|
||||
|
||||
AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
|
||||
[
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
|
||||
AC_CHECK_HEADERS(stdlib.h)
|
||||
AC_REPLACE_FUNCS(strtoumax)
|
||||
|
||||
dnl We don't need (and can't compile) the replacement strtoull
|
||||
dnl unless the type `unsigned long long' exists.
|
||||
dnl Also, only the replacement strtoumax invokes strtoull,
|
||||
dnl so we need the replacement strtoull only if strtoumax does not exist.
|
||||
case "$ac_cv_type_unsigned_long_long,$ac_cv_func_strtoumax" in
|
||||
yes,no)
|
||||
AC_REPLACE_FUNCS(strtoull)
|
||||
;;
|
||||
esac
|
||||
|
||||
])
|
||||
75
man/help2man
75
man/help2man
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/sw/tools/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright © 1997, 98 Free Software Foundation, Inc.
|
||||
# Copyright © 1997, 98, 99 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,11 +25,11 @@ use Getopt::Long;
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.007';
|
||||
my $this_version = '1.010';
|
||||
my $version_info = <<EOT;
|
||||
$this_program $this_version
|
||||
|
||||
Copyright (C) 1997, 98 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 98, 99 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
@@ -252,11 +252,11 @@ for (@help)
|
||||
next;
|
||||
}
|
||||
|
||||
# Catch start of options.
|
||||
if (/^Options:/)
|
||||
# Convert some standard paragraph names
|
||||
if (s/^(Options|Examples):\s*\n//)
|
||||
{
|
||||
print qq(.SH OPTIONS\n);
|
||||
s/Options://;
|
||||
print qq(.SH \U$1\n);
|
||||
next unless length;
|
||||
}
|
||||
|
||||
# Catch bug report text.
|
||||
@@ -271,35 +271,50 @@ for (@help)
|
||||
{$1$2$1\\&...=PATTERN };
|
||||
|
||||
# Convert options.
|
||||
s/(\s)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/ge;
|
||||
s/((?:^|,)\s+)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/mge;
|
||||
|
||||
# Option subsections have second line indented.
|
||||
print qq(.SS "$1"\n) if s/^(\S.*)\n(\s)/$2/;
|
||||
|
||||
# Lines indented more than about 10 spaces may be assumed to be
|
||||
# continuations of the previous line.
|
||||
s/\n {10,}/ /g;
|
||||
|
||||
# Lines following dotted (*) or numbered points may also be
|
||||
# continued if indented to the same level as the text following
|
||||
# the point.
|
||||
1 while s{((?:^|\n)(\s+)(?:[1-9][.)]|\*)(\s+)(?:[^\n]+))\n\2 \3(\S)}
|
||||
{$1 $4}g;
|
||||
|
||||
# Indented paragraph.
|
||||
if (/^\s/)
|
||||
my $ind = 0;
|
||||
for (split /\n/)
|
||||
{
|
||||
for (split /\n/)
|
||||
# indented paragraph
|
||||
if (/^\s/)
|
||||
{
|
||||
s/^\s+//;
|
||||
s/([^,])\s+/$1\n/;
|
||||
print ".TP\n$_\n" if $_;
|
||||
# Join continued lines when indented to the same point as
|
||||
# text following at least two spaces on the previous line.
|
||||
if ($ind > 0 and /^ {$ind}\S/)
|
||||
{
|
||||
s/^\s+//;
|
||||
print "$_\n" if $_;
|
||||
}
|
||||
else
|
||||
{
|
||||
# use the words(s) before two or more spaces for the
|
||||
# tag
|
||||
s/^(\s+)//;
|
||||
$ind = length $1;
|
||||
|
||||
if (s/(\s\s+)/\n/)
|
||||
{
|
||||
$ind += (length $1) + index $_, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ind = 0;
|
||||
}
|
||||
|
||||
print ".TP\n$_\n" if $_;
|
||||
}
|
||||
}
|
||||
# Anything else.
|
||||
else
|
||||
{
|
||||
print ".PP\n" unless $ind < 0;
|
||||
print "$_\n";
|
||||
$ind = -1;
|
||||
}
|
||||
}
|
||||
# Anything else.
|
||||
else
|
||||
{
|
||||
print ".PP\n$_\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
man/pinky.x
Normal file
2
man/pinky.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
@@ -1,3 +1,864 @@
|
||||
1999-05-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0h.
|
||||
|
||||
* tests/touch/dir-1: New test.
|
||||
* tests/touch/Makefile.am (TESTS_ENVIRONMENT): Remove individual
|
||||
upper-case program names. Add a definition of PATH.
|
||||
(TESTS): Add dir-1.
|
||||
|
||||
* src/mkdir.c (main): Use better wording in diagnostic: `cannot
|
||||
create directory' rather than `cannot make directory'. The former
|
||||
also matches the one in makepath.c.
|
||||
|
||||
* src/dd.c: (apply_translations): Use TOUPPER and TOLOWER,
|
||||
not toupper and tolower.
|
||||
|
||||
1999-05-05 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/makepath.c (make_dir): When reporting a mkdir failure and the
|
||||
target cannot be `stat'ed, use the errno from the failed mkdir call,
|
||||
not the one from the stat call. Before this change, running
|
||||
`mkdir -p /no-dir/no-dir' as an unprivileged user would wrongly
|
||||
elicit `No such file or directory' instead of `Permission denied'.
|
||||
|
||||
* lib/strtol.c (TYPE_SIGNED, TYPE_MAXIMUM, TYPE_MINIMUM): Define.
|
||||
(ULONG_LONG_MAX, LONG_LONG_MAX, LONG_LONG_MIN): Define if not defined.
|
||||
Based on a patch from Kaveh Ghazi.
|
||||
|
||||
* src/ls.c (USE_ACL): Define this only #if
|
||||
(HAVE_SYS_ACL_H && HAVE_ACL && defined GETACLCNT).
|
||||
Use `USE_ACL' in place of `HAVE_ACL' everywhere else. From Kaveh Ghazi.
|
||||
|
||||
1999-05-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/makepath.c: Include makepath.h libintl.h, not after it.
|
||||
Otherwise, we'd get the wrong definition of PARAMS from libintl.h.
|
||||
(The method of defining PARAMS in libintl.h doesn't check PROTOTYPES,
|
||||
which is necessary on Irix4 since cc doesn't define __STDC__.)
|
||||
From Kaveh Ghazi.
|
||||
|
||||
1999-04-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Makefile.maint: Define several tag-related make variables.
|
||||
(cvs-dist): Use the make variables instead of shell ones.
|
||||
(announcement): Automatically generate diffs for all ChangeLog files,
|
||||
not just the top level one.
|
||||
|
||||
1999-04-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/dup2.c: New file.
|
||||
|
||||
1999-04-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/touch.c (touch): Only do the fstat if we need to.
|
||||
Resort to calling stat for directories, but only when necessary.
|
||||
(usage): Mention --no-create.
|
||||
|
||||
* src/copy.c (copy_internal): Move the one-file-system test so that
|
||||
it follows the `if (new_dst || !S_ISDIR (dst_sb.st_mode))' block.
|
||||
Prior to this change, `cp --one-file-system' would traverse a file-
|
||||
system boundary if the destination directory existed. From Ton Hospel.
|
||||
|
||||
1999-04-27 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/dd.c: Always use STDIN_FILENO for input and STDOUT_FILENO
|
||||
for output, to avoid confusion with closed input and output fds.
|
||||
(input_fd, output_fd): Remove; all uses changed to STDIN_FILENO
|
||||
and STDOUT_FILENO.
|
||||
(open_fd): New function.
|
||||
(main): Use it, instead of open, to ensure that file descriptors
|
||||
don't get confused.
|
||||
|
||||
1999-04-26 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/ls.c (decode_switches): Use STDIN_FILENO, STDOUT_FILENO instead
|
||||
of 0, 1.
|
||||
|
||||
* src/dd.c (skip): Don't fstat the input file; the result is
|
||||
no longer used.
|
||||
|
||||
1999-04-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/mv/into-self-2: Update to reflect this change by reversing
|
||||
the order of arguments so the symlink is the source, not the
|
||||
destination (otherwise, the mv command would now succeed).
|
||||
|
||||
* src/copy.c (copy_internal): Don't make `mv foo symlink-to-foo' fail.
|
||||
That is, even though source and destination are `the same,' don't fail
|
||||
if the destination is a symlink. From Peter Samuelson.
|
||||
|
||||
1999-04-26 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/dd.c (main): If you can't open an output file (with
|
||||
seek=...) read-write, then open it for write and report an
|
||||
error if we can't seek.
|
||||
|
||||
* lib/filemode.c (setst, ftypelet, mode_string):
|
||||
* lib/mkdir.c (mkdir):
|
||||
* lib/makepath.c (make_path):
|
||||
* lib/modechange.c (make_node_op_equals, mode_compile,
|
||||
mode_create_from_ref, mode_adjust):
|
||||
* lib/modechange.h (mode_adjust):
|
||||
* src/chmod.c (describe_change, change_file_mode):
|
||||
* src/copy.c (copy_reg, copy_internal):
|
||||
* src/copy.h (struct cp_options.umask_kill):
|
||||
* src/cp.c (do_copy, cp_option_init, main):
|
||||
* src/dd.c (main):
|
||||
* src/install.c (mode, cp_option_init, DIR_MODE):
|
||||
* src/mkdir.c (main):
|
||||
* src/mkfifo.c (main):
|
||||
* src/mknod.c (main):
|
||||
* src/mv.c (cp_option_init):
|
||||
* src/touch.c (open_maybe_create):
|
||||
Use proper mode_t types and macros.
|
||||
Don't assume the traditional Unix values for mode bits.
|
||||
|
||||
* lib/filemode.c (S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH,
|
||||
S_IXOTH): Define if not defined.
|
||||
(rwx): Remove.
|
||||
* lib/mkdir.c (S_IRWXU, S_IRWXG, S_IRWXO): Define if not defined.
|
||||
* lib/makepath.c (S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRWXU):
|
||||
Define if not defined.
|
||||
* src/system.h (S_ISUID, S_ISGID, S_ISVTX, S_IRWXU, S_IRWXG, S_IRWXO):
|
||||
Define if not defined.
|
||||
(CHMOD_MODE_BITS): New macro.
|
||||
* src/install.c (isodigit): Remove unused macro.
|
||||
|
||||
* src/mkfifo.c, src/mknod.c (usage):
|
||||
Use symbolic mode as default, not octal.
|
||||
|
||||
* lib/utime.c (utime_null):
|
||||
Don't pass 0666 to open; it's not needed and isn't
|
||||
guaranteed to be portable.
|
||||
|
||||
* lib/filemode.h: <config.h>, <sys/types.h>: Include for mode_t.
|
||||
(mode_string): Now takes mode_t.
|
||||
|
||||
* lib/modechange.h: Include <config.h>, <sys/types.h> for mode_t.
|
||||
(struct mode_change): Members affected and value are now mode_t instead
|
||||
of unsigned short.
|
||||
|
||||
* doc/fileutils.texi, doc/perm.texi:
|
||||
Don't assume traditional Unix mode numbering.
|
||||
|
||||
* lib/modechange.c: modechange.h now includes sys/types.h.
|
||||
Include xstrtol.h.
|
||||
(isodigit, oatoi): Remove.
|
||||
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP,
|
||||
S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH, S_IRWXU, S_IRWXG,
|
||||
S_IRWXO): Define if not defined.
|
||||
(CHMOD_MODE_BITS): New macro.
|
||||
(mode_compile): Convert from octal with xstrtoul, not our own routine.
|
||||
|
||||
1999-04-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0g.
|
||||
|
||||
1999-04-22 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c (word32): Don't use `#error'; it runs afoul of
|
||||
SunOS 4.1.4 cc. From Paul Eggert.
|
||||
|
||||
* lib/strtoull.c: Guard strong_alias and weak_alias with #ifdef _LIBC.
|
||||
|
||||
1999-04-20 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Replace our temporary hack implementation of strtoumax with
|
||||
something very close to the real code in glibc.
|
||||
|
||||
* lib/xstrtoumax.c: Remove the temporary strtoumax replacement;
|
||||
we now have a true replacement in strtoumax.c.
|
||||
(__strtol): Always define to strtoumax.
|
||||
(<stdlib.h>): No need to include.
|
||||
(PARAMS): Remove.
|
||||
(my_strtoumax): Move this to strtoumax.c,
|
||||
rename it to strtoumax, and simplify.
|
||||
|
||||
* lib/strtoull.c, lib/strtoumax.c: New files.
|
||||
|
||||
* lib/strtol.c: Update to glibc 2.1.1 version.
|
||||
|
||||
1999-04-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): s/posix-warn/env-warn/.
|
||||
(check-local): Also test and warn if CDPATH is set.
|
||||
|
||||
1999-04-20 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* configure.in (AC_CANONICAL_HOST): Add; needed for new AC_LFS's
|
||||
cross-compilation.
|
||||
* config.guess: New file (from autoconf).
|
||||
* config.sub: New file (from autoconf).
|
||||
|
||||
* src/shred.c <config.h>: Include first, since it can do
|
||||
things like #define const, and this must be done before
|
||||
including any system headers.
|
||||
|
||||
* lib/xstrtoumax.c (my_strtoumax): Fix typo in computing
|
||||
whether overflow occurred. Improve overflow-detection to use
|
||||
only one conditional branch total, rather than 2N+1
|
||||
conditional branches for an N-digit number.
|
||||
|
||||
1999-04-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Remove strtoull, strtoumax, and
|
||||
strtouq, now that they're checked in m4/xstrtoumax.m4.
|
||||
|
||||
1999-04-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* doc/fileutils.texi, src/shred.c (main, longopts):
|
||||
Use -u instead of -R for --remove, so that we can preserve
|
||||
future compatibility with rm.
|
||||
|
||||
1999-04-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c [!HAVE_CONFIG_H] (ST_BLKSIZE): Define to 65536.
|
||||
(do_wipefd): Use ST_BLKSIZE instead of referring to the st_blksize
|
||||
member directly.
|
||||
|
||||
1999-04-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Fix shred to do the right thing with off_t longer than long.
|
||||
Merge large-integer parsing code with similar code in dd.c,
|
||||
and put the resulting in lib/xstrtoumax.c so that other programs
|
||||
can use it. Instead of adding a new lib/xstrtoumax.h I thought
|
||||
it cleaner to put all the xstroto* declarations into a single
|
||||
header, which for now is lib/xstrtol.h for lack of a better place.
|
||||
(Mayby lib/xstdlib.h would be better? :-)
|
||||
|
||||
I thought of several other problems with shredding regular files;
|
||||
shredding devices is much more reliable. So I changed the defaults
|
||||
to be more suitable for shredding devices; this should help encourage
|
||||
users to do the right thing.
|
||||
|
||||
pfstatus isn't portable to environments with varying width
|
||||
fonts, or with internationalized environments where the byte
|
||||
count of the message is not the same as its print width.
|
||||
Rather than deal with this, I just simplified it to not do
|
||||
tricks with carriage-returns and spaces. (I'm also worried
|
||||
that vprintf may not return the right value on some hosts; I
|
||||
vaguelly recall this being a problem.) As a result, -v and -
|
||||
no longer conflict.
|
||||
|
||||
When removing a special file, try to truncate it first, but don't
|
||||
worry if this reports an error.
|
||||
|
||||
Try to find the size of a non-regular file by seeking to its end.
|
||||
|
||||
Various porting fixes, mostly because of a port to SunOS 4.1.4 cc.
|
||||
|
||||
Some other minor bug fixes.
|
||||
|
||||
* lib/xstrtoul.h: Remove this file.
|
||||
* lib/xstrtoumax.c: New file.
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add strtoull, strtoumax, strtouq.
|
||||
|
||||
* lib/xstrtoul.c (STRING_TO_UNSIGNED): Remove.
|
||||
(__strtol, __strtol_t, __xstrtol): New macros.
|
||||
|
||||
* lib/xstrtol.c (__strtol, __strtol_t, __xstrtol):
|
||||
New macros to specify the
|
||||
underlying function, its returned type, and our function. Default to
|
||||
values suitable for xstrtol.
|
||||
|
||||
Include <ctype.h>, since we use its macros.
|
||||
|
||||
(ULONG_MAX, LONG_MAX, ISBLANK): Remove: no longer needed.
|
||||
(ISSPACE): New macro.
|
||||
|
||||
(bkm_scale, bkm_scale_by_power, __xstrtol, main): __unsigned long int
|
||||
-> __strtol_t.
|
||||
|
||||
(__xstrtol): Depend on whether __strtol_t is an unsigned type, not on
|
||||
whether STRING_TO_UNSIGNED is defined. Skip isspace chars, not
|
||||
isblank chars, to match strtol. When returning
|
||||
LONGINT_INVALID_SUFFIX_CHAR, store the value that we computed into
|
||||
*val.
|
||||
|
||||
* lib/xstrtol.h (__xstrtol, __strtol, __unsigned): Remove macro decls.
|
||||
<inttypes.h>: Include if HAVE_INTTYPES_H.
|
||||
(_DECLARE_XSTRTOL): New macro.
|
||||
(xstrtol, xstrtoul, xstrtoumax): Declare all three functions, so that
|
||||
we need only one include file, not three.
|
||||
(_STRTOL_ERROR): Do not undef, as this is no longer needed.
|
||||
Reword overflow message so that it's independent of type.
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add xstrtoumax.c.
|
||||
(noinst_HEADERS): Remove xstrtoul.h.
|
||||
|
||||
* lib/xmalloc.c (xalloc_fail):
|
||||
Pass xalloc_msg_memory_exhausted through gettext.
|
||||
|
||||
* lib/getdate.y:
|
||||
<stdlib.h>: Include if HAVE_STDLIB_H, since bison 1.27 invokes "free".
|
||||
(LookupWord, yylex): Don't pass negative char to ctype macros.
|
||||
|
||||
* doc/fileutils.texi:
|
||||
Explain why shredding devices is more reliable, and why the
|
||||
default options are more suitable for devices.
|
||||
|
||||
Remove withdrawn options -b or --no-contents, -c or --freed-contents,
|
||||
-C or --all-contents, -k or --no-links, -l or --ordinary-links, -L or
|
||||
--all-links.
|
||||
|
||||
Add -R or --remove, -s or --size.
|
||||
|
||||
-v can no longer be doubled.
|
||||
|
||||
`file system' --> `filesystem' uniformly.
|
||||
|
||||
* src/chgrp.c: Include xstrtol.h, not obsolete file xstrtoul.h.
|
||||
|
||||
* src/shred.c: Include xstrtol.h, not obsolete file xstrtoul.h.
|
||||
"human.h", "xalloc.h": Include.
|
||||
(attribute): Remove; no longer needed.
|
||||
(xstrdup): New decl.
|
||||
(STDOUT_FILENO): New macro.
|
||||
(O_NOCTTY): Make sure it's always defined, even if HAVE_CONFIG_H.
|
||||
|
||||
The following changes have effect only if !HAVE_CONFIG_H.
|
||||
<ctype.h>: New include.
|
||||
(RETSIGTYPE): Remove bogus semicolon at end.
|
||||
(STDOUT_FILENO, uintmax_t, human_readable, LONGEST_HUMAN_READABLE):
|
||||
New macros.
|
||||
(xstrtoumax): Renamed from xstrtoul, with corresponding type changes.
|
||||
Handle suffixes like the real routine does.
|
||||
(error): Remove bogus assignment of errno to errnum.
|
||||
(xmalloc, xstrdup): New functions.
|
||||
|
||||
(O_NOCTTY): Define even if !HAVE_CONFIG_H.
|
||||
(S_ISFIFO, S_ISSOCK): New macros, if not already defined.
|
||||
(OUTPUT_BLOCK_SIZE): New macro.
|
||||
(struct Options.verbose): Now a boolean, since we no longer have two
|
||||
levels of verbosity.
|
||||
(long_opts, usage, main): Remove -D or --device option. Invert -p or
|
||||
--preserve option, and rename it to -R or --remove.
|
||||
(usage): Describe G suffix.
|
||||
(usage): "-" no longer conflicts with -v.
|
||||
(UCHAR_MAX): Indent `#error' so that SunOS 4.1.4 cc doesn't reject it.
|
||||
(ind): Portability fixes: return word32, not unsigned; multiply by
|
||||
sizeof (word32) instead of shifting left by 2.
|
||||
(isaac_refill, isaac_mix): Comment out size of array parameter, as
|
||||
ansi2knr mishandles this.
|
||||
(status_visible, status_pos, pfstatus, flushstatus): Remove, since
|
||||
pfstatus isn't portable to users with varying width fonts, or
|
||||
internationalized messages, and vfprintf is problematic. All callers
|
||||
of pfstatus changed to use error instead; this removes incompatibility
|
||||
of -v with -. All calls to flushstatus removed.
|
||||
(dopass, do_wipefd): Do not translate non-English msgs with gettext.
|
||||
|
||||
(dopass): Cast lseek constant arguments to (off_t) for benefit
|
||||
of pre-ANSI compilers; fix one lseek call whose args were interchanged.
|
||||
Remove unnecessary casts to (off_t). Do not check for EIO
|
||||
when determining file size; this was just my earlier wild guess.
|
||||
Use human_readable to print off_t, instead of casting to unsigned long
|
||||
(which doesn't work in Solaris 2.6, where off_t is longer than long).
|
||||
Output human-readable sizes, instead of always using "K".
|
||||
Check for offset overflow (it happened to me in SunOS 4.1.4).
|
||||
(do_wipefd): Do not insist on regular files, but do check for special
|
||||
files that cannot possibly be shredded.
|
||||
Use xmalloc instead of malloc + check.
|
||||
Do not inspect st_size for non-regular files.
|
||||
Try to find the size of a non-regular file by seeking to its end.
|
||||
Do not assume that a regular file of size-0 has unknown size.
|
||||
Check for regular files with negative sizes,
|
||||
and for overflow after rounding to next block.
|
||||
Always try to truncate, even for special files, but do not report an
|
||||
error if truncation fails on a special file.
|
||||
|
||||
(dopass, wipefile): Do not return 1 for special files; the caller
|
||||
doesn't care any more.
|
||||
|
||||
(wipefd): Remove unnecessary (and nonportable) check for
|
||||
whether the file descriptor is read-only. Remove
|
||||
no-longer-needed check for `-v -'.
|
||||
|
||||
(incname): Return 1 for carry bit, like the documentation says.
|
||||
|
||||
(wipename, wipefile): Accept new argument, specifying the
|
||||
quoted file name. All callers changed.
|
||||
|
||||
(wipename): Use xstrdup instead of strdup+error check.
|
||||
|
||||
(wipefile): Check for ENOTDIR when opening /dev/fd/NNN. Check for
|
||||
errors in NNN more carefully. Restore errno after the check.
|
||||
Check for errors when closing the file descriptor.
|
||||
Use more consistent wording when unable to remove a file.
|
||||
|
||||
(main): Do not remove files by default.
|
||||
Use xstrtoumax instead of xstrtoul uniformly, since xstrtoul won't
|
||||
exist if !HAVE_CONFIG_H.
|
||||
In diagnostics, quote invalid operands to -n and -s options.
|
||||
Allow T, P, E, Z, and Y suffixes in -s operand.
|
||||
flags.verbose is now a boolean, not a counter.
|
||||
Use STDOUT_FILENO instead of 1, for clarity.
|
||||
|
||||
* lib/human.c:
|
||||
Include xstrtol.h, not xstrtoul.h, since xstrtol.h now defines all the
|
||||
xstrto... functions.
|
||||
|
||||
* src/dd.c: Include xstrtol.h.
|
||||
(parse_integer): Migrate most of the work into the new xstrtoumax fn.
|
||||
|
||||
* lib/xstrtoumax.c: New file.
|
||||
|
||||
1999-04-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dd.c (main): Open the output file with *read* access
|
||||
only if we might need to read to satisfy a `seek=' request.
|
||||
From Matthias Urlichs.
|
||||
|
||||
1999-04-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Makefile.maint (alpha): Add trailing slash for ncftp.
|
||||
|
||||
* Version 4.0f.
|
||||
|
||||
* configure.in (AC_OUTPUT): Add tests/dd/Makefile.
|
||||
* tests/Makefile.am (SUBDIRS): Add dd.
|
||||
* tests/dd: New directory
|
||||
* tests/dd/misc: New file.
|
||||
|
||||
`ls --color' would segfault
|
||||
* src/ls.c: Include assert.h.
|
||||
(color_indicator[]): Add an entry for the type, `door.'
|
||||
(main): Assert that the lengths of the color_indicator and
|
||||
indicator_name arrays are appropriately related.
|
||||
Reported by John Gotts.
|
||||
|
||||
* src/dd.c (scanargs): Fix bug introduced with last change: now that
|
||||
the loop is gone, manually decrement argc and increment argv.
|
||||
Reported by Andreas Jaeger and jvogel@linkny.com.
|
||||
|
||||
1999-04-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/getdate.y (difftm): Protoize.
|
||||
|
||||
1999-04-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/strftime.c: Update from master source in libc.
|
||||
|
||||
1999-04-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/ln/misc: Comment out the test added on 1999-01-31.
|
||||
|
||||
* Makefile.maint (url_dir_list): Define properly.
|
||||
(real_dir_list): Likewise.
|
||||
|
||||
* src/shred.c: Don't include string.h.
|
||||
[!HAVE_CONFIG_H]: Include string.h here.
|
||||
[!HAVE_CONFIG_H]: Hard-code RETSIGTYPE to `int'.
|
||||
(sigill_handler): Change return type and type of local `oldhandler' to
|
||||
RETSIGTYPE.
|
||||
(isaac_seed_machdep): Change and type of local `oldhandler' to
|
||||
RETSIGTYPE.
|
||||
From Colin Plumb.
|
||||
|
||||
* Version 4.0e
|
||||
|
||||
* tests/cp/same-file: Change the sed command used to extract the
|
||||
filename from ls -l output, to accommodate the change in format.
|
||||
|
||||
* src/ls.c (print_long_format): Add a space between %s and %3u. This
|
||||
assures that even when modebuf has the trailing `+' and there are more
|
||||
than 99 hard links to a file, the permissions string and the link count
|
||||
will be separated.
|
||||
|
||||
1999-04-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c (dopass): add curly braces to avoid warning about
|
||||
ambiguous `else'.
|
||||
(wipefd): Add parentheses suggested by gcc.
|
||||
(do_wipefd): Remove declaration of unused local.
|
||||
|
||||
1999-04-02 Colin Plumb <colin@nyx.net>
|
||||
|
||||
* shred.c [!HAVE_CONFIG_H] (xstrtoul, error, close_stdout): Added stubs
|
||||
to allow standalone compilation.
|
||||
|
||||
(wipefile): Added support for emulating /dev/fd/# files even if
|
||||
the OS doesn't support them. From Paul Eggert.
|
||||
|
||||
(main, usage): Changed --device short option to -D.
|
||||
|
||||
(wipefd, do_wipefd): Renamed function to do_wipefd and added
|
||||
separate wipefd that performs sanity checks on externally-opened file
|
||||
descriptors, such as not append-only. From Paul Eggert.
|
||||
|
||||
(do_wipefd, isaac_seedfd): Do not read file for any reason.
|
||||
if the file is low-entropy, it's a security hole.
|
||||
(wipefile) Changed to open O_WRONLY and chmod to write-only when
|
||||
forcing.
|
||||
(isaac_seedfd) Function deleted as unnecessary.
|
||||
From Paul Eggert.
|
||||
|
||||
(dopass): Dynamically fall back to fsync() if fdatasync() fails,
|
||||
since POSIX, in their infinitesimal wisdom, encourage implementations
|
||||
that return constant -1, making compile-time testing useless.
|
||||
From Paul Eggert.
|
||||
|
||||
(dopass): Changed to support a size of -1 to mean "unknown".
|
||||
This entailed changing to a counting-up offset rather than couting-down
|
||||
cursize for the central state variable. Also changed size argument to
|
||||
be call-by-reference so that it can be passed back once known.
|
||||
(sizer) Function deleted as unnecessary.
|
||||
(wipefd): Changed to match. From Paul Eggert
|
||||
|
||||
(dopass): Try to skip over bad blocks in destination files.
|
||||
Also added ftruncate() for more complete destruction of metadata.
|
||||
|
||||
(main, usage): Changed "-" to stand for standard output.
|
||||
(wipefd): Added error message to detect conflict with -v.
|
||||
|
||||
(dopass): Added periodic fsync() calls to keep the pass progress
|
||||
display in sync with reality. Hopefully they're sufficiently far spaced
|
||||
that throughput isn't affected. It might be a good thing to do even in
|
||||
non-verbose mode, to avoid filling up the kernel caches with dirty data.
|
||||
Also added ftruncate() for more complete destruction of metadata.
|
||||
|
||||
(quotearg_colon): New function to print
|
||||
pathological filenames properly.
|
||||
[!HAVE_CONFIG_H] (quotearg_colon_buf) New internal helper function
|
||||
that does most of the work.
|
||||
(wipefd, do_wipefd, dopass) Now take a qname (pre-quoted name) argument.
|
||||
(wipename, wipefile, main) Changed diagnostics to use quotearg_colon.
|
||||
Error messages are also in a more uniform format.
|
||||
From Paul Eggert.
|
||||
|
||||
(struct Options, main, do_wipefd): Added -s/--size=N flag.
|
||||
(xstrtoul): Added support for valid_suffixes to help this.
|
||||
(usage) Documented it.
|
||||
|
||||
(error): Changed some arguments from N_() to _(), since error()
|
||||
does not translate its argument. I think this is a bug.
|
||||
|
||||
(struct Options do_wipefd, wipefd, wipefile, main): moved passes
|
||||
argument into the Options structure as n_iterations, which is now a
|
||||
size_t. From Paul Eggert.
|
||||
|
||||
(isaac_seed_start, isaac_seed_data, isaac_seed_finish): New functions
|
||||
to manage seeding of RNG with arbitrary-sized data.
|
||||
(isaac_init): commented out as dead code.
|
||||
(isaac_seed): changed to use new functions to prevent any possibility of
|
||||
a buffer overflow.
|
||||
|
||||
(isaac_seed): Added support for Solaris' gethrtime()
|
||||
configure.in: Corresponding feature test. From Paul Eggert.
|
||||
|
||||
(wipename): Change remove() to unlink() for speed & portability.
|
||||
Use lstat() instead of access() to see if a filename is taken. This
|
||||
works even on dangling symlinks and avoids the suid problems of
|
||||
access(2). From Paul Eggert.
|
||||
|
||||
(isaac_seed_machdep): New function for reading cycle counters
|
||||
|
||||
1999-04-02 Paul Eggert <eggert@shade.twinsun.com>
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add gethrtime.
|
||||
|
||||
* src/shred.c (isaac_seed): Don't overrun the s->mm buffer.
|
||||
Use gethrtime if available. Don't assume that clock_gettime succeeds.
|
||||
Put most random sources first.
|
||||
|
||||
1999-04-02 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
shred: Add new options -bcCklL and fix some porting problems.
|
||||
Remove options -dp. Do not read output files.
|
||||
|
||||
* src/shred.c (long_opts, usage, main, wipefile): Adjust to
|
||||
new options.
|
||||
("human.h", "quotearg.h"): New includes.
|
||||
(struct Options): New members contents, links, n_iterations.
|
||||
Remove allow_devices, remove_file. Change n_iterations to size_t.
|
||||
All uses changed.
|
||||
(output_block_size): New var.
|
||||
(usage): Declare __noreturn__ attribute.
|
||||
(fdatasync): Define to -1 if not present, since we need to invoke both
|
||||
fdatasync and fsync if both are present. All invokers of fdatasync
|
||||
now try fdatasync, then fsync.
|
||||
(MIXIN): New macro.
|
||||
(isaac_seed): Use it to mix in values. Add uid, gid to mix.
|
||||
Don't use gettimeofday, as it has too many porting problems.
|
||||
(isaac_seedfd): Remove, since we no longer read the output files.
|
||||
(sizefd): Remove; we now determine size by writing sequentially.
|
||||
(dopass, wipename, wipefile, main): Clean up error messages.
|
||||
(dopass): Keep track of offset relative to start of file, not
|
||||
end, since we may not know how large the file is. If size is
|
||||
negative, write until we fall off the end of the file.
|
||||
(wipefd): Do not read output file.
|
||||
Return 0 if successful, -1 if not; do not make a special case for
|
||||
non-regular files, since our callers have that info now.
|
||||
(wipename): Now static. Return errno if error.
|
||||
(main): "-" now stands for standard output.
|
||||
Do not shred append-only standard output.
|
||||
(wipefile): Do not grant read permission to file when wiping it.
|
||||
Use symbolic permission (S_IWUSR), not octal.
|
||||
|
||||
* src/system.h (S_IWUSR): Define if not already defined.
|
||||
|
||||
* configure.in (AC_SEARCH_LIBS): Prefer rt to posix4, for Solaris 7.
|
||||
(AC_CHECK_FUNCS): Remove gettimeofday.
|
||||
|
||||
* doc/fileutils.texi: Document recent changes.
|
||||
|
||||
1999-04-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add acl.
|
||||
(AC_CHECK_HEADERS): Add sys/acl.h.
|
||||
* src/ls.c [HAVE_SYS_ACL_H]: Include sys/acl.h.
|
||||
(struct fileinfo): New member `have_acl'.
|
||||
(gobble_file): Initialize it.
|
||||
(print_long_format): Use it.
|
||||
Mostly from Alen Muzinic.
|
||||
|
||||
* src/touch.c (open_maybe_create): New function.
|
||||
(touch): Rewrite not to use `creat' and to eliminate a race
|
||||
condition that could make touch truncate a nonempty file.
|
||||
Report and suggestions from Andrew Tridgell.
|
||||
|
||||
1999-03-31 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/du.c: Remove prototypes and tsort function definitions.
|
||||
|
||||
* src/chown.c (main): Move the declaration of `e' into the scope
|
||||
where it's used and make it `const'.
|
||||
|
||||
* src/install.c (main): Qualify a char* with the `const' keyword.
|
||||
(install_file_in_dir): Likewise.
|
||||
* src/ln.c (main): Likewise.
|
||||
* src/mkdir.c (main): Likewise.
|
||||
* src/mkfifo.c (main): Likewise.
|
||||
* src/mknod.c (main): Likewise.
|
||||
* src/mv.c (main): Likewise.
|
||||
* src/touch.c (touch): Likewise.
|
||||
|
||||
1999-03-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/*.c: Don't include closeout.h or version-etc.h explicitly.
|
||||
Now, they're included via sys2.h.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Minor lint removal in code that forks and execs.
|
||||
|
||||
* lib/mkdir.c (mkdir): Use pid_t instead of int; check status
|
||||
against zero. This is to improve portability.
|
||||
* lib/rename.c (rename): Likewise.
|
||||
* lib/rmdir.c (rmdir): Likewise.
|
||||
|
||||
* lib/rename.c (rename):
|
||||
(rename): Do not print any error messages, so that the messages
|
||||
are internationalized properly.
|
||||
|
||||
* src/install.c (strip): Use standard "cannot fork" message.
|
||||
Check for strip nonzero exit status.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
`chmod =OP' did not properly apply the umask
|
||||
* lib/modechange.c (make_node_op_equals): New function.
|
||||
(mode_append_entry): Likewise.
|
||||
(mode_compile): When none of [ugoa] is specified in an `=OP' change
|
||||
mode request, insert a `=0' entry into the linked list so that all
|
||||
bits are cleared first. Use the new functions.
|
||||
Reported by Andrew Dalke.
|
||||
|
||||
New test for the above.
|
||||
* configure.in (AC_OUTPUT): Add tests/chmod/Makefile.
|
||||
* tests/Makefile.am (SUBDIRS): Add chmod.
|
||||
* tests/chmod: New directory
|
||||
* tests/chmod/equal-x: New file.
|
||||
|
||||
1999-03-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/modechange.c (mode_compile): Upon allocation failure, free
|
||||
everything starting with the head, not the tail.
|
||||
|
||||
* src/install.c (strip): Use pid_t, not int. From John Bley.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dd.c (PROGRAM_NAME, AUTHORS): Define
|
||||
(long_options): Remove unused struct.
|
||||
(scanargs): Remove useless loop.
|
||||
(main): Use PROGRAM_NAME and AUTHORS in call to parse_long_options.
|
||||
* src/mvdir.c: Likewise.
|
||||
* src/sync.c (PROGRAM_NAME, AUTHORS): Define and use.
|
||||
|
||||
1999-03-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
* lib/long-options.c (parse_long_options): Remove version-, copyright-,
|
||||
and author-printing code. Do it via version_etc.
|
||||
|
||||
* lib/version-etc.c: New file.
|
||||
* lib/version-etc.h: Prototype for same.
|
||||
|
||||
* src/sys2.h (GETOPT_HELP_CHAR): Define.
|
||||
(GETOPT_VERSION_CHAR): Define.
|
||||
(GETOPT_HELP_OPTION_DECL): Define.
|
||||
(GETOPT_VERSION_OPTION_DECL): Define.
|
||||
(case_GETOPT_HELP_CHAR): Define.
|
||||
(case_GETOPT_VERSION_CHAR): Define.
|
||||
|
||||
* src/chgrp.c: No longer include long-options.h.
|
||||
Include version-etc.h instead.
|
||||
(PROGRAM_NAME, AUTHORS): Define.
|
||||
[long_options]: Add entries for --help and --version.
|
||||
Remove parse_long_options call.
|
||||
(main) [getopt switch]: Add a case for each of --help and --version.
|
||||
* src/chgrp.c: Likewise.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/cp.c: Likewise.
|
||||
* src/df.c: Likewise.
|
||||
* src/dircolors.c: Likewise.
|
||||
* src/du.c: Likewise.
|
||||
* src/install.c: Likewise.
|
||||
* src/ln.c: Likewise.
|
||||
* src/ls.c: Likewise.
|
||||
* src/mkdir.c: Likewise.
|
||||
* src/mkfifo.c: Likewise.
|
||||
* src/mknod.c: Likewise.
|
||||
* src/mv.c: Likewise.
|
||||
* src/rm.c: Likewise.
|
||||
* src/rmdir.c: Likewise.
|
||||
* src/shred.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
1999-03-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* man/help2man: Import version 1.010.
|
||||
|
||||
1999-03-22 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/chmod.c (usage): Add one-liner. Suggestion from Karl Berry.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/automake-wrap: Rewrite the automake-generated rule for
|
||||
clean-binPROGRAMS so that it removes rm even with a losing PATH on a
|
||||
losing system (PATH with `.' before /bin on a system where you can't
|
||||
unlink a running executable). Reported by William Bader.
|
||||
|
||||
* configure.in: Use jm_WINSIZE_IN_PTEM.
|
||||
* src/ls.c [WINSIZE_IN_PTEM]: Include sys/stream.h and sys/ptem.h.
|
||||
Required by SCO ODT 2.0 systems. Reported by William Bader.
|
||||
|
||||
1999-03-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/remove.c (remove_cwd_entries): Reflect changes in hash_insert.
|
||||
(remove_init): Call hash_initialize with one more argument.
|
||||
|
||||
1999-03-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Revamp to allow fine-tuning to control when and by how
|
||||
much the table grows and shrinks.
|
||||
* lib/hash.c (next_prime): Don't assert.
|
||||
(hash_reset_tuning): New function.
|
||||
(check_tuning): New function.
|
||||
(hash_initialize): Accept and use new tuning parameter.
|
||||
(hash_rehash): Rewrite, updating for tuning.
|
||||
(hash_insert): Honor tuning semantics.
|
||||
(hash_delete): Likewise.
|
||||
From François Pinard.
|
||||
|
||||
* lib/hash.h (struct hash_tuning): Define.
|
||||
(struct hash_table) [tuning]: Add member.
|
||||
(hash_initialize): Add `tuning' parameter.
|
||||
|
||||
* lib/hash.c (hash_insert): Remove last parameter and change semantics.
|
||||
* lib/hash.h (hash_insert): Update prototype.
|
||||
|
||||
* lib/hash.c (hash_insert): Don't increment n_entries unconditionally --
|
||||
otherwise, we'd do so even when the insertion failed.
|
||||
From François Pinard.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/xmalloc.c (xalloc_fail): Use "%s" format so the message doesn't
|
||||
have to be scanned for % signs. Suggestion from François Pinard.
|
||||
|
||||
* Makefile.maint: Add two more URLs and the loops to use them.
|
||||
|
||||
* lib/long-options.c (parse_long_options): Include `Copyright...' line
|
||||
in --version output.
|
||||
Add the `...NO warranty...' message.
|
||||
|
||||
1999-03-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/long-options.c (_): Define it.
|
||||
(parse_long_options): Accept new parameter, authors, and print it.
|
||||
|
||||
* lib/long-options.h: Update prototype.
|
||||
|
||||
* src/chgrp.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/chown.c: Likewise.
|
||||
* src/cp.c: Likewise.
|
||||
* src/dd.c: Likewise.
|
||||
* src/df.c: Likewise.
|
||||
* src/dircolors.c: Likewise.
|
||||
* src/du.c: Likewise.
|
||||
* src/install.c: Likewise.
|
||||
* src/ln.c: Likewise.
|
||||
* src/ls.c: Likewise.
|
||||
* src/mkdir.c: Likewise.
|
||||
* src/mkfifo.c: Likewise.
|
||||
* src/mknod.c: Likewise.
|
||||
* src/mv.c: Likewise.
|
||||
* src/mvdir.c: Likewise.
|
||||
* src/rm.c: Likewise.
|
||||
* src/rmdir.c: Likewise.
|
||||
* src/shred.c: Likewise.
|
||||
* src/sync.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
1999-02-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* getdate.y: <alloca.h>: Include if HAVE_ALLOCA_H, not FORCE_ALLOCA_H.
|
||||
The FORCE_ALLOCA_H was a relic of the bad old pre-autoconf Emacs days.
|
||||
|
||||
1999-02-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c (wipename): Fix string thinko. Now, shredding files
|
||||
in subdirectories works (dir/file). From Janos Farkas.
|
||||
|
||||
1999-02-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dircolors.c (dc_parse_stream): Don't try to dereference
|
||||
NULL if there's an error in our built-in list.
|
||||
Suggestion from François Pinard.
|
||||
|
||||
1999-02-13 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
||||
|
||||
* src/install.c (main): Set x.backup_type only if backups are requested.
|
||||
(cp_option_init): Initialize backup_type.
|
||||
(backup_type): Remove unused variable.
|
||||
|
||||
* doc/fileutils.texi: Fix use of @item vs @itemx.
|
||||
|
||||
1999-02-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dircolors.c (slack_codes): Add "DOOR".
|
||||
(ls_codes): Add corresponding "do".
|
||||
Reported by John Gotts.
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Italian (it).
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0d (aka 4.1-b4).
|
||||
|
||||
@@ -1,4 +1,32 @@
|
||||
Changes in release 4.1:
|
||||
[4.0h]
|
||||
* cp --one-file-system (-x) no longer crosses filesystem boundaries.
|
||||
* touch can once again operate on directories
|
||||
[4.0g]
|
||||
* New large-file support for AIX and HP-UX, and for cross-compiles.
|
||||
* shred's default options are now suitable for devices, not files, since
|
||||
shred is more reliable on devices. shred now does not remove by default;
|
||||
the old -p or --preserve option was inverted and renamed to -u or --remove.
|
||||
* shred -u now attempts to truncate devices before removing them.
|
||||
* shred -v no longer outputs carriage-returns; shred -vv has no extra effect;
|
||||
shred -v now outputs to stderr.
|
||||
* shred now tries to find the size of a non-regular file by seeking to its end.
|
||||
* dd now opens the output file for *read* access only if `seek=' is used.
|
||||
[4.0f]
|
||||
* `ls --color' no longer segfaults
|
||||
* dd works once again
|
||||
[4.0e]
|
||||
* shred --devices option renamed to -D so that -d, -i and -r can be
|
||||
compatible with rm.
|
||||
* shred -s/--size=N option added to specify the size of the object to be
|
||||
shredded.
|
||||
* `shred -' now shreds stdout rather than stdin. This is incompatible with -v.
|
||||
* shred now does not need to read from its output file, so opens it O_WRONLY
|
||||
* `ls -l' uses `+' to designate each file that has a custom ACL
|
||||
* eliminate race condition that could make touch truncate a nonempty file
|
||||
* No longer use *_unlocked I/O macros on systems (like solaris5.5.1) where
|
||||
they're not declared, so selected executables (e.g., rm) that are linked
|
||||
with shared libraries will once again run on solaris5.6 systems.
|
||||
[4.0d (aka 4.1-b3)]
|
||||
* ls recognizes solaris 2 `doors'
|
||||
* new program: shred
|
||||
|
||||
@@ -1,5 +1,303 @@
|
||||
1999-05-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.16i.
|
||||
|
||||
* configure.in: Clean up checks for libraries so that we don't add
|
||||
-lshadow unless necessary. Reported by Joseph S. Myers.
|
||||
|
||||
1999-05-05 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Add definitions to help read utmpx on systems with utmpname.
|
||||
* lib/readutmp.h (UTMP_NAME_FUNCTION): Define.
|
||||
(SET_UTMP_ENT): Likewise.
|
||||
(GET_UTMP_ENT): Likewise.
|
||||
(END_UTMP_ENT): Likewise.
|
||||
* lib/readutmp.c (read_utmp): Use the new definitions.
|
||||
From Kaveh Ghazi.
|
||||
|
||||
* src/date.c (show_date): Change an automatic aggregate initializer
|
||||
to be a static one. For SunOS4's cc. From Kaveh Ghazi.
|
||||
|
||||
1999-05-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in: Remove duplicate use of jm_FUNC_GNU_STRFTIME.
|
||||
Kaveh Ghazi reported that strftime.o was listed twice in the command
|
||||
to build libsu.a.
|
||||
|
||||
1999-05-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.16h.
|
||||
|
||||
* src/hostname.c (main): Give a better diagnostic when we fail to
|
||||
set the hostname.
|
||||
|
||||
* man/Makefile.summ (hostid-summary): Use correct description.
|
||||
Reported by Joseph S. Myers.
|
||||
|
||||
* lib/readutmp.c (read_utmp): Ignore the return value from utmpname.
|
||||
|
||||
1999-04-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dirname.c (main): Manually handle `--', since we no longer
|
||||
call getopt. Reported by Joseph S. Myers.
|
||||
* src/basename.c (main): Likewise.
|
||||
* src/factor.c (main): Likewise.
|
||||
|
||||
1999-04-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/seq.c (main): Handle the case in which seq is given no args.
|
||||
Reported by John Gotts.
|
||||
(main): Revert last change.
|
||||
Instead, loop on `optind < argc' to protect use of argv[optind].
|
||||
|
||||
* lib/human.c <inttypes.h>: Don't include it here.
|
||||
* lib/human.h <inttypes.h>: Include it here instead.
|
||||
<config.h>: Include it here too.
|
||||
Reported by Andreas Jaeger.
|
||||
|
||||
* src/nice.c [NDEBUG]: Remove definition.
|
||||
Reported by Andreas Jaeger.
|
||||
|
||||
1999-04-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/who.c (print_entry): Use `#if', not `#ifdef HAVE_UT_HOST'.
|
||||
|
||||
* Version 1.16g.
|
||||
|
||||
* configure.in: Use AC_CANONICAL_HOST.
|
||||
|
||||
1999-04-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Update factor to use `uintmax_t'.
|
||||
* src/factor.c <xstrtol.h>: Include this, not xstrtoul.h.
|
||||
<human.h>: Include.
|
||||
Use uintmax_t in place of unsigned long.
|
||||
Use human_readable to convert to strings for printing.
|
||||
* lib/xstrtoumax.c: New file.
|
||||
* lib/human.c: New file.
|
||||
* lib/human.h: New file.
|
||||
* lib/Makefile.am (libsu_a_SOURCES): Add human.c and xstrtoumax.c.
|
||||
(noinst_HEADERS): Add human.h. Remove xstrtoul.h.
|
||||
|
||||
1999-04-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/seq.c (main): Restore `+' in getopt_long string. Otherwise,
|
||||
commands like `seq 10 -2 0' wouldn't work. From Andreas Schwab.
|
||||
* tests/seq/basic: Add tests for that.
|
||||
|
||||
1999-04-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/seq: New directory and basic tests.
|
||||
* tests/Makefile.am (SUBDIRS): Add seq.
|
||||
* configure.in (AC_OUTPUT): Add tests/seq/Makefile.
|
||||
|
||||
1999-04-17 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
||||
|
||||
* configure.in: Check for localeconv.
|
||||
|
||||
* src/seq.c (decimal_point): New variable.
|
||||
(main): Set it to locale's decimal point. Fix recognition of
|
||||
negative number as argument.
|
||||
(get_width_format): Correctly handle a negative min_val or step
|
||||
when computing fraction width. Use decimal_point.
|
||||
|
||||
1999-04-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
1999-03-25 James R. Van Zandt <jrv@vanzandt.mv.com>
|
||||
* doc/sh-utils.texi (Options for date): Document --iso-8601
|
||||
* src/date.c: Accept new option: --iso-8601.
|
||||
* lib/Makefile.am (libsu_a_SOURCES): Add argmatch.c and quotearg.c.
|
||||
(noinst_HEADERS): Add argmatch.h and quotearg.h.
|
||||
* lib/argmatch.c: New file.
|
||||
* lib/argmatch.h: New file.
|
||||
* lib/quotearg.c: New file.
|
||||
* lib/quotearg.h: New file.
|
||||
|
||||
1999-03-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h: Include "closeout.h" and "version-etc.h"
|
||||
|
||||
* src/*.c (PROGRAM_NAME, AUTHORS): Define and use.
|
||||
|
||||
* src/date.c: No longer include long-options.h.
|
||||
[long_options]: Add entries for --help and --version.
|
||||
Remove parse_long_options call.
|
||||
(main) [getopt switch]: Add a case for each of --help and --version.
|
||||
* src/env.c: Likewise.
|
||||
* src/id.c: Likewise.
|
||||
* src/pinky.c: Likewise.
|
||||
* src/seq.c: Likewise.
|
||||
* src/su.c: Likewise.
|
||||
* src/sys2.h: Likewise.
|
||||
* src/tee.c: Likewise.
|
||||
* src/tty.c: Likewise.
|
||||
* src/uname.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/test.c (PROGRAM_NAME): Rename from COMMAND_NAME.
|
||||
|
||||
1999-03-28 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/getdate.y (get_date): Reuse tm_isdst of first localtime
|
||||
call; this is an improvement on a bug fix suggested by
|
||||
martin@dresden.nacamar.de. Do not assume that localtime and
|
||||
gmtime return non-null.
|
||||
|
||||
1999-03-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/false.sh (usage): Change `[OPTION]...' to `[OPTION]' to show
|
||||
that only one of --help or --version is recognized at a time.
|
||||
Reported by Meelis Roos.
|
||||
* src/true.sh: Likewise.
|
||||
|
||||
* src/id.c (print_user): Use uid_t instead of int.
|
||||
(print_group): Use gid_t instead of int.
|
||||
From John Bley.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/nohup.sh: Don't modify PATH just to get GNU nice. Instead,
|
||||
try to find an absolute path for GNU nice. From Bruno Haible.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in: Use new macro, jm_WINSIZE_IN_PTEM, instead of
|
||||
open-coding it.
|
||||
|
||||
1999-03-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Italian (it) and Slovak (sk).
|
||||
|
||||
1999-03-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/basename.c (base_name): If NAME is all slashes, return `/' (in
|
||||
conformance with the single unix spec). Reported by Peter Moulder.
|
||||
|
||||
1999-03-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/uptime.c: Declare getloadavg so I can build with -Werror.
|
||||
|
||||
* tests/stty/basic-1: Skip failing tests: parenb, -parenb, -cread.
|
||||
|
||||
* lib/canon-host.c (canon_host): Don't use he->h_addr directly.
|
||||
Based on a patch from Savochkin Andrey Vladimirovich.
|
||||
|
||||
1999-03-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Running `id USER' doesn't report any groups if there is no entry
|
||||
for USER in /etc/group. Always include the one from /etc/passwd.
|
||||
* src/id.c: (xgetgroups): Take new parameter, gid, and pass
|
||||
it to getugroups.
|
||||
(print_group_list): Call getpwuid and adjust calls to xgetgroups
|
||||
to include new parameter.
|
||||
* lib/getugroups.c (getugroups): Take new parameter, gid.
|
||||
Add gid to the list of groups.
|
||||
From Ulrich Drepper.
|
||||
* lib/getgroups.c (getgroups): Protoize.
|
||||
|
||||
1999-03-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/basename: New directory and tests.
|
||||
* tests/Makefile.am (SUBDIRS): Add basename.
|
||||
* configure.in (AC_OUTPUT): Add tests/basename/Makefile.
|
||||
|
||||
1999-03-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/date.c (batch_convert): Use a `%s' format in error call,
|
||||
in case the argument string contains a `%'.
|
||||
|
||||
* man/Makefile.am (man_MANS): Add pinky.1.
|
||||
* man/Makefile.summ (pinky-summary): Define.
|
||||
|
||||
* src/date.c: Include long-options.h.
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/env.c: Likewise.
|
||||
* src/id.c: Likewise.
|
||||
* src/logname.c: Likewise.
|
||||
* src/pathchk.c: Likewise.
|
||||
* src/pinky.c: Likewise.
|
||||
* src/printenv.c: Likewise.
|
||||
* src/seq.c: Likewise.
|
||||
* src/sleep.c: Likewise.
|
||||
* src/su.c: Likewise.
|
||||
* src/tee.c: Likewise.
|
||||
* src/tty.c: Likewise.
|
||||
* src/uname.c: Likewise.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
* src/whoami.c: Likewise.
|
||||
|
||||
1999-03-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/basename.c (main): Include author name argument in call to
|
||||
parse_long_options.
|
||||
* src/chroot.c: Likewise.
|
||||
* src/dirname.c: Likewise.
|
||||
* src/echo.c: Likewise.
|
||||
* src/expr.c: Likewise.
|
||||
* src/factor.c: Likewise.
|
||||
* src/hostid.c: Likewise.
|
||||
* src/hostname.c: Likewise.
|
||||
* src/nice.c: Likewise.
|
||||
* src/printf.c: Likewise.
|
||||
* src/pwd.c: Likewise.
|
||||
* src/stty.c: Likewise.
|
||||
* src/test.c: Likewise.
|
||||
* src/yes.c: Likewise.
|
||||
|
||||
1999-03-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/readutmp.c (read_utmp) [HAVE_UTMPNAME]: Rewrite.
|
||||
|
||||
1999-02-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/stty.c (main): #ifdef-out unreachable code.
|
||||
|
||||
* src/pinky.c (usage): Add a one-line description.
|
||||
Suggestion from Karl Berry.
|
||||
|
||||
1999-02-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Czech (cs).
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/stty/basic-1: Run all tests even if some fail.
|
||||
Don't use trap.
|
||||
|
||||
* tests/stty/basic-1: Use `stty', not $STTY.
|
||||
Fix typo in VERBOSE code: s/\$RM/stty/.
|
||||
* tests/stty/row-col-1: Likewise.
|
||||
|
||||
* tests/stty/Makefile.am (TESTS_ENVIRONMENT): Set PATH, not STTY.
|
||||
|
||||
Include stdio.h before defining `_unlocked' macros.
|
||||
* src/pinky.c: Include stdio.h.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
* lib/readutmp.c: Include stdio.h here...
|
||||
* lib/readutmp.h: ...not here.
|
||||
From Ulrich Drepper.
|
||||
|
||||
* Version 1.16f.
|
||||
|
||||
* Makefile.maint (my-distcheck): Don't depend on dist, now that this
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
Changes in release 1.17
|
||||
[1.16i]
|
||||
* portability tweaks for lib/readutmp.[ch] and src/date.c
|
||||
[1.16h]
|
||||
* seq with no arguments now elicits a useful diagnostic rather than a segfault
|
||||
* portability tweaks to work around utmpname differences
|
||||
* who works on Solaris
|
||||
[1.16g]
|
||||
* factor now uses uintmax_t, so the largest number it can factor is now 2^64 - 1
|
||||
on systems with type `long long'.
|
||||
* nohup no longer modifies the shell's search path
|
||||
* `basename /' now prints `/', per the single unix spec
|
||||
* `who --lookup' no longer erroneously reports `localhost' for IP addresses
|
||||
for which it could not do a reverse lookup.
|
||||
* `id user' wouldn't report a group id in some situations. Now it always does.
|
||||
[1.16f]
|
||||
* chroot now calls chdir ("/") after chroot.
|
||||
* `date -s' now exits with nonzero status upon failure
|
||||
|
||||
@@ -1,3 +1,339 @@
|
||||
1999-05-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22k.
|
||||
|
||||
* Makefile.maint (alpha): Put the announcement in
|
||||
/tmp/announce-$(distdir)
|
||||
|
||||
* tests/sort/Test.pm (neg-nls): New test.
|
||||
|
||||
1999-05-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
|
||||
and all the *_MIN and *_MAX symbols): Remove definitions.
|
||||
* src/sys2.h: Put the definitions here instead (this file is shared
|
||||
between all three *utils packages, while system.h is not).
|
||||
|
||||
1999-05-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sort.c (fraccompare, numcompare): Merge the NLS and
|
||||
non-NLS versions into a single function.
|
||||
|
||||
(decimal_point): Now char, since we no longer convert to unsigned
|
||||
char.
|
||||
(th_sep): Now int, since we use a value out of char range to denote
|
||||
the absence of a thousands separator.
|
||||
(IS_THOUSANDS_SEP): New macro.
|
||||
(USE_NEW_FRAC_COMPARE): Remove.
|
||||
(nls_set_fraction): Arg is now char, not unsigned char.
|
||||
Set th_sep to CHAR_MAX + 1 if there is no thousands separator.
|
||||
(numcompare): Don't convert to unsigned char unless necessary.
|
||||
(main): Turn off decimal points and thousand separators if they
|
||||
are multibyte characters, as we don't support that yet.
|
||||
|
||||
1999-05-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/system.h (CHAR_MIN, CHAR_MAX): New macros.
|
||||
(SCHAR_MIN, SCHAR_MAX): Don't assume that char is signed.
|
||||
|
||||
1999-05-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sort.c (numcompare): Handle comparison of two negative
|
||||
numbers correctly in the ENABLE_NLS case.
|
||||
|
||||
1999-05-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/pr.c (usage): Break the usage message into 3 pieces instead of
|
||||
only 2. The strings had grown to be longer than 2048, which evokes
|
||||
errors when compiling with Irix4's cc. Reported by Kaveh Ghazi.
|
||||
|
||||
* src/tsort.c (search_item): Use `1' instead of `+1'. The latter
|
||||
elicits a syntax error from SunOS4's cc. From Kaveh Ghazi.
|
||||
|
||||
1999-05-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/ptx.c <ctype.h>: Don't include.
|
||||
[!STDC_HEADERS]: Remove definitions of ctype macros.
|
||||
Convert e.g., isspace to ISSPACE to use definitions from sys2.h.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* src/sys2.h (TOLOWER): Define.
|
||||
(TOUPPER): Define.
|
||||
* src/join.c (TOLOWER): Remove definition.
|
||||
* src/md5sum.c: (TOLOWER): Remove definition.
|
||||
|
||||
1999-04-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sort.c (usage): Document the differences between the
|
||||
obsolescent, +POS1[-POS2] form, and the POSIX -k option.
|
||||
|
||||
1999-04-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in: Use AC_CANONICAL_HOST.
|
||||
|
||||
* lib/Makefile.am (libtu_a_SOURCES): Add xstrtoumax.c
|
||||
(noinst_HEADERS): Remove xstrtoul.h.
|
||||
|
||||
* src/csplit.c: Include new "xstrtol.h", not "xstrtoul.h".
|
||||
(struct control) [repeat]: Declare as uintmax_t, not int.
|
||||
(struct control) [lines_required]: Likewise.
|
||||
(handle_line_error): Use human_readable to print lines_required.
|
||||
(parse_repeat_count): Parse a uintmax_t.
|
||||
(parse_patterns): Parse a uintmax_t.
|
||||
|
||||
* src/tail.c: Include new "xstrtol.h", not "xstrtoul.h".
|
||||
* src/od.c: Likewise.
|
||||
|
||||
* src/head.c: Include new "xstrtol.h", not "xstrtoul.h".
|
||||
Change all U_LONG_LONG to uintmax_t.
|
||||
(head_lines): Move a couple dcls into an inner scope.
|
||||
(string_to_integer): Rename from string_to_ull.
|
||||
|
||||
1999-04-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Makefile.maint (b_host): Remove /pub suffix.
|
||||
|
||||
1999-04-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22j.
|
||||
|
||||
* Makefile.maint (my-distcheck): Use AMTAR, not TAR.
|
||||
|
||||
* src/sort.c (usage): s/DIRECT/DIRECTORY/g
|
||||
Rename global: s/temp_file_prefix/temp_dir/.
|
||||
(NAME_MAX_IN_DIR): Rename from PATH_MAX_IN_DIR. Use _POSIX_NAME_MAX,
|
||||
not _POSIX_PATH_MAX. Guard with #if HAVE_PATHCONF rather than
|
||||
#if HAVE_UNISTD_H.
|
||||
(tempname): Wrap after 99999 only for length-impaired file systems.
|
||||
|
||||
1999-04-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tail.c (file_lines): Fix serious bug introduced with last changes.
|
||||
From Andreas Schwab.
|
||||
|
||||
1999-04-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Rename .posix-warn to .env-warn.
|
||||
(check-local): Warn about CDPATH in the same way
|
||||
we warn about POSIXLY_CORRECT, since the cp/same-file test fails at
|
||||
least when using bash with CDPATH set. Reported by Mark Hewitt.
|
||||
|
||||
* src/pr.c Add comments.
|
||||
(init_header): Tweak white space in Date/Time header.
|
||||
* tests/pr/Test.pm: Updated all tests to reflect the big
|
||||
1999-02-13 change. From Roland Huebner.
|
||||
|
||||
1999-04-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cat.c (main): Declare out_dev to be of type dev_t, not `int'.
|
||||
Declare out_ino to be of type ino_t, not `int'.
|
||||
From John Bley.
|
||||
|
||||
* src/od.c (MIN, MAX): Remove definitions.
|
||||
* src/sys2.h (MIN, MAX): Define here instead.
|
||||
Reported by John Bley.
|
||||
|
||||
1999-04-11 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22i.
|
||||
|
||||
* tests/pr/Test.pm (test_vector): Disable all tests while I wait for
|
||||
an updated suite.
|
||||
|
||||
Fix the problem whereby `yes > k & sleep 1; tail -2c k' would infloop.
|
||||
* src/tail.c (COPY_TO_EOF): Define.
|
||||
(dump_remainder): Add parameter, n_bytes, and rewrite to use it.
|
||||
Update callers.
|
||||
(file_lines): Rename parameter.
|
||||
(tail_bytes): Remove obsolete comment.
|
||||
|
||||
Fix the problem whereby `yes > k & sleep 1; tail -1 k' would infloop.
|
||||
* src/tail.c (dump_remainder): Move this function to precede the
|
||||
new use in file_lines.
|
||||
(tail_lines): Don't call dump_remainder here.
|
||||
(file_lines): Call dump_remainder here instead.
|
||||
Reported by Lehti Rami.
|
||||
|
||||
* lib/readtokens.c (readtoken, readtokens): Protoize.
|
||||
|
||||
1999-04-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tail.c (xwrite): Use STDOUT_FILENO instead of literal `1'.
|
||||
|
||||
1999-04-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cat.c: Standardize --help and --version processing.
|
||||
* src/comm.c: Likewise.
|
||||
* src/csplit.c: Likewise.
|
||||
* src/cut.c: Likewise.
|
||||
* src/expand.c: Likewise.
|
||||
* src/fmt.c: Likewise.
|
||||
* src/fold.c: Likewise.
|
||||
* src/head.c: Likewise.
|
||||
* src/join.c: Likewise.
|
||||
* src/md5sum.c: Likewise.
|
||||
* src/nl.c: Likewise.
|
||||
* src/od.c: Likewise.
|
||||
* src/paste.c: Likewise.
|
||||
* src/pr.c: Likewise.
|
||||
* src/ptx.c: Likewise.
|
||||
* src/split.c: Likewise.
|
||||
* src/sum.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
* src/tail.c: Likewise.
|
||||
* src/tr.c: Likewise.
|
||||
* src/unexpand.c: Likewise.
|
||||
* src/uniq.c: Likewise.
|
||||
* src/wc.c: Likewise.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
1999-03-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tail.c (recheck): Factor out a block of duplicated code.
|
||||
Set f->size to 0 upon encountering a new file so we read it from
|
||||
the beginning rather than from then end of the first line or
|
||||
block. Otherwise, after a log rotation, tail would omit the first
|
||||
line or block of the new file. Reported by Ed Avis.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am (SUBDIRS): Temporarily remove pr.
|
||||
|
||||
1999-03-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tac.c: (tac_mem): `#if-0'-out this unused function.
|
||||
(tac_stdin_to_mem): Likewise.
|
||||
|
||||
* doc/textutils.texi (cut invocation): Describe --output-delimiter.
|
||||
|
||||
1999-03-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h (SETVBUF): Define new macro.
|
||||
* src/tail.c (dump_remainder): Don't fflush stdout here.
|
||||
(main) [if forever]: Make stdout unbuffered, instead.
|
||||
Akim Demaille pointed out that when running `echo x>a; tail -f a>>a' ,
|
||||
the file `a' didn't grow longer than two lines. Now it grows
|
||||
without bound.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/md5sum/newline-1: Test for the actual feature.
|
||||
With help from Eli Zaretskii.
|
||||
|
||||
* src/pr.c (usage): Add missing \n\.
|
||||
|
||||
The newline test would always fail on MSDOS/Windows systems --
|
||||
so move it to a separate file where we can test for that.
|
||||
* tests/md5sum/basic-1: Remove newline test.
|
||||
* tests/md5sum/newline-1: New file.
|
||||
* tests/md5sum/Makefile.am (TESTS): Add newline-1.
|
||||
Pointed out by Eli Zaretskii.
|
||||
|
||||
1999-02-13 Roland Huebner <rh@pelikan.cologne.de>
|
||||
* src/pr.c
|
||||
(main): Redefine options -s, -w to be POSIX compliant; introduce
|
||||
new options -J, -S, -W to disentangle -s and -w when used together
|
||||
with the three column options;
|
||||
(add_line_number): Make POSIX compliant; use default number
|
||||
separator TAB with single column output.
|
||||
(add_line_number): Make POSIX compliant; with multicolumn output
|
||||
now prefer `text columns of equal width' rather than a consequent
|
||||
use of `default n-separator TAB'.
|
||||
(add_line_number): Change line number cut-off from lower-oder to
|
||||
higher-oder digit to avoid loss of information; no consequent
|
||||
handling exists in different utilities and other UNIXes.
|
||||
(char_to_clump): Expand input text tabs to 8 spaces, if
|
||||
input_tab_char doesn't equal TAB (adapted to other UNIXes).
|
||||
(usage): Update POSIX compliant options -s, -w; add new options -J,
|
||||
-S, -W.
|
||||
(main): Update the source internal documentation.
|
||||
Some smaller BUGFIXES (print_sep_string, init_header, skip_to_page,
|
||||
reset_status, print_header).
|
||||
|
||||
* tests/md5sum/basic-1 (backslash): Use .\foo instead of \.foo so we
|
||||
don't tramp on root directory in MSDOS/Windows.
|
||||
Suggestion from Eli Zaretskii.
|
||||
|
||||
1999-02-15 Eli Zaretskii <eliz@is.elta.co.il>
|
||||
|
||||
* tests/md5sum/Makefile.am (TESTS_ENVIRONMENT): Run md5sum with the
|
||||
--text option (for MSDOS).
|
||||
|
||||
1999-03-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cut.c (getstr): Change type of `delim' parameter from char to int.
|
||||
(cut_fields): Cast to `unsigned char' before comparing.
|
||||
(main): Cast to `unsigned char' before assigning.
|
||||
From Arne Juul.
|
||||
* tests/cut/Test.pm: Add a test to exercise the bug.
|
||||
|
||||
* src/ptx.c (swallow_file_in_memory): Use a `%s' format in error call,
|
||||
in case the argument string contains a `%'.
|
||||
(main): Likewise.
|
||||
* src/fmt.c (main): Likewise.
|
||||
* src/sort.c (main): Likewise.
|
||||
|
||||
1999-02-13 Eli Zaretskii <eliz@is.elta.co.il>
|
||||
|
||||
* src/sys2.h [__DJGPP__]: Include <io.h> and <sys/exceptn.h>.
|
||||
|
||||
* src/ptx.c (swallow_file_in_memory): Slurp up the whole file at
|
||||
once on MSDOS as well, but we have to relax the test for whether
|
||||
reading it succeeded.
|
||||
|
||||
1999-03-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cat.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/cksum.c: Likewise.
|
||||
* src/comm.c: Likewise.
|
||||
* src/csplit.c: Likewise.
|
||||
* src/cut.c: Likewise.
|
||||
* src/expand.c: Likewise.
|
||||
* src/fmt.c: Likewise.
|
||||
* src/fold.c: Likewise.
|
||||
* src/head.c: Likewise.
|
||||
* src/nl.c: Likewise.
|
||||
* src/od.c: Likewise.
|
||||
* src/paste.c: Likewise.
|
||||
* src/pr.c: Likewise.
|
||||
* src/split.c: Likewise.
|
||||
* src/sum.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
* src/tail.c: Likewise.
|
||||
* src/tr.c: Likewise.
|
||||
* src/unexpand.c: Likewise.
|
||||
* src/uniq.c: Likewise.
|
||||
* src/wc.c: Likewise.
|
||||
|
||||
* src/ptx.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Remove `const' attribute from dcl of argv parameter.
|
||||
Call bindtextdomain and textdomain.
|
||||
Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
|
||||
* src/join.c (main): Include author name argument in call to
|
||||
parse_long_options.
|
||||
* src/md5sum.c (main): Likewise.
|
||||
* src/sort.c (main): Likewise.
|
||||
* src/tsort.c (main): Likewise.
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22h.
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
Changes in release 1.23
|
||||
[1.22k]
|
||||
* `sort -n' works with negative numbers when configured/compiled
|
||||
with --enable-nls
|
||||
* head accepts byte and line counts of type uintmax_t (so up to 2^64 - 1)
|
||||
[1.22j]
|
||||
* tail: fix bug introduced in 1.22i
|
||||
[1.22i]
|
||||
* tail now terminates in `yes > k & sleep 1; tail -2c k'
|
||||
* `tail -f' now ensures that stdout is unbuffered
|
||||
* fix a bug in cut to allow use of 8-bit delimiters
|
||||
* pr accepts POSIX compliant options -s and -w,
|
||||
the new capital letter options -J, -S and _W turn off the
|
||||
unexpected interferences of the small letter options -s and -w
|
||||
if used together with the column options.
|
||||
* pr output has been adapted to other UNIXes in some cases.
|
||||
[1.22h]
|
||||
* portability tweaks
|
||||
* Window/NT/DOS support
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */
|
||||
|
||||
/*$Id: ansi2knr.c,v 1.13 1999/02/03 15:23:21 meyering Exp $*/
|
||||
/*$Id: ansi2knr.c,v 1.14 1999/04/13 14:44:33 meyering Exp $*/
|
||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
|
||||
|
||||
/*
|
||||
@@ -44,7 +44,10 @@ program under the GPL.
|
||||
* consisting of only
|
||||
* identifier1(identifier2)
|
||||
* will not be considered a function definition unless identifier2 is
|
||||
* the word "void". ansi2knr will recognize a multi-line header provided
|
||||
* the word "void", and a line consisting of
|
||||
* identifier1(identifier2, <<arbitrary>>)
|
||||
* will not be considered a function definition.
|
||||
* ansi2knr will recognize a multi-line header provided
|
||||
* that no intervening line ends with a left or right brace or a semicolon.
|
||||
* These algorithms ignore whitespace and comments, except that
|
||||
* the function name must be the first thing on the line.
|
||||
@@ -58,6 +61,12 @@ program under the GPL.
|
||||
* The original and principal author of ansi2knr is L. Peter Deutsch
|
||||
* <ghost@aladdin.com>. Other authors are noted in the change history
|
||||
* that follows (in reverse chronological order):
|
||||
lpd 1999-04-12 added minor fixes from Pavel Roskin
|
||||
<pavel_roskin@geocities.com> for clean compilation with
|
||||
gcc -W -Wall
|
||||
lpd 1999-03-22 added hack to recognize lines consisting of
|
||||
identifier1(identifier2, xxx) as *not* being procedures
|
||||
lpd 1999-02-03 made indentation of preprocessor commands consistent
|
||||
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
|
||||
endless loop; quoted strings within an argument list
|
||||
confused the parser
|
||||
@@ -158,6 +167,11 @@ program under the GPL.
|
||||
|
||||
#endif
|
||||
|
||||
/* Define NULL (for *very* old compilers). */
|
||||
#ifndef NULL
|
||||
# define NULL (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ctype macros don't always handle 8-bit characters correctly.
|
||||
* Compensate for this here.
|
||||
@@ -263,6 +277,11 @@ main(argc, argv)
|
||||
if ( filename )
|
||||
fprintf(out, "#line 1 \"%s\"\n", filename);
|
||||
buf = malloc(bufsize);
|
||||
if ( buf == NULL )
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate read buffer!\n");
|
||||
exit(1);
|
||||
}
|
||||
line = buf;
|
||||
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
||||
{
|
||||
@@ -430,7 +449,7 @@ test1(buf)
|
||||
};
|
||||
char **key = words;
|
||||
char *kp;
|
||||
int len = endfn - buf;
|
||||
unsigned len = endfn - buf;
|
||||
|
||||
while ( (kp = *key) != 0 )
|
||||
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
||||
@@ -443,14 +462,16 @@ test1(buf)
|
||||
int len;
|
||||
/*
|
||||
* Check for identifier1(identifier2) and not
|
||||
* identifier1(void).
|
||||
* identifier1(void), or identifier1(identifier2, xxxx).
|
||||
*/
|
||||
|
||||
while ( isidchar(*p) )
|
||||
p++;
|
||||
len = p - id;
|
||||
p = skipspace(p, 1);
|
||||
if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) )
|
||||
if (*p == ',' ||
|
||||
(*p == ')' && (len != 4 || strncmp(id, "void", 4)))
|
||||
)
|
||||
return 0; /* not a function */
|
||||
}
|
||||
/*
|
||||
@@ -495,7 +516,7 @@ convert1(buf, out, header, convert_varargs)
|
||||
;
|
||||
top: p = endfn;
|
||||
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
||||
if ( breaks == 0 )
|
||||
if ( breaks == NULL )
|
||||
{ /* Couldn't allocate break table, give up */
|
||||
fprintf(stderr, "Unable to allocate break table!\n");
|
||||
fputs(buf, out);
|
||||
@@ -507,7 +528,7 @@ top: p = endfn;
|
||||
do
|
||||
{ int level = 0;
|
||||
char *lp = NULL;
|
||||
char *rp;
|
||||
char *rp = NULL;
|
||||
char *end = NULL;
|
||||
|
||||
if ( bp >= btop )
|
||||
@@ -545,7 +566,7 @@ top: p = endfn;
|
||||
}
|
||||
}
|
||||
/* Erase any embedded prototype parameters. */
|
||||
if ( lp )
|
||||
if ( lp && rp )
|
||||
writeblanks(lp + 1, rp);
|
||||
p--; /* back up over terminator */
|
||||
/* Find the name being declared. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from filenames
|
||||
Copyright (C) 90,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -33,6 +33,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "basename"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
char *base_name ();
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
@@ -93,7 +98,15 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "basename", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle `--' here. */
|
||||
if (argc > 1 && STREQ (argv[1], "--"))
|
||||
{
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc == 1 || argc > 3)
|
||||
{
|
||||
|
||||
34
src/cat.c
34
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 88, 90, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "error.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cat"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund and Richard M. Stallman"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef max
|
||||
#define max(h,i) ((h) > (i) ? (h) : (i))
|
||||
@@ -481,10 +486,10 @@ main (int argc, char **argv)
|
||||
int argind;
|
||||
|
||||
/* Device number of the output (file or whatever). */
|
||||
int out_dev;
|
||||
dev_t out_dev;
|
||||
|
||||
/* I-node number of the output. */
|
||||
int out_ino;
|
||||
ino_t out_ino;
|
||||
|
||||
/* Nonzero if the output file should not be the same as any input file. */
|
||||
int check_redirection = 1;
|
||||
@@ -510,12 +515,6 @@ main (int argc, char **argv)
|
||||
/* If nonzero, call cat, otherwise call simple_cat to do the actual work. */
|
||||
int options = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"number-nonblank", no_argument, NULL, 'b'},
|
||||
@@ -528,8 +527,8 @@ main (int argc, char **argv)
|
||||
#if O_BINARY
|
||||
{"binary", no_argument, NULL, 'B'},
|
||||
#endif
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -614,20 +613,15 @@ main (int argc, char **argv)
|
||||
output_tabs = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cat (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
output_desc = 1;
|
||||
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
36
src/chgrp.c
36
src/chgrp.c
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,11 +24,15 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "group-member.h"
|
||||
#include "savedir.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chgrp"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* MAXUID may come from limits.h *or* sys/params.h (via system.h) above. */
|
||||
#ifndef MAXUID
|
||||
@@ -97,12 +101,6 @@ static const char *groupname;
|
||||
This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* 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'},
|
||||
@@ -112,8 +110,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -303,7 +301,7 @@ usage (int status)
|
||||
Usage: %s [OPTION]... GROUP FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
program_name, program_name);
|
||||
printf (_("\
|
||||
Change the group membership of each FILE to GROUP.\n\
|
||||
\n\
|
||||
@@ -361,21 +359,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
53
src/chmod.c
53
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,12 +22,16 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "modechange.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "filemode.h"
|
||||
#include "modechange.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chmod"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
@@ -70,12 +74,6 @@ static enum Verbosity verbosity = V_off;
|
||||
of this file. This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* 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'},
|
||||
@@ -84,8 +82,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -93,7 +91,7 @@ static struct option const long_options[] =
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
static void
|
||||
describe_change (const char *file, short unsigned int mode,
|
||||
describe_change (const char *file, mode_t mode,
|
||||
enum Change_status changed)
|
||||
{
|
||||
char perms[11]; /* "-rwxrwxrwx" ls-style modes. */
|
||||
@@ -104,18 +102,18 @@ describe_change (const char *file, short unsigned int mode,
|
||||
switch (changed)
|
||||
{
|
||||
case CH_SUCCEEDED:
|
||||
fmt = _("mode of %s changed to %04o (%s)\n");
|
||||
fmt = _("mode of %s changed to %04lo (%s)\n");
|
||||
break;
|
||||
case CH_FAILED:
|
||||
fmt = _("failed to change mode of %s to %04o (%s)\n");
|
||||
fmt = _("failed to change mode of %s to %04lo (%s)\n");
|
||||
break;
|
||||
case CH_NO_CHANGE_REQUESTED:
|
||||
fmt = _("mode of %s retained as %04o (%s)\n");
|
||||
fmt = _("mode of %s retained as %04lo (%s)\n");
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
printf (fmt, file, mode & 07777, &perms[1]);
|
||||
printf (fmt, file, (unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
|
||||
}
|
||||
|
||||
/* Change the mode of FILE according to the list of operations CHANGES.
|
||||
@@ -128,7 +126,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
const int deref_symlink)
|
||||
{
|
||||
struct stat file_stats;
|
||||
unsigned short newmode;
|
||||
mode_t newmode;
|
||||
int errors = 0;
|
||||
|
||||
if (lstat (file, &file_stats))
|
||||
@@ -154,9 +152,9 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
|
||||
newmode = mode_adjust (file_stats.st_mode, changes);
|
||||
|
||||
if (newmode != (file_stats.st_mode & 07777))
|
||||
if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS))
|
||||
{
|
||||
int fail = chmod (file, (int) newmode);
|
||||
int fail = chmod (file, newmode);
|
||||
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
@@ -239,11 +237,12 @@ usage (int status)
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
|
||||
or: %s [OPTION]... OCTAL_MODE FILE...\n\
|
||||
or: %s [OPTION]... OCTAL-MODE FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
printf (_("\
|
||||
Change the mode of each FILE to MODE.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
@@ -326,21 +325,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chmod (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (modeind == 0 && reference_file == NULL)
|
||||
modeind = optind++;
|
||||
|
||||
|
||||
36
src/chown.c
36
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -36,10 +36,14 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "lchown.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chown"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwnam ();
|
||||
@@ -103,12 +107,6 @@ static char *groupname;
|
||||
of this file. This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* 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'},
|
||||
@@ -119,8 +117,8 @@ static struct option const long_options[] =
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -326,7 +324,6 @@ main (int argc, char **argv)
|
||||
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, "");
|
||||
@@ -362,21 +359,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chown (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
@@ -395,7 +384,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
|
||||
const char *e = parse_user_spec (argv[optind], &user, &group,
|
||||
&username, &groupname);
|
||||
if (e)
|
||||
error (1, 0, "%s: %s", argv[optind], e);
|
||||
if (username == NULL)
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chroot"
|
||||
|
||||
#define AUTHORS "Roland McGrath"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
@@ -61,8 +66,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "chroot", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
if (argc == 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
32
src/cksum.c
32
src/cksum.c
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX.2 checksums and sizes of files
|
||||
Copyright (C) 92, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 Q. Frank Xia, qx@math.columbia.edu.
|
||||
Cosmetic changes and reorganization by David MacKenzie, djm@gnu.ai.mit.edu.
|
||||
@@ -42,6 +42,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cksum"
|
||||
|
||||
#define AUTHORS "Q. Frank Xia"
|
||||
|
||||
#ifdef CRCTAB
|
||||
|
||||
# include <stdio.h>
|
||||
@@ -108,6 +113,7 @@ main ()
|
||||
# include <getopt.h>
|
||||
# include <sys/types.h>
|
||||
# include "system.h"
|
||||
# include "long-options.h"
|
||||
# include "error.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
@@ -116,16 +122,8 @@ main ()
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -294,6 +292,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
have_read_stdin = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
@@ -308,15 +309,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cksum (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
if (cksum ("-", 0) < 0)
|
||||
|
||||
30
src/comm.c
30
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 86, 90, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +26,11 @@
|
||||
#include "linebuffer.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "comm"
|
||||
|
||||
#define AUTHORS "Richard Stallman and David MacKenzie"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
@@ -42,16 +47,10 @@ static int only_file_2;
|
||||
/* If nonzero, print lines that are found in both files. */
|
||||
static int both;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -243,19 +242,14 @@ main (int argc, char **argv)
|
||||
both = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("comm (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind + 2 != argc)
|
||||
usage (1);
|
||||
|
||||
|
||||
23
src/copy.c
23
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 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
|
||||
@@ -195,7 +195,7 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
/* Create the new regular file with small permissions initially,
|
||||
to not create a security hole. */
|
||||
|
||||
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
if (dest_desc < 0)
|
||||
{
|
||||
error (0, errno, _("cannot create regular file `%s'"), dst_path);
|
||||
@@ -428,9 +428,8 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
&& ! x->force
|
||||
|
||||
/* Allow them to be the same (and don't set `same') if
|
||||
we're in move mode and they're both symlinks. */
|
||||
we're in move mode and the target is a symlink. */
|
||||
&& !(move_mode
|
||||
&& S_ISLNK (src_sb.st_mode)
|
||||
&& S_ISLNK (dst_sb.st_mode))
|
||||
|
||||
/* If we're making a backup, we'll detect the problem case in
|
||||
@@ -488,9 +487,9 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
if (euidaccess (dst_path, W_OK) != 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s: overwrite `%s', overriding mode %04o? "),
|
||||
_("%s: overwrite `%s', overriding mode %04lo? "),
|
||||
program_name, dst_path,
|
||||
(unsigned int) (dst_sb.st_mode & 07777));
|
||||
(unsigned long) (dst_sb.st_mode & CHMOD_MODE_BITS));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -558,7 +557,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
/* Temporarily change mode to allow overwriting. */
|
||||
if (euidaccess (dst_path, W_OK | X_OK) != 0)
|
||||
{
|
||||
if (chmod (dst_path, 0700))
|
||||
if (chmod (dst_path, S_IRWXU))
|
||||
{
|
||||
error (0, errno, "%s", dst_path);
|
||||
return 1;
|
||||
@@ -682,7 +681,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
/* Create the new directory writable and searchable, so
|
||||
we can create new entries in it. */
|
||||
|
||||
if (mkdir (dst_path, (src_mode & x->umask_kill) | 0700))
|
||||
if (mkdir (dst_path, (src_mode & x->umask_kill) | S_IRWXU))
|
||||
{
|
||||
error (0, errno, _("cannot create directory `%s'"), dst_path);
|
||||
goto un_backup;
|
||||
@@ -697,12 +696,12 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|
||||
if (x->verbose)
|
||||
printf ("%s -> %s\n", src_path, dst_path);
|
||||
|
||||
/* Are we crossing a file system boundary? */
|
||||
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Are we crossing a file system boundary? */
|
||||
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
|
||||
return 0;
|
||||
|
||||
/* Copy the contents of the directory. */
|
||||
|
||||
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x,
|
||||
|
||||
@@ -99,7 +99,7 @@ struct cp_options
|
||||
int symbolic_link;
|
||||
|
||||
/* The bits to preserve in created files' modes. */
|
||||
unsigned int umask_kill;
|
||||
mode_t umask_kill;
|
||||
|
||||
/* If nonzero, do not copy a nondirectory that has an existing destination
|
||||
with the same or newer modification time. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cp-hash.c -- file copying (hash search routines)
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 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
|
||||
|
||||
44
src/cp.c
44
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 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
|
||||
@@ -28,14 +28,18 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "argmatch.h"
|
||||
#include "path-concat.h"
|
||||
#include "closeout.h"
|
||||
#include "cp-hash.h"
|
||||
#include "backupfile.h"
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "error.h"
|
||||
#include "dirname.h"
|
||||
#include "path-concat.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cp"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund, David MacKenzie, and Jim Meyering"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
uid_t geteuid ();
|
||||
@@ -83,12 +87,6 @@ static enum Sparse_type const sparse_type[] =
|
||||
/* The error code to return to the system. */
|
||||
static int exit_status = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
@@ -108,8 +106,8 @@ static struct option const long_opts[] =
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -463,7 +461,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
|
||||
leading directories. */
|
||||
parent_exists = !make_path_private (dst_path,
|
||||
arg_in_concat - dst_path,
|
||||
0700,
|
||||
S_IRWXU,
|
||||
(x->verbose
|
||||
? "%s -> %s\n" : NULL),
|
||||
&attr_list, &new_dst,
|
||||
@@ -619,7 +617,7 @@ cp_option_init (struct cp_options *x)
|
||||
when using chmod. The creation mask is set to be liberal, so
|
||||
that created directories can be written, even if it would not
|
||||
have been allowed with the mask this process was started with. */
|
||||
x->umask_kill = 0777777 ^ umask (0);
|
||||
x->umask_kill = ~ umask (0);
|
||||
|
||||
x->update = 0;
|
||||
x->verbose = 0;
|
||||
@@ -741,21 +739,15 @@ main (int argc, char **argv)
|
||||
version = optarg;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (x.hard_link && x.symbolic_link)
|
||||
{
|
||||
error (0, 0, _("cannot make both hard and symbolic links"));
|
||||
@@ -767,7 +759,7 @@ main (int argc, char **argv)
|
||||
: none);
|
||||
|
||||
if (x.preserve_chmod_bits == 1)
|
||||
x.umask_kill = 0777777;
|
||||
x.umask_kill = ~ (mode_t) 0;
|
||||
|
||||
/* The key difference between -d (--no-dereference) and not is the version
|
||||
of `stat' to call. */
|
||||
|
||||
73
src/csplit.c
73
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,9 +31,15 @@
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "xalloc.h"
|
||||
#include "human.h"
|
||||
#include "safe-read.h"
|
||||
#include "xstrtol.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "csplit"
|
||||
|
||||
#define AUTHORS "Stuart Kemp and David MacKenzie"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
@@ -62,8 +68,8 @@ struct control
|
||||
char *regexpr; /* Non-compiled regular expression. */
|
||||
struct re_pattern_buffer re_compiled; /* Compiled regular expression. */
|
||||
int offset; /* Offset from regexp to split at. */
|
||||
int lines_required; /* Number of lines required. */
|
||||
unsigned int repeat; /* Repeat count. */
|
||||
uintmax_t lines_required; /* Number of lines required. */
|
||||
uintmax_t repeat; /* Repeat count. */
|
||||
int repeat_forever; /* Non-zero if `*' used as a repeat count. */
|
||||
int argnum; /* ARGV index. */
|
||||
boolean ignore; /* If true, produce no output (for regexp). */
|
||||
@@ -202,12 +208,6 @@ static struct control *controls;
|
||||
/* Number of elements in `controls'. */
|
||||
static unsigned int control_used;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"digits", required_argument, NULL, 'n'},
|
||||
@@ -217,8 +217,8 @@ static struct option const longopts[] =
|
||||
{"elide-empty-files", no_argument, NULL, 'z'},
|
||||
{"prefix", required_argument, NULL, 'f'},
|
||||
{"suffix-format", required_argument, NULL, 'b'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -744,8 +744,10 @@ dump_rest_of_file (void)
|
||||
static void
|
||||
handle_line_error (const struct control *p, int repetition)
|
||||
{
|
||||
fprintf (stderr, _("%s: `%d': line number out of range"),
|
||||
program_name, p->lines_required);
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
|
||||
fprintf (stderr, _("%s: `%s': line number out of range"),
|
||||
program_name, human_readable (p->lines_required, buf, 1, 1));
|
||||
if (repetition)
|
||||
fprintf (stderr, _(" on repetition %d\n"), repetition);
|
||||
else
|
||||
@@ -763,7 +765,7 @@ static void
|
||||
process_line_count (const struct control *p, int repetition)
|
||||
{
|
||||
unsigned int linenum;
|
||||
unsigned int last_line_to_save = p->lines_required * (repetition + 1);
|
||||
uintmax_t last_line_to_save = p->lines_required * (repetition + 1);
|
||||
struct cstring *line;
|
||||
|
||||
create_output_file ();
|
||||
@@ -1090,7 +1092,7 @@ check_for_offset (struct control *p, const char *str, const char *num)
|
||||
static void
|
||||
parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
{
|
||||
unsigned long val;
|
||||
uintmax_t val;
|
||||
char *end;
|
||||
|
||||
end = str + strlen (str) - 1;
|
||||
@@ -1102,14 +1104,13 @@ parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
p->repeat_forever = 1;
|
||||
else
|
||||
{
|
||||
if (xstrtoul (str + 1, NULL, 10, &val, "") != LONGINT_OK
|
||||
|| val > UINT_MAX)
|
||||
if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s}: integer required between `{' and `}'"),
|
||||
global_argv[argnum]);
|
||||
}
|
||||
p->repeat = (unsigned int) val;
|
||||
p->repeat = val;
|
||||
}
|
||||
|
||||
*end = '}';
|
||||
@@ -1167,8 +1168,8 @@ 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;
|
||||
uintmax_t val;
|
||||
static uintmax_t last_val = 0;
|
||||
|
||||
for (i = start; i < argc; i++)
|
||||
{
|
||||
@@ -1181,25 +1182,28 @@ parse_patterns (int argc, int start, char **argv)
|
||||
p = new_control_record ();
|
||||
p->argnum = i;
|
||||
|
||||
if (xstrtoul (argv[i], NULL, 10, &val, "") != LONGINT_OK
|
||||
|| val > INT_MAX)
|
||||
if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK)
|
||||
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);
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("line number `%s' is smaller than preceding line number, %s"),
|
||||
argv[i], human_readable (last_val, buf, 1, 1));
|
||||
}
|
||||
|
||||
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;
|
||||
p->lines_required = val;
|
||||
}
|
||||
|
||||
if (i + 1 < argc && *argv[i + 1] == '{')
|
||||
@@ -1454,19 +1458,14 @@ main (int argc, char **argv)
|
||||
elide_empty_files = TRUE;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("csplit (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind < 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
40
src/cut.c
40
src/cut.c
@@ -1,5 +1,5 @@
|
||||
/* cut - remove parts of lines of files
|
||||
Copyright (C) 1984, 1997, 1998 by David M. Ihnat
|
||||
Copyright (C) 1984, 1997, 1998, 1999 by David M. Ihnat
|
||||
|
||||
This program is a total rewrite of the Bell Laboratories Unix(Tm)
|
||||
command of the same name, as of System V. It contains no proprietary
|
||||
@@ -68,12 +68,17 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cut"
|
||||
|
||||
#define AUTHORS "David Ihnat, David MacKenzie, and Jim Meyering"
|
||||
|
||||
char *xstrdup ();
|
||||
|
||||
#define FATAL_ERROR(s) \
|
||||
#define FATAL_ERROR(Message) \
|
||||
do \
|
||||
{ \
|
||||
error (0, 0, (s)); \
|
||||
error (0, 0, (Message)); \
|
||||
usage (2); \
|
||||
} \
|
||||
while (0)
|
||||
@@ -168,12 +173,6 @@ static char *output_delimiter_string;
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", required_argument, 0, 'b'},
|
||||
@@ -182,8 +181,8 @@ static struct option const longopts[] =
|
||||
{"delimiter", required_argument, 0, 'd'},
|
||||
{"only-delimited", no_argument, 0, 's'},
|
||||
{"output-delimiter", required_argument, 0, CHAR_MAX + 1},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -245,7 +244,7 @@ With no FILE, or when FILE is -, read standard input.\n\
|
||||
including the null terminator), or -1 on error or EOF. */
|
||||
|
||||
static int
|
||||
getstr (char **lineptr, int *n, FILE *stream, char terminator)
|
||||
getstr (char **lineptr, int *n, FILE *stream, int terminator)
|
||||
{
|
||||
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||
char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||
@@ -562,7 +561,7 @@ cut_fields (FILE *stream)
|
||||
/* If the first field extends to the end of line (it is not
|
||||
delimited) and we are printing all non-delimited lines,
|
||||
print this one. */
|
||||
if (field_1_buffer[len - 1] != delim)
|
||||
if ((unsigned char) field_1_buffer[len - 1] != delim)
|
||||
{
|
||||
if (suppress_non_delimited)
|
||||
{
|
||||
@@ -735,7 +734,7 @@ main (int argc, char **argv)
|
||||
/* Interpret -d '' to mean `use the NUL byte as the delimiter.' */
|
||||
if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
delim = optarg[0];
|
||||
delim = (unsigned char) optarg[0];
|
||||
delim_specified = 1;
|
||||
break;
|
||||
|
||||
@@ -754,20 +753,15 @@ main (int argc, char **argv)
|
||||
suppress_non_delimited = 1;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (2);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cut (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (operating_mode == undefined_mode)
|
||||
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
|
||||
|
||||
|
||||
96
src/date.c
96
src/date.c
@@ -23,12 +23,18 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "argmatch.h"
|
||||
#include "closeout.h"
|
||||
#include "getline.h"
|
||||
#include "error.h"
|
||||
#include "getdate.h"
|
||||
#include "getline.h"
|
||||
#include "posixtm.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "date"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
size_t strftime ();
|
||||
time_t time ();
|
||||
@@ -41,14 +47,33 @@ char *xstrdup ();
|
||||
|
||||
static void show_date PARAMS ((const char *format, time_t when));
|
||||
|
||||
enum Time_spec
|
||||
{
|
||||
/* display only the date: 1999-03-25 */
|
||||
TIME_SPEC_DATE=1,
|
||||
/* display date and hour: 1999-03-25T03-0500 */
|
||||
TIME_SPEC_HOURS,
|
||||
/* display date, hours, and minutes: 1999-03-25T03:23-0500 */
|
||||
TIME_SPEC_MINUTES,
|
||||
/* display date, hours, minutes, and seconds: 1999-03-25T03:23:14-0500 */
|
||||
TIME_SPEC_SECONDS
|
||||
};
|
||||
|
||||
static char const *const time_spec_string[] =
|
||||
{
|
||||
"date", "hours", "minutes", "seconds", 0
|
||||
};
|
||||
|
||||
static enum Time_spec const time_spec[] =
|
||||
{
|
||||
TIME_SPEC_DATE, TIME_SPEC_HOURS, TIME_SPEC_MINUTES, TIME_SPEC_SECONDS
|
||||
};
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
/* If nonzero, display an ISO 8601 format date/time string */
|
||||
static int iso_8601_format = 0;
|
||||
|
||||
/* If non-zero, display time in RFC-822 format for mail or news. */
|
||||
static int rfc_format = 0;
|
||||
@@ -60,14 +85,15 @@ static struct option const long_options[] =
|
||||
{
|
||||
{"date", required_argument, NULL, 'd'},
|
||||
{"file", required_argument, NULL, 'f'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"iso-8601", optional_argument, NULL, 'I'},
|
||||
{"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'},
|
||||
{"universal", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -98,14 +124,18 @@ Usage: %s [OPTION]... [+FORMAT]\n\
|
||||
printf (_("\
|
||||
Display the current time in the given FORMAT, or set the system date.\n\
|
||||
\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\
|
||||
--version output version information and exit\n\
|
||||
-d, --date=STRING display time described by STRING, not `now'\n\
|
||||
-f, --file=DATEFILE like --date once for each line of DATEFILE\n\
|
||||
-I, --iso-8601[=TIMESPEC] output an ISO-8601 compliant date/time string.\n\
|
||||
TIMESPEC=`date' (or missing) for date only,\n\
|
||||
`hours', `minutes', or `seconds' for date and\n\
|
||||
time to the indicated precision.\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\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
printf (_("\
|
||||
\n\
|
||||
@@ -258,7 +288,7 @@ batch_convert (const char *input_filename, const char *format)
|
||||
free (initial_TZ);
|
||||
|
||||
if (fclose (in_stream) == EOF)
|
||||
error (2, errno, input_filename);
|
||||
error (2, errno, "`%s'", input_filename);
|
||||
|
||||
if (line != NULL)
|
||||
free (line);
|
||||
@@ -287,7 +317,7 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "d:f:r:Rs:u", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "d:f:I::r:Rs:u", long_options, NULL))
|
||||
!= -1)
|
||||
switch (optc)
|
||||
{
|
||||
@@ -299,6 +329,12 @@ main (int argc, char **argv)
|
||||
case 'f':
|
||||
batch_file = optarg;
|
||||
break;
|
||||
case 'I':
|
||||
iso_8601_format = (optarg
|
||||
? XARGMATCH ("--iso-8601", optarg,
|
||||
time_spec_string, time_spec)
|
||||
: TIME_SPEC_DATE);
|
||||
break;
|
||||
case 'r':
|
||||
reference = optarg;
|
||||
break;
|
||||
@@ -312,19 +348,12 @@ main (int argc, char **argv)
|
||||
case 'u':
|
||||
universal_time = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("date (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
n_args = argc - optind;
|
||||
|
||||
option_specified_date = ((datestr ? 1 : 0)
|
||||
@@ -447,6 +476,15 @@ show_date (const char *format, time_t when)
|
||||
struct tm *tm;
|
||||
char *out = NULL;
|
||||
size_t out_length = 0;
|
||||
/* ISO 8601 formats, in local and UTC. See below regarding %z */
|
||||
static char *iso_format_string[5][2] =
|
||||
{
|
||||
{"", ""},
|
||||
{"%Y-%m-%d", "%Y-%m-%d"},
|
||||
{"%Y-%m-%dT%H%z", "%Y-%m-%dT%HZ"},
|
||||
{"%Y-%m-%dT%H:%M%z", "%Y-%m-%dT%H:%MZ"},
|
||||
{"%Y-%m-%dT%H:%M:%S%z", "%Y-%m-%dT%H:%M:%SZ"}
|
||||
};
|
||||
|
||||
tm = localtime (&when);
|
||||
|
||||
@@ -463,7 +501,9 @@ show_date (const char *format, time_t when)
|
||||
? (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");
|
||||
: (iso_8601_format
|
||||
? iso_format_string[iso_8601_format][universal_time]
|
||||
: "%a %b %e %H:%M:%S %Z %Y"));
|
||||
}
|
||||
else if (*format == '\0')
|
||||
{
|
||||
|
||||
240
src/dd.c
240
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 85, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -29,11 +29,17 @@
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "human.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "long-options.h"
|
||||
#include "safe-read.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dd"
|
||||
|
||||
#define AUTHORS "Paul Rubin, David MacKenzie, and Stuart Kemp"
|
||||
|
||||
#ifndef SIGINFO
|
||||
# define SIGINFO SIGUSR1
|
||||
@@ -71,15 +77,9 @@ char *program_name;
|
||||
/* The name of the input file, or NULL for the standard input. */
|
||||
static char *input_file = NULL;
|
||||
|
||||
/* The input file descriptor. */
|
||||
static int input_fd = 0;
|
||||
|
||||
/* The name of the output file, or NULL for the standard output. */
|
||||
static char *output_file = NULL;
|
||||
|
||||
/* The output file descriptor. */
|
||||
static int output_fd = 1;
|
||||
|
||||
/* The number of bytes in which atomic reads are done. */
|
||||
static size_t input_blocksize = 0;
|
||||
|
||||
@@ -266,19 +266,6 @@ static unsigned char const ebcdic_to_ascii[] =
|
||||
070, 071, 0372, 0373, 0374, 0375, 0376, 0377
|
||||
};
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -373,9 +360,9 @@ static void
|
||||
cleanup (void)
|
||||
{
|
||||
print_stats ();
|
||||
if (close (input_fd) < 0)
|
||||
if (close (STDIN_FILENO) < 0)
|
||||
error (1, errno, "%s", input_file);
|
||||
if (close (output_fd) < 0)
|
||||
if (close (STDOUT_FILENO) < 0)
|
||||
error (1, errno, "%s", output_file);
|
||||
}
|
||||
|
||||
@@ -430,12 +417,34 @@ install_handler (int sig_num, RETSIGTYPE (*sig_handler) (int sig))
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Open a file to a particular file descriptor. This is like standard
|
||||
`open', except it always returns DESIRED_FD if successful. */
|
||||
static int
|
||||
open_fd (int desired_fd, char const *filename, int options, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
close (desired_fd);
|
||||
fd = open (filename, options, mode);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
if (fd != desired_fd)
|
||||
{
|
||||
if (dup2 (fd, desired_fd) != desired_fd)
|
||||
desired_fd = -1;
|
||||
if (close (fd) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return desired_fd;
|
||||
}
|
||||
|
||||
/* Write, then empty, the output buffer `obuf'. */
|
||||
|
||||
static void
|
||||
write_output (void)
|
||||
{
|
||||
int nwritten = full_write (output_fd, obuf, output_blocksize);
|
||||
int nwritten = full_write (STDOUT_FILENO, obuf, output_blocksize);
|
||||
if (nwritten != output_blocksize)
|
||||
{
|
||||
error (0, errno, "%s", output_file);
|
||||
@@ -481,101 +490,15 @@ parse_conversion (char *str)
|
||||
Assign nonzero to *INVALID if STR does not represent a number in
|
||||
this format. */
|
||||
|
||||
/* FIXME: use xstrtou?[lq] */
|
||||
|
||||
static uintmax_t
|
||||
parse_integer (char *str, int *invalid)
|
||||
{
|
||||
register uintmax_t n = 0;
|
||||
register char *p = str;
|
||||
uintmax_t n;
|
||||
enum strtol_error e = xstrtoumax (str, &str, 10, &n, "bcEGkMPTwYZ0");
|
||||
|
||||
while (ISDIGIT (*p))
|
||||
if (e == LONGINT_INVALID_SUFFIX_CHAR && *str == 'x')
|
||||
{
|
||||
uintmax_t n10 = n * 10;
|
||||
int digit = *p - '0';
|
||||
if (! (n10 / 10 == n && n10 <= n10 + digit))
|
||||
{
|
||||
*invalid = 1;
|
||||
return 0;
|
||||
}
|
||||
n = n10 + digit;
|
||||
p++;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
uintmax_t multiplier;
|
||||
int power = 0;
|
||||
|
||||
#ifdef lint
|
||||
/* Suppress `used before initialized' warning. */
|
||||
multiplier = 0;
|
||||
#endif
|
||||
|
||||
switch (*p++)
|
||||
{
|
||||
case '\0':
|
||||
return n;
|
||||
case 'b':
|
||||
multiplier = 512;
|
||||
break;
|
||||
case 'c':
|
||||
continue;
|
||||
case 'E': /* Exa */
|
||||
power = 6;
|
||||
break;
|
||||
case 'G': /* Giga */
|
||||
power = 3;
|
||||
break;
|
||||
case 'k': /* kilo */
|
||||
power = 1;
|
||||
break;
|
||||
case 'M': /* Mega */
|
||||
power = 2;
|
||||
break;
|
||||
case 'P': /* Peta */
|
||||
power = 5;
|
||||
break;
|
||||
case 'T': /* Tera */
|
||||
power = 4;
|
||||
break;
|
||||
case 'w':
|
||||
multiplier = 2;
|
||||
break;
|
||||
case 'x':
|
||||
multiplier = parse_integer (p, invalid);
|
||||
p = "";
|
||||
break;
|
||||
case 'Y': /* Yotta */
|
||||
power = 8;
|
||||
break;
|
||||
case 'Z': /* Zetta */
|
||||
power = 7;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
*invalid = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (power)
|
||||
{
|
||||
int base = 1024;
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
case 'B': p++; break;
|
||||
case 'D': p++; base = 1000; break;
|
||||
}
|
||||
|
||||
for (multiplier = base; --power; multiplier *= base)
|
||||
if (multiplier * base / base != multiplier)
|
||||
{
|
||||
*invalid = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
uintmax_t multiplier = parse_integer (str + 1, invalid);
|
||||
|
||||
if (multiplier != 0 && n * multiplier / multiplier != n)
|
||||
{
|
||||
@@ -585,25 +508,22 @@ parse_integer (char *str, int *invalid)
|
||||
|
||||
n *= multiplier;
|
||||
}
|
||||
else if (e != LONGINT_OK)
|
||||
{
|
||||
*invalid = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
scanargs (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int c;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
@@ -707,14 +627,14 @@ only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sy
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
if (ISLOWER (trans_table[i]))
|
||||
trans_table[i] = toupper (trans_table[i]);
|
||||
trans_table[i] = TOUPPER (trans_table[i]);
|
||||
translation_needed = 1;
|
||||
}
|
||||
else if (conversions_mask & C_LCASE)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
if (ISUPPER (trans_table[i]))
|
||||
trans_table[i] = tolower (trans_table[i]);
|
||||
trans_table[i] = TOLOWER (trans_table[i]);
|
||||
translation_needed = 1;
|
||||
}
|
||||
|
||||
@@ -797,19 +717,8 @@ static void
|
||||
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
|
||||
unsigned char *buf)
|
||||
{
|
||||
struct stat stats;
|
||||
off_t o;
|
||||
|
||||
/* Use fstat instead of checking for errno == ESPIPE because
|
||||
lseek doesn't work on some special files but doesn't return an
|
||||
error, either. */
|
||||
/* FIXME: can this really happen? What system? */
|
||||
if (fstat (fdesc, &stats))
|
||||
{
|
||||
error (0, errno, "%s", file);
|
||||
quit (1);
|
||||
}
|
||||
|
||||
/* Try lseek and if an error indicates it was an inappropriate
|
||||
operation, fall back on using read. */
|
||||
o = records * blocksize;
|
||||
@@ -952,7 +861,7 @@ dd_copy (void)
|
||||
obuf = ibuf;
|
||||
|
||||
if (skip_records != 0)
|
||||
skip (input_fd, input_file, skip_records, input_blocksize, ibuf);
|
||||
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
|
||||
|
||||
if (seek_record != 0)
|
||||
{
|
||||
@@ -963,7 +872,8 @@ dd_copy (void)
|
||||
0+0 records out
|
||||
*/
|
||||
|
||||
skip (output_fd, output_file, seek_record, output_blocksize, obuf);
|
||||
skip (STDOUT_FILENO, output_file, seek_record, output_blocksize,
|
||||
obuf);
|
||||
}
|
||||
|
||||
if (max_records == 0)
|
||||
@@ -980,7 +890,7 @@ dd_copy (void)
|
||||
if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR))
|
||||
memset ((char *) ibuf, 0, input_blocksize);
|
||||
|
||||
nread = safe_read (input_fd, ibuf, input_blocksize);
|
||||
nread = safe_read (STDIN_FILENO, ibuf, input_blocksize);
|
||||
|
||||
if (nread == 0)
|
||||
break; /* EOF. */
|
||||
@@ -992,7 +902,7 @@ dd_copy (void)
|
||||
{
|
||||
print_stats ();
|
||||
/* Seek past the bad block if possible. */
|
||||
lseek (input_fd, (off_t) input_blocksize, SEEK_CUR);
|
||||
lseek (STDIN_FILENO, (off_t) input_blocksize, SEEK_CUR);
|
||||
if (conversions_mask & C_SYNC)
|
||||
/* Replace the missing input with null bytes and
|
||||
proceed normally. */
|
||||
@@ -1024,7 +934,7 @@ dd_copy (void)
|
||||
|
||||
if (ibuf == obuf) /* If not C_TWOBUFS. */
|
||||
{
|
||||
int nwritten = full_write (output_fd, obuf, nread);
|
||||
int nwritten = full_write (STDOUT_FILENO, obuf, nread);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
error (0, errno, "%s", output_file);
|
||||
@@ -1083,7 +993,7 @@ dd_copy (void)
|
||||
/* Write out the last block. */
|
||||
if (oc != 0)
|
||||
{
|
||||
int nwritten = full_write (output_fd, obuf, oc);
|
||||
int nwritten = full_write (STDOUT_FILENO, obuf, oc);
|
||||
if (nwritten > 0)
|
||||
w_partial++;
|
||||
if (nwritten < 0)
|
||||
@@ -1111,6 +1021,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
/* Initialize translation table to identity translation. */
|
||||
for (i = 0; i < 256; i++)
|
||||
trans_table[i] = i;
|
||||
@@ -1118,40 +1031,29 @@ main (int argc, char **argv)
|
||||
/* Decode arguments. */
|
||||
scanargs (argc, argv);
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("dd (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
apply_translations ();
|
||||
|
||||
if (input_file != NULL)
|
||||
{
|
||||
input_fd = open (input_file, O_RDONLY);
|
||||
if (input_fd < 0)
|
||||
if (open_fd (STDIN_FILENO, input_file, O_RDONLY, 0) < 0)
|
||||
error (1, errno, "%s", input_file);
|
||||
}
|
||||
else
|
||||
input_file = _("standard input");
|
||||
|
||||
if (input_fd == output_fd)
|
||||
error (1, 0, _("%s is closed"), (input_fd == 0
|
||||
? _("standard input")
|
||||
: _("standard output")));
|
||||
|
||||
if (output_file != NULL)
|
||||
{
|
||||
int omode = O_RDWR | O_CREAT;
|
||||
mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
int opts
|
||||
= (O_CREAT
|
||||
| (seek_record || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
|
||||
|
||||
if (seek_record == 0 && !(conversions_mask & C_NOTRUNC))
|
||||
omode |= O_TRUNC;
|
||||
output_fd = open (output_file, omode, 0666);
|
||||
if (output_fd < 0)
|
||||
/* Open the output file with *read* access only if we might
|
||||
need to read to satisfy a `seek=' request. If we can't read
|
||||
the file, go ahead with write-only access; it might work. */
|
||||
if ((! seek_record
|
||||
|| open_fd (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
|
||||
&& open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)
|
||||
error (1, errno, "%s", output_file);
|
||||
#if HAVE_FTRUNCATE
|
||||
if (seek_record != 0 && !(conversions_mask & C_NOTRUNC))
|
||||
@@ -1159,7 +1061,7 @@ main (int argc, char **argv)
|
||||
off_t o = seek_record * output_blocksize;
|
||||
if (o / output_blocksize != seek_record)
|
||||
error (1, 0, _("file offset out of range"));
|
||||
if (ftruncate (output_fd, o) < 0)
|
||||
if (ftruncate (STDOUT_FILENO, o) < 0)
|
||||
error (0, errno, "%s", output_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
43
src/df.c
43
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,14 +28,19 @@
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "mountlist.h"
|
||||
#include "fsusage.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "dirname.h"
|
||||
#include "error.h"
|
||||
#include "fsusage.h"
|
||||
#include "human.h"
|
||||
#include "mountlist.h"
|
||||
#include "save-cwd.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "df"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
char *xstrdup ();
|
||||
@@ -103,12 +108,6 @@ static struct fs_type_list *fs_exclude_list;
|
||||
/* Linked list of mounted filesystems. */
|
||||
static struct mount_entry *mount_list;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If nonzero, print filesystem type as well. */
|
||||
static int print_type;
|
||||
|
||||
@@ -128,8 +127,8 @@ static struct option const long_options[] =
|
||||
{"no-sync", no_argument, NULL, CHAR_MAX + 2},
|
||||
{"type", required_argument, NULL, 't'},
|
||||
{"exclude-type", required_argument, NULL, 'x'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -691,21 +690,15 @@ main (int argc, char **argv)
|
||||
case 'x':
|
||||
add_excluded_fs_type (optarg);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("df (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
int match = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1994, 1995, 1997, 1998, 1999 H. Peter Anvin
|
||||
Copyright (C) 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,12 +26,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "getline.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "dircolors.h"
|
||||
#include "error.h"
|
||||
#include "getline.h"
|
||||
#include "obstack.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dircolors"
|
||||
|
||||
#define AUTHORS "H. Peter Anvin"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -66,14 +69,14 @@ 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
|
||||
"CHR", "CHAR", "DOOR", "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"
|
||||
"so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec"
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -82,9 +85,9 @@ static struct option const long_options[] =
|
||||
{"sh", no_argument, NULL, 'b'},
|
||||
{"csh", no_argument, NULL, 'c'},
|
||||
{"c-shell", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"print-database", no_argument, NULL, 'p'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -366,7 +369,8 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES))
|
||||
{
|
||||
error (0, 0, _("%s:%lu: unrecognized keyword `%s'"),
|
||||
filename, (long unsigned) line_number, keywd);
|
||||
(filename ? filename : _("<internal>")),
|
||||
(long unsigned) line_number, keywd);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
@@ -427,8 +431,6 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dircolors", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
|
||||
switch (optc)
|
||||
{
|
||||
@@ -444,6 +446,10 @@ main (int argc, char **argv)
|
||||
print_database = 1;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dirname -- strip filename suffix from pathname
|
||||
Copyright (C) 90,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dirname"
|
||||
|
||||
#define AUTHORS "David MacKenzie and Jim Meyering"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -66,7 +71,15 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dirname", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle `--' here. */
|
||||
if (argc > 1 && STREQ (argv[1], "--"))
|
||||
{
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
|
||||
761
src/du.c
761
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 88, 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -51,14 +51,19 @@
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "exclude.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "exclude.h"
|
||||
#include "human.h"
|
||||
#include "xstrtol.h"
|
||||
#include "save-cwd.h"
|
||||
#include "savedir.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "du"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert"
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
@@ -104,19 +109,6 @@ typedef struct String String;
|
||||
int stat ();
|
||||
int lstat ();
|
||||
|
||||
static int hash_insert PARAMS ((ino_t ino, dev_t dev));
|
||||
static int hash_insert2 PARAMS ((struct htab *_htab, ino_t ino, dev_t dev));
|
||||
static uintmax_t count_entry PARAMS ((const char *ent, int top, dev_t last_dev,
|
||||
int depth));
|
||||
static void du_files PARAMS ((char **files));
|
||||
static void hash_init PARAMS ((unsigned int modulus,
|
||||
unsigned int entry_tab_size));
|
||||
static void hash_reset PARAMS ((void));
|
||||
static void str_concatc PARAMS ((String *s1, char *cstr));
|
||||
static void str_copyc PARAMS ((String *s1, char *cstr));
|
||||
static void str_init PARAMS ((String **s1, unsigned int size));
|
||||
static void str_trunc PARAMS ((String *s1, unsigned int length));
|
||||
|
||||
/* Name under which this program was invoked. */
|
||||
char *program_name;
|
||||
|
||||
@@ -163,12 +155,6 @@ static int (*xstat) ();
|
||||
/* The exit status to use if we don't get any fatal errors. */
|
||||
static int exit_status;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* File name patterns to exclude. */
|
||||
static struct exclude *exclude;
|
||||
|
||||
@@ -194,18 +180,14 @@ static struct option const long_options[] =
|
||||
{"separate-dirs", no_argument, NULL, 'S'},
|
||||
{"summarize", no_argument, NULL, 's'},
|
||||
{"total", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
usage (int status, char *reason)
|
||||
usage (int status)
|
||||
{
|
||||
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"),
|
||||
program_name);
|
||||
@@ -244,156 +226,63 @@ Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
/* Initialize string S1 to hold SIZE characters. */
|
||||
|
||||
static void
|
||||
str_init (String **s1, unsigned int size)
|
||||
{
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
int max_depth_specified = 0;
|
||||
String *s;
|
||||
|
||||
/* If nonzero, display only a total for each argument. */
|
||||
int opt_summarize_only = 0;
|
||||
s = (String *) xmalloc (sizeof (struct String));
|
||||
s->text = xmalloc (size + 1);
|
||||
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
s->alloc = size;
|
||||
*s1 = s;
|
||||
}
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
|
||||
!= -1)
|
||||
static void
|
||||
ensure_space (String *s, unsigned int size)
|
||||
{
|
||||
if (s->alloc < size)
|
||||
{
|
||||
long int tmp_long;
|
||||
switch (c)
|
||||
{
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
opt_all = 1;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
opt_combined_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3: /* --max-depth=N */
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > INT_MAX)
|
||||
error (1, 0, _("invalid maximum depth `%s'"), optarg);
|
||||
|
||||
max_depth_specified = 1;
|
||||
max_depth = (int) tmp_long;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
opt_count_all = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
opt_summarize_only = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
opt_one_file_system = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
opt_dereference_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
xstat = stat;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
opt_separate_dirs = 1;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
if (add_exclude_file (exclude, optarg, '\n') != 0)
|
||||
error (1, errno, "%s", optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
add_exclude (exclude, optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1, (char *) 0);
|
||||
}
|
||||
s->text = xrealloc (s->text, size + 1);
|
||||
s->alloc = size;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
/* Assign the null-terminated C-string CSTR to S1. */
|
||||
|
||||
static void
|
||||
str_copyc (String *s1, const char *cstr)
|
||||
{
|
||||
unsigned l = strlen (cstr);
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
static void
|
||||
str_concatc (String *s1, const char *cstr)
|
||||
{
|
||||
unsigned l1 = s1->length;
|
||||
unsigned l2 = strlen (cstr);
|
||||
unsigned l = l1 + l2;
|
||||
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text + l1, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
/* Truncate the string S1 to have length LENGTH. */
|
||||
|
||||
static void
|
||||
str_trunc (String *s1, unsigned int length)
|
||||
{
|
||||
if (s1->length > length)
|
||||
{
|
||||
printf ("du (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
s1->text[length] = 0;
|
||||
s1->length = length;
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0, NULL);
|
||||
|
||||
if (opt_all && opt_summarize_only)
|
||||
usage (1, _("cannot both summarize and show all entries"));
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth == 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing is the same as using --max-depth=0"));
|
||||
}
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth != 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing conflicts with --max-depth=%d"),
|
||||
max_depth);
|
||||
usage (1, NULL);
|
||||
}
|
||||
|
||||
if (opt_summarize_only)
|
||||
max_depth = 0;
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
|
||||
str_init (&path, INITIAL_PATH_SIZE);
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
/* Print N_BLOCKS followed by STRING on a line. NBLOCKS is the number of
|
||||
@@ -411,66 +300,152 @@ print_size (uintmax_t n_blocks, const char *string)
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL. */
|
||||
/* Reset the hash structure in the global variable `htab' to
|
||||
contain no entries. */
|
||||
|
||||
static void
|
||||
du_files (char **files)
|
||||
hash_reset (void)
|
||||
{
|
||||
struct saved_cwd cwd;
|
||||
ino_t initial_ino; /* Initial directory's inode. */
|
||||
dev_t initial_dev; /* Initial directory's device. */
|
||||
int i; /* Index in FILES. */
|
||||
int i;
|
||||
struct entry **p;
|
||||
|
||||
if (save_cwd (&cwd))
|
||||
exit (1);
|
||||
htab->first_free_entry = 0;
|
||||
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, _("current directory"));
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
p = htab->hash;
|
||||
for (i = htab->modulus; i > 0; i--)
|
||||
*p++ = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; files[i]; i++)
|
||||
/* 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
|
||||
hash structure will be rebuilt when ENTRY_TAB_SIZE entries have been
|
||||
inserted, and MODULUS and ENTRY_TAB_SIZE in the global `htab' will be
|
||||
doubled.) */
|
||||
|
||||
static void
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xmalloc (sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xmalloc (sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
hash_reset ();
|
||||
}
|
||||
|
||||
/* Insert INO and DEV in the hash structure HTAB, if not
|
||||
already present. Return zero if inserted and nonzero if it
|
||||
already existed. */
|
||||
|
||||
static int
|
||||
hash_insert2 (struct htab *ht, ino_t ino, dev_t dev)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &ht->hash[ino % ht->modulus];
|
||||
ep2 = *hp;
|
||||
|
||||
/* Collision? */
|
||||
|
||||
if (ep2 != NULL)
|
||||
{
|
||||
char *arg;
|
||||
int s;
|
||||
ep = ep2;
|
||||
|
||||
arg = files[i];
|
||||
/* Search for an entry with the same data. */
|
||||
|
||||
/* Delete final slash in the argument, unless the slash is alone. */
|
||||
s = strlen (arg) - 1;
|
||||
if (s != 0)
|
||||
do
|
||||
{
|
||||
if (arg[s] == '/')
|
||||
arg[s] = 0;
|
||||
|
||||
str_copyc (path, arg);
|
||||
if (ep->ino == ino && ep->dev == dev)
|
||||
return 1; /* Found an entry with the same data. */
|
||||
ep = ep->coll_link;
|
||||
}
|
||||
else if (arg[0] == '/')
|
||||
str_trunc (path, 0); /* Null path for root directory. */
|
||||
else
|
||||
str_copyc (path, arg);
|
||||
while (ep != NULL);
|
||||
|
||||
if (!opt_combined_arguments)
|
||||
hash_reset ();
|
||||
/* Did not find it. */
|
||||
|
||||
count_entry (arg, 1, 0, 0);
|
||||
}
|
||||
|
||||
/* chdir if `count_entry' has changed the working directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
ep = *hp = &ht->entry_tab[ht->first_free_entry++];
|
||||
ep->ino = ino;
|
||||
ep->dev = dev;
|
||||
ep->coll_link = ep2; /* `ep2' is NULL if no collision. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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 nonzero
|
||||
if it wasn't. */
|
||||
|
||||
static int
|
||||
hash_insert (ino_t ino, dev_t dev)
|
||||
{
|
||||
struct htab *htab_r = htab; /* Initially a copy of the global `htab'. */
|
||||
|
||||
if (htab_r->first_free_entry >= htab_r->entry_tab_size)
|
||||
{
|
||||
int i;
|
||||
struct entry *ep;
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
|
||||
/* Increase the number of hash entries, and re-hash the data.
|
||||
The method of shrimping and increasing is made to compactify
|
||||
the heap. If twice as much data would be allocated
|
||||
straightforwardly, we would never re-use a byte of memory. */
|
||||
|
||||
/* Let `htab' shrimp. Keep only the header, not the pointer vector. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r, sizeof (struct htab));
|
||||
|
||||
modulus = 2 * htab_r->modulus;
|
||||
entry_tab_size = 2 * htab_r->entry_tab_size;
|
||||
|
||||
/* Increase the number of possible entries. */
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xrealloc ((char *) htab_r->entry_tab,
|
||||
sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
/* Increase the size of htab again. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r,
|
||||
sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
i = htab_r->first_free_entry;
|
||||
|
||||
/* Make the increased hash table empty. The entries are still
|
||||
available in htab->entry_tab. */
|
||||
|
||||
hash_reset ();
|
||||
|
||||
/* Go through the entries and install them in the pointer vector
|
||||
htab->hash. The items are actually inserted in htab->entry_tab at
|
||||
the position where they already are. The htab->coll_link need
|
||||
however be updated. Could be made a little more efficient. */
|
||||
|
||||
for (ep = htab_r->entry_tab; i > 0; i--)
|
||||
{
|
||||
if (restore_cwd (&cwd, _("starting directory"), NULL))
|
||||
exit (1);
|
||||
hash_insert2 (htab_r, ep->ino, ep->dev);
|
||||
ep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_combined_arguments)
|
||||
print_size (tot_size, _("total"));
|
||||
|
||||
free_cwd (&cwd);
|
||||
return hash_insert2 (htab_r, ino, dev);
|
||||
}
|
||||
|
||||
/* Print (if appropriate) the size (in units determined by `output_block_size')
|
||||
@@ -602,209 +577,213 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
|
||||
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
|
||||
hash structure will be rebuilt when ENTRY_TAB_SIZE entries have been
|
||||
inserted, and MODULUS and ENTRY_TAB_SIZE in the global `htab' will be
|
||||
doubled.) */
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL. */
|
||||
|
||||
static void
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
du_files (char **files)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
struct saved_cwd cwd;
|
||||
ino_t initial_ino; /* Initial directory's inode. */
|
||||
dev_t initial_dev; /* Initial directory's device. */
|
||||
int i; /* Index in FILES. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xmalloc (sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
if (save_cwd (&cwd))
|
||||
exit (1);
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xmalloc (sizeof (struct entry) * entry_tab_size);
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, _("current directory"));
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
hash_reset ();
|
||||
}
|
||||
|
||||
/* Reset the hash structure in the global variable `htab' to
|
||||
contain no entries. */
|
||||
|
||||
static void
|
||||
hash_reset (void)
|
||||
{
|
||||
int i;
|
||||
struct entry **p;
|
||||
|
||||
htab->first_free_entry = 0;
|
||||
|
||||
p = htab->hash;
|
||||
for (i = htab->modulus; i > 0; i--)
|
||||
*p++ = NULL;
|
||||
}
|
||||
|
||||
/* 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 nonzero
|
||||
if it wasn't. */
|
||||
|
||||
static int
|
||||
hash_insert (ino_t ino, dev_t dev)
|
||||
{
|
||||
struct htab *htab_r = htab; /* Initially a copy of the global `htab'. */
|
||||
|
||||
if (htab_r->first_free_entry >= htab_r->entry_tab_size)
|
||||
for (i = 0; files[i]; i++)
|
||||
{
|
||||
int i;
|
||||
struct entry *ep;
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
char *arg;
|
||||
int s;
|
||||
|
||||
/* Increase the number of hash entries, and re-hash the data.
|
||||
The method of shrimping and increasing is made to compactify
|
||||
the heap. If twice as much data would be allocated
|
||||
straightforwardly, we would never re-use a byte of memory. */
|
||||
arg = files[i];
|
||||
|
||||
/* Let `htab' shrimp. Keep only the header, not the pointer vector. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r, sizeof (struct htab));
|
||||
|
||||
modulus = 2 * htab_r->modulus;
|
||||
entry_tab_size = 2 * htab_r->entry_tab_size;
|
||||
|
||||
/* Increase the number of possible entries. */
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xrealloc ((char *) htab_r->entry_tab,
|
||||
sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
/* Increase the size of htab again. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r,
|
||||
sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
i = htab_r->first_free_entry;
|
||||
|
||||
/* Make the increased hash table empty. The entries are still
|
||||
available in htab->entry_tab. */
|
||||
|
||||
hash_reset ();
|
||||
|
||||
/* Go through the entries and install them in the pointer vector
|
||||
htab->hash. The items are actually inserted in htab->entry_tab at
|
||||
the position where they already are. The htab->coll_link need
|
||||
however be updated. Could be made a little more efficient. */
|
||||
|
||||
for (ep = htab_r->entry_tab; i > 0; i--)
|
||||
/* Delete final slash in the argument, unless the slash is alone. */
|
||||
s = strlen (arg) - 1;
|
||||
if (s != 0)
|
||||
{
|
||||
hash_insert2 (htab_r, ep->ino, ep->dev);
|
||||
ep++;
|
||||
if (arg[s] == '/')
|
||||
arg[s] = 0;
|
||||
|
||||
str_copyc (path, arg);
|
||||
}
|
||||
else if (arg[0] == '/')
|
||||
str_trunc (path, 0); /* Null path for root directory. */
|
||||
else
|
||||
str_copyc (path, arg);
|
||||
|
||||
if (!opt_combined_arguments)
|
||||
hash_reset ();
|
||||
|
||||
count_entry (arg, 1, 0, 0);
|
||||
|
||||
/* chdir if `count_entry' has changed the working directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
{
|
||||
if (restore_cwd (&cwd, _("starting directory"), NULL))
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
return hash_insert2 (htab_r, ino, dev);
|
||||
if (opt_combined_arguments)
|
||||
print_size (tot_size, _("total"));
|
||||
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
|
||||
/* Insert INO and DEV in the hash structure HTAB, if not
|
||||
already present. Return zero if inserted and nonzero if it
|
||||
already existed. */
|
||||
|
||||
static int
|
||||
hash_insert2 (struct htab *ht, ino_t ino, dev_t dev)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &ht->hash[ino % ht->modulus];
|
||||
ep2 = *hp;
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
int max_depth_specified = 0;
|
||||
|
||||
/* Collision? */
|
||||
/* If nonzero, display only a total for each argument. */
|
||||
int opt_summarize_only = 0;
|
||||
|
||||
if (ep2 != NULL)
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
ep = ep2;
|
||||
|
||||
/* Search for an entry with the same data. */
|
||||
|
||||
do
|
||||
long int tmp_long;
|
||||
switch (c)
|
||||
{
|
||||
if (ep->ino == ino && ep->dev == dev)
|
||||
return 1; /* Found an entry with the same data. */
|
||||
ep = ep->coll_link;
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
opt_all = 1;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
opt_combined_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3: /* --max-depth=N */
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > INT_MAX)
|
||||
error (1, 0, _("invalid maximum depth `%s'"), optarg);
|
||||
|
||||
max_depth_specified = 1;
|
||||
max_depth = (int) tmp_long;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
opt_count_all = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
opt_summarize_only = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
opt_one_file_system = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
opt_dereference_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
xstat = stat;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
opt_separate_dirs = 1;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
if (add_exclude_file (exclude, optarg, '\n') != 0)
|
||||
error (1, errno, "%s", optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
add_exclude (exclude, optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
while (ep != NULL);
|
||||
|
||||
/* Did not find it. */
|
||||
|
||||
}
|
||||
|
||||
ep = *hp = &ht->entry_tab[ht->first_free_entry++];
|
||||
ep->ino = ino;
|
||||
ep->dev = dev;
|
||||
ep->coll_link = ep2; /* `ep2' is NULL if no collision. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize string S1 to hold SIZE characters. */
|
||||
|
||||
static void
|
||||
str_init (String **s1, unsigned int size)
|
||||
{
|
||||
String *s;
|
||||
|
||||
s = (String *) xmalloc (sizeof (struct String));
|
||||
s->text = xmalloc (size + 1);
|
||||
|
||||
s->alloc = size;
|
||||
*s1 = s;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_space (String *s, unsigned int size)
|
||||
{
|
||||
if (s->alloc < size)
|
||||
if (opt_all && opt_summarize_only)
|
||||
{
|
||||
s->text = xrealloc (s->text, size + 1);
|
||||
s->alloc = size;
|
||||
error (0, 0, _("cannot both summarize and show all entries"));
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign the null-terminated C-string CSTR to S1. */
|
||||
|
||||
static void
|
||||
str_copyc (String *s1, char *cstr)
|
||||
{
|
||||
unsigned l = strlen (cstr);
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
static void
|
||||
str_concatc (String *s1, char *cstr)
|
||||
{
|
||||
unsigned l1 = s1->length;
|
||||
unsigned l2 = strlen (cstr);
|
||||
unsigned l = l1 + l2;
|
||||
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text + l1, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
/* Truncate the string S1 to have length LENGTH. */
|
||||
|
||||
static void
|
||||
str_trunc (String *s1, unsigned int length)
|
||||
{
|
||||
if (s1->length > length)
|
||||
if (opt_summarize_only && max_depth_specified && max_depth == 0)
|
||||
{
|
||||
s1->text[length] = 0;
|
||||
s1->length = length;
|
||||
error (0, 0,
|
||||
_("warning: summarizing is the same as using --max-depth=0"));
|
||||
}
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth != 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing conflicts with --max-depth=%d"),
|
||||
max_depth);
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (opt_summarize_only)
|
||||
max_depth = 0;
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
|
||||
str_init (&path, INITIAL_PATH_SIZE);
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
10
src/echo.c
10
src/echo.c
@@ -1,5 +1,5 @@
|
||||
/* echo.c, derived from code echo.c in Bash.
|
||||
Copyright (C) 87,89,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 87,89, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +21,11 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "echo"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
/* echo [-neE] [arg ...]
|
||||
Output the ARGs. If -n is specified, the trailing newline is
|
||||
suppressed. If the -e option is given, interpretation of the
|
||||
@@ -114,7 +119,8 @@ main (int argc, char **argv)
|
||||
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, "echo", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
else
|
||||
allow_options = 0;
|
||||
|
||||
|
||||
26
src/env.c
26
src/env.c
@@ -86,6 +86,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "env"
|
||||
|
||||
#define AUTHORS "Richard Mlynarik and David MacKenzie"
|
||||
|
||||
int putenv ();
|
||||
|
||||
extern char **environ;
|
||||
@@ -93,18 +98,12 @@ extern char **environ;
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"ignore-environment", no_argument, NULL, 'i'},
|
||||
{"unset", required_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -157,20 +156,13 @@ main (register int argc, register char **argv, char **envp)
|
||||
break;
|
||||
case 'u':
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (2);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("env (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "-"))
|
||||
ignore_environment = 1;
|
||||
|
||||
|
||||
28
src/expand.c
28
src/expand.c
@@ -1,5 +1,5 @@
|
||||
/* expand - convert tabs to spaces
|
||||
Copyright (C) 89, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -41,6 +41,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expand"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The number of bytes added at a time to the amount of memory
|
||||
allocated for the output line. */
|
||||
#define OUTPUT_BLOCK 256
|
||||
@@ -83,18 +88,12 @@ static int have_read_stdin;
|
||||
/* Status to return to the system. */
|
||||
static int exit_status;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"tabs", required_argument, NULL, 't'},
|
||||
{"initial", no_argument, NULL, 'i'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -359,6 +358,8 @@ main (int argc, char **argv)
|
||||
add_tabstop (tabval);
|
||||
tabval = -1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
if (tabval == -1)
|
||||
tabval = 0;
|
||||
@@ -367,15 +368,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("expand (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
add_tabstop (tabval);
|
||||
|
||||
validate_tabstops (tab_list, first_free_tab);
|
||||
|
||||
10
src/expr.c
10
src/expr.c
@@ -1,5 +1,5 @@
|
||||
/* expr -- evaluate expressions.
|
||||
Copyright (C) 86,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -37,6 +37,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expr"
|
||||
|
||||
#define AUTHORS "Mike Parker"
|
||||
|
||||
#define NEW(type) ((type *) xmalloc (sizeof (type)))
|
||||
#define OLD(x) free ((char *) x)
|
||||
|
||||
@@ -167,7 +172,8 @@ main (int argc, char **argv)
|
||||
|
||||
/* Recognize --help or --version only if POSIXLY_CORRECT is not set. */
|
||||
if (!posixly_correct)
|
||||
parse_long_options (argc, argv, "expr", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
|
||||
37
src/factor.c
37
src/factor.c
@@ -1,5 +1,5 @@
|
||||
/* factor -- print factors of n. lose if n > 2^32.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
/* factor -- print factors of n.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,8 +28,14 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "human.h"
|
||||
#include "readtokens.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "factor"
|
||||
|
||||
#define AUTHORS "Paul Rubin"
|
||||
|
||||
/* Token delimiters when reading from a file. */
|
||||
#define DELIM "\n\t "
|
||||
@@ -71,9 +77,9 @@ Print factors of each NUMBER; read standard input with no arguments.\n\
|
||||
/* FIXME: comment */
|
||||
|
||||
static int
|
||||
factor (long unsigned int n0, int max_n_factors, long unsigned int *factors)
|
||||
factor (uintmax_t n0, int max_n_factors, uintmax_t *factors)
|
||||
{
|
||||
register unsigned long n = n0, d, q;
|
||||
register uintmax_t n = n0, d, q;
|
||||
int n_factors = 0;
|
||||
|
||||
if (n < 1)
|
||||
@@ -123,20 +129,21 @@ factor (long unsigned int n0, int max_n_factors, long unsigned int *factors)
|
||||
static int
|
||||
print_factors (const char *s)
|
||||
{
|
||||
unsigned long int factors[MAX_N_FACTORS];
|
||||
unsigned long n;
|
||||
uintmax_t factors[MAX_N_FACTORS];
|
||||
uintmax_t n;
|
||||
int n_factors;
|
||||
int i;
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
|
||||
if (xstrtoul (s, NULL, 10, &n, "") != LONGINT_OK)
|
||||
if (xstrtoumax (s, NULL, 10, &n, "") != 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);
|
||||
printf ("%s:", human_readable (n, buf, 1, 1));
|
||||
for (i = 0; i < n_factors; i++)
|
||||
printf (" %lu", factors[i]);
|
||||
printf (" %s", human_readable (factors[i], buf, 1, 1));
|
||||
putchar ('\n');
|
||||
return 0;
|
||||
}
|
||||
@@ -174,7 +181,15 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "factor", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle `--' here. */
|
||||
if (argc > 1 && STREQ (argv[1], "--"))
|
||||
{
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
fail = 0;
|
||||
if (argc == 1)
|
||||
|
||||
34
src/fmt.c
34
src/fmt.c
@@ -1,5 +1,5 @@
|
||||
/* GNU fmt -- simple text formatter.
|
||||
Copyright (C) 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +30,11 @@
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fmt"
|
||||
|
||||
#define AUTHORS "Ross Paterson"
|
||||
|
||||
/* The following parameters represent the program's idea of what is
|
||||
"best". Adjust to taste, subject to the caveats given. */
|
||||
|
||||
@@ -164,12 +169,6 @@ static void put_space PARAMS ((int space));
|
||||
/* The name this program was run with. */
|
||||
const char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help = 0;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version = 0;
|
||||
|
||||
/* Option values. */
|
||||
|
||||
/* If TRUE, first 2 lines may have different indent (default FALSE). */
|
||||
@@ -297,13 +296,13 @@ In -wNUMBER, the letter `w' may be omitted.\n"),
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{"crown-margin", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"prefix", required_argument, NULL, 'p'},
|
||||
{"split-only", no_argument, NULL, 's'},
|
||||
{"tagged-paragraph", no_argument, NULL, 't'},
|
||||
{"uniform-spacing", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -380,17 +379,12 @@ main (register int argc, register char **argv)
|
||||
set_prefix (optarg);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fmt (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
best_width = max_width * (2 * (100 - LEEWAY) + 1) / 200;
|
||||
|
||||
if (optind == argc)
|
||||
@@ -410,10 +404,10 @@ main (register int argc, register char **argv)
|
||||
{
|
||||
fmt (in_stream);
|
||||
if (fclose (in_stream) == EOF)
|
||||
error (EXIT_FAILURE, errno, file);
|
||||
error (EXIT_FAILURE, errno, "%s", file);
|
||||
}
|
||||
else
|
||||
error (0, errno, file);
|
||||
error (0, errno, "%s", file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
src/fold.c
32
src/fold.c
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,8 +24,13 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fold"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -39,19 +44,13 @@ static int count_bytes;
|
||||
/* If nonzero, at least one of the files we read was standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", no_argument, NULL, 'b'},
|
||||
{"spaces", no_argument, NULL, 's'},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -286,20 +285,15 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fold (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc == optind)
|
||||
errs |= fold_file ("-", width);
|
||||
else
|
||||
|
||||
66
src/head.c
66
src/head.c
@@ -1,5 +1,5 @@
|
||||
/* head -- output first part of file(s)
|
||||
Copyright (C) 89, 90, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,11 +31,13 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "xstrtol.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* FIXME: someday, make this really *be* `long long'. */
|
||||
typedef long int U_LONG_LONG;
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "head"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* Number of lines/chars/blocks to head. */
|
||||
#define DEFAULT_NUMBER 10
|
||||
@@ -58,12 +60,6 @@ char *program_name;
|
||||
/* Have we ever read standard input? */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"bytes", required_argument, NULL, 'c'},
|
||||
@@ -71,8 +67,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"silent", no_argument, NULL, 'q'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -119,7 +115,7 @@ write_header (const char *filename)
|
||||
}
|
||||
|
||||
static int
|
||||
head_bytes (const char *filename, int fd, U_LONG_LONG bytes_to_write)
|
||||
head_bytes (const char *filename, int fd, uintmax_t bytes_to_write)
|
||||
{
|
||||
char buffer[BUFSIZE];
|
||||
int bytes_read;
|
||||
@@ -147,18 +143,18 @@ head_bytes (const char *filename, int fd, U_LONG_LONG bytes_to_write)
|
||||
}
|
||||
|
||||
static int
|
||||
head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
|
||||
head_lines (const char *filename, int fd, uintmax_t lines_to_write)
|
||||
{
|
||||
char buffer[BUFSIZE];
|
||||
int bytes_read;
|
||||
int bytes_to_write;
|
||||
|
||||
/* Need BINARY I/O for the byte counts to be accurate. */
|
||||
SET_BINARY2 (fd, fileno (stdout));
|
||||
|
||||
while (lines_to_write)
|
||||
{
|
||||
bytes_read = safe_read (fd, buffer, BUFSIZE);
|
||||
int bytes_read = safe_read (fd, buffer, BUFSIZE);
|
||||
int bytes_to_write = 0;
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
error (0, errno, "%s", filename);
|
||||
@@ -166,7 +162,6 @@ head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
|
||||
}
|
||||
if (bytes_read == 0)
|
||||
break;
|
||||
bytes_to_write = 0;
|
||||
while (bytes_to_write < bytes_read)
|
||||
if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0)
|
||||
break;
|
||||
@@ -177,7 +172,7 @@ head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
|
||||
}
|
||||
|
||||
static int
|
||||
head (const char *filename, int fd, U_LONG_LONG n_units, int count_lines)
|
||||
head (const char *filename, int fd, uintmax_t n_units, int count_lines)
|
||||
{
|
||||
if (count_lines)
|
||||
return head_lines (filename, fd, n_units);
|
||||
@@ -186,7 +181,7 @@ head (const char *filename, int fd, U_LONG_LONG n_units, int count_lines)
|
||||
}
|
||||
|
||||
static int
|
||||
head_file (const char *filename, U_LONG_LONG n_units, int count_lines)
|
||||
head_file (const char *filename, uintmax_t n_units, int count_lines)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -222,13 +217,13 @@ head_file (const char *filename, U_LONG_LONG n_units, int count_lines)
|
||||
COUNT_LINES indicates whether N_STRING is a number of bytes or a number
|
||||
of lines. It is used solely to give a more specific diagnostic. */
|
||||
|
||||
static U_LONG_LONG
|
||||
string_to_ull (int count_lines, const char *n_string)
|
||||
static uintmax_t
|
||||
string_to_integer (int count_lines, const char *n_string)
|
||||
{
|
||||
strtol_error s_err;
|
||||
unsigned long int tmp_ulong;
|
||||
uintmax_t n;
|
||||
|
||||
s_err = xstrtoul (n_string, NULL, 0, &tmp_ulong, "bkm");
|
||||
s_err = xstrtoumax (n_string, NULL, 0, &n, "bkm");
|
||||
|
||||
if (s_err == LONGINT_INVALID)
|
||||
{
|
||||
@@ -245,7 +240,7 @@ string_to_ull (int count_lines, const char *n_string)
|
||||
count_lines ? _("number of lines") : _("number of bytes"));
|
||||
}
|
||||
|
||||
return tmp_ulong;
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -257,7 +252,7 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
|
||||
/* Number of items to print. */
|
||||
U_LONG_LONG n_units = DEFAULT_NUMBER;
|
||||
uintmax_t n_units = DEFAULT_NUMBER;
|
||||
|
||||
/* If nonzero, interpret the numeric argument as the number of lines.
|
||||
Otherwise, interpret it as the number of bytes. */
|
||||
@@ -331,7 +326,7 @@ main (int argc, char **argv)
|
||||
if (multiplier_char)
|
||||
*(++end_n_string) = 0;
|
||||
|
||||
n_units = string_to_ull (count_lines, n_string);
|
||||
n_units = string_to_integer (count_lines, n_string);
|
||||
|
||||
/* Make the options we just parsed invisible to getopt. */
|
||||
argv[1] = argv[0];
|
||||
@@ -351,12 +346,12 @@ main (int argc, char **argv)
|
||||
|
||||
case 'c':
|
||||
count_lines = 0;
|
||||
n_units = string_to_ull (count_lines, optarg);
|
||||
n_units = string_to_integer (count_lines, optarg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
count_lines = 1;
|
||||
n_units = string_to_ull (count_lines, optarg);
|
||||
n_units = string_to_integer (count_lines, optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
@@ -367,20 +362,15 @@ main (int argc, char **argv)
|
||||
header_mode = always;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("head (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (header_mode == always
|
||||
|| (header_mode == multiple_files && optind < argc - 1))
|
||||
print_headers = 1;
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostid"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
@@ -63,7 +68,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "hostid", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hostname - set or print the name of current host system
|
||||
Copyright (C) 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostname"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
#if !defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) && \
|
||||
defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)
|
||||
# include <sys/systeminfo.h>
|
||||
@@ -82,7 +87,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "hostname", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
#ifdef HAVE_SETHOSTNAME
|
||||
if (argc == 2)
|
||||
@@ -92,7 +98,7 @@ main (int argc, char **argv)
|
||||
/* Set hostname to argv[1]. */
|
||||
err = sethostname (argv[1], strlen (argv[1]));
|
||||
if (err != 0)
|
||||
error (1, errno, "%s", argv[1]);
|
||||
error (1, errno, _("cannot set hostname to `%s'"), argv[1]);
|
||||
exit (0);
|
||||
}
|
||||
#else
|
||||
|
||||
53
src/id.c
53
src/id.c
@@ -29,6 +29,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "id"
|
||||
|
||||
#define AUTHORS "Arnold Robbins and David MacKenzie"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwuid ();
|
||||
struct group *getgrgid ();
|
||||
@@ -40,8 +45,8 @@ gid_t getegid ();
|
||||
|
||||
int getugroups ();
|
||||
|
||||
static void print_user PARAMS ((int uid));
|
||||
static void print_group PARAMS ((int gid));
|
||||
static void print_user PARAMS ((uid_t uid));
|
||||
static void print_group PARAMS ((gid_t gid));
|
||||
static void print_group_list PARAMS ((const char *username));
|
||||
static void print_full_info PARAMS ((const char *username));
|
||||
|
||||
@@ -70,21 +75,15 @@ static gid_t rgid, egid;
|
||||
/* The number of errors encountered so far. */
|
||||
static int problems = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"group", no_argument, NULL, 'g'},
|
||||
{"groups", no_argument, NULL, 'G'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"name", no_argument, NULL, 'n'},
|
||||
{"real", no_argument, NULL, 'r'},
|
||||
{"user", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -150,20 +149,13 @@ main (int argc, char **argv)
|
||||
case 'G':
|
||||
just_group_list = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("id (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (just_user + just_group + just_group_list > 1)
|
||||
error (1, 0, _("cannot print only user and only group"));
|
||||
|
||||
@@ -205,7 +197,7 @@ main (int argc, char **argv)
|
||||
/* Print the name or value of user ID UID. */
|
||||
|
||||
static void
|
||||
print_user (int uid)
|
||||
print_user (uid_t uid)
|
||||
{
|
||||
struct passwd *pwd = NULL;
|
||||
|
||||
@@ -225,7 +217,7 @@ print_user (int uid)
|
||||
/* Print the name or value of group ID GID. */
|
||||
|
||||
static void
|
||||
print_group (int gid)
|
||||
print_group (gid_t gid)
|
||||
{
|
||||
struct group *grp = NULL;
|
||||
|
||||
@@ -244,8 +236,11 @@ print_group (int gid)
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
|
||||
/* FIXME: document */
|
||||
|
||||
static int
|
||||
xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
xgetgroups (const char *username, gid_t gid, int *n_groups,
|
||||
GETGROUPS_T **groups)
|
||||
{
|
||||
int max_n_groups;
|
||||
int ng;
|
||||
@@ -255,14 +250,14 @@ xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
if (username == 0)
|
||||
max_n_groups = getgroups (0, NULL);
|
||||
else
|
||||
max_n_groups = getugroups (0, NULL, username);
|
||||
max_n_groups = getugroups (0, NULL, username, gid);
|
||||
|
||||
/* 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);
|
||||
ng = getugroups (max_n_groups, g, username, gid);
|
||||
|
||||
if (ng < 0)
|
||||
{
|
||||
@@ -285,6 +280,12 @@ xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
static void
|
||||
print_group_list (const char *username)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
||||
pwd = getpwuid (ruid);
|
||||
if (pwd == NULL)
|
||||
problems++;
|
||||
|
||||
print_group (rgid);
|
||||
if (egid != rgid)
|
||||
{
|
||||
@@ -298,7 +299,7 @@ print_group_list (const char *username)
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
if (xgetgroups (username, pwd ? pwd->pw_gid : -1, &n_groups, &groups))
|
||||
{
|
||||
++problems;
|
||||
return;
|
||||
@@ -363,7 +364,7 @@ print_full_info (const char *username)
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
if (xgetgroups (username, pwd ? pwd->pw_gid : -1, &n_groups, &groups))
|
||||
{
|
||||
++problems;
|
||||
return;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user