mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
320 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ecb6ace02 | ||
|
|
6d42c7e9d7 | ||
|
|
6684ffa826 | ||
|
|
bfbc3ce20c | ||
|
|
0f5f23cb9e | ||
|
|
93494dde07 | ||
|
|
be3b9520ad | ||
|
|
c2c6f081c5 | ||
|
|
36b10d9f21 | ||
|
|
72c0980585 | ||
|
|
58647fd63d | ||
|
|
6eb5e899e1 | ||
|
|
a01c762a81 | ||
|
|
c29025e6ed | ||
|
|
b3582e7533 | ||
|
|
12f49aa1ae | ||
|
|
f31f7e1c75 | ||
|
|
d34d42ca05 | ||
|
|
6974d67aa2 | ||
|
|
85d9447441 | ||
|
|
45c381f4ba | ||
|
|
184c0062a4 | ||
|
|
7024c7d55c | ||
|
|
d84a21ea2d | ||
|
|
2f6fa9d160 | ||
|
|
4ac374c8e5 | ||
|
|
17070ae7bf | ||
|
|
a1cc8f5961 | ||
|
|
27caa20d7b | ||
|
|
757555a4dc | ||
|
|
ada5e63612 | ||
|
|
a8d20df6b2 | ||
|
|
4a28ea9bd6 | ||
|
|
e4a1ead494 | ||
|
|
ad1a2f76ce | ||
|
|
a7a6111f81 | ||
|
|
7c579a0231 | ||
|
|
6630a24b7a | ||
|
|
6429ffabbb | ||
|
|
e558629ce1 | ||
|
|
fefa8511b8 | ||
|
|
347db9ce77 | ||
|
|
92da57a7be | ||
|
|
4078ae8de8 | ||
|
|
3086193091 | ||
|
|
823425b310 | ||
|
|
e03fc9bc82 | ||
|
|
64379c5cd8 | ||
|
|
d4825df6cf | ||
|
|
cb3b5ed486 | ||
|
|
7ee8ed7e37 | ||
|
|
a991132f3e | ||
|
|
7f0867df00 | ||
|
|
6354d07ea0 | ||
|
|
3216105fbb | ||
|
|
8d5c4784b8 | ||
|
|
ec47f73107 | ||
|
|
94cd0c09f6 | ||
|
|
db3440d444 | ||
|
|
e8bec0725e | ||
|
|
8598c54bb1 | ||
|
|
e457645eac | ||
|
|
a14303dbc9 | ||
|
|
84ad5c47c8 | ||
|
|
998b3a148c | ||
|
|
71ee764f1e | ||
|
|
07a6f7a9e2 | ||
|
|
0f5ca22215 | ||
|
|
fc50286759 | ||
|
|
0a1fd1d2ad | ||
|
|
7a04e95c62 | ||
|
|
938e7fe7ef | ||
|
|
d8ab75cedc | ||
|
|
650b182278 | ||
|
|
f31f7889fb | ||
|
|
b1f2e5a7fd | ||
|
|
34141257cf | ||
|
|
c96ef37ba9 | ||
|
|
ccc65c4a81 | ||
|
|
be5250f0ec | ||
|
|
d1c1677873 | ||
|
|
6eae430477 | ||
|
|
82d361dc53 | ||
|
|
6e05a13259 | ||
|
|
a1413ad1cd | ||
|
|
c9dd33ec3f | ||
|
|
b9a394eec5 | ||
|
|
f315b52ca9 | ||
|
|
26c02dd946 | ||
|
|
a03a97d7d8 | ||
|
|
ead1152ef8 | ||
|
|
2326be84d5 | ||
|
|
7980fa3b78 | ||
|
|
70a8ff09ed | ||
|
|
38a63c863e | ||
|
|
a4fb33a110 | ||
|
|
bd9a38183c | ||
|
|
45d85e3ba2 | ||
|
|
afa328c54e | ||
|
|
c66e967d70 | ||
|
|
ccaf565665 | ||
|
|
b1a82ad6f2 | ||
|
|
c9a2ec01e5 | ||
|
|
f7acc2f589 | ||
|
|
5bf77e1015 | ||
|
|
3aa15eac61 | ||
|
|
5799c6474d | ||
|
|
f8998dae41 | ||
|
|
a7ba2688ca | ||
|
|
6810b30f39 | ||
|
|
f8d66bde6a | ||
|
|
4675b67c10 | ||
|
|
ae3c7c2fb1 | ||
|
|
a3ff199f12 | ||
|
|
61ef81a837 | ||
|
|
dcb8db3c82 | ||
|
|
92b49f0da1 | ||
|
|
f322649c58 | ||
|
|
f49fee3e5f | ||
|
|
6dbc8ff80b | ||
|
|
65978b6328 | ||
|
|
5f8949c46c | ||
|
|
b302e2becc | ||
|
|
5921d6bc50 | ||
|
|
ec76108bb7 | ||
|
|
519365bb08 | ||
|
|
c1fc9dbe64 | ||
|
|
06b4686f8a | ||
|
|
5a244d2598 | ||
|
|
497a1e0c04 | ||
|
|
32ee7fb170 | ||
|
|
db7449461c | ||
|
|
9ed89c9d9c | ||
|
|
6110857115 | ||
|
|
36afcc383a | ||
|
|
9e7ca26738 | ||
|
|
de38f9c61f | ||
|
|
aa14b2d994 | ||
|
|
a6a3dee962 | ||
|
|
0324f8d422 | ||
|
|
5a9c4223f6 | ||
|
|
eeeb6c7b23 | ||
|
|
206e3f08de | ||
|
|
61a80b3a12 | ||
|
|
4da3feb0e9 | ||
|
|
a3d39ceb13 | ||
|
|
b252cc8d6d | ||
|
|
afac7f3a78 | ||
|
|
fae6846955 | ||
|
|
f79e8bdcaf | ||
|
|
ebfdc834f2 | ||
|
|
6e5ac55673 | ||
|
|
43d2406f55 | ||
|
|
29772527c8 | ||
|
|
4e72061130 | ||
|
|
470cfd9491 | ||
|
|
ff9a9a2bdf | ||
|
|
a3db75c4b3 | ||
|
|
46fb234f5f | ||
|
|
1e985af9d7 | ||
|
|
8ef38f80ec | ||
|
|
047f0c2125 | ||
|
|
a10c7fcd7c | ||
|
|
54a0879129 | ||
|
|
494d8173bd | ||
|
|
e8b739e317 | ||
|
|
ef4765e11b | ||
|
|
ca9451a39d | ||
|
|
1349c30df2 | ||
|
|
8659ec88d4 | ||
|
|
e27d21668c | ||
|
|
902598d05d | ||
|
|
fc026cd548 | ||
|
|
7d4a70eaff | ||
|
|
186958482f | ||
|
|
da80ee04d2 | ||
|
|
dd3a865a8e | ||
|
|
aaf66a2413 | ||
|
|
0eba2a8dd7 | ||
|
|
7c04ce1f09 | ||
|
|
7b4833b03c | ||
|
|
3a62f8785f | ||
|
|
85923cb2bc | ||
|
|
bc05ba3d5a | ||
|
|
ea2969da49 | ||
|
|
0966b97bd1 | ||
|
|
8c3fb79a89 | ||
|
|
fc68d2786b | ||
|
|
0d26afa6e0 | ||
|
|
bb964b3eec | ||
|
|
638776e577 | ||
|
|
0881032a16 | ||
|
|
c58c644f8f | ||
|
|
6e602a0232 | ||
|
|
097d40b3d3 | ||
|
|
57258b3446 | ||
|
|
39508b8db3 | ||
|
|
cd4c2d0fdc | ||
|
|
8a0550a816 | ||
|
|
663d8b143c | ||
|
|
2a1a1843b7 | ||
|
|
9c70563ee7 | ||
|
|
37ce5a5497 | ||
|
|
37a3052a36 | ||
|
|
2a4842f7f3 | ||
|
|
d82fadf365 | ||
|
|
ef63ce007d | ||
|
|
6a8e657775 | ||
|
|
309819620b | ||
|
|
f7bb262cc8 | ||
|
|
d5494d57f5 | ||
|
|
14a2593daf | ||
|
|
9cdd2e05e6 | ||
|
|
6cce6a1b7f | ||
|
|
d9f0ca41bd | ||
|
|
df7cef21c7 | ||
|
|
9f2d1beded | ||
|
|
ff59218d54 | ||
|
|
1a18272561 | ||
|
|
2bdf8621d6 | ||
|
|
758ab7a013 | ||
|
|
734d1cccc3 | ||
|
|
13de1036ac | ||
|
|
2167febcb1 | ||
|
|
2c11b736aa | ||
|
|
a52e0efbe2 | ||
|
|
4935348b67 | ||
|
|
e6a0306b1b | ||
|
|
2bec121abb | ||
|
|
412043f1d8 | ||
|
|
4ffa362cc4 | ||
|
|
35592ba64c | ||
|
|
c1618a8c4c | ||
|
|
96be8bca99 | ||
|
|
b8a16a3f2a | ||
|
|
f1217e4976 | ||
|
|
62279c6e2d | ||
|
|
71545a6276 | ||
|
|
53cfcbd19c | ||
|
|
5618133eed | ||
|
|
ade1f58e11 | ||
|
|
74cf3e8bab | ||
|
|
ca50e875af | ||
|
|
a75ea1014e | ||
|
|
98af2e9636 | ||
|
|
68e5877403 | ||
|
|
2b906615c2 | ||
|
|
443f852f61 | ||
|
|
d1f4e617b5 | ||
|
|
1aa070dd2e | ||
|
|
007e81132a | ||
|
|
6bcfff640e | ||
|
|
aa2880362c | ||
|
|
88bd90109b | ||
|
|
dba300a0d0 | ||
|
|
b9ed71e46e | ||
|
|
7bba3e945f | ||
|
|
1bdfcabd2c | ||
|
|
c88a4c91da | ||
|
|
136f2fd28c | ||
|
|
82739833a1 | ||
|
|
1c5c2597b5 | ||
|
|
eacbf12ea4 | ||
|
|
0ccdf3419d | ||
|
|
cec85a4b3a | ||
|
|
a077a7833c | ||
|
|
a3094b0529 | ||
|
|
d73dd15544 | ||
|
|
27c1ad9576 | ||
|
|
2eefbf7647 | ||
|
|
79d39ab7bf | ||
|
|
12782f54b0 | ||
|
|
fff6de7b04 | ||
|
|
cc76db2016 | ||
|
|
77c94909cf | ||
|
|
3b8d19272d | ||
|
|
6099914170 | ||
|
|
09d96ac539 | ||
|
|
3edbca0e04 | ||
|
|
c062a35803 | ||
|
|
3da029a5d9 | ||
|
|
de1dabf7d7 | ||
|
|
03283b5000 | ||
|
|
9f5dc7e7d0 | ||
|
|
ab9cd27938 | ||
|
|
c767a49741 | ||
|
|
0fdd1b9130 | ||
|
|
f19ca6fe29 | ||
|
|
6cc3cf776c | ||
|
|
e162abfc5b | ||
|
|
866773c72a | ||
|
|
06bab849fc | ||
|
|
ed0becde29 | ||
|
|
8d64a37a77 | ||
|
|
0520188821 | ||
|
|
05d9a7233b | ||
|
|
f664e44a2f | ||
|
|
5705eaaee2 | ||
|
|
0e69432852 | ||
|
|
2d69426882 | ||
|
|
5d4f8ebdfd | ||
|
|
b246280c27 | ||
|
|
60e021ee4e | ||
|
|
63c0f480ad | ||
|
|
e375f4e9c8 | ||
|
|
109b9c5f94 | ||
|
|
126c1a40e5 | ||
|
|
2440fd8bac | ||
|
|
98b9c4bed7 | ||
|
|
40f708f534 | ||
|
|
ebc5dc0b0c | ||
|
|
e0ed4e6a77 | ||
|
|
c24393e0fd | ||
|
|
e15db4ca81 | ||
|
|
1059e96721 | ||
|
|
234ea05171 | ||
|
|
0fa007e352 | ||
|
|
9e6b379dbf | ||
|
|
d46bab3a59 | ||
|
|
541699c01c |
7
GNUmakefile
Normal file
7
GNUmakefile
Normal file
@@ -0,0 +1,7 @@
|
||||
# Having a separate GNUmakefile lets me `include' the dynamically
|
||||
# generated rules created via Makefile.maint as well as Makefile.maint itself.
|
||||
# This makefile is used only if you run GNU Make.
|
||||
# It is necessary if you modify files in the m4/ directory or
|
||||
# want to build targets usually of interest only to the maintainer.
|
||||
include Makefile
|
||||
include $(srcdir)/Makefile.maint
|
||||
62
Makefile.maint
Normal file
62
Makefile.maint
Normal file
@@ -0,0 +1,62 @@
|
||||
# -*-Makefile-*-
|
||||
# This Makefile fragment is shared between fileutils, sh-utils, textutils.
|
||||
|
||||
maintainer-check:
|
||||
if head ChangeLog| grep 'Version $(VERSION)' > /dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "$(VERSION) not in ChangeLog; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) my-distcheck
|
||||
|
||||
# Tag before making distribution. Also, don't make a distribution if
|
||||
# checks fail. Also, make sure the NEWS file is up-to-date.
|
||||
cvs-dist: maintainer-check
|
||||
pkg=`echo "$(PACKAGE)" | tr a-z A-Z`; \
|
||||
ver=`echo "$(VERSION)" | sed 's/\./_/g'`; \
|
||||
tag="$$pkg-$$ver"; \
|
||||
echo tag=$$tag; \
|
||||
if cvs -n log -h README| grep -e $$tag > /dev/null; then \
|
||||
echo "VERSION not new; not tagging" 1>&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
cvs update po; \
|
||||
cvs tag -c $$tag
|
||||
$(MAKE) dist
|
||||
|
||||
t=./=test
|
||||
my-distcheck: dist
|
||||
-rm -rf $(t)
|
||||
mkdir $(t)
|
||||
GZIP=$(GZIP) $(TAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-gettext \
|
||||
&& $(MAKE) \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& $(MAKE) distclean
|
||||
cd $(t) && $(TAR) --diff -z -f ../$(distdir).tar.gz
|
||||
-rm -rf $(t)
|
||||
@echo "========================"; \
|
||||
echo "$(distdir).tar.gz is ready for distribution"; \
|
||||
echo "========================"
|
||||
|
||||
acdir = m4
|
||||
aclocal-files: configure.in m4/Makefile.am
|
||||
echo "acfiles = \\" > $@-tmp
|
||||
(cd $(srcdir) && find $(acdir) -type f -name '*.m4' -print) \
|
||||
| sed 's!^!$(top_srcdir)/!' \
|
||||
| tr '\012' ' ' \
|
||||
| fmt \
|
||||
| sed -e 's/$$/ \\/' -e '$$s/..$$//' \
|
||||
>> $@-tmp
|
||||
echo >> $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
-include aclocal-files
|
||||
|
||||
# Override default rule to use --acdir option
|
||||
$(srcdir)/aclocal.m4: configure.in $(acfiles)
|
||||
cd $(srcdir) && aclocal -I $(acdir)
|
||||
6
THANKS
6
THANKS
@@ -6,9 +6,12 @@ Andreas Schwab: schwab@issan.informatik.uni-dortmund.de
|
||||
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
|
||||
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
|
||||
Greg McGary: gkm@eng.ascend.com
|
||||
Hugh Daniel: hugh@xanadu.com
|
||||
@@ -17,6 +20,7 @@ James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
Jesse Thilo: jgt2@eecs.lehigh.edu
|
||||
Joakim Rosqvist: dvljrt@cs.umu.se
|
||||
John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th
|
||||
Kjetil Torgrim Homme: kjetilho@ifi.uio.no
|
||||
Marcus Daniels: marcus@sysc.pdx.edu
|
||||
Mark A. Thomas: thommark@access.digex.net
|
||||
Mark Harris: mark@monitor.designacc.com
|
||||
@@ -27,6 +31,7 @@ Miles Bader: miles@gnu.ai.mit.edu
|
||||
Noel Cragg: noel@red-bean.com
|
||||
Peter Eriksson: peter@ifm.liu.se
|
||||
Paul Eggert: eggert@twinsun.com
|
||||
Philippe De Muyter: phdm@macqel.be
|
||||
Ross Ridge: rridge@calum.csclub.uwaterloo.ca
|
||||
Santiago Vila Doncel: sanvila@unex.es
|
||||
Stuart Kemp: skemp@peter.bmc.com
|
||||
@@ -35,4 +40,3 @@ Torbjorn Lindgren: tl@funcom.no
|
||||
Tony Leneis: tony@plaza.ds.adp.com
|
||||
Michael Veksler: mveksler@techunix.technion.ac.il
|
||||
Wayne Stewart: wstewa@atl.com
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile.in generated automatically by automake 1.2d from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.2f from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
# 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.
|
||||
@@ -71,7 +71,6 @@ INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
MVDIR_PROG = @MVDIR_PROG@
|
||||
@@ -115,8 +114,8 @@ GZIP = --best
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .dvi .info .ps .texi .texinfo
|
||||
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
.SUFFIXES: .dvi .info .ps .texi .texinfo .txi
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnits doc/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
@@ -124,7 +123,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
version.texi: @MAINT@stamp-vti
|
||||
version.texi: stamp-vti
|
||||
cp $(srcdir)/stamp-vti $(srcdir)/version.texi
|
||||
|
||||
stamp-vti: fileutils.texi $(top_srcdir)/configure.in
|
||||
@@ -145,7 +144,7 @@ clean-vti:
|
||||
distclean-vti:
|
||||
|
||||
maintainer-clean-vti:
|
||||
-@MAINT@rm -f stamp-vti version.texi
|
||||
-rm -f stamp-vti version.texi
|
||||
|
||||
fileutils.info: fileutils.texi version.texi
|
||||
fileutils.dvi: fileutils.texi version.texi
|
||||
@@ -180,6 +179,20 @@ DVIPS = dvips
|
||||
.texinfo.dvi:
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.txi.dvi:
|
||||
TEXINPUTS=$(srcdir):$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
.dvi.ps:
|
||||
$(DVIPS) $< -o $@
|
||||
|
||||
@@ -212,7 +225,7 @@ uninstall-info:
|
||||
test -z "$ii" \
|
||||
|| install-info --info-dir=$(infodir) --remove $$file; \
|
||||
done
|
||||
$(NORMAL_UNINSTALL)
|
||||
@$(NORMAL_UNINSTALL)
|
||||
for file in $(INFO_DEPS); do \
|
||||
(cd $(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
|
||||
done
|
||||
|
||||
@@ -166,7 +166,7 @@ The GNU shell utilities are mostly compatible with the POSIX.2 standard.
|
||||
@c This paragraph appears in all of fileutils.texi, textutils.texi, and
|
||||
@c sh-utils.texi too -- so be sure to keep them consistent.
|
||||
@cindex bugs, reporting
|
||||
Please report bugs to @samp{sh-utils-bugs@@gnu.ai.mit.edu}. Remember
|
||||
Please report bugs to @samp{sh-utils-bugs@@gnu.org}. Remember
|
||||
to include the version number, machine architecture, input files, and
|
||||
any other information needed to reproduce the bug: your input, what you
|
||||
expected, what you got, and why it is wrong. Diffs are welcome, but
|
||||
|
||||
@@ -142,7 +142,7 @@ The GNU text utilities are mostly compatible with the @sc{POSIX.2} standard.
|
||||
@c This paragraph appears in all of fileutils.texi, textutils.texi, and
|
||||
@c sh-utils.texi too -- so be sure to keep them consistent.
|
||||
@cindex bugs, reporting
|
||||
Please report bugs to @samp{textutils-bugs@@gnu.ai.mit.edu}. Remember
|
||||
Please report bugs to @samp{textutils-bugs@@gnu.org}. Remember
|
||||
to include the version number, machine architecture, input files, and
|
||||
any other information needed to reproduce the bug: your input, what you
|
||||
expected, what you got, and why it is wrong. Diffs are welcome, but
|
||||
|
||||
@@ -10,18 +10,20 @@ EXTRA_DIST = chown.c getgroups.c getline.c lstat.c malloc.c mktime.c \
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.c \
|
||||
addext.c argmatch.c backupfile.c basename.c dirname.c exclude.c filemode.c \
|
||||
addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
|
||||
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h error.h exclude.h fnmatch.h fsusage.h \
|
||||
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 \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
quotearg.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
|
||||
198
lib/Makefile.in
198
lib/Makefile.in
@@ -1,6 +1,6 @@
|
||||
# Makefile.in generated automatically by automake 1.2d from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.2f from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
# 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.
|
||||
@@ -71,7 +71,6 @@ INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
@@ -98,19 +97,21 @@ EXTRA_DIST = chown.c getgroups.c getline.c lstat.c malloc.c mktime.c \
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.c \
|
||||
addext.c argmatch.c backupfile.c basename.c dirname.c exclude.c filemode.c \
|
||||
addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
|
||||
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h error.h exclude.h fnmatch.h fsusage.h \
|
||||
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 \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
quotearg.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
@@ -125,11 +126,12 @@ LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
ANSI2KNR = ../src/ansi2knr
|
||||
libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
|
||||
addext$U.o argmatch$U.o backupfile$U.o basename$U.o dirname$U.o \
|
||||
exclude$U.o filemode$U.o full-write$U.o human$U.o idcache$U.o isdir$U.o \
|
||||
long-options$U.o makepath$U.o modechange$U.o hash$U.o path-concat$U.o \
|
||||
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
|
||||
addext$U.o argmatch$U.o backupfile$U.o basename$U.o closeout$U.o \
|
||||
dirname$U.o exclude$U.o filemode$U.o full-write$U.o human$U.o \
|
||||
idcache$U.o isdir$U.o long-options$U.o makepath$U.o modechange$U.o \
|
||||
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
|
||||
savedir$U.o stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o \
|
||||
xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
|
||||
AR = ar
|
||||
YLWRAP = $(srcdir)/ylwrap
|
||||
CFLAGS = @CFLAGS@
|
||||
@@ -151,31 +153,31 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
TAR = tar
|
||||
GZIP = --best
|
||||
DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
|
||||
.deps/backupfile.P .deps/basename.P .deps/chown.P .deps/dirname.P \
|
||||
.deps/error.P .deps/euidaccess.P .deps/exclude.P .deps/fileblocks.P \
|
||||
.deps/filemode.P .deps/fnmatch.P .deps/fsusage.P .deps/ftruncate.P \
|
||||
.deps/full-write.P .deps/getdate.P .deps/getgroups.P .deps/getline.P \
|
||||
.deps/getopt.P .deps/getopt1.P .deps/group-member.P .deps/hash.P \
|
||||
.deps/human.P .deps/idcache.P .deps/isdir.P .deps/long-options.P \
|
||||
.deps/lstat.P .deps/makepath.P .deps/malloc.P .deps/memcmp.P \
|
||||
.deps/memcpy.P .deps/memset.P .deps/mkdir.P .deps/mktime.P \
|
||||
.deps/modechange.P .deps/mountlist.P .deps/obstack.P \
|
||||
.deps/path-concat.P .deps/posixtm.P .deps/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/backupfile.P .deps/basename.P .deps/chown.P .deps/closeout.P \
|
||||
.deps/dirname.P .deps/error.P .deps/euidaccess.P .deps/exclude.P \
|
||||
.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/fsusage.P \
|
||||
.deps/ftruncate.P .deps/full-write.P .deps/getdate .deps/getdate.P \
|
||||
.deps/getgroups.P .deps/getline.P .deps/getopt.P .deps/getopt1.P \
|
||||
.deps/group-member.P .deps/hash.P .deps/human.P .deps/idcache.P \
|
||||
.deps/isdir.P .deps/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
|
||||
SOURCES = $(libfu_a_SOURCES)
|
||||
OBJECTS = $(libfu_a_OBJECTS)
|
||||
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .h .o .s .y
|
||||
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
.SUFFIXES: .S .c .o .s .y
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
@@ -192,9 +194,6 @@ distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
@@ -202,7 +201,7 @@ maintainer-clean-noinstLIBRARIES:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
@@ -229,30 +228,55 @@ libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
|
||||
$(RANLIB) libfu.a
|
||||
.y.c:
|
||||
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
|
||||
.y.h:
|
||||
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
|
||||
posixtm.h: posixtm.c
|
||||
getdate.h: getdate.c
|
||||
|
||||
addext_.c: addext.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/addext.c; then echo $(srcdir)/addext.c; else echo addext.c; fi` addext_.c
|
||||
alloca_.c: alloca.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/alloca.c; then echo $(srcdir)/alloca.c; else echo alloca.c; fi` alloca_.c
|
||||
argmatch_.c: argmatch.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/argmatch.c; then echo $(srcdir)/argmatch.c; else echo argmatch.c; fi` argmatch_.c
|
||||
backupfile_.c: backupfile.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/backupfile.c; then echo $(srcdir)/backupfile.c; else echo backupfile.c; fi` backupfile_.c
|
||||
basename_.c: basename.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/basename.c; then echo $(srcdir)/basename.c; else echo basename.c; fi` basename_.c
|
||||
chown_.c: chown.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/chown.c; then echo $(srcdir)/chown.c; else echo chown.c; fi` chown_.c
|
||||
closeout_.c: closeout.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/closeout.c; then echo $(srcdir)/closeout.c; else echo closeout.c; fi` closeout_.c
|
||||
dirname_.c: dirname.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/dirname.c; then echo $(srcdir)/dirname.c; else echo dirname.c; fi` dirname_.c
|
||||
error_.c: error.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/error.c; then echo $(srcdir)/error.c; else echo error.c; fi` error_.c
|
||||
euidaccess_.c: euidaccess.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/euidaccess.c; then echo $(srcdir)/euidaccess.c; else echo euidaccess.c; fi` euidaccess_.c
|
||||
exclude_.c: exclude.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/exclude.c; then echo $(srcdir)/exclude.c; else echo exclude.c; fi` exclude_.c
|
||||
fileblocks_.c: fileblocks.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/fileblocks.c; then echo $(srcdir)/fileblocks.c; else echo fileblocks.c; fi` fileblocks_.c
|
||||
filemode_.c: filemode.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/filemode.c; then echo $(srcdir)/filemode.c; else echo filemode.c; fi` filemode_.c
|
||||
fnmatch_.c: fnmatch.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/fnmatch.c; then echo $(srcdir)/fnmatch.c; else echo fnmatch.c; fi` fnmatch_.c
|
||||
fsusage_.c: fsusage.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/fsusage.c; then echo $(srcdir)/fsusage.c; else echo fsusage.c; fi` fsusage_.c
|
||||
ftruncate_.c: ftruncate.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/ftruncate.c; then echo $(srcdir)/ftruncate.c; else echo ftruncate.c; fi` ftruncate_.c
|
||||
full-write_.c: full-write.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/full-write.c; then echo $(srcdir)/full-write.c; else echo full-write.c; fi` full-write_.c
|
||||
getdate_.c: getdate.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/getdate.c; then echo $(srcdir)/getdate.c; else echo getdate.c; fi` getdate_.c
|
||||
getgroups_.c: getgroups.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/getgroups.c; then echo $(srcdir)/getgroups.c; else echo getgroups.c; fi` getgroups_.c
|
||||
getline_.c: getline.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/getline.c; then echo $(srcdir)/getline.c; else echo getline.c; fi` getline_.c
|
||||
getopt_.c: getopt.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/getopt.c; then echo $(srcdir)/getopt.c; else echo getopt.c; fi` getopt_.c
|
||||
getopt1_.c: getopt1.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/getopt1.c; then echo $(srcdir)/getopt1.c; else echo getopt1.c; fi` getopt1_.c
|
||||
group-member_.c: group-member.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/group-member.c; then echo $(srcdir)/group-member.c; else echo group-member.c; fi` group-member_.c
|
||||
hash_.c: hash.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/hash.c; then echo $(srcdir)/hash.c; else echo hash.c; fi` hash_.c
|
||||
human_.c: human.c $(ANSI2KNR)
|
||||
@@ -263,22 +287,74 @@ isdir_.c: isdir.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/isdir.c; then echo $(srcdir)/isdir.c; else echo isdir.c; fi` isdir_.c
|
||||
long-options_.c: long-options.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/long-options.c; then echo $(srcdir)/long-options.c; else echo long-options.c; fi` long-options_.c
|
||||
lstat_.c: lstat.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/lstat.c; then echo $(srcdir)/lstat.c; else echo lstat.c; fi` lstat_.c
|
||||
makepath_.c: makepath.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/makepath.c; then echo $(srcdir)/makepath.c; else echo makepath.c; fi` makepath_.c
|
||||
malloc_.c: malloc.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/malloc.c; then echo $(srcdir)/malloc.c; else echo malloc.c; fi` malloc_.c
|
||||
memcmp_.c: memcmp.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/memcmp.c; then echo $(srcdir)/memcmp.c; else echo memcmp.c; fi` memcmp_.c
|
||||
memcpy_.c: memcpy.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/memcpy.c; then echo $(srcdir)/memcpy.c; else echo memcpy.c; fi` memcpy_.c
|
||||
memset_.c: memset.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/memset.c; then echo $(srcdir)/memset.c; else echo memset.c; fi` memset_.c
|
||||
mkdir_.c: mkdir.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/mkdir.c; then echo $(srcdir)/mkdir.c; else echo mkdir.c; fi` mkdir_.c
|
||||
mktime_.c: mktime.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/mktime.c; then echo $(srcdir)/mktime.c; else echo mktime.c; fi` mktime_.c
|
||||
modechange_.c: modechange.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/modechange.c; then echo $(srcdir)/modechange.c; else echo modechange.c; fi` modechange_.c
|
||||
mountlist_.c: mountlist.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/mountlist.c; then echo $(srcdir)/mountlist.c; else echo mountlist.c; fi` mountlist_.c
|
||||
obstack_.c: obstack.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/obstack.c; then echo $(srcdir)/obstack.c; else echo obstack.c; fi` obstack_.c
|
||||
path-concat_.c: path-concat.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/path-concat.c; then echo $(srcdir)/path-concat.c; else echo path-concat.c; fi` path-concat_.c
|
||||
posixtm_.c: posixtm.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/posixtm.c; then echo $(srcdir)/posixtm.c; else echo posixtm.c; fi` posixtm_.c
|
||||
quotearg_.c: quotearg.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/quotearg.c; then echo $(srcdir)/quotearg.c; else echo quotearg.c; fi` quotearg_.c
|
||||
realloc_.c: realloc.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/realloc.c; then echo $(srcdir)/realloc.c; else echo realloc.c; fi` realloc_.c
|
||||
regex_.c: regex.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/regex.c; then echo $(srcdir)/regex.c; else echo regex.c; fi` regex_.c
|
||||
rename_.c: rename.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/rename.c; then echo $(srcdir)/rename.c; else echo rename.c; fi` rename_.c
|
||||
rmdir_.c: rmdir.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/rmdir.c; then echo $(srcdir)/rmdir.c; else echo rmdir.c; fi` rmdir_.c
|
||||
rpmatch_.c: rpmatch.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/rpmatch.c; then echo $(srcdir)/rpmatch.c; else echo rpmatch.c; fi` rpmatch_.c
|
||||
rx_.c: rx.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/rx.c; then echo $(srcdir)/rx.c; else echo rx.c; fi` rx_.c
|
||||
safe-read_.c: safe-read.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/safe-read.c; then echo $(srcdir)/safe-read.c; else echo safe-read.c; fi` safe-read_.c
|
||||
save-cwd_.c: save-cwd.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/save-cwd.c; then echo $(srcdir)/save-cwd.c; else echo save-cwd.c; fi` save-cwd_.c
|
||||
savedir_.c: savedir.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/savedir.c; then echo $(srcdir)/savedir.c; else echo savedir.c; fi` savedir_.c
|
||||
stat_.c: stat.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/stat.c; then echo $(srcdir)/stat.c; else echo stat.c; fi` stat_.c
|
||||
stpcpy_.c: stpcpy.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/stpcpy.c; then echo $(srcdir)/stpcpy.c; else echo stpcpy.c; fi` stpcpy_.c
|
||||
strcasecmp_.c: strcasecmp.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strcasecmp.c; then echo $(srcdir)/strcasecmp.c; else echo strcasecmp.c; fi` strcasecmp_.c
|
||||
strdup_.c: strdup.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strdup.c; then echo $(srcdir)/strdup.c; else echo strdup.c; fi` strdup_.c
|
||||
strftime_.c: strftime.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strftime.c; then echo $(srcdir)/strftime.c; else echo strftime.c; fi` strftime_.c
|
||||
stripslash_.c: stripslash.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/stripslash.c; then echo $(srcdir)/stripslash.c; else echo stripslash.c; fi` stripslash_.c
|
||||
strndup_.c: strndup.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strndup.c; then echo $(srcdir)/strndup.c; else echo strndup.c; fi` strndup_.c
|
||||
strstr_.c: strstr.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strstr.c; then echo $(srcdir)/strstr.c; else echo strstr.c; fi` strstr_.c
|
||||
strtol_.c: strtol.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strtol.c; then echo $(srcdir)/strtol.c; else echo strtol.c; fi` strtol_.c
|
||||
strtoul_.c: strtoul.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strtoul.c; then echo $(srcdir)/strtoul.c; else echo strtoul.c; fi` strtoul_.c
|
||||
strverscmp_.c: strverscmp.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/strverscmp.c; then echo $(srcdir)/strverscmp.c; else echo strverscmp.c; fi` strverscmp_.c
|
||||
userspec_.c: userspec.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/userspec.c; then echo $(srcdir)/userspec.c; else echo userspec.c; fi` userspec_.c
|
||||
xgetcwd_.c: xgetcwd.c $(ANSI2KNR)
|
||||
@@ -293,12 +369,18 @@ xstrtoul_.c: xstrtoul.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/xstrtoul.c; then echo $(srcdir)/xstrtoul.c; else echo xstrtoul.c; fi` xstrtoul_.c
|
||||
yesno_.c: yesno.c $(ANSI2KNR)
|
||||
$(ANSI2KNR) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` yesno_.c
|
||||
addext_.o argmatch_.o backupfile_.o basename_.o dirname_.o exclude_.o \
|
||||
filemode_.o full-write_.o getdate_.o getopt_.o getopt1_.o hash_.o \
|
||||
human_.o idcache_.o isdir_.o long-options_.o makepath_.o modechange_.o \
|
||||
path-concat_.o posixtm_.o safe-read_.o save-cwd_.o savedir_.o \
|
||||
stripslash_.o userspec_.o xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o \
|
||||
xstrtoul_.o yesno_.o : $(ANSI2KNR)
|
||||
addext_.o alloca_.o argmatch_.o backupfile_.o basename_.o chown_.o \
|
||||
closeout_.o dirname_.o error_.o euidaccess_.o exclude_.o fileblocks_.o \
|
||||
filemode_.o fnmatch_.o fsusage_.o ftruncate_.o full-write_.o getdate_.o \
|
||||
getgroups_.o getline_.o getopt_.o getopt1_.o group-member_.o hash_.o \
|
||||
human_.o idcache_.o isdir_.o 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 \
|
||||
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)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
@@ -309,8 +391,12 @@ ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) $(LISP) -o $$here/TAGS)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
@@ -338,14 +424,9 @@ distdir: $(DISTFILES)
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done
|
||||
|
||||
MKDEP = $(CC) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
-include .deps/.P
|
||||
.deps/.P: $(BUILT_SOURCES)
|
||||
echo > $@
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
@@ -356,13 +437,16 @@ distclean-depend:
|
||||
maintainer-clean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
.deps/%.P: %.c
|
||||
@echo "Computing dependencies for $<..."
|
||||
@o='o'; \
|
||||
test -n "$o" && o='$$o'; \
|
||||
$(MKDEP) $< >$@.tmp \
|
||||
&& sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," < $@.tmp > $@ \
|
||||
&& rm -f $@.tmp
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).P -c $<
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
|
||||
< .deps/$(*F).p > .deps/$(*F).P
|
||||
@-rm -f .deps/$(*F).p
|
||||
info:
|
||||
dvi:
|
||||
check: all
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
Copyright (C) 1990,1991,1992,1993,1995,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-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
|
||||
@@ -74,7 +74,7 @@ char *malloc ();
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
/* Upper bound on the string length of an integer converted to string.
|
||||
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
|
||||
@@ -97,15 +97,12 @@ char *malloc ();
|
||||
# define REAL_DIR_ENTRY(dp) 1
|
||||
#endif
|
||||
|
||||
/* Which type of backup file names are generated. */
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
/* The extension added to file names to produce a simple (as opposed
|
||||
to numbered) backup file name. */
|
||||
const char *simple_backup_suffix = ".orig";
|
||||
const char *simple_backup_suffix = "~";
|
||||
|
||||
static int max_backup_version __BACKUPFILE_P ((const char *, const char *));
|
||||
static int version_number __BACKUPFILE_P ((const char *, const char *, size_t));
|
||||
static int max_backup_version PARAMS ((const char *, const char *));
|
||||
static int version_number PARAMS ((const char *, const char *, size_t));
|
||||
|
||||
/* Return the name of the new backup file for file FILE,
|
||||
allocated with malloc. Return 0 if out of memory.
|
||||
@@ -113,8 +110,7 @@ static int version_number __BACKUPFILE_P ((const char *, const char *, size_t));
|
||||
Do not call this function if backup_type == none. */
|
||||
|
||||
char *
|
||||
find_backup_file_name (file)
|
||||
const char *file;
|
||||
find_backup_file_name (const char *file, enum backup_type backup_type)
|
||||
{
|
||||
size_t backup_suffix_size_max;
|
||||
size_t file_len = strlen (file);
|
||||
@@ -163,9 +159,7 @@ find_backup_file_name (file)
|
||||
*/
|
||||
|
||||
static int
|
||||
max_backup_version (file, dir)
|
||||
const char *file;
|
||||
const char *dir;
|
||||
max_backup_version (const char *file, const char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
@@ -199,10 +193,7 @@ max_backup_version (file, dir)
|
||||
*/
|
||||
|
||||
static int
|
||||
version_number (base, backup, base_length)
|
||||
const char *base;
|
||||
const char *backup;
|
||||
size_t base_length;
|
||||
version_number (const char *base, const char *backup, size_t base_length)
|
||||
{
|
||||
int version;
|
||||
const char *p;
|
||||
@@ -235,8 +226,7 @@ static const enum backup_type backup_types[] =
|
||||
Unique abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
get_version (version)
|
||||
const char *version;
|
||||
get_version (const char *version)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1991, 1992, 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
|
||||
@@ -33,18 +33,23 @@ enum backup_type
|
||||
numbered
|
||||
};
|
||||
|
||||
extern enum backup_type backup_type;
|
||||
#define VALID_BACKUP_TYPE(Type) \
|
||||
((Type) == none \
|
||||
|| (Type) == simple \
|
||||
|| (Type) == numbered_existing \
|
||||
|| (Type) == numbered)
|
||||
|
||||
extern char const *simple_backup_suffix;
|
||||
|
||||
#ifndef __BACKUPFILE_P
|
||||
# if defined __STDC__ || __GNUC__
|
||||
# define __BACKUPFILE_P(args) args
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define __BACKUPFILE_P(args) ()
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char *base_name __BACKUPFILE_P ((char const *));
|
||||
char *find_backup_file_name __BACKUPFILE_P ((char const *));
|
||||
enum backup_type get_version __BACKUPFILE_P ((char const *));
|
||||
void addext __BACKUPFILE_P ((char *, char const *, int));
|
||||
char *base_name PARAMS ((char const *));
|
||||
char *find_backup_file_name PARAMS ((char const *, enum backup_type));
|
||||
enum backup_type get_version PARAMS ((char const *));
|
||||
void addext PARAMS ((char *, char const *, int));
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
/* basename.c -- return the last element in a path */
|
||||
/* basename.c -- return the last element in a path
|
||||
Copyright (C) 1990, 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. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(f) 0
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(c) ((c) == '/')
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
@@ -17,8 +32,7 @@
|
||||
In some environments the builtin `basename' modifies its argument. */
|
||||
|
||||
char *
|
||||
base_name (name)
|
||||
char const *name;
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
60
lib/closeout.c
Normal file
60
lib/closeout.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/* closeout.c - close standard output
|
||||
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. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Close standard output, exiting with status STATUS on failure. */
|
||||
void
|
||||
close_stdout_status (int status)
|
||||
{
|
||||
if (ferror (stdout))
|
||||
error (status, 0, _("write error"));
|
||||
if (fclose (stdout) != 0)
|
||||
error (status, errno, _("write error"));
|
||||
}
|
||||
|
||||
/* Close standard output, exiting with status EXIT_FAILURE on failure. */
|
||||
void
|
||||
close_stdout (void)
|
||||
{
|
||||
close_stdout_status (EXIT_FAILURE);
|
||||
}
|
||||
10
lib/closeout.h
Normal file
10
lib/closeout.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void close_stdout PARAMS ((void));
|
||||
void close_stdout_status PARAMS ((int status));
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dirname.c -- return all but the last element in a path
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -15,22 +15,22 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#if defined STDC_HEADERS || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#ifndef strrchr
|
||||
#define strrchr rindex
|
||||
#endif
|
||||
# include <strings.h>
|
||||
# ifndef strrchr
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
|
||||
78
lib/error.c
78
lib/error.c
@@ -1,10 +1,14 @@
|
||||
/* error.c -- error handler for noninteractive utilities
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is 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
|
||||
@@ -12,13 +16,14 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -43,12 +48,11 @@
|
||||
void exit ();
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
#include "error.h"
|
||||
|
||||
/* Get prototypes for the functions defined here. */
|
||||
#include <error.h>
|
||||
#ifndef _
|
||||
#define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
@@ -65,15 +69,21 @@ unsigned int error_message_count;
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
#define program_name program_invocation_name
|
||||
#include <errno.h>
|
||||
|
||||
#else /* not _LIBC */
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
#define error __error
|
||||
#define error_at_line __error_at_line
|
||||
|
||||
#else
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
#ifndef HAVE_STRERROR_R
|
||||
# if HAVE_STRERROR
|
||||
# ifndef strerror /* On some systems, strerror is a macro */
|
||||
char *strerror ();
|
||||
@@ -87,13 +97,13 @@ private_strerror (errnum)
|
||||
extern int sys_nerr;
|
||||
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return sys_errlist[errnum];
|
||||
return _(sys_errlist[errnum]);
|
||||
return _("Unknown system error");
|
||||
}
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
|
||||
#endif /* not _LIBC */
|
||||
#endif /* HAVE_STRERROR_R */
|
||||
#endif /* _LIBC */
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
@@ -138,7 +148,14 @@ error (status, errnum, message, va_alist)
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
{
|
||||
#if defined HAVE_STRERROR_R || defined _LIBC
|
||||
char errbuf[1024];
|
||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
||||
#else
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
#endif
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
@@ -206,9 +223,24 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
{
|
||||
#if defined HAVE_STRERROR_R || defined _LIBC
|
||||
char errbuf[1024];
|
||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
||||
#else
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
#endif
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
#undef error
|
||||
#undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
||||
|
||||
57
lib/error.h
57
lib/error.h
@@ -1,10 +1,14 @@
|
||||
/* error.h -- declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -12,26 +16,31 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef ERROR_H_
|
||||
# define ERROR_H_
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
# ifndef __attribute__
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if defined (__STDC__) && __STDC__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
@@ -49,11 +58,11 @@ extern void error_at_line (int status, int errnum, const char *fname,
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
# else
|
||||
#else
|
||||
void error ();
|
||||
void error_at_line ();
|
||||
extern void (*error_print_progname) ();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
@@ -62,4 +71,8 @@ extern unsigned int error_message_count;
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#endif /* not ERROR_H_ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
||||
|
||||
@@ -21,7 +21,7 @@ Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/* Written by David MacKenzie and Torbjorn Granlund.
|
||||
Adapted for GNU C library by Roland McGrath. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -111,7 +111,7 @@ static gid_t egid;
|
||||
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
|
||||
static int have_ids = 0;
|
||||
|
||||
# ifdef HAVE_GETGROUPS
|
||||
# if HAVE_GETGROUPS
|
||||
int group_member ();
|
||||
# else
|
||||
# define group_member(gid) 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Convert file size to number of blocks on System V-like machines.
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -17,22 +17,31 @@
|
||||
|
||||
/* Written by Brian L. Matthews, blm@6sceng.UUCP. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_ST_BLOCKS && !defined _POSIX_SOURCE && defined BSIZE
|
||||
# include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_ST_BLOCKS && !defined _POSIX_SOURCE && defined BSIZE
|
||||
|
||||
# if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
|
||||
# ifndef NINDIR
|
||||
|
||||
# if defined (__DJGPP__)
|
||||
typedef long daddr_t; /* for disk address */
|
||||
# endif
|
||||
|
||||
/* Some SysV's, like Irix, seem to lack this. Hope it's correct. */
|
||||
/* Number of inode pointers per indirect block. */
|
||||
# define NINDIR (BSIZE/sizeof(daddr_t))
|
||||
# define NINDIR (BSIZE / sizeof (daddr_t))
|
||||
# endif /* !NINDIR */
|
||||
|
||||
/* Number of direct block addresses in an inode. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* filemode.c -- make a string describing file modes
|
||||
Copyright (C) 1985, 1990, 1993 Free Software Foundation, Inc.
|
||||
Copyright (C) 1985, 1990, 1993, 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
|
||||
@@ -15,8 +15,8 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -47,45 +47,45 @@
|
||||
#endif
|
||||
|
||||
#ifdef STAT_MACROS_BROKEN
|
||||
#undef S_ISBLK
|
||||
#undef S_ISCHR
|
||||
#undef S_ISDIR
|
||||
#undef S_ISFIFO
|
||||
#undef S_ISLNK
|
||||
#undef S_ISMPB
|
||||
#undef S_ISMPC
|
||||
#undef S_ISNWK
|
||||
#undef S_ISREG
|
||||
#undef S_ISSOCK
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISLNK
|
||||
# undef S_ISMPB
|
||||
# undef S_ISMPC
|
||||
# undef S_ISNWK
|
||||
# undef S_ISREG
|
||||
# undef S_ISSOCK
|
||||
#endif /* STAT_MACROS_BROKEN. */
|
||||
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#endif
|
||||
#if !defined(S_ISCHR) && defined(S_IFCHR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#endif
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if !defined(S_ISREG) && defined(S_IFREG)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#if !defined(S_ISFIFO) && defined(S_IFIFO)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#endif
|
||||
#if !defined(S_ISLNK) && defined(S_IFLNK)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
||||
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
#endif
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
#endif
|
||||
|
||||
void mode_string ();
|
||||
|
||||
@@ -1,37 +1,52 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
This program is 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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Enable GNU extensions in fnmatch.h. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined (STDC_HEADERS) || !defined (isascii)
|
||||
# define ISASCII(c) 1
|
||||
#else
|
||||
# define ISASCII(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define ISUPPER(c) (ISASCII (c) && isupper (c))
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined _LIBC || !defined __GNU_LIBRARY__
|
||||
|
||||
|
||||
# if defined STDC_HEADERS || !defined isascii
|
||||
# define ISASCII(c) 1
|
||||
# else
|
||||
# define ISASCII(c) isascii(c)
|
||||
# endif
|
||||
|
||||
# define ISUPPER(c) (ISASCII (c) && isupper (c))
|
||||
|
||||
|
||||
# ifndef errno
|
||||
extern int errno;
|
||||
@@ -49,7 +64,7 @@ fnmatch (pattern, string, flags)
|
||||
register char c;
|
||||
|
||||
/* Note that this evaluates C many times. */
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
{
|
||||
@@ -71,6 +86,9 @@ fnmatch (pattern, string, flags)
|
||||
if (!(flags & FNM_NOESCAPE))
|
||||
{
|
||||
c = *p++;
|
||||
if (c == '\0')
|
||||
/* Trailing \ loses. */
|
||||
return FNM_NOMATCH;
|
||||
c = FOLD (c);
|
||||
}
|
||||
if (FOLD (*n) != c)
|
||||
@@ -82,10 +100,24 @@ fnmatch (pattern, string, flags)
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
|
||||
if (((flags & FNM_FILE_NAME) && *n == '/') ||
|
||||
(c == '?' && *n == '\0'))
|
||||
return FNM_NOMATCH;
|
||||
for (c = *p++; c == '?' || c == '*'; c = *p++)
|
||||
{
|
||||
if ((flags & FNM_FILE_NAME) && *n == '/')
|
||||
/* A slash does not match a wildcard under FNM_FILE_NAME. */
|
||||
return FNM_NOMATCH;
|
||||
else if (c == '?')
|
||||
{
|
||||
/* A ? needs to match one character. */
|
||||
if (*n == '\0')
|
||||
/* There isn't another character; no match. */
|
||||
return FNM_NOMATCH;
|
||||
else
|
||||
/* One character of the string is consumed in matching
|
||||
this ? wildcard, so *??? won't match if there are
|
||||
less than three characters. */
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == '\0')
|
||||
return 0;
|
||||
@@ -122,7 +154,11 @@ fnmatch (pattern, string, flags)
|
||||
register char cstart = c, cend = c;
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
cstart = cend = *p++;
|
||||
{
|
||||
if (*p == '\0')
|
||||
return FNM_NOMATCH;
|
||||
cstart = cend = *p++;
|
||||
}
|
||||
|
||||
cstart = cend = FOLD (cstart);
|
||||
|
||||
@@ -169,8 +205,12 @@ fnmatch (pattern, string, flags)
|
||||
|
||||
c = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
/* XXX 1003.2d11 is unclear if this is right. */
|
||||
++p;
|
||||
{
|
||||
if (*p == '\0')
|
||||
return FNM_NOMATCH;
|
||||
/* XXX 1003.2d11 is unclear if this is right. */
|
||||
++p;
|
||||
}
|
||||
}
|
||||
if (not)
|
||||
return FNM_NOMATCH;
|
||||
@@ -196,3 +236,5 @@ fnmatch (pattern, string, flags)
|
||||
|
||||
# undef FOLD
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* fsusage.c -- return space usage of mounted filesystems
|
||||
Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 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
|
||||
@@ -65,6 +65,12 @@ int statfs ();
|
||||
int statvfs ();
|
||||
#endif
|
||||
|
||||
/* Many space usage primitives use all 1 bits to denote a value that is
|
||||
not applicable or unknown. Propagate this information by returning
|
||||
a uintmax_t value that is all 1 bits if the argument is all 1 bits,
|
||||
even if the argument is unsigned and smaller than unitmax_t. */
|
||||
#define PROPAGATE_ALL_ONES(x) ((x) == -1 ? (uintmax_t) -1 : (uintmax_t) (x))
|
||||
|
||||
int safe_read ();
|
||||
|
||||
/* Fill in the fields of FSP with information about space usage for
|
||||
@@ -87,7 +93,7 @@ get_fs_usage (path, disk, fsp)
|
||||
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
|
||||
return -1;
|
||||
|
||||
fsp->fsu_blocksize = fsd.f_fsize;
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#endif /* STAT_STATFS3_OSF1 */
|
||||
|
||||
@@ -99,11 +105,11 @@ get_fs_usage (path, disk, fsp)
|
||||
return -1;
|
||||
|
||||
fsp->fsu_blocksize = 1024;
|
||||
fsp->fsu_blocks = fsd.fd_req.btot;
|
||||
fsp->fsu_bfree = fsd.fd_req.bfree;
|
||||
fsp->fsu_bavail = fsd.fd_req.bfreen;
|
||||
fsp->fsu_files = fsd.fd_req.gtot;
|
||||
fsp->fsu_ffree = fsd.fd_req.gfree;
|
||||
fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
|
||||
fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
|
||||
fsp->fsu_bavail = PROPAGATE_ALL_ONES (fsd.fd_req.bfreen);
|
||||
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
|
||||
|
||||
#endif /* STAT_STATFS2_FS_DATA */
|
||||
|
||||
@@ -132,12 +138,14 @@ get_fs_usage (path, disk, fsp)
|
||||
}
|
||||
close (fd);
|
||||
|
||||
fsp->fsu_blocksize = fsd.s_type == Fs2b ? 1024 : 512;
|
||||
fsp->fsu_blocks = fsd.s_fsize;
|
||||
fsp->fsu_bfree = fsd.s_tfree;
|
||||
fsp->fsu_bavail = fsd.s_tfree;
|
||||
fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1);
|
||||
fsp->fsu_ffree = fsd.s_tinode;
|
||||
fsp->fsu_blocksize = (fsd.s_type == Fs2b ? 1024 : 512);
|
||||
fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.s_fsize);
|
||||
fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.s_tfree);
|
||||
fsp->fsu_bavail = PROPAGATE_ALL_ONES (fsd.s_tfree);
|
||||
fsp->fsu_files = (fsd.s_isize == -1
|
||||
? (uintmax_t) -1
|
||||
: (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
|
||||
|
||||
#endif /* STAT_READ_FILSYS */
|
||||
|
||||
@@ -148,7 +156,7 @@ get_fs_usage (path, disk, fsp)
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
|
||||
fsp->fsu_blocksize = fsd.f_bsize;
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
|
||||
# ifdef STATFS_TRUNCATES_BLOCK_COUNTS
|
||||
|
||||
@@ -174,7 +182,7 @@ get_fs_usage (path, disk, fsp)
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
|
||||
fsp->fsu_blocksize = fsd.f_fsize;
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#endif /* STAT_STATFS2_FSIZE */
|
||||
|
||||
@@ -193,7 +201,7 @@ get_fs_usage (path, disk, fsp)
|
||||
systems seem to always be in terms of 512-byte blocks,
|
||||
no matter what value f_bsize has. */
|
||||
# if _AIX || defined(_CRAY)
|
||||
fsp->fsu_blocksize = fsd.f_bsize;
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
# else
|
||||
fsp->fsu_blocksize = 512;
|
||||
# endif
|
||||
@@ -208,18 +216,19 @@ get_fs_usage (path, disk, fsp)
|
||||
return -1;
|
||||
|
||||
/* f_frsize isn't guaranteed to be supported. */
|
||||
fsp->fsu_blocksize = fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize;
|
||||
fsp->fsu_blocksize =
|
||||
PROPAGATE_ALL_ONES (fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize);
|
||||
|
||||
#endif /* STAT_STATVFS */
|
||||
|
||||
#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS)
|
||||
/* !Ultrix && !SVR2 */
|
||||
|
||||
fsp->fsu_blocks = fsd.f_blocks;
|
||||
fsp->fsu_bfree = fsd.f_bfree;
|
||||
fsp->fsu_bavail = fsd.f_bavail;
|
||||
fsp->fsu_files = fsd.f_files;
|
||||
fsp->fsu_ffree = fsd.f_ffree;
|
||||
fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks);
|
||||
fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.f_bfree);
|
||||
fsp->fsu_bavail = PROPAGATE_ALL_ONES (fsd.f_bavail);
|
||||
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
|
||||
|
||||
#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* ftruncate emulations that work on some System V's.
|
||||
This file is in the public domain. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -19,15 +19,15 @@ ftruncate (fd, length)
|
||||
}
|
||||
|
||||
#else /* not F_CHSIZE */
|
||||
#ifdef F_FREESP
|
||||
# ifdef F_FREESP
|
||||
|
||||
/* By William Kucharski <kucharsk@netcom.com>. */
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
# include <sys/stat.h>
|
||||
# include <errno.h>
|
||||
# if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
|
||||
int
|
||||
ftruncate (fd, length)
|
||||
@@ -71,8 +71,8 @@ ftruncate (fd, length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* not F_CHSIZE nor F_FREESP */
|
||||
#ifdef HAVE_CHSIZE
|
||||
# else /* not F_CHSIZE nor F_FREESP */
|
||||
# if HAVE_CHSIZE
|
||||
|
||||
int
|
||||
ftruncate (fd, length)
|
||||
@@ -82,12 +82,12 @@ ftruncate (fd, length)
|
||||
return chsize (fd, length);
|
||||
}
|
||||
|
||||
#else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
|
||||
# else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
# include <errno.h>
|
||||
# ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
int
|
||||
ftruncate (fd, length)
|
||||
@@ -98,6 +98,6 @@ ftruncate (fd, length)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* not HAVE_CHSIZE */
|
||||
#endif /* not F_FREESP */
|
||||
# endif /* not HAVE_CHSIZE */
|
||||
# endif /* not F_FREESP */
|
||||
#endif /* not F_CHSIZE */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* full-write.c -- an interface to write that retries after interrupts
|
||||
Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 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
|
||||
@@ -37,10 +37,7 @@ extern int errno;
|
||||
Return LEN upon success, write's (negative) error code otherwise. */
|
||||
|
||||
int
|
||||
full_write (desc, ptr, len)
|
||||
int desc;
|
||||
char *ptr;
|
||||
size_t len;
|
||||
full_write (int desc, const char *ptr, size_t len)
|
||||
{
|
||||
int total_written;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 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
|
||||
@@ -14,28 +14,28 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined (__GNUC__) || __STDC__
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (vms)
|
||||
#ifdef vms
|
||||
# include <types.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
# ifdef TIME_WITH_SYS_TIME
|
||||
# if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
# else
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
** a couple of people on Usenet. Completely overhauled by Rich $alz
|
||||
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
|
||||
**
|
||||
** This grammar has 13 shift/reduce conflicts.
|
||||
**
|
||||
** This code is in the public domain and has no copyright.
|
||||
*/
|
||||
|
||||
@@ -51,8 +49,6 @@
|
||||
host does not conform to Posix. */
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#include "getdate.h"
|
||||
|
||||
#if defined (STDC_HEADERS) || defined (USG)
|
||||
# include <string.h>
|
||||
#endif
|
||||
@@ -64,10 +60,6 @@
|
||||
# define bcopy(from, to, len) memcpy ((to), (from), (len))
|
||||
#endif
|
||||
|
||||
extern struct tm *gmtime ();
|
||||
extern struct tm *localtime ();
|
||||
extern time_t mktime ();
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
yacc generated parsers in the same program. Note that these are only
|
||||
@@ -172,6 +164,9 @@ static int yyRelYear;
|
||||
|
||||
%}
|
||||
|
||||
/* This grammar has 13 shift/reduce conflicts. */
|
||||
%expect 13
|
||||
|
||||
%union {
|
||||
int Number;
|
||||
enum _MERIDIAN Meridian;
|
||||
@@ -441,6 +436,15 @@ o_merid : /* NULL */
|
||||
|
||||
%%
|
||||
|
||||
/* Include this file down here because bison inserts code above which
|
||||
may define-away `const'. We want the prototype for get_date to have
|
||||
the same signature as the function definition does. */
|
||||
#include "getdate.h"
|
||||
|
||||
extern struct tm *gmtime ();
|
||||
extern struct tm *localtime ();
|
||||
extern time_t mktime ();
|
||||
|
||||
/* Month and day table. */
|
||||
static TABLE const MonthDayTable[] = {
|
||||
{ "january", tMONTH, 1 },
|
||||
@@ -886,9 +890,7 @@ difftm (a, b)
|
||||
}
|
||||
|
||||
time_t
|
||||
get_date (p, now)
|
||||
const char *p;
|
||||
const time_t *now;
|
||||
get_date (const char *p, const time_t *now)
|
||||
{
|
||||
struct tm tm, tm0, *tmp;
|
||||
time_t Start;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* getugroups.c -- return a list of the groups a user is in
|
||||
Copyright (C) 1990, 1991 Free Software Foundation.
|
||||
Copyright (C) 1990, 1991, 1998 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -45,10 +45,7 @@ struct group *getgrent ();
|
||||
the current process. */
|
||||
|
||||
int
|
||||
getugroups (maxcount, grouplist, username)
|
||||
int maxcount;
|
||||
GETGROUPS_T *grouplist;
|
||||
char *username;
|
||||
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username)
|
||||
{
|
||||
struct group *grp;
|
||||
register char **cp;
|
||||
@@ -59,16 +56,27 @@ getugroups (maxcount, grouplist, username)
|
||||
for (cp = grp->gr_mem; *cp; ++cp)
|
||||
if (!strcmp (username, *cp))
|
||||
{
|
||||
if (maxcount != 0)
|
||||
int n;
|
||||
|
||||
/* See if this group number is already on the list. */
|
||||
for (n = 0; n < count; ++n)
|
||||
if (grouplist[n] == grp->gr_gid)
|
||||
break;
|
||||
|
||||
/* If it's a new group number, then try to add it to the list. */
|
||||
if (n == count)
|
||||
{
|
||||
if (count >= maxcount)
|
||||
if (maxcount != 0)
|
||||
{
|
||||
endgrent ();
|
||||
return count;
|
||||
if (count >= maxcount)
|
||||
{
|
||||
endgrent ();
|
||||
return count;
|
||||
}
|
||||
grouplist[count] = grp->gr_gid;
|
||||
}
|
||||
grouplist[count] = grp->gr_gid;
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
endgrent ();
|
||||
return count;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* group-member.c -- determine whether group id is in calling user's group list
|
||||
Copyright (C) 1994, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 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
|
||||
@@ -15,7 +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. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ struct group_info
|
||||
GETGROUPS_T *group;
|
||||
};
|
||||
|
||||
#ifdef HAVE_GETGROUPS
|
||||
#if HAVE_GETGROUPS
|
||||
|
||||
static void
|
||||
free_group_info (struct group_info *g)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* idcache.c -- map user and group IDs, cached for speed
|
||||
Copyright (C) 1985, 1988, 1989, 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1985, 1988, 1989, 1990, 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
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
@@ -44,6 +44,10 @@ struct group *getgrnam ();
|
||||
char *xmalloc ();
|
||||
char *xstrdup ();
|
||||
|
||||
#ifdef __DJGPP__
|
||||
static char digits[] = "0123456789";
|
||||
#endif
|
||||
|
||||
struct userid
|
||||
{
|
||||
union
|
||||
@@ -55,23 +59,15 @@ struct userid
|
||||
struct userid *next;
|
||||
};
|
||||
|
||||
/* The members of this list have already been looked up.
|
||||
If a name is NULL, the corresponding id is not in the password file. */
|
||||
static struct userid *user_alist;
|
||||
|
||||
#ifdef NOT_USED
|
||||
/* The members of this list are names not in the local passwd file;
|
||||
their names are always not NULL, and their ids are irrelevant. */
|
||||
/* The members of this list have names not in the local passwd file. */
|
||||
static struct userid *nouser_alist;
|
||||
#endif /* NOT_USED */
|
||||
|
||||
/* Translate UID to a login name, with cache.
|
||||
If UID cannot be resolved, return NULL.
|
||||
Cache lookup failures, too. */
|
||||
/* Translate UID to a login name, with cache, or NULL if unresolved. */
|
||||
|
||||
char *
|
||||
getuser (uid)
|
||||
uid_t uid;
|
||||
getuser (uid_t uid)
|
||||
{
|
||||
register struct userid *tail;
|
||||
struct passwd *pwent;
|
||||
@@ -83,31 +79,28 @@ getuser (uid)
|
||||
pwent = getpwuid (uid);
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail->id.u = uid;
|
||||
tail->name = (pwent ? xstrdup (pwent->pw_name) : NULL);
|
||||
tail->name = pwent ? xstrdup (pwent->pw_name) : NULL;
|
||||
|
||||
/* Add to the head of the list, so most recently added is first. */
|
||||
/* Add to the head of the list, so most recently used is first. */
|
||||
tail->next = user_alist;
|
||||
user_alist = tail;
|
||||
return tail->name;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
|
||||
/* Translate USER to a UID, with cache.
|
||||
Return NULL if there is no such user.
|
||||
(We also cache which user names have no passwd entry,
|
||||
so we don't keep looking them up.) */
|
||||
|
||||
uid_t *
|
||||
getuidbyname (user)
|
||||
const char *user;
|
||||
getuidbyname (const char *user)
|
||||
{
|
||||
register struct userid *tail;
|
||||
struct passwd *pwent;
|
||||
|
||||
for (tail = user_alist; tail; tail = tail->next)
|
||||
/* Avoid a function call for the most common case. */
|
||||
if (tail->name && *tail->name == *user && !strcmp (tail->name, user))
|
||||
if (*tail->name == *user && !strcmp (tail->name, user))
|
||||
return &tail->id.u;
|
||||
|
||||
for (tail = nouser_alist; tail; tail = tail->next)
|
||||
@@ -116,11 +109,20 @@ getuidbyname (user)
|
||||
return 0;
|
||||
|
||||
pwent = getpwnam (user);
|
||||
#ifdef __DJGPP__
|
||||
/* We need to pretend to be the user USER, to make
|
||||
pwd functions know about an arbitrary user name. */
|
||||
if (!pwent && strspn (user, digits) < strlen (user))
|
||||
{
|
||||
setenv ("USER", user, 1);
|
||||
pwent = getpwnam (user); /* now it will succeed */
|
||||
}
|
||||
#endif
|
||||
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail->name = xstrdup (user);
|
||||
|
||||
/* Add to the head of the list, so most recently added is first. */
|
||||
/* Add to the head of the list, so most recently used is first. */
|
||||
if (pwent)
|
||||
{
|
||||
tail->id.u = pwent->pw_uid;
|
||||
@@ -134,20 +136,14 @@ getuidbyname (user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* NOT_USED */
|
||||
|
||||
/* Use the same struct as for userids. */
|
||||
static struct userid *group_alist;
|
||||
#ifdef NOT_USED
|
||||
static struct userid *nogroup_alist;
|
||||
#endif
|
||||
|
||||
/* Translate GID to a group name, with cache.
|
||||
Return NULL if the group has no name. */
|
||||
/* Translate GID to a group name, with cache, or NULL if unresolved. */
|
||||
|
||||
char *
|
||||
getgroup (gid)
|
||||
gid_t gid;
|
||||
getgroup (gid_t gid)
|
||||
{
|
||||
register struct userid *tail;
|
||||
struct group *grent;
|
||||
@@ -159,7 +155,7 @@ getgroup (gid)
|
||||
grent = getgrgid (gid);
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail->id.g = gid;
|
||||
tail->name = (grent ? xstrdup (grent->gr_name) : NULL);
|
||||
tail->name = grent ? xstrdup (grent->gr_name) : NULL;
|
||||
|
||||
/* Add to the head of the list, so most recently used is first. */
|
||||
tail->next = group_alist;
|
||||
@@ -167,23 +163,20 @@ getgroup (gid)
|
||||
return tail->name;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
|
||||
/* Translate GROUP to a GID, with cache.
|
||||
Return NULL if there is no such group.
|
||||
(We also cache which group names have no group entry,
|
||||
so we don't keep looking them up.) */
|
||||
|
||||
gid_t *
|
||||
getgidbyname (group)
|
||||
const char *group;
|
||||
getgidbyname (const char *group)
|
||||
{
|
||||
register struct userid *tail;
|
||||
struct group *grent;
|
||||
|
||||
for (tail = group_alist; tail; tail = tail->next)
|
||||
/* Avoid a function call for the most common case. */
|
||||
if (tail->name && *tail->name == *group && !strcmp (tail->name, group))
|
||||
if (*tail->name == *group && !strcmp (tail->name, group))
|
||||
return &tail->id.g;
|
||||
|
||||
for (tail = nogroup_alist; tail; tail = tail->next)
|
||||
@@ -192,6 +185,15 @@ getgidbyname (group)
|
||||
return 0;
|
||||
|
||||
grent = getgrnam (group);
|
||||
#ifdef __DJGPP__
|
||||
/* We need to pretend to belong to group GROUP, to make
|
||||
grp functions know about any arbitrary group name. */
|
||||
if (!grent && strspn (group, digits) < strlen (group))
|
||||
{
|
||||
setenv ("GROUP", group, 1);
|
||||
grent = getgrnam (group); /* now it will succeed */
|
||||
}
|
||||
#endif
|
||||
|
||||
tail = (struct userid *) xmalloc (sizeof (struct userid));
|
||||
tail->name = xstrdup (group);
|
||||
@@ -209,5 +211,3 @@ getgidbyname (group)
|
||||
nogroup_alist = tail;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* NOT_USED */
|
||||
|
||||
10
lib/isdir.c
10
lib/isdir.c
@@ -1,5 +1,5 @@
|
||||
/* isdir.c -- determine whether a directory exists
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -15,19 +15,19 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef STAT_MACROS_BROKEN
|
||||
#undef S_ISDIR
|
||||
# undef S_ISDIR
|
||||
#endif /* STAT_MACROS_BROKEN. */
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* If PATH is an existing directory or symbolic link to a directory,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* linebuffer.h -- declarations for reading 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
|
||||
@@ -14,7 +14,10 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#if !defined LINEBUFFER_H
|
||||
# define LINEBUFFER_H
|
||||
|
||||
/* A `struct linebuffer' holds a line of text. */
|
||||
|
||||
struct linebuffer
|
||||
@@ -24,12 +27,13 @@ struct linebuffer
|
||||
char *buffer;
|
||||
};
|
||||
|
||||
#undef PARAMS
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
#else
|
||||
# define PARAMS(Args) ()
|
||||
#endif
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Initialize linebuffer LINEBUFFER for use. */
|
||||
void initbuffer PARAMS ((struct linebuffer *linebuffer));
|
||||
@@ -42,3 +46,5 @@ struct linebuffer *readline PARAMS ((struct linebuffer *linebuffer,
|
||||
|
||||
/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
|
||||
void freebuffer PARAMS ((struct linebuffer *));
|
||||
|
||||
#endif /* LINEBUFFER_H */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Utility to accept --help and --version options as unobtrusively as possible.
|
||||
Copyright (C) 1993, 1994 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 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
|
||||
@@ -17,12 +17,13 @@
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -62,6 +63,8 @@ parse_long_options (argc, argv, command_name, package, version, usage)
|
||||
|
||||
case 'v':
|
||||
printf ("%s (%s) %s\n", command_name, package, version);
|
||||
close_stdout (); /* FIXME: output failure exit status
|
||||
should be settable via an arg. */
|
||||
exit (0);
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* makepath.c -- Ensure that a directory path exists.
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -217,6 +217,14 @@ make_path (const char *argpath,
|
||||
if (!do_chdir)
|
||||
basename_dir = dirpath;
|
||||
|
||||
/* The mkdir and stat calls below appear to be reversed.
|
||||
They are not. It is important to call mkdir first and then to
|
||||
call stat (to distinguish the three cases) only if mkdir fails.
|
||||
The alternative to this approach is to `stat' each directory,
|
||||
then to call mkdir if it doesn't exist. But if some other process
|
||||
were to create the directory between the stat & mkdir, the mkdir
|
||||
would fail with EEXIST. */
|
||||
|
||||
*slash = '\0';
|
||||
if (mkdir (basename_dir, tmp_mode))
|
||||
{
|
||||
@@ -239,29 +247,31 @@ make_path (const char *argpath,
|
||||
}
|
||||
}
|
||||
|
||||
if (newly_created_dir && verbose_fmt_string != NULL)
|
||||
fprintf (stderr, verbose_fmt_string, dirpath);
|
||||
if (newly_created_dir)
|
||||
{
|
||||
if (verbose_fmt_string)
|
||||
fprintf (stderr, verbose_fmt_string, dirpath);
|
||||
|
||||
if (newly_created_dir
|
||||
&& (owner != (uid_t) -1 || group != (gid_t) -1)
|
||||
&& chown (basename_dir, owner, group)
|
||||
if ((owner != (uid_t) -1 || group != (gid_t) -1)
|
||||
&& chown (basename_dir, owner, group)
|
||||
#if defined(AFS) && defined (EPERM)
|
||||
&& errno != EPERM
|
||||
&& errno != EPERM
|
||||
#endif
|
||||
)
|
||||
{
|
||||
error (0, errno, "%s", dirpath);
|
||||
CLEANUP;
|
||||
return 1;
|
||||
}
|
||||
)
|
||||
{
|
||||
error (0, errno, "%s", dirpath);
|
||||
CLEANUP;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (re_protect)
|
||||
{
|
||||
struct ptr_list *new = (struct ptr_list *)
|
||||
alloca (sizeof (struct ptr_list));
|
||||
new->dirname_end = slash;
|
||||
new->next = leading_dirs;
|
||||
leading_dirs = new;
|
||||
if (re_protect)
|
||||
{
|
||||
struct ptr_list *new = (struct ptr_list *)
|
||||
alloca (sizeof (struct ptr_list));
|
||||
new->dirname_end = slash;
|
||||
new->next = leading_dirs;
|
||||
leading_dirs = new;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we were able to save the initial working directory,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#undef PARAMS
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
#else
|
||||
# define PARAMS(Args) ()
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
|
||||
32
lib/mktime.c
32
lib/mktime.c
@@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
/* mktime: convert a `struct tm' to a time_t value
|
||||
Copyright (C) 1993-1997, 1998 Free Software Foundation, Inc.
|
||||
Contributed by Paul Eggert (eggert@twinsun.com).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
@@ -73,21 +74,26 @@
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#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) 0 - TYPE_MINIMUM (t))
|
||||
|
||||
#ifndef INT_MIN
|
||||
# define INT_MIN (~0 << (sizeof (int) * CHAR_BIT - 1))
|
||||
# define INT_MIN TYPE_MINIMUM (int)
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX (~0 - INT_MIN)
|
||||
# define INT_MAX TYPE_MAXIMUM (int)
|
||||
#endif
|
||||
|
||||
#ifndef TIME_T_MIN
|
||||
/* The outer cast to time_t works around a bug in Cray C 5.0.3.0. */
|
||||
# define TIME_T_MIN ((time_t) \
|
||||
(0 < (time_t) -1 ? (time_t) 0 \
|
||||
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)))
|
||||
# define TIME_T_MIN TYPE_MINIMUM (time_t)
|
||||
#endif
|
||||
#ifndef TIME_T_MAX
|
||||
# define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
|
||||
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
|
||||
#endif
|
||||
|
||||
#define TM_YEAR_BASE 1900
|
||||
@@ -365,7 +371,15 @@ __mktime_internal (tp, convert, offset)
|
||||
double dday = 366 * dyear + mday;
|
||||
double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested;
|
||||
|
||||
if (TIME_T_MAX / 3 - TIME_T_MIN / 3 < (dsec < 0 ? - dsec : dsec))
|
||||
/* On Irix4.0.5 cc, dividing TIME_T_MIN by 3 does not produce
|
||||
correct results, ie., it erroneously gives a positive value
|
||||
of 715827882. Setting a variable first then doing math on it
|
||||
seems to work. (ghazi@caip.rutgers.edu) */
|
||||
|
||||
const time_t time_t_max = TIME_T_MAX;
|
||||
const time_t time_t_min = TIME_T_MIN;
|
||||
|
||||
if (time_t_max / 3 - time_t_min / 3 < (dsec < 0 ? - dsec : dsec))
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mountlist.c -- return a list of mounted filesystems
|
||||
Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 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
|
||||
@@ -15,7 +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. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -42,7 +42,7 @@ char *xrealloc ();
|
||||
char *xstrdup ();
|
||||
void error ();
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
@@ -101,7 +101,7 @@ void error ();
|
||||
# define MOUNTED_GETMNTTBL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_MNTENT_H
|
||||
#if HAVE_SYS_MNTENT_H
|
||||
/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
|
||||
# include <sys/mntent.h>
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* path-concat.c -- concatenate two arbitrary pathnames
|
||||
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
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1994, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
@@ -28,6 +28,8 @@
|
||||
systems like Irix 5.3. */
|
||||
#undef putenv
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (__GNU_LIBRARY__) || defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
@@ -51,6 +53,10 @@
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
|
||||
int
|
||||
|
||||
346
lib/quotearg.c
Normal file
346
lib/quotearg.c
Normal file
@@ -0,0 +1,346 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
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. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <quotearg.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define ISASCII(c) 1
|
||||
#else
|
||||
# define ISASCII(c) isascii (c)
|
||||
#endif
|
||||
#ifdef isgraph
|
||||
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
|
||||
#else
|
||||
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX ((unsigned char) -1)
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Quote the chararacters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
int quote_these_too[((UCHAR_MAX + 1) / INT_BITS
|
||||
+ ((UCHAR_MAX + 1) % INT_BITS != 0))];
|
||||
};
|
||||
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal", "shell", "shell-always", "c", "escape", 0
|
||||
};
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to a default value if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *
|
||||
clone_quoting_options (struct quoting_options *o)
|
||||
{
|
||||
struct quoting_options *p
|
||||
= (struct quoting_options *) xmalloc (sizeof (struct quoting_options));
|
||||
if (o)
|
||||
*p = *o;
|
||||
else
|
||||
memset (p, 0, sizeof *p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get the value of O's quoting style. */
|
||||
enum quoting_style
|
||||
get_quoting_style (struct quoting_options *o)
|
||||
{
|
||||
return o->style;
|
||||
}
|
||||
|
||||
/* In O, set the value of the quoting style to S. */
|
||||
void
|
||||
set_quoting_style (struct quoting_options *o, enum quoting_style s)
|
||||
{
|
||||
o->style = s;
|
||||
}
|
||||
|
||||
/* In O, set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int
|
||||
set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
{
|
||||
unsigned char uc = c;
|
||||
int *p = o->quote_these_too + uc / INT_BITS;
|
||||
int shift = uc % INT_BITS;
|
||||
int r = (*p >> shift) & 1;
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Place into buffer BUF (of size BUFSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buf, size_t bufsize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
unsigned char c;
|
||||
size_t i;
|
||||
size_t len;
|
||||
int quote_mark;
|
||||
enum quoting_style quoting_style = o->style;
|
||||
#define STORE(c) do { if (len < bufsize) buf[len] = (c); len++; } while (0)
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
if (! (argsize == -1 ? arg[0] == '\0' : argsize == 0))
|
||||
{
|
||||
switch (arg[0])
|
||||
{
|
||||
case '#': case '~':
|
||||
break;
|
||||
|
||||
default:
|
||||
len = 0;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
if (argsize == -1 ? arg[i] == '\0' : i == argsize)
|
||||
goto done;
|
||||
|
||||
c = arg[i];
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\t': case '\n': case ' ':
|
||||
case '!': /* special in csh */
|
||||
case '"': case '$': case '&': case '\'':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '?': case '[': case '\\':
|
||||
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
goto needs_quoting;
|
||||
}
|
||||
|
||||
if (o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))
|
||||
goto needs_quoting;
|
||||
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
needs_quoting:;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Fall through. */
|
||||
|
||||
case shell_always_quoting_style:
|
||||
quote_mark = '\'';
|
||||
break;
|
||||
|
||||
case c_quoting_style:
|
||||
quote_mark = '"';
|
||||
break;
|
||||
|
||||
default:
|
||||
quote_mark = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
|
||||
if (quote_mark)
|
||||
STORE (quote_mark);
|
||||
|
||||
for (i = 0; ! (argsize == -1 ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
c = arg[i];
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case literal_quoting_style:
|
||||
break;
|
||||
|
||||
case shell_quoting_style:
|
||||
case shell_always_quoting_style:
|
||||
if (c == '\'')
|
||||
{
|
||||
STORE ('\'');
|
||||
STORE ('\\');
|
||||
STORE ('\'');
|
||||
}
|
||||
break;
|
||||
|
||||
case c_quoting_style:
|
||||
case escape_quoting_style:
|
||||
switch (c)
|
||||
{
|
||||
case '?': /* Do not generate trigraphs. */
|
||||
case '\\': goto store_escape;
|
||||
/* Not all C compilers know what \a means. */
|
||||
case 7 : c = 'a'; goto store_escape;
|
||||
case '\b': c = 'b'; goto store_escape;
|
||||
case '\f': c = 'f'; goto store_escape;
|
||||
case '\n': c = 'n'; goto store_escape;
|
||||
case '\r': c = 'r'; goto store_escape;
|
||||
case '\t': c = 't'; goto store_escape;
|
||||
case '\v': c = 'v'; goto store_escape;
|
||||
|
||||
case ' ':
|
||||
if (quoting_style == escape_quoting_style)
|
||||
goto store_escape;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (quoting_style == c_quoting_style)
|
||||
goto store_escape;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!ISGRAPH (c))
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 3));
|
||||
c = '0' + (c & 3);
|
||||
goto store_c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (! (o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
store_escape:
|
||||
STORE ('\\');
|
||||
}
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (quote_mark)
|
||||
STORE (quote_mark);
|
||||
|
||||
done:
|
||||
if (len < bufsize)
|
||||
buf[len] = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg, struct quoting_options *options)
|
||||
{
|
||||
static unsigned nslots;
|
||||
static struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
} *slotvec;
|
||||
|
||||
if (nslots <= n)
|
||||
{
|
||||
int n1 = n + 1;
|
||||
size_t s = n1 * sizeof (struct slotvec);
|
||||
if (! (0 < n1 && n1 == s / sizeof (struct slotvec)))
|
||||
abort ();
|
||||
slotvec = (struct slotvec *) xrealloc (slotvec, s);
|
||||
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec));
|
||||
nslots = n;
|
||||
}
|
||||
|
||||
{
|
||||
size_t size = slotvec[n].size;
|
||||
char *val = slotvec[n].val;
|
||||
size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
slotvec[n].size = size = qsize + 1;
|
||||
slotvec[n].val = val = xrealloc (val, size);
|
||||
quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
struct quoting_options quotearg_quoting_options;
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, "earg_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
struct quoting_options options;
|
||||
options = quotearg_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
||||
97
lib/quotearg.h
Normal file
97
lib/quotearg.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
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. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
/* Basic quoting styles. */
|
||||
enum quoting_style
|
||||
{
|
||||
literal_quoting_style, /* --quoting-style=literal */
|
||||
shell_quoting_style, /* --quoting-style=shell */
|
||||
shell_always_quoting_style, /* --quoting-style=shell-always */
|
||||
c_quoting_style, /* --quoting-style=c */
|
||||
escape_quoting_style /* --quoting-style=escape */
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but
|
||||
this is planned to change to --quoting-style=shell in the future. */
|
||||
#ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
#endif
|
||||
|
||||
/* Names of quoting styles. */
|
||||
extern char const *const quoting_style_args[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to a default value if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *clone_quoting_options
|
||||
PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* Get the value of O's quoting style. */
|
||||
enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* In O, set the value of the quoting style to S. */
|
||||
void set_quoting_style PARAMS ((struct quoting_options *o,
|
||||
enum quoting_style s));
|
||||
|
||||
/* In O, set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
||||
|
||||
/* Place into buffer BUF (of size BUFSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t quotearg_buffer PARAMS ((char *buf, size_t bufsize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o));
|
||||
|
||||
/* The quoting options used by the convenience functions listed below. */
|
||||
|
||||
extern struct quoting_options quotearg_quoting_options;
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
The variable quotearg_quoting_options specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
char *quotearg_n PARAMS ((int n, char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n (ARG, 0). */
|
||||
char *quotearg PARAMS ((char const *arg));
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char PARAMS ((char const *arg, char ch));
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon PARAMS ((char const *arg));
|
||||
@@ -1,5 +1,5 @@
|
||||
/* save-cwd.c -- Save and restore current working directory.
|
||||
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 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
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
/* Written by Jim Meyering <meyering@na-net.ornl.gov>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <sys/file.h>
|
||||
@@ -67,7 +67,7 @@ save_cwd (cwd)
|
||||
|
||||
if (have_working_fchdir)
|
||||
{
|
||||
#ifdef HAVE_FCHDIR
|
||||
#if HAVE_FCHDIR
|
||||
cwd->desc = open (".", O_RDONLY);
|
||||
if (cwd->desc < 0)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ struct saved_cwd
|
||||
};
|
||||
|
||||
# ifndef PARAMS
|
||||
# if __STDC__
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* savedir.c -- save the list of files in a directory in a string
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
12
lib/stat.c
12
lib/stat.c
@@ -1,7 +1,7 @@
|
||||
/* Work around the bug in some systems whereby stat succeeds when
|
||||
given the zero-length file name argument. The stat from SunOS4.1.4
|
||||
has this bug.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -33,7 +33,13 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* FIXME: describe. */
|
||||
/* This is a wrapper for stat(2).
|
||||
If FILE is the empty string, fail with errno == ENOENT.
|
||||
Otherwise, return the result of calling the real stat.
|
||||
|
||||
This works around the bug in some systems whereby stat succeeds when
|
||||
given the zero-length file name argument. The stat from SunOS4.1.4
|
||||
has this bug. */
|
||||
|
||||
int
|
||||
rpl_stat (file, sbuf)
|
||||
@@ -42,7 +48,7 @@ rpl_stat (file, sbuf)
|
||||
{
|
||||
if (file && *file == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
10
lib/strdup.c
10
lib/strdup.c
@@ -1,5 +1,5 @@
|
||||
/* strdup.c -- return a newly allocated copy of a string
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -15,13 +15,13 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
char *strcpy ();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* userspec.c -- Parse a user and group string.
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 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
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifdef __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
#else
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
@@ -153,6 +153,15 @@ parse_user_spec (spec_arg, uid, gid, username_arg, groupname_arg)
|
||||
if (u == NULL && g == NULL)
|
||||
return "can not omit both user and group";
|
||||
|
||||
#ifdef __DJGPP__
|
||||
/* Pretend that we are the user U whose group is G. This makes
|
||||
pwd and grp functions ``know'' about the UID and GID of these. */
|
||||
if (u && !is_number (u))
|
||||
setenv ("USER", u, 1);
|
||||
if (g && !is_number (g))
|
||||
setenv ("GROUP", g, 1);
|
||||
#endif
|
||||
|
||||
if (u != NULL)
|
||||
{
|
||||
pwd = getpwnam (u);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xstrdup.c -- copy a string with out of memory checking
|
||||
Copyright (C) 1990, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -19,24 +19,28 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
char *xmalloc (size_t);
|
||||
char *xstrdup (char *string);
|
||||
#else
|
||||
char *xmalloc ();
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
char *xmalloc PARAMS ((size_t n));
|
||||
|
||||
/* Return a newly allocated copy of STRING. */
|
||||
|
||||
char *
|
||||
xstrdup (string)
|
||||
char *string;
|
||||
xstrdup (const char *string)
|
||||
{
|
||||
return strcpy (xmalloc (strlen (string) + 1), string);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#ifndef XSTRTOD_H
|
||||
# define XSTRTOD_H 1
|
||||
|
||||
#undef PARAMS
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
#else
|
||||
# define PARAMS(Args) ()
|
||||
#endif
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
int
|
||||
xstrtod PARAMS ((const char *str, const char **ptr, double *result));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 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
|
||||
@@ -46,12 +46,24 @@ extern int errno;
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#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) 0 - TYPE_MINIMUM (t))
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||
# define ULONG_MAX TYPE_MAXIMUM (unsigned long int)
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||
# define LONG_MAX TYPE_MAXIMUM (long int)
|
||||
#endif
|
||||
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* yesno.c -- read a yes/no response from stdin
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 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
|
||||
@@ -15,12 +15,12 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
26
m4/ChangeLog
26
m4/ChangeLog
@@ -1,3 +1,29 @@
|
||||
1998-03-15 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* prereq.m4: New file.
|
||||
* error.m4: New file.
|
||||
* Makefile.am (EXTRA_DIST): Add error.m4 and prereq.m4.
|
||||
|
||||
1998-02-07 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* getline.m4: Don't set am_cv_func_working_getline before the
|
||||
cache-check for the same variable -- that defeated the purpose of
|
||||
the test; the test program was never run. This was a problem only
|
||||
on systems with losing getline functions -- HP-UX 10.20 is one.
|
||||
Reported by Bjorn Helgaas.
|
||||
|
||||
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add perl.m4.
|
||||
|
||||
1998-01-10 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add const.m4.
|
||||
|
||||
* const.m4: New file. Use an initializer in this declaration
|
||||
typedef int charset[2]; const charset x;
|
||||
Reported by Bob Glickstein.
|
||||
|
||||
1997-12-21 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* chown.m4: Fix reversed types on -1 args to chown.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
# find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \
|
||||
# |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
|
||||
EXTRA_DIST = README \
|
||||
check-decl.m4 chown.m4 d-ino.m4 d-type.m4 decl.m4 getgroups.m4 getline.m4 \
|
||||
getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 lfs.m4 \
|
||||
lstat.m4 malloc.m4 memcmp.m4 putenv.m4 readdir.m4 realloc.m4 \
|
||||
stat.m4 strftime.m4 uintmax_t.m4 uptime.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 jm-mktime.m4 jm-winsz1.m4 \
|
||||
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 putenv.m4 \
|
||||
readdir.m4 realloc.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 \
|
||||
mktime.m4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile.in generated automatically by automake 1.2d from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.2f from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
# 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.
|
||||
@@ -75,7 +75,6 @@ INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
@@ -93,10 +92,10 @@ YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
EXTRA_DIST = README \
|
||||
check-decl.m4 chown.m4 d-ino.m4 d-type.m4 decl.m4 getgroups.m4 getline.m4 \
|
||||
getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 lfs.m4 \
|
||||
lstat.m4 malloc.m4 memcmp.m4 putenv.m4 readdir.m4 realloc.m4 \
|
||||
stat.m4 strftime.m4 uintmax_t.m4 uptime.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 jm-mktime.m4 jm-winsz1.m4 \
|
||||
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 putenv.m4 \
|
||||
readdir.m4 realloc.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 \
|
||||
mktime.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
@@ -111,7 +110,7 @@ GZIP = --best
|
||||
default: all
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnits m4/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
|
||||
66
m4/const.m4
Normal file
66
m4/const.m4
Normal file
@@ -0,0 +1,66 @@
|
||||
#serial 1
|
||||
|
||||
dnl Just like AC_C_CONST from autoconf-2.12, but with an initializer
|
||||
dnl for `charset x' and with
|
||||
dnl AC_DEFINE(const, )
|
||||
dnl changed to
|
||||
dnl AC_DEFINE_UNQUOTED(const, [/* empty */])
|
||||
dnl to avoid this warning:
|
||||
dnl [...]/m4: Warning: Excess arguments to built-in `define' ignored
|
||||
|
||||
undefine([AC_C_CONST])
|
||||
AC_DEFUN(AC_C_CONST,
|
||||
[dnl This message is consistent in form with the other checking messages,
|
||||
dnl and with the result message.
|
||||
AC_CACHE_CHECK([for working const], ac_cv_c_const,
|
||||
[AC_TRY_COMPILE(,
|
||||
changequote(<<, >>)dnl
|
||||
<<
|
||||
/* Ultrix mips cc rejects this. */
|
||||
typedef int charset[2]; const charset x = {0, 0};
|
||||
/* SunOS 4.1.1 cc rejects this. */
|
||||
char const *const *ccp;
|
||||
char **p;
|
||||
/* NEC SVR4.0.2 mips cc rejects this. */
|
||||
struct point {int x, y;};
|
||||
static struct point const zero = {0,0};
|
||||
/* AIX XL C 1.02.0.0 rejects this.
|
||||
It does not let you subtract one const X* pointer from another in an arm
|
||||
of an if-expression whose if-part is not a constant expression */
|
||||
const char *g = "string";
|
||||
ccp = &g + (g ? g-g : 0);
|
||||
/* HPUX 7.0 cc rejects these. */
|
||||
++ccp;
|
||||
p = (char**) ccp;
|
||||
ccp = (char const *const *) p;
|
||||
{ /* SCO 3.2v4 cc rejects this. */
|
||||
char *t;
|
||||
char const *s = 0 ? (char *) 0 : (char const *) 0;
|
||||
|
||||
*t++ = 0;
|
||||
}
|
||||
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
|
||||
int x[] = {25, 17};
|
||||
const int *foo = &x[0];
|
||||
++foo;
|
||||
}
|
||||
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
|
||||
typedef const int *iptr;
|
||||
iptr p = 0;
|
||||
++p;
|
||||
}
|
||||
{ /* AIX XL C 1.02.0.0 rejects this saying
|
||||
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
|
||||
struct s { int j; const int *ap[3]; };
|
||||
struct s *b; b->j = 5;
|
||||
}
|
||||
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
|
||||
const int foo = 10;
|
||||
}
|
||||
>>,
|
||||
changequote([, ])dnl
|
||||
ac_cv_c_const=yes, ac_cv_c_const=no)])
|
||||
if test $ac_cv_c_const = no; then
|
||||
AC_DEFINE_UNQUOTED(const, [/* empty */])
|
||||
fi
|
||||
])
|
||||
11
m4/error.m4
Normal file
11
m4/error.m4
Normal file
@@ -0,0 +1,11 @@
|
||||
#serial 1
|
||||
|
||||
dnl FIXME: put these prerequisite-only *.m4 files in a separate
|
||||
dnl directory -- otherwise, they'll conflict with existing files.
|
||||
|
||||
dnl These are the prerequisite macros for GNU's error.c file.
|
||||
AC_DEFUN(jm_PREREQ_ERROR,
|
||||
[
|
||||
AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
|
||||
AC_HEADER_STDC
|
||||
])
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl See if there's a working, system-supplied version of the getline function.
|
||||
dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
|
||||
@@ -7,7 +7,6 @@ dnl to do with the function we need.
|
||||
AC_DEFUN(AM_FUNC_GETLINE,
|
||||
[dnl
|
||||
am_getline_needs_run_time_check=no
|
||||
am_cv_func_working_getline=yes
|
||||
AC_CHECK_FUNC(getline,
|
||||
dnl Found it in some library. Verify that it works.
|
||||
am_getline_needs_run_time_check=yes,
|
||||
|
||||
39
m4/perl.m4
Normal file
39
m4/perl.m4
Normal file
@@ -0,0 +1,39 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Find a new-enough version of Perl.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_PERL,
|
||||
[
|
||||
dnl FIXME: don't hard-code 5.003
|
||||
dnl FIXME: should we cache the result?
|
||||
AC_MSG_CHECKING([for perl5.003 or newer])
|
||||
if test "${PERL+set}" = set; then
|
||||
# `PERL' is set in the user's environment.
|
||||
candidate_perl_names="$PERL"
|
||||
perl_specified=yes
|
||||
else
|
||||
candidate_perl_names='perl perl5'
|
||||
perl_specified=no
|
||||
fi
|
||||
|
||||
found=no
|
||||
AC_SUBST(PERL)
|
||||
PERL="$missing_dir/missing perl"
|
||||
for perl in $candidate_perl_names; do
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
if ( $perl -e 'require 5.003' ) > /dev/null 2>&1; then
|
||||
PERL=$perl
|
||||
found=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
AC_MSG_RESULT($found)
|
||||
test $found = no && AC_MSG_WARN([
|
||||
*** You don't seem to have perl5.003 or newer installed.
|
||||
*** Because of that, you may be unable to regenerate certain files
|
||||
*** if you modify the sources from which they are derived.] )
|
||||
])
|
||||
9
m4/prereq.m4
Normal file
9
m4/prereq.m4
Normal file
@@ -0,0 +1,9 @@
|
||||
#serial 1
|
||||
|
||||
dnl These are the prerequisite macros for files in the lib/
|
||||
dnl directories of the fileutils, sh-utils, and textutils packages.
|
||||
|
||||
AC_DEFUN(jm_PREREQ,
|
||||
[
|
||||
jm_PREREQ_ERROR
|
||||
])
|
||||
File diff suppressed because it is too large
Load Diff
6160
old/fileutils/ChangeLog-1997
Normal file
6160
old/fileutils/ChangeLog-1997
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,42 @@
|
||||
Changes in release 3.17:
|
||||
[3.16i]
|
||||
[3.16n]
|
||||
* `mv dir dir' once again does *not* remove dir/
|
||||
* ls accepts new options:
|
||||
--indicator-style=none (no indicators, the default)
|
||||
--indicator-style=classify (all indicators)
|
||||
(equivalent to -F or --classify)
|
||||
--indicator-style=file-type (file type indicators)
|
||||
(equivalent to -p or --file-type)
|
||||
|
||||
--quoting-style=literal (do not quote output)
|
||||
--quoting-style=shell (minimally quote output for the shell)
|
||||
--quoting-style=shell-always (always quote output with '' for the shell)
|
||||
--quoting-style=c (quote output as for a C-language string)
|
||||
(equivalent to -Q or --quote-name)
|
||||
--quoting-style=escape (like c but omit enclosing "")
|
||||
(equivalent to -b or --escape)
|
||||
|
||||
--show-control-chars is the opposite of --hide-control-chars
|
||||
This option can be useful if output is to a terminal,
|
||||
to override the default beahvior of hiding control characters.
|
||||
|
||||
* The QUOTING_STYLE environment variable can now be used to specify the
|
||||
default value for ls's --quoting-style option. If not specified,
|
||||
the default quoting style is 'literal', but this default may change to
|
||||
'shell' in a future version of this package.
|
||||
* ls's quoting style now affects operands in diagnostics, too.
|
||||
* ls's --dired option now outputs the quoting style
|
||||
using the format of the new --quoting-style option.
|
||||
* ls's -e or --quote-shell option (introduced in 3.16j) has been removed;
|
||||
use --quoting-style=shell to get its functionality.
|
||||
[3.16m]
|
||||
* mv can move (and doesn't read) special files
|
||||
* remove maintainer mode
|
||||
[3.16l]
|
||||
* mv can finally move non-regular files between partitions
|
||||
[3.16k]
|
||||
* install accepts new option, -D
|
||||
[3.16j]
|
||||
* du accepts new options, --exclude=PAT and --exclude-from=FILE (-X FILE)
|
||||
* ls now quotes file names for the shell by default, if they contain
|
||||
characters that need quoting. Use -N to get the old default behavior.
|
||||
@@ -27,7 +64,7 @@ Changes in release 3.17:
|
||||
* rmdir accepts new options: --ignore-fail-on-non-empty and --verbose
|
||||
* on most hosts df, du, and ls now overflow at 2**64 bytes, not 2**31 bytes
|
||||
* all programs now work on large files on LFS systems like Solaris 2.6 and
|
||||
Linux with the pre-2.1 release of GNU libc.
|
||||
Linux with the pre-2.1 development version of GNU libc.
|
||||
* df now works with OpenBSD 2.1 beta
|
||||
* cp -d FILE SYMLINK-TO-FILE doesn't erase FILE. Now it gives an error.
|
||||
|
||||
|
||||
@@ -1,3 +1,72 @@
|
||||
1998-03-13 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* lib/getugroups.c (getugroups): Don't add a group number if it
|
||||
would be a duplicate. From Ulrich Drepper.
|
||||
|
||||
1998-02-22 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Add mk-script.
|
||||
* tests/Makefile.am.in (EXTRA_DIST): Remove mk-script.pl.
|
||||
(mk_script): Set to ../mk-script.
|
||||
(x-tests): Use `$(PERL) -w -- $(mk_script)', not ./mk-script.
|
||||
Remove @MAINT@ cruft.
|
||||
(Makefile.am): Likewise.
|
||||
Remove @MAINT@ cruft. Now `missing' will explain the failure
|
||||
when people don't have Perl yet modify a file whose rebuilding
|
||||
would lead to the use of Perl.
|
||||
|
||||
* src/Makefile.am (pinky_LDADD): Explicitly add @GETHOSTBYNAME_LIB@.
|
||||
(who_LDADD): Likewise.
|
||||
(pinky_DEPENDENCIES): Set to $(LDADD)
|
||||
(who_DEPENDENCIES): Likewise.
|
||||
|
||||
1998-02-20 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* lib/getdate.h: Removed. Could cause confusion with an
|
||||
automake-generated `.y.h' rule.
|
||||
* lib/get-date.h: Renamed from getdate.h.
|
||||
* lib/getdate.y: s/getdate.h/get-date.h/
|
||||
* lib/Makefile.am (noinst_HEADERS): s/getdate.h/get-date.h/
|
||||
* src/date.c: s/getdate.h/get-date.h/
|
||||
|
||||
1998-02-16 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* configure.in (jm_FUNC_LSTAT): Use it.
|
||||
(jm_FUNC_STAT): Use it.
|
||||
* acconfig.h: Add lstat.
|
||||
* lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c.
|
||||
|
||||
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* tests/nice: Fail immediately if this test is run with `nice'
|
||||
level different from zero. Reported by Philippe De Muyter.
|
||||
|
||||
1998-02-03 Philippe De Muyter <phdm@macqel.be>
|
||||
|
||||
* src/id.c (xgetgroups): Guard function defn with #if HAVE_GETGROUPS.
|
||||
|
||||
* lib/putenv.c (sys/types.h): Include to get size_t on some systems.
|
||||
(NULL): Define if needed.
|
||||
|
||||
1998-01-31 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in (AC_LFS): Use it.
|
||||
|
||||
1998-01-25 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Makefile.maint: New file.
|
||||
* Makefile.am: Move rules common to textutils, fileutils, sh-utils
|
||||
into Makefile.maint.
|
||||
Include Makefile.maint.
|
||||
(EXTRA_DIST): Add Makefile.maint.
|
||||
|
||||
1998-01-03 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* lib/Makefile.am (AUTOMAKE_OPTIONS): Define to ../src/ansi2knr.
|
||||
|
||||
* configure.in: Convert the .o suffix on files in LIBOBJS to $U.o so
|
||||
those files will be built via the ANSI2KNR-filtering rules if necessary.
|
||||
|
||||
1997-12-25 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in: Remove AC_DEFINE of _GNU_SOURCE.
|
||||
|
||||
@@ -1,3 +1,166 @@
|
||||
1998-03-03 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sort.c (xtmpfopen): Open temporary file exclusively, to
|
||||
foil a common denial-of-service attack.
|
||||
* src/tac.c (save_stdin): Likewise.
|
||||
|
||||
1998-02-16 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* configure.in (jm_FUNC_LSTAT): Use it.
|
||||
(jm_FUNC_STAT): Use it.
|
||||
* lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c.
|
||||
|
||||
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* Version 1.22e.
|
||||
|
||||
* configure.in: Don't use AM_MAINTAINER_MODE or
|
||||
AC_PATH_PROG(PERL, perl).
|
||||
(jm_PERL): Use this.
|
||||
|
||||
1998-02-04 Jim Meyering <meyering@eng.ascend.com>
|
||||
|
||||
* tests/Makefile.am.in (EXTRA_DIST): Remove mk-script.pl.
|
||||
(mk_script): Set to ../mk-script.
|
||||
(x-tests): Use `$(PERL) -w -- $(mk_script)', not ./mk-script.
|
||||
Remove @MAINT@ cruft.
|
||||
(Makefile.am): Likewise.
|
||||
Remove @MAINT@ cruft. Now `missing' will explain the failure
|
||||
when people don't have Perl yet modify a file whose rebuilding
|
||||
would lead to the use of Perl.
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Add mk-script.
|
||||
* tests/*/mk-script.pl: Remove files.
|
||||
|
||||
* GNUmakefile: New file.
|
||||
* Makefile.am (EXTRA_DIST): Add GNUmakefile.
|
||||
Don't include Makefile.maint from here. It's included from GNUmakefile.
|
||||
|
||||
1998-01-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* configure.in (AC_LFS): Put before anything that can affect or use
|
||||
CPPFLAGS, LDFLAGS, or LIBS.
|
||||
|
||||
1998-01-25 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Makefile.maint: New file.
|
||||
* Makefile.am: Move rules common to textutils, fileutils, sh-utils
|
||||
into Makefile.maint.
|
||||
Include Makefile.maint.
|
||||
(EXTRA_DIST): Add Makefile.maint.
|
||||
|
||||
* src/cat.c (cat): Convert comma-expressions to pairs of
|
||||
semicolon-terminated stmts.
|
||||
Add braces around compound if/else stmts.
|
||||
|
||||
1998-01-24 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/tail.c (parse_obsolescent_option): Do not interpret `-f -n 1 ...'
|
||||
as obsolescent options.
|
||||
Accept new option: --sleep-interval=SECONDS (-s).
|
||||
FIXME: document new option in textutils.texi.
|
||||
(parse_options): Recognize it.
|
||||
(usage): Describe it.
|
||||
(tail_forever): Use it.
|
||||
(dump_remainder): Use it.
|
||||
* tests/tail/Test.pm (f-1): Add test for option-processing of `-f -n 1'.
|
||||
|
||||
* tests/cut/: Rename directory to remove `-test' suffix.
|
||||
* tests/join/: Likewise.
|
||||
* tests/md5sum/: Likewise.
|
||||
* tests/pr/: Likewise.
|
||||
* tests/sort/: Likewise.
|
||||
* tests/tr/: Likewise.
|
||||
* configure.in (AC_OUTPUT): Reflect renamings in tests/.
|
||||
* tests/Makefile.am (SUBDIRS): Reflect renamings in tests/.
|
||||
|
||||
* src/system.h (TYPE_MINIMUM): Add extra outer cast to work around
|
||||
bug in Cray C 5.0.3.0 when T == time_t.
|
||||
|
||||
1998-01-18 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/sort.c (strncoll, strncoll_s2_readonly, look_for_fraction,
|
||||
numcompare): Remove the `unsigned' from some `unsigned char*'
|
||||
parameter types. Add casts via UCHAR where necessary to avoid
|
||||
problems with unwanted sign extension. Based on a patch from
|
||||
Kaveh Ghazi to appease Irix4's cc compiler.
|
||||
|
||||
1998-01-17 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/split.c (next_file_name): Rewrite. This removes an artificial
|
||||
limit (albeit already high, at INT_MAX :-) on the number of files
|
||||
split could create. Reported by Ralf W. Stephan.
|
||||
|
||||
1998-01-16 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/sort.c: (mergefps): Add braces to avoid ambiguous `else' stmt.
|
||||
(nls_set_fraction): Likewise.
|
||||
|
||||
* src/sort.c: Guard inclusion of langinfo.h also with HAVE_LANGINFO_H,
|
||||
for Irix-4.0.5. From Kaveh Ghazi.
|
||||
* configure.in: Check for langinfo.h.
|
||||
|
||||
* lib/getline.c: Make PARAMS-defining conditionals consistent.
|
||||
* lib/linebuffer.h: Likewise.
|
||||
* lib/long-options.h: Likewise.
|
||||
* lib/memcasecmp.h: Likewise.
|
||||
* lib/xstrtod.h: Likewise.
|
||||
* lib/xstrtol.h: Likewise.
|
||||
Suggestion from Kaveh Ghazi.
|
||||
|
||||
* tests/head/Test.pm (fail-0): Disable test. It depends on
|
||||
sizeof(long) being 32 bits. Reported by Kaveh Ghazi.
|
||||
|
||||
1998-01-10 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* Version 1.22d.
|
||||
|
||||
* src/system.h [HAVE_LIMITS_H]: Include limits.h
|
||||
(TYPE_SIGNED): Define.
|
||||
(TYPE_MINIMUM): Define.
|
||||
(TYPE_MAXIMUM): Define.
|
||||
(CHAR_BIT): Define.
|
||||
(SCHAR_MAX): Define.
|
||||
(UCHAR_MAX): Define.
|
||||
(SHRT_MAX): Define.
|
||||
(INT_MAX): Define.
|
||||
(UINT_MAX): Define.
|
||||
(LONG_MAX): Define.
|
||||
(ULONG_MAX): Define.
|
||||
* src/*.c: Remove definitions of those symbols.
|
||||
|
||||
* src/csplit.c: Move inclusion of regex.h/rx.h to follow system.h
|
||||
since it now includes limit.h which defines RE_DUP_MAX.
|
||||
* src/nl.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
|
||||
* lib/xstrtol.c (bkm_scale): Renamed from BKM_SCALE.
|
||||
Rewrite macro as function. Return a value. Update caller.
|
||||
Cast __ZLONG_MAX `__unsigned long int' before casting to double to
|
||||
avoid SunOS /bin/cc compiler bug.
|
||||
|
||||
1998-01-08 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* src/tac-pipe.c: New file. But not yet used.
|
||||
* src/Makefile.am (EXTRA_DIST): Add tac-pipe.c.
|
||||
|
||||
* src/tac.c (tac_stream): Don't perform arithmetic on now-void* pointer
|
||||
result of xrealloc (until recently it was char*).
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add nl_langinfo.
|
||||
* src/sort.c (inittables): Add && HAVE_NL_LANGINFO to the #if-test
|
||||
guarding the nls month-checking code.
|
||||
(nls_numeric_format): Remove unnecessary (and error-evoking w/SunOS' cc)
|
||||
`unsigned' from dcls of text and lim.
|
||||
(main): Cast lconvp->grouping to `unsigned char*' to appease SunOS's cc.
|
||||
|
||||
1998-01-03 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* lib/Makefile.am (AUTOMAKE_OPTIONS): Define to ../src/ansi2knr.
|
||||
|
||||
* configure.in: Convert the .o suffix on files in LIBOBJS to $U.o so
|
||||
those files will be built via the ANSI2KNR-filtering rules if necessary.
|
||||
|
||||
1997-12-25 Jim Meyering <meyering@na-net.ornl.gov>
|
||||
|
||||
* configure.in: Remove AC_DEFINE of _GNU_SOURCE.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Changes in release 1.23
|
||||
[1.22e]
|
||||
* remove maintainer mode
|
||||
[1.22d]
|
||||
* wc accepts new option: --max-line-length (-L)
|
||||
* sort can sort according to your locale if your C library supports that
|
||||
|
||||
116
src/cat.c
116
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 88, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 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
|
||||
@@ -381,60 +381,76 @@ cat (
|
||||
/* If quoting, i.e. at least one of -v, -e, or -t specified,
|
||||
scan for chars that need conversion. */
|
||||
if (quote)
|
||||
for (;;)
|
||||
{
|
||||
if (ch >= 32)
|
||||
{
|
||||
if (ch < 127)
|
||||
*bpout++ = ch;
|
||||
else if (ch == 127)
|
||||
*bpout++ = '^',
|
||||
*bpout++ = '?';
|
||||
else
|
||||
{
|
||||
*bpout++ = 'M',
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (ch >= 32)
|
||||
{
|
||||
if (ch < 127)
|
||||
*bpout++ = ch;
|
||||
else if (ch == 127)
|
||||
{
|
||||
*bpout++ = '^';
|
||||
*bpout++ = '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
*bpout++ = 'M';
|
||||
*bpout++ = '-';
|
||||
if (ch >= 128 + 32)
|
||||
if (ch < 128 + 127)
|
||||
*bpout++ = ch - 128;
|
||||
if (ch >= 128 + 32)
|
||||
{
|
||||
if (ch < 128 + 127)
|
||||
*bpout++ = ch - 128;
|
||||
else
|
||||
{
|
||||
*bpout++ = '^';
|
||||
*bpout++ = '?';
|
||||
}
|
||||
}
|
||||
else
|
||||
*bpout++ = '^',
|
||||
*bpout++ = '?';
|
||||
else
|
||||
*bpout++ = '^',
|
||||
*bpout++ = ch - 128 + 64;
|
||||
}
|
||||
}
|
||||
else if (ch == '\t' && output_tabs)
|
||||
*bpout++ = '\t';
|
||||
else if (ch == '\n')
|
||||
{
|
||||
newlines = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
*bpout++ = '^',
|
||||
*bpout++ = ch + 64;
|
||||
{
|
||||
*bpout++ = '^';
|
||||
*bpout++ = ch - 128 + 64;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ch == '\t' && output_tabs)
|
||||
*bpout++ = '\t';
|
||||
else if (ch == '\n')
|
||||
{
|
||||
newlines = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*bpout++ = '^';
|
||||
*bpout++ = ch + 64;
|
||||
}
|
||||
|
||||
ch = *bpin++;
|
||||
}
|
||||
ch = *bpin++;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Not quoting, neither of -v, -e, or -t specified. */
|
||||
for (;;)
|
||||
{
|
||||
if (ch == '\t' && !output_tabs)
|
||||
*bpout++ = '^',
|
||||
*bpout++ = ch + 64;
|
||||
else if (ch != '\n')
|
||||
*bpout++ = ch;
|
||||
else
|
||||
{
|
||||
newlines = -1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
/* Not quoting, neither of -v, -e, or -t specified. */
|
||||
for (;;)
|
||||
{
|
||||
if (ch == '\t' && !output_tabs)
|
||||
{
|
||||
*bpout++ = '^';
|
||||
*bpout++ = ch + 64;
|
||||
}
|
||||
else if (ch != '\n')
|
||||
*bpout++ = ch;
|
||||
else
|
||||
{
|
||||
newlines = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
ch = *bpin++;
|
||||
}
|
||||
ch = *bpin++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
43
src/chgrp.c
43
src/chgrp.c
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 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
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "group-member.h"
|
||||
@@ -38,11 +39,11 @@
|
||||
struct group *getgrnam ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ENDGRENT
|
||||
#if ! HAVE_ENDGRENT
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
#if HAVE_LCHOWN
|
||||
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
|
||||
#else
|
||||
# define LCHOWN(FILE, OWNER, GROUP) 1
|
||||
@@ -55,6 +56,18 @@ enum Change_status
|
||||
CH_NO_CHANGE_REQUESTED
|
||||
};
|
||||
|
||||
enum Verbosity
|
||||
{
|
||||
/* Print a message for each file that is processed. */
|
||||
V_high,
|
||||
|
||||
/* Print a message for each file whose attributes we change. */
|
||||
V_changes_only,
|
||||
|
||||
/* Do not be verbose. This is the default. */
|
||||
V_off
|
||||
};
|
||||
|
||||
static int change_dir_group PARAMS ((const char *dir, int group,
|
||||
const struct stat *statp));
|
||||
|
||||
@@ -71,11 +84,8 @@ static int recurse;
|
||||
/* If nonzero, force silence (no error messages). */
|
||||
static int force_silent;
|
||||
|
||||
/* If nonzero, describe the files we process. */
|
||||
static int verbose;
|
||||
|
||||
/* If nonzero, describe only owners or groups that change. */
|
||||
static int changes_only;
|
||||
/* Level of verbosity. */
|
||||
static enum Verbosity verbosity = V_off;
|
||||
|
||||
/* The name of the group to which ownership of the files is being given. */
|
||||
static const char *groupname;
|
||||
@@ -188,7 +198,7 @@ change_file_group (const char *file, int group)
|
||||
else
|
||||
fail = chown (file, (uid_t) -1, group);
|
||||
|
||||
if (verbose || (changes_only && !fail))
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
describe_change (file, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
|
||||
if (fail)
|
||||
@@ -215,7 +225,7 @@ change_file_group (const char *file, int group)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (verbose && changes_only == 0)
|
||||
else if (verbosity == V_high)
|
||||
{
|
||||
describe_change (file, CH_NO_CHANGE_REQUESTED);
|
||||
}
|
||||
@@ -305,6 +315,7 @@ Change the group membership of each FILE to GROUP.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -321,7 +332,7 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
|
||||
{
|
||||
@@ -336,8 +347,7 @@ main (int argc, char **argv)
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
verbosity = V_changes_only;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
@@ -346,7 +356,7 @@ main (int argc, char **argv)
|
||||
change_symlinks = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
verbosity = V_high;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
@@ -356,6 +366,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -368,7 +379,7 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCHOWN
|
||||
#if ! HAVE_LCHOWN
|
||||
if (change_symlinks)
|
||||
{
|
||||
error (1, 0, _("--no-dereference (-h) is not supported on this system"));
|
||||
@@ -389,5 +400,7 @@ main (int argc, char **argv)
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (argv[optind], group);
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
36
src/chmod.c
36
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 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
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "modechange.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
|
||||
@@ -34,6 +35,18 @@ enum Change_status
|
||||
CH_NO_CHANGE_REQUESTED
|
||||
};
|
||||
|
||||
enum Verbosity
|
||||
{
|
||||
/* Print a message for each file that is processed. */
|
||||
V_high,
|
||||
|
||||
/* Print a message for each file whose attributes we change. */
|
||||
V_changes_only,
|
||||
|
||||
/* Do not be verbose. This is the default. */
|
||||
V_off
|
||||
};
|
||||
|
||||
void mode_string ();
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
@@ -50,16 +63,13 @@ static int recurse;
|
||||
/* If nonzero, force silence (no error messages). */
|
||||
static int force_silent;
|
||||
|
||||
/* If nonzero, describe the modes we set. */
|
||||
static int verbose;
|
||||
/* Level of verbosity. */
|
||||
static enum Verbosity verbosity = V_off;
|
||||
|
||||
/* The argument to the --reference option. Use the owner and group IDs
|
||||
of this file. This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, describe only modes that change. */
|
||||
static int changes_only;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
@@ -148,7 +158,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
{
|
||||
int fail = chmod (file, (int) newmode);
|
||||
|
||||
if (verbose || (changes_only && !fail))
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
|
||||
if (fail)
|
||||
@@ -158,7 +168,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
errors = 1;
|
||||
}
|
||||
}
|
||||
else if (verbose && changes_only == 0)
|
||||
else if (verbosity == V_high)
|
||||
describe_change (file, newmode, CH_NO_CHANGE_REQUESTED);
|
||||
|
||||
if (recurse && S_ISDIR (file_stats.st_mode))
|
||||
@@ -247,6 +257,7 @@ Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n\
|
||||
one or more of the letters rwxXstugo.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -268,7 +279,7 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -307,13 +318,13 @@ main (int argc, char **argv)
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
changes_only = 1;
|
||||
verbosity = V_changes_only;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
verbosity = V_high;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
@@ -323,6 +334,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chmod (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -354,5 +366,7 @@ main (int argc, char **argv)
|
||||
errors |= change_file_mode (argv[optind], changes, 1);
|
||||
}
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
43
src/chown.c
43
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 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
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
|
||||
@@ -45,11 +46,11 @@ struct group *getgrnam ();
|
||||
struct group *getgrgid ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ENDPWENT
|
||||
#if ! HAVE_ENDPWENT
|
||||
# define endpwent() ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
#if HAVE_LCHOWN
|
||||
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
|
||||
#else
|
||||
# define LCHOWN(FILE, OWNER, GROUP) 1
|
||||
@@ -65,6 +66,18 @@ enum Change_status
|
||||
CH_NO_CHANGE_REQUESTED
|
||||
};
|
||||
|
||||
enum Verbosity
|
||||
{
|
||||
/* Print a message for each file that is processed. */
|
||||
V_high,
|
||||
|
||||
/* Print a message for each file whose attributes we change. */
|
||||
V_changes_only,
|
||||
|
||||
/* Do not be verbose. This is the default. */
|
||||
V_off
|
||||
};
|
||||
|
||||
static int change_dir_owner PARAMS ((const char *dir, uid_t user, gid_t group,
|
||||
struct stat *statp));
|
||||
|
||||
@@ -81,11 +94,8 @@ static int recurse;
|
||||
/* If nonzero, force silence (no error messages). */
|
||||
static int force_silent;
|
||||
|
||||
/* If nonzero, describe the files we process. */
|
||||
static int verbose;
|
||||
|
||||
/* If nonzero, describe only owners or groups that change. */
|
||||
static int changes_only;
|
||||
/* Level of verbosity. */
|
||||
static enum Verbosity verbosity = V_off;
|
||||
|
||||
/* The name of the user to which ownership of the files is being given. */
|
||||
static char *username;
|
||||
@@ -175,7 +185,7 @@ change_file_owner (const char *file, uid_t user, gid_t group)
|
||||
else
|
||||
fail = chown (file, newuser, newgroup);
|
||||
|
||||
if (verbose || (changes_only && !fail))
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
describe_change (file, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
|
||||
if (fail)
|
||||
@@ -185,7 +195,7 @@ change_file_owner (const char *file, uid_t user, gid_t group)
|
||||
errors = 1;
|
||||
}
|
||||
}
|
||||
else if (verbose && changes_only == 0)
|
||||
else if (verbosity == V_high)
|
||||
{
|
||||
describe_change (file, CH_NO_CHANGE_REQUESTED);
|
||||
}
|
||||
@@ -280,6 +290,7 @@ Owner is unchanged if missing. Group is unchanged if missing, but changed\n\
|
||||
to login group if implied by a period. A colon may replace the period.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -298,7 +309,7 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
|
||||
{
|
||||
@@ -313,8 +324,7 @@ main (int argc, char **argv)
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
verbosity = V_changes_only;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
@@ -323,7 +333,7 @@ main (int argc, char **argv)
|
||||
change_symlinks = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
verbosity = V_high;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
@@ -333,6 +343,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chown (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -345,7 +356,7 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCHOWN
|
||||
#if ! HAVE_LCHOWN
|
||||
if (change_symlinks)
|
||||
{
|
||||
error (1, 0, _("--no-dereference (-h) is not supported on this system"));
|
||||
@@ -379,5 +390,7 @@ main (int argc, char **argv)
|
||||
errors |= change_file_owner (argv[optind], user, group);
|
||||
}
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
63
src/copy.c
63
src/copy.c
@@ -25,8 +25,9 @@
|
||||
#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. \
|
||||
But root probably wants to know, e.g. if NFS disallows it. */ \
|
||||
&& (errno != EPERM || x->myeuid == 0))
|
||||
But root probably wants to know, e.g. if NFS disallows it, \
|
||||
or if the target system doesn't support file ownership. */ \
|
||||
&& ((errno != EPERM && errno != EINVAL) || x->myeuid == 0))
|
||||
|
||||
struct dir_list
|
||||
{
|
||||
@@ -42,7 +43,8 @@ int yesno ();
|
||||
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
|
||||
int new_dst, dev_t device,
|
||||
struct dir_list *ancestors,
|
||||
const struct cp_options *x));
|
||||
const struct cp_options *x,
|
||||
int *copy_into_self));
|
||||
|
||||
/* The invocation name of this program. */
|
||||
extern char *program_name;
|
||||
@@ -63,17 +65,17 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
|
||||
copy the contents to DST_PATH_IN. NEW_DST is nonzero if
|
||||
DST_PATH_IN is a directory that was created previously in the
|
||||
recursion. SRC_SB and ANCESTORS describe SRC_PATH_IN.
|
||||
Set *COPY_INTO_SELF to nonzero if SRC_PATH_IN is a parent of
|
||||
(or the same as) DST_PATH_IN; otherwise, set it to zero.
|
||||
Return 0 if successful, -1 if an error occurs. */
|
||||
|
||||
static int
|
||||
copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
const struct stat *src_sb, struct dir_list *ancestors,
|
||||
const struct cp_options *x)
|
||||
const struct cp_options *x, int *copy_into_self)
|
||||
{
|
||||
char *name_space;
|
||||
char *namep;
|
||||
char *src_path;
|
||||
char *dst_path;
|
||||
int ret = 0;
|
||||
|
||||
errno = 0;
|
||||
@@ -92,13 +94,16 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
namep = name_space;
|
||||
while (*namep != '\0')
|
||||
{
|
||||
src_path = path_concat (src_path_in, namep, NULL);
|
||||
dst_path = path_concat (dst_path_in, namep, NULL);
|
||||
int local_copy_into_self;
|
||||
char *src_path = path_concat (src_path_in, namep, NULL);
|
||||
char *dst_path = path_concat (dst_path_in, namep, NULL);
|
||||
|
||||
if (dst_path == NULL || src_path == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
ret |= copy_internal (src_path, dst_path, new_dst, src_sb->st_dev,
|
||||
ancestors, x);
|
||||
ancestors, x, &local_copy_into_self);
|
||||
*copy_into_self |= local_copy_into_self;
|
||||
|
||||
/* Free the memory for `src_path'. The memory for `dst_path'
|
||||
cannot be deallocated, since it is used to create multiple
|
||||
@@ -165,7 +170,7 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
|
||||
buf_size = ST_BLKSIZE (sb);
|
||||
|
||||
#ifdef HAVE_ST_BLOCKS
|
||||
#if HAVE_ST_BLOCKS
|
||||
if (sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
|
||||
{
|
||||
/* Use a heuristic to determine whether SRC_PATH contains any
|
||||
@@ -262,7 +267,7 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
|
||||
if (last_write_made_hole)
|
||||
{
|
||||
#ifdef HAVE_FTRUNCATE
|
||||
#if HAVE_FTRUNCATE
|
||||
/* Write a null character and truncate it again. */
|
||||
if (full_write (dest_desc, "", 1) < 0
|
||||
|| ftruncate (dest_desc, n_read_total) < 0)
|
||||
@@ -300,12 +305,14 @@ ret2:
|
||||
number of the parent directory, or 0 if the parent of this file is
|
||||
not known. ANCESTORS points to a linked, null terminated list of
|
||||
devices and inodes of parent directories of SRC_PATH.
|
||||
Set *COPY_INTO_SELF to nonzero if SRC_PATH is a parent of (or the
|
||||
same as) DST_PATH; otherwise, set it to zero.
|
||||
Return 0 if successful, 1 if an error occurs. */
|
||||
|
||||
static int
|
||||
copy_internal (const char *src_path, const char *dst_path,
|
||||
int new_dst, dev_t device, struct dir_list *ancestors,
|
||||
const struct cp_options *x)
|
||||
const struct cp_options *x, int *copy_into_self)
|
||||
{
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
@@ -315,6 +322,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
char *dst_backup = NULL;
|
||||
int fix_mode = 0;
|
||||
|
||||
*copy_into_self = 0;
|
||||
if ((*(x->xstat)) (src_path, &src_sb))
|
||||
{
|
||||
error (0, errno, "%s", src_path);
|
||||
@@ -334,7 +342,10 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
/* Did we just create this file? */
|
||||
|
||||
if (earlier_file == &new_file)
|
||||
return 0;
|
||||
{
|
||||
*copy_into_self = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
src_mode = src_sb.st_mode;
|
||||
src_type = src_sb.st_mode;
|
||||
@@ -422,9 +433,10 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (backup_type != none && !S_ISDIR (dst_sb.st_mode))
|
||||
if (x->backup_type != none && !S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dst_path);
|
||||
char *tmp_backup = find_backup_file_name (dst_path,
|
||||
x->backup_type);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
@@ -550,7 +562,8 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|
||||
/* Copy the contents of the directory. */
|
||||
|
||||
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x))
|
||||
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x,
|
||||
copy_into_self))
|
||||
return 1;
|
||||
}
|
||||
#ifdef S_ISLNK
|
||||
@@ -646,7 +659,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
{
|
||||
/* Preserve the owner and group of the just-`copied'
|
||||
symbolic link, if possible. */
|
||||
# ifdef HAVE_LCHOWN
|
||||
# if HAVE_LCHOWN
|
||||
if (DO_CHOWN (lchown, dst_path, src_sb.st_uid, src_sb.st_gid))
|
||||
{
|
||||
error (0, errno, _("preserving ownership for %s"), dst_path);
|
||||
@@ -755,10 +768,12 @@ valid_options (const struct cp_options *co)
|
||||
{
|
||||
assert (co != NULL);
|
||||
|
||||
assert (VALID_BACKUP_TYPE (co->backup_type));
|
||||
|
||||
/* FIXME: make sure xstat and dereference are consistent. */
|
||||
assert (co->xstat);
|
||||
|
||||
assert (co->sparse_mode != SPARSE_UNUSED);
|
||||
assert (VALID_SPARSE_MODE (co->sparse_mode));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -766,15 +781,17 @@ valid_options (const struct cp_options *co)
|
||||
any type. NONEXISTENT_DST should be nonzero if the file DST_PATH
|
||||
is known not to exist (e.g., because its parent directory was just
|
||||
created); NONEXISTENT_DST should be zero if DST_PATH might already
|
||||
exist. DEVICE is the device number of the parent directory of
|
||||
DST_PATH, or 0 if the parent of this file is not known.
|
||||
OPTIONS is ... FIXME-describe
|
||||
exist. OPTIONS is ... FIXME-describe
|
||||
Set *COPY_INTO_SELF to nonzero if SRC_PATH is a parent of (or the
|
||||
same as) DST_PATH; otherwise, set it to zero.
|
||||
Return 0 if successful, 1 if an error occurs. */
|
||||
|
||||
int
|
||||
copy (const char *src_path, const char *dst_path,
|
||||
int nonexistent_dst, const struct cp_options *options)
|
||||
int nonexistent_dst, const struct cp_options *options,
|
||||
int *copy_into_self)
|
||||
{
|
||||
assert (valid_options (options));
|
||||
return copy_internal (src_path, dst_path, nonexistent_dst, 0, NULL, options);
|
||||
return copy_internal (src_path, dst_path, nonexistent_dst, 0, NULL,
|
||||
options, copy_into_self);
|
||||
}
|
||||
|
||||
10
src/copy.h
10
src/copy.h
@@ -22,8 +22,15 @@ enum Sparse_type
|
||||
SPARSE_ALWAYS
|
||||
};
|
||||
|
||||
# define VALID_SPARSE_MODE(Mode) \
|
||||
((Mode) == SPARSE_NEVER \
|
||||
|| (Mode) == SPARSE_AUTO \
|
||||
|| (Mode) == SPARSE_ALWAYS)
|
||||
|
||||
struct cp_options
|
||||
{
|
||||
enum backup_type backup_type;
|
||||
|
||||
/* If nonzero, copy all files except (directories and, if not dereferencing
|
||||
them, symbolic links,) as if they were regular files. */
|
||||
int copy_as_regular;
|
||||
@@ -87,6 +94,7 @@ struct cp_options
|
||||
|
||||
int
|
||||
copy PARAMS ((const char *src_path, const char *dst_path,
|
||||
int nonexistent_dst, const struct cp_options *options));
|
||||
int nonexistent_dst, const struct cp_options *options,
|
||||
int *copy_into_self));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cp-hash.c -- file copying (hash search routines)
|
||||
Copyright (C) 89, 90, 91, 95, 1996, 1997 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
39
src/cp.c
39
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 95, 1996, 1997 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,7 +25,9 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* FIXME: uncomment for release
|
||||
#define NDEBUG
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include <getopt.h>
|
||||
@@ -33,6 +35,7 @@
|
||||
#include "backupfile.h"
|
||||
#include "argmatch.h"
|
||||
#include "path-concat.h"
|
||||
#include "closeout.h"
|
||||
#include "cp-hash.h"
|
||||
#include "copy.h"
|
||||
#include "error.h"
|
||||
@@ -176,6 +179,7 @@ options are given and SOURCE and DEST are the same name for an existing,\n\
|
||||
regular file.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -243,9 +247,10 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
}
|
||||
|
||||
/* If non-root uses -p, it's ok if we can't preserve ownership.
|
||||
But root probably wants to know, e.g. if NFS disallows it. */
|
||||
But root probably wants to know, e.g. if NFS disallows it,
|
||||
or if the target system doesn't support file ownership. */
|
||||
if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
|
||||
&& (errno != EPERM || myeuid == 0))
|
||||
&& ((errno != EPERM && errno != EINVAL) || myeuid == 0))
|
||||
{
|
||||
error (0, errno, _("preserving ownership for %s"), dst_path);
|
||||
return 1;
|
||||
@@ -480,7 +485,8 @@ do_copy (int argc, char **argv, const struct cp_options *x)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret |= copy (arg, dst_path, new_dst, x);
|
||||
int unused;
|
||||
ret |= copy (arg, dst_path, new_dst, x, &unused);
|
||||
forget_all ();
|
||||
|
||||
if (flag_path)
|
||||
@@ -501,6 +507,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
|
||||
{
|
||||
char *new_dest;
|
||||
char *source;
|
||||
int unused;
|
||||
struct stat source_stats;
|
||||
|
||||
if (flag_path)
|
||||
@@ -519,17 +526,22 @@ do_copy (int argc, char **argv, const struct cp_options *x)
|
||||
where SUFFIX is determined by any version control options used. */
|
||||
|
||||
if (x->force
|
||||
&& backup_type != none
|
||||
&& x->backup_type != none
|
||||
&& STREQ (source, dest)
|
||||
&& !new_dst && S_ISREG (sb.st_mode))
|
||||
{
|
||||
new_dest = find_backup_file_name (dest);
|
||||
/* Set backup_type to `none' so that the normal backup
|
||||
static struct cp_options x_tmp;
|
||||
|
||||
new_dest = find_backup_file_name (dest, x->backup_type);
|
||||
/* Set x->backup_type to `none' so that the normal backup
|
||||
mechanism is not used when performing the actual copy.
|
||||
backup_type must be set to `none' only *after* the above
|
||||
call to find_backup_file_name -- that function uses
|
||||
backup_type to determine the suffix it applies. */
|
||||
backup_type = none;
|
||||
x_tmp = *x;
|
||||
x_tmp.backup_type = none;
|
||||
x = &x_tmp;
|
||||
|
||||
if (new_dest == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
@@ -562,7 +574,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
|
||||
new_dest = dest;
|
||||
}
|
||||
|
||||
return copy (source, new_dest, new_dst, x);
|
||||
return copy (source, new_dest, new_dst, x, &unused);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -572,6 +584,9 @@ is not a directory"),
|
||||
dest);
|
||||
usage (1);
|
||||
}
|
||||
|
||||
/* unreachable */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -728,6 +743,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -740,8 +756,7 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
x.backup_type = (make_backups ? get_version (version) : none);
|
||||
|
||||
if (x.preserve == 1)
|
||||
x.umask_kill = 0777777;
|
||||
@@ -760,5 +775,7 @@ main (int argc, char **argv)
|
||||
|
||||
exit_status |= do_copy (argc, argv, &x);
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
15
src/csplit.c
15
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 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
|
||||
@@ -29,24 +29,15 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif /* HAVE_LIMITS_H */
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
#include "system.h"
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
#else
|
||||
# include <rx.h>
|
||||
#endif
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
@@ -142,7 +142,7 @@ batch_convert (const char *input_filename, const char *format)
|
||||
{
|
||||
size_t tz_len = strlen (initial_TZ);
|
||||
char *buf = xmalloc (3 + tz_len + 1);
|
||||
mempcpy (mempcpy (buf, "TZ=", 3), initial_TZ, tz_len + 1);
|
||||
memcpy (mempcpy (buf, "TZ=", 3), initial_TZ, tz_len + 1);
|
||||
initial_TZ = buf;
|
||||
}
|
||||
}
|
||||
|
||||
70
src/dcgen
Executable file
70
src/dcgen
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
eval 'exec /p/bin/perl -S $0 ${1+"$@"}'
|
||||
if 0;
|
||||
|
||||
# dcgen -- generate C declarations of arrays of lines and line lengths
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
# written by Jim Meyering
|
||||
|
||||
# If you uncomment the following lines, you should also do
|
||||
# s/chop/chomp and s/local/my/.
|
||||
#require 5.002;
|
||||
#use strict;
|
||||
|
||||
# Convert an arbitrary file to dcl of two arrays.
|
||||
# One of lines, the other of lengths.
|
||||
|
||||
local $prefix = 'G_';
|
||||
|
||||
local @line;
|
||||
while (<>)
|
||||
{
|
||||
chop;
|
||||
push (@line, $_);
|
||||
}
|
||||
|
||||
local $n = @line;
|
||||
print "#define ${prefix}N_LINES $n\n\n";
|
||||
|
||||
local $indent = ' ';
|
||||
print "const size_t ${prefix}line_length[${prefix}N_LINES] =\n{\n$indent";
|
||||
local $ind = $indent;
|
||||
local $i;
|
||||
for ($i = 0; $i < @line; $i++)
|
||||
{
|
||||
local $comma = ($i < @line - 1 ? ',' : '');
|
||||
$ind = '' if $i == @line - 1;
|
||||
local $sep = ($i && $i % 18 == 0 || $i == @line - 1 ? "\n$ind" : ' ');
|
||||
print length ($line[$i]), $comma, $sep;
|
||||
}
|
||||
print "};\n\n";
|
||||
|
||||
print "const char *const ${prefix}line[${prefix}N_LINES] =\n{\n";
|
||||
while (1)
|
||||
{
|
||||
$_ = shift (@line);
|
||||
local $comma = (@line ? ',' : '');
|
||||
print "$indent\"$_\"$comma\n";
|
||||
last if !@line;
|
||||
}
|
||||
print "};\n";
|
||||
|
||||
exit (0);
|
||||
70
src/df.c
70
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 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
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "fsusage.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
|
||||
@@ -140,7 +141,7 @@ print_header (void)
|
||||
printf (" ");
|
||||
|
||||
if (inode_format)
|
||||
printf (" Inodes IUsed IFree %%IUsed");
|
||||
printf (" Inodes IUsed IFree %%IUsed ");
|
||||
else
|
||||
if (output_units == 1024 * 1024)
|
||||
printf (" MB-blocks Used Available Capacity");
|
||||
@@ -184,6 +185,13 @@ excluded_fstype (const char *fstype)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
return n == -1 ? "-" : human_readable (n, buf, from_units, to_units, base);
|
||||
}
|
||||
|
||||
/* Display a space listing for the disk device with absolute path DISK.
|
||||
If MOUNT_POINT is non-NULL, it is the path of the root of the
|
||||
filesystem on DISK.
|
||||
@@ -234,23 +242,28 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
double inodes_percent_used;
|
||||
uintmax_t inodes_used;
|
||||
|
||||
if (fsu.fsu_files == 0)
|
||||
if (fsu.fsu_files == -1 || fsu.fsu_files < fsu.fsu_ffree)
|
||||
{
|
||||
inodes_used = 0;
|
||||
fsu.fsu_ffree = 0;
|
||||
inodes_percent_used = 0;
|
||||
inodes_used = -1;
|
||||
inodes_percent_used = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
inodes_used = fsu.fsu_files - fsu.fsu_ffree;
|
||||
inodes_percent_used = inodes_used * 100.0 / fsu.fsu_files;
|
||||
inodes_percent_used =
|
||||
(fsu.fsu_files == 0 ? 0
|
||||
: inodes_used * 100.0 / fsu.fsu_files);
|
||||
}
|
||||
|
||||
printf (" %7s %7s %7s %5.0f%%",
|
||||
human_readable (fsu.fsu_files, buf[0], 1, 1, human_readable_base),
|
||||
human_readable (inodes_used, buf[1], 1, 1, human_readable_base),
|
||||
human_readable (fsu.fsu_ffree, buf[2], 1, 1, human_readable_base),
|
||||
inodes_percent_used);
|
||||
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));
|
||||
|
||||
if (inodes_percent_used < 0)
|
||||
printf (" - ");
|
||||
else
|
||||
printf (" %5.0f%%", inodes_percent_used);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -259,27 +272,31 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
|
||||
double blocks_percent_used;
|
||||
uintmax_t blocks_used;
|
||||
|
||||
if (fsu.fsu_blocks == 0)
|
||||
if (fsu.fsu_blocks == -1 || fsu.fsu_blocks < fsu.fsu_bfree)
|
||||
{
|
||||
blocks_used = 0;
|
||||
fsu.fsu_bavail = 0;
|
||||
blocks_percent_used = 0;
|
||||
blocks_used = -1;
|
||||
blocks_percent_used = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks_used = fsu.fsu_blocks - fsu.fsu_bfree;
|
||||
blocks_percent_used =
|
||||
blocks_used * 100.0 / (blocks_used + fsu.fsu_bavail);
|
||||
(fsu.fsu_bfree < fsu.fsu_bavail ? -1
|
||||
: (blocks_used + fsu.fsu_bavail) == 0 ? 0
|
||||
: blocks_used * 100.0 / (blocks_used + fsu.fsu_bavail));
|
||||
}
|
||||
|
||||
printf (" %*s %*s %*s %5.0f%% ",
|
||||
w, human_readable (fsu.fsu_blocks, buf[0], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
w, human_readable (blocks_used, buf[1], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
w, human_readable (fsu.fsu_bavail, buf[2], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
blocks_percent_used);
|
||||
printf (" %*s %*s %*s ",
|
||||
w, df_readable (fsu.fsu_blocks, buf[0], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
w, df_readable (blocks_used, buf[1], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base),
|
||||
w, df_readable (fsu.fsu_bavail, buf[2], fsu.fsu_blocksize,
|
||||
output_units, human_readable_base));
|
||||
if (blocks_percent_used < 0)
|
||||
printf (" - ");
|
||||
else
|
||||
printf (" %5.0f%% ", blocks_percent_used);
|
||||
}
|
||||
|
||||
if (mount_point)
|
||||
@@ -518,6 +535,7 @@ or all filesystems by default.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -625,6 +643,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("df (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -716,6 +735,7 @@ with the portable output format"));
|
||||
show_entry (argv[i], &stats[i - optind]);
|
||||
}
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1994, 1995, 1997 H. Peter Anvin
|
||||
Copyright (C) 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#include "system.h"
|
||||
#include "getline.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "dircolors.h"
|
||||
@@ -114,6 +115,7 @@ file types and extensions. Otherwise, a precompiled database is used.\n\
|
||||
For details on the format of these files, run `dircolors --print-database'.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
@@ -516,8 +518,7 @@ dircolors' internal database"));
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
close_stdout ();
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
6
src/du.c
6
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 88, 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 89, 90, 91, 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
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "exclude.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -238,6 +239,7 @@ Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -372,6 +374,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("du (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -405,6 +408,7 @@ main (int argc, char **argv)
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
|
||||
14
src/fmt.c
14
src/fmt.c
@@ -1,5 +1,5 @@
|
||||
/* GNU fmt -- simple text formatter.
|
||||
Copyright (C) 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
@@ -22,18 +22,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
/* Redefine. Otherwise, systems (Unicos for one) with headers that define
|
||||
it to be a type get syntax errors for the variable declaration below. */
|
||||
#define word unused_word_type
|
||||
|
||||
14
src/fold.c
14
src/fold.c
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 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
|
||||
@@ -26,18 +26,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
|
||||
10
src/id.c
10
src/id.c
@@ -1,5 +1,5 @@
|
||||
/* id -- print real and effective UIDs and GIDs
|
||||
Copyright (C) 1989-1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1995, 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
|
||||
@@ -215,6 +215,8 @@ print_group (int gid)
|
||||
printf ("%s", grp->gr_name);
|
||||
}
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
|
||||
static int
|
||||
xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
{
|
||||
@@ -249,6 +251,8 @@ xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
return fail;
|
||||
}
|
||||
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
|
||||
/* Print all of the distinct groups the user is in. */
|
||||
|
||||
static void
|
||||
@@ -281,7 +285,7 @@ print_group_list (const char *username)
|
||||
}
|
||||
free (groups);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
}
|
||||
|
||||
/* Print all of the info about the user's user and group IDs. */
|
||||
@@ -353,7 +357,7 @@ print_full_info (const char *username)
|
||||
}
|
||||
free (groups);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* install - copy files and set attributes
|
||||
Copyright (C) 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 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
|
||||
@@ -53,6 +53,11 @@
|
||||
This is different from the SunOS 4.0 install, which gives
|
||||
directories that it creates the default attributes.
|
||||
|
||||
-D
|
||||
Like the -d option, but a file is installed, along with the directory.
|
||||
Useful when installing into a new directory, and the install
|
||||
process doesn't properly comprehend making directories.
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
#ifdef _AIX
|
||||
@@ -70,6 +75,7 @@
|
||||
#include "backupfile.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -89,11 +95,11 @@ uid_t getuid ();
|
||||
gid_t getgid ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ENDGRENT
|
||||
#if ! HAVE_ENDGRENT
|
||||
# define endgrent() ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ENDPWENT
|
||||
#if ! HAVE_ENDPWENT
|
||||
# define endpwent() ((void) 0)
|
||||
#endif
|
||||
|
||||
@@ -112,6 +118,7 @@ gid_t getgid ();
|
||||
#endif
|
||||
|
||||
char *base_name ();
|
||||
char *dirname ();
|
||||
int safe_read ();
|
||||
int full_write ();
|
||||
int isdir ();
|
||||
@@ -121,6 +128,7 @@ static int change_timestamps PARAMS ((const char *from, const char *to));
|
||||
static int change_attributes PARAMS ((const char *path, int no_need_to_chown));
|
||||
static int copy_file PARAMS ((const char *from, const char *to,
|
||||
int *to_created));
|
||||
static int install_file_to_path PARAMS ((const char *from, const char *to));
|
||||
static int install_file_in_dir PARAMS ((const char *from, const char *to_dir));
|
||||
static int install_file_in_file PARAMS ((const char *from, const char *to));
|
||||
static void get_ids PARAMS ((void));
|
||||
@@ -130,6 +138,9 @@ static void usage PARAMS ((int status));
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* FIXME: document */
|
||||
enum backup_type backup_type;
|
||||
|
||||
/* The user name that will own the files, or NULL to make the owner
|
||||
the current user ID. */
|
||||
static char *owner_name;
|
||||
@@ -190,6 +201,7 @@ main (int argc, char **argv)
|
||||
char *symbolic_mode = NULL;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
int mkdir_and_install = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -205,12 +217,12 @@ main (int argc, char **argv)
|
||||
verbose = 0;
|
||||
umask (0);
|
||||
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (version)
|
||||
simple_backup_suffix = version;
|
||||
version = getenv ("VERSION_CONTROL");
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (version)
|
||||
simple_backup_suffix = version;
|
||||
version = getenv ("VERSION_CONTROL");
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcsdg:m:o:pvV:S:", long_options,
|
||||
while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pvV:S:", long_options,
|
||||
NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -228,6 +240,9 @@ main (int argc, char **argv)
|
||||
case 'd':
|
||||
dir_arg = 1;
|
||||
break;
|
||||
case 'D':
|
||||
mkdir_and_install = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
@@ -257,6 +272,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("install (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -268,8 +284,7 @@ main (int argc, char **argv)
|
||||
error (1, 0,
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
backup_type = (make_backups ? get_version (version) : none);
|
||||
|
||||
if (optind == argc || (optind == argc - 1 && !dir_arg))
|
||||
{
|
||||
@@ -301,8 +316,10 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
if (optind == argc - 2)
|
||||
{
|
||||
if (!isdir (argv[argc - 1]))
|
||||
{
|
||||
if (mkdir_and_install)
|
||||
errors = install_file_to_path (argv[argc - 2], argv[argc - 1]);
|
||||
else if (!isdir (argv[argc - 1]))
|
||||
errors = install_file_in_file (argv[argc - 2], argv[argc - 1]);
|
||||
else
|
||||
errors = install_file_in_dir (argv[argc - 2], argv[argc - 1]);
|
||||
@@ -318,9 +335,46 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
/* Copy file FROM onto file TO, creating any missing parent directories of TO.
|
||||
Return 0 if successful, 1 if an error occurs */
|
||||
|
||||
static int
|
||||
install_file_to_path (const char *from, const char *to)
|
||||
{
|
||||
char *dest_dir;
|
||||
int fail;
|
||||
|
||||
dest_dir = dirname (to);
|
||||
|
||||
/* check to make sure this is a path (not install a b ) */
|
||||
if (!STREQ (dest_dir, ".")
|
||||
&& !isdir (dest_dir))
|
||||
{
|
||||
/* FIXME: Note that it's a little kludgey (even dangerous) that we
|
||||
derive the permissions for parent directories from the permissions
|
||||
specfied for the file, but since this option is intended mainly to
|
||||
help installers when the distribution doesn't provide proper install
|
||||
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, mode, mode, owner_id, group_id, 0,
|
||||
(verbose ? _("creating directory `%s'") : NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = install_file_in_file (from, to);
|
||||
}
|
||||
|
||||
free (dest_dir);
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
/* Copy file FROM onto file TO and give TO the appropriate
|
||||
attributes.
|
||||
Return 0 if successful, 1 if an error occurs. */
|
||||
@@ -413,7 +467,7 @@ copy_file (const char *from, const char *to, int *to_created)
|
||||
/* The destination file exists. Try to back it up if required. */
|
||||
if (backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (to);
|
||||
char *tmp_backup = find_backup_file_name (to, backup_type);
|
||||
char *dst_backup;
|
||||
|
||||
if (tmp_backup == NULL)
|
||||
@@ -643,13 +697,16 @@ Usage: %s [OPTION]... SOURCE DEST (1st format)\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
printf (_("\
|
||||
In first two formats, copy SOURCE to DEST or multiple SOURCE(s) to\n\
|
||||
DIRECTORY, while setting permission modes and owner/group. In third\n\
|
||||
format, make all components of the given DIRECTORY(ies).\n\
|
||||
In the first two formats, copy SOURCE to DEST or multiple SOURCE(s) to\n\
|
||||
the existing DIRECTORY, while setting permission modes and owner/group.\n\
|
||||
In the third format, create all components of the given DIRECTORY(ies).\n\
|
||||
\n\
|
||||
-b, --backup make backup before removal\n\
|
||||
-c (ignored)\n\
|
||||
-d, --directory create [leading] directories, mandatory for 3rd format\n\
|
||||
-d, --directory treat all arguments as directory names; create all\n\
|
||||
components of the specified directories\n\
|
||||
-D create all leading components of DEST except the last,\n\
|
||||
then copy SOURCE to DEST; useful in the 1st format\n\
|
||||
-g, --group=GROUP set group ownership, instead of process' current group\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), instead of rwxr-xr-x\n\
|
||||
-o, --owner=OWNER set ownership (super-user only)\n\
|
||||
@@ -672,6 +729,7 @@ version control may be set with VERSION_CONTROL, values are:\n\
|
||||
never, simple always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
14
src/join.c
14
src/join.c
@@ -1,5 +1,5 @@
|
||||
/* join - join lines of two files on a common field
|
||||
Copyright (C) 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 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
|
||||
@@ -28,18 +28,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#if _LIBC || STDC_HEADERS
|
||||
# define TOLOWER(c) tolower (c)
|
||||
#else
|
||||
|
||||
49
src/ln.c
49
src/ln.c
@@ -1,5 +1,5 @@
|
||||
/* `ln' program to create links between files.
|
||||
Copyright (C) 86, 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 89, 90, 91, 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
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
int link (); /* Some systems don't declare this anywhere. */
|
||||
@@ -66,6 +67,9 @@ void strip_trailing_slashes ();
|
||||
/* The name by which the program was run, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* FIXME: document */
|
||||
enum backup_type backup_type;
|
||||
|
||||
/* A pointer to the function used to make links. This will point to either
|
||||
`link' or `symlink'. */
|
||||
static int (*linkfunc) ();
|
||||
@@ -265,7 +269,7 @@ do_link (const char *source, const char *dest)
|
||||
|
||||
if (backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dest);
|
||||
char *tmp_backup = find_backup_file_name (dest, backup_type);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
dest_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
@@ -322,26 +326,28 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... SOURCE [DEST]\n\
|
||||
or: %s [OPTION]... SOURCE... DIRECTORY\n\
|
||||
Usage: %s [OPTION]... TARGET [LINK_NAME]\n\
|
||||
or: %s [OPTION]... TARGET... DIRECTORY\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
printf (_("\
|
||||
Link SOURCE to DEST (. by default), or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
Makes hard links by default, symbolic links with -s.\n\
|
||||
Create a link to the specified TARGET with optional LINK_NAME. If there is\n\
|
||||
more than one TARGET, the last argument must be a directory; create links\n\
|
||||
in DIRECTORY to each TARGET. Create hard links by default, symbolic links\n\
|
||||
with --symbolic. When creating hard links, each TARGET must exist.\n\
|
||||
\n\
|
||||
-b, --backup make backups for removed files\n\
|
||||
-d, -F, --directory hard link directories (super-user only)\n\
|
||||
-f, --force remove existing destinations\n\
|
||||
-n, --no-dereference treat destination that is a symlink to a\n\
|
||||
directory as if it were a normal file\n\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-s, --symbolic make symbolic links instead of hard links\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-v, --verbose print name of each file before linking\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
-b, --backup make a backup of each existing destination file\n\
|
||||
-d, -F, --directory hard link directories (super-user only)\n\
|
||||
-f, --force remove existing destination files\n\
|
||||
-n, --no-dereference treat destination that is a symlink to a\n\
|
||||
directory as if it were a normal file\n\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-s, --symbolic make symbolic links instead of hard links\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-v, --verbose print name of each file before linking\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
"));
|
||||
printf (_("\
|
||||
@@ -353,6 +359,7 @@ version control may be set with VERSION_CONTROL, values are:\n\
|
||||
never, simple always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -429,6 +436,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("ln (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -441,8 +449,7 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
backup_type = (make_backups ? get_version (version) : none);
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (symbolic_link)
|
||||
@@ -499,5 +506,7 @@ main (int argc, char **argv)
|
||||
errors += do_link (argv[optind], to);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
close_stdout ();
|
||||
exit (errors != 0);
|
||||
}
|
||||
|
||||
339
src/ls.c
339
src/ls.c
@@ -1,5 +1,5 @@
|
||||
/* `dir', `vdir' and `ls' directory listing programs for GNU.
|
||||
Copyright (C) 85, 88, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 88, 90, 91, 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
|
||||
@@ -47,7 +47,7 @@
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#if HAVE_TERMIOS_H
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
@@ -65,11 +65,13 @@
|
||||
|
||||
#include "obstack.h"
|
||||
#include "ls.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "argmatch.h"
|
||||
#include "xstrtol.h"
|
||||
#include "strverscmp.h"
|
||||
#include "quotearg.h"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -138,7 +140,8 @@ void strip_trailing_slashes ();
|
||||
char *xstrdup ();
|
||||
void invalid_arg ();
|
||||
|
||||
static size_t quote_filename PARAMS ((FILE *out, const char *filename));
|
||||
static size_t quote_name PARAMS ((FILE *out, const char *name,
|
||||
struct quoting_options const *options));
|
||||
static char *make_link_path PARAMS ((const char *path, const char *linkname));
|
||||
static int compare_atime PARAMS ((const struct fileinfo *file1,
|
||||
const struct fileinfo *file2));
|
||||
@@ -330,20 +333,26 @@ static int output_units;
|
||||
static int dired;
|
||||
|
||||
/* `none' means don't mention the type of files.
|
||||
`all' means mention the types of all files.
|
||||
`not_programs' means do so except for executables.
|
||||
`classify' means mention file types and mark executables.
|
||||
`file_type' means mention only file types.
|
||||
|
||||
Controlled by -F and -p. */
|
||||
Controlled by -F, -p, and --indicator-style. */
|
||||
|
||||
enum indicator_style
|
||||
{
|
||||
none, /* default */
|
||||
all, /* -F */
|
||||
not_programs /* -p */
|
||||
none, /* --indicator-style=none */
|
||||
classify, /* -F, --indicator-style=classify */
|
||||
file_type /* -p, --indicator-style=file-type */
|
||||
};
|
||||
|
||||
static enum indicator_style indicator_style;
|
||||
|
||||
/* Names of indicator styles. */
|
||||
static char const *const indicator_style_args[] =
|
||||
{
|
||||
"none", "classify", "file-type", 0
|
||||
};
|
||||
|
||||
/* Nonzero means use colors to mark types. Also define the different
|
||||
colors as well as the stuff for the LS_COLORS environment variable.
|
||||
The LS_COLORS variable is now in a termcap-like format. */
|
||||
@@ -445,26 +454,14 @@ struct ignore_pattern
|
||||
|
||||
static struct ignore_pattern *ignore_patterns;
|
||||
|
||||
/* Nonzero means quote nongraphic chars in file names. -b */
|
||||
|
||||
static int quote_funny_chars;
|
||||
|
||||
/* Nonzero means output nongraphic chars in file names as `?'. -q */
|
||||
|
||||
static int qmark_funny_chars;
|
||||
|
||||
/* Nonzero means output each file name using C syntax for a string.
|
||||
Always accompanied by `quote_funny_chars'.
|
||||
This mode, together with -x or -C or -m,
|
||||
and without such frills as -F or -s,
|
||||
is guaranteed to make it possible for a program receiving
|
||||
the output to tell exactly what file names are present. -Q */
|
||||
/* Quoting options for file and dir name output. */
|
||||
|
||||
static int quote_as_string;
|
||||
|
||||
/* Nonzero means use shell style quoting; it is also unambiguous. -e */
|
||||
|
||||
static int quote_shell;
|
||||
static struct quoting_options *filename_quoting_options;
|
||||
static struct quoting_options *dirname_quoting_options;
|
||||
|
||||
/* The number of chars per hardware tab stop. Setting this to zero
|
||||
inhibits the use of TAB characters for separating columns. -T */
|
||||
@@ -521,12 +518,14 @@ static struct option const long_options[] =
|
||||
{"file-type", no_argument, 0, 'F'},
|
||||
{"si", no_argument, 0, 'H'},
|
||||
{"ignore", required_argument, 0, 'I'},
|
||||
{"indicator-style", required_argument, 0, 14},
|
||||
{"dereference", no_argument, 0, 'L'},
|
||||
{"literal", no_argument, 0, 'N'},
|
||||
{"quote-name", no_argument, 0, 'Q'},
|
||||
{"quote-shell", no_argument, 0, 'e'},
|
||||
{"quoting-style", required_argument, 0, 15},
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
{"format", required_argument, 0, 12},
|
||||
{"show-control-chars", no_argument, 0, 16},
|
||||
{"sort", required_argument, 0, 10},
|
||||
{"tabsize", required_argument, 0, 'T'},
|
||||
{"time", required_argument, 0, 11},
|
||||
@@ -650,11 +649,11 @@ static int max_idx;
|
||||
#define MIN_COLUMN_WIDTH 3
|
||||
|
||||
|
||||
/* Write to standard output the strings PREFIX and STYLE, followed by
|
||||
/* Write to standard output PREFIX, followed by the quoting style and
|
||||
a space-separated list of the integers stored in OS all on one line. */
|
||||
|
||||
static void
|
||||
dired_dump_obstack (const char *prefix, const char *style, struct obstack *os)
|
||||
dired_dump_obstack (const char *prefix, struct obstack *os)
|
||||
{
|
||||
int n_pos;
|
||||
|
||||
@@ -666,7 +665,6 @@ dired_dump_obstack (const char *prefix, const char *style, struct obstack *os)
|
||||
|
||||
pos = (size_t *) obstack_finish (os);
|
||||
fputs (prefix, stdout);
|
||||
fputs (style, stdout);
|
||||
for (i = 0; i < n_pos; i++)
|
||||
printf (" %d", (int) pos[i]);
|
||||
fputs ("\n", stdout);
|
||||
@@ -698,6 +696,7 @@ main (int argc, char **argv)
|
||||
(ls_mode == LS_LS ? "ls"
|
||||
: (ls_mode == LS_MULTI_COL ? "dir" : "vdir")),
|
||||
GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -773,18 +772,13 @@ main (int argc, char **argv)
|
||||
|
||||
if (dired && format == long_format)
|
||||
{
|
||||
const char *quoting_style = (quote_shell ? " -e"
|
||||
: quote_as_string ? " -Q"
|
||||
: quote_funny_chars ? " -b"
|
||||
: " -N");
|
||||
/* No need to free these since we're about to exit. */
|
||||
dired_dump_obstack ("//DIRED//", quoting_style, &dired_obstack);
|
||||
dired_dump_obstack ("//SUBDIRED//", quoting_style, &subdired_obstack);
|
||||
dired_dump_obstack ("//DIRED//", &dired_obstack);
|
||||
dired_dump_obstack ("//SUBDIRED//", &subdired_obstack);
|
||||
printf ("//DIRED-OPTIONS// --quoting-style=%s\n",
|
||||
quoting_style_args[get_quoting_style (filename_quoting_options)]);
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
/* Restore default color before exiting */
|
||||
if (print_with_color)
|
||||
{
|
||||
@@ -792,6 +786,7 @@ main (int argc, char **argv)
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
}
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -801,13 +796,12 @@ main (int argc, char **argv)
|
||||
static int
|
||||
decode_switches (int argc, char **argv)
|
||||
{
|
||||
register char *p;
|
||||
register char const *p;
|
||||
int c;
|
||||
int i;
|
||||
long int tmp_long;
|
||||
|
||||
qmark_funny_chars = 0;
|
||||
quote_funny_chars = 0;
|
||||
|
||||
/* initialize all switches to default settings */
|
||||
|
||||
@@ -816,13 +810,13 @@ decode_switches (int argc, char **argv)
|
||||
case LS_MULTI_COL:
|
||||
/* This is for the `dir' program. */
|
||||
format = many_per_line;
|
||||
quote_funny_chars = 1;
|
||||
set_quoting_style ("earg_quoting_options, escape_quoting_style);
|
||||
break;
|
||||
|
||||
case LS_LONG_FORMAT:
|
||||
/* This is for the `vdir' program. */
|
||||
format = long_format;
|
||||
quote_funny_chars = 1;
|
||||
set_quoting_style ("earg_quoting_options, escape_quoting_style);
|
||||
break;
|
||||
|
||||
case LS_LS:
|
||||
@@ -858,8 +852,10 @@ decode_switches (int argc, char **argv)
|
||||
all_files = 0;
|
||||
really_all_files = 0;
|
||||
ignore_patterns = 0;
|
||||
quote_as_string = 0;
|
||||
quote_shell = 1;
|
||||
|
||||
if ((p = getenv ("QUOTING_STYLE"))
|
||||
&& 0 <= (i = argmatch (p, quoting_style_args)))
|
||||
set_quoting_style ("earg_quoting_options, (enum quoting_style) i);
|
||||
|
||||
if ((p = getenv ("BLOCKSIZE"))
|
||||
&& strncmp (p, "HUMAN", sizeof ("HUMAN") - 1) == 0)
|
||||
@@ -879,7 +875,7 @@ decode_switches (int argc, char **argv)
|
||||
{
|
||||
error (0, 0,
|
||||
_("ignoring invalid width in environment variable COLUMNS: %s"),
|
||||
p);
|
||||
quotearg (p));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,7 +902,7 @@ decode_switches (int argc, char **argv)
|
||||
{
|
||||
error (0, 0,
|
||||
_("ignoring invalid tab size in environment variable TABSIZE: %s"),
|
||||
p);
|
||||
quotearg (p));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,10 +921,7 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
quote_funny_chars = 1;
|
||||
quote_as_string = 0;
|
||||
quote_shell = 0;
|
||||
qmark_funny_chars = 0;
|
||||
set_quoting_style ("earg_quoting_options, escape_quoting_style);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
@@ -940,13 +933,6 @@ decode_switches (int argc, char **argv)
|
||||
immediate_dirs = 1;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
quote_shell = 1;
|
||||
quote_as_string = 0;
|
||||
quote_funny_chars = 0;
|
||||
qmark_funny_chars = 0;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
/* Same as enabling -a -U and disabling -l -s. */
|
||||
all_files = 1;
|
||||
@@ -997,14 +983,11 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
indicator_style = not_programs;
|
||||
indicator_style = file_type;
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
qmark_funny_chars = 1;
|
||||
quote_as_string = 0;
|
||||
quote_funny_chars = 0;
|
||||
quote_shell = 0;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
@@ -1020,6 +1003,7 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
sort_type = sort_time;
|
||||
time_type = time_atime;
|
||||
break;
|
||||
|
||||
@@ -1030,7 +1014,8 @@ decode_switches (int argc, char **argv)
|
||||
case 'w':
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long <= 0 || tmp_long > INT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("invalid line width: %s"), optarg);
|
||||
error (EXIT_FAILURE, 0, _("invalid line width: %s"),
|
||||
quotearg (optarg));
|
||||
line_length = (int) tmp_long;
|
||||
break;
|
||||
|
||||
@@ -1057,7 +1042,7 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
indicator_style = all;
|
||||
indicator_style = classify;
|
||||
break;
|
||||
|
||||
case 'G': /* inhibit display of group info */
|
||||
@@ -1073,17 +1058,11 @@ decode_switches (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
quote_as_string = 0;
|
||||
quote_funny_chars = 0;
|
||||
quote_shell = 0;
|
||||
qmark_funny_chars = 0;
|
||||
set_quoting_style ("earg_quoting_options, literal_quoting_style);
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
quote_as_string = 1;
|
||||
quote_funny_chars = 1;
|
||||
quote_shell = 0;
|
||||
qmark_funny_chars = 0;
|
||||
set_quoting_style ("earg_quoting_options, c_quoting_style);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
@@ -1097,7 +1076,8 @@ decode_switches (int argc, char **argv)
|
||||
case 'T':
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > INT_MAX)
|
||||
error (EXIT_FAILURE, 0, _("invalid tab size: %s"), optarg);
|
||||
error (EXIT_FAILURE, 0, _("invalid tab size: %s"),
|
||||
quotearg (optarg));
|
||||
tabsize = (int) tmp_long;
|
||||
break;
|
||||
|
||||
@@ -1174,6 +1154,31 @@ decode_switches (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 14: /* --indicator-style */
|
||||
i = argmatch (optarg, indicator_style_args);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg (_("indicator style"), optarg, i);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
indicator_style = (enum indicator_style) i;
|
||||
break;
|
||||
|
||||
case 15: /* --quoting-style */
|
||||
i = argmatch (optarg, quoting_style_args);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg (_("quoting style"), optarg, i);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
set_quoting_style ("earg_quoting_options,
|
||||
(enum quoting_style) i);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
qmark_funny_chars = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
@@ -1182,6 +1187,14 @@ decode_switches (int argc, char **argv)
|
||||
if (human_readable_base)
|
||||
output_units = 1;
|
||||
|
||||
filename_quoting_options = clone_quoting_options ("earg_quoting_options);
|
||||
if (indicator_style != none)
|
||||
for (p = "*=@|" + (int) indicator_style - 1; *p; p++)
|
||||
set_char_quoting (filename_quoting_options, *p, 1);
|
||||
|
||||
dirname_quoting_options = clone_quoting_options ("earg_quoting_options);
|
||||
set_char_quoting (dirname_quoting_options, ':', 1);
|
||||
|
||||
return optind;
|
||||
}
|
||||
|
||||
@@ -1479,7 +1492,7 @@ parse_ls_color (void)
|
||||
}
|
||||
}
|
||||
if (state == -1)
|
||||
error (0, 0, _("unrecognized prefix: %s"), label);
|
||||
error (0, 0, _("unrecognized prefix: %s"), quotearg (label));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1549,7 +1562,7 @@ print_dir (const char *name, const char *realname)
|
||||
reading = opendir (name);
|
||||
if (!reading)
|
||||
{
|
||||
error (0, errno, "%s", name);
|
||||
error (0, errno, "%s", quotearg_colon (name));
|
||||
exit_status = 1;
|
||||
return;
|
||||
}
|
||||
@@ -1565,7 +1578,7 @@ print_dir (const char *name, const char *realname)
|
||||
|
||||
if (CLOSEDIR (reading))
|
||||
{
|
||||
error (0, errno, "%s", name);
|
||||
error (0, errno, "%s", quotearg_colon (name));
|
||||
exit_status = 1;
|
||||
/* Don't return; print whatever we got. */
|
||||
}
|
||||
@@ -1583,7 +1596,8 @@ print_dir (const char *name, const char *realname)
|
||||
{
|
||||
DIRED_INDENT ();
|
||||
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
|
||||
dired_pos += quote_filename (stdout, realname ? realname : name);
|
||||
dired_pos += quote_name (stdout, realname ? realname : name,
|
||||
dirname_quoting_options);
|
||||
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
|
||||
FPUTS_LITERAL (":\n", stdout);
|
||||
}
|
||||
@@ -1709,10 +1723,13 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
}
|
||||
else
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
{
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
}
|
||||
|
||||
if (val < 0)
|
||||
{
|
||||
error (0, errno, "%s", path);
|
||||
error (0, errno, "%s", quotearg_colon (path));
|
||||
exit_status = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1817,7 +1834,7 @@ get_link_name (const char *filename, struct fileinfo *f)
|
||||
linksize = readlink (filename, linkbuf, PATH_MAX + 1);
|
||||
if (linksize < 0)
|
||||
{
|
||||
error (0, errno, "%s", filename);
|
||||
error (0, errno, "%s", quotearg_colon (filename));
|
||||
exit_status = 1;
|
||||
}
|
||||
else
|
||||
@@ -2150,7 +2167,7 @@ print_long_format (const struct fileinfo *f)
|
||||
const char *fmt;
|
||||
char *user_name;
|
||||
|
||||
#ifdef HAVE_ST_DM_MODE
|
||||
#if HAVE_ST_DM_MODE
|
||||
mode_string (f->stat.st_dm_mode, modebuf);
|
||||
#else
|
||||
mode_string (f->stat.st_mode, modebuf);
|
||||
@@ -2308,134 +2325,34 @@ print_long_format (const struct fileinfo *f)
|
||||
print_type_indicator (f->stat.st_mode);
|
||||
}
|
||||
|
||||
/* If OUT is not null, output a quoted representation of the file name P.
|
||||
/* Output to OUT a quoted representation of the file name P,
|
||||
using OPTIONS to control quoting.
|
||||
Return the number of characters in P's quoted representation. */
|
||||
|
||||
static size_t
|
||||
quote_filename (register FILE *out, register const char *p)
|
||||
quote_name (FILE *out, const char *p, struct quoting_options const *options)
|
||||
{
|
||||
register unsigned char c;
|
||||
register size_t len;
|
||||
#define OUTCHAR(c) do { len++; if (out) putc (c, out); } while (0)
|
||||
char smallbuf[BUFSIZ];
|
||||
size_t len = quotearg_buffer (smallbuf, sizeof smallbuf, p, -1, options);
|
||||
char *buf;
|
||||
|
||||
if (quote_shell)
|
||||
{
|
||||
const char *p0 = p;
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
case '\0': case '#': case '~':
|
||||
break;
|
||||
|
||||
default:
|
||||
for (;; p++)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
default:
|
||||
continue;
|
||||
|
||||
case '\t': case '\n': case ' ':
|
||||
case '!': /* special in csh */
|
||||
case '"': case '$': case '&': case '\'':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '?': case '[': case '\\':
|
||||
case '^': /* synonym for | in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
switch (p[-1])
|
||||
{
|
||||
case '=': case '@':
|
||||
/* These require quoting if at the end of the file name,
|
||||
to avoid ambiguity with the output of -F or -p. */
|
||||
break;
|
||||
|
||||
default:
|
||||
len = p - p0;
|
||||
if (out)
|
||||
fwrite (p0, 1, len, out);
|
||||
return len;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Shell quoting is needed. */
|
||||
|
||||
p = p0;
|
||||
len = 0;
|
||||
OUTCHAR ('\'');
|
||||
|
||||
while ((c = *p++))
|
||||
{
|
||||
OUTCHAR (c);
|
||||
|
||||
if (c == '\'')
|
||||
{
|
||||
OUTCHAR ('\\');
|
||||
OUTCHAR ('\'');
|
||||
OUTCHAR ('\'');
|
||||
}
|
||||
}
|
||||
|
||||
OUTCHAR ('\'');
|
||||
}
|
||||
if (len < sizeof smallbuf)
|
||||
buf = smallbuf;
|
||||
else
|
||||
{
|
||||
len = 0;
|
||||
|
||||
if (quote_as_string)
|
||||
OUTCHAR ('"');
|
||||
|
||||
while ((c = *p++))
|
||||
{
|
||||
if (quote_funny_chars)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '\\': OUTCHAR ('\\'); break;
|
||||
case '\n': OUTCHAR ('\\'); c = 'n'; break;
|
||||
case '\b': OUTCHAR ('\\'); c = 'b'; break;
|
||||
case '\r': OUTCHAR ('\\'); c = 'r'; break;
|
||||
case '\t': OUTCHAR ('\\'); c = 't'; break;
|
||||
case '\f': OUTCHAR ('\\'); c = 'f'; break;
|
||||
|
||||
case ' ':
|
||||
if (!quote_as_string)
|
||||
OUTCHAR ('\\');
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (quote_as_string)
|
||||
OUTCHAR ('\\');
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!ISGRAPH (c))
|
||||
{
|
||||
OUTCHAR ('\\');
|
||||
OUTCHAR ('0' + (c >> 6));
|
||||
OUTCHAR ('0' + ((c >> 3) & 3));
|
||||
c = '0' + (c & 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (qmark_funny_chars && !ISPRINT (c))
|
||||
c = '?';
|
||||
|
||||
OUTCHAR (c);
|
||||
}
|
||||
|
||||
if (quote_as_string)
|
||||
OUTCHAR ('"');
|
||||
buf = (char *) alloca (len + 1);
|
||||
quotearg_buffer (buf, len + 1, p, -1, options);
|
||||
}
|
||||
|
||||
if (qmark_funny_chars)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < len; i++)
|
||||
if (! ISPRINT ((unsigned char) buf[i]))
|
||||
buf[i] = '?';
|
||||
}
|
||||
|
||||
fwrite (buf, 1, len, out);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -2449,7 +2366,7 @@ print_name_with_quoting (const char *p, unsigned int mode, int linkok,
|
||||
if (stack)
|
||||
PUSH_CURRENT_DIRED_POS (stack);
|
||||
|
||||
dired_pos += quote_filename (stdout, p);
|
||||
dired_pos += quote_name (stdout, p, filename_quoting_options);
|
||||
|
||||
if (stack)
|
||||
PUSH_CURRENT_DIRED_POS (stack);
|
||||
@@ -2516,7 +2433,7 @@ print_type_indicator (unsigned int mode)
|
||||
PUTCHAR ('=');
|
||||
#endif
|
||||
|
||||
if (S_ISREG (mode) && indicator_style == all
|
||||
if (S_ISREG (mode) && indicator_style == classify
|
||||
&& (mode & S_IXUGO))
|
||||
PUTCHAR ('*');
|
||||
}
|
||||
@@ -2616,7 +2533,7 @@ length_of_file_name_and_frills (const struct fileinfo *f)
|
||||
if (print_block_size)
|
||||
len += 1 + block_size_size;
|
||||
|
||||
len += quote_filename (0, f->name);
|
||||
len += quotearg_buffer (0, 0, f->name, -1, filename_quoting_options);
|
||||
|
||||
if (indicator_style != none)
|
||||
{
|
||||
@@ -2624,7 +2541,7 @@ length_of_file_name_and_frills (const struct fileinfo *f)
|
||||
|
||||
if (S_ISREG (filetype))
|
||||
{
|
||||
if (indicator_style == all
|
||||
if (indicator_style == classify
|
||||
&& (f->stat.st_mode & S_IXUGO))
|
||||
len += 1;
|
||||
}
|
||||
@@ -2935,9 +2852,8 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
|
||||
types. WHEN may be `never', `always', or `auto'\n\
|
||||
-d, --directory list directory entries instead of contents\n\
|
||||
-D, --dired generate output designed for Emacs' dired mode\n\
|
||||
-e, --quote-shell quote entry names for shell (default)\n\
|
||||
-f do not sort, enable -aU, disable -lst\n\
|
||||
-F, --classify append a character for typing each entry\n\
|
||||
-F, --classify append indicator (one of */=@|) to entries\n\
|
||||
--format=WORD across -x, commas -m, horizontal -x, long -l,\n\
|
||||
single-column -1, verbose -l, vertical -C\n\
|
||||
--full-time list both full date and full time\n"));
|
||||
@@ -2947,6 +2863,8 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
|
||||
-G, --no-group inhibit display of group information\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\
|
||||
--indicator-style=WORD append indicator with style WORD to entry names:\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\
|
||||
@@ -2957,21 +2875,25 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
|
||||
-N, --literal print raw entry names (don't treat e.g. control\n\
|
||||
characters specially)\n\
|
||||
-o use long listing format without group info\n\
|
||||
-p append a character for typing each entry\n\
|
||||
-p, --file-type append indicator (one of /=@|) to entries\n\
|
||||
-q, --hide-control-chars print ? instead of non graphic characters\n\
|
||||
--show-control-chars show non graphic characters as-is (default)\n\
|
||||
-Q, --quote-name enclose entry names in double quotes\n\
|
||||
--quoting-style=WORD use quoting style WORD for entry names:\n\
|
||||
literal, shell, shell-always, c, escape\n\
|
||||
-r, --reverse reverse order while sorting\n\
|
||||
-R, --recursive list subdirectories recursively\n\
|
||||
-s, --size print size of each file, in blocks\n"));
|
||||
|
||||
printf (_("\
|
||||
-S sort by file size\n\
|
||||
--sort=WORD ctime -c, extension -X, none -U, size -S,\n\
|
||||
--sort=WORD extension -X, none -U, size -S, time -t,\n\
|
||||
version -v\n\
|
||||
status -c, time -t, atime -u, access -u, use -u\n\
|
||||
--time=WORD show time as WORD instead of modification time:\n\
|
||||
atime, access, use, ctime or status\n\
|
||||
-t sort by modification time; with -l: show mtime\n\
|
||||
atime, access, use, ctime or status; use\n\
|
||||
specified time as sort key if --sort=time\n\
|
||||
-t sort by modification time\n\
|
||||
-T, --tabsize=COLS assume tab stops at each COLS instead of 8\n\
|
||||
-u sort by last access time; with -l: show atime\n\
|
||||
-U do not sort; list entries in directory order\n\
|
||||
@@ -2990,6 +2912,7 @@ optional WHEN argument is equivalent to using --color=always. With\n\
|
||||
to a terminal (tty).\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mkdir -- make directories
|
||||
Copyright (C) 90, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 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
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -68,6 +69,7 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -112,6 +114,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mkdir (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mkfifo -- make fifo's (named pipes)
|
||||
Copyright (C) 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 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
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -66,6 +67,7 @@ Create named pipes (FIFOs) with the given NAMEs.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -107,6 +109,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mkfifo (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mknod -- make special files
|
||||
Copyright (C) 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 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
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -77,6 +78,7 @@ MAJOR MINOR are forbidden for TYPE p, mandatory otherwise. TYPE may be:\n\
|
||||
p create a FIFO\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -116,6 +118,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mknod (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
299
src/mv.c
299
src/mv.c
@@ -1,5 +1,5 @@
|
||||
/* mv -- move or rename files
|
||||
Copyright (C) 86, 89, 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 89, 90, 91, 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
|
||||
@@ -46,40 +46,42 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* FIXME: uncomment for release
|
||||
#define NDEBUG
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "path-concat.h"
|
||||
#include "backupfile.h"
|
||||
#include "closeout.h"
|
||||
#include "cp-hash.h"
|
||||
#include "copy.h"
|
||||
#include "remove.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
#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
|
||||
|
||||
/* Initial number of entries in the inode hash table. */
|
||||
#define INITIAL_ENTRY_TAB_SIZE 70
|
||||
|
||||
char *base_name ();
|
||||
int euidaccess ();
|
||||
int full_write ();
|
||||
enum backup_type get_version ();
|
||||
int isdir ();
|
||||
int yesno ();
|
||||
int lstat ();
|
||||
int safe_read ();
|
||||
int full_write ();
|
||||
int euidaccess ();
|
||||
int yesno ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, query the user before overwriting files. */
|
||||
static int interactive;
|
||||
|
||||
/* If nonzero, do not query the user before overwriting unwritable
|
||||
files. */
|
||||
static int override_mode;
|
||||
|
||||
/* If nonzero, do not move a nondirectory that has an existing destination
|
||||
with the same or newer modification time. */
|
||||
static int update = 0;
|
||||
|
||||
/* If nonzero, list each file as it is moved. */
|
||||
static int verbose;
|
||||
|
||||
/* If nonzero, stdin is a tty. */
|
||||
static int stdin_tty;
|
||||
|
||||
@@ -95,14 +97,59 @@ static struct option const long_options[] =
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
{"update", no_argument, &update, 1},
|
||||
{"verbose", no_argument, &verbose, 1},
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
rm_option_init (struct rm_options *x)
|
||||
{
|
||||
x->unlink_dirs = 0;
|
||||
|
||||
/* FIXME: maybe this should be 1. The POSIX spec doesn't specify. */
|
||||
x->ignore_missing_files = 0;
|
||||
|
||||
x->recursive = 1;
|
||||
|
||||
/* Should we prompt for removal, too? No. Prompting for the `move'
|
||||
part is enough. It implies removal. */
|
||||
x->interactive = 0;
|
||||
x->stdin_tty = 0;
|
||||
|
||||
x->verbose = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cp_option_init (struct cp_options *x)
|
||||
{
|
||||
x->copy_as_regular = 0; /* FIXME: maybe make this an option */
|
||||
x->dereference = 0;
|
||||
x->force = 0;
|
||||
x->hard_link = 0;
|
||||
x->interactive = 0;
|
||||
x->myeuid = geteuid ();
|
||||
x->one_file_system = 0;
|
||||
x->preserve = 1;
|
||||
x->require_preserve = 0; /* FIXME: maybe make this an option */
|
||||
x->recursive = 1;
|
||||
x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */
|
||||
x->symbolic_link = 0;
|
||||
|
||||
/* Find out the current file creation mask, to knock the right bits
|
||||
when using chmod. The creation mask is set to be liberal, so
|
||||
that created directories can be written, even if it would not
|
||||
have been allowed with the mask this process was started with. */
|
||||
x->umask_kill = 0777777 ^ umask (0);
|
||||
|
||||
x->update = 0;
|
||||
x->verbose = 0;
|
||||
x->xstat = lstat;
|
||||
}
|
||||
|
||||
/* If PATH is an existing directory, return nonzero, else 0. */
|
||||
|
||||
static int
|
||||
@@ -113,140 +160,17 @@ is_real_dir (const char *path)
|
||||
return lstat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
|
||||
}
|
||||
|
||||
/* Apply as many of the file attributes (the struct stat fields: st_atime,
|
||||
st_mtime, st_uid, st_gid, st_mode) of ATTR to FILE as possible.
|
||||
Return non-zero if any operation failed; return zero otherwise. */
|
||||
|
||||
static int
|
||||
apply_attributes (const char *file, const struct stat *attr)
|
||||
{
|
||||
struct utimbuf tv;
|
||||
mode_t mode = attr->st_mode;
|
||||
int fail = 0;
|
||||
|
||||
/* Try to apply the modtime and access time. */
|
||||
tv.actime = attr->st_atime;
|
||||
tv.modtime = attr->st_mtime;
|
||||
if (utime (file, &tv))
|
||||
{
|
||||
error (0, errno, "%s: unable to restore file times", file);
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
/* chown would turn off set[ug]id bits for non-root, so do the
|
||||
chown before the chmod. */
|
||||
|
||||
/* Try to apply group ID and owner ID. */
|
||||
if (chown (file, attr->st_uid, attr->st_gid))
|
||||
{
|
||||
error (0, errno, "%s: unable to restore owner and group IDs", file);
|
||||
|
||||
/* If the owner and group cannot be preserved, then mask off
|
||||
any setgid and setuid bits. */
|
||||
mode &= (~(S_ISUID | S_ISGID));
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
/* Try to apply file mode. */
|
||||
if (chmod (file, mode & 07777))
|
||||
{
|
||||
error (0, errno, "%s: unable to restore file mode", file);
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
/* Copy regular file SOURCE onto file DEST. SOURCE_STATS must be
|
||||
the result of calling lstat on SOURCE.
|
||||
Return 1 if an error occurred, 0 if successful. */
|
||||
|
||||
static int
|
||||
copy_reg (const char *source, const char *dest, const struct stat *source_stats)
|
||||
{
|
||||
int ifd;
|
||||
int ofd;
|
||||
char buf[1024 * 8];
|
||||
int len; /* Number of bytes read into `buf'. */
|
||||
|
||||
if (!S_ISREG (source_stats->st_mode))
|
||||
{
|
||||
error (0, 0,
|
||||
_("cannot move `%s' across filesystems: Not a regular file"),
|
||||
source);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlink (dest) && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("cannot remove `%s'"), dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ifd = open (source, O_RDONLY, 0);
|
||||
if (ifd < 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
return 1;
|
||||
}
|
||||
ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
if (ofd < 0)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
close (ifd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((len = safe_read (ifd, buf, sizeof (buf))) > 0)
|
||||
{
|
||||
if (full_write (ofd, buf, len) < 0)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
close (ifd);
|
||||
close (ofd);
|
||||
unlink (dest);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (len < 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
close (ifd);
|
||||
close (ofd);
|
||||
unlink (dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (close (ifd) < 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
close (ofd);
|
||||
return 1;
|
||||
}
|
||||
if (close (ofd) < 0)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Try to apply the attributes of SOURCE to DEST.
|
||||
Each failure gets a diagnostic, but POSIX requires that failure
|
||||
to preserve attributes not change mv's exit status. */
|
||||
apply_attributes (dest, source_stats);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move SOURCE onto DEST. Handles cross-filesystem moves.
|
||||
If SOURCE is a directory, DEST must not exist.
|
||||
Return 0 if successful, non-zero if an error occurred. */
|
||||
|
||||
static int
|
||||
do_move (const char *source, const char *dest)
|
||||
do_move (const char *source, const char *dest, const struct cp_options *x)
|
||||
{
|
||||
char *dest_backup = NULL;
|
||||
struct stat source_stats;
|
||||
struct stat dest_stats;
|
||||
int nonexistent_dst;
|
||||
int fail;
|
||||
|
||||
if (lstat (source, &source_stats) != 0)
|
||||
@@ -255,8 +179,10 @@ do_move (const char *source, const char *dest)
|
||||
return 1;
|
||||
}
|
||||
|
||||
nonexistent_dst = 1;
|
||||
if (lstat (dest, &dest_stats) == 0)
|
||||
{
|
||||
nonexistent_dst = 0;
|
||||
|
||||
if (source_stats.st_dev == dest_stats.st_dev
|
||||
&& source_stats.st_ino == dest_stats.st_ino)
|
||||
@@ -271,11 +197,11 @@ do_move (const char *source, const char *dest)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (source_stats.st_mode) && update
|
||||
if (!S_ISDIR (source_stats.st_mode) && x->update
|
||||
&& source_stats.st_mtime <= dest_stats.st_mtime)
|
||||
return 0;
|
||||
|
||||
if (!override_mode && (interactive || stdin_tty)
|
||||
if (!x->force && (x->interactive || stdin_tty)
|
||||
&& euidaccess (dest, W_OK))
|
||||
{
|
||||
fprintf (stderr, _("%s: replace `%s', overriding mode %04o? "),
|
||||
@@ -284,16 +210,16 @@ do_move (const char *source, const char *dest)
|
||||
if (!yesno ())
|
||||
return 0;
|
||||
}
|
||||
else if (interactive)
|
||||
else if (x->interactive)
|
||||
{
|
||||
fprintf (stderr, _("%s: replace `%s'? "), program_name, dest);
|
||||
if (!yesno ())
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (backup_type != none)
|
||||
if (x->backup_type != none)
|
||||
{
|
||||
char *tmp_backup = find_backup_file_name (dest);
|
||||
char *tmp_backup = find_backup_file_name (dest, x->backup_type);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
dest_backup = (char *) alloca (strlen (tmp_backup) + 1);
|
||||
@@ -317,7 +243,7 @@ do_move (const char *source, const char *dest)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
if (x->verbose)
|
||||
printf ("%s -> %s\n", source, dest);
|
||||
|
||||
/* Always try rename first. */
|
||||
@@ -345,16 +271,48 @@ do_move (const char *source, const char *dest)
|
||||
This function used to resort to copying only when rename failed
|
||||
and set errno to EXDEV. */
|
||||
|
||||
fail = copy_reg (source, dest, &source_stats);
|
||||
static int first = 1;
|
||||
int copy_into_self;
|
||||
|
||||
if (first)
|
||||
{
|
||||
first = 0;
|
||||
|
||||
/* Allocate space for remembering copied and created files. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
}
|
||||
|
||||
fail = copy (source, dest, nonexistent_dst, x, ©_into_self);
|
||||
if (fail)
|
||||
{
|
||||
/* Restore original destination file DEST if made a backup. */
|
||||
if (dest_backup && rename (dest_backup, dest))
|
||||
error (0, errno, _("cannot un-backup `%s'"), dest);
|
||||
}
|
||||
else 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. */
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = unlink (source);
|
||||
struct rm_options rm_options;
|
||||
struct File_spec fs;
|
||||
enum RM_status status;
|
||||
|
||||
rm_option_init (&rm_options);
|
||||
rm_options.verbose = x->verbose;
|
||||
|
||||
remove_init ();
|
||||
|
||||
fspec_init_file (&fs, source);
|
||||
status = rm (&fs, 1, &rm_options);
|
||||
assert (VALID_STATUS (status));
|
||||
if (status == RM_ERROR)
|
||||
fail = 1;
|
||||
|
||||
remove_fini ();
|
||||
|
||||
if (fail)
|
||||
error (0, errno, _("cannot remove `%s'"), source);
|
||||
}
|
||||
@@ -381,7 +339,7 @@ strip_trailing_slashes_2 (char *path)
|
||||
Return 0 if successful, non-zero if an error occurred. */
|
||||
|
||||
static int
|
||||
movefile (char *source, char *dest, int dest_is_dir)
|
||||
movefile (char *source, char *dest, int dest_is_dir, const struct cp_options *x)
|
||||
{
|
||||
int dest_had_trailing_slash = strip_trailing_slashes_2 (dest);
|
||||
int fail;
|
||||
@@ -407,12 +365,12 @@ movefile (char *source, char *dest, int dest_is_dir)
|
||||
new_dest = path_concat (dest, src_basename, NULL);
|
||||
if (new_dest == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
fail = do_move (source, new_dest);
|
||||
fail = do_move (source, new_dest, x);
|
||||
free (new_dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = do_move (source, dest);
|
||||
fail = do_move (source, dest, x);
|
||||
}
|
||||
|
||||
return fail;
|
||||
@@ -438,7 +396,7 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\
|
||||
-f, --force remove existing destinations, never prompt\n\
|
||||
-i, --interactive prompt before overwrite\n\
|
||||
-S, --suffix=SUFFIX override the usual backup suffix\n\
|
||||
-u, --update move only older or brand new files\n\
|
||||
-u, --update move only older or brand new non-directories\n\
|
||||
-v, --verbose explain what is being done\n\
|
||||
-V, --version-control=WORD override the usual version control\n\
|
||||
--help display this help and exit\n\
|
||||
@@ -454,6 +412,7 @@ version control may be set with VERSION_CONTROL, values are:\n\
|
||||
never, simple always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -466,18 +425,20 @@ main (int argc, char **argv)
|
||||
int make_backups = 0;
|
||||
int dest_is_dir;
|
||||
char *version;
|
||||
struct cp_options x;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
cp_option_init (&x);
|
||||
|
||||
version = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
if (version)
|
||||
simple_backup_suffix = version;
|
||||
version = getenv ("VERSION_CONTROL");
|
||||
|
||||
interactive = override_mode = verbose = update = 0;
|
||||
errors = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bfiuvS:V:", long_options, NULL)) != -1)
|
||||
@@ -490,18 +451,18 @@ main (int argc, char **argv)
|
||||
make_backups = 1;
|
||||
break;
|
||||
case 'f':
|
||||
interactive = 0;
|
||||
override_mode = 1;
|
||||
x.interactive = 0;
|
||||
x.force = 1;
|
||||
break;
|
||||
case 'i':
|
||||
interactive = 1;
|
||||
override_mode = 0;
|
||||
x.interactive = 1;
|
||||
x.force = 0;
|
||||
break;
|
||||
case 'u':
|
||||
update = 1;
|
||||
x.update = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
x.verbose = 1;
|
||||
break;
|
||||
case 'S':
|
||||
simple_backup_suffix = optarg;
|
||||
@@ -517,6 +478,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mv (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -531,8 +493,7 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (make_backups)
|
||||
backup_type = get_version (version);
|
||||
x.backup_type = (make_backups ? get_version (version) : none);
|
||||
|
||||
stdin_tty = isatty (STDIN_FILENO);
|
||||
dest_is_dir = isdir (argv[argc - 1]);
|
||||
@@ -543,7 +504,9 @@ main (int argc, char **argv)
|
||||
|
||||
/* Move each arg but the last onto the last. */
|
||||
for (; optind < argc - 1; ++optind)
|
||||
errors |= movefile (argv[optind], argv[argc - 1], dest_is_dir);
|
||||
errors |= movefile (argv[optind], argv[argc - 1], dest_is_dir, &x);
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
17
src/nl.c
17
src/nl.c
@@ -1,5 +1,5 @@
|
||||
/* nl -- number lines of files
|
||||
Copyright (C) 89, 92, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 92, 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
|
||||
@@ -24,9 +24,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#include "linebuffer.h"
|
||||
#include "system.h"
|
||||
|
||||
#if WITH_REGEX
|
||||
# include <regex.h>
|
||||
@@ -34,16 +33,6 @@
|
||||
# include <rx.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#include "linebuffer.h"
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
|
||||
27
src/od.c
27
src/od.c
@@ -1,5 +1,5 @@
|
||||
/* od -- dump files in octal and other formats
|
||||
Copyright (C) 92, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 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
|
||||
@@ -37,36 +37,11 @@ typedef long double LONG_DOUBLE;
|
||||
typedef double LONG_DOUBLE;
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef SCHAR_MAX
|
||||
# define SCHAR_MAX 127
|
||||
#endif
|
||||
#ifndef SCHAR_MIN
|
||||
# define SCHAR_MIN (-128)
|
||||
#endif
|
||||
#ifndef SHRT_MAX
|
||||
# define SHRT_MAX 32767
|
||||
#endif
|
||||
#ifndef SHRT_MIN
|
||||
# define SHRT_MIN (-32768)
|
||||
#endif
|
||||
#ifndef ULONG_MAX
|
||||
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||
#endif
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#if HAVE_VALUES_H
|
||||
# include <values.h>
|
||||
#endif
|
||||
|
||||
#ifndef BITSPERBYTE
|
||||
# define BITSPERBYTE 8
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
14
src/pr.c
14
src/pr.c
@@ -1,5 +1,5 @@
|
||||
/* pr -- convert text files for printing.
|
||||
Copyright (C) 88, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 91, 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
|
||||
@@ -178,18 +178,6 @@
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
|
||||
848
src/remove.c
Normal file
848
src/remove.c
Normal file
@@ -0,0 +1,848 @@
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "save-cwd.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "hash.h"
|
||||
#include "remove.h"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined (__GNUC__) || __STDC__
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef D_INO_IN_DIRENT
|
||||
# define D_INO(dp) ((dp)->d_ino)
|
||||
# define ENABLE_CYCLE_CHECK
|
||||
#else
|
||||
/* Some systems don't have inodes, so fake them to avoid lots of ifdefs. */
|
||||
# define D_INO(dp) 1
|
||||
#endif
|
||||
|
||||
#if !defined (S_ISLNK)
|
||||
# define S_ISLNK(Mode) 0
|
||||
#endif
|
||||
|
||||
#define DOT_OR_DOTDOT(Basename) \
|
||||
(Basename[0] == '.' && (Basename[1] == '\0' \
|
||||
|| (Basename[1] == '.' && Basename[2] == '\0')))
|
||||
|
||||
#if defined strdupa
|
||||
# define ASSIGN_STRDUPA(DEST, S) \
|
||||
do { DEST = strdupa(S); } while (0)
|
||||
#else
|
||||
# define ASSIGN_STRDUPA(DEST, S) \
|
||||
do \
|
||||
{ \
|
||||
const char *s_ = (S); \
|
||||
size_t len_ = strlen (s_) + 1; \
|
||||
char *tmp_dest_ = (char *) alloca (len_); \
|
||||
DEST = memcpy (tmp_dest_, (s_), len_); \
|
||||
} \
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
/* Initial capacity of per-directory hash table of entries that have
|
||||
been processed but not been deleted. */
|
||||
#define HT_INITIAL_CAPACITY 13
|
||||
|
||||
/* Initial capacity of the active directory hash table. This table will
|
||||
be resized only for hierarchies more than about 45 levels deep. */
|
||||
#define ACTIVE_DIR_INITIAL_CAPACITY 53
|
||||
|
||||
char *base_name ();
|
||||
int euidaccess ();
|
||||
int yesno ();
|
||||
|
||||
extern char *program_name;
|
||||
|
||||
/* state initialized by remove_init, freed by remove_fini */
|
||||
|
||||
/* An entry in the active_dir_map. */
|
||||
struct active_dir_ent
|
||||
{
|
||||
ino_t inum;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
/* The name of the directory (starting with and relative to a command
|
||||
line argument) being processed. When a subdirectory is entered, a new
|
||||
component is appended (pushed). When RM chdir's out of a directory,
|
||||
the top component is removed (popped). This is used to form a full
|
||||
file name when necessary. */
|
||||
static struct obstack dir_stack;
|
||||
|
||||
/* Stack of lengths of directory names (including trailing slash)
|
||||
appended to dir_stack. We have to have a separate stack of lengths
|
||||
(rather than just popping back to previous slash) because the first
|
||||
element pushed onto the dir stack may contain slashes. */
|
||||
static struct obstack len_stack;
|
||||
|
||||
/* Set of `active' directories from the current command-line argument
|
||||
to the level in the hierarchy at which files are being removed.
|
||||
A directory is added to the active set when RM begins removing it
|
||||
(or its entries), and it is removed from the set just after RM has
|
||||
finished processing it.
|
||||
|
||||
This is actually a map (not a set), implemented with a hash table.
|
||||
For each active directory, it maps the directory's inode number to the
|
||||
depth of that directory relative to the root of the tree being deleted.
|
||||
A directory specified on the command line has depth zero.
|
||||
This construct is used to detect directory cycles so that RM can warn
|
||||
about them rather than iterating endlessly. */
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
static struct HT *active_dir_map;
|
||||
#endif
|
||||
|
||||
static inline unsigned int
|
||||
current_depth (void)
|
||||
{
|
||||
return obstack_object_size (&len_stack) / sizeof (size_t);
|
||||
}
|
||||
|
||||
static void
|
||||
print_nth_dir (FILE *stream, unsigned int depth)
|
||||
{
|
||||
size_t *length = (size_t *) obstack_base (&len_stack);
|
||||
char *dir_name = (char *) obstack_base (&dir_stack);
|
||||
unsigned int sum = 0;
|
||||
unsigned int i;
|
||||
|
||||
assert (0 <= depth && depth < current_depth ());
|
||||
|
||||
for (i = 0; i <= depth; i++)
|
||||
{
|
||||
sum += length[i];
|
||||
}
|
||||
|
||||
fwrite (dir_name, 1, sum, stream);
|
||||
}
|
||||
|
||||
static inline struct active_dir_ent *
|
||||
make_active_dir_ent (ino_t inum, unsigned int depth)
|
||||
{
|
||||
struct active_dir_ent *ent;
|
||||
ent = (struct active_dir_ent *) xmalloc (sizeof *ent);
|
||||
ent->inum = inum;
|
||||
ent->depth = depth;
|
||||
return ent;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
hash_active_dir_ent (void const *x, unsigned int table_size)
|
||||
{
|
||||
struct active_dir_ent const *ade = x;
|
||||
return ade->inum % table_size;
|
||||
}
|
||||
|
||||
static int
|
||||
hash_compare_active_dir_ents (void const *x, void const *y)
|
||||
{
|
||||
struct active_dir_ent const *a = x;
|
||||
struct active_dir_ent const *b = y;
|
||||
return (a->inum == b->inum ? 0 : 1);
|
||||
}
|
||||
|
||||
/* A hash function for null-terminated char* strings using
|
||||
the method described in Aho, Sethi, & Ullman, p 436. */
|
||||
|
||||
static unsigned int
|
||||
hash_pjw (const void *x, unsigned int tablesize)
|
||||
{
|
||||
const char *s = x;
|
||||
unsigned int h = 0;
|
||||
unsigned int g;
|
||||
|
||||
while (*s != 0)
|
||||
{
|
||||
h = (h << 4) + *s++;
|
||||
if ((g = h & (unsigned int) 0xf0000000) != 0)
|
||||
h = (h ^ (g >> 24)) ^ g;
|
||||
}
|
||||
|
||||
return (h % tablesize);
|
||||
}
|
||||
|
||||
static int
|
||||
hash_compare_strings (void const *x, void const *y)
|
||||
{
|
||||
return strcmp (x, y);
|
||||
}
|
||||
|
||||
static inline void
|
||||
push_dir (const char *dir_name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = strlen (dir_name);
|
||||
|
||||
/* Append the string onto the stack. */
|
||||
obstack_grow (&dir_stack, dir_name, len);
|
||||
|
||||
/* Append a trailing slash. */
|
||||
obstack_1grow (&dir_stack, '/');
|
||||
|
||||
/* Add one for the slash. */
|
||||
++len;
|
||||
|
||||
/* Push the length (including slash) onto its stack. */
|
||||
obstack_grow (&len_stack, &len, sizeof (len));
|
||||
}
|
||||
|
||||
static inline void
|
||||
pop_dir (void)
|
||||
{
|
||||
int n_lengths = obstack_object_size (&len_stack) / sizeof (size_t);
|
||||
size_t *length = (size_t *) obstack_base (&len_stack);
|
||||
size_t top_len;
|
||||
|
||||
assert (n_lengths > 0);
|
||||
top_len = length[n_lengths - 1];
|
||||
assert (top_len >= 2);
|
||||
|
||||
/* Pop off the specified length of pathname. */
|
||||
assert (obstack_object_size (&dir_stack) >= top_len);
|
||||
obstack_blank (&dir_stack, -top_len);
|
||||
|
||||
/* Pop the length stack, too. */
|
||||
assert (obstack_object_size (&len_stack) >= sizeof (size_t));
|
||||
obstack_blank (&len_stack, -(sizeof (size_t)));
|
||||
}
|
||||
|
||||
/* Copy the SRC_LEN bytes of data beginning at SRC into the DST_LEN-byte
|
||||
buffer, DST, so that the last source byte is at the end of the destination
|
||||
buffer. If SRC_LEN is longer than DST_LEN, then set *TRUNCATED to non-zero.
|
||||
Set *RESULT to point to the beginning of (the portion of) the source data
|
||||
in DST. Return the number of bytes remaining in the destination buffer. */
|
||||
|
||||
static size_t
|
||||
right_justify (char *dst, size_t dst_len, const char *src, size_t src_len,
|
||||
char **result, int *truncated)
|
||||
{
|
||||
const char *sp;
|
||||
char *dp;
|
||||
|
||||
if (src_len <= dst_len)
|
||||
{
|
||||
sp = src;
|
||||
dp = dst + (dst_len - src_len);
|
||||
*truncated = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp = src + (src_len - dst_len);
|
||||
dp = dst;
|
||||
src_len = dst_len;
|
||||
*truncated = 1;
|
||||
}
|
||||
|
||||
*result = memcpy (dp, sp, src_len);
|
||||
return dst_len - src_len;
|
||||
}
|
||||
|
||||
/* Using the global directory name obstack, create the full path to FILENAME.
|
||||
Return it in sometimes-realloc'd space that should not be freed by the
|
||||
caller. Realloc as necessary. If realloc fails, use a static buffer
|
||||
and put as long a suffix in that buffer as possible. */
|
||||
|
||||
static char *
|
||||
full_filename (const char *filename)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t n_allocated = 0;
|
||||
|
||||
int dir_len = obstack_object_size (&dir_stack);
|
||||
char *dir_name = (char *) obstack_base (&dir_stack);
|
||||
size_t n_bytes_needed;
|
||||
size_t filename_len;
|
||||
|
||||
filename_len = strlen (filename);
|
||||
n_bytes_needed = dir_len + filename_len + 1;
|
||||
|
||||
if (n_bytes_needed > n_allocated)
|
||||
{
|
||||
/* This code requires that realloc accept NULL as the first arg.
|
||||
This function must not use xrealloc. Otherwise, an out-of-memory
|
||||
error involving a file name to be expanded here wouldn't ever
|
||||
be issued. Use realloc and fall back on using a static buffer
|
||||
if memory allocation fails. */
|
||||
buf = realloc (buf, n_bytes_needed);
|
||||
n_allocated = n_bytes_needed;
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
#define SBUF_SIZE 512
|
||||
#define ELLIPSES_PREFIX "[...]"
|
||||
static char static_buf[SBUF_SIZE];
|
||||
int truncated;
|
||||
size_t len;
|
||||
char *p;
|
||||
|
||||
len = right_justify (static_buf, SBUF_SIZE, filename,
|
||||
filename_len + 1, &p, &truncated);
|
||||
right_justify (static_buf, len, dir_name, dir_len, &p, &truncated);
|
||||
if (truncated)
|
||||
{
|
||||
memcpy (static_buf, ELLIPSES_PREFIX,
|
||||
sizeof (ELLIPSES_PREFIX) - 1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy directory part, including trailing slash, and then
|
||||
append the filename part, including a trailing zero byte. */
|
||||
memcpy (mempcpy (buf, dir_name, dir_len), filename, filename_len + 1);
|
||||
|
||||
assert (strlen (buf) + 1 == n_bytes_needed);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
fspec_init_file (struct File_spec *fs, const char *filename)
|
||||
{
|
||||
fs->filename = (char *) filename;
|
||||
fs->have_full_mode = 0;
|
||||
fs->have_filetype_mode = 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
fspec_init_dp (struct File_spec *fs, struct dirent *dp)
|
||||
{
|
||||
fs->filename = dp->d_name;
|
||||
fs->have_full_mode = 0;
|
||||
fs->have_filetype_mode = 0;
|
||||
fs->inum = D_INO (dp);
|
||||
|
||||
#if D_TYPE_IN_DIRENT && defined (DT_UNKNOWN) && defined (DTTOIF)
|
||||
if (dp->d_type != DT_UNKNOWN)
|
||||
{
|
||||
fs->have_filetype_mode = 1;
|
||||
fs->mode = DTTOIF (dp->d_type);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int
|
||||
fspec_get_full_mode (struct File_spec *fs, mode_t *full_mode)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
|
||||
if (fs->have_full_mode)
|
||||
{
|
||||
*full_mode = fs->mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lstat (fs->filename, &stat_buf))
|
||||
return 1;
|
||||
|
||||
fs->have_full_mode = 1;
|
||||
fs->have_filetype_mode = 1;
|
||||
fs->mode = stat_buf.st_mode;
|
||||
fs->inum = stat_buf.st_ino;
|
||||
|
||||
*full_mode = stat_buf.st_mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
fspec_get_filetype_mode (struct File_spec *fs, mode_t *filetype_mode)
|
||||
{
|
||||
int fail;
|
||||
|
||||
if (fs->have_filetype_mode)
|
||||
{
|
||||
*filetype_mode = fs->mode;
|
||||
fail = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = fspec_get_full_mode (fs, filetype_mode);
|
||||
}
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
static inline mode_t
|
||||
fspec_filetype_mode (const struct File_spec *fs)
|
||||
{
|
||||
assert (fs->have_filetype_mode);
|
||||
return fs->mode;
|
||||
}
|
||||
|
||||
/* Recursively remove all of the entries in the current directory.
|
||||
Return an indication of the success of the operation. */
|
||||
|
||||
enum RM_status
|
||||
remove_cwd_entries (const struct rm_options *x)
|
||||
{
|
||||
/* NOTE: this is static. */
|
||||
static DIR *dirp = NULL;
|
||||
|
||||
/* NULL or a malloc'd and initialized hash table of entries in the
|
||||
current directory that have been processed but not removed --
|
||||
due either to an error or to an interactive `no' response. */
|
||||
struct HT *ht = NULL;
|
||||
|
||||
/* FIXME: describe */
|
||||
static struct obstack entry_name_pool;
|
||||
static int first_call = 1;
|
||||
|
||||
enum RM_status status = RM_OK;
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = 0;
|
||||
obstack_init (&entry_name_pool);
|
||||
}
|
||||
|
||||
if (dirp)
|
||||
{
|
||||
if (CLOSEDIR (dirp))
|
||||
{
|
||||
/* FIXME-someday: but this is actually the previously opened dir. */
|
||||
error (0, errno, "%s", full_filename ("."));
|
||||
status = RM_ERROR;
|
||||
}
|
||||
dirp = NULL;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
/* FIXME: why do this? */
|
||||
errno = 0;
|
||||
|
||||
dirp = opendir (".");
|
||||
if (dirp == NULL)
|
||||
{
|
||||
if (errno != ENOENT || !x->ignore_missing_files)
|
||||
{
|
||||
error (0, errno, "%s", full_filename ("."));
|
||||
status = RM_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
char *entry_name;
|
||||
struct File_spec fs;
|
||||
enum RM_status tmp_status;
|
||||
struct dirent *dp;
|
||||
|
||||
/* FILE should be skipped if it is `.' or `..', or if it is in
|
||||
the table, HT, of entries we've already processed. */
|
||||
#define SKIPPABLE(Ht, File) (DOT_OR_DOTDOT(File) \
|
||||
|| (Ht && hash_query_in_table (Ht, File)))
|
||||
|
||||
/* FIXME: use readdir_r directly into an obstack to avoid
|
||||
the obstack_copy0 below --
|
||||
Suggestion from Uli. Be careful -- there are different
|
||||
prototypes on e.g. Solaris.
|
||||
|
||||
Do something like this:
|
||||
#define NAME_MAX_FOR(Parent_dir) pathconf ((Parent_dir),
|
||||
_PC_NAME_MAX);
|
||||
dp = obstack_alloc (sizeof (struct dirent)
|
||||
+ NAME_MAX_FOR (".") + 1);
|
||||
fail = xreaddir (dirp, dp);
|
||||
where xreaddir is ...
|
||||
|
||||
But what about systems like the hurd where NAME_MAX is supposed
|
||||
to be effectively unlimited. We don't want to have to allocate
|
||||
a huge buffer to accommodate maximum possible entry name. */
|
||||
|
||||
dp = readdir (dirp);
|
||||
|
||||
#if ! HAVE_WORKING_READDIR
|
||||
if (dp == NULL)
|
||||
{
|
||||
/* Since we have probably modified the directory since it
|
||||
was opened, readdir returning NULL does not necessarily
|
||||
mean we have read the last entry. Rewind it and check
|
||||
again. This happens on SunOS4.1.4 with 254 or more files
|
||||
in a directory. */
|
||||
rewinddir (dirp);
|
||||
while ((dp = readdir (dirp)) && SKIPPABLE (ht, dp->d_name))
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dp == NULL)
|
||||
break;
|
||||
|
||||
if (SKIPPABLE (ht, dp->d_name))
|
||||
continue;
|
||||
|
||||
fspec_init_dp (&fs, dp);
|
||||
|
||||
/* Save a copy of the name of this entry, in case we have
|
||||
to add it to the set of unremoved entries below. */
|
||||
entry_name = obstack_copy0 (&entry_name_pool,
|
||||
dp->d_name, NLENGTH (dp));
|
||||
|
||||
/* CAUTION: after this call to rm, DP may not be valid --
|
||||
it may have been freed due to a close in a recursive call
|
||||
(through rm and remove_dir) to this function. */
|
||||
tmp_status = rm (&fs, 0, x);
|
||||
|
||||
/* Update status. */
|
||||
if (tmp_status > status)
|
||||
status = tmp_status;
|
||||
assert (VALID_STATUS (status));
|
||||
|
||||
/* If this entry was not removed (due either to an error or to
|
||||
an interactive `no' response), record it in the hash table so
|
||||
we don't consider it again if we reopen this directory later. */
|
||||
if (status != RM_OK)
|
||||
{
|
||||
int fail;
|
||||
|
||||
if (ht == NULL)
|
||||
{
|
||||
ht = hash_initialize (HT_INITIAL_CAPACITY, NULL,
|
||||
hash_pjw, hash_compare_strings);
|
||||
if (ht == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
HASH_INSERT_NEW_ITEM (ht, entry_name, &fail);
|
||||
if (fail)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This entry was not saved in the hash table. Free it. */
|
||||
obstack_free (&entry_name_pool, entry_name);
|
||||
}
|
||||
|
||||
if (dirp == NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (dirp == NULL);
|
||||
|
||||
if (CLOSEDIR (dirp))
|
||||
{
|
||||
error (0, errno, "%s", full_filename ("."));
|
||||
status = 1;
|
||||
}
|
||||
dirp = NULL;
|
||||
|
||||
if (ht)
|
||||
{
|
||||
hash_free (ht);
|
||||
}
|
||||
|
||||
if (obstack_object_size (&entry_name_pool) > 0)
|
||||
obstack_free (&entry_name_pool, obstack_base (&entry_name_pool));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Query the user if appropriate, and if ok try to remove the
|
||||
file or directory specified by FS. Return RM_OK if it is removed,
|
||||
and RM_ERROR or RM_USER_DECLINED if not. */
|
||||
|
||||
static enum RM_status
|
||||
remove_file (struct File_spec *fs, const struct rm_options *x)
|
||||
{
|
||||
int asked = 0;
|
||||
char *pathname = fs->filename;
|
||||
|
||||
if (!x->ignore_missing_files && (x->interactive || x->stdin_tty)
|
||||
&& euidaccess (pathname, W_OK))
|
||||
{
|
||||
if (!S_ISLNK (fspec_filetype_mode (fs)))
|
||||
{
|
||||
fprintf (stderr,
|
||||
(S_ISDIR (fspec_filetype_mode (fs))
|
||||
? _("%s: remove write-protected directory `%s'? ")
|
||||
: _("%s: remove write-protected file `%s'? ")),
|
||||
program_name, full_filename (pathname));
|
||||
if (!yesno ())
|
||||
return RM_USER_DECLINED;
|
||||
|
||||
asked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!asked && x->interactive)
|
||||
{
|
||||
/* FIXME: use a variant of error (instead of fprintf) that doesn't
|
||||
append a newline. Then we won't have to declare program_name in
|
||||
this file. */
|
||||
fprintf (stderr,
|
||||
(S_ISDIR (fspec_filetype_mode (fs))
|
||||
? _("%s: remove directory `%s'? ")
|
||||
: _("%s: remove `%s'? ")),
|
||||
program_name, full_filename (pathname));
|
||||
if (!yesno ())
|
||||
return RM_USER_DECLINED;
|
||||
}
|
||||
|
||||
if (x->verbose)
|
||||
printf (_("removing non-directory %s\n"), full_filename (pathname));
|
||||
|
||||
if (unlink (pathname) && (errno != ENOENT || !x->ignore_missing_files))
|
||||
{
|
||||
error (0, errno, _("cannot unlink `%s'"), full_filename (pathname));
|
||||
return RM_ERROR;
|
||||
}
|
||||
return RM_OK;
|
||||
}
|
||||
|
||||
/* If not in recursive mode, print an error message and return RM_ERROR.
|
||||
Otherwise, query the user if appropriate, then try to recursively
|
||||
remove the directory specified by FS. Return RM_OK if it is removed,
|
||||
and RM_ERROR or RM_USER_DECLINED if not.
|
||||
FIXME: describe need_save_cwd parameter. */
|
||||
|
||||
static enum RM_status
|
||||
remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
|
||||
{
|
||||
enum RM_status status;
|
||||
struct saved_cwd cwd;
|
||||
char *dir_name = fs->filename;
|
||||
const char *fmt = NULL;
|
||||
|
||||
if (!x->recursive)
|
||||
{
|
||||
error (0, 0, _("%s: is a directory"), full_filename (dir_name));
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
if (!x->ignore_missing_files && (x->interactive || x->stdin_tty)
|
||||
&& euidaccess (dir_name, W_OK))
|
||||
{
|
||||
fmt = _("%s: directory `%s' is write protected; descend into it anyway? ");
|
||||
}
|
||||
else if (x->interactive)
|
||||
{
|
||||
fmt = _("%s: descend into directory `%s'? ");
|
||||
}
|
||||
|
||||
if (fmt)
|
||||
{
|
||||
fprintf (stderr, fmt, program_name, full_filename (dir_name));
|
||||
if (!yesno ())
|
||||
return RM_USER_DECLINED;
|
||||
}
|
||||
|
||||
if (x->verbose)
|
||||
printf (_("removing all entries of directory %s\n"),
|
||||
full_filename (dir_name));
|
||||
|
||||
/* Save cwd if needed. */
|
||||
if (need_save_cwd && save_cwd (&cwd))
|
||||
return RM_ERROR;
|
||||
|
||||
/* Make target directory the current one. */
|
||||
if (chdir (dir_name) < 0)
|
||||
{
|
||||
error (0, errno, _("cannot change to directory %s"),
|
||||
full_filename (dir_name));
|
||||
if (need_save_cwd)
|
||||
free_cwd (&cwd);
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
push_dir (dir_name);
|
||||
|
||||
/* Save a copy of dir_name. Otherwise, remove_cwd_entries may clobber
|
||||
it because it is just a pointer to the dir entry's d_name field, and
|
||||
remove_cwd_entries may close the directory. */
|
||||
ASSIGN_STRDUPA (dir_name, dir_name);
|
||||
|
||||
status = remove_cwd_entries (x);
|
||||
|
||||
pop_dir ();
|
||||
|
||||
/* Restore cwd. */
|
||||
if (need_save_cwd)
|
||||
{
|
||||
if (restore_cwd (&cwd, NULL, NULL))
|
||||
{
|
||||
free_cwd (&cwd);
|
||||
return RM_ERROR;
|
||||
}
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
else if (chdir ("..") < 0)
|
||||
{
|
||||
error (0, errno, _("cannot change back to directory %s via `..'"),
|
||||
full_filename (dir_name));
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
if (x->interactive)
|
||||
{
|
||||
error (0, 0, _("remove directory `%s'%s? "), full_filename (dir_name),
|
||||
(status != RM_OK ? _(" (might be nonempty)") : ""));
|
||||
if (!yesno ())
|
||||
{
|
||||
return RM_USER_DECLINED;
|
||||
}
|
||||
}
|
||||
|
||||
if (x->verbose)
|
||||
printf (_("removing the directory itself: %s\n"), full_filename (dir_name));
|
||||
|
||||
if (rmdir (dir_name) && (errno != ENOENT || !x->ignore_missing_files))
|
||||
{
|
||||
error (0, errno, _("cannot remove directory `%s'"),
|
||||
full_filename (dir_name));
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
return RM_OK;
|
||||
}
|
||||
|
||||
/* Remove the file or directory specified by FS after checking appropriate
|
||||
things. Return RM_OK if it is removed, and RM_ERROR or RM_USER_DECLINED
|
||||
if not. If USER_SPECIFIED_NAME is non-zero, then the name part of FS may
|
||||
be `.', `..', or may contain slashes. Otherwise, it must be a simple file
|
||||
name (and hence must specify a file in the current directory). */
|
||||
|
||||
enum RM_status
|
||||
rm (struct File_spec *fs, int user_specified_name, const struct rm_options *x)
|
||||
{
|
||||
mode_t filetype_mode;
|
||||
|
||||
if (user_specified_name)
|
||||
{
|
||||
char *base = base_name (fs->filename);
|
||||
|
||||
if (DOT_OR_DOTDOT (base))
|
||||
{
|
||||
error (0, 0, _("cannot remove `.' or `..'"));
|
||||
return RM_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (fspec_get_filetype_mode (fs, &filetype_mode))
|
||||
{
|
||||
if (x->ignore_missing_files && errno == ENOENT)
|
||||
return RM_OK;
|
||||
|
||||
error (0, errno, _("cannot remove `%s'"), full_filename (fs->filename));
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
if (S_ISDIR (filetype_mode))
|
||||
{
|
||||
int fail;
|
||||
struct active_dir_ent *old_ent;
|
||||
|
||||
/* Insert this directory in the active_dir_map.
|
||||
If there is already a directory in the map with the same inum,
|
||||
then there's *probably* a directory cycle. This test can get
|
||||
a false positive if two directories have the same inode number
|
||||
but different device numbers and one directory contains the
|
||||
other. But since people don't often try to delete hierarchies
|
||||
containing mount points, and when they do, duplicate inode
|
||||
numbers are not that likely, this isn't worth detecting. */
|
||||
old_ent = hash_insert_if_absent (active_dir_map,
|
||||
make_active_dir_ent (fs->inum,
|
||||
current_depth ()),
|
||||
&fail);
|
||||
if (fail)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
if (old_ent)
|
||||
{
|
||||
error (0, 0, _("\
|
||||
WARNING: Circular directory structure.\n\
|
||||
This almost certainly means that you have a corrupted file system.\n\
|
||||
NOTIFY YOUR SYSTEM MANAGER.\n\
|
||||
The following two directories have the same inode number:\n"));
|
||||
/* FIXME: test this!! */
|
||||
print_nth_dir (stderr, current_depth ());
|
||||
fputc ('\n', stderr);
|
||||
print_nth_dir (stderr, old_ent->depth);
|
||||
fputc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
|
||||
free (old_ent);
|
||||
|
||||
if (x->interactive)
|
||||
{
|
||||
error (0, 0, _("continue? "));
|
||||
if (yesno ())
|
||||
return RM_ERROR;
|
||||
}
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!S_ISDIR (filetype_mode) || x->unlink_dirs)
|
||||
{
|
||||
return remove_file (fs, x);
|
||||
}
|
||||
else
|
||||
{
|
||||
int need_save_cwd = user_specified_name;
|
||||
enum RM_status status;
|
||||
|
||||
if (need_save_cwd)
|
||||
need_save_cwd = (strchr (fs->filename, '/') != NULL);
|
||||
|
||||
status = remove_dir (fs, need_save_cwd, x);
|
||||
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
{
|
||||
struct active_dir_ent tmp;
|
||||
struct active_dir_ent *old_ent;
|
||||
|
||||
/* Remove this directory from the active_dir_map. */
|
||||
tmp.inum = fs->inum;
|
||||
old_ent = hash_delete_if_present (active_dir_map, &tmp);
|
||||
assert (old_ent != NULL);
|
||||
free (old_ent);
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
remove_init (void)
|
||||
{
|
||||
/* Initialize dir-stack obstacks. */
|
||||
obstack_init (&dir_stack);
|
||||
obstack_init (&len_stack);
|
||||
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
active_dir_map = hash_initialize (ACTIVE_DIR_INITIAL_CAPACITY, free,
|
||||
hash_active_dir_ent,
|
||||
hash_compare_active_dir_ents);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
remove_fini (void)
|
||||
{
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
hash_free (active_dir_map);
|
||||
#endif
|
||||
|
||||
obstack_free (&dir_stack, NULL);
|
||||
obstack_free (&len_stack, NULL);
|
||||
}
|
||||
49
src/remove.h
Normal file
49
src/remove.h
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
struct rm_options
|
||||
{
|
||||
/* If nonzero, ignore nonexistant files. */
|
||||
int ignore_missing_files;
|
||||
|
||||
/* If nonzero, query the user about whether to remove each file. */
|
||||
int interactive;
|
||||
|
||||
/* If nonzero, recursively remove directories. */
|
||||
int recursive;
|
||||
|
||||
/* If nonzero, stdin is a tty. */
|
||||
int stdin_tty;
|
||||
|
||||
/* If nonzero, remove directories with unlink instead of rmdir, and don't
|
||||
require a directory to be empty before trying to unlink it.
|
||||
Only works for the super-user. */
|
||||
int unlink_dirs;
|
||||
|
||||
/* If nonzero, display the name of each file removed. */
|
||||
int verbose;
|
||||
};
|
||||
|
||||
enum RM_status
|
||||
{
|
||||
/* These must be listed in order of increasing seriousness. */
|
||||
RM_OK = 1,
|
||||
RM_USER_DECLINED,
|
||||
RM_ERROR
|
||||
};
|
||||
|
||||
#define VALID_STATUS(S) \
|
||||
((S) == RM_OK || (S) == RM_USER_DECLINED || (S) == RM_ERROR)
|
||||
|
||||
struct File_spec
|
||||
{
|
||||
char *filename;
|
||||
unsigned int have_filetype_mode:1;
|
||||
unsigned int have_full_mode:1;
|
||||
mode_t mode;
|
||||
ino_t inum;
|
||||
};
|
||||
|
||||
enum RM_status rm PARAMS ((struct File_spec *fs, int user_specified_name,
|
||||
const struct rm_options *x));
|
||||
void fspec_init_file PARAMS ((struct File_spec *fs, const char *filename));
|
||||
void remove_init PARAMS ((void));
|
||||
void remove_fini PARAMS ((void));
|
||||
23
src/rmdir.c
23
src/rmdir.c
@@ -1,5 +1,5 @@
|
||||
/* rmdir -- remove directories
|
||||
Copyright (C) 90, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 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
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
@@ -85,11 +86,12 @@ remove_parents (char *path)
|
||||
while (slash > path && *slash == '/')
|
||||
--slash;
|
||||
slash[1] = 0;
|
||||
fail = rmdir (path);
|
||||
|
||||
/* Give a diagnostic for each successful removal if --verbose. */
|
||||
if (verbose && !fail)
|
||||
error (0, errno, _("removed directory, %s"), path);
|
||||
/* Give a diagnostic for each attempted removal if --verbose. */
|
||||
if (verbose)
|
||||
error (0, errno, _("removing directory, %s"), path);
|
||||
|
||||
fail = rmdir (path);
|
||||
|
||||
if (fail)
|
||||
{
|
||||
@@ -126,6 +128,7 @@ Remove the DIRECTORY(ies), if they are empty.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -166,6 +169,7 @@ main (int argc, char **argv)
|
||||
if (show_version)
|
||||
{
|
||||
printf ("rmdir (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -186,11 +190,12 @@ main (int argc, char **argv)
|
||||
/* Stripping slashes is harmless for rmdir;
|
||||
if the arg is not a directory, it will fail with ENOTDIR. */
|
||||
strip_trailing_slashes (dir);
|
||||
fail = rmdir (dir);
|
||||
|
||||
/* Give a diagnostic for each successful removal if --verbose. */
|
||||
if (verbose && !fail)
|
||||
error (0, errno, _("removed directory, %s"), dir);
|
||||
/* Give a diagnostic for each attempted removal if --verbose. */
|
||||
if (verbose)
|
||||
error (0, errno, _("removing directory, %s"), dir);
|
||||
|
||||
fail = rmdir (dir);
|
||||
|
||||
if (fail)
|
||||
{
|
||||
|
||||
140
src/sort.c
140
src/sort.c
@@ -1,5 +1,5 @@
|
||||
/* sort - sort lines of text (with all kinds of options).
|
||||
Copyright (C) 88, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 91-97, 98 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
|
||||
@@ -39,18 +39,10 @@
|
||||
#include "xstrtod.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#if defined ENABLE_NLS && HAVE_LANGINFO_H
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#else
|
||||
# ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 255
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char *xstrdup ();
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
@@ -90,7 +82,7 @@ char *xstrdup ();
|
||||
|
||||
static unsigned char decimal_point;
|
||||
static unsigned char th_sep;
|
||||
static unsigned char *nls_grouping;
|
||||
static char *nls_grouping;
|
||||
|
||||
/* This is "C" locale, need another? */
|
||||
static int need_locale = 0;
|
||||
@@ -354,7 +346,7 @@ xtmpfopen (const char *file)
|
||||
FILE *fp;
|
||||
int fd;
|
||||
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
|
||||
if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
|
||||
{
|
||||
error (0, errno, "%s", file);
|
||||
@@ -491,7 +483,7 @@ nls_sort_month_comp (const void *m1, const void *m2)
|
||||
/* Do collation on strings S1 and S2, but for at most L characters.
|
||||
we use the fact, that we KNOW that LEN is the min of the two lengths */
|
||||
static int
|
||||
strncoll (unsigned char *s1, unsigned char *s2, int len)
|
||||
strncoll (char *s1, char *s2, int len)
|
||||
{
|
||||
register int diff;
|
||||
|
||||
@@ -521,7 +513,7 @@ strncoll (unsigned char *s1, unsigned char *s2, int len)
|
||||
Use the fact, that we KNOW that S2 is the shorter string and has
|
||||
length LEN. */
|
||||
static int
|
||||
strncoll_s2_readonly (unsigned char *s1, const unsigned char *s2, int len)
|
||||
strncoll_s2_readonly (char *s1, const char *s2, int len)
|
||||
{
|
||||
register int diff;
|
||||
|
||||
@@ -567,26 +559,26 @@ inittables (void)
|
||||
fold_toupper[i] = i;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#if defined ENABLE_NLS && HAVE_NL_LANGINFO
|
||||
/* If We're not in the "C" locale, read in different names for months. */
|
||||
if (need_locale)
|
||||
{
|
||||
nls_months_collide[0] = 1; /* if an error, look again */
|
||||
for (i = 0; i < NLS_NUM_MONTHS; i++)
|
||||
{
|
||||
unsigned char *s;
|
||||
char *s;
|
||||
size_t s_len;
|
||||
int j;
|
||||
|
||||
s = nl_langinfo (ABMON_1 + us_monthtab[i].val - 1);
|
||||
s = (char *) nl_langinfo (ABMON_1 + us_monthtab[i].val - 1);
|
||||
s_len = strlen (s);
|
||||
nls_monthtab[i].name = (char *) xmalloc (s_len + 1);
|
||||
nls_monthtab[i].val = us_monthtab[i].val;
|
||||
|
||||
/* It has been pointed out, that abreviated month names
|
||||
/* Be careful: abreviated month names
|
||||
may be longer than the usual 3 characters. */
|
||||
for (j = 0; j < s_len; j++)
|
||||
nls_monthtab[i].name[j] = fold_toupper[s[j]];
|
||||
nls_monthtab[i].name[j] = fold_toupper[UCHAR (s[j])];
|
||||
nls_monthtab[i].name[j] = '\0';
|
||||
|
||||
nls_months_collide[nls_monthtab[i].val] = 0;
|
||||
@@ -1067,26 +1059,28 @@ static void
|
||||
nls_set_fraction (register unsigned char ch)
|
||||
{
|
||||
if (!nls_fraction_found && ch != decimal_point)
|
||||
if (ch == FLOATING_POINT)
|
||||
{ /* US style */
|
||||
decimal_point = FLOATING_POINT;
|
||||
th_sep = FLOATING_COMMA;
|
||||
}
|
||||
else if (ch == FLOATING_COMMA)
|
||||
{ /* EU style */
|
||||
decimal_point = FLOATING_COMMA;
|
||||
th_sep = FLOATING_POINT;
|
||||
}
|
||||
else if (ch != decimal_point)
|
||||
{ /* Alien */
|
||||
decimal_point = ch;
|
||||
th_sep = '\0';
|
||||
}
|
||||
{
|
||||
if (ch == FLOATING_POINT)
|
||||
{ /* US style */
|
||||
decimal_point = FLOATING_POINT;
|
||||
th_sep = FLOATING_COMMA;
|
||||
}
|
||||
else if (ch == FLOATING_COMMA)
|
||||
{ /* EU style */
|
||||
decimal_point = FLOATING_COMMA;
|
||||
th_sep = FLOATING_POINT;
|
||||
}
|
||||
else if (ch != decimal_point)
|
||||
{ /* Alien */
|
||||
decimal_point = ch;
|
||||
th_sep = '\0';
|
||||
}
|
||||
}
|
||||
nls_fraction_found = 1;
|
||||
}
|
||||
|
||||
/* Look for a fraction
|
||||
It ain't as simple as it looks... however, consider a number:
|
||||
It isn't as simple as it looks... however, consider a number:
|
||||
1.234,00
|
||||
1,234.00
|
||||
It's easy to tell which is a decimal point, and which isn't. We use
|
||||
@@ -1132,9 +1126,9 @@ nls_set_fraction (register unsigned char ch)
|
||||
*/
|
||||
|
||||
static void
|
||||
look_for_fraction (unsigned const char *s, unsigned const char *e)
|
||||
look_for_fraction (const char *s, const char *e)
|
||||
{
|
||||
register unsigned const char *p;
|
||||
register const char *p;
|
||||
register unsigned short n = 0;
|
||||
static unsigned short max_groups = 0;
|
||||
static unsigned short *groups = NULL;
|
||||
@@ -1146,7 +1140,7 @@ look_for_fraction (unsigned const char *s, unsigned const char *e)
|
||||
}
|
||||
|
||||
/* skip blanks and signs */
|
||||
while (blanks[*s] || *s == NEGATIVE_SIGN)
|
||||
while (blanks[UCHAR (*s)] || *s == NEGATIVE_SIGN)
|
||||
s++;
|
||||
/* groups = {}, n = 0 */
|
||||
for (p = s; p < e; p++)
|
||||
@@ -1208,14 +1202,14 @@ look_for_fraction (unsigned const char *s, unsigned const char *e)
|
||||
}
|
||||
|
||||
static int
|
||||
numcompare (register const unsigned char *a, register const unsigned char *b)
|
||||
numcompare (register const char *a, register const char *b)
|
||||
{
|
||||
int ret_code = 1; /* normal return status, see later in code */
|
||||
int diff = 0; /* difference between two digits */
|
||||
|
||||
while (blanks[*a])
|
||||
while (blanks[UCHAR (*a)])
|
||||
++a;
|
||||
while (blanks[*b])
|
||||
while (blanks[UCHAR (*b)])
|
||||
++b;
|
||||
|
||||
/* next character in a,b is non-blank */
|
||||
@@ -1653,8 +1647,8 @@ keycompare (const struct line *a, const struct line *b)
|
||||
of the time) we could temporarily NUL-terminate them in
|
||||
place and avoid the copy. */
|
||||
|
||||
unsigned char *copy_a = (unsigned char *) alloca (lena + 1);
|
||||
unsigned char *copy_b = (unsigned char *) alloca (lenb + 1);
|
||||
char *copy_a = (char *) alloca (lena + 1);
|
||||
char *copy_b = (char *) alloca (lenb + 1);
|
||||
int new_len_a, new_len_b, i;
|
||||
|
||||
/* We can't use strcoll directly on the two strings,
|
||||
@@ -2032,32 +2026,34 @@ mergefps (FILE **fps, register int nfps, FILE *ofp)
|
||||
|
||||
/* Check if we need to read more lines into core. */
|
||||
if (++cur[ord[0]] == lines[ord[0]].used)
|
||||
if (fillbuf (&buffer[ord[0]], fps[ord[0]]))
|
||||
{
|
||||
findlines (&buffer[ord[0]], &lines[ord[0]]);
|
||||
cur[ord[0]] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We reached EOF on fps[ord[0]]. */
|
||||
for (i = 1; i < nfps; ++i)
|
||||
if (ord[i] > ord[0])
|
||||
--ord[i];
|
||||
--nfps;
|
||||
xfclose (fps[ord[0]]);
|
||||
free (buffer[ord[0]].buf);
|
||||
free ((char *) lines[ord[0]].lines);
|
||||
for (i = ord[0]; i < nfps; ++i)
|
||||
{
|
||||
fps[i] = fps[i + 1];
|
||||
buffer[i] = buffer[i + 1];
|
||||
lines[i] = lines[i + 1];
|
||||
cur[i] = cur[i + 1];
|
||||
}
|
||||
for (i = 0; i < nfps; ++i)
|
||||
ord[i] = ord[i + 1];
|
||||
continue;
|
||||
}
|
||||
{
|
||||
if (fillbuf (&buffer[ord[0]], fps[ord[0]]))
|
||||
{
|
||||
findlines (&buffer[ord[0]], &lines[ord[0]]);
|
||||
cur[ord[0]] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We reached EOF on fps[ord[0]]. */
|
||||
for (i = 1; i < nfps; ++i)
|
||||
if (ord[i] > ord[0])
|
||||
--ord[i];
|
||||
--nfps;
|
||||
xfclose (fps[ord[0]]);
|
||||
free (buffer[ord[0]].buf);
|
||||
free ((char *) lines[ord[0]].lines);
|
||||
for (i = ord[0]; i < nfps; ++i)
|
||||
{
|
||||
fps[i] = fps[i + 1];
|
||||
buffer[i] = buffer[i + 1];
|
||||
lines[i] = lines[i + 1];
|
||||
cur[i] = cur[i + 1];
|
||||
}
|
||||
for (i = 0; i < nfps; ++i)
|
||||
ord[i] = ord[i + 1];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* The new line just read in may be larger than other lines
|
||||
already in core; push it back in the queue until we encounter
|
||||
@@ -2100,8 +2096,8 @@ nls_numeric_format (const struct line *line, int nlines)
|
||||
int iter;
|
||||
for (iter = 0; !nls_fraction_found; iter++)
|
||||
{
|
||||
unsigned char *text;
|
||||
unsigned char *lim;
|
||||
char *text;
|
||||
char *lim;
|
||||
struct keyfield *key = n_key->key;
|
||||
|
||||
/* text = {}, lim = {}, key = first key */
|
||||
@@ -2492,7 +2488,7 @@ main (int argc, char **argv)
|
||||
|
||||
decimal_point = *lconvp->decimal_point;
|
||||
th_sep = *lconvp->thousands_sep;
|
||||
nls_grouping = lconvp->grouping;
|
||||
nls_grouping = (char *) (lconvp->grouping);
|
||||
}
|
||||
|
||||
/* if locale doesn't define a decimal point, we'll use the
|
||||
|
||||
64
src/split.c
64
src/split.c
@@ -1,5 +1,5 @@
|
||||
/* split.c -- split a file into pieces.
|
||||
Copyright (C) 88, 91, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 91, 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,18 +27,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX ((int) (UINT_MAX >> 1))
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -127,40 +115,30 @@ SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.\n\
|
||||
static void
|
||||
next_file_name (void)
|
||||
{
|
||||
int x;
|
||||
char *ne;
|
||||
unsigned int i;
|
||||
static unsigned n_digits = 2;
|
||||
char *p;
|
||||
|
||||
static int first_call = 1;
|
||||
|
||||
/* Status for outfile name generation. */
|
||||
static unsigned outfile_count = 0;
|
||||
static unsigned outfile_name_limit = 25 * 26;
|
||||
static unsigned outfile_name_generation = 1;
|
||||
|
||||
if (!first_call)
|
||||
outfile_count++;
|
||||
first_call = 0;
|
||||
if (outfile_count < outfile_name_limit)
|
||||
/* Change any suffix of `z's to `a's. */
|
||||
for (p = outfile_end - 1; *p == 'z'; p--)
|
||||
{
|
||||
for (ne = outfile_end - 1; ; ne--)
|
||||
{
|
||||
x = *ne;
|
||||
if (x != 'z')
|
||||
break;
|
||||
*ne = 'a';
|
||||
}
|
||||
*ne = x + 1;
|
||||
return;
|
||||
*p = 'a';
|
||||
}
|
||||
|
||||
outfile_count = 0;
|
||||
outfile_name_limit *= 26;
|
||||
outfile_name_generation++;
|
||||
*outfile_mid++ = 'z';
|
||||
for (i = 0; i <= outfile_name_generation; i++)
|
||||
outfile_mid[i] = 'a';
|
||||
outfile_end += 2;
|
||||
/* Increment the rightmost non-`z' character that was present before the
|
||||
above z/a substitutions. There is guaranteed to be such a character. */
|
||||
++(*p);
|
||||
|
||||
/* If the result of that increment operation yielded a `z' and there
|
||||
are only `z's to the left of it, then append two more `a' characters
|
||||
to the end and add 1 (-1 + 2) to the number of digits (we're taking
|
||||
out this `z' and adding two `a's). */
|
||||
if (*p == 'z' && p == outfile_mid)
|
||||
{
|
||||
++n_digits;
|
||||
++outfile_mid;
|
||||
*outfile_end++ = 'a';
|
||||
*outfile_end++ = 'a';
|
||||
}
|
||||
}
|
||||
|
||||
/* Write BYTES bytes at BP to an output file.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* sync - update the super block
|
||||
Copyright (C) 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -44,6 +45,7 @@ Force changed blocks to disk, update the super block.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user