mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
443 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72e1d14aec | ||
|
|
584f4d85cf | ||
|
|
9096ee8e42 | ||
|
|
f7c0efdba2 | ||
|
|
a3c0837bc3 | ||
|
|
834b042b93 | ||
|
|
f0e77e8722 | ||
|
|
5c094d2ab2 | ||
|
|
1eb146483f | ||
|
|
1b3c2bbb06 | ||
|
|
edbbc8335c | ||
|
|
48405e4b9c | ||
|
|
f9ae8064f2 | ||
|
|
9ce9d75ddb | ||
|
|
d59ce5651c | ||
|
|
981c203fab | ||
|
|
c0385fb129 | ||
|
|
ac88b78ef3 | ||
|
|
e01fce9e16 | ||
|
|
164bff8dc0 | ||
|
|
7b7b9007db | ||
|
|
c0ad97a781 | ||
|
|
c5a9a5f563 | ||
|
|
b363124be4 | ||
|
|
d06d2de67c | ||
|
|
82f324a6fd | ||
|
|
84f0e8fc80 | ||
|
|
9a27c21fbf | ||
|
|
1fff978392 | ||
|
|
4d87b9a10e | ||
|
|
8fd24dfea9 | ||
|
|
9355314687 | ||
|
|
5c6991f93d | ||
|
|
9e9d7be706 | ||
|
|
49b81671fd | ||
|
|
38429fe661 | ||
|
|
ce0ba9e9d9 | ||
|
|
5b3b5af5b8 | ||
|
|
6a2cf8a297 | ||
|
|
22fd1ff303 | ||
|
|
cb1386ec32 | ||
|
|
da2761cc1a | ||
|
|
1fc1a65968 | ||
|
|
b6f403c606 | ||
|
|
fa59cde3fe | ||
|
|
6f7507be50 | ||
|
|
33df2fe237 | ||
|
|
87c3c9c7c6 | ||
|
|
e622324cbe | ||
|
|
99114dd25a | ||
|
|
e29225aa01 | ||
|
|
8bfd3a7d70 | ||
|
|
f9abdd4a47 | ||
|
|
c7f7a81276 | ||
|
|
f721219e91 | ||
|
|
ded46c159b | ||
|
|
9cc2f64ff3 | ||
|
|
ae3a2c75ff | ||
|
|
24fa66e128 | ||
|
|
b6a0fe5ab0 | ||
|
|
da190d7c06 | ||
|
|
ddd448d549 | ||
|
|
71bd321379 | ||
|
|
93449adfa4 | ||
|
|
21041064bd | ||
|
|
f5443ca875 | ||
|
|
eb771bb870 | ||
|
|
43589db615 | ||
|
|
04a86ff23a | ||
|
|
b32c1f0696 | ||
|
|
94d7c5b58c | ||
|
|
0cb7d9a409 | ||
|
|
81bb7f1df3 | ||
|
|
7fc3b4cf7d | ||
|
|
cef050f076 | ||
|
|
919b805380 | ||
|
|
0e48a577b5 | ||
|
|
b0ead8f2d6 | ||
|
|
5614a7d282 | ||
|
|
9c5fb99864 | ||
|
|
1145211d6b | ||
|
|
0c35411a4f | ||
|
|
8bd9ea509e | ||
|
|
bddb246b90 | ||
|
|
e646635206 | ||
|
|
ea9e600f58 | ||
|
|
78c34dee50 | ||
|
|
56949aaebd | ||
|
|
18d7d6b082 | ||
|
|
0cb75a1a07 | ||
|
|
cc271ce8f3 | ||
|
|
bf73df9811 | ||
|
|
b07a5a108e | ||
|
|
2db8ef7c55 | ||
|
|
634ff11428 | ||
|
|
c3b1ab8af1 | ||
|
|
327a21114a | ||
|
|
df91781926 | ||
|
|
4431579378 | ||
|
|
19afd110b3 | ||
|
|
5b02046b20 | ||
|
|
97a44fbdf0 | ||
|
|
49d59ad66b | ||
|
|
c2bbdeab6d | ||
|
|
0d33861999 | ||
|
|
9c38d004ec | ||
|
|
a302182ac8 | ||
|
|
6b0411ab47 | ||
|
|
65ce4687f5 | ||
|
|
363847ca74 | ||
|
|
d223f01b43 | ||
|
|
3a2b528573 | ||
|
|
14717b8618 | ||
|
|
dc8cd6e39a | ||
|
|
6db0107e71 | ||
|
|
a6f74451d3 | ||
|
|
8d2302724c | ||
|
|
8fa35e89ca | ||
|
|
baad4b697c | ||
|
|
79d411ceba | ||
|
|
52070d3e4a | ||
|
|
85cc6dedf8 | ||
|
|
e3869f58ad | ||
|
|
c34fd6b4a7 | ||
|
|
63d64851b1 | ||
|
|
d68269bb55 | ||
|
|
2aa62088a3 | ||
|
|
f2d4fc8016 | ||
|
|
bf57f4af46 | ||
|
|
dc43a7bb60 | ||
|
|
9d7c2d4f7d | ||
|
|
888da5c359 | ||
|
|
7b0caffd31 | ||
|
|
ed2a7b4e53 | ||
|
|
2a6a20ae20 | ||
|
|
1dce9a3295 | ||
|
|
f6da9983e4 | ||
|
|
e6bc93f49a | ||
|
|
88c0b8d630 | ||
|
|
669ff7331b | ||
|
|
54667de765 | ||
|
|
736ea546d9 | ||
|
|
461aea548a | ||
|
|
e31691fc1d | ||
|
|
8e576e0036 | ||
|
|
b9fa91a205 | ||
|
|
ff438ee87f | ||
|
|
34cd17408c | ||
|
|
138bad1512 | ||
|
|
f0604f17d6 | ||
|
|
3fce6c3270 | ||
|
|
ba36aa0602 | ||
|
|
58a54666a7 | ||
|
|
40178d3a77 | ||
|
|
b9ca4fe720 | ||
|
|
c6afbb198c | ||
|
|
c267424d7b | ||
|
|
053a0e3a8e | ||
|
|
39b1c602aa | ||
|
|
2df9108f70 | ||
|
|
a2d2353f0d | ||
|
|
6af7fe7bf9 | ||
|
|
26abcd14d2 | ||
|
|
2fe9a639e5 | ||
|
|
f1db42afed | ||
|
|
2d329c22c0 | ||
|
|
c3db9f982a | ||
|
|
c01e767ceb | ||
|
|
0d16e71b07 | ||
|
|
2fcce776e8 | ||
|
|
bad1e4b2e1 | ||
|
|
f5a228ae42 | ||
|
|
a40eb86598 | ||
|
|
0136b885fe | ||
|
|
0f7ac75854 | ||
|
|
9fc5987250 | ||
|
|
e71d9696d7 | ||
|
|
6e1306ba8b | ||
|
|
a607901e48 | ||
|
|
01053400d0 | ||
|
|
419b2d26fe | ||
|
|
4ed33b3073 | ||
|
|
ef9ee27d89 | ||
|
|
277da1b998 | ||
|
|
983b8c433c | ||
|
|
d5c69ef797 | ||
|
|
eb8ea6eac5 | ||
|
|
da68f39411 | ||
|
|
2fcc1267b5 | ||
|
|
4ead0cb8df | ||
|
|
f96dc5e195 | ||
|
|
82e166ebbb | ||
|
|
6a9aa3cf98 | ||
|
|
3cf7eece6f | ||
|
|
7dfff499c3 | ||
|
|
52e2de5780 | ||
|
|
c0d6757201 | ||
|
|
3942f87ee3 | ||
|
|
9d07c1872f | ||
|
|
be388d139c | ||
|
|
6e132bee5e | ||
|
|
7d63d3c635 | ||
|
|
08d53c4c6a | ||
|
|
94edd792f7 | ||
|
|
5ab6986171 | ||
|
|
25176dbdef | ||
|
|
b49807bfb2 | ||
|
|
d71367f33e | ||
|
|
bd85887daf | ||
|
|
82988e97cf | ||
|
|
2b374ec2d9 | ||
|
|
3e3b8558d6 | ||
|
|
5c4cb177ef | ||
|
|
71a3fc7989 | ||
|
|
5c9345dbd1 | ||
|
|
287ddc8d05 | ||
|
|
36ac5f1519 | ||
|
|
bde54af30f | ||
|
|
cafbd3477a | ||
|
|
165718775f | ||
|
|
f90d1551cb | ||
|
|
613f0e187f | ||
|
|
ca6da4ffce | ||
|
|
ac517dbe89 | ||
|
|
3ae3622d9e | ||
|
|
27682ba5ce | ||
|
|
8dd3e53122 | ||
|
|
d1187d36da | ||
|
|
0f85045bb3 | ||
|
|
69835e9fb6 | ||
|
|
3ba948db7e | ||
|
|
d1f9e2315b | ||
|
|
d04604664a | ||
|
|
4e9a99dd9a | ||
|
|
3f3df4e600 | ||
|
|
27e780fe97 | ||
|
|
122d3f15ae | ||
|
|
bb3fca40db | ||
|
|
91c40bd499 | ||
|
|
0f4fcb1fbd | ||
|
|
3fbc98bb54 | ||
|
|
240b9c0f89 | ||
|
|
fc13bb65df | ||
|
|
27f3ca3d5a | ||
|
|
f1a7e03bbe | ||
|
|
8d58cbb99e | ||
|
|
3b87431a69 | ||
|
|
d09816b054 | ||
|
|
19c23eefb7 | ||
|
|
ef8d2acace | ||
|
|
f7d6ece6e4 | ||
|
|
90a63a16ec | ||
|
|
ec7ec3773f | ||
|
|
a97f821233 | ||
|
|
b15e832f4d | ||
|
|
e77a16efec | ||
|
|
7fd7c6465e | ||
|
|
7fc23ef625 | ||
|
|
1bd7deb235 | ||
|
|
f2dd2f10c1 | ||
|
|
1af4f2f11d | ||
|
|
1703d0d59c | ||
|
|
7ac1d190bc | ||
|
|
0c3c6b1b0b | ||
|
|
01c3ff5a1e | ||
|
|
1b03d98f62 | ||
|
|
b294d530d4 | ||
|
|
75b6b90fe1 | ||
|
|
7613946ac6 | ||
|
|
5b16f997e8 | ||
|
|
ee041d6d4f | ||
|
|
f89f495c0d | ||
|
|
5e3e9e7a15 | ||
|
|
8d4d2c4cf4 | ||
|
|
36de2ed1e2 | ||
|
|
f42b337a0b | ||
|
|
6cdd12a9f2 | ||
|
|
a0ec87fbf9 | ||
|
|
5c71306463 | ||
|
|
da69105424 | ||
|
|
1ea1c0864c | ||
|
|
a4e98775a4 | ||
|
|
5017930f13 | ||
|
|
73b7370917 | ||
|
|
bca292d9e6 | ||
|
|
6e3b675ea8 | ||
|
|
95efa0587b | ||
|
|
e49ef588db | ||
|
|
5823a999fe | ||
|
|
218c464b91 | ||
|
|
3cc80de466 | ||
|
|
52fa9ac235 | ||
|
|
9b809393be | ||
|
|
610567e17f | ||
|
|
ad4e506e0f | ||
|
|
4475ffda48 | ||
|
|
1b23f5094d | ||
|
|
02f917c543 | ||
|
|
60a6e7be26 | ||
|
|
8133377948 | ||
|
|
1df5503ccf | ||
|
|
e9a5c7551c | ||
|
|
adfde62439 | ||
|
|
4b05962106 | ||
|
|
df142feab8 | ||
|
|
b2aff777b1 | ||
|
|
b793f241f4 | ||
|
|
ad22b83e45 | ||
|
|
c71fc5f18e | ||
|
|
3e13b5e49d | ||
|
|
8f55e63084 | ||
|
|
2eb479a682 | ||
|
|
ec65e39e6f | ||
|
|
bedf44ba83 | ||
|
|
0cb0cc4e2f | ||
|
|
aee16a6664 | ||
|
|
93d47b3db9 | ||
|
|
18c222c5b5 | ||
|
|
bb01a24be5 | ||
|
|
1ccc979847 | ||
|
|
ad1d74e973 | ||
|
|
0142ca7d96 | ||
|
|
bcfa9cbbd7 | ||
|
|
6c93489171 | ||
|
|
345c323ffd | ||
|
|
1f682431ae | ||
|
|
698a43f363 | ||
|
|
def9c2bf0b | ||
|
|
6191d1839a | ||
|
|
184870f9bb | ||
|
|
6ccae5e2d8 | ||
|
|
31f6e2b228 | ||
|
|
d05618c5c2 | ||
|
|
7a314199db | ||
|
|
837a447ba4 | ||
|
|
5d2bbddf97 | ||
|
|
6dda2aaa52 | ||
|
|
3fa1d4bb24 | ||
|
|
1c84606b56 | ||
|
|
b1b273f24f | ||
|
|
e211d3960f | ||
|
|
9282f5f8a6 | ||
|
|
1d2074e02a | ||
|
|
8dce8df49a | ||
|
|
4d4b2c8e5e | ||
|
|
a72bab1a32 | ||
|
|
affbb977af | ||
|
|
aa1c5467ec | ||
|
|
435fa5a7dd | ||
|
|
b7441176e3 | ||
|
|
f3c14cb59f | ||
|
|
8ba97d963e | ||
|
|
223e88f957 | ||
|
|
83d4b736d2 | ||
|
|
257c5c4737 | ||
|
|
391c960cba | ||
|
|
62f208d493 | ||
|
|
60ae0b81a5 | ||
|
|
09d344df5b | ||
|
|
43f4099c95 | ||
|
|
476cb02516 | ||
|
|
159788fcca | ||
|
|
f32dc5a2b0 | ||
|
|
ea7102f120 | ||
|
|
41ef62c472 | ||
|
|
26d5ce2f26 | ||
|
|
868ed3b0af | ||
|
|
6552bb980b | ||
|
|
79a6760fe4 | ||
|
|
531453d901 | ||
|
|
1d94869663 | ||
|
|
ce195c7a07 | ||
|
|
09a2261919 | ||
|
|
c5eb9edf26 | ||
|
|
dd9470cb58 | ||
|
|
02fc5fa0d0 | ||
|
|
b62793b100 | ||
|
|
c7af539321 | ||
|
|
e989012b57 | ||
|
|
7aeda9a4d3 | ||
|
|
d51682ef43 | ||
|
|
ab869ed00e | ||
|
|
73ab48d4e7 | ||
|
|
73e6d60538 | ||
|
|
032aecf5e7 | ||
|
|
8f3524de4a | ||
|
|
439fdff851 | ||
|
|
933b990ab9 | ||
|
|
ae965a958a | ||
|
|
214ee5aecd | ||
|
|
4dc12acc27 | ||
|
|
a92dd43b7c | ||
|
|
d2698caef3 | ||
|
|
db8fe3cf1f | ||
|
|
664ba0841c | ||
|
|
26d84b6c70 | ||
|
|
70c8aaf873 | ||
|
|
182a1780ac | ||
|
|
cf430d3590 | ||
|
|
6ae99a4290 | ||
|
|
c76172fbb0 | ||
|
|
dd040b917a | ||
|
|
4ec1fad4e7 | ||
|
|
9d9fef5595 | ||
|
|
6fd3c331ba | ||
|
|
9b989298f4 | ||
|
|
07507c07da | ||
|
|
c96968a2a3 | ||
|
|
a3e1200b4a | ||
|
|
2b2424aab8 | ||
|
|
994c3c82ef | ||
|
|
dfc86db1cc | ||
|
|
162f6824cf | ||
|
|
feccdc6c58 | ||
|
|
2f617e52d6 | ||
|
|
d200f4974b | ||
|
|
de45950430 | ||
|
|
4d95aa356f | ||
|
|
d82af243b1 | ||
|
|
2781ec69b7 | ||
|
|
4a9222e0c2 | ||
|
|
84c104b6da | ||
|
|
500594433a | ||
|
|
ed1fdb8841 | ||
|
|
5d59e18618 | ||
|
|
94ff35fc2d | ||
|
|
dc6658157d | ||
|
|
36fc028151 | ||
|
|
6db9dc96d3 | ||
|
|
7af859841f | ||
|
|
dcfb3e037a | ||
|
|
bc63f10b59 | ||
|
|
ce42a622b2 | ||
|
|
5cd15e8abb | ||
|
|
c685d1c4cb | ||
|
|
cc13b3d81f | ||
|
|
f23d890626 | ||
|
|
e7976515e2 | ||
|
|
25485fa497 | ||
|
|
ab4ea710f1 | ||
|
|
39f78131e2 | ||
|
|
75637a7ef4 | ||
|
|
9e1c89c38e |
@@ -42,3 +42,39 @@ my-distcheck: dist
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
echo "========================"
|
||||
|
||||
THIS_VERSION_REGEXP := $(shell echo $(VERSION)|sed 's/\./\\./g')
|
||||
# FIXME: this works only for test releases.
|
||||
PREV_VERSION := $(shell echo $(VERSION)|tr a-z Xa-y)
|
||||
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
|
||||
v = Version
|
||||
url = ftp://alpha.gnu.org/gnu/$(distdir).tar.gz
|
||||
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
|
||||
rel-check:
|
||||
tarz=/tmp/rel-check-tarz-$$$$; \
|
||||
md5_tmp=/tmp/rel-check-md5-$$$$; \
|
||||
set -e; \
|
||||
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
|
||||
wget -q --output-document=$$tarz $(url); \
|
||||
echo "$(md5) -" > $$md5_tmp; \
|
||||
md5sum -c $$md5_tmp < $$tarz
|
||||
|
||||
announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
@( \
|
||||
echo Subject: $(distdir) released; \
|
||||
echo; \
|
||||
echo FIXME: put comments here; \
|
||||
echo; \
|
||||
echo " $(url)"; \
|
||||
echo; \
|
||||
echo "$(md5) $(distdir).tar.gz"; \
|
||||
echo; \
|
||||
echo NEWS:; \
|
||||
sed -n "/$(THIS_VERSION_REGEXP)/,/$(PREV_VERSION_REGEXP)/p" NEWS \
|
||||
| grep -v '^\['; \
|
||||
echo; \
|
||||
echo ChangeLog entries:; \
|
||||
sed -n "/$v $(THIS_VERSION_REGEXP)/,/$v $(PREV_VERSION_REGEXP)/p" \
|
||||
ChangeLog | grep -v '\* $v'; \
|
||||
)
|
||||
|
||||
6
THANKS
6
THANKS
@@ -3,21 +3,26 @@ The rest of the addresses are still in the ChangeLog.
|
||||
|
||||
Achim Blumensath: blume@corona.oche.de
|
||||
Andreas Schwab: schwab@issan.informatik.uni-dortmund.de
|
||||
Andries Brouwer: Andries.Brouwer@cwi.nl
|
||||
Arne Henrik Juul: arnej@imf.unit.no
|
||||
Bauke Jan Douma: bjdouma@xs4all.nl
|
||||
Bengt Martensson: bengt@mathematik.uni-Bremen.de
|
||||
Bjorn Helgaas: helgaas@rsn.hp.com
|
||||
Charles Karney: karney@pppl.gov
|
||||
Christian von Roques: roques@pond.sub.org
|
||||
Dirk Lattermann: dlatt@t-online.de
|
||||
Don Parsons: dparsons@synapse.kent.edu
|
||||
Eirik Fuller: eirik@netcom.com
|
||||
Eli Zaretskii: eliz@is.elta.co.il
|
||||
Emile LeBlanc: leblanc@math.toronto.edu
|
||||
François Pinard: pinard@iro.umontreal.ca
|
||||
Galen Hazelwood: galenh@micron.net
|
||||
Göran Uddeborg: goeran@uddeborg.pp.se
|
||||
Greg McGary: gkm@eng.ascend.com
|
||||
Hugh Daniel: hugh@xanadu.com
|
||||
James: james@albion.glarp.com
|
||||
James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Tanis: jtt@soscorp.com
|
||||
Jesse Thilo: jgt2@eecs.lehigh.edu
|
||||
Joakim Rosqvist: dvljrt@cs.umu.se
|
||||
John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th
|
||||
@@ -31,6 +36,7 @@ Masami Takikawa: takikawm@CS.ORST.EDU
|
||||
Matthew S. Levine: mslevine@theory.lcs.mit.edu
|
||||
Miles Bader: miles@gnu.ai.mit.edu
|
||||
Noel Cragg: noel@red-bean.com
|
||||
Olav Morkrid: olav@funcom.com
|
||||
Peter Eriksson: peter@ifm.liu.se
|
||||
Paul Eggert: eggert@twinsun.com
|
||||
Philippe De Muyter: phdm@macqel.be
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
|
||||
@@ -35,6 +35,7 @@ START-INFO-DIR-ENTRY
|
||||
* od: (textutils)od invocation. Dump files in octal, etc.
|
||||
* paste: (textutils)paste invocation. Merge lines of files.
|
||||
* pr: (textutils)pr invocation. Paginate or columnate files.
|
||||
* ptx: (textutils)ptx invocation. Produce permuted indexes.
|
||||
* sort: (textutils)sort invocation. Sort text files.
|
||||
* split: (textutils)split invocation. Split into fixed-size pieces.
|
||||
* sum: (textutils)sum invocation. Print traditional checksum.
|
||||
@@ -117,12 +118,89 @@ This manual documents version @value{VERSION} of the GNU text utilities.
|
||||
* Formatting file contents:: fmt pr fold
|
||||
* Output of parts of files:: head tail split csplit
|
||||
* Summarizing files:: wc sum cksum md5sum
|
||||
* Operating on sorted files:: sort uniq comm
|
||||
* Operating on sorted files:: sort uniq comm ptx
|
||||
* Operating on fields within a line:: cut paste join
|
||||
* Operating on characters:: tr expand unexpand
|
||||
* Opening the software toolbox:: The software tools philosophy.
|
||||
* Index:: General index.
|
||||
|
||||
@detailmenu
|
||||
--- The Detailed Node Listing ---
|
||||
|
||||
Output of entire files
|
||||
|
||||
* cat invocation:: Concatenate and write files.
|
||||
* tac invocation:: Concatenate and write files in reverse.
|
||||
* nl invocation:: Number lines and write files.
|
||||
* od invocation:: Write files in octal or other formats.
|
||||
|
||||
Formatting file contents
|
||||
|
||||
* fmt invocation:: Reformat paragraph text.
|
||||
* pr invocation:: Paginate or columnate files for printing.
|
||||
* fold invocation:: Wrap input lines to fit in specified width.
|
||||
|
||||
Output of parts of files
|
||||
|
||||
* head invocation:: Output the first part of files.
|
||||
* tail invocation:: Output the last part of files.
|
||||
* split invocation:: Split a file into fixed-size pieces.
|
||||
* csplit invocation:: Split a file into context-determined pieces.
|
||||
|
||||
Summarizing files
|
||||
|
||||
* wc invocation:: Print byte, word, and line counts.
|
||||
* sum invocation:: Print checksum and block counts.
|
||||
* cksum invocation:: Print CRC checksum and byte counts.
|
||||
* md5sum invocation:: Print or check message-digests.
|
||||
|
||||
Operating on sorted files
|
||||
|
||||
* sort invocation:: Sort text files.
|
||||
* uniq invocation:: Uniqify files.
|
||||
* comm invocation:: Compare two sorted files line by line.
|
||||
* ptx invocation:: Produce a permuted index of file contents.
|
||||
|
||||
@code{ptx}: Produce permuted indexes
|
||||
|
||||
* General options in ptx:: Options which affect general program behaviour.
|
||||
* 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.
|
||||
* Compatibility in ptx:: The GNU extensions to @code{ptx}
|
||||
|
||||
Operating on fields within a line
|
||||
|
||||
* cut invocation:: Print selected parts of lines.
|
||||
* paste invocation:: Merge lines of files.
|
||||
* join invocation:: Join lines on a common field.
|
||||
|
||||
Operating on characters
|
||||
|
||||
* tr invocation:: Translate, squeeze, and/or delete characters.
|
||||
* expand invocation:: Convert tabs to spaces.
|
||||
* unexpand invocation:: Convert spaces to tabs.
|
||||
|
||||
@code{tr}: Translate, squeeze, and/or delete characters
|
||||
|
||||
* Character sets:: Specifying sets of characters.
|
||||
* Translating:: Changing one characters to another.
|
||||
* Squeezing:: Squeezing repeats and deleting.
|
||||
* Warnings in tr:: Warning messages.
|
||||
|
||||
Opening the software toolbox
|
||||
|
||||
* Toolbox introduction:: Toolbox introduction
|
||||
* I/O redirection:: I/O redirection
|
||||
* The who command:: The @code{who} command
|
||||
* The cut command:: The @code{cut} command
|
||||
* The sort command:: The @code{sort} command
|
||||
* The uniq command:: The @code{uniq} command
|
||||
* Putting the tools together:: Putting the tools together
|
||||
|
||||
@end detailmenu
|
||||
@end menu
|
||||
|
||||
@end ifinfo
|
||||
|
||||
|
||||
@@ -872,10 +950,12 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@table @samp
|
||||
|
||||
@item +@var{first_page}[@var{:last_page}]
|
||||
@opindex +@var{first_page}[@var{:last_page}]
|
||||
@item +@var{first_page}[:@var{last_page}]
|
||||
@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{:LAST_PAGE} implies end of file. While
|
||||
@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
|
||||
@@ -883,7 +963,9 @@ first page of input file (not first page printed). Page 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
|
||||
@@ -892,24 +974,32 @@ 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.
|
||||
|
||||
@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.
|
||||
|
||||
@item -c
|
||||
@itemx --show-control-chars
|
||||
@opindex -c
|
||||
@opindex --show-control-chars
|
||||
Print control characters using hat notation (e.g., @samp{^G}); print
|
||||
other unprintable characters in octal backslash notation. By default,
|
||||
unprintable characters are not changed.
|
||||
|
||||
@item -d
|
||||
@itemx --double-space
|
||||
@opindex -d
|
||||
@opindex --double-space
|
||||
@cindex double spacing
|
||||
Double space the output.
|
||||
|
||||
@item -e[@var{in-tabchar}[@var{in-tabwidth}]]
|
||||
@itemx --expand-tabs[=@var{in-tabchar}[@var{in-tabwidth}]]
|
||||
@opindex -e
|
||||
@opindex --expand-tabs
|
||||
@cindex input tabs
|
||||
Expand tabs to spaces on input. Optional argument @var{in-tabchar} is
|
||||
the input tab character (default is @key{TAB}). Second optional
|
||||
@@ -918,15 +1008,19 @@ is 8).
|
||||
|
||||
@item -f
|
||||
@itemx -F
|
||||
@itemx --form-feed
|
||||
@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.
|
||||
|
||||
|
||||
@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}
|
||||
@@ -935,7 +1029,9 @@ header. Don't use @samp{-h""}. A space between the -h option and the
|
||||
argument is always peremptory.
|
||||
|
||||
@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}
|
||||
is the output tab character (default is @key{TAB}). Second optional
|
||||
@@ -943,7 +1039,9 @@ argument @var{out-tabwidth} is the output tab character's width (default
|
||||
is 8).
|
||||
|
||||
@item -j
|
||||
@itemx --join-lines
|
||||
@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
|
||||
@@ -951,14 +1049,18 @@ Merge lines of full length. Used together with the 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.
|
||||
|
||||
@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
|
||||
@@ -970,7 +1072,9 @@ line numbers. The default header becomes
|
||||
|
||||
|
||||
@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
|
||||
@@ -980,12 +1084,16 @@ first line of the input file (not with the first line printed, see
|
||||
@samp{-N}).
|
||||
|
||||
@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.
|
||||
|
||||
@item -o @var{n}
|
||||
@itemx --indent=@var{n}
|
||||
@opindex -o
|
||||
@opindex --indent
|
||||
@cindex indenting lines
|
||||
@cindex left margin
|
||||
Indent each line with @var{n} (default is zero) spaces wide, i.e., set
|
||||
@@ -993,12 +1101,16 @@ the left margin. The total page width is @var{n} plus the width set
|
||||
with the @samp{-w} option.
|
||||
|
||||
@item -r
|
||||
@itemx --no-file-warnings
|
||||
@opindex -r
|
||||
@opindex --no-file-warnings
|
||||
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}]
|
||||
@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
|
||||
@@ -1007,7 +1119,9 @@ option is omitted altogether, the default is @key{TAB} together with
|
||||
does not affect line truncation or column alignment.
|
||||
|
||||
@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
|
||||
@@ -1017,16 +1131,22 @@ useful together with other options; e.g.: @samp{-t -e4}, expand
|
||||
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
|
||||
set in the input files.
|
||||
|
||||
@item -v
|
||||
@itemx --show-nonprinting
|
||||
@opindex -v
|
||||
@opindex --show-nonprinting
|
||||
Print unprintable characters in octal backslash notation.
|
||||
|
||||
@item -w @var{page_width}
|
||||
@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,
|
||||
@@ -1738,6 +1858,7 @@ These commands work with (or produce) sorted files.
|
||||
* sort invocation:: Sort text files.
|
||||
* uniq invocation:: Uniqify files.
|
||||
* comm invocation:: Compare two sorted files line by line.
|
||||
* ptx invocation::
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -2188,6 +2309,469 @@ Upon normal completion @code{comm} produces an exit code of zero.
|
||||
If there is an error it exits with nonzero status.
|
||||
|
||||
|
||||
@node ptx invocation
|
||||
@section @code{ptx}: Produce permuted indexes
|
||||
|
||||
@pindex ptx
|
||||
|
||||
@code{ptx} reads a text file and essentially produces a permuted index, with
|
||||
each keyword in its context. The calling sketch is either one of:
|
||||
|
||||
@example
|
||||
ptx [@var{option} @dots{}] [@var{file} @dots{}]
|
||||
ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]]
|
||||
@end example
|
||||
|
||||
The @samp{-G} (or its equivalent: @samp{--traditional}) option disables
|
||||
all GNU extensions and revert to traditional mode, thus introducing some
|
||||
limitations, and changes several of the program's default option values.
|
||||
When @samp{-G} is not specified, GNU extensions are always enabled. GNU
|
||||
extensions to @code{ptx} are documented wherever appropriate in this
|
||||
document. See @xref{Compatibility in ptx} for an explicit list of them.
|
||||
|
||||
Individual options are explained in incoming sections.
|
||||
|
||||
When GNU extensions are enabled, there may be zero, one or several
|
||||
@var{file} after the options. If there is no @var{file}, the program
|
||||
reads the standard input. If there is one or several @var{file}, they
|
||||
give the name of input files which are all read in turn, as if all the
|
||||
input files were concatenated. However, there is a full contextual
|
||||
break between each file and, when automatic referencing is requested,
|
||||
file names and line numbers refer to individual text input files. In
|
||||
all cases, the program produces the permuted index onto the standard
|
||||
output.
|
||||
|
||||
When GNU extensions are @emph{not} enabled, that is, when the program
|
||||
operates in traditional mode, there may be zero, one or two parameters
|
||||
besides the options. If there is no parameters, the program reads the
|
||||
standard input and produces the permuted index onto the standard output.
|
||||
If there is only one parameter, it names the text @var{input} to be read
|
||||
instead of the standard input. If two parameters are given, they give
|
||||
respectively the name of the @var{input} file to read and the name of
|
||||
the @var{output} file to produce. @emph{Be very careful} to note that,
|
||||
in this case, the contents of file given by the second parameter is
|
||||
destroyed. This behaviour is dictated only by System V @code{ptx}
|
||||
compatibility, because GNU Standards discourage output parameters not
|
||||
introduced by an option.
|
||||
|
||||
Note that for @emph{any} file named as the value of an option or as an
|
||||
input text file, a single dash @kbd{-} may be used, in which case
|
||||
standard input is assumed. However, it would not make sense to use this
|
||||
convention more than once per program invocation.
|
||||
|
||||
@menu
|
||||
* General options in ptx:: Options which affect general program behaviour.
|
||||
* 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.
|
||||
* Compatibility in ptx::
|
||||
@end menu
|
||||
|
||||
|
||||
@node General options in ptx
|
||||
@subsection General options
|
||||
|
||||
@table @code
|
||||
|
||||
@item -C
|
||||
@itemx --copyright
|
||||
Prints a short note about the Copyright and copying conditions, then
|
||||
exit without further processing.
|
||||
|
||||
@item -G
|
||||
@itemx --traditional
|
||||
As already explained, this option disables all GNU extensions to
|
||||
@code{ptx} and switch to traditional mode.
|
||||
|
||||
@item --help
|
||||
Prints a short help on standard output, then exit without further
|
||||
processing.
|
||||
|
||||
@item --version
|
||||
Prints the program verison on standard output, then exit without further
|
||||
processing.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Charset selection in ptx
|
||||
@subsection Charset selection
|
||||
|
||||
As it is setup now, the program assumes that the input file is coded
|
||||
using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
|
||||
@emph{unless} if it is compiled for MS-DOS, in which case it uses the
|
||||
character set of the IBM-PC. (GNU @code{ptx} is not known to work on
|
||||
smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of
|
||||
characters which are letters is then different, this fact alters the
|
||||
behaviour of regular expression matching. Thus, the default regular
|
||||
expression for a keyword allows foreign or diacriticized letters.
|
||||
Keyword sorting, however, is still crude; it obeys the underlying
|
||||
character set ordering quite blindly.
|
||||
|
||||
@table @code
|
||||
|
||||
@item -f
|
||||
@itemx --ignore-case
|
||||
Fold lower case letters to upper case for sorting.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Input processing in ptx
|
||||
@subsection Word selection and input processing
|
||||
|
||||
@table @code
|
||||
|
||||
@item -b @var{file}
|
||||
@item --break-file=@var{file}
|
||||
|
||||
This option is an alternative way to option @code{-W} for describing
|
||||
which characters make up words. This option introduces the name of a
|
||||
file which contains a list of characters which can@emph{not} be part of
|
||||
one word, this file is called the @dfn{Break file}. Any character which
|
||||
is not part of the Break file is a word constituent. If both options
|
||||
@code{-b} and @code{-W} are specified, then @code{-W} has precedence and
|
||||
@code{-b} is ignored.
|
||||
|
||||
When GNU extensions are enabled, the only way to avoid newline as a
|
||||
break character is to write all the break characters in the file with no
|
||||
newline at all, not even at the end of the file. When GNU extensions
|
||||
are disabled, spaces, tabs and newlines are always considered as break
|
||||
characters even if not included in the Break file.
|
||||
|
||||
@item -i @var{file}
|
||||
@itemx --ignore-file=@var{file}
|
||||
|
||||
The file associated with this option contains a list of words which will
|
||||
never be taken as keywords in concordance output. It is called the
|
||||
@dfn{Ignore file}. The file contains exactly one word in each line; the
|
||||
end of line separation of words is not subject to the value of the
|
||||
@code{-S} option.
|
||||
|
||||
There is a default Ignore file used by @code{ptx} when this option is
|
||||
not specified, usually found in @file{/usr/local/lib/eign} if this has
|
||||
not been changed at installation time. If you want to deactivate the
|
||||
default Ignore file, specify @code{/dev/null} instead.
|
||||
|
||||
@item -o @var{file}
|
||||
@itemx --only-file=@var{file}
|
||||
|
||||
The file associated with this option contains a list of words which will
|
||||
be retained in concordance output, any word not mentioned in this file
|
||||
is ignored. The file is called the @dfn{Only file}. The file contains
|
||||
exactly one word in each line; the end of line separation of words is
|
||||
not subject to the value of the @code{-S} option.
|
||||
|
||||
There is no default for the Only file. In the case there are both an
|
||||
Only file and an Ignore file, a word will be subject to be a keyword
|
||||
only if it is given in the Only file and not given in the Ignore file.
|
||||
|
||||
@item -r
|
||||
@itemx --references
|
||||
|
||||
On each input line, the leading sequence of non white characters will be
|
||||
taken to be a reference that has the purpose of identifying this input
|
||||
line on the produced permuted index. See @xref{Output formatting in ptx} for
|
||||
more information about reference production. Using this option change
|
||||
the default value for option @code{-S}.
|
||||
|
||||
Using this option, the program does not try very hard to remove
|
||||
references from contexts in output, but it succeeds in doing so
|
||||
@emph{when} the context ends exactly at the newline. If option
|
||||
@code{-r} is used with @code{-S} default value, or when GNU extensions
|
||||
are disabled, this condition is always met and references are completely
|
||||
excluded from the output contexts.
|
||||
|
||||
@item -S @var{regexp}
|
||||
@itemx --sentence-regexp=@var{regexp}
|
||||
|
||||
This option selects which regular expression will describe the end of a
|
||||
line or the end of a sentence. In fact, there is other distinction
|
||||
between end of lines or end of sentences than the effect of this regular
|
||||
expression, and input line boundaries have no special significance
|
||||
outside this option. By default, when GNU extensions are enabled and if
|
||||
@code{-r} option is not used, end of sentences are used. In this
|
||||
case, the precise @var{regex} is imported from GNU emacs:
|
||||
|
||||
@example
|
||||
[.?!][]\"')@}]*\\($\\|\t\\| \\)[ \t\n]*
|
||||
@end example
|
||||
|
||||
Whenever GNU extensions are disabled or if @code{-r} option is used, end
|
||||
of lines are used; in this case, the default @var{regexp} is just:
|
||||
|
||||
@example
|
||||
\n
|
||||
@end example
|
||||
|
||||
Using an empty REGEXP is equivalent to completely disabling end of line or end
|
||||
of sentence recognition. In this case, the whole file is considered to
|
||||
be a single big line or sentence. The user might want to disallow all
|
||||
truncation flag generation as well, through option @code{-F ""}.
|
||||
@xref{Regexps, , Syntax of Regular Expressions, emacs, The GNU Emacs
|
||||
Manual}.
|
||||
|
||||
When the keywords happen to be near the beginning of the input line or
|
||||
sentence, this often creates an unused area at the beginning of the
|
||||
output context line; when the keywords happen to be near the end of the
|
||||
input line or sentence, this often creates an unused area at the end of
|
||||
the output context line. The program tries to fill those unused areas
|
||||
by wrapping around context in them; the tail of the input line or
|
||||
sentence is used to fill the unused area on the left of the output line;
|
||||
the head of the input line or sentence is used to fill the unused area
|
||||
on the right of the output line.
|
||||
|
||||
As a matter of convenience to the user, many usual backslashed escape
|
||||
sequences, as found in the C language, are recognized and converted to
|
||||
the corresponding characters by @code{ptx} itself.
|
||||
|
||||
@item -W @var{regexp}
|
||||
@itemx --word-regexp=@var{regexp}
|
||||
|
||||
This option selects which regular expression will describe each keyword.
|
||||
By default, if GNU extensions are enabled, a word is a sequence of
|
||||
letters; the @var{regexp} used is @code{\w+}. When GNU extensions are
|
||||
disabled, a word is by default anything which ends with a space, a tab
|
||||
or a newline; the @var{regexp} used is @code{[^ \t\n]+}.
|
||||
|
||||
An empty REGEXP is equivalent to not using this option, letting the
|
||||
default dive in. @xref{Regexps, , Syntax of Regular Expressions, emacs,
|
||||
The GNU Emacs Manual}.
|
||||
|
||||
As a matter of convenience to the user, many usual backslashed escape
|
||||
sequences, as found in the C language, are recognized and converted to
|
||||
the corresponding characters by @code{ptx} itself.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Output formatting in ptx
|
||||
@subsection Output formatting
|
||||
|
||||
Output format is mainly controlled by @code{-O} and @code{-T} options,
|
||||
described in the table below. When neither @code{-O} nor @code{-T} is
|
||||
selected, and if GNU extensions are enabled, the program choose an
|
||||
output format suited for a dumb terminal. Each keyword occurrence is
|
||||
output to the center of one line, surrounded by its left and right
|
||||
contexts. Each field is properly justified, so the concordance output
|
||||
could readily be observed. As a special feature, if automatic
|
||||
references are selected by option @code{-A} and are output before the
|
||||
left context, that is, if option @code{-R} is @emph{not} selected, then
|
||||
a colon is added after the reference; this nicely interfaces with GNU
|
||||
Emacs @code{next-error} processing. In this default output format, each
|
||||
white space character, like newline and tab, is merely changed to
|
||||
exactly one space, with no special attempt to compress consecutive
|
||||
spaces. This might change in the future. Except for those white space
|
||||
characters, every other character of the underlying set of 256
|
||||
characters is transmitted verbatim.
|
||||
|
||||
Output format is further controlled by the following options.
|
||||
|
||||
@table @code
|
||||
|
||||
@item -g @var{number}
|
||||
@itemx --gap-size=@var{number}
|
||||
|
||||
Select the size of the minimum white gap between the fields on the output
|
||||
line.
|
||||
|
||||
@item -w @var{number}
|
||||
@itemx --width=@var{number}
|
||||
|
||||
Select the output maximum width of each final line. If references are
|
||||
used, they are included or excluded from the output maximum width
|
||||
depending on the value of option @code{-R}. If this option is not
|
||||
selected, that is, when references are output before the left context,
|
||||
the output maximum width takes into account the maximum length of all
|
||||
references. If this options is selected, that is, when references are
|
||||
output after the right context, the output maximum width does not take
|
||||
into account the space taken by references, nor the gap that precedes
|
||||
them.
|
||||
|
||||
@item -A
|
||||
@itemx --auto-reference
|
||||
|
||||
Select automatic references. Each input line will have an automatic
|
||||
reference made up of the file name and the line ordinal, with a single
|
||||
colon between them. However, the file name will be empty when standard
|
||||
input is being read. If both @code{-A} and @code{-r} are selected, then
|
||||
the input reference is still read and skipped, but the automatic
|
||||
reference is used at output time, overriding the input reference.
|
||||
|
||||
@item -R
|
||||
@itemx --right-side-refs
|
||||
|
||||
In default output format, when option @code{-R} is not used, any
|
||||
reference produced by the effect of options @code{-r} or @code{-A} are
|
||||
given to the far right of output lines, after the right context. In
|
||||
default output format, when option @code{-R} is specified, references
|
||||
are rather given to the beginning of each output line, before the left
|
||||
context. For any other output format, option @code{-R} is almost
|
||||
ignored, except for the fact that the width of references is @emph{not}
|
||||
taken into account in total output width given by @code{-w} whenever
|
||||
@code{-R} is selected.
|
||||
|
||||
This option is automatically selected whenever GNU extensions are
|
||||
disabled.
|
||||
|
||||
@item -F @var{string}
|
||||
@itemx --flac-truncation=@var{string}
|
||||
|
||||
This option will request that any truncation in the output be reported
|
||||
using the string @var{string}. Most output fields theoretically extend
|
||||
towards the beginning or the end of the current line, or current
|
||||
sentence, as selected with option @code{-S}. But there is a maximum
|
||||
allowed output line width, changeable through option @code{-w}, which is
|
||||
further divided into space for various output fields. When a field has
|
||||
to be truncated because cannot extend until the beginning or the end of
|
||||
the current line to fit in the, then a truncation occurs. By default,
|
||||
the string used is a single slash, as in @code{-F /}.
|
||||
|
||||
@var{string} may have more than one character, as in @code{-F ...}.
|
||||
Also, in the particular case @var{string} is empty (@code{-F ""}),
|
||||
truncation flagging is disabled, and no truncation marks are appended in
|
||||
this case.
|
||||
|
||||
As a matter of convenience to the user, many usual backslashed escape
|
||||
sequences, as found in the C language, are recognized and converted to
|
||||
the corresponding characters by @code{ptx} itself.
|
||||
|
||||
@item -M @var{string}
|
||||
@itemx --macro-name=@var{string}
|
||||
|
||||
Select another @var{string} to be used instead of @samp{xx}, while
|
||||
generating output suitable for @code{nroff}, @code{troff} or @TeX{}.
|
||||
|
||||
@item -O
|
||||
@itemx --format=roff
|
||||
|
||||
Choose an output format suitable for @code{nroff} or @code{troff}
|
||||
processing. Each output line will look like:
|
||||
|
||||
@example
|
||||
.xx "@var{tail}" "@var{before}" "@var{keyword_and_after}" "@var{head}" "@var{ref}"
|
||||
@end example
|
||||
|
||||
so it will be possible to write an @samp{.xx} roff macro to take care of
|
||||
the output typesetting. This is the default output format when GNU
|
||||
extensions are disabled. Option @samp{-M} might be used to change
|
||||
@samp{xx} to another macro name.
|
||||
|
||||
In this output format, each non-graphical character, like newline and
|
||||
tab, is merely changed to exactly one space, with no special attempt to
|
||||
compress consecutive spaces. Each quote character: @kbd{"} is doubled
|
||||
so it will be correctly processed by @code{nroff} or @code{troff}.
|
||||
|
||||
@item -T
|
||||
@itemx --format=tex
|
||||
|
||||
Choose an output format suitable for @TeX{} processing. Each output
|
||||
line will look like:
|
||||
|
||||
@example
|
||||
\xx @{@var{tail}@}@{@var{before}@}@{@var{keyword}@}@{@var{after}@}@{@var{head}@}@{@var{ref}@}
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
so it will be possible to write write a @code{\xx} definition to take
|
||||
care of the output typesetting. Note that when references are not being
|
||||
produced, that is, neither option @code{-A} nor option @code{-r} is
|
||||
selected, the last parameter of each @code{\xx} call is inhibited.
|
||||
Option @samp{-M} might be used to change @samp{xx} to another macro
|
||||
name.
|
||||
|
||||
In this output format, some special characters, like @kbd{$}, @kbd{%},
|
||||
@kbd{&}, @kbd{#} and @kbd{_} are automatically protected with a
|
||||
backslash. Curly brackets @kbd{@{}, @kbd{@}} are also protected with a
|
||||
backslash, but also enclosed in a pair of dollar signs to force
|
||||
mathematical mode. The backslash itself produces the sequence
|
||||
@code{\backslash@{@}}. Circumflex and tilde diacritics produce the
|
||||
sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other
|
||||
diacriticized characters of the underlying character set produce an
|
||||
appropriate @TeX{} sequence as far as possible. The other non-graphical
|
||||
characters, like newline and tab, and all others characters which are
|
||||
not part of ASCII, are merely changed to exactly one space, with no
|
||||
special attempt to compress consecutive spaces. Let me know how to
|
||||
improve this special character processing for @TeX{}.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Compatibility in ptx
|
||||
@subsection The GNU extensions to @code{ptx}
|
||||
|
||||
This version of @code{ptx} contains a few features which do not exist in
|
||||
System V @code{ptx}. These extra features are suppressed by using the
|
||||
@samp{-G} command line option, unless overridden by other command line
|
||||
options. Some GNU extensions cannot be recovered by overriding, so the
|
||||
simple rule is to avoid @samp{-G} if you care about GNU extensions.
|
||||
Here are the differences between this program and System V @code{ptx}.
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
This program can read many input files at once, it always writes the
|
||||
resulting concordance on standard output. On the other end, System V
|
||||
@code{ptx} reads only one file and produce the result on standard output
|
||||
or, if a second @var{file} parameter is given on the command, to that
|
||||
@var{file}.
|
||||
|
||||
Having output parameters not introduced by options is a quite dangerous
|
||||
practice which GNU avoids as far as possible. So, for using @code{ptx}
|
||||
portably between GNU and System V, you should pay attention to always
|
||||
use it with a single input file, and always expect the result on
|
||||
standard output. You might also want to automatically configure in a
|
||||
@samp{-G} option to @code{ptx} calls in products using @code{ptx}, if
|
||||
the configurator finds that the installed @code{ptx} accepts @samp{-G}.
|
||||
|
||||
@item
|
||||
The only options available in System V @code{ptx} are options @samp{-b},
|
||||
@samp{-f}, @samp{-g}, @samp{-i}, @samp{-o}, @samp{-r}, @samp{-t} and
|
||||
@samp{-w}. All other options are GNU extensions and are not repeated in
|
||||
this enumeration. Moreover, some options have a slightly different
|
||||
meaning when GNU extensions are enabled, as explained below.
|
||||
|
||||
@item
|
||||
By default, concordance output is not formatted for @code{troff} or
|
||||
@code{nroff}. It is rather formatted for a dumb terminal. @code{troff}
|
||||
or @code{nroff} output may still be selected through option @code{-O}.
|
||||
|
||||
@item
|
||||
Unless @code{-R} option is used, the maximum reference width is
|
||||
subtracted from the total output line width. With GNU extensions
|
||||
disabled, width of references is not taken into account in the output
|
||||
line width computations.
|
||||
|
||||
@item
|
||||
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.
|
||||
|
||||
@item
|
||||
Input line length is only limited by available memory, even if GNU
|
||||
extensions are disabled. However, System V @code{ptx} processes only
|
||||
the first 200 characters in each line.
|
||||
|
||||
@item
|
||||
The break (non-word) characters default to be every character except all
|
||||
letters of the underlying character set, diacriticized or not. When GNU
|
||||
extensions are disabled, the break characters default to space, tab and
|
||||
newline only.
|
||||
|
||||
@item
|
||||
The program makes better use of output line width. If GNU extensions
|
||||
are disabled, the program rather tries to imitate System V @code{ptx},
|
||||
but still, there are some slight disposition glitches this program does
|
||||
not completely reproduce.
|
||||
|
||||
@item
|
||||
The user can specify both an Ignore file and an Only file. This is not
|
||||
allowed with System V @code{ptx}.
|
||||
|
||||
@end itemize
|
||||
|
||||
|
||||
@node Operating on fields within a line
|
||||
@chapter Operating on fields within a line
|
||||
|
||||
@@ -2845,7 +3429,6 @@ ones, to tabs.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@c What's GNU?
|
||||
@c Arnold Robbins
|
||||
@node Opening the software toolbox
|
||||
@@ -2856,13 +3439,13 @@ number 2, in the @cite{What's GNU?} column. It was written by Arnold
|
||||
Robbins.
|
||||
|
||||
@menu
|
||||
* Toolbox introduction::
|
||||
* I/O redirection::
|
||||
* The who command::
|
||||
* The cut command::
|
||||
* The sort command::
|
||||
* The uniq command::
|
||||
* Putting the tools together::
|
||||
* Toolbox introduction:: Toolbox introduction
|
||||
* I/O redirection:: I/O redirection
|
||||
* The who command:: The @code{who} command
|
||||
* The cut command:: The @code{cut} command
|
||||
* The sort command:: The @code{sort} command
|
||||
* The uniq command:: The @code{uniq} command
|
||||
* Putting the tools together:: Putting the tools together
|
||||
@end menu
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Makefile
|
||||
getdate.c
|
||||
posixtm.c
|
||||
safe-stat.h
|
||||
safe-stat.c
|
||||
safe-lstat.c
|
||||
|
||||
@@ -6,7 +6,7 @@ noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.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 \
|
||||
@@ -18,10 +18,10 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
error.h exclude.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h long-options.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 \
|
||||
quotearg.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
BUILT_SOURCES = getdate.c
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -96,7 +95,7 @@ noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.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 \
|
||||
@@ -108,13 +107,13 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
error.h exclude.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h long-options.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 \
|
||||
quotearg.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
BUILT_SOURCES = getdate.c
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -134,7 +133,6 @@ 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
|
||||
AR = ar
|
||||
YLWRAP = $(srcdir)/ylwrap
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
@@ -144,9 +142,9 @@ 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 posixtm.c realloc.c regex.c regex.h rename.c \
|
||||
rmdir.c rpmatch.c rx.c rx.h stat.c stpcpy.c strcasecmp.c strdup.c \
|
||||
strftime.c strndup.c strstr.c strtol.c strtoul.c strverscmp.c ylwrap
|
||||
obstack.c obstack.h realloc.c regex.c rename.c rmdir.c rpmatch.c stat.c \
|
||||
stpcpy.c strcasecmp.c strdup.c strftime.c strndup.c strstr.c strtol.c \
|
||||
strtoul.c strverscmp.c utime.c ylwrap
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@@ -163,15 +161,14 @@ DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.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 \
|
||||
.deps/posixtm.P .deps/quotearg.P .deps/realloc.P .deps/regex.P \
|
||||
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.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/strndup.P .deps/strstr.P .deps/strtol.P \
|
||||
.deps/strtoul.P .deps/strverscmp.P .deps/userspec.P .deps/xgetcwd.P \
|
||||
.deps/xmalloc.P .deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P \
|
||||
.deps/yesno.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/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
|
||||
SOURCES = $(libfu_a_SOURCES)
|
||||
OBJECTS = $(libfu_a_OBJECTS)
|
||||
|
||||
@@ -232,8 +229,10 @@ libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
|
||||
$(AR) cru libfu.a $(libfu_a_OBJECTS) $(libfu_a_LIBADD)
|
||||
$(RANLIB) libfu.a
|
||||
.y.c:
|
||||
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
|
||||
posixtm.h: posixtm.c
|
||||
$(YACC) $(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
|
||||
|
||||
addext_.c: addext.c $(ANSI2KNR)
|
||||
@@ -332,8 +331,6 @@ rmdir_.c: rmdir.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rmdir.c; then echo $(srcdir)/rmdir.c; else echo rmdir.c; fi` | $(ANSI2KNR) > rmdir_.c
|
||||
rpmatch_.c: rpmatch.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rpmatch.c; then echo $(srcdir)/rpmatch.c; else echo rpmatch.c; fi` | $(ANSI2KNR) > rpmatch_.c
|
||||
rx_.c: rx.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rx.c; then echo $(srcdir)/rx.c; else echo rx.c; fi` | $(ANSI2KNR) > rx_.c
|
||||
safe-read_.c: safe-read.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/safe-read.c; then echo $(srcdir)/safe-read.c; else echo safe-read.c; fi` | $(ANSI2KNR) > safe-read_.c
|
||||
save-cwd_.c: save-cwd.c $(ANSI2KNR)
|
||||
@@ -364,6 +361,8 @@ strverscmp_.c: strverscmp.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/strverscmp.c; then echo $(srcdir)/strverscmp.c; else echo strverscmp.c; fi` | $(ANSI2KNR) > strverscmp_.c
|
||||
userspec_.c: userspec.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/userspec.c; then echo $(srcdir)/userspec.c; else echo userspec.c; fi` | $(ANSI2KNR) > userspec_.c
|
||||
utime_.c: utime.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/utime.c; then echo $(srcdir)/utime.c; else echo utime.c; fi` | $(ANSI2KNR) > utime_.c
|
||||
xgetcwd_.c: xgetcwd.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/xgetcwd.c; then echo $(srcdir)/xgetcwd.c; else echo xgetcwd.c; fi` | $(ANSI2KNR) > xgetcwd_.c
|
||||
xmalloc_.c: xmalloc.c $(ANSI2KNR)
|
||||
@@ -383,11 +382,11 @@ 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 rx_.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 strndup_.o strstr_.o strtol_.o \
|
||||
strtoul_.o strverscmp_.o userspec_.o xgetcwd_.o xmalloc_.o xstrdup_.o \
|
||||
xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
|
||||
strtoul_.o strverscmp_.o userspec_.o utime_.o xgetcwd_.o xmalloc_.o \
|
||||
xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
|
||||
63
lib/bumpalloc.h
Normal file
63
lib/bumpalloc.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* BUMP_ALLOC macro - increase table allocation by one element.
|
||||
Copyright (C) 1990, 1991, 1993, 1998 Free Software Foundation, Inc.
|
||||
François Pinard <pinard@iro.umontreal.ca>, 1990.
|
||||
|
||||
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. */
|
||||
|
||||
/*-------------------------------------------------------------------------.
|
||||
| Bump the allocation of the array pointed to by TABLE whenever required. |
|
||||
| The table already has already COUNT elements in it, this macro ensure it |
|
||||
| has enough space to accommodate at least one more element. Space is |
|
||||
| allocated (2 ^ EXPONENT) elements at a time. Each element of the array |
|
||||
| is of type TYPE. |
|
||||
`-------------------------------------------------------------------------*/
|
||||
|
||||
/* Routines `xmalloc' and `xrealloc' are called to do the actual memory
|
||||
management. This implies that the program will abort with an `Memory
|
||||
exhausted!' error if any problem arise.
|
||||
|
||||
To work correctly, at least EXPONENT and TYPE should always be the
|
||||
same for all uses of this macro for any given TABLE. A secure way to
|
||||
achieve this is to never use this macro directly, but use it to define
|
||||
other macros, which would then be TABLE-specific.
|
||||
|
||||
The first time through, COUNT is usually zero. Note that COUNT is not
|
||||
updated by this macro, but it should be update elsewhere, later. This
|
||||
is convenient, because it allows TABLE[COUNT] to refer to the new
|
||||
element at the end. Once its construction is completed, COUNT++ will
|
||||
record it in the table. Calling this macro several times in a row
|
||||
without updating COUNT is a bad thing to do. */
|
||||
|
||||
#define BUMP_ALLOC(Table, Count, Exponent, Type) \
|
||||
BUMP_ALLOC_WITH_SIZE ((Table), (Count), (Exponent), Type, sizeof (Type))
|
||||
|
||||
/* In cases `sizeof TYPE' would not always yield the correct value for
|
||||
the size of each element entry, this macro accepts a supplementary
|
||||
SIZE argument. The EXPONENT, TYPE and SIZE parameters should still
|
||||
have the same value for all macro calls related to a specific TABLE. */
|
||||
|
||||
#define BUMP_ALLOC_WITH_SIZE(Table, Count, Exponent, Type, Size) \
|
||||
do \
|
||||
{ \
|
||||
if (((Count) & (~(~0 << (Exponent)))) == 0) \
|
||||
{ \
|
||||
if ((Count) == 0) \
|
||||
(Table) = (Type *) xmalloc ((1 << (Exponent)) * (Size)); \
|
||||
else \
|
||||
(Table) = (Type *) \
|
||||
xrealloc ((Table), ((Count) + (1 << (Exponent))) * (Size)); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
148
lib/diacrit.c
Normal file
148
lib/diacrit.c
Normal file
@@ -0,0 +1,148 @@
|
||||
/* Diacritics processing for a few character codes.
|
||||
Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
François Pinard <pinard@iro.umontreal.ca>, 1988.
|
||||
|
||||
All this file is a temporary hack, waiting for locales in GNU.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "diacrit.h"
|
||||
|
||||
/* ISO 8859-1 Latin-1 code is used as the underlying character set. If
|
||||
MSDOS is defined, IBM-PC's character set code is used instead. */
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| For each alphabetic character, returns what it would be without its |
|
||||
| possible diacritic symbol. |
|
||||
`--------------------------------------------------------------------*/
|
||||
|
||||
const char diacrit_base[256] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', 0, 0, 0, 0, 0,
|
||||
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', 0, 0, 0, 0, 0,
|
||||
|
||||
#ifdef MSDOS
|
||||
|
||||
'C', 'u', 'e', 'a', 'a', 'a', 'a', 'c',
|
||||
'e', 'e', 'e', 'i', 'i', 'i', 'A', 'A',
|
||||
'E', 'e', 'E', 'o', 'o', 'o', 'u', 'u',
|
||||
'y', 'O', 'U', 0, 0, 0, 0, 0,
|
||||
'a', 'i', 'o', 'u', 'n', 'N', 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
#else /* not MSDOS */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'C',
|
||||
'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I',
|
||||
0, 'N', 'O', 'O', 'O', 'O', 'O', 0,
|
||||
'O', 'U', 'U', 'U', 'U', 'Y', 0, 0,
|
||||
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c',
|
||||
'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
|
||||
0, 'n', 'o', 'o', 'o', 'o', 'o', 0,
|
||||
'o', 'u', 'u', 'u', 'u', 'y', 0, 'y',
|
||||
|
||||
#endif /* not MSDOS */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------.
|
||||
| For each alphabetic character, returns a code of what its diacritic is, |
|
||||
| according to the following codes: 1 (eE) over aA for latin diphtongs; 2 |
|
||||
| (') acute accent; 3 (`) grave accent; 4 (^) circumflex accent; 5 (") |
|
||||
| umlaut or diaraesis; 6 (~) tilda; 7 (,) cedilla; 8 (o) covering degree |
|
||||
| symbol; 9 (|) slashed character. |
|
||||
`------------------------------------------------------------------------*/
|
||||
|
||||
const char diacrit_diac[256] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 4, 0,
|
||||
3, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 6, 0,
|
||||
|
||||
#ifdef MSDOS
|
||||
|
||||
7, 5, 2, 4, 5, 3, 8, 7,
|
||||
4, 5, 3, 5, 4, 3, 5, 8,
|
||||
2, 1, 1, 4, 5, 3, 4, 3,
|
||||
5, 5, 5, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 6, 6, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
#else /* not MSDOS */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
3, 2, 4, 6, 5, 8, 1, 7,
|
||||
3, 2, 4, 5, 3, 2, 4, 5,
|
||||
0, 6, 3, 2, 4, 6, 5, 0,
|
||||
9, 3, 2, 4, 5, 2, 0, 0,
|
||||
3, 2, 4, 6, 5, 8, 1, 7,
|
||||
3, 2, 4, 5, 3, 2, 4, 5,
|
||||
0, 6, 3, 2, 4, 6, 5, 0,
|
||||
9, 3, 2, 4, 5, 2, 0, 0,
|
||||
|
||||
#endif /* not MSDOS */
|
||||
};
|
||||
16
lib/diacrit.h
Normal file
16
lib/diacrit.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/* Diacritics processing for a few character codes.
|
||||
Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
François Pinard <pinard@iro.umontreal.ca>, 1988.
|
||||
|
||||
All this file is a temporary hack, waiting for locales in GNU.
|
||||
*/
|
||||
|
||||
extern const char diacrit_base[]; /* characters without diacritics */
|
||||
extern const char diacrit_diac[]; /* diacritic code for each character */
|
||||
|
||||
/* Returns CHAR without its diacritic. CHAR is known to be alphabetic. */
|
||||
#define tobase(Char) (diacrit_base[(unsigned char) (Char)])
|
||||
|
||||
/* Returns a diacritic code for CHAR. CHAR is known to be alphabetic. */
|
||||
#define todiac(Char) (diacrit_diac[(unsigned char) (Char)])
|
||||
|
||||
264
lib/filemode.c
264
lib/filemode.c
@@ -22,6 +22,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "filemode.h"
|
||||
|
||||
#if !S_IRUSR
|
||||
# if S_IREAD
|
||||
# define S_IRUSR S_IREAD
|
||||
@@ -88,10 +90,132 @@
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
#endif
|
||||
|
||||
void mode_string ();
|
||||
static char ftypelet ();
|
||||
static void rwx ();
|
||||
static void setst ();
|
||||
/* 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)
|
||||
{
|
||||
#ifdef S_ISUID
|
||||
if (bits & S_ISUID)
|
||||
{
|
||||
if (chars[3] != 'x')
|
||||
/* Set-uid, but not executable by owner. */
|
||||
chars[3] = 'S';
|
||||
else
|
||||
chars[3] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISGID
|
||||
if (bits & S_ISGID)
|
||||
{
|
||||
if (chars[6] != 'x')
|
||||
/* Set-gid, but not executable by group. */
|
||||
chars[6] = 'S';
|
||||
else
|
||||
chars[6] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISVTX
|
||||
if (bits & S_ISVTX)
|
||||
{
|
||||
if (chars[9] != 'x')
|
||||
/* Sticky, but not executable by others. */
|
||||
chars[9] = 'T';
|
||||
else
|
||||
chars[9] = 't';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return a character indicating the type of file described by
|
||||
file mode BITS:
|
||||
'd' for directories
|
||||
'b' for block special files
|
||||
'c' for character special files
|
||||
'm' for multiplexor files
|
||||
'M' for an off-line (regular) file
|
||||
'l' for symbolic links
|
||||
's' for sockets
|
||||
'p' for fifos
|
||||
'-' for regular files
|
||||
'?' for any other file type. */
|
||||
|
||||
static char
|
||||
ftypelet (long int bits)
|
||||
{
|
||||
#ifdef S_ISBLK
|
||||
if (S_ISBLK (bits))
|
||||
return 'b';
|
||||
#endif
|
||||
if (S_ISCHR (bits))
|
||||
return 'c';
|
||||
if (S_ISDIR (bits))
|
||||
return 'd';
|
||||
if (S_ISREG (bits))
|
||||
return '-';
|
||||
#ifdef S_ISFIFO
|
||||
if (S_ISFIFO (bits))
|
||||
return 'p';
|
||||
#endif
|
||||
#ifdef S_ISLNK
|
||||
if (S_ISLNK (bits))
|
||||
return 'l';
|
||||
#endif
|
||||
#ifdef S_ISSOCK
|
||||
if (S_ISSOCK (bits))
|
||||
return 's';
|
||||
#endif
|
||||
#ifdef S_ISMPC
|
||||
if (S_ISMPC (bits))
|
||||
return 'm';
|
||||
#endif
|
||||
#ifdef S_ISNWK
|
||||
if (S_ISNWK (bits))
|
||||
return 'n';
|
||||
#endif
|
||||
|
||||
/* The following two tests are for Cray DMF (Data Migration
|
||||
Facility), which is a HSM file system. A migrated file has a
|
||||
`st_dm_mode' that is different from the normal `st_mode', so any
|
||||
tests for migrated files should use the former. */
|
||||
|
||||
#ifdef S_ISOFD
|
||||
if (S_ISOFD (bits))
|
||||
/* off line, with data */
|
||||
return 'M';
|
||||
#endif
|
||||
#ifdef S_ISOFL
|
||||
/* off line, with no data */
|
||||
if (S_ISOFL (bits))
|
||||
return 'M';
|
||||
#endif
|
||||
return '?';
|
||||
}
|
||||
|
||||
/* Like filemodestring, but only the relevant part of the `struct stat'
|
||||
is given as an argument. */
|
||||
|
||||
void
|
||||
mode_string (short unsigned int 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]);
|
||||
setst (mode, str);
|
||||
}
|
||||
|
||||
/* filemodestring - fill in string STR with an ls-style ASCII
|
||||
representation of the st_mode field of file stats block STATP.
|
||||
@@ -130,137 +254,7 @@ static void setst ();
|
||||
'T' if the file is sticky but not executable. */
|
||||
|
||||
void
|
||||
filemodestring (statp, str)
|
||||
struct stat *statp;
|
||||
char *str;
|
||||
filemodestring (struct stat *statp, char *str)
|
||||
{
|
||||
mode_string (statp->st_mode, str);
|
||||
}
|
||||
|
||||
/* Like filemodestring, but only the relevant part of the `struct stat'
|
||||
is given as an argument. */
|
||||
|
||||
void
|
||||
mode_string (mode, str)
|
||||
unsigned short 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]);
|
||||
setst (mode, str);
|
||||
}
|
||||
|
||||
/* Return a character indicating the type of file described by
|
||||
file mode BITS:
|
||||
'd' for directories
|
||||
'b' for block special files
|
||||
'c' for character special files
|
||||
'm' for multiplexor files
|
||||
'l' for symbolic links
|
||||
's' for sockets
|
||||
'p' for fifos
|
||||
'-' for regular files
|
||||
'?' for any other file type. */
|
||||
|
||||
static char
|
||||
ftypelet (bits)
|
||||
long bits;
|
||||
{
|
||||
#ifdef S_ISBLK
|
||||
if (S_ISBLK (bits))
|
||||
return 'b';
|
||||
#endif
|
||||
if (S_ISCHR (bits))
|
||||
return 'c';
|
||||
if (S_ISDIR (bits))
|
||||
return 'd';
|
||||
if (S_ISREG (bits))
|
||||
return '-';
|
||||
#ifdef S_ISFIFO
|
||||
if (S_ISFIFO (bits))
|
||||
return 'p';
|
||||
#endif
|
||||
#ifdef S_ISLNK
|
||||
if (S_ISLNK (bits))
|
||||
return 'l';
|
||||
#endif
|
||||
#ifdef S_ISSOCK
|
||||
if (S_ISSOCK (bits))
|
||||
return 's';
|
||||
#endif
|
||||
#ifdef S_ISMPC
|
||||
if (S_ISMPC (bits))
|
||||
return 'm';
|
||||
#endif
|
||||
#ifdef S_ISNWK
|
||||
if (S_ISNWK (bits))
|
||||
return 'n';
|
||||
#endif
|
||||
|
||||
#ifdef S_ISOFD
|
||||
/* Cray migrated dmf file. */
|
||||
if (S_ISOFD (bits))
|
||||
return 'M';
|
||||
#endif
|
||||
#ifdef S_ISOFL
|
||||
/* Cray migrated dmf file. */
|
||||
if (S_ISOFL (bits))
|
||||
return 'M';
|
||||
#endif
|
||||
return '?';
|
||||
}
|
||||
|
||||
/* Look at read, write, and execute bits in BITS and set
|
||||
flags in CHARS accordingly. */
|
||||
|
||||
static void
|
||||
rwx (bits, chars)
|
||||
unsigned short 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 (bits, chars)
|
||||
unsigned short bits;
|
||||
char *chars;
|
||||
{
|
||||
#ifdef S_ISUID
|
||||
if (bits & S_ISUID)
|
||||
{
|
||||
if (chars[3] != 'x')
|
||||
/* Set-uid, but not executable by owner. */
|
||||
chars[3] = 'S';
|
||||
else
|
||||
chars[3] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISGID
|
||||
if (bits & S_ISGID)
|
||||
{
|
||||
if (chars[6] != 'x')
|
||||
/* Set-gid, but not executable by group. */
|
||||
chars[6] = 'S';
|
||||
else
|
||||
chars[6] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISVTX
|
||||
if (bits & S_ISVTX)
|
||||
{
|
||||
if (chars[9] != 'x')
|
||||
/* Sticky, but not executable by others. */
|
||||
chars[9] = 'T';
|
||||
else
|
||||
chars[9] = 't';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
9
lib/filemode.h
Normal file
9
lib/filemode.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void mode_string PARAMS ((short unsigned int mode, char *str));
|
||||
125
lib/human.c
125
lib/human.c
@@ -1,5 +1,5 @@
|
||||
/* human.c -- print human readable file size
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -16,9 +16,12 @@
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Originally contributed by lm@sgi.com;
|
||||
--si and large file support added by eggert@twinsun.com. */
|
||||
--si, output block size selection, and large file support
|
||||
added by eggert@twinsun.com. */
|
||||
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
@@ -34,6 +37,24 @@
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_GETENV
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <error.h>
|
||||
#include <xstrtoul.h>
|
||||
|
||||
#include "human.h"
|
||||
|
||||
@@ -52,25 +73,32 @@ static const char suffixes[] =
|
||||
|
||||
/* Convert N to a human readable format in BUF.
|
||||
|
||||
N is expressed in units of FROM_UNITS; use units of TO_UNITS in the
|
||||
output number. FROM_UNITS and TO_UNITS must be positive, and one must
|
||||
be a multiple of the other.
|
||||
N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must
|
||||
be positive.
|
||||
|
||||
If BASE is nonzero, use a format like "127k" if possible,
|
||||
using powers of BASE; otherwise, use ordinary decimal format.
|
||||
Normally BASE is either 1000 or 1024; it must be at least 2.
|
||||
Most people visually process strings of 3-4 digits effectively,
|
||||
but longer strings of digits are more prone to misinterpretation.
|
||||
Hence, converting to an abbreviated form usually improves readability.
|
||||
Use a suffix indicating which power is being used.
|
||||
For example, assuming BASE is 1024, 8500 would be converted to 8.3k,
|
||||
If OUTPUT_BLOCK_SIZE is positive, use units of OUTPUT_BLOCK_SIZE in
|
||||
the output number. OUTPUT_BLOCK_SIZE must be a multiple of
|
||||
FROM_BLOCK_SIZE or vice versa.
|
||||
|
||||
If OUTPUT_BLOCK_SIZE is negative, use a format like "127k" if
|
||||
possible, using powers of -OUTPUT_BLOCK_SIZE; otherwise, use
|
||||
ordinary decimal format. Normally -OUTPUT_BLOCK_SIZE is either
|
||||
1000 or 1024; it must be at least 2. Most people visually process
|
||||
strings of 3-4 digits effectively, but longer strings of digits are
|
||||
more prone to misinterpretation. Hence, converting to an
|
||||
abbreviated form usually improves readability. Use a suffix
|
||||
indicating which power is being used. For example, assuming
|
||||
-OUTPUT_BLOCK_SIZE is 1024, 8500 would be converted to 8.3k,
|
||||
133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller
|
||||
than BASE aren't modified. */
|
||||
than -OUTPUT_BLOCK_SIZE aren't modified. */
|
||||
|
||||
char *
|
||||
human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
human_readable (uintmax_t n, char *buf,
|
||||
int from_block_size, int output_block_size)
|
||||
{
|
||||
uintmax_t amt;
|
||||
int base;
|
||||
int to_block_size;
|
||||
int tenths;
|
||||
int power;
|
||||
char *p;
|
||||
@@ -81,6 +109,17 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */
|
||||
int rounding;
|
||||
|
||||
if (output_block_size < 0)
|
||||
{
|
||||
base = -output_block_size;
|
||||
to_block_size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
base = 0;
|
||||
to_block_size = output_block_size;
|
||||
}
|
||||
|
||||
p = buf + LONGEST_HUMAN_READABLE;
|
||||
*p = '\0';
|
||||
|
||||
@@ -89,11 +128,11 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
power = 0;
|
||||
#endif
|
||||
|
||||
/* Adjust AMT out of FROM_UNITS units and into TO_UNITS units. */
|
||||
/* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */
|
||||
|
||||
if (to_units <= from_units)
|
||||
if (to_block_size <= from_block_size)
|
||||
{
|
||||
int multiplier = from_units / to_units;
|
||||
int multiplier = from_block_size / to_block_size;
|
||||
amt = n * multiplier;
|
||||
tenths = rounding = 0;
|
||||
|
||||
@@ -119,7 +158,7 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
e *= base;
|
||||
power++;
|
||||
}
|
||||
while (e * base <= amt && power < sizeof suffixes - 1);
|
||||
while (e * base <= damt && power < sizeof suffixes - 1);
|
||||
|
||||
damt /= e;
|
||||
|
||||
@@ -133,7 +172,7 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
}
|
||||
else
|
||||
{
|
||||
int divisor = to_units / from_units;
|
||||
int divisor = to_block_size / from_block_size;
|
||||
int r10 = (n % divisor) * 10;
|
||||
int r2 = (r10 % divisor) * 2;
|
||||
amt = n / divisor;
|
||||
@@ -201,3 +240,47 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* The default block size used for output. This number may change in
|
||||
the future as disks get larger. */
|
||||
#ifndef DEFAULT_BLOCK_SIZE
|
||||
# define DEFAULT_BLOCK_SIZE 1024
|
||||
#endif
|
||||
|
||||
static char const *const block_size_args[] = { "human-readable", "si", 0 };
|
||||
static int const block_size_types[] = { -1024, -1000 };
|
||||
|
||||
static strtol_error
|
||||
humblock (char const *spec, int *block_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (! spec && ! (spec = getenv ("BLOCK_SIZE")))
|
||||
*block_size = getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE;
|
||||
else if (0 <= (i = argmatch (spec, block_size_args)))
|
||||
*block_size = block_size_types[i];
|
||||
else
|
||||
{
|
||||
char *ptr;
|
||||
unsigned long val;
|
||||
strtol_error e = xstrtoul (spec, &ptr, 0, &val, "eEgGkKmMpPtTyYzZ0");
|
||||
if (e != LONGINT_OK)
|
||||
return e;
|
||||
if (*ptr)
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
if ((int) val < 0 || val != (int) val)
|
||||
return LONGINT_OVERFLOW;
|
||||
*block_size = (int) val;
|
||||
}
|
||||
|
||||
return LONGINT_OK;
|
||||
}
|
||||
|
||||
void
|
||||
human_block_size (char const *spec, int report_errors, int *block_size)
|
||||
{
|
||||
strtol_error e = humblock (spec, block_size);
|
||||
if (e != LONGINT_OK && report_errors)
|
||||
STRTOL_FATAL_ERROR (spec, _("block size"), e);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
char *human_readable PARAMS ((uintmax_t, char *, int, int, int));
|
||||
char *human_readable PARAMS ((uintmax_t, char *, int, int));
|
||||
|
||||
void human_block_size PARAMS ((char const *, int, int *));
|
||||
|
||||
#endif /* HUMAN_H_ */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#include "lchown.h"
|
||||
|
||||
/* Work just like chown, except when FILE is a symbolic link.
|
||||
In that case, set errno to ENOSYS and return -1. */
|
||||
|
||||
9
lib/lchown.h
Normal file
9
lib/lchown.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* Some systems don't have ENOSYS. */
|
||||
#ifndef ENOSYS
|
||||
# ifdef ENOTSUP
|
||||
# define ENOSYS ENOTSUP
|
||||
# else
|
||||
/* Some systems don't have ENOTSUP either. */
|
||||
# define ENOSYS ENOMSG
|
||||
# endif
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* linebuffer.c -- read arbitrarily long lines
|
||||
Copyright (C) 1986, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,11 +12,15 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Richard Stallman. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "linebuffer.h"
|
||||
|
||||
@@ -27,8 +31,7 @@ void free ();
|
||||
/* Initialize linebuffer LINEBUFFER for use. */
|
||||
|
||||
void
|
||||
initbuffer (linebuffer)
|
||||
struct linebuffer *linebuffer;
|
||||
initbuffer (struct linebuffer *linebuffer)
|
||||
{
|
||||
linebuffer->length = 0;
|
||||
linebuffer->size = 200;
|
||||
@@ -37,19 +40,18 @@ initbuffer (linebuffer)
|
||||
|
||||
/* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
|
||||
Remove any newline. Does not null terminate.
|
||||
Return LINEBUFFER, except at end of file return 0. */
|
||||
Return zero upon error or upon end of file.
|
||||
Otherwise, return LINEBUFFER. */
|
||||
|
||||
struct linebuffer *
|
||||
readline (linebuffer, stream)
|
||||
struct linebuffer *linebuffer;
|
||||
FILE *stream;
|
||||
readline (struct linebuffer *linebuffer, FILE *stream)
|
||||
{
|
||||
int c;
|
||||
char *buffer = linebuffer->buffer;
|
||||
char *p = linebuffer->buffer;
|
||||
char *end = buffer + linebuffer->size; /* Sentinel. */
|
||||
|
||||
if (feof (stream))
|
||||
if (feof (stream) || ferror (stream))
|
||||
{
|
||||
linebuffer->length = 0;
|
||||
return 0;
|
||||
@@ -83,8 +85,7 @@ readline (linebuffer, stream)
|
||||
/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
|
||||
|
||||
void
|
||||
freebuffer (linebuffer)
|
||||
struct linebuffer *linebuffer;
|
||||
freebuffer (struct linebuffer *linebuffer)
|
||||
{
|
||||
free (linebuffer->buffer);
|
||||
free (linebuffer);
|
||||
|
||||
332
lib/mountlist.c
332
lib/mountlist.c
@@ -42,6 +42,19 @@ char *xrealloc ();
|
||||
char *xstrdup ();
|
||||
void error ();
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
@@ -116,10 +129,10 @@ void error ();
|
||||
/* Return the value of the hexadecimal number represented by CP.
|
||||
No prefix (like '0x') or suffix (like 'h') is expected to be
|
||||
part of CP. */
|
||||
/* FIXME: this can overflow */
|
||||
|
||||
static int
|
||||
xatoi (cp)
|
||||
char *cp;
|
||||
xatoi (char *cp)
|
||||
{
|
||||
int val;
|
||||
|
||||
@@ -140,107 +153,120 @@ xatoi (cp)
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT1. */
|
||||
|
||||
#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__) && !defined (__OpenBSD__)
|
||||
#if MOUNTED_GETMNTINFO
|
||||
|
||||
# if ! HAVE_F_FSTYPENAME_IN_STATFS
|
||||
static char *
|
||||
fstype_to_string (t)
|
||||
short t;
|
||||
fstype_to_string (short t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
# ifdef MOUNT_PC
|
||||
# ifdef MOUNT_PC
|
||||
case MOUNT_PC:
|
||||
return "pc";
|
||||
# endif
|
||||
# ifdef MOUNT_MFS
|
||||
# endif
|
||||
# ifdef MOUNT_MFS
|
||||
case MOUNT_MFS:
|
||||
return "mfs";
|
||||
# endif
|
||||
# ifdef MOUNT_LO
|
||||
# endif
|
||||
# ifdef MOUNT_LO
|
||||
case MOUNT_LO:
|
||||
return "lo";
|
||||
# endif
|
||||
# ifdef MOUNT_TFS
|
||||
# endif
|
||||
# ifdef MOUNT_TFS
|
||||
case MOUNT_TFS:
|
||||
return "tfs";
|
||||
# endif
|
||||
# ifdef MOUNT_TMP
|
||||
# endif
|
||||
# ifdef MOUNT_TMP
|
||||
case MOUNT_TMP:
|
||||
return "tmp";
|
||||
# endif
|
||||
# ifdef MOUNT_UFS
|
||||
# endif
|
||||
# ifdef MOUNT_UFS
|
||||
case MOUNT_UFS:
|
||||
return "ufs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_NFS
|
||||
# endif
|
||||
# ifdef MOUNT_NFS
|
||||
case MOUNT_NFS:
|
||||
return "nfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_MSDOS
|
||||
# endif
|
||||
# ifdef MOUNT_MSDOS
|
||||
case MOUNT_MSDOS:
|
||||
return "msdos" ;
|
||||
# endif
|
||||
# ifdef MOUNT_LFS
|
||||
# endif
|
||||
# ifdef MOUNT_LFS
|
||||
case MOUNT_LFS:
|
||||
return "lfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_LOFS
|
||||
# endif
|
||||
# ifdef MOUNT_LOFS
|
||||
case MOUNT_LOFS:
|
||||
return "lofs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_FDESC
|
||||
# endif
|
||||
# ifdef MOUNT_FDESC
|
||||
case MOUNT_FDESC:
|
||||
return "fdesc" ;
|
||||
# endif
|
||||
# ifdef MOUNT_PORTAL
|
||||
# endif
|
||||
# ifdef MOUNT_PORTAL
|
||||
case MOUNT_PORTAL:
|
||||
return "portal" ;
|
||||
# endif
|
||||
# ifdef MOUNT_NULL
|
||||
# endif
|
||||
# ifdef MOUNT_NULL
|
||||
case MOUNT_NULL:
|
||||
return "null" ;
|
||||
# endif
|
||||
# ifdef MOUNT_UMAP
|
||||
# endif
|
||||
# ifdef MOUNT_UMAP
|
||||
case MOUNT_UMAP:
|
||||
return "umap" ;
|
||||
# endif
|
||||
# ifdef MOUNT_KERNFS
|
||||
# endif
|
||||
# ifdef MOUNT_KERNFS
|
||||
case MOUNT_KERNFS:
|
||||
return "kernfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_PROCFS
|
||||
# endif
|
||||
# ifdef MOUNT_PROCFS
|
||||
case MOUNT_PROCFS:
|
||||
return "procfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_AFS
|
||||
# endif
|
||||
# ifdef MOUNT_AFS
|
||||
case MOUNT_AFS:
|
||||
return "afs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_CD9660
|
||||
# endif
|
||||
# ifdef MOUNT_CD9660
|
||||
case MOUNT_CD9660:
|
||||
return "cd9660" ;
|
||||
# endif
|
||||
# ifdef MOUNT_UNION
|
||||
# endif
|
||||
# ifdef MOUNT_UNION
|
||||
case MOUNT_UNION:
|
||||
return "union" ;
|
||||
# endif
|
||||
# ifdef MOUNT_DEVFS
|
||||
# endif
|
||||
# ifdef MOUNT_DEVFS
|
||||
case MOUNT_DEVFS:
|
||||
return "devfs" ;
|
||||
# endif
|
||||
# ifdef MOUNT_EXT2FS
|
||||
# endif
|
||||
# ifdef MOUNT_EXT2FS
|
||||
case MOUNT_EXT2FS:
|
||||
return "ext2fs" ;
|
||||
# endif
|
||||
# endif
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
# endif /* ! HAVE_F_FSTYPENAME_IN_STATFS */
|
||||
|
||||
/* __NetBSD__ || BSD_NET2 || __OpenBSD__ */
|
||||
static char *
|
||||
fsp_to_string (const struct statfs *fsp)
|
||||
{
|
||||
# if defined HAVE_F_FSTYPENAME_IN_STATFS
|
||||
return fsp->f_fstypename;
|
||||
# else
|
||||
return fstype_to_string (fsp->f_type);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
static char *
|
||||
fstype_to_string (t)
|
||||
int t;
|
||||
fstype_to_string (int t)
|
||||
{
|
||||
struct vfs_ent *e;
|
||||
|
||||
@@ -255,22 +281,14 @@ fstype_to_string (t)
|
||||
/* Return a list of the currently mounted filesystems, or NULL on error.
|
||||
Add each entry to the tail of the list so that they stay in order.
|
||||
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
|
||||
the returned list are valid. Otherwise, they might not be.
|
||||
If ALL_FS is zero, do not return entries for filesystems that
|
||||
are automounter (dummy) entries. */
|
||||
the returned list are valid. Otherwise, they might not be. */
|
||||
|
||||
struct mount_entry *
|
||||
read_filesystem_list (need_fs_type, all_fs)
|
||||
int need_fs_type, all_fs;
|
||||
read_filesystem_list (int need_fs_type)
|
||||
{
|
||||
struct mount_entry *mount_list;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry *mtail;
|
||||
|
||||
/* Start the list off with a dummy entry. */
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_next = NULL;
|
||||
mount_list = mtail = me;
|
||||
struct mount_entry **mtail = &mount_list;
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
{
|
||||
@@ -285,18 +303,17 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
|
||||
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
p = mntlist;
|
||||
while(p){
|
||||
for (p = mntlist; p; p = p->next) {
|
||||
mnt = p->ment;
|
||||
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup(mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup(mnt->mnt_dir);
|
||||
me->me_type = xstrdup(mnt->mnt_type);
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = -1;
|
||||
me->me_next = NULL;
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
p = p->next;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
freemntlist(mntlist);
|
||||
}
|
||||
@@ -315,14 +332,12 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
|
||||
while ((mnt = getmntent (fp)))
|
||||
{
|
||||
if (!all_fs && (!strcmp (mnt->mnt_type, "ignore")
|
||||
|| !strcmp (mnt->mnt_type, "auto")))
|
||||
continue;
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup (mnt->mnt_dir);
|
||||
me->me_type = xstrdup (mnt->mnt_type);
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
devopt = strstr (mnt->mnt_opts, "dev=");
|
||||
if (devopt)
|
||||
{
|
||||
@@ -333,15 +348,14 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
}
|
||||
else
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
if (endmntent (fp) == 0)
|
||||
return NULL;
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT1. */
|
||||
|
||||
@@ -353,23 +367,21 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
entries = getmntinfo (&fsp, MNT_NOWAIT);
|
||||
if (entries < 0)
|
||||
return NULL;
|
||||
while (entries-- > 0)
|
||||
for (; entries-- > 0; fsp++)
|
||||
{
|
||||
char *fs_type = fsp_to_string (fsp);
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = xstrdup (fsp->f_mntonname);
|
||||
# if defined (__NetBSD__) || defined (__OpenBSD__)
|
||||
me->me_type = xstrdup (fsp->f_fstypename);
|
||||
# else
|
||||
me->me_type = fstype_to_string (fsp->f_type);
|
||||
# endif
|
||||
me->me_type = fs_type;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
fsp++;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
@@ -380,22 +392,24 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
int val;
|
||||
struct fs_data fsd;
|
||||
|
||||
while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
|
||||
(char *) 0)) > 0)
|
||||
while (errno = 0,
|
||||
0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
|
||||
(char *) 0)))
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = xstrdup (fsd.fd_req.path);
|
||||
me->me_type = gt_names[fsd.fd_req.fstype];
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = fsd.fd_req.dev;
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
if (val < 0)
|
||||
return NULL;
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNT. */
|
||||
|
||||
@@ -424,12 +438,13 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
me->me_devname = xstrdup (stats[counter].f_mntfromname);
|
||||
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
|
||||
me->me_type = mnt_names[stats[counter].f_type];
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
free (stats);
|
||||
@@ -470,15 +485,24 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
me->me_type = xstrdup (typebuf);
|
||||
}
|
||||
# endif
|
||||
me->me_next = NULL;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
{
|
||||
int saved_errno = errno;
|
||||
fclose (fp);
|
||||
errno = saved_errno;
|
||||
goto free_then_fail;
|
||||
}
|
||||
|
||||
if (fclose (fp) == EOF)
|
||||
return NULL;
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
|
||||
|
||||
@@ -491,12 +515,13 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
me->me_devname = xstrdup ( (*ent)->mt_resource);
|
||||
me->me_mountdir = xstrdup( (*ent)->mt_directory);
|
||||
me->me_type = xstrdup ((*ent)->mt_fstype);
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
endmnttbl();
|
||||
}
|
||||
@@ -508,33 +533,69 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
char *table = MNTTAB;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
int lockfd = -1;
|
||||
|
||||
# if defined F_RDLCK && defined F_SETLKW
|
||||
/* MNTTAB_LOCK is a macro name of our own invention; it's not present in
|
||||
e.g. Solaris 2.6. If the SVR4 folks ever define a macro
|
||||
for this file name, we should use their macro name instead.
|
||||
(Why not just lock MNTTAB directly? We don't know.) */
|
||||
# ifndef MNTTAB_LOCK
|
||||
# define MNTTAB_LOCK "/etc/.mnttab.lock"
|
||||
# endif
|
||||
lockfd = open (MNTTAB_LOCK, O_RDONLY);
|
||||
if (0 <= lockfd)
|
||||
{
|
||||
struct flock flock;
|
||||
flock.l_type = F_RDLCK;
|
||||
flock.l_whence = SEEK_SET;
|
||||
flock.l_start = 0;
|
||||
flock.l_len = 0;
|
||||
while (fcntl (lockfd, F_SETLKW, &flock) == -1)
|
||||
if (errno != EINTR)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
close (lockfd);
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
return NULL;
|
||||
# endif
|
||||
|
||||
errno = 0;
|
||||
fp = fopen (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((ret = getmntent (fp, &mnt)) == 0)
|
||||
ret = errno;
|
||||
else
|
||||
{
|
||||
/* Don't show automounted filesystems twice on e.g., Solaris. */
|
||||
if (!all_fs && MNT_IGNORE (&mnt))
|
||||
continue;
|
||||
while ((ret = getmntent (fp, &mnt)) == 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt.mnt_special);
|
||||
me->me_mountdir = xstrdup (mnt.mnt_mountp);
|
||||
me->me_type = xstrdup (mnt.mnt_fstype);
|
||||
me->me_dummy = MNT_IGNORE (&mnt) != 0;
|
||||
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt.mnt_special);
|
||||
me->me_mountdir = xstrdup (mnt.mnt_mountp);
|
||||
me->me_type = xstrdup (mnt.mnt_fstype);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
|
||||
}
|
||||
|
||||
if (ret > 0)
|
||||
return NULL;
|
||||
if (fclose (fp) == EOF)
|
||||
return NULL;
|
||||
if (0 <= lockfd && close (lockfd) != 0)
|
||||
ret = errno;
|
||||
|
||||
if (0 <= ret)
|
||||
{
|
||||
errno = ret;
|
||||
goto free_then_fail;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT2. */
|
||||
|
||||
@@ -560,6 +621,7 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
{
|
||||
char *host, *path;
|
||||
|
||||
me->me_remote = 1;
|
||||
/* Prepend the remote pathname. */
|
||||
host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
|
||||
path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
|
||||
@@ -570,25 +632,43 @@ read_filesystem_list (need_fs_type, all_fs)
|
||||
}
|
||||
else
|
||||
{
|
||||
me->me_remote = 0;
|
||||
me->me_devname = xstrdup (thisent +
|
||||
vmp->vmt_data[VMT_OBJECT].vmt_off);
|
||||
}
|
||||
me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
|
||||
me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
free (entries);
|
||||
}
|
||||
#endif /* MOUNTED_VMOUNT. */
|
||||
|
||||
/* Free the dummy head. */
|
||||
me = mount_list;
|
||||
mount_list = mount_list->me_next;
|
||||
free (me);
|
||||
*mtail = NULL;
|
||||
return mount_list;
|
||||
|
||||
|
||||
free_then_fail:
|
||||
{
|
||||
int saved_errno = errno;
|
||||
*mtail = NULL;
|
||||
|
||||
while (mount_list)
|
||||
{
|
||||
me = mount_list->me_next;
|
||||
free (mount_list->me_devname);
|
||||
free (mount_list->me_mountdir);
|
||||
/* FIXME: me_type is not always malloced. */
|
||||
free (mount_list);
|
||||
mount_list = me;
|
||||
}
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mountlist.h -- declarations for list of mounted filesystems
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,11 +22,26 @@ struct mount_entry
|
||||
char *me_mountdir; /* Mount point directory pathname. */
|
||||
char *me_type; /* "nfs", "4.2", etc. */
|
||||
dev_t me_dev; /* Device number of me_mountdir. */
|
||||
unsigned int me_dummy : 1; /* Nonzero for dummy filesystems. */
|
||||
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
|
||||
struct mount_entry *me_next;
|
||||
};
|
||||
|
||||
#if __STDC__
|
||||
struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs);
|
||||
#else
|
||||
struct mount_entry *read_filesystem_list ();
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct mount_entry *read_filesystem_list PARAMS ((int need_fs_type));
|
||||
|
||||
#ifndef ME_DUMMY
|
||||
# define ME_DUMMY(fs_name, fs_type) \
|
||||
(!strcmp (fs_type, "auto") || !strcmp (fs_type, "ignore"))
|
||||
#endif
|
||||
|
||||
#ifndef ME_REMOTE
|
||||
# define ME_REMOTE(fs_name, fs_type) (strchr (fs_name, ':') != 0)
|
||||
#endif
|
||||
|
||||
1135
lib/posixtm.c
1135
lib/posixtm.c
File diff suppressed because it is too large
Load Diff
16
lib/posixtm.h
Normal file
16
lib/posixtm.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef POSIXTM_H_
|
||||
# define POSIXTM_H_
|
||||
|
||||
/* POSIX Date Syntax flags. */
|
||||
# define PDS_LEADING_YEAR 1
|
||||
# define PDS_TRAILING_YEAR 2
|
||||
# define PDS_CENTURY 4
|
||||
# define PDS_SECONDS 8
|
||||
|
||||
time_t
|
||||
posixtime (const char *s, unsigned int syntax_bits);
|
||||
|
||||
struct tm *
|
||||
posixtm (const char *s, unsigned int syntax_bits);
|
||||
|
||||
#endif
|
||||
116
lib/regex.c
116
lib/regex.c
@@ -55,10 +55,36 @@
|
||||
/* For platform which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
#if WIDE_CHAR_SUPPORT
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
/* We have to keep the namespace clean. */
|
||||
# define regfree(preg) __regfree (preg)
|
||||
# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
|
||||
# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
|
||||
# define regerror(errcode, preg, errbuf, errbuf_size) \
|
||||
__regerror(errcode, preg, errbuf, errbuf_size)
|
||||
# define re_set_registers(bu, re, nu, st, en) \
|
||||
__re_set_registers (bu, re, nu, st, en)
|
||||
# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
|
||||
__re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
# define re_match(bufp, string, size, pos, regs) \
|
||||
__re_match (bufp, string, size, pos, regs)
|
||||
# define re_search(bufp, string, size, startpos, range, regs) \
|
||||
__re_search (bufp, string, size, startpos, range, regs)
|
||||
# define re_compile_pattern(pattern, length, bufp) \
|
||||
__re_compile_pattern (pattern, length, bufp)
|
||||
# define re_set_syntax(syntax) __re_set_syntax (syntax)
|
||||
# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
|
||||
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
|
||||
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
|
||||
|
||||
#define btowc __btowc
|
||||
#endif
|
||||
|
||||
/* This is for other GNU distributions with internationalized messages. */
|
||||
#if HAVE_LIBINTL_H || defined _LIBC
|
||||
# include <libintl.h>
|
||||
@@ -110,8 +136,12 @@ char *realloc ();
|
||||
# ifndef INHIBIT_STRING_HEADER
|
||||
# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
|
||||
# include <string.h>
|
||||
# if !defined bzero && !defined _LIBC
|
||||
# define bzero(s, n) (memset (s, '\0', n), (s))
|
||||
# ifndef bzero
|
||||
# ifndef _LIBC
|
||||
# define bzero(s, n) (memset (s, '\0', n), (s))
|
||||
# else
|
||||
# define bzero(s, n) __bzero (s, n)
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# include <strings.h>
|
||||
@@ -195,7 +225,8 @@ init_syntax_once ()
|
||||
STDC_HEADERS is defined, then autoconf has verified that the ctype
|
||||
macros don't need to be guarded with references to isascii. ...
|
||||
Defining isascii to 1 should let any compiler worth its salt
|
||||
eliminate the && through constant folding." */
|
||||
eliminate the && through constant folding."
|
||||
Solaris defines some of these symbols so we must undefine them first. */
|
||||
|
||||
#undef ISASCII
|
||||
#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
|
||||
@@ -971,6 +1002,9 @@ re_set_syntax (syntax)
|
||||
#endif /* DEBUG */
|
||||
return ret;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_set_syntax, re_set_syntax)
|
||||
#endif
|
||||
|
||||
/* This table gives an error message for each of the error codes listed
|
||||
in regex.h. Obviously the order here has to be same as there.
|
||||
@@ -1699,7 +1733,11 @@ typedef struct
|
||||
# define CHAR_CLASS_MAX_LENGTH 256
|
||||
# endif
|
||||
|
||||
# define IS_CHAR_CLASS(string) wctype (string)
|
||||
# ifdef _LIBC
|
||||
# define IS_CHAR_CLASS(string) __wctype (string)
|
||||
# else
|
||||
# define IS_CHAR_CLASS(string) wctype (string)
|
||||
# endif
|
||||
#else
|
||||
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
||||
|
||||
@@ -2176,14 +2214,14 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
for (;;)
|
||||
{
|
||||
PATFETCH (c);
|
||||
if (c == ':' || c == ']' || p == pend
|
||||
if ((c == ':' && *p == ']') || p == pend
|
||||
|| c1 == CHAR_CLASS_MAX_LENGTH)
|
||||
break;
|
||||
str[c1++] = c;
|
||||
}
|
||||
str[c1] = '\0';
|
||||
|
||||
/* If isn't a word bracketed by `[:' and:`]':
|
||||
/* If isn't a word bracketed by `[:' and `:]':
|
||||
undo the ending character, the letters, and leave
|
||||
the leading `:' and `[' (but set bits for them). */
|
||||
if (c == ':' && *p == ']')
|
||||
@@ -2194,7 +2232,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
wctype_t wt;
|
||||
int ch;
|
||||
|
||||
wt = wctype (str);
|
||||
wt = IS_CHAR_CLASS (str);
|
||||
if (wt == 0)
|
||||
FREE_STACK_RETURN (REG_ECTYPE);
|
||||
|
||||
@@ -2206,8 +2244,13 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
|
||||
{
|
||||
# ifdef _LIBC
|
||||
if (__iswctype (__btowc (ch), wt))
|
||||
SET_LIST_BIT (ch);
|
||||
#else
|
||||
if (iswctype (btowc (ch), wt))
|
||||
SET_LIST_BIT (ch);
|
||||
#endif
|
||||
|
||||
if (translate && (is_upper || is_lower)
|
||||
&& (ISUPPER (ch) || ISLOWER (ch)))
|
||||
@@ -2691,7 +2734,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
|
||||
case 'w':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
laststart = b;
|
||||
BUF_PUSH (wordchar);
|
||||
@@ -2699,7 +2742,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
|
||||
case 'W':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
laststart = b;
|
||||
BUF_PUSH (notwordchar);
|
||||
@@ -2707,37 +2750,37 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
|
||||
case '<':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (wordbeg);
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (wordend);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (wordbound);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (notwordbound);
|
||||
break;
|
||||
|
||||
case '`':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (begbuf);
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
if (re_syntax_options & RE_NO_GNU_OPS)
|
||||
if (syntax & RE_NO_GNU_OPS)
|
||||
goto normal_char;
|
||||
BUF_PUSH (endbuf);
|
||||
break;
|
||||
@@ -3375,6 +3418,9 @@ re_compile_fastmap (bufp)
|
||||
RESET_FAIL_STACK ();
|
||||
return 0;
|
||||
} /* re_compile_fastmap */
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_compile_fastmap, re_compile_fastmap)
|
||||
#endif
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
|
||||
@@ -3410,6 +3456,9 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
|
||||
regs->start = regs->end = (regoff_t *) 0;
|
||||
}
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_set_registers, re_set_registers)
|
||||
#endif
|
||||
|
||||
/* Searching routines. */
|
||||
|
||||
@@ -3426,6 +3475,9 @@ re_search (bufp, string, size, startpos, range, regs)
|
||||
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
|
||||
regs, size);
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_search, re_search)
|
||||
#endif
|
||||
|
||||
|
||||
/* Using the compiled pattern in BUFP->buffer, first tries to match the
|
||||
@@ -3479,7 +3531,11 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
|
||||
|
||||
/* If the search isn't to be a backwards one, don't waste time in a
|
||||
search for a pattern that must be anchored. */
|
||||
if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
|
||||
if (bufp->used > 0 && range > 0
|
||||
&& ((re_opcode_t) bufp->buffer[0] == begbuf
|
||||
/* `begline' is like `begbuf' if it cannot match at newlines. */
|
||||
|| ((re_opcode_t) bufp->buffer[0] == begline
|
||||
&& !bufp->newline_anchor)))
|
||||
{
|
||||
if (startpos > 0)
|
||||
return -1;
|
||||
@@ -3582,6 +3638,9 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
|
||||
}
|
||||
return -1;
|
||||
} /* re_search_2 */
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_search_2, re_search_2)
|
||||
#endif
|
||||
|
||||
/* This converts PTR, a pointer into one of the search strings `string1'
|
||||
and `string2' into an offset from the beginning of that string. */
|
||||
@@ -3683,6 +3742,9 @@ re_match (bufp, string, size, pos, regs)
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
# ifdef _LIBC
|
||||
weak_alias (__re_match, re_match)
|
||||
# endif
|
||||
#endif /* not emacs */
|
||||
|
||||
static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p,
|
||||
@@ -3728,6 +3790,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_match_2, re_match_2)
|
||||
#endif
|
||||
|
||||
/* This is a separate function so that we can force an alloca cleanup
|
||||
afterwards. */
|
||||
@@ -5421,6 +5486,9 @@ re_compile_pattern (pattern, length, bufp)
|
||||
return NULL;
|
||||
return gettext (re_error_msgid[(int) ret]);
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_compile_pattern, re_compile_pattern)
|
||||
#endif
|
||||
|
||||
/* Entry points compatible with 4.2 BSD regex library. We don't define
|
||||
them unless specifically requested. */
|
||||
@@ -5453,12 +5521,12 @@ re_comp (s)
|
||||
{
|
||||
re_comp_buf.buffer = (unsigned char *) malloc (200);
|
||||
if (re_comp_buf.buffer == NULL)
|
||||
return gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
re_comp_buf.allocated = 200;
|
||||
|
||||
re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
|
||||
if (re_comp_buf.fastmap == NULL)
|
||||
return gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
}
|
||||
|
||||
/* Since `re_exec' always passes NULL for the `regs' argument, we
|
||||
@@ -5591,6 +5659,9 @@ regcomp (preg, pattern, cflags)
|
||||
|
||||
return (int) ret;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__regcomp, regcomp)
|
||||
#endif
|
||||
|
||||
|
||||
/* regexec searches for a given pattern, specified by PREG, in the
|
||||
@@ -5667,6 +5738,9 @@ regexec (preg, string, nmatch, pmatch, eflags)
|
||||
/* We want zero return to mean success, unlike `re_search'. */
|
||||
return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__regexec, regexec)
|
||||
#endif
|
||||
|
||||
|
||||
/* Returns a message corresponding to an error code, ERRCODE, returned
|
||||
@@ -5712,6 +5786,9 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
|
||||
return msg_size;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__regerror, regerror)
|
||||
#endif
|
||||
|
||||
|
||||
/* Free dynamically allocated space used by PREG. */
|
||||
@@ -5736,5 +5813,8 @@ regfree (preg)
|
||||
free (preg->translate);
|
||||
preg->translate = NULL;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__regfree, regfree)
|
||||
#endif
|
||||
|
||||
#endif /* not emacs */
|
||||
|
||||
49
lib/regex.h
49
lib/regex.h
@@ -442,11 +442,15 @@ typedef struct
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
extern const char *__re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
extern const char *re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
@@ -455,6 +459,7 @@ extern const char *re_compile_pattern
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
@@ -463,6 +468,9 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
extern int __re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
extern int re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
@@ -470,6 +478,10 @@ extern int re_search
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
extern int __re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs, int stop));
|
||||
extern int re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
@@ -478,12 +490,19 @@ extern int re_search_2
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
extern int __re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
extern int re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
extern int __re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop));
|
||||
extern int re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
@@ -502,6 +521,9 @@ extern int re_match_2
|
||||
Unless this function is called, the first search or match using
|
||||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
extern void __re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
extern void re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
@@ -515,14 +537,25 @@ extern int re_exec _RE_ARGS ((const char *));
|
||||
#endif
|
||||
|
||||
/* POSIX compatibility. */
|
||||
extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
|
||||
extern int regexec
|
||||
_RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
|
||||
regmatch_t pmatch[], int eflags));
|
||||
extern size_t regerror
|
||||
_RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
|
||||
size_t errbuf_size));
|
||||
extern void regfree _RE_ARGS ((regex_t *preg));
|
||||
extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
|
||||
int __cflags));
|
||||
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
|
||||
int __cflags));
|
||||
|
||||
extern int __regexec _RE_ARGS ((const regex_t *__preg,
|
||||
const char *__string, size_t __nmatch,
|
||||
regmatch_t __pmatch[], int __eflags));
|
||||
extern int regexec _RE_ARGS ((const regex_t *__preg,
|
||||
const char *__string, size_t __nmatch,
|
||||
regmatch_t __pmatch[], int __eflags));
|
||||
|
||||
extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
|
||||
extern void __regfree _RE_ARGS ((regex_t *__preg));
|
||||
extern void regfree _RE_ARGS ((regex_t *__preg));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Determine whether string value is affirmation or negative response
|
||||
according to current locale's data.
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,11 +30,7 @@
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include <regex.h>
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
|
||||
@@ -38,7 +38,7 @@ extern int errno;
|
||||
for an error. */
|
||||
|
||||
ssize_t
|
||||
safe_read (int desc, char *ptr, size_t len)
|
||||
safe_read (int desc, void *ptr, size_t len)
|
||||
{
|
||||
ssize_t n_chars;
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
#endif
|
||||
|
||||
ssize_t
|
||||
safe_read PARAMS ((int desc, char *ptr, size_t len));
|
||||
safe_read PARAMS ((int desc, void *ptr, size_t len));
|
||||
|
||||
81
lib/utime.c
Normal file
81
lib/utime.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* derived from a function in touch.c */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef utime
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif
|
||||
|
||||
#include "safe-read.h"
|
||||
|
||||
/* Some systems (even some that do have <utime.h>) don't declare this
|
||||
structure anywhere. */
|
||||
#ifndef HAVE_STRUCT_UTIMBUF
|
||||
struct utimbuf
|
||||
{
|
||||
long actime;
|
||||
long modtime;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Emulate utime (file, NULL) for systems (like 4.3BSD) that do not
|
||||
interpret it to set the access and modification times of FILE to
|
||||
the current time. Return 0 if successful, -1 if not. */
|
||||
|
||||
static int
|
||||
utime_null (const char *file)
|
||||
{
|
||||
#if HAVE_UTIMES_NULL
|
||||
return utimes (file, 0);
|
||||
#else
|
||||
int fd;
|
||||
char c;
|
||||
int status = 0;
|
||||
struct stat sb;
|
||||
|
||||
fd = open (file, O_RDWR, 0666);
|
||||
if (fd < 0
|
||||
|| fstat (fd, &sb) < 0
|
||||
|| safe_read (fd, &c, sizeof (char)) < 0
|
||||
|| lseek (fd, (off_t) 0, SEEK_SET) < 0
|
||||
|| full_write (fd, &c, sizeof (char)) < 0
|
||||
/* Maybe do this -- it's necessary on SunOS4.1.3 with some combination
|
||||
of patches, but that system doesn't use this code: it has utimes.
|
||||
|| fsync (fd) < 0
|
||||
*/
|
||||
|| ftruncate (fd, st.st_size) < 0
|
||||
|| close (fd) < 0)
|
||||
status = -1;
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
rpl_utime (const char *file, const struct utimbuf *times)
|
||||
{
|
||||
if (times)
|
||||
return utime (file, times);
|
||||
|
||||
return utime_null (file);
|
||||
}
|
||||
124
lib/xstrtol.c
124
lib/xstrtol.c
@@ -21,6 +21,10 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Some pre-ANSI implementations (e.g. SunOS 4)
|
||||
need stderr defined if assertion checking is enabled. */
|
||||
#include <stdio.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
@@ -34,7 +38,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
@@ -71,40 +74,41 @@ extern int errno;
|
||||
__unsigned long int __strtol ();
|
||||
|
||||
static int
|
||||
bkm_scale (x, scale_factor)
|
||||
__unsigned long int *x;
|
||||
int scale_factor;
|
||||
bkm_scale (__unsigned long int *x, int scale_factor)
|
||||
{
|
||||
/* The cast to `__unsigned long int' before the cast to double is
|
||||
required to work around a bug in SunOS's /bin/cc. */
|
||||
if (*x > (double) ((__unsigned long int) __ZLONG_MAX) / scale_factor)
|
||||
{
|
||||
__unsigned long int product = *x * scale_factor;
|
||||
if (*x != product / scale_factor)
|
||||
return 1;
|
||||
*x = product;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bkm_scale_by_power (__unsigned long int *x, int base, int power)
|
||||
{
|
||||
while (power--)
|
||||
if (bkm_scale (x, base))
|
||||
return 1;
|
||||
}
|
||||
*x *= scale_factor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: comment. */
|
||||
|
||||
strtol_error
|
||||
__xstrtol (s, ptr, base, val, valid_suffixes)
|
||||
const char *s;
|
||||
char **ptr;
|
||||
int base;
|
||||
__unsigned long int *val;
|
||||
const char *valid_suffixes;
|
||||
__xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
__unsigned long int *val, const char *valid_suffixes)
|
||||
{
|
||||
char *t_ptr;
|
||||
char **p;
|
||||
__unsigned long int tmp;
|
||||
|
||||
assert (0 <= base && base <= 36);
|
||||
assert (0 <= strtol_base && strtol_base <= 36);
|
||||
|
||||
p = (ptr ? ptr : &t_ptr);
|
||||
|
||||
errno = 0;
|
||||
tmp = __strtol (s, p, base);
|
||||
tmp = __strtol (s, p, strtol_base);
|
||||
if (errno != 0)
|
||||
return LONGINT_OVERFLOW;
|
||||
if (*p == s)
|
||||
@@ -121,44 +125,92 @@ __xstrtol (s, ptr, base, val, valid_suffixes)
|
||||
|
||||
if (**p != '\0')
|
||||
{
|
||||
int base = 1024;
|
||||
int suffixes = 1;
|
||||
int overflow;
|
||||
|
||||
if (!strchr (valid_suffixes, **p))
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
|
||||
if (strchr (valid_suffixes, '0'))
|
||||
{
|
||||
/* The ``valid suffix'' '0' is a special flag meaning that
|
||||
an optional second suffix is allowed, which can change
|
||||
the base, e.g. "100MD" for 100 megabytes decimal. */
|
||||
|
||||
switch (p[0][1])
|
||||
{
|
||||
case 'B':
|
||||
suffixes++;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
base = 1000;
|
||||
suffixes++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (**p)
|
||||
{
|
||||
case 'b':
|
||||
if (bkm_scale (&tmp, 512))
|
||||
return LONGINT_OVERFLOW;
|
||||
++(*p);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
++(*p);
|
||||
overflow = bkm_scale (&tmp, 512);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
case 'k':
|
||||
if (bkm_scale (&tmp, 1024))
|
||||
return LONGINT_OVERFLOW;
|
||||
++(*p);
|
||||
overflow = bkm_scale (&tmp, 1024);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (bkm_scale (&tmp, 1024 * 1024))
|
||||
return LONGINT_OVERFLOW;
|
||||
++(*p);
|
||||
case 'c':
|
||||
overflow = 0;
|
||||
break;
|
||||
|
||||
case 'E': /* Exa */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 6);
|
||||
break;
|
||||
|
||||
case 'G': /* Giga */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 3);
|
||||
break;
|
||||
|
||||
case 'k': /* kilo */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 1);
|
||||
break;
|
||||
|
||||
case 'M': /* Mega */
|
||||
case 'm': /* 'm' is undocumented; for backward compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 2);
|
||||
break;
|
||||
|
||||
case 'P': /* Peta */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 5);
|
||||
break;
|
||||
|
||||
case 'T': /* Tera */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 4);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (bkm_scale (&tmp, 2))
|
||||
return LONGINT_OVERFLOW;
|
||||
++(*p);
|
||||
overflow = bkm_scale (&tmp, 2);
|
||||
break;
|
||||
|
||||
case 'Y': /* Yotta */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 8);
|
||||
break;
|
||||
|
||||
case 'Z': /* Zetta */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 7);
|
||||
break;
|
||||
|
||||
default:
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
return LONGINT_OVERFLOW;
|
||||
|
||||
(*p) += suffixes;
|
||||
}
|
||||
|
||||
*val = tmp;
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
# define __xstrtol xstrtoul
|
||||
# define __strtol strtoul
|
||||
# define __unsigned unsigned
|
||||
# define __ZLONG_MAX ULONG_MAX
|
||||
# else
|
||||
# define __xstrtol xstrtol
|
||||
# define __strtol strtol
|
||||
# define __unsigned /* empty */
|
||||
# define __ZLONG_MAX LONG_MAX
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
|
||||
84
m4/ChangeLog
84
m4/ChangeLog
@@ -1,3 +1,87 @@
|
||||
1998-08-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Port nanosecond-resolution times to UnixWare 2.1.2 and
|
||||
pedantic Solaris 2.6.
|
||||
|
||||
* st_mtim.m4 (AC_STRUCT_ST_MTIM_NSEC): Renamed from
|
||||
AC_STRUCT_ST_MTIM.
|
||||
* st_mtim.m4 (AC_STRUCT_ST_MTIM_NSEC):
|
||||
Generate name of ns member, instead of just 1 or undef.
|
||||
Allow for UnixWare 2.1.2 and Solaris 2.6 if in pedantic mode.
|
||||
|
||||
1998-08-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* ssize_t.m4 (jm_TYPE_SSIZE_T): Remove file.
|
||||
* check-type.m4: New file. Replacement for AC_CHECK_TYPE.
|
||||
* jm-macros.m4: Use the new AC_CHECK_TYPE(ssize_t, int)
|
||||
instead of jm_TYPE_SSIZE_T.
|
||||
|
||||
1998-08-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* st_dm_mode.m4: New file. From Johan Danielsson.
|
||||
|
||||
1998-08-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* st_mtim.m4: Use hack to avoid having to put #undef HAVE_ST_MTIM
|
||||
in acconfig.h manually.
|
||||
|
||||
1998-07-31 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* st_mtim.m4: New file.
|
||||
|
||||
1998-07-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* utimes.m4: Undef stat.
|
||||
|
||||
1998-07-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* utime.m4 (jm_FUNC_UTIME): New file and macro.
|
||||
* utimes.m4 (jm_FUNC_UTIMES_NULL): New file and macro.
|
||||
|
||||
1998-07-09 Manfred Hollstein <manfred@s-direktnet.de>
|
||||
|
||||
* chown.m4 (jm_FUNC_CHOWN): Add a check to verify that the
|
||||
uid and gid actually remain unchanged.
|
||||
|
||||
1998-07-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-glibc-io.m4: Remove fclose_unlocked.
|
||||
|
||||
1998-07-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* regex.m4: Use syscmd, ifelse, and sysval. Mainly as an exercise
|
||||
to prove that this macro can be used in packages without regex.c.
|
||||
|
||||
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* gettext.m4 (AM_WITH_NLS): Remove intl/libintl.h if <libintl.h>
|
||||
is to be used.
|
||||
|
||||
1998-07-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* gettext.m4: Add -lintl if it's found to be necessary.
|
||||
|
||||
* gettext.m4: New file -- from gettext-0.10.35.
|
||||
* lcmessage.m4: Likewise.
|
||||
* progtest.m4: Likewise.
|
||||
|
||||
* regex.m4 (jm_WITH_REGEX): New file and macro.
|
||||
* jm-macros.m4: Require the new macro.
|
||||
|
||||
1998-06-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* fstypename.m4: Include sys/param.h. NetBSD 1.3.1 requires this
|
||||
for the definition of NGROUPS (used in a system header included
|
||||
by sys/mount.h).
|
||||
|
||||
1998-06-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* ls-mntd-fs.m4: New file.
|
||||
* fstypename.m4: New file.
|
||||
|
||||
* jm-macros.m4: Require the new macro.
|
||||
* jm-glibc-io.m4: New file.
|
||||
|
||||
1998-05-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Add jm_FUNC_LCHOWN.
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
|
||||
##m4-files-begin
|
||||
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 chown.m4 \
|
||||
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 getgroups.m4 getline.m4 \
|
||||
getloadavg.m4 inttypes_h.m4 isc-posix.m4 jm-macros.m4 jm-mktime.m4 \
|
||||
jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 \
|
||||
perl.m4 prereq.m4 putenv.m4 readdir.m4 realloc.m4 ssize_t.m4 stat.m4 \
|
||||
strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4
|
||||
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 check-type.m4 \
|
||||
chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 \
|
||||
getgroups.m4 getline.m4 getloadavg.m4 gettext.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
|
||||
|
||||
##m4-files-end
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -90,12 +89,14 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 chown.m4 \
|
||||
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 getgroups.m4 getline.m4 \
|
||||
getloadavg.m4 inttypes_h.m4 isc-posix.m4 jm-macros.m4 jm-mktime.m4 \
|
||||
jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 \
|
||||
perl.m4 prereq.m4 putenv.m4 readdir.m4 realloc.m4 ssize_t.m4 stat.m4 \
|
||||
strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4
|
||||
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 check-type.m4 \
|
||||
chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 \
|
||||
getgroups.m4 getline.m4 getloadavg.m4 gettext.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
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
|
||||
28
m4/check-type.m4
Normal file
28
m4/check-type.m4
Normal file
@@ -0,0 +1,28 @@
|
||||
#serial 1
|
||||
|
||||
dnl Just like AC_CHECK_TYPE from autoconf-2.12, but also checks in unistd.h
|
||||
dnl on systems that have it. Fujitsu UXP/V needs this for ssize_t.
|
||||
|
||||
undefine([AC_CHECK_TYPE])
|
||||
dnl AC_CHECK_TYPE(TYPE, DEFAULT)
|
||||
AC_DEFUN(AC_CHECK_TYPE,
|
||||
[AC_REQUIRE([AC_HEADER_STDC])dnl
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
AC_MSG_CHECKING(for $1)
|
||||
AC_CACHE_VAL(ac_cv_type_$1,
|
||||
[AC_EGREP_CPP(dnl
|
||||
changequote(<<,>>)dnl
|
||||
<<$1[^a-zA-Z_0-9]>>dnl
|
||||
changequote([,]), [#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
|
||||
AC_MSG_RESULT($ac_cv_type_$1)
|
||||
if test $ac_cv_type_$1 = no; then
|
||||
AC_DEFINE($1, $2)
|
||||
fi
|
||||
])
|
||||
10
m4/chown.m4
10
m4/chown.m4
@@ -17,6 +17,7 @@ AC_DEFUN(jm_FUNC_CHOWN,
|
||||
AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
|
||||
[AC_TRY_RUN([
|
||||
# include <sys/types.h>
|
||||
# include <stat.h>
|
||||
# include <fcntl.h>
|
||||
# ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
@@ -28,7 +29,14 @@ AC_DEFUN(jm_FUNC_CHOWN,
|
||||
char *f = "conftestchown";
|
||||
if (creat (f, 0600) < 0)
|
||||
exit (1);
|
||||
exit (chown (f, (uid_t) -1, (gid_t) -1) == -1 ? 1 : 0);
|
||||
if (stat (f, &before) < 0)
|
||||
exit (1);
|
||||
if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
|
||||
exit (1);
|
||||
if (stat (f, &after) < 0)
|
||||
exit (1);
|
||||
exit ((before.st_uid == after.st_uid
|
||||
&& before.st_gid == after.st_gid) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_chown=yes,
|
||||
|
||||
42
m4/fstypename.m4
Normal file
42
m4/fstypename.m4
Normal file
@@ -0,0 +1,42 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if struct statfs has the f_fstypename member.
|
||||
dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FSTYPENAME,
|
||||
[
|
||||
AC_CACHE_CHECK([for f_fstypename in struct statfs],
|
||||
fu_cv_sys_f_fstypename_in_statfs,
|
||||
[
|
||||
AC_TRY_COMPILE(
|
||||
[
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
],
|
||||
[struct statfs s; int i = sizeof s.f_fstypename;],
|
||||
fu_cv_sys_f_fstypename_in_statfs=yes,
|
||||
fu_cv_sys_f_fstypename_in_statfs=no
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(F_FSTYPENAME_IN_STATFS)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_F_FSTYPENAME_IN_STATFS
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
fi
|
||||
]
|
||||
)
|
||||
324
m4/gettext.m4
Normal file
324
m4/gettext.m4
Normal file
@@ -0,0 +1,324 @@
|
||||
# Macro to add for using GNU gettext.
|
||||
# Ulrich Drepper <drepper@cygnus.com>, 1995.
|
||||
#
|
||||
# This file can be copied and used freely without restrictions. It can
|
||||
# be used in projects which are not available under the GNU Public License
|
||||
# but which still want to provide support for the GNU gettext functionality.
|
||||
# Please note that the actual code is *not* freely available.
|
||||
|
||||
# serial 105
|
||||
|
||||
AC_DEFUN(AM_WITH_NLS,
|
||||
[AC_MSG_CHECKING([whether NLS is requested])
|
||||
dnl Default is enabled NLS
|
||||
AC_ARG_ENABLE(nls,
|
||||
[ --disable-nls do not use Native Language Support],
|
||||
USE_NLS=$enableval, USE_NLS=yes)
|
||||
AC_MSG_RESULT($USE_NLS)
|
||||
AC_SUBST(USE_NLS)
|
||||
|
||||
USE_INCLUDED_LIBINTL=no
|
||||
|
||||
dnl If we use NLS figure out what method
|
||||
if test "$USE_NLS" = "yes"; then
|
||||
AC_DEFINE(ENABLE_NLS)
|
||||
AC_MSG_CHECKING([whether included gettext is requested])
|
||||
AC_ARG_WITH(included-gettext,
|
||||
[ --with-included-gettext use the GNU gettext library included here],
|
||||
nls_cv_force_use_gnu_gettext=$withval,
|
||||
nls_cv_force_use_gnu_gettext=no)
|
||||
AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
|
||||
|
||||
nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
|
||||
if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
|
||||
dnl User does not insist on using GNU NLS library. Figure out what
|
||||
dnl to use. If gettext or catgets are available (in this order) we
|
||||
dnl use this. Else we have to fall back to GNU NLS library.
|
||||
dnl catgets is only used if permitted by option --with-catgets.
|
||||
nls_cv_header_intl=
|
||||
nls_cv_header_libgt=
|
||||
CATOBJEXT=NONE
|
||||
|
||||
AC_CHECK_HEADER(libintl.h,
|
||||
[AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
|
||||
[AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
|
||||
gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
|
||||
|
||||
if test "$gt_cv_func_gettext_libc" != "yes"; then
|
||||
AC_CHECK_LIB(intl, bindtextdomain,
|
||||
[AC_CACHE_CHECK([for gettext in libintl],
|
||||
gt_cv_func_gettext_libintl,
|
||||
[AC_CHECK_LIB(intl, gettext,
|
||||
gt_cv_func_gettext_libintl=yes,
|
||||
gt_cv_func_gettext_libintl=no)],
|
||||
gt_cv_func_gettext_libintl=no)])
|
||||
|
||||
if test "$gt_cv_func_gettext_libintl" = yes; then
|
||||
LIBS="$LIBS -lintl"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test "$gt_cv_func_gettext_libc" = "yes" \
|
||||
|| test "$gt_cv_func_gettext_libintl" = "yes"; then
|
||||
AC_DEFINE(HAVE_GETTEXT)
|
||||
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
|
||||
if test "$MSGFMT" != "no"; then
|
||||
AC_CHECK_FUNCS(dcgettext)
|
||||
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
|
||||
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
|
||||
AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
|
||||
return _nl_msg_cat_cntr],
|
||||
[CATOBJEXT=.gmo
|
||||
DATADIRNAME=share],
|
||||
[CATOBJEXT=.mo
|
||||
DATADIRNAME=lib])
|
||||
INSTOBJEXT=.mo
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
if test "$CATOBJEXT" = "NONE"; then
|
||||
AC_MSG_CHECKING([whether catgets can be used])
|
||||
AC_ARG_WITH(catgets,
|
||||
[ --with-catgets use catgets functions if available],
|
||||
nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
|
||||
AC_MSG_RESULT($nls_cv_use_catgets)
|
||||
|
||||
if test "$nls_cv_use_catgets" = "yes"; then
|
||||
dnl No gettext in C library. Try catgets next.
|
||||
AC_CHECK_LIB(i, main)
|
||||
AC_CHECK_FUNC(catgets,
|
||||
[AC_DEFINE(HAVE_CATGETS)
|
||||
INTLOBJS="\$(CATOBJS)"
|
||||
AC_PATH_PROG(GENCAT, gencat, no)dnl
|
||||
if test "$GENCAT" != "no"; then
|
||||
AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
|
||||
if test "$GMSGFMT" = "no"; then
|
||||
AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
|
||||
fi
|
||||
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
|
||||
USE_INCLUDED_LIBINTL=yes
|
||||
CATOBJEXT=.cat
|
||||
INSTOBJEXT=.cat
|
||||
DATADIRNAME=lib
|
||||
INTLDEPS='$(top_builddir)/intl/libintl.a'
|
||||
INTLLIBS=$INTLDEPS
|
||||
LIBS=`echo $LIBS | sed -e 's/-lintl//'`
|
||||
nls_cv_header_intl=intl/libintl.h
|
||||
nls_cv_header_libgt=intl/libgettext.h
|
||||
fi])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$CATOBJEXT" = "NONE"; then
|
||||
dnl Neither gettext nor catgets in included in the C library.
|
||||
dnl Fall back on GNU gettext library.
|
||||
nls_cv_use_gnu_gettext=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$nls_cv_use_gnu_gettext" = "yes"; then
|
||||
dnl Mark actions used to generate GNU NLS library.
|
||||
INTLOBJS="\$(GETTOBJS)"
|
||||
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
|
||||
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
|
||||
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
|
||||
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
|
||||
AC_SUBST(MSGFMT)
|
||||
USE_INCLUDED_LIBINTL=yes
|
||||
CATOBJEXT=.gmo
|
||||
INSTOBJEXT=.mo
|
||||
DATADIRNAME=share
|
||||
INTLDEPS='$(top_builddir)/intl/libintl.a'
|
||||
INTLLIBS=$INTLDEPS
|
||||
LIBS=`echo $LIBS | sed -e 's/-lintl//'`
|
||||
nls_cv_header_intl=intl/libintl.h
|
||||
nls_cv_header_libgt=intl/libgettext.h
|
||||
fi
|
||||
|
||||
dnl Test whether we really found GNU xgettext.
|
||||
if test "$XGETTEXT" != ":"; then
|
||||
dnl If it is no GNU xgettext we define it as : so that the
|
||||
dnl Makefiles still can work.
|
||||
if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
|
||||
: ;
|
||||
else
|
||||
AC_MSG_RESULT(
|
||||
[found xgettext program is not GNU xgettext; ignore it])
|
||||
XGETTEXT=":"
|
||||
fi
|
||||
fi
|
||||
|
||||
# We need to process the po/ directory.
|
||||
POSUB=po
|
||||
else
|
||||
DATADIRNAME=share
|
||||
nls_cv_header_intl=intl/libintl.h
|
||||
nls_cv_header_libgt=intl/libgettext.h
|
||||
fi
|
||||
if test -z "$nsl_cv_header_intl"; then
|
||||
# Clean out junk possibly left behind by a previous configuration.
|
||||
rm -f intl/libintl.h
|
||||
fi
|
||||
AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
|
||||
AC_OUTPUT_COMMANDS(
|
||||
[case "$CONFIG_FILES" in *po/Makefile.in*)
|
||||
sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
|
||||
esac])
|
||||
|
||||
|
||||
# If this is used in GNU gettext we have to set USE_NLS to `yes'
|
||||
# because some of the sources are only built for this goal.
|
||||
if test "$PACKAGE" = gettext; then
|
||||
USE_NLS=yes
|
||||
USE_INCLUDED_LIBINTL=yes
|
||||
fi
|
||||
|
||||
dnl These rules are solely for the distribution goal. While doing this
|
||||
dnl we only have to keep exactly one list of the available catalogs
|
||||
dnl in configure.in.
|
||||
for lang in $ALL_LINGUAS; do
|
||||
GMOFILES="$GMOFILES $lang.gmo"
|
||||
POFILES="$POFILES $lang.po"
|
||||
done
|
||||
|
||||
dnl Make all variables we use known to autoconf.
|
||||
AC_SUBST(USE_INCLUDED_LIBINTL)
|
||||
AC_SUBST(CATALOGS)
|
||||
AC_SUBST(CATOBJEXT)
|
||||
AC_SUBST(DATADIRNAME)
|
||||
AC_SUBST(GMOFILES)
|
||||
AC_SUBST(INSTOBJEXT)
|
||||
AC_SUBST(INTLDEPS)
|
||||
AC_SUBST(INTLLIBS)
|
||||
AC_SUBST(INTLOBJS)
|
||||
AC_SUBST(POFILES)
|
||||
AC_SUBST(POSUB)
|
||||
])
|
||||
|
||||
AC_DEFUN(AM_GNU_GETTEXT,
|
||||
[AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_PROG_RANLIB])dnl
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
AC_REQUIRE([AC_HEADER_STDC])dnl
|
||||
AC_REQUIRE([AC_C_CONST])dnl
|
||||
AC_REQUIRE([AC_C_INLINE])dnl
|
||||
AC_REQUIRE([AC_TYPE_OFF_T])dnl
|
||||
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
|
||||
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
|
||||
AC_REQUIRE([AC_FUNC_MMAP])dnl
|
||||
|
||||
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
|
||||
unistd.h sys/param.h])
|
||||
AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
|
||||
strdup __argz_count __argz_stringify __argz_next])
|
||||
|
||||
if test "${ac_cv_func_stpcpy+set}" != "set"; then
|
||||
AC_CHECK_FUNCS(stpcpy)
|
||||
fi
|
||||
if test "${ac_cv_func_stpcpy}" = "yes"; then
|
||||
AC_DEFINE(HAVE_STPCPY)
|
||||
fi
|
||||
|
||||
AM_LC_MESSAGES
|
||||
AM_WITH_NLS
|
||||
|
||||
if test "x$CATOBJEXT" != "x"; then
|
||||
if test "x$ALL_LINGUAS" = "x"; then
|
||||
LINGUAS=
|
||||
else
|
||||
AC_MSG_CHECKING(for catalogs to be installed)
|
||||
NEW_LINGUAS=
|
||||
for lang in ${LINGUAS=$ALL_LINGUAS}; do
|
||||
case "$ALL_LINGUAS" in
|
||||
*$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
|
||||
esac
|
||||
done
|
||||
LINGUAS=$NEW_LINGUAS
|
||||
AC_MSG_RESULT($LINGUAS)
|
||||
fi
|
||||
|
||||
dnl Construct list of names of catalog files to be constructed.
|
||||
if test -n "$LINGUAS"; then
|
||||
for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl The reference to <locale.h> in the installed <libintl.h> file
|
||||
dnl must be resolved because we cannot expect the users of this
|
||||
dnl to define HAVE_LOCALE_H.
|
||||
if test $ac_cv_header_locale_h = yes; then
|
||||
INCLUDE_LOCALE_H="#include <locale.h>"
|
||||
else
|
||||
INCLUDE_LOCALE_H="\
|
||||
/* The system does not provide the header <locale.h>. Take care yourself. */"
|
||||
fi
|
||||
AC_SUBST(INCLUDE_LOCALE_H)
|
||||
|
||||
dnl Determine which catalog format we have (if any is needed)
|
||||
dnl For now we know about two different formats:
|
||||
dnl Linux libc-5 and the normal X/Open format
|
||||
test -d intl || mkdir intl
|
||||
if test "$CATOBJEXT" = ".cat"; then
|
||||
AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
|
||||
|
||||
dnl Transform the SED scripts while copying because some dumb SEDs
|
||||
dnl cannot handle comments.
|
||||
sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
|
||||
fi
|
||||
dnl po2tbl.sed is always needed.
|
||||
sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
|
||||
$srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
|
||||
|
||||
dnl In the intl/Makefile.in we have a special dependency which makes
|
||||
dnl only sense for gettext. We comment this out for non-gettext
|
||||
dnl packages.
|
||||
if test "$PACKAGE" = "gettext"; then
|
||||
GT_NO="#NO#"
|
||||
GT_YES=
|
||||
else
|
||||
GT_NO=
|
||||
GT_YES="#YES#"
|
||||
fi
|
||||
AC_SUBST(GT_NO)
|
||||
AC_SUBST(GT_YES)
|
||||
|
||||
dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
|
||||
dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
|
||||
dnl Try to locate is.
|
||||
MKINSTALLDIRS=
|
||||
if test -n "$ac_aux_dir"; then
|
||||
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
|
||||
fi
|
||||
if test -z "$MKINSTALLDIRS"; then
|
||||
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
|
||||
fi
|
||||
AC_SUBST(MKINSTALLDIRS)
|
||||
|
||||
dnl *** For now the libtool support in intl/Makefile is not for real.
|
||||
l=
|
||||
AC_SUBST(l)
|
||||
|
||||
dnl Generate list of files to be processed by xgettext which will
|
||||
dnl be included in po/Makefile.
|
||||
test -d po || mkdir po
|
||||
if test "x$srcdir" != "x."; then
|
||||
if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
|
||||
posrcprefix="$srcdir/"
|
||||
else
|
||||
posrcprefix="../$srcdir/"
|
||||
fi
|
||||
else
|
||||
posrcprefix="../"
|
||||
fi
|
||||
rm -f po/POTFILES
|
||||
sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
|
||||
< $srcdir/po/POTFILES.in > po/POTFILES
|
||||
])
|
||||
23
m4/jm-glibc-io.m4
Normal file
23
m4/jm-glibc-io.m4
Normal file
@@ -0,0 +1,23 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if the glibc *_unlocked I/O macros are available.
|
||||
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 \
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -7,10 +7,11 @@ AC_DEFUN(jm_MACROS,
|
||||
dnl This macro actually runs replacement code. See isc-posix.m4.
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
|
||||
AC_REQUIRE([jm_WITH_REGEX])
|
||||
AC_REQUIRE([jm_ASSERT])
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
AC_REQUIRE([jm_TYPE_SSIZE_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])
|
||||
@@ -27,4 +28,5 @@ AC_DEFUN(jm_MACROS,
|
||||
AC_REQUIRE([jm_FUNC_MALLOC])
|
||||
AC_REQUIRE([jm_FUNC_READDIR])
|
||||
AC_REQUIRE([jm_FUNC_MEMCMP])
|
||||
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
|
||||
])
|
||||
|
||||
19
m4/lcmessage.m4
Normal file
19
m4/lcmessage.m4
Normal file
@@ -0,0 +1,19 @@
|
||||
# Check whether LC_MESSAGES is available in <locale.h>.
|
||||
# Ulrich Drepper <drepper@cygnus.com>, 1995.
|
||||
#
|
||||
# This file can be copied and used freely without restrictions. It can
|
||||
# be used in projects which are not available under the GNU Public License
|
||||
# but which still want to provide support for the GNU gettext functionality.
|
||||
# Please note that the actual code is *not* freely available.
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_LC_MESSAGES,
|
||||
[if test $ac_cv_header_locale_h = yes; then
|
||||
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
|
||||
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
|
||||
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
|
||||
if test $am_cv_val_LC_MESSAGES = yes; then
|
||||
AC_DEFINE(HAVE_LC_MESSAGES)
|
||||
fi
|
||||
fi])
|
||||
201
m4/ls-mntd-fs.m4
Normal file
201
m4/ls-mntd-fs.m4
Normal file
@@ -0,0 +1,201 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl This is not pretty. I've just taken the autoconf code and wrapped
|
||||
dnl it in an AC_DEFUN.
|
||||
dnl
|
||||
dnl CAUTION: This is very fragile. It relies on several checks that
|
||||
dnl are still in fileutils' configure.in:
|
||||
dnl FIXME: add AC_REQUIRE uses to pull in all definitions required
|
||||
dnl for all uses of $ac_cv_func_* and $ac_cv_header_* variables below.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
|
||||
[
|
||||
# Determine how to get the list of mounted filesystems.
|
||||
list_mounted_fs=
|
||||
|
||||
# If the getmntent function is available but not in the standard library,
|
||||
# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
|
||||
AC_FUNC_GETMNTENT
|
||||
|
||||
# This test must precede the ones for getmntent because Unicos-9 is
|
||||
# reported to have the getmntent function, but its support is incompatible
|
||||
# with other getmntent implementations.
|
||||
|
||||
# NOTE: Normally, I wouldn't use a check for system type as I've done for
|
||||
# `CRAY' below since that goes against the whole autoconf philosophy. But
|
||||
# I think there is too great a chance that some non-Cray system has a
|
||||
# function named listmntent to risk the false positive.
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# Cray UNICOS 9
|
||||
AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
|
||||
[fu_cv_sys_mounted_cray_listmntent=no
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef _CRAY
|
||||
yes
|
||||
#endif
|
||||
], [test $ac_cv_func_listmntent = yes \
|
||||
&& fu_cv_sys_mounted_cray_listmntent=yes]
|
||||
)
|
||||
]
|
||||
)
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
|
||||
if test $fu_cv_sys_mounted_cray_listmntent = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_LISTMNTENT)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_func_getmntent = yes; then
|
||||
|
||||
# This system has the getmntent function.
|
||||
# Determine whether it's the one-argument variant or the two-argument one.
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# 4.3BSD, SunOS, HP-UX, Dynix, Irix
|
||||
AC_MSG_CHECKING([for one-argument getmntent function])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
|
||||
[test $ac_cv_header_mntent_h = yes \
|
||||
&& fu_cv_sys_mounted_getmntent1=yes \
|
||||
|| fu_cv_sys_mounted_getmntent1=no])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
|
||||
if test $fu_cv_sys_mounted_getmntent1 = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_GETMNTENT1)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# SVR4
|
||||
AC_MSG_CHECKING([for two-argument getmntent function])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
|
||||
[AC_EGREP_HEADER(getmntent, sys/mnttab.h,
|
||||
fu_cv_sys_mounted_getmntent2=yes,
|
||||
fu_cv_sys_mounted_getmntent2=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
|
||||
if test $fu_cv_sys_mounted_getmntent2 = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_GETMNTENT2)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# DEC Alpha running OSF/1.
|
||||
AC_MSG_CHECKING([for getfsstat function])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/fs_types.h>],
|
||||
[struct statfs *stats;
|
||||
int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
|
||||
fu_cv_sys_mounted_getsstat=yes,
|
||||
fu_cv_sys_mounted_getsstat=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
|
||||
if test $fu_cv_sys_mounted_getsstat = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_GETFSSTAT)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# AIX.
|
||||
AC_MSG_CHECKING([for mntctl function and struct vmount])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
|
||||
[AC_TRY_CPP([#include <fshelp.h>],
|
||||
fu_cv_sys_mounted_vmount=yes,
|
||||
fu_cv_sys_mounted_vmount=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
|
||||
if test $fu_cv_sys_mounted_vmount = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_VMOUNT)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# SVR3
|
||||
AC_MSG_CHECKING([for FIXME existence of three headers])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
|
||||
[AC_TRY_CPP([
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/fstyp.h>
|
||||
#include <mnttab.h>],
|
||||
fu_cv_sys_mounted_fread_fstyp=yes,
|
||||
fu_cv_sys_mounted_fread_fstyp=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
|
||||
if test $fu_cv_sys_mounted_fread_fstyp = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_FREAD_FSTYP)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# 4.4BSD and DEC OSF/1.
|
||||
AC_MSG_CHECKING([for getmntinfo function])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
|
||||
[
|
||||
ok=
|
||||
if test $ac_cv_func_getmntinfo = yes; then
|
||||
AC_EGREP_HEADER(f_type;, sys/mount.h,
|
||||
ok=yes)
|
||||
fi
|
||||
test -n "$ok" \
|
||||
&& fu_cv_sys_mounted_getmntinfo=yes \
|
||||
|| fu_cv_sys_mounted_getmntinfo=no
|
||||
])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
|
||||
if test $fu_cv_sys_mounted_getmntinfo = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_GETMNTINFO)
|
||||
fi
|
||||
fi
|
||||
|
||||
# FIXME: add a test for netbsd-1.1 here
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# Ultrix
|
||||
AC_MSG_CHECKING([for getmnt function])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
|
||||
[AC_TRY_CPP([
|
||||
#include <sys/fs_types.h>
|
||||
#include <sys/mount.h>],
|
||||
fu_cv_sys_mounted_getmnt=yes,
|
||||
fu_cv_sys_mounted_getmnt=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
|
||||
if test $fu_cv_sys_mounted_getmnt = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_GETMNT)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
# SVR2
|
||||
AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
|
||||
AC_CACHE_VAL(fu_cv_sys_mounted_fread,
|
||||
[AC_TRY_CPP([#include <mnttab.h>],
|
||||
fu_cv_sys_mounted_fread=yes,
|
||||
fu_cv_sys_mounted_fread=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_mounted_fread)
|
||||
if test $fu_cv_sys_mounted_fread = yes; then
|
||||
list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_FREAD)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$list_mounted_fs"; then
|
||||
AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
|
||||
# FIXME -- no need to abort building the whole package
|
||||
# Can't build mountlist.c or anything that needs its functions
|
||||
fi
|
||||
|
||||
])
|
||||
47
m4/progtest.m4
Normal file
47
m4/progtest.m4
Normal file
@@ -0,0 +1,47 @@
|
||||
# Search path for a program which passes the given test.
|
||||
# Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
#
|
||||
# This file can be copied and used freely without restrictions. It can
|
||||
# be used in projects which are not available under the GNU Public License
|
||||
# but which still want to provide support for the GNU gettext functionality.
|
||||
# Please note that the actual code is *not* freely available.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
|
||||
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
|
||||
AC_DEFUN(AM_PATH_PROG_WITH_TEST,
|
||||
[# Extract the first word of "$2", so it can be a program name with args.
|
||||
set dummy $2; ac_word=[$]2
|
||||
AC_MSG_CHECKING([for $ac_word])
|
||||
AC_CACHE_VAL(ac_cv_path_$1,
|
||||
[case "[$]$1" in
|
||||
/*)
|
||||
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
for ac_dir in ifelse([$5], , $PATH, [$5]); do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f $ac_dir/$ac_word; then
|
||||
if [$3]; then
|
||||
ac_cv_path_$1="$ac_dir/$ac_word"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
dnl If no 4th arg is given, leave the cache variable unset,
|
||||
dnl so AC_PATH_PROGS will keep looking.
|
||||
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
|
||||
])dnl
|
||||
;;
|
||||
esac])dnl
|
||||
$1="$ac_cv_path_$1"
|
||||
if test -n "[$]$1"; then
|
||||
AC_MSG_RESULT([$]$1)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
AC_SUBST($1)dnl
|
||||
])
|
||||
23
m4/regex.m4
Normal file
23
m4/regex.m4
Normal file
@@ -0,0 +1,23 @@
|
||||
#serial 2
|
||||
|
||||
dnl Derived from code in GNU grep.
|
||||
|
||||
AC_DEFUN(jm_WITH_REGEX,
|
||||
[
|
||||
dnl Even packages that don't use regex.c can use this macro.
|
||||
dnl Of course, for them it doesn't do anything.
|
||||
|
||||
syscmd([test -f lib/regex.c])
|
||||
ifelse(sysval, 0,
|
||||
[
|
||||
AC_ARG_WITH(included-regex,
|
||||
[ --without-included-regex don't compile regex (use with caution)],
|
||||
jm_with_regex=$withval,
|
||||
jm_with_regex=yes)
|
||||
if test "$jm_with_regex" = yes; then
|
||||
LIBOBJS="$LIBOBJS regex.o"
|
||||
fi
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
# If ssize_t is not defined in sys/types.h, define it to `int'.
|
||||
|
||||
AC_DEFUN(jm_TYPE_SSIZE_T,
|
||||
[AC_CACHE_CHECK(for ssize_t in sys/types.h, jm_ac_cv_type_ssize_t,
|
||||
[
|
||||
AC_EGREP_HEADER(ssize_t, sys/types.h,
|
||||
jm_ac_cv_type_ssize_t=yes,
|
||||
jm_ac_cv_type_ssize_t=no)
|
||||
if test $jm_ac_cv_type_ssize_t = no; then
|
||||
AC_DEFINE(ssize_t, int)
|
||||
fi
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
25
m4/st_dm_mode.m4
Normal file
25
m4/st_dm_mode.m4
Normal file
@@ -0,0 +1,25 @@
|
||||
# Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
|
||||
|
||||
AC_DEFUN(AC_STRUCT_ST_DM_MODE,
|
||||
[AC_CACHE_CHECK([for st_dm_mode in struct stat], ac_cv_struct_st_dm_mode,
|
||||
[AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <sys/stat.h>], [struct stat s; s.st_dm_mode;],
|
||||
ac_cv_struct_st_dm_mode=yes,
|
||||
ac_cv_struct_st_dm_mode=no)])
|
||||
|
||||
if test $ac_cv_struct_st_dm_mode = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to add the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(ST_DM_MODE)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_ST_DM_MODE
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
fi
|
||||
]
|
||||
)
|
||||
30
m4/st_mtim.m4
Normal file
30
m4/st_mtim.m4
Normal file
@@ -0,0 +1,30 @@
|
||||
#serial 3
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
# Define ST_MTIM_NSEC to be the nanoseconds member of struct stat's st_mtim,
|
||||
# if it exists.
|
||||
|
||||
AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
|
||||
[AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
|
||||
ac_cv_struct_st_mtim_nsec,
|
||||
[ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
ac_cv_struct_st_mtim_nsec=no
|
||||
# tv_nsec -- the usual case
|
||||
# _tv_nsec -- Solaris 2.6, if
|
||||
# (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
|
||||
# && !defined __EXTENSIONS__)
|
||||
# st__tim.tv_nsec -- UnixWare 2.1.2
|
||||
for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
|
||||
CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
|
||||
[ac_cv_struct_st_mtim_nsec=$ac_val; break])
|
||||
done
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"])
|
||||
|
||||
if test $ac_cv_struct_st_mtim_nsec != no; then
|
||||
AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec)
|
||||
fi
|
||||
]
|
||||
)
|
||||
18
m4/utime.m4
Normal file
18
m4/utime.m4
Normal file
@@ -0,0 +1,18 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering
|
||||
dnl Replace the utime function on systems that need it.
|
||||
|
||||
dnl FIXME
|
||||
|
||||
AC_DEFUN(jm_FUNC_UTIME,
|
||||
[
|
||||
AC_CHECK_HEADERS(utime.h)
|
||||
AC_REQUIRE([jm_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([AC_FUNC_UTIME_NULL])
|
||||
|
||||
if test $ac_cv_func_utime_null = no; then
|
||||
jm_FUNC_UTIMES_NULL
|
||||
AC_REPLACE_FUNCS(utime)
|
||||
fi
|
||||
])
|
||||
39
m4/utimes.m4
Normal file
39
m4/utimes.m4
Normal file
@@ -0,0 +1,39 @@
|
||||
#serial 2
|
||||
|
||||
dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL.
|
||||
|
||||
AC_DEFUN(jm_FUNC_UTIMES_NULL,
|
||||
[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
|
||||
[rm -f conftestdata; > conftestdata
|
||||
AC_TRY_RUN([
|
||||
/* In case stat has been defined to rpl_stat, undef it here. */
|
||||
#undef stat
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
main() {
|
||||
struct stat s, t;
|
||||
exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
|
||||
&& stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
|
||||
&& t.st_mtime - s.st_mtime < 120));
|
||||
}],
|
||||
ac_cv_func_utimes_null=yes,
|
||||
ac_cv_func_utimes_null=no,
|
||||
ac_cv_func_utimes_null=no)
|
||||
rm -f core core.* *.core])
|
||||
|
||||
if test $ac_cv_func_utimes_null = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(UTIMES_NULL)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_UTIMES_NULL
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
fi
|
||||
]
|
||||
)
|
||||
@@ -1,3 +1,550 @@
|
||||
1998-09-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16w.
|
||||
|
||||
* src/df.c (show_dev) [!posix_format]: When using --print-type,
|
||||
let the device path and the file system type share a single (wider)
|
||||
field if their combined lengths allow it. From Andries Brouwer.
|
||||
|
||||
* tests/touch/empty-file: Upon failure, suggest how to rerun the test
|
||||
with longer delay, in case NFS clock skew was the cause of the failure.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* tests/ls-2/quoting: Add tests.
|
||||
* tests/Fetish.pm (run_tests): Add simple PRE/POST hooks.
|
||||
(_create_file): Don't include $$ in temp file name.
|
||||
(run_tests): Use shorter suffixes for temp file names.
|
||||
|
||||
1998-09-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/touch.c: Include posixtm.h.
|
||||
(usage): Correct the description of the format of the
|
||||
date string argument to -t option.
|
||||
(main): Update to use rewritten posixtime function.
|
||||
Reported by Andries Brouwer.
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Change posixtm.y to posixtm.c.
|
||||
(noinst_HEADERS): Add posixtm.h.
|
||||
|
||||
* lib/posixtm.h: New file.
|
||||
* lib/posixtm.c: New file. Rewritten based on posixtm.y.
|
||||
* lib/posixtm.y: Remove file.
|
||||
|
||||
1998-09-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/ls.c (print_dir_name): Put back.
|
||||
(print_dir): Also print directory name header if print_dir_name is
|
||||
true.
|
||||
|
||||
1998-08-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16v.
|
||||
|
||||
* src/du.c (long_options): Use corresponding short-option character
|
||||
in place of `1', and `NULL' in place of pointer in initialization.
|
||||
* src/cp.c (long_opts): Likewise.
|
||||
* src/ln.c (long_options): Likewise.
|
||||
* src/mkdir.c (longopts): Likewise.
|
||||
* src/rmdir.c (longopts): Likewise.
|
||||
* src/chown.c: Replace 12 and 13 with CHAR_MAX + 1 and CHAR_MAX + 2
|
||||
respectively.
|
||||
* src/chmod.c (long_options): Replace 12 with CHAR_MAX + 1.
|
||||
* src/chgrp.c (long_options): Replace 12 with CHAR_MAX + 1.
|
||||
|
||||
* tests/Fetish.pm: New file -- moved from ls-2/.
|
||||
* configure.in (AC_OUTPUT): Add tests/dircolors/Makefile.
|
||||
* tests/Makefile.am (SUBDIRS): Add dircolors.
|
||||
(EXTRA_DIST): Add Fetish.pm.
|
||||
* tests/dircolors: New directory
|
||||
|
||||
* src/ls.c (print_dir_name): Remove global variable.
|
||||
(print_dir): When trace_dirs is set, always print the directory
|
||||
name header.
|
||||
|
||||
1998-08-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dircolors.c (dc_parse_stream): Don't segfault when a line
|
||||
contains only one token. Reported by Olav Morkrid.
|
||||
|
||||
1998-08-24 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/system.h (CHAR_MIN, CHAR_MAX):
|
||||
Renamed from SCHAR_MIN, SCHAR_MAX, since these
|
||||
macros apply to char, not signed char.
|
||||
|
||||
* src/df.c, src/du.c, src/touch.c (long_options, main):
|
||||
Don't assume ASCII.
|
||||
|
||||
1998-08-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Port nanosecond-resolution times to UnixWare 2.1.2 and
|
||||
pedantic Solaris 2.6.
|
||||
|
||||
* configure.in (AC_STRUCT_ST_MTIM_NSEC): Renamed from AC_STRUCT_ST_MTIM.
|
||||
* acconfig.h (ST_MTIM_NSEC): New #undef.
|
||||
* src/system.h: (ST_TIME_CMP_NS, ATIME_CMP, CTIME_CMP, MTIME_CMP):
|
||||
Use new ST_MTIM_NSEC macro.
|
||||
|
||||
1998-08-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/filemode.h (PARAMS): Define and use.
|
||||
From Kaveh Ghazi.
|
||||
|
||||
1998-08-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16u.
|
||||
|
||||
* Makefile.maint (announcement): New target.
|
||||
|
||||
* tests/mv/into-self: Update to reflect changed behavior of mv.
|
||||
* src/mv.c (do_move): Fail upon attempt to move a directory into itself.
|
||||
With prodding from François Pinard :-)
|
||||
|
||||
* tests/ls-2/Fetish.pm: New file
|
||||
* tests/ls-2/run-test: New file
|
||||
|
||||
* src/copy.c (copy_internal) [one-file-system]: Do copy mount point
|
||||
directories (but none of their entries). This makes `cp --archive
|
||||
--one-file-system' use the same policy `tar --one-file-system' does.
|
||||
From Marty Leisner.
|
||||
|
||||
* src/ls.c (qmark_funny_chars): Add comment from Paul eggert.
|
||||
|
||||
1998-08-14 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/mv/setup: Work around another bug in Ultrix4.3a's /bin/sh.
|
||||
Reported by Christian von Roques.
|
||||
|
||||
* configure.in (AC_OUTPUT): Add tests/ls-2/Makefile.
|
||||
* tests/Makefile.am (SUBDIRS): Add ls-2.
|
||||
* tests/ls-2: New directory
|
||||
|
||||
1998-08-14 Christian von Roques <roques@pond.sub.org>
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNT]: Don't
|
||||
infloop on getmnt(2) returning 0.
|
||||
|
||||
* tests/cp/backup-is-src: Avoid bug in Ultrix4.3a /bin/sh,
|
||||
not initializing output redirection of : command.
|
||||
* tests/mv/backup-is-src: Likewise.
|
||||
* tests/rm/i-1: Likewise.
|
||||
|
||||
1998-08-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* po/Makefile.in.in: Provide automake-style DESTDIR support.
|
||||
From Johan Danielsson.
|
||||
(DISTFILES): Remove ChangeLog.
|
||||
po/ChangeLog: Remove empty file.
|
||||
|
||||
* configure.in (AC_STRUCT_ST_DM_MODE): Use it.
|
||||
|
||||
* src/ls.c: Include filemode.h.
|
||||
* src/chmod.c: Likewise.
|
||||
|
||||
* lib/filemode.c (ftypelet): Add comments for Cray DMF support.
|
||||
From Johan Danielsson.
|
||||
Protoize. Tsort function definitions and remove prototypes of
|
||||
static functions.
|
||||
(mode_string): Remove prototype.
|
||||
* lib/filemode.h (mode_string): New file.
|
||||
* lib/Makefile.am (noinst_HEADERS): Add filemode.h.
|
||||
|
||||
1998-08-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16t.
|
||||
|
||||
1998-07-31 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Add support for filesystems whose timestamps have better resolution
|
||||
than 1 second (e.g. Solaris 2.6, recent Linux kernels).
|
||||
|
||||
* configure.in (AC_STRUCT_ST_MTIM): Add.
|
||||
|
||||
* src/copy.c (copy_internal): Compare time stamps with
|
||||
subsecond resolution if available.
|
||||
|
||||
* src/ls.c (compare_ctime, rev_cmp_ctime, compare_mtime,
|
||||
rev_cmp_mtime, compare_atime, rev_cmp_atime): Compare time
|
||||
stamps with subsecond resolution if available.
|
||||
|
||||
* src/system.h: (ST_TIME_CMP_NS, ST_TIME_CMP, ATIME_CMP,
|
||||
CTIME_CMP, MTIME_CMP): New macros.
|
||||
|
||||
1998-08-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add slovak (sk) and norwegian (no).
|
||||
|
||||
1998-07-28 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list): Remove all_fs
|
||||
argument, but put the necessary information into the result so
|
||||
that the caller can ignore filesystems that he's not
|
||||
interested in.
|
||||
|
||||
* lib/mountlist.h (struct mount_entry):
|
||||
New members me_dummy, me_remote.
|
||||
(read_filesystem_list): Remove all_fs argument.
|
||||
(REMOTE_FS_TYPE): Remove.
|
||||
(ME_DUMMY, ME_REMOTE): New macros.
|
||||
|
||||
* lib/xstrtol.c: Remove duplicate include of <stdio.h>.
|
||||
|
||||
* src/df.c (show_all_fs):
|
||||
Revert to boolean value; the old negative value is
|
||||
now in show_local_fs.
|
||||
(show_local_fs): New variable.
|
||||
(show_dev): New args me_dummy and me_class. Use show_local_fs
|
||||
and boolean show_all_fs in combination with these new args
|
||||
to decide whether to show a device.
|
||||
(show_disk): Pass flags to show_dev.
|
||||
(show_point): Use a non-dummy mount entry if possible.
|
||||
(show_all_entries): Pass flags to show_dev.
|
||||
(main): --local sets show_local_fs now. Ask for file system types if
|
||||
show_local_fs is nonzero, since ME_REMOTE might need them.
|
||||
|
||||
1998-07-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/install/Makefile.am (TESTS_ENVIRONMENT): Set LS, MKDIR, and RM.
|
||||
|
||||
* tests/install/basic-1: Add a test for this.
|
||||
* src/install.c: Make copy create each destination file initially
|
||||
with mode 0600 so strip will work, then apply specified mode.
|
||||
Arne Henrik Juul reported that `./ginstall -s -c -m 555 dd /tmp' failed.
|
||||
|
||||
1998-07-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/mv.c (chown): Remove unused definition.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* src/rmdir.c (main): rmdir fails with EEXIST on some systems.
|
||||
Handle that, so --ignore-fail-on-non-empty works.
|
||||
(EEXIST): Define to zero if not defined.
|
||||
(ENOTEMPTY): Likewise.
|
||||
|
||||
* tests/cp/same-file: Remove `diff' I'd put in for debugging.
|
||||
Exit with the status from cmp.
|
||||
|
||||
* Version 3.16s.
|
||||
|
||||
* tests/cp/same-file: Skip three more unportable tests.
|
||||
These failed on SunOS4.1.4.
|
||||
|
||||
* src/copy.c (SAME_INODE): Remove definition.
|
||||
* src/sys2.h (SAME_INODE): Define it here instead.
|
||||
|
||||
* src/remove.c (same_file): New function.
|
||||
(remove_dir): Use it to give a better diagnostic when rmdir fails
|
||||
because it can't remove the current directory.
|
||||
|
||||
* src/df.c (long_options): Changes table entries not to use this form:
|
||||
{"all", no_argument, &show_all_fs, 1},
|
||||
but rather this form:
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
Using the latter, all the option handling in one place: the getopt loop.
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNTINFO]:
|
||||
Use fsp_to_string.
|
||||
(fsp_to_string): Don't xmalloc return value (yet).
|
||||
(xatoi): Ansideclify.
|
||||
(fstype_to_string): Ansideclify.
|
||||
* lib/mountlist.h: Define and use PARAMS macro.
|
||||
|
||||
* lib/utime.c: New file.
|
||||
* src/touch.c (utime_now): Moved into m4/utimes.m4.
|
||||
(touch) [!HAVE_UTIME_NULL]: Remove #ifdef and the use of utime_now
|
||||
in the if-block.
|
||||
|
||||
* configure.in (jm_FUNC_UTIME): Use this, not AC_FUNC_UTIME.
|
||||
|
||||
1998-07-22 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/human.c (human_readable): amt -> damt, to fix typo when
|
||||
computing which power to use after overflow occurs during
|
||||
multiplication.
|
||||
|
||||
* lib/xstrtol.c: Include <stdio.h> if NDEBUG is not defined;
|
||||
needed on SunOS 4.
|
||||
|
||||
1998-07-21 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Add df -l or --local option.
|
||||
* doc/fileutils.texi: Document it.
|
||||
* lib/mountlist.h (REMOTE_FS_TYPE): New macro.
|
||||
* lib/mountlist.c (read_filesystem_list):
|
||||
If all_fs is negative, omit non-local filesytems.
|
||||
|
||||
* src/df.c (show_dev): Omit local devices if show_all_fs is negative.
|
||||
(show_all_fs): If negative, omit non-local filesystems.
|
||||
All uses of (all_fs != 0) changed to (all_fs > 0).
|
||||
(long_options, usage, main): Add -l or --local option.
|
||||
(main): When asking for df of an explicit file name, get all
|
||||
the mount points, so that we're more likely to find it when
|
||||
we look it up.
|
||||
|
||||
1998-07-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/copy.c (copy_internal): Add another exclusion from the
|
||||
sameness test: when --force has been specified, the destination
|
||||
is unlinked before any copy.
|
||||
(copy_internal): Add yet another: when both src and dest are symlinks.
|
||||
|
||||
* tests/touch: New subdir.
|
||||
* tests/Makefile.am (SUBDIRS): Add touch.
|
||||
* configure.in (AC_OUTPUT): Add tests/touch/Makefile.
|
||||
|
||||
* tests/mv/into-self-2: New test.
|
||||
* tests/mv/Makefile.am (TESTS): Add into-self-2.
|
||||
|
||||
1998-07-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list): Fix more memory leaks on
|
||||
failure.
|
||||
|
||||
1998-07-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Work around failure of chown calls on m68k-motorola-sysv systems.
|
||||
* src/chown.c: Include lchown.h.
|
||||
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
|
||||
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
|
||||
* lib/lchown.c: Include lchown.h.
|
||||
Reported by and with suggestions from Manfred Hollstein.
|
||||
|
||||
1998-07-12 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/df.c (print_header): Print "1k-blocks", not "1.0k-blocks".
|
||||
|
||||
1998-07-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h [HAVE_FCLOSE_UNLOCKED]: Remove unnecessary block.
|
||||
Suggestion from Ulrich Drepper.
|
||||
|
||||
1998-07-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/safe-read.c (safe_read): Change type of pointer parameter to
|
||||
`void' to avoid Irix4 cc errors. Reported by Kaveh Ghazi.
|
||||
* lib/safe-read.h: Update prototype.
|
||||
|
||||
* src/dircolors.c (parse_line): Add casts to avoid errors from
|
||||
Irix4's `cc' C compiler. From Kaveh Ghazi.
|
||||
|
||||
* lib/xstrtol.c: Include stdio.h. Required on some systems when
|
||||
using assert. From Kaveh Ghazi.
|
||||
|
||||
* tests/mv/backup-is-src: Use cmp, not diff.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
1998-07-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16r.
|
||||
|
||||
* src/remove.c (remove_dir): Use fprintf (not error) to avoid
|
||||
newline in prompt.
|
||||
|
||||
1998-06-30 Paul Eggert <eggert@shade.twinsun.com>
|
||||
|
||||
* lib/mountlist.c: (read_filesystem_list):
|
||||
Don't leak memory on failure.
|
||||
Don't create a dummy struct mount_entry entry;
|
||||
use the address-of-the-tail-address method instead.
|
||||
Preserve errno if possible on failure, setting it to 0 if inapplicable.
|
||||
Close file descriptor leak if the F_SETLKW failed.
|
||||
Report an error if SVR4 lock file cannot be opened for some reason
|
||||
other than a nonexistent lock file.
|
||||
|
||||
1998-07-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (AM_WITH_REGEX): Remove. Now the replacement
|
||||
macro, jm_WITH_REGEX, is bundled with the rest in jm_MACROS.
|
||||
* acconfig.h (WITH_REGEX): Remove undef.
|
||||
* lib/Makefile.am (noinst_HEADERS): Add regex.h.
|
||||
* lib/rpmatch.c: Remove #ifdef around <regex.h> inclusion.
|
||||
* lib/rx.c: Remove file.
|
||||
* lib/rx.h: Remove file.
|
||||
|
||||
* src/df.c (df_readable): Rename local so as not to shadow global.
|
||||
|
||||
* src/copy.c (SAME_INODE): New macro.
|
||||
Use it to replace open-coded equivalents.
|
||||
(copy_internal): Rename variable and reverse sense of tests
|
||||
to make the code a little clearer.
|
||||
|
||||
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/copy.c (copy_internal): Try harder identifying a relative
|
||||
symbolic link in the current directory.
|
||||
|
||||
* src/copy.c (copy_internal): Don't skip test for same file if
|
||||
creating a hardlink from symlink over a non-symlink while making
|
||||
backups.
|
||||
* tests/cp/same-file: Skip tests that depend on link(2) not
|
||||
following symlinks.
|
||||
|
||||
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/copy.c (copy_internal): Don't call chown on a symlink.
|
||||
|
||||
1998-07-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/xstrtol.c: Don't define NDEBUG here, now that it's done via
|
||||
configure's --disable-assert option.
|
||||
|
||||
1998-06-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list):
|
||||
Plug file descriptor leak on failure.
|
||||
Report failure if lock file can't be opened for some reason
|
||||
other than nonexistence.
|
||||
|
||||
1998-06-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16q.
|
||||
|
||||
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNTENT2]:
|
||||
Always close stream and file descriptor before returning.
|
||||
|
||||
* src/df.c (main): Move the test of the result of the
|
||||
read_filesystem_list call up out of if-block -- code in the
|
||||
else-block depends on it too.
|
||||
|
||||
1998-06-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/mountlist.c: (read_filesystem_list): If SVR4, lock
|
||||
/etc/.mnttab.lock if available, to avoid race conditions
|
||||
(e.g. with the automounter on Solaris 2.6).
|
||||
|
||||
Include <errno.h>, <fcntl.h>, <unistd.h>.
|
||||
|
||||
1998-06-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/mountlist.c (fstype_to_string): Guard with
|
||||
#if ! HAVE_F_FSTYPENAME_IN_STATFS.
|
||||
|
||||
1998-06-28 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Add support for new --block-size option and
|
||||
BLOCK_SIZE. DF_BLOCK_SIZE, etc. variables to `df', `du', and `ls'.
|
||||
Adjust df output slightly to accommodate larger filesystems.
|
||||
|
||||
* lib/human.c, lib/human.h (human_readable): Coalesce last two args
|
||||
into one, for convenience. All callers changed.
|
||||
(human_block_size): New function.
|
||||
* lib/human.c: Include <config.h> only if HAVE_CONFIG_H.
|
||||
Include <stdlib.h> if HAVE_STDLIB_H;
|
||||
declare getenv unless HAVE_DECL_GETENV.
|
||||
(_): New macro.
|
||||
Include <argmatch.h>, <error.h>, <xstrtoul.h>.
|
||||
(DEFAULT_BLOCK_SIZE): New macro.
|
||||
(block_size_args, block_size_types): New constants.
|
||||
(humblock): New function.
|
||||
* lib/xstrtol.h (__ZLONG_MAX): Remove.
|
||||
* lib/xstrtol.c (bkm_scale): Don't assume that you can convert
|
||||
unsigned long to double without losing information.
|
||||
(bkm_scale_by_power): New function.
|
||||
|
||||
* lib/xstrtol.c (__xstrtol), src/dd.c (parse_integer):
|
||||
Add support for SI-like suffixes like "GB" and "TD".
|
||||
* src/dd.c (usage): Describe it.
|
||||
|
||||
* src/df.c, src/du.c, src/ls.c (human_readable_base, output_units):
|
||||
Remove; replace with new variable output_block_size. All uses changed.
|
||||
(long_options, usage, main): Add --block-size.
|
||||
(main, decode_switches): Use new human_block_size function to
|
||||
initialize output block size consistently with other programs.
|
||||
|
||||
* src/df.c (print_header, show_dev): Shrink some columns and expand
|
||||
others, to squeeze in support for today's larger filesystems.
|
||||
(print_header): Print output block size using power-of-1024 SI format.
|
||||
(df_readable): Coalesce last two args into one, for convenience.
|
||||
All callers changed.
|
||||
(main): Remove check for portable output format and larger
|
||||
or human-readable block sizes.
|
||||
|
||||
* NEWS, doc/fileutils.texi: Describe above changes.
|
||||
|
||||
1998-06-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/ls.c (usage): Make --kilobytes description consistent with
|
||||
that in du and df. From Göran Uddeborg.
|
||||
|
||||
* lib/mountlist.c (fsp_to_string): Clean out some crufty #ifdefs
|
||||
now that we're using the jm_FSTYPENAME autoconf macro.
|
||||
James Tanis reported the old version didn't compile on BSDI3.
|
||||
|
||||
* configure.in: Move big block of list_mounted_fs checks into
|
||||
new jm_LIST_MOUNTED_FILESYSTEMS macro.
|
||||
Use new jm_FSTYPENAME macro.
|
||||
|
||||
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
|
||||
* src/ls.c: Add DIRED_ prefix to the macros: PUTCHAR, FPUTS, and
|
||||
FPUTS_LITERAL
|
||||
|
||||
1998-06-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/copy.c (copy_reg): Detect identical source and dest here.
|
||||
(copy_internal): Make the test symmetric.
|
||||
|
||||
* tests/cp/same-file: New file.
|
||||
* tests/cp/Makefile.am (TESTS): Add it.
|
||||
|
||||
1998-06-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/remove.c (remove_file): Remove `non-directory' part of
|
||||
`removing non-directory FILE' verbose message.
|
||||
|
||||
1998-06-23 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/df.c (show_dev): Increase field width for blocks, used,
|
||||
and available columns from 7 to 8.
|
||||
|
||||
1998-06-21 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* aclocal.m4: Regenerate with fixed gettext.m4 installed.
|
||||
See README-alpha for details.
|
||||
|
||||
1998-06-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/automake-wrap: Quote `&' in sed replacement text.
|
||||
|
||||
1998-05-31 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16p.
|
||||
|
||||
* src/install.c (main): Fix argv-handling bug in my 1998-05-09 change.
|
||||
Reported by Don Parsons.
|
||||
|
||||
1998-05-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/ls/time-1: Clean up ctime test. Note that it fails also
|
||||
on Solaris5.5.1 tmpfs file systems.
|
||||
|
||||
Solve the `rm -f rm' problem more cleanly.
|
||||
* src/.rm-warning: Remove file.
|
||||
* src/automake-wrap: New file.
|
||||
* src/Makefile.am (AUTOMAKE): Define to use automake-wrap.
|
||||
(Makefile.in): Depend on automake-wrap.
|
||||
(EXTRA_DIST): Add automake-wrap.
|
||||
(DISTCLEANFILES): Remove definition.
|
||||
(rm_DEPENDENCIES): Likewise.
|
||||
(.rm-warn-stamp): Remove rule.
|
||||
|
||||
1998-05-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/ls/Makefile.am (TESTS): s/cr-1/rt-1/
|
||||
* tests/ls/rt-1: New file, renamed from cr-1.
|
||||
|
||||
1998-05-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/Makefile.am (.rm-warn-stamp): Cope with $(srcdir) != ".".
|
||||
|
||||
* tests/ls/cr-1: Don't use the ctime for testing, it is impossible
|
||||
to set it reliably.
|
||||
|
||||
1998-05-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
|
||||
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
|
||||
[!_GNU_SOURCE]: Add #undef instead.
|
||||
|
||||
1998-05-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16o.
|
||||
|
||||
@@ -1,4 +1,49 @@
|
||||
Changes in release 3.17:
|
||||
[3.16w]
|
||||
* touch now interprets `-t TIME-DATE' as POSIX specifies
|
||||
* `ls EMPTY-DIR EMPTY-DIR' once again outputs the directory names
|
||||
[3.16v]
|
||||
* portability fixes
|
||||
* `ls -R EMPTY-DIR' now outputs the name of the directory
|
||||
[3.16u]
|
||||
* mv now fails (as it should) upon attempt to move a directory into itself
|
||||
* `cp -a --one-file-system' now copies any mount point directories it
|
||||
encounters on the selected file system.
|
||||
[3.16t]
|
||||
* cp (with --update) and ls compare time stamps with subsecond resolution when
|
||||
available (e.g., on systems with recent Linux kernels and on Solaris 2.6).
|
||||
* install once again does the -m-specified chmod *after* running strip
|
||||
(this fixes another bug introduced in 3.16o)
|
||||
[3.16s]
|
||||
* df accept a new option --local (-l)
|
||||
* touch works around a system-specific bug so it now affects existing,
|
||||
zero-length files on certain systems
|
||||
* chown now works even on certain SVR3 systems where it used to fail
|
||||
[3.16r]
|
||||
* include gettext's m4 macros
|
||||
* minor cp bug fixed
|
||||
* non-portable cp tests removed
|
||||
* --without-included-regex now means don't compile regex.c
|
||||
* rx support removed
|
||||
[3.16q]
|
||||
* `df', `du', and `ls' now accept a new option --block-size=SIZE,
|
||||
where SIZE can be a positive integer block size, followed by an
|
||||
optional SI prefix (e.g. `k' for kilo, `M' for Mega), followed by an
|
||||
optional `B' (for ``byte'', indicating powers of 1024, which is the
|
||||
default) or `D' (for ``decimal byte'', indicating powers of 1000).
|
||||
SIZE can also be `human-readable' (for -h or --human-readable
|
||||
behavior) or `si' (for -H or --si behavior).
|
||||
* These suffixes can also be used by `dd'; e.g. `dd bs=1MB' is equivalent
|
||||
to `dd bs=1048576'.
|
||||
* The default block size for the `df' command is now obtained from the
|
||||
DF_BLOCK_SIZE environment variable or, if that is not set, from BLOCK_SIZE.
|
||||
Similarly for `du' and `ls'.
|
||||
* The output columns of `df' have been adjusted slightly to accommodate
|
||||
larger filesystems.
|
||||
* fix gettext-related link failures seen when configuring certain ways
|
||||
[3.16p]
|
||||
* fix install bug introduced in 3.16o
|
||||
* build/test changes only
|
||||
[3.16o]
|
||||
* chown accepts new option, --dereference. --no-dereference is now the default.
|
||||
* install now shares core copying code with mv and cp
|
||||
|
||||
@@ -1,7 +1,71 @@
|
||||
1998-05-16 Jim Meyering <meyering@ascend.com>
|
||||
1998-08-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/su.c (longopts): Use corresponding short-option character
|
||||
in place of `1', and `NULL' in place of pointer in initialization.
|
||||
|
||||
1998-08-11 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/uptime.c (usage): Correct description. Reported by John Murphy.
|
||||
|
||||
1998-07-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
|
||||
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
|
||||
* lib/lchown.c: Include lchown.h.
|
||||
|
||||
1998-07-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/seq.c (check_format): Add `5' to the list of digits.
|
||||
Reported by Donni Erpel.
|
||||
|
||||
1998-07-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.16f.
|
||||
|
||||
* tests/test: New directory and tests.
|
||||
* tests/Makefile.am (SUBDIRS): Add test.
|
||||
* configure.in (AC_OUTPUT): Add tests/test/Makefile.
|
||||
|
||||
1998-07-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libsu_a_SOURCES): Remove regex.c, now that it's
|
||||
automatically discovered by automake.
|
||||
(noinst_HEADERS): Remove unused safe-read.h.
|
||||
|
||||
* src/Makefile.am (CLEANFILES): Put $(SCRIPTS) here rather than in
|
||||
DISTCLEANFILES.
|
||||
(CLEANFILES): Add su, since we build it unconditionally, yet it's
|
||||
never put in @OPTIONAL_BIN_PROGS@.
|
||||
|
||||
1998-06-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/uptime.c: Include system.h only after error.h and readutmp.h
|
||||
so we don't get redefinition warnings about getc, etc.
|
||||
* src/who.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
|
||||
1998-06-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
|
||||
|
||||
1998-06-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/test.c (unary_operator): Fail if the operand to -t is not valid.
|
||||
(posixtest): Treat `test -t' the same as `test -t 1'.
|
||||
|
||||
1998-05-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/test.c (two_arguments): Don't test argv[pos][2] if it's
|
||||
past end of string.
|
||||
|
||||
1998-05-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
|
||||
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
|
||||
[!_GNU_SOURCE]: Add #undef instead.
|
||||
|
||||
1998-05-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/readutmp.c (read_utmp): Add variant for systems that have
|
||||
the utmpname function.
|
||||
Ansideclify.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Changes in release 1.17
|
||||
[1.16f]
|
||||
* new autoconf tests detect bugs in vendor mktime from Irix-6.4 and SunOS4.1.4
|
||||
Your executables will be a little larger on such systems because you'll use
|
||||
GNU's mktime function, but date will work more reliably.
|
||||
[1.16f]
|
||||
* hostid: new program
|
||||
* `yes --help' and `yes --version' print those strings when the POSIXLY_CORRECT
|
||||
environment variable is set
|
||||
|
||||
@@ -1,7 +1,131 @@
|
||||
1998-05-16 Jim Meyering <meyering@ascend.com>
|
||||
1998-08-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/pr.c (usage): Reformat.
|
||||
|
||||
* src/ptx.c: Add braces to suppress warning about ambiguous `else'.
|
||||
* lib/bumpalloc.h: Likewise.
|
||||
|
||||
1998-08-13 François Pinard <pinard@iro.umontreal.ca>
|
||||
|
||||
* src/ptx.c: New file.
|
||||
* src/Makefile.am (bin_PROGRAMS): Add ptx.
|
||||
* lib/bumpalloc.h, lib/diacrit.h, lib/diacrit.c: New files.
|
||||
* lib/Makefile.am (libtu_a_SOURCES): Add diacrit.c.
|
||||
(noinst_HEADERS): Add bumpalloc.h and diacrit.h.
|
||||
|
||||
1998-08-09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/pr.c (long_options): Add long names for all options.
|
||||
(usage): Update help string.
|
||||
(main): Handle the special options --pages and --columns.
|
||||
|
||||
1998-08-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/linebuffer.c (readline): Return zero upon error as well as upon
|
||||
end of file. From James Youngman.
|
||||
Ansideclify.
|
||||
|
||||
1998-08-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sort.c (my_setlocale): Guard definition within #ifdef ENABLE_NLS.
|
||||
From Manfred Hollstein.
|
||||
|
||||
1998-07-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/cut/Test.pm: Avoid broken pipe message for tests that fail
|
||||
with usage errors.
|
||||
|
||||
* src/sort.c (usage): Add angle brackets to make `Report bugs...'
|
||||
message consistent with all the rest.
|
||||
|
||||
1998-07-28 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* tests/cut/Test.pm: Avoid broken pipe for 'y' and 'z' tests.
|
||||
|
||||
* src/sort.c (NEGATION_SIGN): Renamed from NEGATIVE_SIGN to avoid
|
||||
clash with <langinfo.h>. All uses changed.
|
||||
|
||||
1998-07-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* intl/localealias.c (read_alias_file): Avoid mixing `char*' and
|
||||
`unsigned char*' variables. Again for irix4.
|
||||
Mostly from Kaveh Ghazi.
|
||||
|
||||
* src/join.c: Convert some char* dcls to `unsigned char*' and remove
|
||||
a cast -- to placate irix4's cc.
|
||||
* src/fmt.c (check_punctuation): Add cast to placate irix4's cc.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* src/md5sum.c (split_3): Add cast to placate irix4's cc.
|
||||
From Kaveh Ghazi.
|
||||
|
||||
1998-07-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22f.
|
||||
|
||||
* tests/cut/Test.pm: Add tests for new --output-delimiter option,
|
||||
as well as for NUL input delimiter (--delimiter='').
|
||||
* src/cut.c (cut_fields): Honor new --output-delimiter option.
|
||||
(main): Fix handling of --delimiter='' (-d ''). Until now, it has
|
||||
never worked as advertised. I guess no one tried it.
|
||||
|
||||
* tests/sort/Test.pm: Add two tests relating to this.
|
||||
* src/sort.c (main): Stat all non-`-' input file files (and fail if a
|
||||
stat fails) when an output file is specified by `-o' but doesn't exist.
|
||||
Reported by Will Edgington.
|
||||
|
||||
* tests/sort/Test.pm: New tests of -o.
|
||||
|
||||
1998-07-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
|
||||
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
|
||||
* lib/lchown.c: Include lchown.h.
|
||||
|
||||
1998-07-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (AM_WITH_REGEX): Remove. Now the replacement
|
||||
macro, jm_WITH_REGEX, is bundled with the rest in jm_MACROS.
|
||||
* acconfig.h (WITH_REGEX): Remove undef.
|
||||
* src/csplit.c: Remove #ifdef around <regex.h> inclusion.
|
||||
* src/nl.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
* src/csplit.c (extract_regexp): Remove #if !WITH_REGEX...#endif block.
|
||||
* lib/Makefile.am (noinst_HEADERS): Remove rx.h.
|
||||
* lib/rx.c: Remove file.
|
||||
* lib/rx.h: Remove file.
|
||||
|
||||
1998-06-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/wc.c: Update calls to human_readable -- now there's one fewer arg.
|
||||
|
||||
* lib/Makefile.am (libtu_a_SOURCES): Add argmatch.c.
|
||||
(noinst_HEADERS): Add argmatch.h.
|
||||
|
||||
1998-06-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
|
||||
|
||||
1998-06-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/pr/Test.pm: Add two tests for double spacing.
|
||||
* src/pr.c (print_page): If cols_ready_to_print is zero,
|
||||
break out of loop just before the double-space test.
|
||||
Reported by Michael Stutz.
|
||||
|
||||
1998-06-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am.in (check): Depend on $(maint_gen) so
|
||||
`make maintainer-clean; ./configure; make check' works.
|
||||
|
||||
1998-05-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
|
||||
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
|
||||
[!_GNU_SOURCE]: Add #undef instead.
|
||||
|
||||
1998-05-16 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (jm_MACROS): New wrapper macro.
|
||||
Remove uses of most jm_* macros.
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
Changes in release 1.23
|
||||
[1.22g]
|
||||
* pr accepts long option names (see `pr --help')
|
||||
* new program: ptx (moved to this package from being its own distribution)
|
||||
[1.22f]
|
||||
* cut accepts new --output-delimiter=STR option
|
||||
* `sort -o no-such-file no-such-file' now fails, as it should
|
||||
* fix pr bug: pr -td didn't double space
|
||||
* fix tac bug when using -b, -r, and -s SEPARATOR
|
||||
* fix sort bug whereby using key-local `d' option would cause following
|
||||
key specs to be ignored when any two keys (in the `d'-modified test)
|
||||
|
||||
@@ -26,7 +26,7 @@ subdir = po
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
|
||||
CC = @CC@
|
||||
GENCAT = @GENCAT@
|
||||
@@ -46,7 +46,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
|
||||
SOURCES = cat-id-tbl.c
|
||||
POFILES = @POFILES@
|
||||
GMOFILES = @GMOFILES@
|
||||
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
|
||||
DISTFILES = Makefile.in.in POTFILES.in $(PACKAGE).pot \
|
||||
stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
|
||||
|
||||
POTFILES = \
|
||||
@@ -110,17 +110,17 @@ install-exec:
|
||||
install-data: install-data-@USE_NLS@
|
||||
install-data-no: all
|
||||
install-data-yes: all
|
||||
if test -r "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(datadir); \
|
||||
if test -x "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
|
||||
else \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(datadir); \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
|
||||
fi
|
||||
@catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
cat=`basename $$cat`; \
|
||||
case "$$cat" in \
|
||||
*.gmo) destdir=$(gnulocaledir);; \
|
||||
*) destdir=$(localedir);; \
|
||||
*.gmo) destdir=$(DESTDIR)$(gnulocaledir);; \
|
||||
*) destdir=$(DESTDIR)$(localedir);; \
|
||||
esac; \
|
||||
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
|
||||
dir=$$destdir/$$lang/LC_MESSAGES; \
|
||||
@@ -152,13 +152,13 @@ install-data-yes: all
|
||||
fi; \
|
||||
done
|
||||
if test "$(PACKAGE)" = "gettext"; then \
|
||||
if test -r "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(gettextsrcdir); \
|
||||
if test -x "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
|
||||
else \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
|
||||
fi; \
|
||||
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
|
||||
$(gettextsrcdir)/Makefile.in.in; \
|
||||
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
@@ -171,12 +171,12 @@ uninstall:
|
||||
for cat in $$catalogs; do \
|
||||
cat=`basename $$cat`; \
|
||||
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
|
||||
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
done
|
||||
rm -f $(gettextsrcdir)/po-Makefile.in.in
|
||||
rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in.in
|
||||
|
||||
check: all
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ static struct option const long_options[] =
|
||||
{"no-dereference", no_argument, 0, 'h'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, 12},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
@@ -340,7 +340,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 12:
|
||||
case CHAR_MAX + 1:
|
||||
reference_file = optarg;
|
||||
break;
|
||||
case 'R':
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "filemode.h"
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
@@ -47,7 +48,6 @@ enum Verbosity
|
||||
V_off
|
||||
};
|
||||
|
||||
void mode_string ();
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
static int change_dir_mode PARAMS ((const char *dir,
|
||||
@@ -82,7 +82,7 @@ static struct option const long_options[] =
|
||||
{"changes", no_argument, 0, 'c'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, 12},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
@@ -311,7 +311,7 @@ main (int argc, char **argv)
|
||||
error (1, 0, _("invalid mode"));
|
||||
modeind = thisind;
|
||||
break;
|
||||
case 12:
|
||||
case CHAR_MAX + 1:
|
||||
reference_file = optarg;
|
||||
break;
|
||||
case 'R':
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "lchown.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwnam ();
|
||||
@@ -112,11 +113,11 @@ static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
{"changes", no_argument, 0, 'c'},
|
||||
{"dereference", no_argument, 0, 13},
|
||||
{"dereference", no_argument, 0, CHAR_MAX + 2},
|
||||
{"no-dereference", no_argument, 0, 'h'},
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, 12},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
@@ -340,10 +341,10 @@ main (int argc, char **argv)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 12:
|
||||
case CHAR_MAX + 1:
|
||||
reference_file = optarg;
|
||||
break;
|
||||
case 13:
|
||||
case CHAR_MAX + 2:
|
||||
change_symlinks = 0;
|
||||
break;
|
||||
case 'R':
|
||||
|
||||
142
src/copy.c
142
src/copy.c
@@ -34,13 +34,6 @@
|
||||
#include "cp-hash.h"
|
||||
#include "path-concat.h"
|
||||
|
||||
/* On Linux (from slackware-1.2.13 to 2.0.2?) there is no lchown function.
|
||||
To change ownership of symlinks, you must run chown with an effective
|
||||
UID of 0. */
|
||||
#ifdef __linux__
|
||||
# define ROOT_CHOWN_AFFECTS_SYMLINKS
|
||||
#endif
|
||||
|
||||
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
|
||||
(Chown ((File), (x->myeuid == 0 ? (New_uid) : x->myeuid), (New_gid)) \
|
||||
/* If non-root uses -p, it's ok if we can't preserve ownership. \
|
||||
@@ -58,6 +51,7 @@ struct dir_list
|
||||
int full_write ();
|
||||
int euidaccess ();
|
||||
int yesno ();
|
||||
char *dirname ();
|
||||
|
||||
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
|
||||
int new_dst, dev_t device,
|
||||
@@ -185,7 +179,16 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
source_desc = open (src_path, O_RDONLY);
|
||||
if (source_desc < 0)
|
||||
{
|
||||
error (0, errno, "%s", src_path);
|
||||
/* If SRC_PATH doesn't exist, then chances are good that the
|
||||
user did something like this `cp --backup foo foo': and foo
|
||||
existed to start with, but copy_internal renamed DST_PATH
|
||||
with the backup suffix, thus also renaming SRC_PATH. */
|
||||
if (errno == ENOENT)
|
||||
error (0, 0, _("`%s' and `%s' are the same file"),
|
||||
src_path, dst_path);
|
||||
else
|
||||
error (0, errno, "%s", src_path);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -378,10 +381,6 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Are we crossing a file system boundary? */
|
||||
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
|
||||
return 0;
|
||||
|
||||
/* We wouldn't insert a node unless nlink > 1, except that we need to
|
||||
find created files so as to not copy infinitely if a directory is
|
||||
copied into itself. */
|
||||
@@ -415,7 +414,9 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
new_dst = 1;
|
||||
{
|
||||
new_dst = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -423,20 +424,43 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|
||||
/* The destination file exists already. */
|
||||
|
||||
same = (src_sb.st_ino == dst_sb.st_ino
|
||||
&& src_sb.st_dev == dst_sb.st_dev);
|
||||
same = (SAME_INODE (src_sb, dst_sb));
|
||||
|
||||
#ifdef S_ISLNK
|
||||
/* If we're preserving symlinks (--no-dereference) and the
|
||||
destination file is a symlink, use stat (not xstat) to
|
||||
see if it points back to the source. */
|
||||
if (!same && !x->dereference && S_ISLNK (dst_sb.st_mode))
|
||||
/* If we're preserving symlinks (--no-dereference) and either
|
||||
file is a symlink, use stat (not xstat) to see if they refer
|
||||
to the same file. */
|
||||
if (!same
|
||||
|
||||
/* If we'll remove DST_PATH first, then this doesn't matter. */
|
||||
&& ! x->force
|
||||
|
||||
/* Allow them to be the same (and don't set `same') if
|
||||
we're in move mode and they're both symlinks. */
|
||||
&& !(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
|
||||
copy_reg because SRC_PATH will no longer exist. Allowing
|
||||
the test to be deferred lets cp do some useful things.
|
||||
But when creating hardlinks and SRC_PATH is a symlink
|
||||
but DST_PATH is not we must test anyway. */
|
||||
&& (x->backup_type == none
|
||||
|| (x->hard_link
|
||||
&& S_ISLNK (src_sb.st_mode)
|
||||
&& !S_ISLNK (dst_sb.st_mode)))
|
||||
&& !x->dereference
|
||||
&& (S_ISLNK (dst_sb.st_mode) || S_ISLNK (src_sb.st_mode)))
|
||||
{
|
||||
struct stat dst2_sb;
|
||||
struct stat src2_sb;
|
||||
if (stat (dst_path, &dst2_sb) == 0
|
||||
&& (src_sb.st_ino == dst2_sb.st_ino &&
|
||||
src_sb.st_dev == dst2_sb.st_dev))
|
||||
same = 1;
|
||||
&& stat (src_path, &src2_sb) == 0
|
||||
&& SAME_INODE (src2_sb, dst2_sb))
|
||||
{
|
||||
same = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -445,9 +469,12 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
if (x->hard_link)
|
||||
return 0;
|
||||
|
||||
error (0, 0, _("`%s' and `%s' are the same file"),
|
||||
src_path, dst_path);
|
||||
return 1;
|
||||
if (x->backup_type == none && !x->force)
|
||||
{
|
||||
error (0, 0, _("`%s' and `%s' are the same file"),
|
||||
src_path, dst_path);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!S_ISDIR (src_type))
|
||||
@@ -460,7 +487,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (x->update && src_sb.st_mtime <= dst_sb.st_mtime)
|
||||
if (x->update && MTIME_CMP (src_sb, dst_sb) <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -630,6 +657,10 @@ 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;
|
||||
}
|
||||
|
||||
/* Copy the contents of the directory. */
|
||||
@@ -641,25 +672,42 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
#ifdef S_ISLNK
|
||||
else if (x->symbolic_link)
|
||||
{
|
||||
if (*src_path == '/'
|
||||
|| (!strncmp (dst_path, "./", 2) && strchr (dst_path + 2, '/') == 0)
|
||||
|| strchr (dst_path, '/') == 0)
|
||||
if (*src_path != '/')
|
||||
{
|
||||
if (symlink (src_path, dst_path))
|
||||
/* Check that DST_PATH denotes a file in the current directory. */
|
||||
struct stat dot_sb;
|
||||
struct stat dst_parent_sb;
|
||||
char *dst_parent;
|
||||
int in_current_dir;
|
||||
|
||||
dst_parent = dirname (dst_path);
|
||||
if (dst_parent == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
in_current_dir = (STREQ (".", dst_parent)
|
||||
/* If either stat call fails, it's ok not to report
|
||||
the failure and say dst_path is in the current
|
||||
directory. Other things will fail later. */
|
||||
|| stat (".", &dot_sb)
|
||||
|| stat (dst_parent, &dst_parent_sb)
|
||||
|| SAME_INODE (dot_sb, dst_parent_sb));
|
||||
free (dst_parent);
|
||||
|
||||
if (! in_current_dir)
|
||||
{
|
||||
error (0, errno, "%s", dst_path);
|
||||
error (0, 0,
|
||||
_("%s: can make relative symbolic links only in current directory"),
|
||||
dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (symlink (src_path, dst_path))
|
||||
{
|
||||
error (0, 0,
|
||||
_("%s: can make relative symbolic links only in current directory"),
|
||||
dst_path);
|
||||
error (0, errno, "%s", dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
else if (x->hard_link)
|
||||
@@ -738,26 +786,10 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
goto un_backup;
|
||||
}
|
||||
# else
|
||||
# ifdef ROOT_CHOWN_AFFECTS_SYMLINKS
|
||||
if (x->myeuid == 0)
|
||||
{
|
||||
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
|
||||
{
|
||||
error (0, errno, _("preserving ownership for %s"), dst_path);
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: maybe give a diagnostic: you must be root
|
||||
to preserve ownership and group of symlinks. */
|
||||
}
|
||||
# else
|
||||
/* Can't preserve ownership of symlinks.
|
||||
FIXME: maybe give a warning or even error for symlinks
|
||||
in directories with the sticky bit set -- there, not
|
||||
preserving owner/group is a potential security problem. */
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -786,6 +818,10 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
{
|
||||
struct utimbuf utb;
|
||||
|
||||
/* There's currently no interface to set file timestamps with
|
||||
better than 1-second resolution, so discard any fractional
|
||||
part of the source timestamp. */
|
||||
|
||||
utb.actime = src_sb.st_atime;
|
||||
utb.modtime = src_sb.st_mtime;
|
||||
|
||||
|
||||
12
src/cp.c
12
src/cp.c
@@ -96,13 +96,13 @@ static struct option const long_opts[] =
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"sparse", required_argument, NULL, 2},
|
||||
{"sparse", required_argument, NULL, CHAR_MAX + 1},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"link", no_argument, NULL, 'l'},
|
||||
{"no-dereference", no_argument, NULL, 'd'},
|
||||
{"one-file-system", no_argument, NULL, 'x'},
|
||||
{"parents", no_argument, &flag_path, 1},
|
||||
{"path", no_argument, &flag_path, 1},
|
||||
{"parents", no_argument, NULL, 'P'},
|
||||
{"path", no_argument, NULL, 'P'},
|
||||
{"preserve", no_argument, NULL, 'p'},
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
@@ -233,6 +233,10 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
{
|
||||
struct utimbuf utb;
|
||||
|
||||
/* There's currently no interface to set file timestamps with
|
||||
better than 1-second resolution, so discard any fractional
|
||||
part of the source timestamp. */
|
||||
|
||||
utb.actime = src_sb.st_atime;
|
||||
utb.modtime = src_sb.st_mtime;
|
||||
|
||||
@@ -650,7 +654,7 @@ main (int argc, char **argv)
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case CHAR_MAX + 1:
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -28,11 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
@@ -1150,9 +1146,6 @@ extract_regexp (int argnum, boolean ignore, char *str)
|
||||
p->re_compiled.buffer = (unsigned char *) xmalloc (p->re_compiled.allocated);
|
||||
p->re_compiled.fastmap = xmalloc (256);
|
||||
p->re_compiled.translate = 0;
|
||||
#if !WITH_REGEX
|
||||
p->re_compiled.syntax_parens = 0;
|
||||
#endif
|
||||
err = re_compile_pattern (p->regexpr, len, &p->re_compiled);
|
||||
if (err)
|
||||
{
|
||||
|
||||
38
src/cut.c
38
src/cut.c
@@ -68,6 +68,8 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
char *xstrdup ();
|
||||
|
||||
#define FATAL_ERROR(s) \
|
||||
do \
|
||||
{ \
|
||||
@@ -156,6 +158,13 @@ static int suppress_non_delimited;
|
||||
/* The delimeter character for field mode. */
|
||||
static int delim;
|
||||
|
||||
/* The length of output_delimiter_string. */
|
||||
static size_t output_delimiter_length;
|
||||
|
||||
/* The output field separator string. Defaults to the 1-character
|
||||
string consisting of the input delimiter. */
|
||||
static char *output_delimiter_string;
|
||||
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
@@ -172,6 +181,7 @@ static struct option const longopts[] =
|
||||
{"fields", required_argument, 0, 'f'},
|
||||
{"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},
|
||||
{0, 0, 0, 0}
|
||||
@@ -198,6 +208,8 @@ Print selected parts of lines from each FILE to standard output.\n\
|
||||
-f, --fields=LIST output only these fields\n\
|
||||
-n (ignored)\n\
|
||||
-s, --only-delimited do not print lines not containing delimiters\n\
|
||||
--output-delimiter=STRING use STRING as the output delimiter\n\
|
||||
the default is to use the input delimiter\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
@@ -579,7 +591,10 @@ cut_fields (FILE *stream)
|
||||
if (print_kth (field_idx))
|
||||
{
|
||||
if (found_any_selected_field)
|
||||
putchar (delim);
|
||||
{
|
||||
fwrite (output_delimiter_string, sizeof (char),
|
||||
output_delimiter_length, stdout);
|
||||
}
|
||||
found_any_selected_field = 1;
|
||||
|
||||
while ((c = getc (stream)) != delim && c != '\n' && c != EOF)
|
||||
@@ -674,6 +689,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc, exit_status = 0;
|
||||
int delim_specified = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -720,6 +736,15 @@ main (int argc, char **argv)
|
||||
if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
delim = optarg[0];
|
||||
delim_specified = 1;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
/* Interpret --output-delimiter='' to mean
|
||||
`use the NUL byte as the delimiter.' */
|
||||
output_delimiter_length = (optarg[0] == '\0'
|
||||
? 1 : strlen (optarg));
|
||||
output_delimiter_string = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
@@ -753,9 +778,18 @@ main (int argc, char **argv)
|
||||
FATAL_ERROR (_("suppressing non-delimited lines makes sense\n\
|
||||
\tonly when operating on fields"));
|
||||
|
||||
if (delim == '\0')
|
||||
if (!delim_specified)
|
||||
delim = '\t';
|
||||
|
||||
if (output_delimiter_string == NULL)
|
||||
{
|
||||
static char dummy[2];
|
||||
dummy[0] = delim;
|
||||
dummy[1] = '\0';
|
||||
output_delimiter_string = dummy;
|
||||
output_delimiter_length = 1;
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
exit_status |= cut_file ("-");
|
||||
else
|
||||
|
||||
65
src/dd.c
65
src/dd.c
@@ -304,8 +304,10 @@ Copy a file, converting and formatting according to the options.\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
BYTES may be suffixed: by xM for multiplication by M, by c for x1,\n\
|
||||
by w for x2, by b for x512, by k for x1024. Each KEYWORD may be:\n\
|
||||
BYTES may be followed by the following multiplicative suffixes:\n\
|
||||
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,\n\
|
||||
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.\n\
|
||||
Each KEYWORD may be:\n\
|
||||
\n\
|
||||
ascii from EBCDIC to ASCII\n\
|
||||
ebcdic from ASCII to EBCDIC\n\
|
||||
@@ -352,15 +354,15 @@ print_stats (void)
|
||||
{
|
||||
char buf[2][LONGEST_HUMAN_READABLE + 1];
|
||||
fprintf (stderr, _("%s+%s records in\n"),
|
||||
human_readable (r_full, buf[0], 1, 1, 0),
|
||||
human_readable (r_partial, buf[1], 1, 1, 0));
|
||||
human_readable (r_full, buf[0], 1, 1),
|
||||
human_readable (r_partial, buf[1], 1, 1));
|
||||
fprintf (stderr, _("%s+%s records out\n"),
|
||||
human_readable (w_full, buf[0], 1, 1, 0),
|
||||
human_readable (w_partial, buf[1], 1, 1, 0));
|
||||
human_readable (w_full, buf[0], 1, 1),
|
||||
human_readable (w_partial, buf[1], 1, 1));
|
||||
if (r_truncate > 0)
|
||||
{
|
||||
fprintf (stderr, "%s %s\n",
|
||||
human_readable (r_truncate, buf[0], 1, 1, 0),
|
||||
human_readable (r_truncate, buf[0], 1, 1),
|
||||
(r_truncate == 1
|
||||
? _("truncated record")
|
||||
: _("truncated records")));
|
||||
@@ -503,6 +505,12 @@ parse_integer (char *str, int *invalid)
|
||||
for (;;)
|
||||
{
|
||||
uintmax_t multiplier;
|
||||
int power = 0;
|
||||
|
||||
#ifdef lint
|
||||
/* Suppress `used before initialized' warning. */
|
||||
multiplier = 0;
|
||||
#endif
|
||||
|
||||
switch (*p++)
|
||||
{
|
||||
@@ -513,8 +521,23 @@ parse_integer (char *str, int *invalid)
|
||||
break;
|
||||
case 'c':
|
||||
continue;
|
||||
case 'k':
|
||||
multiplier = 1024;
|
||||
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;
|
||||
@@ -523,6 +546,12 @@ parse_integer (char *str, int *invalid)
|
||||
multiplier = parse_integer (p, invalid);
|
||||
p = "";
|
||||
break;
|
||||
case 'Y': /* Yotta */
|
||||
power = 8;
|
||||
break;
|
||||
case 'Z': /* Zetta */
|
||||
power = 7;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
*invalid = 1;
|
||||
@@ -530,6 +559,24 @@ parse_integer (char *str, int *invalid)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (multiplier != 0 && n * multiplier / multiplier != n)
|
||||
{
|
||||
*invalid = 1;
|
||||
|
||||
229
src/df.c
229
src/df.c
@@ -51,15 +51,16 @@ static int inode_format;
|
||||
uninteresting types. */
|
||||
static int show_all_fs;
|
||||
|
||||
/* If nonzero, show only local filesystems. */
|
||||
static int show_local_fs;
|
||||
|
||||
/* If nonzero, output data for each filesystem corresponding to a
|
||||
command line argument -- even if it's a dummy (automounter) entry. */
|
||||
static int show_listed_fs;
|
||||
|
||||
/* base used for human style output */
|
||||
static int human_readable_base;
|
||||
|
||||
/* The units to count in. */
|
||||
static int output_units;
|
||||
/* If positive, the units to use when printing sizes;
|
||||
if negative, the human-readable base. */
|
||||
static int output_block_size;
|
||||
|
||||
/* If nonzero, use the POSIX output format. */
|
||||
static int posix_format;
|
||||
@@ -113,18 +114,20 @@ static int print_type;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, &show_all_fs, 1},
|
||||
{"inodes", no_argument, &inode_format, 1},
|
||||
{"human-readable", no_argument, 0, 'h'},
|
||||
{"si", no_argument, 0, 'H'},
|
||||
{"kilobytes", no_argument, 0, 'k'},
|
||||
{"megabytes", no_argument, 0, 'm'},
|
||||
{"portability", no_argument, &posix_format, 1},
|
||||
{"print-type", no_argument, &print_type, 1},
|
||||
{"sync", no_argument, 0, 129},
|
||||
{"no-sync", no_argument, 0, 130},
|
||||
{"type", required_argument, 0, 't'},
|
||||
{"exclude-type", required_argument, 0, 'x'},
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"block-size", required_argument, NULL, CHAR_MAX + 3},
|
||||
{"inodes", no_argument, NULL, 'i'},
|
||||
{"human-readable", no_argument, NULL, 'h'},
|
||||
{"si", no_argument, NULL, 'H'},
|
||||
{"kilobytes", no_argument, NULL, 'k'},
|
||||
{"local", no_argument, NULL, 'l'},
|
||||
{"megabytes", no_argument, NULL, 'm'},
|
||||
{"portability", no_argument, NULL, 'P'},
|
||||
{"print-type", no_argument, NULL, 'T'},
|
||||
{"sync", no_argument, NULL, CHAR_MAX + 1},
|
||||
{"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},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -141,15 +144,22 @@ print_header (void)
|
||||
printf (" ");
|
||||
|
||||
if (inode_format)
|
||||
printf (" Inodes IUsed IFree %%IUsed ");
|
||||
printf (" Inodes IUsed IFree IUse%%");
|
||||
else if (output_block_size < 0)
|
||||
printf (" Size Used Avail Use%%");
|
||||
else
|
||||
if (output_units == 1024 * 1024)
|
||||
printf (" MB-blocks Used Available Capacity");
|
||||
else if (human_readable_base)
|
||||
printf (" Size Used Avail Capacity");
|
||||
else
|
||||
printf (" %s Used Available Capacity",
|
||||
output_units == 1024 ? "1024-blocks" : " 512-blocks");
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
char *p = human_readable (output_block_size, buf, 1, -1024);
|
||||
|
||||
/* Replace e.g. "1.0k" by "1k". */
|
||||
size_t plen = strlen (p);
|
||||
if (3 <= plen && strncmp (p + plen - 3, ".0", 2) == 0)
|
||||
strcpy (p + plen - 3, p + plen - 1);
|
||||
|
||||
printf (" %4s-blocks Used Available Use%%", p);
|
||||
}
|
||||
|
||||
printf (" Mounted on\n");
|
||||
}
|
||||
|
||||
@@ -187,9 +197,11 @@ excluded_fstype (const char *fstype)
|
||||
|
||||
/* Like human_readable, except return "-" if the argument is -1. */
|
||||
static char *
|
||||
df_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
df_readable (uintmax_t n, char *buf,
|
||||
int from_block_size, int t_output_block_size)
|
||||
{
|
||||
return n == -1 ? "-" : human_readable (n, buf, from_units, to_units, base);
|
||||
return (n == -1 ? "-"
|
||||
: human_readable (n, buf, from_block_size, t_output_block_size));
|
||||
}
|
||||
|
||||
/* Display a space listing for the disk device with absolute path DISK.
|
||||
@@ -197,14 +209,22 @@ df_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
|
||||
filesystem on DISK.
|
||||
If FSTYPE is non-NULL, it is the type of the filesystem on DISK.
|
||||
If MOUNT_POINT is non-NULL, then DISK may be NULL -- certain systems may
|
||||
not be able to produce statistics in this case. */
|
||||
not be able to produce statistics in this case.
|
||||
ME_DUMMY and ME_REMOTE are the mount entry flags. */
|
||||
|
||||
static void
|
||||
show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
show_dev (const char *disk, const char *mount_point, const char *fstype,
|
||||
int me_dummy, int me_remote)
|
||||
{
|
||||
struct fs_usage fsu;
|
||||
const char *stat_file;
|
||||
|
||||
if (me_remote && show_local_fs)
|
||||
return;
|
||||
|
||||
if (me_dummy && show_all_fs == 0 && !show_listed_fs)
|
||||
return;
|
||||
|
||||
if (!selected_fstype (fstype) || excluded_fstype (fstype))
|
||||
return;
|
||||
|
||||
@@ -226,21 +246,36 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
|
||||
if (! disk)
|
||||
disk = "-"; /* unknown */
|
||||
|
||||
printf ((print_type ? "%-13s" : "%-20s"), disk);
|
||||
if ((int) strlen (disk) > (print_type ? 13 : 20) && !posix_format)
|
||||
printf ((print_type ? "\n%13s" : "\n%20s"), "");
|
||||
|
||||
if (! fstype)
|
||||
fstype = "-"; /* unknown */
|
||||
|
||||
/* df.c reserved 5 positions for fstype,
|
||||
but that does not suffice for type iso9660 */
|
||||
if (print_type)
|
||||
printf (" %-5s ", fstype);
|
||||
{
|
||||
int disk_name_len = (int) strlen (disk);
|
||||
int fstype_len = (int) strlen (fstype);
|
||||
if (disk_name_len + fstype_len + 2 < 20)
|
||||
printf ("%s%*s ", disk, 18 - disk_name_len, fstype);
|
||||
else if (!posix_format)
|
||||
printf ("%s\n%18s ", disk, fstype);
|
||||
else
|
||||
printf ("%s %s", disk, fstype);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int) strlen (disk) > 20 && !posix_format)
|
||||
printf ("%s\n%20s", disk, "");
|
||||
else
|
||||
printf ("%-20s", disk);
|
||||
}
|
||||
|
||||
if (inode_format)
|
||||
{
|
||||
char buf[3][LONGEST_HUMAN_READABLE + 1];
|
||||
double inodes_percent_used;
|
||||
uintmax_t inodes_used;
|
||||
int inode_units = output_block_size < 0 ? output_block_size : 1;
|
||||
|
||||
if (fsu.fsu_files == -1 || fsu.fsu_files < fsu.fsu_ffree)
|
||||
{
|
||||
@@ -256,18 +291,18 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
}
|
||||
|
||||
printf (" %7s %7s %7s ",
|
||||
df_readable (fsu.fsu_files, buf[0], 1, 1, human_readable_base),
|
||||
df_readable (inodes_used, buf[1], 1, 1, human_readable_base),
|
||||
df_readable (fsu.fsu_ffree, buf[2], 1, 1, human_readable_base));
|
||||
df_readable (fsu.fsu_files, buf[0], 1, inode_units),
|
||||
df_readable (inodes_used, buf[1], 1, inode_units),
|
||||
df_readable (fsu.fsu_ffree, buf[2], 1, inode_units));
|
||||
|
||||
if (inodes_percent_used < 0)
|
||||
printf (" - ");
|
||||
printf (" - ");
|
||||
else
|
||||
printf (" %5.0f%%", inodes_percent_used);
|
||||
printf ("%4.0f%%", inodes_percent_used);
|
||||
}
|
||||
else
|
||||
{
|
||||
int w = human_readable_base ? 5 : 7;
|
||||
int w = output_block_size < 0 ? 5 : 9;
|
||||
char buf[2][LONGEST_HUMAN_READABLE + 1];
|
||||
char availbuf[LONGEST_HUMAN_READABLE + 2];
|
||||
char *avail;
|
||||
@@ -296,22 +331,22 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
? - fsu.fsu_bavail
|
||||
: fsu.fsu_bavail),
|
||||
availbuf + 1, fsu.fsu_blocksize,
|
||||
output_units, human_readable_base);
|
||||
output_block_size);
|
||||
|
||||
if (fsu.fsu_bavail_top_bit_set)
|
||||
*--avail = '-';
|
||||
|
||||
printf (" %*s %*s %*s ",
|
||||
printf (" %*s %*s %*s ",
|
||||
w, df_readable (fsu.fsu_blocks, buf[0], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
output_block_size),
|
||||
w, df_readable (blocks_used, buf[1], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
output_block_size),
|
||||
w, avail);
|
||||
|
||||
if (blocks_percent_used < 0)
|
||||
printf (" - ");
|
||||
printf (" - ");
|
||||
else
|
||||
printf (" %5.0f%% ", blocks_percent_used);
|
||||
printf ("%3.0f%%", blocks_percent_used);
|
||||
}
|
||||
|
||||
if (mount_point)
|
||||
@@ -325,7 +360,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0)
|
||||
mount_point += 8;
|
||||
#endif
|
||||
printf (" %s", mount_point);
|
||||
printf (" %s", mount_point);
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
@@ -341,11 +376,12 @@ show_disk (const char *disk)
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
if (STREQ (disk, me->me_devname))
|
||||
{
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type,
|
||||
me->me_dummy, me->me_remote);
|
||||
return;
|
||||
}
|
||||
/* No filesystem is mounted on DISK. */
|
||||
show_dev (disk, (char *) NULL, (char *) NULL);
|
||||
show_dev (disk, (char *) NULL, (char *) NULL, 0, 0);
|
||||
}
|
||||
|
||||
/* Return the root mountpoint of the filesystem on which FILE exists, in
|
||||
@@ -427,6 +463,7 @@ show_point (const char *point, const struct stat *statp)
|
||||
{
|
||||
struct stat disk_stats;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry *matching_dummy = NULL;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
{
|
||||
@@ -449,11 +486,27 @@ show_point (const char *point, const struct stat *statp)
|
||||
if (stat (me->me_mountdir, &disk_stats) != 0 ||
|
||||
disk_stats.st_dev != me->me_dev)
|
||||
continue;
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
|
||||
/* Prefer non-dummy entries. */
|
||||
if (me->me_dummy)
|
||||
{
|
||||
matching_dummy = me;
|
||||
continue;
|
||||
}
|
||||
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type,
|
||||
me->me_dummy, me->me_remote);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (matching_dummy)
|
||||
{
|
||||
show_dev (matching_dummy->me_devname, matching_dummy->me_mountdir,
|
||||
matching_dummy->me_type, 1, matching_dummy->me_remote);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
|
||||
print as much info as we can; methods that require the device to be
|
||||
present will fail at a later point. */
|
||||
@@ -462,7 +515,7 @@ show_point (const char *point, const struct stat *statp)
|
||||
char *mp = find_mount_point (point, statp);
|
||||
if (mp)
|
||||
{
|
||||
show_dev (0, mp, 0);
|
||||
show_dev (0, mp, 0, 0, 0);
|
||||
free (mp);
|
||||
}
|
||||
else
|
||||
@@ -491,7 +544,8 @@ show_all_entries (void)
|
||||
struct mount_entry *me;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type);
|
||||
show_dev (me->me_devname, me->me_mountdir, me->me_type,
|
||||
me->me_dummy, me->me_remote);
|
||||
}
|
||||
|
||||
/* Add FSTYPE to the list of filesystem types to display. */
|
||||
@@ -534,11 +588,13 @@ Show information about the filesystem on which each FILE resides,\n\
|
||||
or all filesystems by default.\n\
|
||||
\n\
|
||||
-a, --all include filesystems having 0 blocks\n\
|
||||
--block-size=SIZE use SIZE-byte blocks\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
|
||||
-H, --si likewise, but use powers of 1000 not 1024\n\
|
||||
-i, --inodes list inode information instead of block usage\n\
|
||||
-k, --kilobytes use 1024-byte blocks\n\
|
||||
-m, --megabytes use 1048576-byte blocks\n\
|
||||
-k, --kilobytes like --block-size=1024\n\
|
||||
-l, --local limit listing to local filesystems\n\
|
||||
-m, --megabytes like --block-size=1048576\n\
|
||||
--no-sync do not invoke sync before getting usage info (default)\n\
|
||||
-P, --portability use the POSIX output format\n\
|
||||
--sync invoke sync before getting usage info\n\
|
||||
@@ -572,31 +628,13 @@ main (int argc, char **argv)
|
||||
show_all_fs = 0;
|
||||
show_listed_fs = 0;
|
||||
|
||||
if (getenv ("POSIXLY_CORRECT"))
|
||||
output_units = 512;
|
||||
else
|
||||
{
|
||||
char *bs;
|
||||
if ((bs = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
{
|
||||
human_readable_base = 1024;
|
||||
output_units = 1;
|
||||
}
|
||||
else if (bs && STREQ (bs, "SI"))
|
||||
{
|
||||
human_readable_base = 1000;
|
||||
output_units = 1;
|
||||
}
|
||||
else
|
||||
output_units = 1024;
|
||||
}
|
||||
human_block_size (getenv ("DF_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
print_type = 0;
|
||||
posix_format = 0;
|
||||
exit_status = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "aiF:hHkmPTt:vx:", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "aiF:hHklmPTt:vx:", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -610,20 +648,19 @@ main (int argc, char **argv)
|
||||
inode_format = 1;
|
||||
break;
|
||||
case 'h':
|
||||
human_readable_base = 1024;
|
||||
output_units = 1;
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
case 'H':
|
||||
human_readable_base = 1000;
|
||||
output_units = 1;
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
case 'k':
|
||||
human_readable_base = 0;
|
||||
output_units = 1024;
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
case 'l':
|
||||
show_local_fs = 1;
|
||||
break;
|
||||
case 'm':
|
||||
human_readable_base = 0;
|
||||
output_units = 1024 * 1024;
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
case 'T':
|
||||
print_type = 1;
|
||||
@@ -631,13 +668,17 @@ main (int argc, char **argv)
|
||||
case 'P':
|
||||
posix_format = 1;
|
||||
break;
|
||||
case 129:
|
||||
case CHAR_MAX + 1:
|
||||
require_sync = 1;
|
||||
break;
|
||||
case 130:
|
||||
case CHAR_MAX + 2:
|
||||
require_sync = 0;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
/* Accept -F as a synonym for -t for compatibility with Solaris. */
|
||||
case 't':
|
||||
@@ -665,15 +706,6 @@ main (int argc, char **argv)
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (posix_format && output_units == 1024 * 1024)
|
||||
error (1, 0, _("the option for counting 1MB blocks may not be used\n\
|
||||
with the portable output format"));
|
||||
|
||||
if (posix_format && human_readable_base)
|
||||
error (1, 0,
|
||||
_("the option for printing with adaptive units may not be used\n\
|
||||
with the portable output format"));
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
int match = 0;
|
||||
@@ -724,16 +756,17 @@ with the portable output format"));
|
||||
mount_list =
|
||||
read_filesystem_list ((fs_select_list != NULL
|
||||
|| fs_exclude_list != NULL
|
||||
|| print_type),
|
||||
show_all_fs);
|
||||
|| print_type
|
||||
|| show_local_fs));
|
||||
|
||||
if (mount_list == NULL)
|
||||
error (1, errno, _("cannot read table of mounted filesystems"));
|
||||
|
||||
if (require_sync)
|
||||
sync ();
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
if (mount_list == NULL)
|
||||
error (1, errno, _("cannot read table of mounted filesystems"));
|
||||
print_header ();
|
||||
show_all_entries ();
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ parse_line (unsigned char const *line, char **keyword, char **arg)
|
||||
++p;
|
||||
}
|
||||
|
||||
*keyword = xstrndup (keyword_start, p - keyword_start);
|
||||
*keyword = xstrndup ((const char *) keyword_start, p - keyword_start);
|
||||
if (*p == '\0')
|
||||
return;
|
||||
|
||||
@@ -198,7 +198,7 @@ parse_line (unsigned char const *line, char **keyword, char **arg)
|
||||
}
|
||||
++p;
|
||||
|
||||
*arg = xstrndup (arg_start, p - arg_start);
|
||||
*arg = xstrndup ((const char *) arg_start, p - arg_start);
|
||||
}
|
||||
|
||||
/* FIXME: Write a string to standard out, while watching for "dangerous"
|
||||
@@ -287,11 +287,20 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
break;
|
||||
}
|
||||
|
||||
parse_line (line, &keywd, &arg);
|
||||
parse_line ((unsigned char *) line, &keywd, &arg);
|
||||
|
||||
if (keywd == NULL)
|
||||
continue;
|
||||
|
||||
if (arg == NULL)
|
||||
{
|
||||
error (0, 0, _("%s:%lu: invalid line; missing second token"),
|
||||
filename, (long unsigned) line_number);
|
||||
err = 1;
|
||||
free (keywd);
|
||||
continue;
|
||||
}
|
||||
|
||||
unrecognized = 0;
|
||||
if (strcasecmp (keywd, "TERM") == 0)
|
||||
{
|
||||
|
||||
85
src/du.c
85
src/du.c
@@ -26,9 +26,9 @@
|
||||
arguments have been processed. This can be used to find
|
||||
out the disk usage of a directory, with some files excluded.
|
||||
-h Print sizes in human readable format (1k 234M 2G, etc).
|
||||
-k Print sizes in kilobytes instead of 512 byte blocks
|
||||
(the default required by POSIX).
|
||||
-m Print sizes in megabytes instead of 512 byte blocks
|
||||
-H Similar, but use powers of 1000 not 1024.
|
||||
-k Print sizes in kilobytes.
|
||||
-m Print sizes in megabytes.
|
||||
-b Print sizes in bytes.
|
||||
-S Count the size of each directory separately, not including
|
||||
the sizes of subdirectories.
|
||||
@@ -143,11 +143,9 @@ static int opt_dereference_arguments = 0;
|
||||
is at level 0, so `du --max-depth=0' is equivalent to `du -s'. */
|
||||
static int max_depth = INT_MAX;
|
||||
|
||||
/* base used for human style output */
|
||||
static int human_readable_base;
|
||||
|
||||
/* The units to count in. */
|
||||
static int output_units;
|
||||
/* If positive, the units to use when printing sizes;
|
||||
if negative, the human-readable base. */
|
||||
static int output_block_size;
|
||||
|
||||
/* Accumulated path for file or directory being processed. */
|
||||
static String *path;
|
||||
@@ -179,22 +177,23 @@ static uintmax_t tot_size = 0;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, &opt_all, 1},
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"block-size", required_argument, 0, CHAR_MAX + 2},
|
||||
{"bytes", no_argument, NULL, 'b'},
|
||||
{"count-links", no_argument, &opt_count_all, 1},
|
||||
{"count-links", no_argument, NULL, 'l'},
|
||||
{"dereference", no_argument, NULL, 'L'},
|
||||
{"dereference-args", no_argument, &opt_dereference_arguments, 1},
|
||||
{"exclude", required_argument, 0, 128},
|
||||
{"dereference-args", no_argument, NULL, 'D'},
|
||||
{"exclude", required_argument, 0, CHAR_MAX + 1},
|
||||
{"exclude-from", required_argument, 0, 'X'},
|
||||
{"human-readable", no_argument, NULL, 'h'},
|
||||
{"si", no_argument, 0, 'H'},
|
||||
{"kilobytes", no_argument, NULL, 'k'},
|
||||
{"max-depth", required_argument, NULL, 13},
|
||||
{"max-depth", required_argument, NULL, CHAR_MAX + 3},
|
||||
{"megabytes", no_argument, NULL, 'm'},
|
||||
{"one-file-system", no_argument, &opt_one_file_system, 1},
|
||||
{"separate-dirs", no_argument, &opt_separate_dirs, 1},
|
||||
{"one-file-system", no_argument, NULL, 'x'},
|
||||
{"separate-dirs", no_argument, NULL, 'S'},
|
||||
{"summarize", no_argument, NULL, 's'},
|
||||
{"total", no_argument, &opt_combined_arguments, 1},
|
||||
{"total", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -217,15 +216,16 @@ usage (int status, char *reason)
|
||||
Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
\n\
|
||||
-a, --all write counts for all files, not just directories\n\
|
||||
--block-size=SIZE use SIZE-byte blocks\n\
|
||||
-b, --bytes print size in bytes\n\
|
||||
-c, --total produce a grand total\n\
|
||||
-D, --dereference-args dereference PATHs when symbolic link\n\
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
|
||||
-H, --si likewise, but use powers of 1000 not 1024\n\
|
||||
-k, --kilobytes use 1024-byte blocks\n\
|
||||
-k, --kilobytes like --block-size=1024\n\
|
||||
-l, --count-links count sizes many times if hard linked\n\
|
||||
-L, --dereference dereference all symbolic links\n\
|
||||
-m, --megabytes use 1048576-byte blocks\n\
|
||||
-m, --megabytes like --block-size=1048576\n\
|
||||
-S, --separate-dirs do not include size of subdirectories\n\
|
||||
-s, --summarize display only a total for each argument\n\
|
||||
-x, --one-file-system skip directories on different filesystems\n\
|
||||
@@ -249,7 +249,6 @@ main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
char *bs;
|
||||
int max_depth_specified = 0;
|
||||
|
||||
/* If nonzero, display only a total for each argument. */
|
||||
@@ -266,21 +265,7 @@ main (int argc, char **argv)
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
if (getenv ("POSIXLY_CORRECT"))
|
||||
output_units = 512;
|
||||
else if ((bs = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
{
|
||||
human_readable_base = 1024;
|
||||
output_units = 1;
|
||||
}
|
||||
else if (bs && STREQ (bs, "SI"))
|
||||
{
|
||||
human_readable_base = 1000;
|
||||
output_units = 1;
|
||||
}
|
||||
else
|
||||
output_units = 1024;
|
||||
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
|
||||
!= -1)
|
||||
@@ -296,8 +281,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
human_readable_base = 0;
|
||||
output_units = 1;
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
@@ -305,21 +289,18 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
human_readable_base = 1024;
|
||||
output_units = 1;
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
human_readable_base = 1000;
|
||||
output_units = 1;
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
human_readable_base = 0;
|
||||
output_units = 1024;
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case 13: /* --max-depth=N */
|
||||
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);
|
||||
@@ -329,8 +310,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
human_readable_base = 0;
|
||||
output_units = 1024 * 1024;
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
@@ -362,10 +342,14 @@ main (int argc, char **argv)
|
||||
error (1, errno, "%s", optarg);
|
||||
break;
|
||||
|
||||
case 128:
|
||||
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);
|
||||
}
|
||||
@@ -413,8 +397,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Print N_BLOCKS followed by STRING on a line. NBLOCKS is the number of
|
||||
ST_NBLOCKSIZE-byte blocks; convert it to OUTPUT_UNITS units before
|
||||
printing. If HUMAN_READABLE_BASE is nonzero, use a human readable
|
||||
ST_NBLOCKSIZE-byte blocks; convert it to OUTPUT_BLOCK_SIZE units before
|
||||
printing. If OUTPUT_BLOCK_SIZE is negative, use a human readable
|
||||
notation instead. */
|
||||
|
||||
static void
|
||||
@@ -422,8 +406,7 @@ print_size (uintmax_t n_blocks, const char *string)
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
printf ("%s\t%s\n",
|
||||
human_readable (n_blocks, buf, ST_NBLOCKSIZE, output_units,
|
||||
human_readable_base),
|
||||
human_readable (n_blocks, buf, ST_NBLOCKSIZE, output_block_size),
|
||||
string);
|
||||
fflush (stdout);
|
||||
}
|
||||
@@ -490,7 +473,7 @@ du_files (char **files)
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
|
||||
/* Print (if appropriate) the size (in units determined by `output_units')
|
||||
/* Print (if appropriate) the size (in units determined by `output_block_size')
|
||||
of file or directory ENT. Return the size of ENT in units of 512-byte
|
||||
blocks. TOP is one for external calls, zero for recursive calls.
|
||||
LAST_DEV is the device that the parent directory of ENT is on.
|
||||
|
||||
@@ -708,7 +708,7 @@ check_punctuation (register WORD *w)
|
||||
{
|
||||
const unsigned char *start, *finish;
|
||||
|
||||
start = w->text;
|
||||
start = (unsigned char *) w->text;
|
||||
finish = start + (w->length - 1);
|
||||
w->paren = isopen (*start);
|
||||
w->punct = ISPUNCT (*finish);
|
||||
|
||||
@@ -135,7 +135,7 @@ enum backup_type get_version ();
|
||||
int stat ();
|
||||
|
||||
static int change_timestamps PARAMS ((const char *from, const char *to));
|
||||
static int change_attributes PARAMS ((const char *path, mode_t mode));
|
||||
static int change_attributes PARAMS ((const char *path));
|
||||
static int copy_file PARAMS ((const char *from, const char *to,
|
||||
const struct cp_options *x));
|
||||
static int install_file_to_path PARAMS ((const char *from, const char *to,
|
||||
@@ -168,6 +168,10 @@ static char *group_name;
|
||||
/* The group ID corresponding to `group_name'. */
|
||||
static gid_t group_id;
|
||||
|
||||
/* The permissions to which the files will be set. The umask has
|
||||
no effect. */
|
||||
static mode_t mode = 0755;
|
||||
|
||||
/* If nonzero, strip executable files after copying them. */
|
||||
static int strip_files;
|
||||
|
||||
@@ -218,8 +222,13 @@ cp_option_init (struct cp_options *x)
|
||||
x->recursive = 0;
|
||||
x->sparse_mode = SPARSE_AUTO;
|
||||
x->symbolic_link = 0;
|
||||
|
||||
/* Create destination files initially writable so we can run strip on them.
|
||||
Although GNU strip works fine on read-only files, some others
|
||||
would fail. */
|
||||
x->set_mode = 1;
|
||||
x->mode = 0755;
|
||||
x->mode = 0600;
|
||||
|
||||
x->umask_kill = 0;
|
||||
x->update = 0;
|
||||
x->verbose = 0;
|
||||
@@ -337,7 +346,7 @@ main (int argc, char **argv)
|
||||
error (1, 0, _("invalid mode `%s'"), symbolic_mode);
|
||||
else if (change == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
x.mode = mode_adjust (0, change);
|
||||
mode = mode_adjust (0, change);
|
||||
}
|
||||
|
||||
get_ids ();
|
||||
@@ -348,7 +357,7 @@ main (int argc, char **argv)
|
||||
for (i = 0; i < n_files; i++)
|
||||
{
|
||||
errors |=
|
||||
make_path (file[i], x.mode, x.mode, owner_id, group_id, 0,
|
||||
make_path (file[i], mode, mode, owner_id, group_id, 0,
|
||||
(x.verbose ? "creating directory `%s'" : NULL));
|
||||
}
|
||||
}
|
||||
@@ -370,11 +379,18 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
int i;
|
||||
if (!isdir (file[1]))
|
||||
usage (1);
|
||||
const char *dest = file[n_files - 1];
|
||||
if (!isdir (dest))
|
||||
{
|
||||
error (0, 0,
|
||||
_("installing multiple files, but last argument (%s) \
|
||||
is not a directory"),
|
||||
dest);
|
||||
usage (1);
|
||||
}
|
||||
for (i = 0; i < n_files - 1; i++)
|
||||
{
|
||||
errors |= install_file_in_dir (file[i], file[n_files - 1], &x);
|
||||
errors |= install_file_in_dir (file[i], dest, &x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,7 +423,7 @@ install_file_to_path (const char *from, const char *to,
|
||||
rules, it's not so bad. Maybe use something like this instead:
|
||||
int parent_dir_mode = (mode | (S_IRUGO | S_IXUGO)) & (~SPECIAL_BITS);
|
||||
*/
|
||||
fail = make_path (dest_dir, x->mode, x->mode, owner_id, group_id, 0,
|
||||
fail = make_path (dest_dir, mode, mode, owner_id, group_id, 0,
|
||||
(x->verbose ? _("creating directory `%s'") : NULL));
|
||||
}
|
||||
else
|
||||
@@ -432,7 +448,7 @@ install_file_in_file (const char *from, const char *to,
|
||||
return 1;
|
||||
if (strip_files)
|
||||
strip (to);
|
||||
if (change_attributes (to, x->mode))
|
||||
if (change_attributes (to))
|
||||
return 1;
|
||||
if (x->preserve_timestamps)
|
||||
return change_timestamps (from, to);
|
||||
@@ -486,7 +502,7 @@ copy_file (const char *from, const char *to, const struct cp_options *x)
|
||||
Return 0 if successful, 1 if not. */
|
||||
|
||||
static int
|
||||
change_attributes (const char *path, mode_t mode)
|
||||
change_attributes (const char *path)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -533,6 +549,11 @@ change_timestamps (const char *from, const char *to)
|
||||
error (0, errno, "%s", from);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* There's currently no interface to set file timestamps with
|
||||
better than 1-second resolution, so discard any fractional
|
||||
part of the source timestamp. */
|
||||
|
||||
utb.actime = stb.st_atime;
|
||||
utb.modtime = stb.st_mtime;
|
||||
if (utime (to, &utb))
|
||||
|
||||
20
src/join.c
20
src/join.c
@@ -61,15 +61,15 @@ struct outlist
|
||||
/* A field of a line. */
|
||||
struct field
|
||||
{
|
||||
const char *beg; /* First character in field. */
|
||||
const unsigned char *beg; /* First character in field. */
|
||||
size_t len; /* The length of the field. */
|
||||
};
|
||||
|
||||
/* A line read from an input file. Newlines are not stored. */
|
||||
struct line
|
||||
{
|
||||
char *beg; /* First character in line. */
|
||||
char *lim; /* Character after last character in line. */
|
||||
unsigned char *beg; /* First character in line. */
|
||||
unsigned char *lim; /* Character after last character in line. */
|
||||
int nfields; /* Number of elements in `fields'. */
|
||||
int nfields_allocated; /* Number of elements in `fields'. */
|
||||
struct field *fields;
|
||||
@@ -171,7 +171,7 @@ separated by CHAR.\n\
|
||||
}
|
||||
|
||||
static void
|
||||
ADD_FIELD (struct line *line, const char *field, size_t len)
|
||||
ADD_FIELD (struct line *line, const unsigned char *field, size_t len)
|
||||
{
|
||||
if (line->nfields >= line->nfields_allocated)
|
||||
{
|
||||
@@ -191,7 +191,8 @@ static void
|
||||
xfields (struct line *line)
|
||||
{
|
||||
int i;
|
||||
unsigned char *ptr, *lim;
|
||||
unsigned char *ptr;
|
||||
unsigned char *lim;
|
||||
|
||||
ptr = line->beg;
|
||||
lim = line->lim;
|
||||
@@ -229,8 +230,7 @@ xfields (struct line *line)
|
||||
}
|
||||
}
|
||||
|
||||
if ((char *) ptr > line->beg
|
||||
&& ((tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
|
||||
if (ptr > line->beg && ((tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
|
||||
{
|
||||
/* Add one more (empty) field because the last character of the
|
||||
line was a delimiter. */
|
||||
@@ -246,7 +246,7 @@ get_line (FILE *fp, struct line *line)
|
||||
{
|
||||
static int linesize = 80;
|
||||
int c, i;
|
||||
char *ptr;
|
||||
unsigned char *ptr;
|
||||
|
||||
if (feof (fp))
|
||||
return 0;
|
||||
@@ -330,7 +330,9 @@ delseq (struct seq *seq)
|
||||
static int
|
||||
keycmp (struct line *line1, struct line *line2)
|
||||
{
|
||||
const char *beg1, *beg2; /* Start of field to compare in each file. */
|
||||
/* Start of field to compare in each file. */
|
||||
const unsigned char *beg1, *beg2;
|
||||
|
||||
int len1, len2; /* Length of fields to compare. */
|
||||
int diff;
|
||||
|
||||
|
||||
6
src/ln.c
6
src/ln.c
@@ -108,13 +108,13 @@ static int show_version;
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
{"directory", no_argument, &hard_dir_link, 1},
|
||||
{"directory", no_argument, NULL, 'F'},
|
||||
{"no-dereference", no_argument, NULL, 'n'},
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
{"symbolic", no_argument, &symbolic_link, 1},
|
||||
{"verbose", no_argument, &verbose, 1},
|
||||
{"symbolic", no_argument, NULL, 's'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
|
||||
130
src/ls.c
130
src/ls.c
@@ -72,6 +72,7 @@
|
||||
#include "xstrtol.h"
|
||||
#include "strverscmp.h"
|
||||
#include "quotearg.h"
|
||||
#include "filemode.h"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -132,8 +133,6 @@ struct bin_str
|
||||
time_t time ();
|
||||
#endif
|
||||
|
||||
void mode_string ();
|
||||
|
||||
char *getgroup ();
|
||||
char *getuser ();
|
||||
void strip_trailing_slashes ();
|
||||
@@ -317,13 +316,13 @@ int inhibit_group;
|
||||
|
||||
static int numeric_ids;
|
||||
|
||||
/* Nonzero means mention the size in 512 byte blocks of each file. -s */
|
||||
/* Nonzero means mention the size in blocks of each file. -s */
|
||||
|
||||
static int print_block_size;
|
||||
|
||||
/* The units to count blocks in. */
|
||||
|
||||
static int output_units;
|
||||
/* If positive, the units to use when printing sizes;
|
||||
if negative, the human-readable base. */
|
||||
static int output_block_size;
|
||||
|
||||
/* Precede each line of long output (per file) with a string like `m,n:'
|
||||
where M is the number of characters after the `:' and before the
|
||||
@@ -409,10 +408,6 @@ struct col_ext_type *col_ext_list = NULL;
|
||||
/* Buffer for color sequences */
|
||||
static char *color_buf;
|
||||
|
||||
/* base used for human style output */
|
||||
|
||||
static int human_readable_base;
|
||||
|
||||
/* Nonzero means mention the inode number of each file. -i */
|
||||
|
||||
static int print_inode;
|
||||
@@ -454,8 +449,15 @@ struct ignore_pattern
|
||||
|
||||
static struct ignore_pattern *ignore_patterns;
|
||||
|
||||
/* Nonzero means output nongraphic chars in file names as `?'. -q */
|
||||
|
||||
/* Nonzero means output nongraphic chars in file names as `?'.
|
||||
(-q, --hide-control-chars)
|
||||
qmark_funny_chars and the quoting style (-Q, --quoting-style=WORD) are
|
||||
independent. The algorithm is: first, obey the quoting style to get a
|
||||
string representing the file name; then, if qmark_funny_chars is set,
|
||||
replace all nonprintable chars in that string with `?'. It's necessary
|
||||
to replace nonprintable chars even in quoted strings, because we don't
|
||||
want to mess up the terminal if control chars get sent to it, and some
|
||||
quoting methods pass through control chars as-is. */
|
||||
static int qmark_funny_chars;
|
||||
|
||||
/* Quoting options for file and dir name output. */
|
||||
@@ -532,6 +534,7 @@ static struct option const long_options[] =
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"color", optional_argument, 0, 13},
|
||||
{"block-size", required_argument, 0, 17},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -569,14 +572,14 @@ static char const *const time_args[] =
|
||||
and later output themselves. */
|
||||
static size_t dired_pos;
|
||||
|
||||
#define PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0)
|
||||
#define DIRED_PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0)
|
||||
|
||||
/* Write S to STREAM and increment DIRED_POS by S_LEN. */
|
||||
#define FPUTS(s, stream, s_len) \
|
||||
#define DIRED_FPUTS(s, stream, s_len) \
|
||||
do {fputs ((s), (stream)); dired_pos += s_len;} while (0)
|
||||
|
||||
/* Like FPUTS, but for use when S is a literal string. */
|
||||
#define FPUTS_LITERAL(s, stream) \
|
||||
/* Like DIRED_FPUTS, but for use when S is a literal string. */
|
||||
#define DIRED_FPUTS_LITERAL(s, stream) \
|
||||
do {fputs ((s), (stream)); dired_pos += sizeof((s)) - 1;} while (0)
|
||||
|
||||
#define DIRED_INDENT() \
|
||||
@@ -584,7 +587,7 @@ static size_t dired_pos;
|
||||
{ \
|
||||
/* FIXME: remove the `&& format == long_format' clause. */ \
|
||||
if (dired && format == long_format) \
|
||||
FPUTS_LITERAL (" ", stdout); \
|
||||
DIRED_FPUTS_LITERAL (" ", stdout); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
@@ -753,7 +756,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
print_current_files ();
|
||||
if (pending_dirs)
|
||||
PUTCHAR ('\n');
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
else if (pending_dirs && pending_dirs->next == 0)
|
||||
print_dir_name = 0;
|
||||
@@ -824,6 +827,7 @@ decode_switches (int argc, char **argv)
|
||||
if (isatty (1))
|
||||
{
|
||||
format = many_per_line;
|
||||
/* See description of qmark_funny_chars, above. */
|
||||
qmark_funny_chars = 1;
|
||||
}
|
||||
else
|
||||
@@ -843,7 +847,6 @@ decode_switches (int argc, char **argv)
|
||||
sort_reverse = 0;
|
||||
numeric_ids = 0;
|
||||
print_block_size = 0;
|
||||
output_units = getenv ("POSIXLY_CORRECT") ? 512 : 1024;
|
||||
indicator_style = none;
|
||||
print_inode = 0;
|
||||
trace_links = 0;
|
||||
@@ -857,11 +860,7 @@ decode_switches (int argc, char **argv)
|
||||
&& 0 <= (i = argmatch (p, quoting_style_args)))
|
||||
set_quoting_style (NULL, (enum quoting_style) i);
|
||||
|
||||
if ((p = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (p, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
human_readable_base = 1024;
|
||||
else if (p && STREQ (p, "SI"))
|
||||
human_readable_base = 1000;
|
||||
human_block_size (getenv ("LS_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
line_length = 80;
|
||||
if ((p = getenv ("COLUMNS")) && *p)
|
||||
@@ -950,11 +949,11 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
human_readable_base = 1024;
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
human_readable_base = 1000;
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
@@ -962,7 +961,7 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_units = 1024;
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
@@ -1178,14 +1177,15 @@ decode_switches (int argc, char **argv)
|
||||
qmark_funny_chars = 0;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (human_readable_base)
|
||||
output_units = 1;
|
||||
|
||||
filename_quoting_options = clone_quoting_options (NULL);
|
||||
if (indicator_style != none)
|
||||
for (p = "*=@|" + (int) indicator_style - 1; *p; p++)
|
||||
@@ -1591,14 +1591,14 @@ print_dir (const char *name, const char *realname)
|
||||
if (trace_dirs)
|
||||
extract_dirs_from_files (name, 1);
|
||||
|
||||
if (print_dir_name)
|
||||
if (trace_dirs || print_dir_name)
|
||||
{
|
||||
DIRED_INDENT ();
|
||||
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
|
||||
dired_pos += quote_name (stdout, realname ? realname : name,
|
||||
dirname_quoting_options);
|
||||
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
|
||||
FPUTS_LITERAL (":\n", stdout);
|
||||
DIRED_FPUTS_LITERAL (":\n", stdout);
|
||||
}
|
||||
|
||||
if (format == long_format || print_block_size)
|
||||
@@ -1608,19 +1608,18 @@ print_dir (const char *name, const char *realname)
|
||||
|
||||
DIRED_INDENT ();
|
||||
p = _("total");
|
||||
FPUTS (p, stdout, strlen (p));
|
||||
PUTCHAR (' ');
|
||||
p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_units,
|
||||
human_readable_base);
|
||||
FPUTS (p, stdout, strlen (p));
|
||||
PUTCHAR ('\n');
|
||||
DIRED_FPUTS (p, stdout, strlen (p));
|
||||
DIRED_PUTCHAR (' ');
|
||||
p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_block_size);
|
||||
DIRED_FPUTS (p, stdout, strlen (p));
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
|
||||
if (files_index)
|
||||
print_current_files ();
|
||||
|
||||
if (pending_dirs)
|
||||
PUTCHAR ('\n');
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
|
||||
/* Add `pattern' to the list of patterns for which files that match are
|
||||
@@ -1802,7 +1801,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
int len = strlen (human_readable (blocks, buf, ST_NBLOCKSIZE,
|
||||
output_units, human_readable_base));
|
||||
output_block_size));
|
||||
if (block_size_size < len)
|
||||
block_size_size = len < 7 ? len : 7;
|
||||
}
|
||||
@@ -1990,7 +1989,7 @@ sort_files (void)
|
||||
static int
|
||||
compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
|
||||
int diff = CTIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -1999,7 +1998,7 @@ compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
static int
|
||||
rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
|
||||
int diff = CTIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -2008,7 +2007,7 @@ rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1)
|
||||
static int
|
||||
compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
|
||||
int diff = MTIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -2017,7 +2016,7 @@ compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
static int
|
||||
rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
|
||||
int diff = MTIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -2026,7 +2025,7 @@ rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1)
|
||||
static int
|
||||
compare_atime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime);
|
||||
int diff = ATIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -2035,7 +2034,7 @@ compare_atime (const struct fileinfo *file1, const struct fileinfo *file2)
|
||||
static int
|
||||
rev_cmp_atime (const struct fileinfo *file2, const struct fileinfo *file1)
|
||||
{
|
||||
int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime);
|
||||
int diff = ATIME_CMP (file2->stat, file1->stat);
|
||||
if (diff == 0)
|
||||
diff = strcmp (file1->name, file2->name);
|
||||
return diff;
|
||||
@@ -2161,7 +2160,7 @@ print_current_files (void)
|
||||
for (i = 0; i < files_index; i++)
|
||||
{
|
||||
print_long_format (files + i);
|
||||
PUTCHAR ('\n');
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2191,6 +2190,7 @@ print_long_format (const struct fileinfo *f)
|
||||
char *user_name;
|
||||
|
||||
#if HAVE_ST_DM_MODE
|
||||
/* Cray DMF: look at the file's migrated, not real, status */
|
||||
mode_string (f->stat.st_dm_mode, modebuf);
|
||||
#else
|
||||
mode_string (f->stat.st_mode, modebuf);
|
||||
@@ -2240,7 +2240,7 @@ print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
char hbuf[LONGEST_HUMAN_READABLE + 1];
|
||||
sprintf (p, "%*s ", INODE_DIGITS,
|
||||
human_readable ((uintmax_t) f->stat.st_ino, hbuf, 1, 1, 0));
|
||||
human_readable ((uintmax_t) f->stat.st_ino, hbuf, 1, 1));
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
@@ -2249,8 +2249,7 @@ print_long_format (const struct fileinfo *f)
|
||||
char hbuf[LONGEST_HUMAN_READABLE + 1];
|
||||
sprintf (p, "%*s ", block_size_size,
|
||||
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), hbuf,
|
||||
ST_NBLOCKSIZE, output_units,
|
||||
human_readable_base));
|
||||
ST_NBLOCKSIZE, output_block_size));
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
@@ -2283,8 +2282,8 @@ print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
char hbuf[LONGEST_HUMAN_READABLE + 1];
|
||||
sprintf (p, "%8s ",
|
||||
human_readable ((uintmax_t) f->stat.st_size,
|
||||
hbuf, 1, 1, human_readable_base));
|
||||
human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
|
||||
output_block_size < 0 ? output_block_size : 1));
|
||||
}
|
||||
|
||||
p += strlen (p);
|
||||
@@ -2305,7 +2304,7 @@ print_long_format (const struct fileinfo *f)
|
||||
p += s;
|
||||
*p++ = ' ';
|
||||
|
||||
/* NUL-terminate the string -- fputs (via FPUTS) requires it. */
|
||||
/* NUL-terminate the string -- fputs (via DIRED_FPUTS) requires it. */
|
||||
*p = '\0';
|
||||
}
|
||||
else
|
||||
@@ -2317,19 +2316,19 @@ print_long_format (const struct fileinfo *f)
|
||||
|
||||
if (when < 0)
|
||||
{
|
||||
const char *num = human_readable (- (uintmax_t) when, hbuf, 1, 1, 0);
|
||||
const char *num = human_readable (- (uintmax_t) when, hbuf, 1, 1);
|
||||
int sign_width = width - strlen (num);
|
||||
sprintf (p, "%*s%s ", sign_width < 0 ? 0 : sign_width, "-", num);
|
||||
}
|
||||
else
|
||||
sprintf (p, "%*s ", width,
|
||||
human_readable ((uintmax_t) when, hbuf, 1, 1, 0));
|
||||
human_readable ((uintmax_t) when, hbuf, 1, 1));
|
||||
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
DIRED_INDENT ();
|
||||
FPUTS (buf, stdout, p - buf);
|
||||
DIRED_FPUTS (buf, stdout, p - buf);
|
||||
print_name_with_quoting (f->name, f->stat.st_mode, f->linkok,
|
||||
&dired_obstack);
|
||||
|
||||
@@ -2337,7 +2336,7 @@ print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
if (f->linkname)
|
||||
{
|
||||
FPUTS_LITERAL (" -> ", stdout);
|
||||
DIRED_FPUTS_LITERAL (" -> ", stdout);
|
||||
print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
|
||||
NULL);
|
||||
if (indicator_style != none)
|
||||
@@ -2422,12 +2421,12 @@ print_file_name_and_frills (const struct fileinfo *f)
|
||||
|
||||
if (print_inode)
|
||||
printf ("%*s ", INODE_DIGITS,
|
||||
human_readable ((uintmax_t) f->stat.st_ino, buf, 1, 1, 0));
|
||||
human_readable ((uintmax_t) f->stat.st_ino, buf, 1, 1));
|
||||
|
||||
if (print_block_size)
|
||||
printf ("%*s ", block_size_size,
|
||||
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), buf,
|
||||
ST_NBLOCKSIZE, output_units, human_readable_base));
|
||||
ST_NBLOCKSIZE, output_block_size));
|
||||
|
||||
print_name_with_quoting (f->name, f->stat.st_mode, f->linkok, NULL);
|
||||
|
||||
@@ -2439,26 +2438,26 @@ static void
|
||||
print_type_indicator (unsigned int mode)
|
||||
{
|
||||
if (S_ISDIR (mode))
|
||||
PUTCHAR ('/');
|
||||
DIRED_PUTCHAR ('/');
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (S_ISLNK (mode))
|
||||
PUTCHAR ('@');
|
||||
DIRED_PUTCHAR ('@');
|
||||
#endif
|
||||
|
||||
#ifdef S_ISFIFO
|
||||
if (S_ISFIFO (mode))
|
||||
PUTCHAR ('|');
|
||||
DIRED_PUTCHAR ('|');
|
||||
#endif
|
||||
|
||||
#ifdef S_ISSOCK
|
||||
if (S_ISSOCK (mode))
|
||||
PUTCHAR ('=');
|
||||
DIRED_PUTCHAR ('=');
|
||||
#endif
|
||||
|
||||
if (S_ISREG (mode) && indicator_style == classify
|
||||
&& (mode & S_IXUGO))
|
||||
PUTCHAR ('*');
|
||||
DIRED_PUTCHAR ('*');
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2868,6 +2867,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
|
||||
-a, --all do not hide entries starting with .\n\
|
||||
-A, --almost-all do not list implied . and ..\n\
|
||||
-b, --escape print octal escapes for nongraphic characters\n\
|
||||
--block-size=SIZE use SIZE-byte blocks\n\
|
||||
-B, --ignore-backups do not list implied entries ending with ~\n\
|
||||
-c sort by change time; with -l: show ctime\n\
|
||||
-C list entries by columns\n\
|
||||
@@ -2890,7 +2890,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
|
||||
none (default), classify (-F), file-type (-p)\n\
|
||||
-i, --inode print index number of each file\n\
|
||||
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN\n\
|
||||
-k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
|
||||
-k, --kilobytes like --block-size=1024\n\
|
||||
-l use a long listing format\n\
|
||||
-L, --dereference list entries pointed to by symbolic links\n\
|
||||
-m fill width with a comma separated list of entries\n\
|
||||
|
||||
@@ -152,7 +152,7 @@ split_3 (char *s, size_t s_len, unsigned char **u, int *binary, char **w)
|
||||
++i;
|
||||
filename_has_newline = 1;
|
||||
}
|
||||
*u = &s[i];
|
||||
*u = (unsigned char *) &s[i];
|
||||
|
||||
/* The first field has to be the 32-character hexadecimal
|
||||
representation of the message digest. If it is not followed
|
||||
|
||||
@@ -43,7 +43,7 @@ static int show_version;
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"parents", no_argument, &path_mode, 1},
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"verbose", no_argument, NULL, 2},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
|
||||
39
src/mv.c
39
src/mv.c
@@ -56,10 +56,6 @@
|
||||
#include "remove.h"
|
||||
#include "error.h"
|
||||
|
||||
#if HAVE_LCHOWN
|
||||
# define chown(PATH, OWNER, GROUP) lchown(PATH, OWNER, GROUP)
|
||||
#endif
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
|
||||
@@ -181,21 +177,34 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
}
|
||||
|
||||
fail = copy (source, dest, 0, x,
|
||||
©_into_self, &rename_succeeded);
|
||||
fail = copy (source, dest, 0, x, ©_into_self, &rename_succeeded);
|
||||
|
||||
if (!fail)
|
||||
{
|
||||
const char *dir_to_remove;
|
||||
if (copy_into_self)
|
||||
{
|
||||
/* Do *not* remove SOURCE if it is the same as or a parent
|
||||
of DEST. Otherwise, mv would be removing the original
|
||||
*and* the copy. */
|
||||
/* In general, when copy returns with copy_into_self set, SOURCE is
|
||||
the same as, or a parent of DEST. In this case we know it's a
|
||||
parent. It doesn't make sense to move a directory into itself, and
|
||||
besides in some situations doing so would give highly nonintuitive
|
||||
results. Run this `mkdir b; touch a c; mv * b' in an empty
|
||||
directory. Here's the result of running echo `find b -print`:
|
||||
b b/a b/b b/b/a b/c. Notice that only file `a' was copied
|
||||
into b/b. Handle this by giving a diagnostic, removing the
|
||||
copied-into-self directory, DEST (`b/b' in the example),
|
||||
and failing. */
|
||||
|
||||
dir_to_remove = dest;
|
||||
error (0, 0,
|
||||
_("cannot move `%s' to a subdirectory of itself, `%s'"),
|
||||
source, dest);
|
||||
}
|
||||
else if (rename_succeeded)
|
||||
{
|
||||
/* No need to remove anything. SOURCE was successfully
|
||||
renamed to DEST. */
|
||||
dir_to_remove = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -221,6 +230,11 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
|
||||
This function used to resort to copying only when rename
|
||||
failed and set errno to EXDEV. */
|
||||
|
||||
dir_to_remove = source;
|
||||
}
|
||||
|
||||
if (dir_to_remove != NULL)
|
||||
{
|
||||
struct rm_options rm_options;
|
||||
struct File_spec fs;
|
||||
enum RM_status status;
|
||||
@@ -230,7 +244,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
|
||||
|
||||
remove_init ();
|
||||
|
||||
fspec_init_file (&fs, source);
|
||||
fspec_init_file (&fs, dir_to_remove);
|
||||
status = rm (&fs, 1, &rm_options);
|
||||
assert (VALID_STATUS (status));
|
||||
if (status == RM_ERROR)
|
||||
@@ -239,8 +253,11 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
|
||||
remove_fini ();
|
||||
|
||||
if (fail)
|
||||
error (0, errno, _("cannot remove `%s'"), source);
|
||||
error (0, errno, _("cannot remove `%s'"), dir_to_remove);
|
||||
}
|
||||
|
||||
if (copy_into_self)
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
return fail;
|
||||
|
||||
6
src/nl.c
6
src/nl.c
@@ -27,11 +27,7 @@
|
||||
#include "linebuffer.h"
|
||||
#include "system.h"
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
101
src/pr.c
101
src/pr.c
@@ -580,6 +580,27 @@ static struct option const long_options[] =
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"test", no_argument, &test_suite, 1},
|
||||
{"pages", required_argument, NULL, CHAR_MAX + 1},
|
||||
{"columns", required_argument, NULL, CHAR_MAX + 2},
|
||||
{"across", no_argument, NULL, 'a'},
|
||||
{"show-control-chars", no_argument, NULL, 'c'},
|
||||
{"double-space", no_argument, NULL, 'd'},
|
||||
{"expand-tabs", optional_argument, NULL, 'e'},
|
||||
{"form-feed", no_argument, NULL, 'f'},
|
||||
{"header", required_argument, NULL, 'h'},
|
||||
{"output-tabs", optional_argument, NULL, 'i'},
|
||||
{"join-lines", no_argument, NULL, 'j'},
|
||||
{"length", required_argument, NULL, 'l'},
|
||||
{"merge", no_argument, NULL, 'm'},
|
||||
{"number-lines", optional_argument, NULL, 'n'},
|
||||
{"first-line-number", required_argument, NULL, 'N'},
|
||||
{"indent", required_argument, NULL, 'o'},
|
||||
{"no-file-warnings", no_argument, NULL, 'r'},
|
||||
{"separator", optional_argument, NULL, 's'},
|
||||
{"omit-header", no_argument, NULL, 't'},
|
||||
{"omit-pagination", no_argument, NULL, 'T'},
|
||||
{"show-nonprinting", no_argument, NULL, 'v'},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -722,6 +743,24 @@ main (int argc, char **argv)
|
||||
case 0: /* getopt long option */
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1: /* --pages=FIRST_PAGE[:LAST_PAGE] */
|
||||
first_last_page (optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2: /* --columns=COLUMN */
|
||||
{
|
||||
long int tmp_long;
|
||||
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|
||||
|| tmp_long <= 0 || tmp_long > INT_MAX)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("`--columns=COLUMN' invalid number of columns: `%s'"),
|
||||
optarg);
|
||||
}
|
||||
columns = (int) tmp_long;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'a':
|
||||
print_across_flag = TRUE;
|
||||
storing_columns = FALSE;
|
||||
@@ -1584,7 +1623,10 @@ print_page (void)
|
||||
--lines_left_on_page;
|
||||
}
|
||||
|
||||
if (double_space && pv && extremities)
|
||||
if (cols_ready_to_print () <= 0 && !extremities)
|
||||
break;
|
||||
|
||||
if (double_space && pv)
|
||||
{
|
||||
putchar ('\n');
|
||||
--lines_left_on_page;
|
||||
@@ -2413,44 +2455,61 @@ Usage: %s [OPTION]... [FILE]...\n\
|
||||
Paginate or columnate FILE(s) for printing.\n\
|
||||
\n\
|
||||
+FIRST_PAGE[:LAST_PAGE]\n\
|
||||
--pages=FIRST_PAGE[:LAST_PAGE]\n\
|
||||
begin [stop] printing with page FIRST_[LAST_]PAGE\n\
|
||||
-COLUMN produce COLUMN-column output and print columns down,\n\
|
||||
-COLUMN\n\
|
||||
--columns=COLUMN produce COLUMN-column output and print columns down,\n\
|
||||
unless -a is used. Balance number of lines in the\n\
|
||||
columns on each page.\n\
|
||||
-a print columns across rather than down, used together\n\
|
||||
-a, --across print columns across rather than down, used together\n\
|
||||
with -COLUMN\n\
|
||||
-c use hat notation (^G) and octal backslash notation\n\
|
||||
-d double space the output\n\
|
||||
-e[CHAR[WIDTH]] expand input CHARs (TABs) to tab WIDTH (8)\n\
|
||||
-F, -f use form feeds instead of newlines to separate pages\n\
|
||||
-c, --show-control-chars\n\
|
||||
use hat notation (^G) and octal backslash notation\n\
|
||||
-d, --double-space\n\
|
||||
double space the output\n\
|
||||
-e, --expand-tabs[=CHAR[WIDTH]]\n\
|
||||
expand input CHARs (TABs) to tab WIDTH (8)\n\
|
||||
-F, -f, --form-feed\n\
|
||||
use form feeds instead of newlines to separate pages\n\
|
||||
(by a 3-line page header with -f or a 5-line header\n\
|
||||
and trailer without -f)\n\
|
||||
-h HEADER use a centered HEADER instead of filename in page headers\n\
|
||||
-h, --header=HEADER\n\
|
||||
use a centered HEADER instead of filename in page headers\n\
|
||||
with long headers left-hand-side truncation may occur\n\
|
||||
-h \"\" prints a blank line. Don't use -h\"\"\n\
|
||||
-i[CHAR[WIDTH]] replace spaces with CHARs (TABs) to tab WIDTH (8)\n\
|
||||
-j merge full lines, turns off -w line truncation, no column\n\
|
||||
-i, --output-tabs[=CHAR[WIDTH]]\n\
|
||||
replace spaces with CHARs (TABs) to tab WIDTH (8)\n\
|
||||
-j, --join-lines merge full lines, turns off -w line truncation, no column\n\
|
||||
alignment, -s[STRING] sets separators\n\
|
||||
-l PAGE_LENGTH set the page length to PAGE_LENGTH (66) lines\n\
|
||||
-l, --length PAGE_LENGTH\n\
|
||||
set the page length to PAGE_LENGTH (66) lines\n\
|
||||
(default number of lines of text 56, with -f 63)\n"));
|
||||
printf (_("\
|
||||
-m print all files in parallel, one in each column,\n\
|
||||
-m, --merge print all files in parallel, one in each column,\n\
|
||||
truncate lines, but join lines of full length with -j\n\
|
||||
-n[SEP[DIGITS]] number lines, use DIGITS (5) digits, then SEP (TAB)\n\
|
||||
-n, --number-lines[=SEP[DIGITS]]\n\
|
||||
number lines, use DIGITS (5) digits, then SEP (TAB)\n\
|
||||
default counting starts with 1st line of input file\n\
|
||||
-N NUMBER start counting with NUMBER at 1st line of first\n\
|
||||
-N, --first-line-number=NUMBER\n\
|
||||
start counting with NUMBER at 1st line of first\n\
|
||||
page printed (see +FIRST_PAGE)\n\
|
||||
-o MARGIN offset each line with MARGIN spaces (do not affect -w)\n\
|
||||
-r inhibit warning when a file cannot be opened\n\
|
||||
-s[STRING] separate columns by an optional STRING, don't use\n\
|
||||
-o, --indent=MARGIN\n\
|
||||
offset each line with MARGIN spaces (do not affect -w)\n\
|
||||
-r, --no-file-warnings\n\
|
||||
inhibit warning when a file cannot be opened\n\
|
||||
-s, --separator[=STRING]\n\
|
||||
separate columns by an optional STRING, don't use\n\
|
||||
-s \"STRING\", -s only: No separator used (same as -s\"\"),\n\
|
||||
without -s: Default separator \'TAB\' with -j and \'space\'\n\
|
||||
otherwise (same as -s\" \")\n\
|
||||
-t inhibit page headers and trailers\n\
|
||||
-T inhibit page headers and trailers, eliminate any page\n\
|
||||
-t, --omit-header inhibit page headers and trailers\n\
|
||||
-T, --omit-pagination\n\
|
||||
inhibit page headers and trailers, eliminate any page\n\
|
||||
layout by form feeds set in input files\n\
|
||||
-v use octal backslash notation\n\
|
||||
-w PAGE_WIDTH set page width to PAGE_WIDTH (72) columns, truncate\n\
|
||||
-v, --show-nonprinting\n\
|
||||
use octal backslash notation\n\
|
||||
-w, --width=PAGE_WIDTH\n\
|
||||
set page width to PAGE_WIDTH (72) columns, truncate\n\
|
||||
lines (see also -j option)\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
|
||||
38
src/remove.c
38
src/remove.c
@@ -412,6 +412,16 @@ fspec_filetype_mode (const struct File_spec *fs)
|
||||
return fs->mode;
|
||||
}
|
||||
|
||||
static int
|
||||
same_file (const char *file_1, const char *file_2)
|
||||
{
|
||||
struct stat sb1, sb2;
|
||||
return (lstat (file_1, &sb1) == 0
|
||||
&& lstat (file_2, &sb2) == 0
|
||||
&& SAME_INODE (sb1, sb2));
|
||||
}
|
||||
|
||||
|
||||
/* Recursively remove all of the entries in the current directory.
|
||||
Return an indication of the success of the operation. */
|
||||
|
||||
@@ -625,7 +635,7 @@ remove_file (struct File_spec *fs, const struct rm_options *x)
|
||||
}
|
||||
|
||||
if (x->verbose)
|
||||
printf (_("removing non-directory %s\n"), full_filename (pathname));
|
||||
printf (_("removing %s\n"), full_filename (pathname));
|
||||
|
||||
if (unlink (pathname) && (errno != ENOENT || !x->ignore_missing_files))
|
||||
{
|
||||
@@ -720,8 +730,10 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
|
||||
|
||||
if (x->interactive)
|
||||
{
|
||||
error (0, 0, _("remove directory `%s'%s? "), full_filename (dir_name),
|
||||
(status != RM_OK ? _(" (might be nonempty)") : ""));
|
||||
fprintf (stderr, _("%s: remove directory `%s'%s? "),
|
||||
program_name,
|
||||
full_filename (dir_name),
|
||||
(status != RM_OK ? _(" (might be nonempty)") : ""));
|
||||
if (!yesno ())
|
||||
{
|
||||
return RM_USER_DECLINED;
|
||||
@@ -733,8 +745,24 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
|
||||
|
||||
if (rmdir (dir_name) && (errno != ENOENT || !x->ignore_missing_files))
|
||||
{
|
||||
error (0, errno, _("cannot remove directory `%s'"),
|
||||
full_filename (dir_name));
|
||||
int saved_errno = errno;
|
||||
|
||||
#ifndef EINVAL
|
||||
# define EINVAL 0
|
||||
#endif
|
||||
/* See if rmdir just failed because DIR_NAME is the current directory.
|
||||
If so, give a better diagnostic than `rm: cannot remove directory
|
||||
`...': Invalid argument' */
|
||||
if (errno == EINVAL && same_file (".", dir_name))
|
||||
{
|
||||
error (0, 0, _("cannot remove current directory `%s'"),
|
||||
full_filename (dir_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, saved_errno, _("cannot remove directory `%s'"),
|
||||
full_filename (dir_name));
|
||||
}
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
|
||||
27
src/rmdir.c
27
src/rmdir.c
@@ -31,6 +31,14 @@
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef EEXIST
|
||||
# define EEXIST 0
|
||||
#endif
|
||||
|
||||
#ifndef ENOTEMPTY
|
||||
# define ENOTEMPTY 0
|
||||
#endif
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -56,7 +64,7 @@ static struct option const longopts[] =
|
||||
{
|
||||
/* Don't name this `--force' because it's not close enough in meaning
|
||||
to e.g. rm's -f option. */
|
||||
{"ignore-fail-on-non-empty", no_argument, NULL, 13},
|
||||
{"ignore-fail-on-non-empty", no_argument, NULL, CHAR_MAX + 1},
|
||||
|
||||
{"path", no_argument, NULL, 'p'},
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
@@ -155,7 +163,7 @@ main (int argc, char **argv)
|
||||
case 'p':
|
||||
empty_paths = 1;
|
||||
break;
|
||||
case 13:
|
||||
case CHAR_MAX + 1:
|
||||
ignore_fail_on_non_empty = 1;
|
||||
break;
|
||||
case 14:
|
||||
@@ -199,14 +207,17 @@ main (int argc, char **argv)
|
||||
|
||||
if (fail)
|
||||
{
|
||||
if (!ignore_fail_on_non_empty || errno != ENOTEMPTY)
|
||||
{
|
||||
error (0, errno, "%s", dir);
|
||||
errors = 1;
|
||||
}
|
||||
if (ignore_fail_on_non_empty
|
||||
&& (errno == ENOTEMPTY || errno == EEXIST))
|
||||
continue;
|
||||
|
||||
error (0, errno, "%s", dir);
|
||||
errors = 1;
|
||||
}
|
||||
else if (empty_paths)
|
||||
errors += remove_parents (dir);
|
||||
{
|
||||
errors += remove_parents (dir);
|
||||
}
|
||||
}
|
||||
|
||||
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
|
||||
@@ -276,7 +276,7 @@ check_format (const char *fmt)
|
||||
fmt += strspn (fmt, "-+#0");
|
||||
if (ISDIGIT (*fmt))
|
||||
{
|
||||
fmt += strspn (fmt, "012345789");
|
||||
fmt += strspn (fmt, "0123456789");
|
||||
|
||||
if (*fmt == '.')
|
||||
fmt += strspn (++fmt, "0123456789");
|
||||
|
||||
82
src/sort.c
82
src/sort.c
@@ -61,7 +61,7 @@ char *xstrdup ();
|
||||
|
||||
#define FLOATING_POINT '.'
|
||||
#define FLOATING_COMMA ','
|
||||
#define NEGATIVE_SIGN '-'
|
||||
#define NEGATION_SIGN '-'
|
||||
#define NUMERIC_ZERO '0'
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
@@ -307,7 +307,7 @@ for that key. If no key given, use the entire line as key. With no\n\
|
||||
FILE, or when FILE is -, read standard input.\n\
|
||||
")
|
||||
, DEFAULT_TMPDIR);
|
||||
puts (_("\nReport bugs to textutils-bugs@gnu.org"));
|
||||
puts (_("\nReport bugs to <textutils-bugs@gnu.org>."));
|
||||
}
|
||||
/* Don't use EXIT_FAILURE here in case it is defined to be 1.
|
||||
POSIX requires that sort return 1 IFF invoked with -c and
|
||||
@@ -1132,7 +1132,7 @@ look_for_fraction (const char *s, const char *e)
|
||||
}
|
||||
|
||||
/* skip blanks and signs */
|
||||
while (blanks[UCHAR (*s)] || *s == NEGATIVE_SIGN)
|
||||
while (blanks[UCHAR (*s)] || *s == NEGATION_SIGN)
|
||||
s++;
|
||||
/* groups = {}, n = 0 */
|
||||
for (p = s; p < e; p++)
|
||||
@@ -1205,12 +1205,12 @@ numcompare (register const char *a, register const char *b)
|
||||
++b;
|
||||
|
||||
/* next character in a,b is non-blank */
|
||||
if ((*a == NEGATIVE_SIGN || *b == NEGATIVE_SIGN) && *a != *b)
|
||||
if ((*a == NEGATION_SIGN || *b == NEGATION_SIGN) && *a != *b)
|
||||
{
|
||||
/* a < 0, or b < 0, but not both */
|
||||
if (*a == NEGATIVE_SIGN)
|
||||
if (*a == NEGATION_SIGN)
|
||||
ret_code = -1, ++a; /* a looks < b */
|
||||
else if (*b == NEGATIVE_SIGN)
|
||||
else if (*b == NEGATION_SIGN)
|
||||
ret_code = 1, ++b; /* b looks < a */
|
||||
/* bypass zeroes, decimal points, and thousand sep in a & b */
|
||||
while (*a == NUMERIC_ZERO || (th_sep && *a == th_sep)
|
||||
@@ -1237,7 +1237,7 @@ numcompare (register const char *a, register const char *b)
|
||||
else
|
||||
{
|
||||
/* either both numbers are signed, or both are not-signed */
|
||||
if (*a == NEGATIVE_SIGN)
|
||||
if (*a == NEGATION_SIGN)
|
||||
{
|
||||
++a;
|
||||
++b;
|
||||
@@ -1306,12 +1306,12 @@ numcompare (register const char *a, register const char *b)
|
||||
while (blanks[tmpb])
|
||||
tmpb = UCHAR (*++b);
|
||||
|
||||
if (tmpa == NEGATIVE_SIGN)
|
||||
if (tmpa == NEGATION_SIGN)
|
||||
{
|
||||
do
|
||||
tmpa = UCHAR (*++a);
|
||||
while (tmpa == NUMERIC_ZERO);
|
||||
if (tmpb != NEGATIVE_SIGN)
|
||||
if (tmpb != NEGATION_SIGN)
|
||||
{
|
||||
if (tmpa == decimal_point)
|
||||
do
|
||||
@@ -1360,7 +1360,7 @@ numcompare (register const char *a, register const char *b)
|
||||
|
||||
return tmpb - tmpa;
|
||||
}
|
||||
else if (tmpb == NEGATIVE_SIGN)
|
||||
else if (tmpb == NEGATION_SIGN)
|
||||
{
|
||||
do
|
||||
tmpb = UCHAR (*++b);
|
||||
@@ -2280,7 +2280,9 @@ sort (char **files, int nfiles, FILE *ofp)
|
||||
#endif
|
||||
sortlines (lines.lines, lines.used, tmp);
|
||||
if (feof (fp) && !nfiles && !n_temp_files && !buf.left)
|
||||
tfp = ofp;
|
||||
{
|
||||
tfp = ofp;
|
||||
}
|
||||
else
|
||||
{
|
||||
++n_temp_files;
|
||||
@@ -2427,7 +2429,7 @@ key_init (struct keyfield *key)
|
||||
/* strdup and return the result of setlocale, but guard against a NULL
|
||||
return value. If setlocale returns NULL, strdup FAIL_VAL instead. */
|
||||
|
||||
#if !defined __GLIBC__ || __GLIBC__ < 2
|
||||
#if defined ENABLE_NLS && ( !defined __GLIBC__ || __GLIBC__ < 2 )
|
||||
static inline char *
|
||||
my_setlocale (const char *locale, const char *fail_val)
|
||||
{
|
||||
@@ -2857,49 +2859,73 @@ but lacks following character offset"));
|
||||
for (i = 0; i < nfiles; ++i)
|
||||
{
|
||||
char buf[8192];
|
||||
FILE *fp;
|
||||
FILE *in_fp;
|
||||
FILE *out_fp;
|
||||
int cc;
|
||||
|
||||
if (S_ISREG (outstat.st_mode) && !STREQ (outfile, files[i]))
|
||||
{
|
||||
struct stat instat;
|
||||
if ((!STREQ (files[i], "-")
|
||||
? stat (files[i], &instat)
|
||||
: fstat (STDIN_FILENO, &instat)) != 0)
|
||||
if ((STREQ (files[i], "-")
|
||||
? fstat (STDIN_FILENO, &instat)
|
||||
: stat (files[i], &instat)) != 0)
|
||||
{
|
||||
error (0, errno, "%s", files[i]);
|
||||
cleanup ();
|
||||
exit (SORT_FAILURE);
|
||||
}
|
||||
if (S_ISREG (instat.st_mode)
|
||||
&& (instat.st_ino != outstat.st_ino
|
||||
|| instat.st_dev != outstat.st_dev))
|
||||
if (S_ISREG (instat.st_mode) && !SAME_INODE (instat, outstat))
|
||||
{
|
||||
/* We know the files are distinct. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fp = xfopen (files[i], "r");
|
||||
in_fp = xfopen (files[i], "r");
|
||||
tmp = tempname ();
|
||||
ofp = xtmpfopen (tmp);
|
||||
while ((cc = fread (buf, 1, sizeof buf, fp)) > 0)
|
||||
write_bytes (buf, cc, ofp);
|
||||
if (ferror (fp))
|
||||
out_fp = xtmpfopen (tmp);
|
||||
/* FIXME: maybe use copy.c(copy) here. */
|
||||
while ((cc = fread (buf, 1, sizeof buf, in_fp)) > 0)
|
||||
write_bytes (buf, cc, out_fp);
|
||||
if (ferror (in_fp))
|
||||
{
|
||||
error (0, errno, "%s", files[i]);
|
||||
cleanup ();
|
||||
exit (SORT_FAILURE);
|
||||
}
|
||||
xfclose (ofp);
|
||||
xfclose (fp);
|
||||
xfclose (out_fp);
|
||||
xfclose (in_fp);
|
||||
files[i] = tmp;
|
||||
}
|
||||
ofp = xfopen (outfile, "w");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A non-`-' outfile was specified, but the file doesn't yet exist.
|
||||
Before opening it for writing (thus creating it), make sure all
|
||||
of the input files exist. Otherwise, creating the output file
|
||||
could create an otherwise missing input file, making sort succeed
|
||||
when it should fail. */
|
||||
for (i = 0; i < nfiles; ++i)
|
||||
{
|
||||
struct stat sb;
|
||||
if (STREQ (files[i], "-"))
|
||||
continue;
|
||||
if (stat (files[i], &sb))
|
||||
{
|
||||
error (0, errno, "%s", files[i]);
|
||||
cleanup ();
|
||||
exit (SORT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
ofp = xfopen (outfile, "w");
|
||||
}
|
||||
ofp = xfopen (outfile, "w");
|
||||
}
|
||||
else
|
||||
ofp = stdout;
|
||||
{
|
||||
ofp = stdout;
|
||||
}
|
||||
|
||||
if (mergeonly)
|
||||
merge (files, nfiles, ofp);
|
||||
|
||||
@@ -659,7 +659,7 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Return 1 if the string only contains valid options. */
|
||||
/* Return 1 if the string contains only valid options. */
|
||||
int
|
||||
valid_options (char *opt, const char *valid_opts,
|
||||
const char *valid_arg_opts)
|
||||
|
||||
6
src/su.c
6
src/su.c
@@ -1,5 +1,5 @@
|
||||
/* su for GNU. Run a shell with substitute user and group IDs.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -170,9 +170,9 @@ static int change_environment;
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"command", required_argument, 0, 'c'},
|
||||
{"fast", no_argument, &fast_startup, 1},
|
||||
{"fast", no_argument, NULL, 'f'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"login", no_argument, &simulate_login, 1},
|
||||
{"login", no_argument, NULL, 'l'},
|
||||
{"preserve-environment", no_argument, &change_environment, 0},
|
||||
{"shell", required_argument, 0, 's'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
|
||||
64
src/sys2.h
64
src/sys2.h
@@ -156,3 +156,67 @@ off_t lseek ();
|
||||
/* Be CAREFUL that there are no side effects in N. */
|
||||
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
|
||||
#endif
|
||||
|
||||
/* These are wrappers for functions/macros from GNU libc.
|
||||
The standard I/O functions are thread-safe. These *_unlocked ones
|
||||
are more efficient but not thread-safe. That they're not thread-safe
|
||||
is fine since all these applications are single threaded. */
|
||||
|
||||
#ifdef HAVE_CLEARERR_UNLOCKED
|
||||
# undef clearerr
|
||||
# define clearerr(S) clearerr_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FEOF_UNLOCKED
|
||||
# undef feof
|
||||
# define feof(S) feof_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FERROR_UNLOCKED
|
||||
# undef ferror
|
||||
# define ferror(S) ferror_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FFLUSH_UNLOCKED
|
||||
# undef fflush
|
||||
# define fflush(S) fflush_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FPUTC_UNLOCKED
|
||||
# undef fputc
|
||||
# define fputc(C, S) fputc_unlocked (C, S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FREAD_UNLOCKED
|
||||
# undef fread
|
||||
# define fread(P, Z, N, S) fread_unlocked (P, Z, N, S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FWRITE_UNLOCKED
|
||||
# undef fwrite
|
||||
# define fwrite(P, Z, N, S) fwrite_unlocked (P, Z, N, S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETC_UNLOCKED
|
||||
# undef getc
|
||||
# define getc(S) getc_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETCHAR_UNLOCKED
|
||||
# undef getchar
|
||||
# define getchar(S) getchar_unlocked (S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PUTC_UNLOCKED
|
||||
# undef putc
|
||||
# define putc(C, S) putc_unlocked (C, S)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PUTCHAR_UNLOCKED
|
||||
# undef putchar
|
||||
# define putchar(C) putchar_unlocked (C)
|
||||
#endif
|
||||
|
||||
#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
|
||||
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
|
||||
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
|
||||
|
||||
24
src/system.h
24
src/system.h
@@ -81,6 +81,17 @@
|
||||
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
#endif
|
||||
|
||||
#ifdef ST_MTIM_NSEC
|
||||
# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns)
|
||||
#else
|
||||
# define ST_TIME_CMP_NS(a, b, ns) 0
|
||||
#endif
|
||||
#define ST_TIME_CMP(a, b, s, ns) \
|
||||
((a).s < (b).s ? -1 : (a).s > (b).s ? 1 : ST_TIME_CMP_NS(a, b, ns))
|
||||
#define ATIME_CMP(a, b) ST_TIME_CMP (a, b, st_atime, st_atim.ST_MTIM_NSEC)
|
||||
#define CTIME_CMP(a, b) ST_TIME_CMP (a, b, st_ctime, st_ctim.ST_MTIM_NSEC)
|
||||
#define MTIME_CMP(a, b) ST_TIME_CMP (a, b, st_mtime, st_mtim.ST_MTIM_NSEC)
|
||||
|
||||
#if !defined(HAVE_MKFIFO)
|
||||
# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
|
||||
#endif
|
||||
@@ -118,20 +129,19 @@
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
|
||||
It is necessary at least when t == time_t. */
|
||||
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
|
||||
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
|
||||
#ifndef SCHAR_MIN
|
||||
# define SCHAR_MIN TYPE_MINIMUM (char)
|
||||
#ifndef CHAR_MIN
|
||||
# define CHAR_MIN TYPE_MINIMUM (char)
|
||||
#endif
|
||||
|
||||
#ifndef SCHAR_MAX
|
||||
# define SCHAR_MAX TYPE_MAXIMUM (char)
|
||||
#ifndef CHAR_MAX
|
||||
# define CHAR_MAX TYPE_MAXIMUM (char)
|
||||
#endif
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
|
||||
@@ -42,11 +42,7 @@ tac -r -s '.\|
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
12
src/tail.c
12
src/tail.c
@@ -132,11 +132,11 @@ static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"allow-missing", required_argument, NULL, 11},
|
||||
{"allow-missing", required_argument, NULL, CHAR_MAX + 1},
|
||||
{"bytes", required_argument, NULL, 'c'},
|
||||
{"follow", no_argument, NULL, 'f'},
|
||||
{"follow-descriptor", no_argument, NULL, 12},
|
||||
{"follow-name", no_argument, NULL, 13},
|
||||
{"follow-descriptor", no_argument, NULL, CHAR_MAX + 2},
|
||||
{"follow-name", no_argument, NULL, CHAR_MAX + 3},
|
||||
{"lines", required_argument, NULL, 'n'},
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"silent", no_argument, NULL, 'q'},
|
||||
@@ -1168,15 +1168,15 @@ parse_options (int argc, char **argv,
|
||||
forever = 1;
|
||||
break;
|
||||
|
||||
case 11:
|
||||
case CHAR_MAX + 1:
|
||||
allow_missing = 1;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
case CHAR_MAX + 2:
|
||||
follow_mode = follow_descriptor;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
case CHAR_MAX + 3:
|
||||
follow_mode = follow_name;
|
||||
break;
|
||||
|
||||
|
||||
36
src/test.c
36
src/test.c
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Modified to run with the GNU shell by bfox. */
|
||||
|
||||
/* Copyright (C) 1987-1996, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -370,7 +370,7 @@ term (void)
|
||||
value = binary_operator ();
|
||||
|
||||
/* Might be a switch type argument */
|
||||
else if ('-' == argv[pos][0] && 0 == argv[pos][2])
|
||||
else if ('-' == argv[pos][0] && argv[pos][1] && 0 == argv[pos][2])
|
||||
{
|
||||
if (unop (argv[pos][1]))
|
||||
value = unary_operator ();
|
||||
@@ -627,7 +627,7 @@ binary_operator (void)
|
||||
static int
|
||||
unary_operator (void)
|
||||
{
|
||||
long r, value;
|
||||
long fd, value;
|
||||
struct stat stat_buf;
|
||||
|
||||
switch (argv[pos][1])
|
||||
@@ -784,14 +784,19 @@ unary_operator (void)
|
||||
return (TRUE == (0 != (stat_buf.st_mode & S_ISVTX)));
|
||||
#endif
|
||||
|
||||
case 't': /* File (fd) is a terminal? (fd) defaults to stdout. */
|
||||
case 't': /* File (fd) is a terminal? */
|
||||
advance (0);
|
||||
if (pos < argc && isint (argv[pos], &r))
|
||||
if (pos < argc)
|
||||
{
|
||||
if (!isint (argv[pos], &fd))
|
||||
integer_expected_error (_("after -t"));
|
||||
advance (0);
|
||||
return (TRUE == (isatty ((int) r)));
|
||||
}
|
||||
return (TRUE == (isatty (1)));
|
||||
else
|
||||
{
|
||||
fd = 1;
|
||||
}
|
||||
return (TRUE == (isatty ((int) fd)));
|
||||
|
||||
case 'n': /* True if arg has some length. */
|
||||
unary_advance ();
|
||||
@@ -873,14 +878,25 @@ unop (int op)
|
||||
return (member (op, "abcdefgkLhprsStuwxOGnz"));
|
||||
}
|
||||
|
||||
static int
|
||||
one_argument (const char *s)
|
||||
{
|
||||
if (STREQ (s, "-t"))
|
||||
return (TRUE == (isatty (1)));
|
||||
|
||||
return strlen (s) != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
two_arguments (void)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (STREQ (argv[pos], "!"))
|
||||
value = strlen (argv[pos+1]) == 0;
|
||||
else if ((argv[pos][0] == '-') && (argv[pos][2] == '\0'))
|
||||
value = ! one_argument (argv[pos+1]);
|
||||
else if (argv[pos][0] == '-'
|
||||
&& argv[pos][1] != '\0'
|
||||
&& argv[pos][2] == '\0')
|
||||
{
|
||||
if (unop (argv[pos][1]))
|
||||
value = unary_operator ();
|
||||
@@ -929,7 +945,7 @@ posixtest (void)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
value = strlen (argv[1]) != 0;
|
||||
value = one_argument (argv[1]);
|
||||
pos = argc;
|
||||
break;
|
||||
|
||||
|
||||
71
src/touch.c
71
src/touch.c
@@ -15,21 +15,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Options:
|
||||
-a, --time={atime,access,use} Change access time only.
|
||||
-c, --no-create Do not create files that do not exist.
|
||||
-d, --date=TIME Specify time and date in various formats.
|
||||
-f Ignored.
|
||||
-m, --time={mtime,modify} Change modification time only.
|
||||
-r, --reference=FILE Use the time and date of reference file FILE.
|
||||
-t TIME Specify time and date in the form
|
||||
`MMDDhhmm[[CC]YY][.ss]'.
|
||||
|
||||
If no options are given, -am is the default, using the current time.
|
||||
The -r, -t, and -d options are mutually exclusive. If a file does not
|
||||
exist, create it unless -c is given.
|
||||
|
||||
Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie,
|
||||
/* Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie,
|
||||
and Randy Smith. */
|
||||
|
||||
#include <config.h>
|
||||
@@ -43,19 +29,15 @@
|
||||
#include "argmatch.h"
|
||||
#include "getdate.h"
|
||||
#include "safe-read.h"
|
||||
#include "posixtm.h"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
time_t time ();
|
||||
#endif
|
||||
|
||||
time_t posixtime ();
|
||||
int full_write ();
|
||||
void invalid_arg ();
|
||||
|
||||
#if ! HAVE_UTIME_NULL
|
||||
static int utime_now ();
|
||||
#endif
|
||||
|
||||
/* Bitmasks for `change_times'. */
|
||||
#define CH_ATIME 1
|
||||
#define CH_MTIME 2
|
||||
@@ -100,7 +82,7 @@ static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"time", required_argument, 0, 130},
|
||||
{"time", required_argument, 0, CHAR_MAX + 1},
|
||||
{"no-create", no_argument, 0, 'c'},
|
||||
{"date", required_argument, 0, 'd'},
|
||||
{"file", required_argument, 0, 'r'},
|
||||
@@ -171,18 +153,18 @@ touch (char *file)
|
||||
|
||||
if (amtime_now)
|
||||
{
|
||||
#if ! HAVE_UTIME_NULL
|
||||
status = utime_now (file, sbuf.st_size);
|
||||
#else
|
||||
/* Pass NULL to utime so it will not fail if we just have
|
||||
write access to the file, but don't own it. */
|
||||
status = utime (file, NULL);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
struct utimbuf utb;
|
||||
|
||||
/* There's currently no interface to set file timestamps with
|
||||
better than 1-second resolution, so discard any fractional
|
||||
part of the source timestamp. */
|
||||
|
||||
if (use_ref)
|
||||
{
|
||||
utb.actime = ref_stats.st_atime;
|
||||
@@ -209,32 +191,6 @@ touch (char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if ! HAVE_UTIME_NULL
|
||||
/* Emulate utime (file, NULL) for systems (like 4.3BSD) that do not
|
||||
interpret it to set the access and modification times of FILE to
|
||||
the current time. FILESIZE is the correct size of FILE, used to
|
||||
make sure empty files are not lengthened to 1 byte.
|
||||
Return 0 if successful, -1 if not. */
|
||||
|
||||
static int
|
||||
utime_now (const char *file, off_t filesize)
|
||||
{
|
||||
int fd;
|
||||
char c;
|
||||
int status = 0;
|
||||
|
||||
fd = open (file, O_RDWR, 0666);
|
||||
if (fd < 0
|
||||
|| safe_read (fd, &c, sizeof (char)) < 0
|
||||
|| lseek (fd, (off_t) 0, SEEK_SET) < 0
|
||||
|| full_write (fd, &c, sizeof (char)) < 0
|
||||
|| ftruncate (fd, filesize) < 0
|
||||
|| close (fd) < 0)
|
||||
status = -1;
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -244,6 +200,8 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [OPTION]... FILE...\n"), program_name);
|
||||
printf (_(" or : %s [-acm] MMDDhhmm[YY] FILE... (obsolescent)\n"),
|
||||
program_name);
|
||||
printf (_("\
|
||||
Update the access and modification times of each FILE to the current time.\n\
|
||||
\n\
|
||||
@@ -253,12 +211,14 @@ Update the access and modification times of each FILE to the current time.\n\
|
||||
-f (ignored)\n\
|
||||
-m change only the modification time\n\
|
||||
-r, --reference=FILE use this file's times instead of current time\n\
|
||||
-t STAMP use MMDDhhmm[[CC]YY][.ss] instead of current time\n\
|
||||
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time\n\
|
||||
--time=WORD access -a, atime -a, mtime -m, modify -m, use -a\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
STAMP may be used without -t if none of -drt, nor --, are used.\n\
|
||||
Note that the three time-date formats recognized for the -d and -t options\n\
|
||||
and for the obsolescent argument are all different.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
@@ -318,13 +278,14 @@ main (int argc, char **argv)
|
||||
|
||||
case 't':
|
||||
posix_date++;
|
||||
newtime = posixtime (optarg);
|
||||
newtime = posixtime (optarg,
|
||||
PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS);
|
||||
if (newtime == (time_t) -1)
|
||||
error (1, 0, _("invalid date format `%s'"), optarg);
|
||||
date_set++;
|
||||
break;
|
||||
|
||||
case 130:
|
||||
case CHAR_MAX + 1:
|
||||
i = argmatch (optarg, time_args);
|
||||
if (i < 0)
|
||||
{
|
||||
@@ -368,7 +329,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (!date_set && optind < argc && !STREQ (argv[optind - 1], "--"))
|
||||
{
|
||||
newtime = posixtime (argv[optind]);
|
||||
newtime = posixtime (argv[optind], PDS_TRAILING_YEAR);
|
||||
if (newtime != (time_t) -1)
|
||||
{
|
||||
optind++;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GNU's uptime.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,9 +20,9 @@
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -162,7 +162,9 @@ usage (int status)
|
||||
{
|
||||
printf (_("Usage: %s [OPTION]... [ FILE ]\n"), program_name);
|
||||
printf (_("\
|
||||
Output who is currently logged in according to FILE.\n\
|
||||
Print the current time, the length of time the system has been up,\n\
|
||||
the number of users on the system, and the average number of jobs\n\
|
||||
in the run queue over the last 1, 5 and 15 minutes.\n\
|
||||
If FILE is not specified, use %s. %s as FILE is common.\n\
|
||||
\n\
|
||||
--help display this help and exit\n\
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GNU's users.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,9 +20,9 @@
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
8
src/wc.c
8
src/wc.c
@@ -111,22 +111,22 @@ write_counts (uintmax_t lines,
|
||||
|
||||
if (print_lines)
|
||||
{
|
||||
printf ("%7s", human_readable (lines, buf, 1, 1, 0));
|
||||
printf ("%7s", human_readable (lines, buf, 1, 1));
|
||||
space = " ";
|
||||
}
|
||||
if (print_words)
|
||||
{
|
||||
printf ("%s%7s", space, human_readable (words, buf, 1, 1, 0));
|
||||
printf ("%s%7s", space, human_readable (words, buf, 1, 1));
|
||||
space = " ";
|
||||
}
|
||||
if (print_chars)
|
||||
{
|
||||
printf ("%s%7s", space, human_readable (chars, buf, 1, 1, 0));
|
||||
printf ("%s%7s", space, human_readable (chars, buf, 1, 1));
|
||||
space = " ";
|
||||
}
|
||||
if (print_linelength)
|
||||
{
|
||||
printf ("%s%7s", space, human_readable (linelength, buf, 1, 1, 0));
|
||||
printf ("%s%7s", space, human_readable (linelength, buf, 1, 1));
|
||||
}
|
||||
if (*file)
|
||||
printf (" %s", file);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GNU's who.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -27,9 +27,9 @@
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 64
|
||||
|
||||
287
tests/Fetish.pm
Normal file
287
tests/Fetish.pm
Normal file
@@ -0,0 +1,287 @@
|
||||
package Fetish;
|
||||
# This is a testing framework.
|
||||
|
||||
# In case you're wondering about the name, it comes from the
|
||||
# names of the three packages: FIleutils, SH-utils, TExtutils.
|
||||
|
||||
require 5.003;
|
||||
use strict;
|
||||
use vars qw($VERSION @ISA @EXPORT);
|
||||
|
||||
use FileHandle;
|
||||
use File::Compare qw(compare);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
($VERSION = '$Revision: 1.3 $ ') =~ tr/[0-9].//cd;
|
||||
@EXPORT = qw (run_tests);
|
||||
|
||||
my @Types = qw (IN OUT ERR EXIT PRE POST);
|
||||
my %Types = map {$_ => 1} @Types;
|
||||
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT PRE POST);
|
||||
my $srcdir = $ENV{srcdir};
|
||||
my $Global_count = 1;
|
||||
|
||||
# A file spec: a scalar or a reference to a single-keyed hash
|
||||
# ================
|
||||
# 'contents' contents only (file name is derived from test name)
|
||||
# {filename => 'contents'} filename and contents
|
||||
# {filename => undef} filename only -- $(srcdir)/filename must exist
|
||||
#
|
||||
# FIXME: If there is more than one input file, the you can't specify REDIRECT.
|
||||
# PIPE is still ok.
|
||||
#
|
||||
# I/O spec: a hash ref with the following properties
|
||||
# ================
|
||||
# - one key/value pair
|
||||
# - the key must be one of these strings: IN, OUT, ERR, EXIT
|
||||
# - the value must be a file spec
|
||||
# {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
|
||||
# {OUT => {'filename'=>undef}} compare contents of existing filename to
|
||||
# stdout from cmd
|
||||
# {OUT => {'filename'=>[$CTOR, $DTOR]}} $CTOR and $DTOR are references to
|
||||
# functions, each which is passed the single argument `filename'.
|
||||
# $CTOR must create `filename'.
|
||||
# DTOR may be omitted in which case `sub{unlink @_[0]}' is used.
|
||||
# FIXME: implement this
|
||||
# Ditto for `ERR', but compare with stderr
|
||||
# {EXIT => N} expect exit status of cmd to be N
|
||||
#
|
||||
# There may be many input file specs. File names from the input specs
|
||||
# are concatenated in order on the command line.
|
||||
# There may be at most one of the OUT-, ERR-, and EXIT-keyed specs.
|
||||
# If the OUT-(or ERR)-keyed hash ref is omitted, then expect no output
|
||||
# on stdout (or stderr).
|
||||
# If the EXIT-keyed one is omitted, then expect the exit status to be zero.
|
||||
|
||||
# FIXME: Make sure that no junkfile is also listed as a
|
||||
# non-junkfile (i.e. with undef for contents)
|
||||
|
||||
sub _shell_quote ($)
|
||||
{
|
||||
my ($string) = @_;
|
||||
$string =~ s/\'/\'\\\'\'/g;
|
||||
return "'$string'";
|
||||
}
|
||||
|
||||
sub _create_file ($$$$)
|
||||
{
|
||||
my ($program_name, $test_name, $file_name, $data) = @_;
|
||||
my $file;
|
||||
if (defined $file_name)
|
||||
{
|
||||
$file = $file_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = "$test_name.$Global_count";
|
||||
++$Global_count;
|
||||
}
|
||||
|
||||
# The test spec gave a string.
|
||||
# Write it to a temp file and return tempfile name.
|
||||
my $fh = new FileHandle "> $file";
|
||||
die "$program_name: $file: $!\n" if ! $fh;
|
||||
print $fh $data;
|
||||
$fh->close || die "$program_name: $file: $!\n";
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
# FIXME: cleanup on interrupt
|
||||
# FIXME: extract `do_1_test' function
|
||||
|
||||
# FIXME: having to include $program_name here is an expedient kludge.
|
||||
# Library code doesn't `die'.
|
||||
sub run_tests ($$$$$)
|
||||
{
|
||||
my ($program_name, $prog, $t_spec, $save_temps, $verbose) = @_;
|
||||
|
||||
# Warn about empty t_spec.
|
||||
# FIXME
|
||||
|
||||
# Remove all temp files upon interrupt.
|
||||
# FIXME
|
||||
|
||||
# Verify that test names are distinct.
|
||||
my $found_duplicate = 0;
|
||||
my %seen;
|
||||
my $t;
|
||||
foreach $t (@$t_spec)
|
||||
{
|
||||
my $test_name = $t->[0];
|
||||
if ($seen{$test_name})
|
||||
{
|
||||
warn "$program_name: $test_name: duplicate test name\n";
|
||||
$found_duplicate = 1;
|
||||
}
|
||||
$seen{$test_name} = 1;
|
||||
}
|
||||
return 1 if $found_duplicate;
|
||||
|
||||
# FIXME check exit status
|
||||
system ($prog, '--version');
|
||||
|
||||
my @junk_files;
|
||||
my $fail = 0;
|
||||
foreach $t (@$t_spec)
|
||||
{
|
||||
my $test_name = shift @$t;
|
||||
my $expect = {};
|
||||
my ($pre, $post);
|
||||
|
||||
# FIXME: maybe don't reset this.
|
||||
$Global_count = 1;
|
||||
my @args;
|
||||
my $io_spec;
|
||||
my %seen_type;
|
||||
foreach $io_spec (@$t)
|
||||
{
|
||||
if (!ref $io_spec)
|
||||
{
|
||||
push @args, $io_spec;
|
||||
next;
|
||||
}
|
||||
|
||||
die "$program_name: $test_name: invalid test spec\n"
|
||||
if ref $io_spec ne 'HASH';
|
||||
|
||||
my $n = keys %$io_spec;
|
||||
die "$program_name: $test_name: spec has $n elements --"
|
||||
. " expected 1\n"
|
||||
if $n != 1;
|
||||
my ($type, $val) = each %$io_spec;
|
||||
die "$program_name: $test_name: invalid key `$type' in test spec\n"
|
||||
if ! $Types{$type};
|
||||
|
||||
# Make sure there's no more than one of OUT, ERR, EXIT.
|
||||
die "$program_name: $test_name: more than one $type spec\n"
|
||||
if $Zero_one_type{$type} and $seen_type{$type}++;
|
||||
|
||||
if ($type eq 'PRE' or $type eq 'POST')
|
||||
{
|
||||
$expect->{$type} = $val;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($type eq 'EXIT')
|
||||
{
|
||||
die "$program_name: $test_name: invalid EXIT code\n"
|
||||
if $val !~ /^\d+$/;
|
||||
# FIXME: make sure $data is numeric
|
||||
$expect->{EXIT} = $val;
|
||||
next;
|
||||
}
|
||||
|
||||
my $file_spec = $val;
|
||||
my ($file_name, $contents);
|
||||
if (!ref $file_spec)
|
||||
{
|
||||
($file_name, $contents) = (undef, $file_spec);
|
||||
}
|
||||
elsif (ref $file_spec eq 'HASH')
|
||||
{
|
||||
my $n = keys %$file_spec;
|
||||
die "$program_name: $test_name: $type spec has $n elements --"
|
||||
. " expected 1\n"
|
||||
if $n != 1;
|
||||
($file_name, $contents) = each %$file_spec;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "$program_name: $test_name: invalid RHS in $type-spec\n"
|
||||
}
|
||||
|
||||
my $is_junk_file = (! defined $file_name
|
||||
|| ($type eq 'IN' && defined $contents));
|
||||
my $file = _create_file ($program_name, $test_name,
|
||||
$file_name, $contents);
|
||||
if ($type eq 'IN')
|
||||
{
|
||||
push @args, _shell_quote $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$expect->{$type} = $file;
|
||||
}
|
||||
|
||||
if ($is_junk_file)
|
||||
{
|
||||
push @junk_files, $file
|
||||
}
|
||||
else
|
||||
{
|
||||
# FIXME: put $srcdir in here somewhere
|
||||
warn "$program_name: $test_name: specified file `$file' does"
|
||||
. " not exist\n"
|
||||
if ! -f "$srcdir/$file";
|
||||
}
|
||||
}
|
||||
|
||||
# Expect an exit status of zero if it's not specified.
|
||||
$expect->{EXIT} ||= 0;
|
||||
|
||||
# Allow ERR to be omitted -- in that case, expect no error output.
|
||||
my $eo;
|
||||
foreach $eo (qw (OUT ERR))
|
||||
{
|
||||
if (!exists $expect->{$eo})
|
||||
{
|
||||
$expect->{$eo} = _create_file ($program_name, $test_name,
|
||||
undef, '');
|
||||
push @junk_files, $expect->{$eo};
|
||||
}
|
||||
}
|
||||
|
||||
# FIXME: Does it ever make sense to specify a filename *and* contents
|
||||
# in OUT or ERR spec?
|
||||
|
||||
warn "$test_name...\n" if $verbose;
|
||||
&{$expect->{PRE}} if $expect->{PRE};
|
||||
my %tmp;
|
||||
$tmp{OUT} = "$test_name.O";
|
||||
$tmp{ERR} = "$test_name.E";
|
||||
push @junk_files, $tmp{OUT}, $tmp{ERR};
|
||||
my @cmd = ($prog, @args, "> $tmp{OUT}", "2> $tmp{ERR}");
|
||||
my $cmd_str = join ' ', @cmd;
|
||||
warn "Running command: `$cmd_str'\n" if $verbose;
|
||||
my $rc = 0xffff & system $cmd_str;
|
||||
if ($rc == 0xff00)
|
||||
{
|
||||
warn "$program_name: test $test_name failed: command failed:\n"
|
||||
. " `$cmd_str': $!\n";
|
||||
$fail = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
$rc >>= 8 if $rc > 0x80;
|
||||
if ($expect->{EXIT} != $rc)
|
||||
{
|
||||
warn "$program_name: test $test_name failed: exit status mismatch:"
|
||||
. " expected $expect->{EXIT}, got $rc\n";
|
||||
$fail = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
foreach $eo (qw (OUT ERR))
|
||||
{
|
||||
my $eo_lower = lc $eo;
|
||||
if (compare ($expect->{$eo}, $tmp{$eo}))
|
||||
{
|
||||
warn "$program_name: test $test_name: std$eo_lower mismatch,"
|
||||
. " comparing $expect->{$eo} and $tmp{$eo}\n";
|
||||
$fail = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
&{$expect->{POST}} if $expect->{POST};
|
||||
|
||||
}
|
||||
|
||||
# FIXME: maybe unlink files inside the big foreach loop?
|
||||
unlink @junk_files if ! $save_temps;
|
||||
|
||||
return $fail;
|
||||
}
|
||||
|
||||
## package return
|
||||
1;
|
||||
@@ -20,6 +20,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
|
||||
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
|
||||
CLEANFILES = $(run_gen)
|
||||
|
||||
check: $(maint_gen)
|
||||
|
||||
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
|
||||
rm -f $@ $@t
|
||||
sed -n '1,/^##test-files-begin/p' $< > $@t
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
|
||||
AUTOMAKE_OPTIONS = 1.1 gnits
|
||||
|
||||
TESTS = backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src
|
||||
TESTS = \
|
||||
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
|
||||
same-file
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = CP=../../src/cp RM=../../src/rm
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -92,7 +91,9 @@ l = @l@
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.1 gnits
|
||||
|
||||
TESTS = backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src
|
||||
TESTS = \
|
||||
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
|
||||
same-file
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = CP=../../src/cp RM=../../src/rm
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
||||
@@ -10,8 +10,8 @@ fi
|
||||
|
||||
framework_failure=0
|
||||
$RM -f a a~ || framework_failure=1
|
||||
: > a || framework_failure=1
|
||||
echo a > a~ || framework_failure=1
|
||||
echo a > a || framework_failure=1
|
||||
echo a-tilde > a~ || framework_failure=1
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
|
||||
174
tests/cp/same-file
Executable file
174
tests/cp/same-file
Executable file
@@ -0,0 +1,174 @@
|
||||
#!/bin/sh
|
||||
# Test some of cp's options and how cp handles situations in
|
||||
# which a naive implementation might overwrite the source file.
|
||||
|
||||
# FIXME: punt for now
|
||||
CP=cp
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
$CP --version
|
||||
fi
|
||||
|
||||
LANGUAGE=C; export LANGUAGE
|
||||
LANG=C; export LANG
|
||||
|
||||
VERSION_CONTROL=numbered; export VERSION_CONTROL
|
||||
|
||||
pwd=`pwd`
|
||||
PATH=$pwd/../../src:$PATH
|
||||
|
||||
actual=actual-$$
|
||||
expected=expected-$$
|
||||
trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
|
||||
|
||||
exec 1> $actual
|
||||
|
||||
# FIXME: This should be bigger: like more than 8k
|
||||
contents=XYZ
|
||||
|
||||
for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
|
||||
for options in '' -d -f -df -b -bd -bf -bdf \
|
||||
-l -dl -fl -dfl -bl -bdl -bfl -bdfl; do
|
||||
case $args$options in
|
||||
# These tests are not portable.
|
||||
'sl1 sl2'-bd*l)
|
||||
continue;;
|
||||
'symlink foo'-dfl)
|
||||
continue;;
|
||||
'symlink foo'-bdfl)
|
||||
continue;;
|
||||
'sl1 sl2'-dfl)
|
||||
continue;;
|
||||
esac
|
||||
rm -rf dir
|
||||
mkdir dir
|
||||
cd dir
|
||||
echo $contents > foo
|
||||
case "$args" in *symlink*) ln -s foo symlink ;; esac
|
||||
case "$args" in *hardlink*) ln foo hardlink ;; esac
|
||||
case "$args" in *sl1*) ln -s foo sl1;; esac
|
||||
case "$args" in *sl2*) ln -s foo sl2;; esac
|
||||
(
|
||||
(
|
||||
# echo 1>&2 $CP $options $args
|
||||
$CP $options $args 2>.err
|
||||
echo $? $options
|
||||
|
||||
# Normalize the program name in the error output,
|
||||
# and put brackets around the output.
|
||||
test -s .err && echo "[`sed 's/^[^:][^:]*:/cp:/' .err`]"
|
||||
# Strip off all but the file names.
|
||||
ls="`ls -lG --ignore=.err . \
|
||||
| sed \
|
||||
-e '/^total /d' \
|
||||
-e 's/^..............................................//'`"
|
||||
echo "($ls)"
|
||||
# Make sure the original is unchanged and that
|
||||
# the destination is a copy.
|
||||
for f in $args; do
|
||||
if test -f $f; then
|
||||
case "`cat $f`" in
|
||||
"$contents") ;;
|
||||
*) echo cp FAILED;;
|
||||
esac
|
||||
else
|
||||
echo symlink-loop
|
||||
fi
|
||||
done
|
||||
) | tr '\012' ' '
|
||||
echo
|
||||
) | sed 's/ *$//'
|
||||
cd ..
|
||||
done
|
||||
echo
|
||||
done
|
||||
|
||||
cat <<\EOF > $expected
|
||||
1 [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
|
||||
1 -d [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
|
||||
0 -f (foo symlink)
|
||||
0 -df (foo symlink)
|
||||
0 -b (foo symlink symlink.~1~ -> foo)
|
||||
0 -bd (foo symlink symlink.~1~ -> foo)
|
||||
0 -bf (foo symlink symlink.~1~ -> foo)
|
||||
0 -bdf (foo symlink symlink.~1~ -> foo)
|
||||
0 -l (foo symlink -> foo)
|
||||
0 -dl (foo symlink -> foo)
|
||||
0 -fl (foo symlink -> foo)
|
||||
0 -dfl (foo symlink)
|
||||
0 -bl (foo symlink -> foo)
|
||||
0 -bdl (foo symlink symlink.~1~ -> foo)
|
||||
0 -bfl (foo symlink -> foo)
|
||||
0 -bdfl (foo symlink symlink.~1~ -> foo)
|
||||
|
||||
1 [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
|
||||
1 -d [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
|
||||
1 -f [cp: `symlink' and `foo' are the same file] (symlink -> foo) symlink-loop symlink-loop
|
||||
0 -df (foo -> foo symlink -> foo) symlink-loop symlink-loop
|
||||
1 -b [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
|
||||
0 -bd (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop
|
||||
1 -bf [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
|
||||
0 -bdf (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop
|
||||
0 -l (foo symlink -> foo)
|
||||
0 -dl (foo symlink -> foo)
|
||||
0 -fl (foo symlink -> foo)
|
||||
0 -bl (foo symlink -> foo)
|
||||
0 -bdl (foo symlink -> foo)
|
||||
0 -bfl (foo symlink -> foo)
|
||||
|
||||
1 [cp: `foo' and `foo' are the same file] (foo)
|
||||
1 -d [cp: `foo' and `foo' are the same file] (foo)
|
||||
1 -f [cp: `foo' and `foo' are the same file] () symlink-loop symlink-loop
|
||||
1 -df [cp: `foo' and `foo' are the same file] () symlink-loop symlink-loop
|
||||
1 -b [cp: `foo' and `foo' are the same file] (foo)
|
||||
1 -bd [cp: `foo' and `foo' are the same file] (foo)
|
||||
0 -bf (foo foo.~1~)
|
||||
0 -bdf (foo foo.~1~)
|
||||
0 -l (foo)
|
||||
0 -dl (foo)
|
||||
0 -fl (foo)
|
||||
0 -dfl (foo)
|
||||
0 -bl (foo)
|
||||
0 -bdl (foo)
|
||||
0 -bfl (foo foo.~1~)
|
||||
0 -bdfl (foo foo.~1~)
|
||||
|
||||
1 [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
|
||||
1 -d [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
|
||||
0 -f (foo sl1 -> foo sl2)
|
||||
0 -df (foo sl1 -> foo sl2 -> foo)
|
||||
0 -b (foo sl1 -> foo sl2 sl2.~1~ -> foo)
|
||||
0 -bd (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
|
||||
0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo)
|
||||
0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
|
||||
0 -l (foo sl1 -> foo sl2 -> foo)
|
||||
0 -dl (foo sl1 -> foo sl2 -> foo)
|
||||
0 -fl (foo sl1 -> foo sl2 -> foo)
|
||||
0 -bl (foo sl1 -> foo sl2 -> foo)
|
||||
0 -bfl (foo sl1 -> foo sl2 -> foo)
|
||||
|
||||
1 [cp: `foo' and `hardlink' are the same file] (foo hardlink)
|
||||
1 -d [cp: `foo' and `hardlink' are the same file] (foo hardlink)
|
||||
0 -f (foo hardlink)
|
||||
0 -df (foo hardlink)
|
||||
0 -b (foo hardlink hardlink.~1~)
|
||||
0 -bd (foo hardlink hardlink.~1~)
|
||||
0 -bf (foo hardlink hardlink.~1~)
|
||||
0 -bdf (foo hardlink hardlink.~1~)
|
||||
0 -l (foo hardlink)
|
||||
0 -dl (foo hardlink)
|
||||
0 -fl (foo hardlink)
|
||||
0 -dfl (foo hardlink)
|
||||
0 -bl (foo hardlink)
|
||||
0 -bdl (foo hardlink)
|
||||
0 -bfl (foo hardlink)
|
||||
0 -bdfl (foo hardlink)
|
||||
|
||||
EOF
|
||||
|
||||
# Uncomment this if you see a failure and want to try to diagnose it.
|
||||
# diff -u $expected $actual 1>&2
|
||||
|
||||
cmp $expected $actual
|
||||
exit $?
|
||||
@@ -8,13 +8,17 @@ maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
|
||||
i.X j.I j.X k.I k.X l.I l.X m.I m.X n.I n.X o.I o.X p.I p.X q.I q.X r.I r.X \
|
||||
s.I s.X t.I t.X u.I u.X v.I v.X w.I w.X x.I x.X y.I y.X z.I z.X empty-fl.I \
|
||||
empty-fl.X missing-fl.I missing-fl.X empty-bl.I empty-bl.X missing-bl.I \
|
||||
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X
|
||||
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X o-delim.I o-delim.X \
|
||||
nul-idelim.I nul-idelim.X nul-odelim.I nul-odelim.X multichar-od.I \
|
||||
multichar-od.X
|
||||
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
|
||||
9.E a.O a.E b.O b.E c.O c.E d.O d.E e.O e.E f.O f.E g.O g.E h.O h.E i.O i.E \
|
||||
j.O j.E k.O k.E l.O l.E m.O m.E n.O n.E o.O o.E p.O p.E q.O q.E r.O r.E s.O \
|
||||
s.E t.O t.E u.O u.E v.O v.E w.O w.E x.O x.E y.O y.E z.O z.E empty-fl.O \
|
||||
empty-fl.E missing-fl.O missing-fl.E empty-bl.O empty-bl.E missing-bl.O \
|
||||
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E
|
||||
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E o-delim.O o-delim.E \
|
||||
nul-idelim.O nul-idelim.E nul-odelim.O nul-odelim.E multichar-od.O \
|
||||
multichar-od.E
|
||||
##test-files-end
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
@@ -34,6 +38,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
|
||||
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
|
||||
CLEANFILES = $(run_gen)
|
||||
|
||||
check: $(maint_gen)
|
||||
|
||||
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
|
||||
rm -f $@ $@t
|
||||
sed -n '1,/^##test-files-begin/p' $< > $@t
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -94,13 +93,17 @@ maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
|
||||
i.X j.I j.X k.I k.X l.I l.X m.I m.X n.I n.X o.I o.X p.I p.X q.I q.X r.I r.X \
|
||||
s.I s.X t.I t.X u.I u.X v.I v.X w.I w.X x.I x.X y.I y.X z.I z.X empty-fl.I \
|
||||
empty-fl.X missing-fl.I missing-fl.X empty-bl.I empty-bl.X missing-bl.I \
|
||||
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X
|
||||
missing-bl.X empty-f1.I empty-f1.X empty-f2.I empty-f2.X o-delim.I o-delim.X \
|
||||
nul-idelim.I nul-idelim.X nul-odelim.I nul-odelim.X multichar-od.I \
|
||||
multichar-od.X
|
||||
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
|
||||
9.E a.O a.E b.O b.E c.O c.E d.O d.E e.O e.E f.O f.E g.O g.E h.O h.E i.O i.E \
|
||||
j.O j.E k.O k.E l.O l.E m.O m.E n.O n.E o.O o.E p.O p.E q.O q.E r.O r.E s.O \
|
||||
s.E t.O t.E u.O u.E v.O v.E w.O w.E x.O x.E y.O y.E z.O z.E empty-fl.O \
|
||||
empty-fl.E missing-fl.O missing-fl.E empty-bl.O empty-bl.E missing-bl.O \
|
||||
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E
|
||||
missing-bl.E empty-f1.O empty-f1.E empty-f2.O empty-f2.E o-delim.O o-delim.E \
|
||||
nul-idelim.O nul-idelim.E nul-odelim.O nul-odelim.E multichar-od.O \
|
||||
multichar-od.E
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
noinst_SCRIPTS = $x-tests
|
||||
@@ -237,6 +240,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
|
||||
mv $@.n $@
|
||||
chmod 755 $@
|
||||
|
||||
check: $(maint_gen)
|
||||
|
||||
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
|
||||
rm -f $@ $@t
|
||||
sed -n '1,/^##test-files-begin/p' $< > $@t
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user