mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
276 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a147c61141 | ||
|
|
4afd87dd11 | ||
|
|
339497e1f4 | ||
|
|
62528b9cf8 | ||
|
|
50c573d457 | ||
|
|
96309d1da7 | ||
|
|
d815c152df | ||
|
|
25abb410d4 | ||
|
|
baa8cd4493 | ||
|
|
d008b48e3b | ||
|
|
5b86bf7cde | ||
|
|
54ec5153c5 | ||
|
|
6369a887ba | ||
|
|
42edc330ed | ||
|
|
e0e1dc0bf8 | ||
|
|
f381610dd5 | ||
|
|
034df8db20 | ||
|
|
8fe009ed7c | ||
|
|
c21cecaea8 | ||
|
|
1d47220ab2 | ||
|
|
cf691ec714 | ||
|
|
7c2d5de6c7 | ||
|
|
db6ce0481b | ||
|
|
98327bba60 | ||
|
|
a29afcb470 | ||
|
|
bf504d2a46 | ||
|
|
ce9c687d5a | ||
|
|
eaaff3246a | ||
|
|
7ba3c38741 | ||
|
|
c69d22ae26 | ||
|
|
35aee6bf13 | ||
|
|
ac03113efe | ||
|
|
bbea0501a9 | ||
|
|
a7b641acd5 | ||
|
|
c4cf0531ff | ||
|
|
a7d0351c20 | ||
|
|
beb464c0ea | ||
|
|
d8a18c33e8 | ||
|
|
abdc079cd5 | ||
|
|
d0b9ad729c | ||
|
|
24df6275fb | ||
|
|
2500fe4079 | ||
|
|
3a3189e6c3 | ||
|
|
db3c0ffb44 | ||
|
|
8935f38d4e | ||
|
|
667799f7e2 | ||
|
|
d30f9691c1 | ||
|
|
fdd07e3d2b | ||
|
|
419aa42181 | ||
|
|
516b48e7a2 | ||
|
|
03c1b8518c | ||
|
|
39090114f0 | ||
|
|
b2513fc340 | ||
|
|
b989ccb248 | ||
|
|
2067a9fe97 | ||
|
|
a717cdf2d6 | ||
|
|
bb0631e825 | ||
|
|
9dab31b501 | ||
|
|
2080baecff | ||
|
|
69952761e1 | ||
|
|
319976a665 | ||
|
|
8137487dd7 | ||
|
|
0b1a5f6fe9 | ||
|
|
236d3671e2 | ||
|
|
ab33da4b55 | ||
|
|
34f0f5c2c9 | ||
|
|
bad53b08e6 | ||
|
|
1682163674 | ||
|
|
8ca2ea6a0e | ||
|
|
7549c10f35 | ||
|
|
45eb651902 | ||
|
|
6c9f8b17d0 | ||
|
|
771cd1f617 | ||
|
|
75cedb69be | ||
|
|
dc475b06bd | ||
|
|
581baf7d99 | ||
|
|
7ca462d865 | ||
|
|
81e166e0ce | ||
|
|
190ab69c07 | ||
|
|
9d044f6b96 | ||
|
|
713d9932c3 | ||
|
|
83bd8b5ff1 | ||
|
|
f92141140b | ||
|
|
695cdd6f6a | ||
|
|
e7f2703c47 | ||
|
|
3d308f9549 | ||
|
|
f42367c3e7 | ||
|
|
0aa9923d96 | ||
|
|
85b4cd220b | ||
|
|
f0a21a933a | ||
|
|
42884ec0c7 | ||
|
|
c227e4a167 | ||
|
|
c92de17d2f | ||
|
|
c060f16ed7 | ||
|
|
f19d194943 | ||
|
|
a721b1ac67 | ||
|
|
2a147b2b43 | ||
|
|
c004c87b6c | ||
|
|
eff1cee6e1 | ||
|
|
06303195c0 | ||
|
|
dd007634ac | ||
|
|
562f29a2a2 | ||
|
|
11212212b0 | ||
|
|
1271e5321c | ||
|
|
0b80d92d60 | ||
|
|
542d10fd71 | ||
|
|
cec649b346 | ||
|
|
04d1d85350 | ||
|
|
cdbee41fbf | ||
|
|
153de419bc | ||
|
|
bc3d22ae9b | ||
|
|
dafd051712 | ||
|
|
fde28088f4 | ||
|
|
c2db2a08d9 | ||
|
|
1424b8fd50 | ||
|
|
df3d9f6812 | ||
|
|
df570c09ee | ||
|
|
e2ff4b6e90 | ||
|
|
e16c2033b4 | ||
|
|
4159e9e2f6 | ||
|
|
a6ea4bd455 | ||
|
|
f9ce2cffec | ||
|
|
2bf19e8467 | ||
|
|
5a16e75a56 | ||
|
|
fd6c9bbcef | ||
|
|
ab589a9ada | ||
|
|
3a7f42f1a8 | ||
|
|
278e9999a9 | ||
|
|
8ee5e50927 | ||
|
|
3ae2c2ecf0 | ||
|
|
5cfbca30a9 | ||
|
|
6d97ed71b7 | ||
|
|
0a1a14a095 | ||
|
|
674d2ec393 | ||
|
|
96359cf648 | ||
|
|
855b12df1d | ||
|
|
6e8f572094 | ||
|
|
e4fd405431 | ||
|
|
e9e5d9bf3f | ||
|
|
9e1ddcbf89 | ||
|
|
2003f808c7 | ||
|
|
5c591b0e36 | ||
|
|
dac5c72090 | ||
|
|
5c8eb257ea | ||
|
|
703336d148 | ||
|
|
2bc2cc2f54 | ||
|
|
1905d5266b | ||
|
|
58bb02e74d | ||
|
|
dc82d52a02 | ||
|
|
158b19d487 | ||
|
|
e0aa18bb33 | ||
|
|
ac6d2b033e | ||
|
|
a3631a8114 | ||
|
|
5478a521d6 | ||
|
|
ff12f6ff27 | ||
|
|
ae79d1fceb | ||
|
|
45eb5dac3c | ||
|
|
95d1aad02d | ||
|
|
b910e6ea14 | ||
|
|
4ba4999328 | ||
|
|
d7176770d4 | ||
|
|
fe27c7d14e | ||
|
|
0c23f18574 | ||
|
|
fbaac7ba29 | ||
|
|
959eb64fb4 | ||
|
|
290a9e03f2 | ||
|
|
c057543e47 | ||
|
|
7456d2a652 | ||
|
|
965a1e5a94 | ||
|
|
bee00278e6 | ||
|
|
59aae8f311 | ||
|
|
097ca8427d | ||
|
|
546f3f81da | ||
|
|
e879a5a73e | ||
|
|
8eaa894f84 | ||
|
|
be65d0ad03 | ||
|
|
3a69319e76 | ||
|
|
0d24fd9224 | ||
|
|
9bf8b6b4c7 | ||
|
|
4677710c39 | ||
|
|
7fbb24fe4e | ||
|
|
c537a72db4 | ||
|
|
23b14f50e3 | ||
|
|
b9842e7300 | ||
|
|
2cd167fba1 | ||
|
|
133e0a63c5 | ||
|
|
95fe06e1ba | ||
|
|
0c3c9353ab | ||
|
|
cffac32634 | ||
|
|
b035c9078c | ||
|
|
b79cd299cb | ||
|
|
1e8f1e0863 | ||
|
|
0f8e5e93c1 | ||
|
|
4433aaa043 | ||
|
|
68bb940729 | ||
|
|
96e08503da | ||
|
|
21e69c4002 | ||
|
|
bcaa45d181 | ||
|
|
96e8d93844 | ||
|
|
104866a990 | ||
|
|
3a01605b6b | ||
|
|
13106e125b | ||
|
|
8a8a4eeab0 | ||
|
|
075ce6b479 | ||
|
|
c771f143db | ||
|
|
76b9399091 | ||
|
|
81706baebd | ||
|
|
59277d9406 | ||
|
|
73444fc778 | ||
|
|
f62a91b03e | ||
|
|
a820bf8457 | ||
|
|
1120f4c00c | ||
|
|
e2fcc9923d | ||
|
|
a7c6ba5e86 | ||
|
|
5b2aa1846b | ||
|
|
782b270314 | ||
|
|
ff743d5451 | ||
|
|
0f67dfcaa3 | ||
|
|
88cbad9817 | ||
|
|
0ae96f2361 | ||
|
|
32deb2026b | ||
|
|
8a61d8e336 | ||
|
|
6e7be7b1c6 | ||
|
|
51f63eeac9 | ||
|
|
61fa70ac19 | ||
|
|
d0bdbe00ba | ||
|
|
e35e21e280 | ||
|
|
8f443fb9c1 | ||
|
|
d48f86fb02 | ||
|
|
a877f41093 | ||
|
|
88ab6854e5 | ||
|
|
09483e6dc6 | ||
|
|
fce748fe1f | ||
|
|
878b334351 | ||
|
|
0800a11f65 | ||
|
|
37f353eb26 | ||
|
|
68cab6ea0d | ||
|
|
2e250112ee | ||
|
|
a4758241e7 | ||
|
|
4762e42042 | ||
|
|
8e42ae2cc4 | ||
|
|
824529d0aa | ||
|
|
7568de8654 | ||
|
|
16f3644da7 | ||
|
|
e2bf10d90e | ||
|
|
df7b9c808b | ||
|
|
4eb7ae21e8 | ||
|
|
07c6f5e387 | ||
|
|
e02df462ba | ||
|
|
b874c17169 | ||
|
|
e63a340c46 | ||
|
|
aa1c4f58f1 | ||
|
|
089aa98fb8 | ||
|
|
69272c2e85 | ||
|
|
421265ba29 | ||
|
|
0fbe67a146 | ||
|
|
a0a658c1f6 | ||
|
|
232eb53f42 | ||
|
|
147d933a4f | ||
|
|
6dde919c8a | ||
|
|
0bf08d23cd | ||
|
|
ed2d3ddb6b | ||
|
|
3dea3dfe03 | ||
|
|
70a87bf7ca | ||
|
|
1a4f074c9e | ||
|
|
9b1973fbd7 | ||
|
|
03b1afaa8d | ||
|
|
60979fecbb | ||
|
|
e9144d8d30 | ||
|
|
0c87b3168c | ||
|
|
3946ca7fc1 | ||
|
|
2dc3a543b1 | ||
|
|
f7bb13ecd8 | ||
|
|
68737ed84b | ||
|
|
e91bb3d2e9 | ||
|
|
5fd73cbdf3 |
@@ -51,8 +51,15 @@ THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
PREV_VERSION := $(shell echo $(VERSION)|tr a-z Xa-y)
|
||||
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
|
||||
v = Version
|
||||
url-host-prefix = ftp://alpha.gnu.org
|
||||
url = $(url-host-prefix)/gnu/fetish/$(distdir).tar.gz
|
||||
url_list = \
|
||||
ftp://alpha.gnu.org/gnu/fetish/$(distdir).tar.gz \
|
||||
ftp://tug.org/pub/gnu/fetish/$(distdir).tar.gz \
|
||||
ftp://ftp.enst.fr/pub/gnu/gnits/fetish/$(distdir).tar.gz
|
||||
dir_list = \
|
||||
/fs/share/ftp/gnu/fetish \
|
||||
/home/ftp/pub/gnu/fetish \
|
||||
/pub/gnu/gnits/fetish
|
||||
|
||||
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
|
||||
rel-check:
|
||||
@@ -70,7 +77,9 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
echo; \
|
||||
echo FIXME: put comments here; \
|
||||
echo; \
|
||||
echo " $(url)"; \
|
||||
for url in $(url_list); do \
|
||||
echo " $$url"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo "$(md5) $(distdir).tar.gz"; \
|
||||
echo; \
|
||||
@@ -89,7 +98,9 @@ alpha:
|
||||
ln $(distdir).tar.gz ../release
|
||||
chmod a-w $(distdir).tar.gz
|
||||
@echo =====================================
|
||||
@echo 'ncftp -u $(url-host-prefix)/fs/share/ftp/gnu/fetish/'
|
||||
@for url in $(dir_list); do \
|
||||
echo "ncftp -u $$url"; \
|
||||
done
|
||||
@echo '# put $(distdir).tar.gz'
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo 'pot-mail $(distdir).tar.gz | bash'
|
||||
|
||||
8
THANKS
8
THANKS
@@ -3,11 +3,14 @@ The rest of the addresses are still in the ChangeLog.
|
||||
|
||||
Achim Blumensath: blume@corona.oche.de
|
||||
aldomel: aldomel@ix.netcom.com
|
||||
Alen Muzinic: zveki@fly.cc.fer.hr
|
||||
Akim Demaille: demaille@inf.enst.fr
|
||||
Alain Magloire: alain@qnx.com
|
||||
Alexey Solovyov: alekso@math.uu.se
|
||||
Andreas Jaeger: jaeger@gnu.org
|
||||
Andreas Schwab: schwab@issan.informatik.uni-dortmund.de
|
||||
Andrew Dalke: dalke@bioreason.com
|
||||
Andrew Tridgell: tridge@samba.org
|
||||
Andries Brouwer: Andries.Brouwer@cwi.nl
|
||||
Arne Henrik Juul: arnej@imf.unit.no
|
||||
Bauke Jan Douma: bjdouma@xs4all.nl
|
||||
@@ -33,12 +36,16 @@ James: james@albion.glarp.com
|
||||
James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Tanis: jtt@soscorp.com
|
||||
Jamie Lokier: jamie@imbolc.ucc.ie
|
||||
Janos Farkas: chexum@shadow.banki.hu
|
||||
Jesse Thilo: jgt2@eecs.lehigh.edu
|
||||
Joakim Rosqvist: dvljrt@cs.umu.se
|
||||
Johan Danielsson: joda@pdc.kth.se
|
||||
John Bley: jbb6@acpub.duke.edu
|
||||
John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th
|
||||
John Gotts: jgotts@umich.edu
|
||||
Karl Heuer: kwzh@gnu.org
|
||||
Kjetil Torgrim Homme: kjetilho@ifi.uio.no
|
||||
Larry McVoy: lm@sgi.com
|
||||
Lars Hecking: lhecking@nmrc.ucc.ie
|
||||
Lorne Baker: lbaker@nitro.avint.net
|
||||
Marcus Daniels: marcus@sysc.pdx.edu
|
||||
@@ -68,3 +75,4 @@ Ulrich Drepper: drepper@cygnus.com
|
||||
Volker Borchert: bt@teknon.de
|
||||
Michael Veksler: mveksler@techunix.technion.ac.il
|
||||
Wayne Stewart: wstewa@atl.com
|
||||
William Bader: william@nscs.fast.net
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -66,6 +66,7 @@ DF_PROG = @DF_PROG@
|
||||
GENCAT = @GENCAT@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -89,6 +90,7 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
|
||||
info_TEXINFOS = fileutils.texi
|
||||
|
||||
EXTRA_DIST = perm.texi getdate.texi
|
||||
@@ -252,10 +254,11 @@ dist-info: $(INFO_DEPS)
|
||||
|
||||
mostlyclean-aminfo:
|
||||
-rm -f fileutils.aux fileutils.cp fileutils.cps fileutils.dvi \
|
||||
fileutils.fn fileutils.fns fileutils.ky fileutils.kys \
|
||||
fileutils.ps fileutils.log fileutils.pg fileutils.toc \
|
||||
fileutils.tp fileutils.tps fileutils.vr fileutils.vrs \
|
||||
fileutils.op fileutils.tr fileutils.cv fileutils.cn
|
||||
fileutils.fn fileutils.fns fileutils.pgs fileutils.ky \
|
||||
fileutils.kys fileutils.ps fileutils.log fileutils.pg \
|
||||
fileutils.toc fileutils.tp fileutils.tps fileutils.vr \
|
||||
fileutils.vrs fileutils.op fileutils.tr fileutils.cv \
|
||||
fileutils.cn
|
||||
|
||||
clean-aminfo:
|
||||
|
||||
@@ -285,7 +288,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
@@ -315,7 +318,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile $(INFO_DEPS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(infodir)
|
||||
|
||||
|
||||
@@ -797,7 +797,7 @@ This makes it possible to test @code{expr length quote "$x"} or
|
||||
@code{expr quote "$x" : '.*/\(.\)'} and have it do the right thing even if
|
||||
the value of @var{$x} happens to be (for example) @code{/} or @code{index}.
|
||||
This operator is a GNU extension. It is disabled when
|
||||
the environment variable @var{POSIXLY_CORRECT} is set.
|
||||
the environment variable @env{POSIXLY_CORRECT} is set.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -1749,7 +1749,7 @@ Tell the kernel that the terminal has @var{n} columns. Non-POSIX.
|
||||
@vindex COLUMNS
|
||||
Print the number of rows and columns that the kernel thinks the
|
||||
terminal has. (Systems that don't support rows and cols in the kernel
|
||||
typically use the environment variables @code{LINES} and @code{COLUMNS}
|
||||
typically use the environment variables @env{LINES} and @env{COLUMNS}
|
||||
instead; however, GNU @code{stty} does not know anything about them.)
|
||||
Non-POSIX.
|
||||
|
||||
@@ -2390,6 +2390,7 @@ input. This is useful when you have many dates to process, because the
|
||||
system overhead of starting up the @code{date} executable many times can
|
||||
be considerable.
|
||||
|
||||
@item -R
|
||||
@itemx --rfc-822
|
||||
@opindex -R
|
||||
@opindex --rfc-822
|
||||
@@ -2690,7 +2691,7 @@ Ordinarily, filenames are looked up starting at the root of the
|
||||
directory structure, i.e., @file{/}. @code{chroot} changes the root to
|
||||
the directory @var{newroot} (which must exist) and then runs
|
||||
@var{command} with optional @var{args}. If @var{command} is not
|
||||
specified, the default is the value of the @code{SHELL} environment
|
||||
specified, the default is the value of the @env{SHELL} environment
|
||||
variable or @code{/bin/sh} if not set, invoked with the @samp{-i} option.
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
@@ -2720,7 +2721,7 @@ to an empty value is different from unsetting it.
|
||||
|
||||
@vindex PATH
|
||||
The first remaining argument specifies the program name to invoke; it is
|
||||
searched for according to the @code{PATH} environment variable. Any
|
||||
searched for according to the @env{PATH} environment variable. Any
|
||||
remaining arguments are passed as arguments to that program.
|
||||
|
||||
@cindex environment, printing
|
||||
@@ -2864,9 +2865,9 @@ effective user id of zero (the super-user).
|
||||
@vindex LOGNAME
|
||||
@cindex login shell
|
||||
By default, @code{su} does not change the current directory.
|
||||
It sets the environment variables @code{HOME} and @code{SHELL}
|
||||
It sets the environment variables @env{HOME} and @env{SHELL}
|
||||
from the password entry for @var{user}, and if @var{user} is not
|
||||
the super-user, sets @code{USER} and @code{LOGNAME} to @var{user}.
|
||||
the super-user, sets @env{USER} and @env{LOGNAME} to @var{user}.
|
||||
By default, the shell is not a login shell.
|
||||
|
||||
Any additional @var{arg}s are passed as additional arguments to the
|
||||
@@ -2917,10 +2918,10 @@ expansion (globbing), which is not likely to be useful.
|
||||
@vindex PATH
|
||||
@cindex login shell, creating
|
||||
Make the shell a login shell. This means the following. Unset all
|
||||
environment variables except @code{TERM}, @code{HOME}, and @code{SHELL}
|
||||
(which are set as described above), and @code{USER} and @code{LOGNAME}
|
||||
environment variables except @env{TERM}, @env{HOME}, and @env{SHELL}
|
||||
(which are set as described above), and @env{USER} and @env{LOGNAME}
|
||||
(which are set, even for the super-user, as described above), and set
|
||||
@code{PATH} to a compiled-in default value. Change to @var{user}'s home
|
||||
@env{PATH} to a compiled-in default value. Change to @var{user}'s home
|
||||
directory. Prepend @samp{-} to the shell's name, intended to make it
|
||||
read its login startup file(s).
|
||||
|
||||
@@ -2933,9 +2934,9 @@ read its login startup file(s).
|
||||
@cindex environment, preserving
|
||||
@flindex /etc/shells
|
||||
@cindex restricted shell
|
||||
Do not change the environment variables @code{HOME}, @code{USER},
|
||||
@code{LOGNAME}, or @code{SHELL}. Run the shell given in the environment
|
||||
variable @code{SHELL} instead of the shell from @var{user}'s passwd
|
||||
Do not change the environment variables @env{HOME}, @env{USER},
|
||||
@env{LOGNAME}, or @env{SHELL}. Run the shell given in the environment
|
||||
variable @env{SHELL} instead of the shell from @var{user}'s passwd
|
||||
entry, unless the user running @code{su} is not the superuser and
|
||||
@var{user}'s shell is restricted. A @dfn{restricted shell} is one that
|
||||
is not listed in the file @file{/etc/shells}, or in a compiled-in list
|
||||
|
||||
982
doc/texinfo.tex
982
doc/texinfo.tex
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,9 @@ by the Foundation.
|
||||
@end titlepage
|
||||
|
||||
|
||||
@c If your makeinfo doesn't grok this @ifnottex directive, then either
|
||||
@c get a newer version of makeinfo or do s/ifnottex/ifinfo/ here and on
|
||||
@c the matching @end directive below.
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top GNU text utilities
|
||||
@@ -165,7 +168,7 @@ Operating on sorted files
|
||||
|
||||
@code{ptx}: Produce permuted indexes
|
||||
|
||||
* General options in ptx:: Options which affect general program behaviour.
|
||||
* General options in ptx:: Options which affect general program behavior.
|
||||
* Charset selection in ptx:: Underlying character set considerations.
|
||||
* Input processing in ptx:: Input fields, contexts, and keyword selection.
|
||||
* Output formatting in ptx:: Types of output format, and sizing the fields.
|
||||
@@ -961,23 +964,43 @@ optionally outputting in multicolumn format; optionally merges all
|
||||
pr [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@end example
|
||||
|
||||
By default, a 5-line header is printed: two blank lines; a line with the
|
||||
date, the file name, and the page count; and two more blank lines. A
|
||||
footer of five blank lines is also printed. With the @samp{-f} option, a
|
||||
3-line header is printed: the leading two blank lines are omitted; no
|
||||
footer used. The default @var{page_length} in both cases is 66 lines.
|
||||
The text line of the header takes up the full @var{page_width} in the
|
||||
form @samp{yy-mm-dd HH:MM string Page nnnn}. String is a centered
|
||||
string.
|
||||
By default, a 5-line header is printed at each page: two blank lines;
|
||||
a line with the date, the filename, and the page count; and two more
|
||||
blank lines. A footer of five blank lines is also printed. With the @samp{-F}
|
||||
option, a 3-line header is printed: the leading two blank lines are
|
||||
omitted; no footer is used. The default @var{page_length} in both cases is 66
|
||||
lines. The default number of text lines changes from 56 (without @samp{-F})
|
||||
to 63 (with @samp{-F}). The text line of the header takes up the full
|
||||
@var{page_width} in the form @samp{yyyy-mm-dd HH:MM string Page nnnn}.
|
||||
String is a centered header string.
|
||||
|
||||
Form feeds in the input cause page breaks in the output. Multiple form
|
||||
Form feeds in the input cause page breaks in the output. Multiple form
|
||||
feeds produce empty pages.
|
||||
|
||||
Columns have equal width, separated by an optional string (default
|
||||
space). Lines will always be truncated to line width (default 72),
|
||||
unless you use the @samp{-j} option. For single column output no line
|
||||
truncation occurs by default. Use @samp{-w} option to truncate lines
|
||||
in that case.
|
||||
Columns are of equal width, separated by an optional string (default
|
||||
is @samp{space}). For multicolumn output, lines will always be truncated to
|
||||
@var{page_width} (default 72), unless you use the @samp{-J} option. For single
|
||||
column output no line truncation occurs by default. Use @samp{-W} option to
|
||||
truncate lines in that case.
|
||||
|
||||
Including version 1.22i:
|
||||
|
||||
Some small @var{letter options} (@samp{-s}, @samp{-w}) has been redefined
|
||||
with the object of a better @var{posix} compliance. The output of some
|
||||
further cases has been adapted to other @var{unix}es. A violation of
|
||||
downward compatibility has to be accepted.
|
||||
|
||||
Some @var{new capital letter} options (@samp{-J}, @samp{-S}, @samp{-W})
|
||||
has been introduced to turn off unexpected interferences of small letter
|
||||
options. The @samp{-N} option and the second argument @var{last_page}
|
||||
of @samp{+FIRST_PAGE} offer more flexibility. The detailed handling of
|
||||
form feeds set in the input files requires @samp{-T} option.
|
||||
|
||||
Capital letter options dominate small letter ones.
|
||||
|
||||
Some of the option-arguments (compare @samp{-s}, @samp{-S}, @samp{-e},
|
||||
@samp{-i}, @samp{-n}) cannot be specified as separate arguments from the
|
||||
preceding option letter (already stated in the @var{posix} specification).
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@@ -987,32 +1010,39 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
@itemx --pages=@var{first_page}[:@var{last_page}]
|
||||
@opindex +@var{first_page}[:@var{last_page}]
|
||||
@opindex --pages
|
||||
Begin printing with page @var{first_page} and stop with
|
||||
@var{last_page}. Missing @samp{:@var{last_page}} implies end of file. While
|
||||
estimating the number of skipped pages each form feed in the input file
|
||||
results in a new page. Page counting with and without
|
||||
@samp{+@var{first_page}} is identical. By default, it starts with the
|
||||
first page of input file (not first page printed). Page numbering may be
|
||||
altered by @samp{-N} option.
|
||||
Begin printing with page @var{first_page} and stop with @var{last_page}.
|
||||
Missing @samp{:@var{last_page}} implies end of file. While estimating
|
||||
the number of skipped pages each form feed in the input file results
|
||||
in a new page. Page counting with and without @samp{+@var{first_page}}
|
||||
is identical. By default, counting starts with the first page of input
|
||||
file (not first page printed). Line numbering may be altered by @samp{-N}
|
||||
option.
|
||||
|
||||
@item -@var{column}
|
||||
@itemx --columns=@var{column}
|
||||
@opindex -@var{column}
|
||||
@opindex --columns
|
||||
@cindex down columns
|
||||
With each single @var{file}, produce @var{column}-column output and
|
||||
print columns down. The column width is automatically estimated from
|
||||
@var{page_width}. This option might well cause some columns to be
|
||||
truncated. The number of lines in the columns on each page will be
|
||||
balanced. @samp{-@var{column}} may not be used with @samp{-m} option.
|
||||
With each single @var{file}, produce @var{column} columns of output
|
||||
(default is 1) and print columns down, unless @samp{-a} is used. The
|
||||
column width is automatically decreased as @var{column} increases; unless
|
||||
you use the @samp{-W/-w} option to increase @var{page_width} as well.
|
||||
This option might well cause some lines to be truncated. The number of
|
||||
lines in the columns on each page are balanced. The options @samp{-e}
|
||||
and @samp{-i} are on for multiple text-column output. Together with
|
||||
@samp{-J} option column alignment and line truncation is turned off.
|
||||
Lines of full length are joined in a free field format and @samp{-S}
|
||||
option may set field separators. @samp{-@var{column}} may not be used
|
||||
with @samp{-m} option.
|
||||
|
||||
@item -a
|
||||
@itemx --across
|
||||
@opindex -a
|
||||
@opindex --across
|
||||
@cindex across columns
|
||||
With each single @var{file}, print columns across rather than down.
|
||||
@var{column} must be greater than one.
|
||||
With each single @var{file}, print columns across rather than down. The
|
||||
@samp{-@var{column}} option must be given with @var{column} greater than one.
|
||||
If a line is too long to fit in a column, it is truncated.
|
||||
|
||||
@item -c
|
||||
@itemx --show-control-chars
|
||||
@@ -1034,7 +1064,7 @@ Double space the output.
|
||||
@opindex -e
|
||||
@opindex --expand-tabs
|
||||
@cindex input tabs
|
||||
Expand tabs to spaces on input. Optional argument @var{in-tabchar} is
|
||||
Expand @var{tab}s to spaces on input. Optional argument @var{in-tabchar} is
|
||||
the input tab character (default is @key{TAB}). Second optional
|
||||
argument @var{in-tabwidth} is the input tab character's width (default
|
||||
is 8).
|
||||
@@ -1045,93 +1075,110 @@ is 8).
|
||||
@opindex -F
|
||||
@opindex -f
|
||||
@opindex --form-feed
|
||||
Use a form feed instead of newlines to separate output pages. Default
|
||||
page length of 66 lines is not altered. But the number of lines of text
|
||||
per page changes from 56 to 63 lines.
|
||||
|
||||
Use a form feed instead of newlines to separate output pages. The default
|
||||
page length of 66 lines is not altered. But the number of lines of text
|
||||
per page changes from default 56 to 63 lines.
|
||||
|
||||
@item -h @var{HEADER}
|
||||
@itemx --header=@var{HEADER}
|
||||
@opindex -h
|
||||
@opindex --header
|
||||
Replace the file name in the header with the centered string
|
||||
@var{header}. Left-hand-side truncation (marked by a @samp{*}) may occur
|
||||
if the total header line @samp{yy-mm-dd HH:MM HEADER Page nnnn}
|
||||
becomes larger than @var{page_width}. @samp{-h ""} prints a blank line
|
||||
header. Don't use @samp{-h""}. A space between the -h option and the
|
||||
argument is always peremptory.
|
||||
Replace the filename in the header with the centered string @var{header}.
|
||||
Left-hand-side truncation (marked by a @samp{*}) may occur if the total
|
||||
header line @samp{yyyy-mm-dd HH:MM HEADER Page nnnn} becomes larger than
|
||||
@var{page_width}. @samp{-h ""} prints a blank line header. Don't use
|
||||
@samp{-h""}.
|
||||
A space between the @samp{-h} option and the argument is always
|
||||
indispensable.
|
||||
|
||||
@item -i[@var{out-tabchar}[@var{out-tabwidth}]]
|
||||
@itemx --output-tabs[=@var{out-tabchar}[@var{out-tabwidth}]]
|
||||
@opindex -i
|
||||
@opindex --output-tabs
|
||||
@cindex output tabs
|
||||
Replace spaces with tabs on output. Optional argument @var{out-tabchar}
|
||||
Replace spaces with @var{tab}s on output. Optional argument @var{out-tabchar}
|
||||
is the output tab character (default is @key{TAB}). Second optional
|
||||
argument @var{out-tabwidth} is the output tab character's width (default
|
||||
is 8).
|
||||
|
||||
@item -j
|
||||
@item -J
|
||||
@itemx --join-lines
|
||||
@opindex -j
|
||||
@opindex -J
|
||||
@opindex --join-lines
|
||||
Merge lines of full length. Used together with the column options
|
||||
@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}. Turns off
|
||||
@samp{-w} line truncation; no column alignment used; may be used with
|
||||
@samp{-s[@var{separator}]}.
|
||||
Merge lines of full length. Used together with the column options
|
||||
@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}. Turns off
|
||||
@samp{-W/-w} line truncation;
|
||||
no column alignment used; may be used with @samp{-S[@var{string}]}.
|
||||
@samp{-J} has been introduced (together with @samp{-W} and @samp{-S})
|
||||
to disentangle the old (@var{posix} compliant) options @samp{-w} and
|
||||
@samp{-s} along with the three column options.
|
||||
|
||||
|
||||
@item -l @var{page_length}
|
||||
@itemx --length=@var{page_length}
|
||||
@opindex -l
|
||||
@opindex --length
|
||||
Set the page length to @var{page_length} (default 66) lines. If
|
||||
@var{page_length} is less than or equal 10 (and <= 3 with @samp{-f}),
|
||||
the headers and footers are omitted, and all form feeds set in input
|
||||
files are eliminated, as if the @samp{-T} option had been given.
|
||||
Set the page length to @var{page_length} (default 66) lines, including
|
||||
the lines of the header [and the footer]. If @var{page_length} is less
|
||||
than or equal 10 (and <= 3 with @samp{-F}), the header and footer are
|
||||
omitted, and all form feeds set in input files are eliminated, as if
|
||||
the @samp{-T} option had been given.
|
||||
|
||||
@item -m
|
||||
@itemx --merge
|
||||
@opindex -m
|
||||
@opindex --merge
|
||||
Merge and print all @var{file}s in parallel, one in each column. If a
|
||||
line is too long to fit in a column, it is truncated (but see
|
||||
@samp{-j}). @samp{-s[@var{separator}]} may be used. Empty pages in some
|
||||
@var{file}s (form feeds set) produce empty columns, still marked by
|
||||
@var{separator}. Completely empty common pages show no separators or
|
||||
line numbers. The default header becomes
|
||||
@samp{yy-mm-dd HH:MM <blanks> Page nnnn}; may be used with
|
||||
@samp{-h @var{header}} to fill up the middle part.
|
||||
|
||||
Merge and print all @var{file}s in parallel, one in each column. If a
|
||||
line is too long to fit in a column, it is truncated, unless @samp{-J}
|
||||
option is used. @samp{-S[@var{string}]} may be used. Empty pages in
|
||||
some @var{file}s (form feeds set) produce empty columns, still marked
|
||||
by @var{string}. The result is a continuous line numbering and column
|
||||
marking throughout the whole merged file. Completely empty merged pages
|
||||
show no separators or line numbers. The default header becomes
|
||||
@samp{yyyy-mm-dd HH:MM <blanks> Page nnnn}; may be used with
|
||||
@samp{-h @var{header}} to fill up the middle blank part.
|
||||
|
||||
@item -n[@var{number-separator}[@var{digits}]]
|
||||
@itemx --number-lines[=@var{number-separator}[@var{digits}]]
|
||||
@opindex -n
|
||||
@opindex --number-lines
|
||||
Precede each column with a line number; with parallel @var{file}s
|
||||
(@samp{-m}), precede only each line with a line number. Optional argument
|
||||
@var{number-separator} is the character to print after each number
|
||||
(default is @key{TAB}). Optional argument @var{digits} is the number of
|
||||
digits per line number (default is 5). Default line counting starts with
|
||||
first line of the input file (not with the first line printed, see
|
||||
@samp{-N}).
|
||||
Provide @var{digits} digit line numbering (default for @var{digits} is
|
||||
5). With multicolumn output the number occupies the first @var{digits}
|
||||
column positions of each text column or only each line of @samp{-m}
|
||||
output. With single column output the number precedes each line just as
|
||||
@samp{-m} does. Default counting of the line numbers starts with 1st
|
||||
line of the input file (not the 1st line printed, compare the
|
||||
@samp{--page} option and @samp{-N} option).
|
||||
Optional argument @var{number-separator} is the character appended to
|
||||
the line number to separate it from the text followed. The default
|
||||
separator is a @key{TAB}. In a strict sense a @key{TAB} is always
|
||||
printed with single column output only. The @var{TAB}-width varies
|
||||
with the @var{TAB}-position, e.g. with the left @var{margin} specified
|
||||
by @samp{-o} option. With multicolumn output priority is given to
|
||||
@samp{equal width of output columns} (a @var{posix} specification).
|
||||
The @var{TAB}-width is fixed to the value of the 1st column and does
|
||||
not change with different values of left @var{margin}. That means a
|
||||
fixed number of spaces is always printed in the place of the
|
||||
@var{number-separator tab}. The tabification depends upon the output
|
||||
position.
|
||||
|
||||
@item -N @var{line_number}
|
||||
@itemx --first-line-number=@var{line_number}
|
||||
@opindex -N
|
||||
@opindex --first-line-number
|
||||
Start line counting with no. @var{line_number} at first line of first
|
||||
page printed.
|
||||
Start line counting with the number @var{line_number} at first line of
|
||||
first page printed (in most cases not the first line of the input file).
|
||||
|
||||
@item -o @var{n}
|
||||
@itemx --indent=@var{n}
|
||||
@item -o @var{margin}
|
||||
@itemx --indent=@var{margin}
|
||||
@opindex -o
|
||||
@opindex --indent
|
||||
@cindex indenting lines
|
||||
@cindex left margin
|
||||
Indent each line with @var{n} (default is zero) spaces wide, i.e., set
|
||||
the left margin. The total page width is @var{n} plus the width set
|
||||
with the @samp{-w} option.
|
||||
Indent each line with a margin @var{margin} spaces wide (default is zero).
|
||||
The total page width is the size of the margin plus the @var{page_width}
|
||||
set with the @samp{-W/-w} option. A limited overflow may occur with
|
||||
numbered single column output (compare @samp{-n} option).
|
||||
|
||||
@item -r
|
||||
@itemx --no-file-warnings
|
||||
@@ -1140,34 +1187,50 @@ with the @samp{-w} option.
|
||||
Do not print a warning message when an argument @var{file} cannot be
|
||||
opened. (The exit status will still be nonzero, however.)
|
||||
|
||||
@item -s[@var{separator}]
|
||||
@itemx --separator[=@var{separator}]
|
||||
@item -s[@var{char}]
|
||||
@itemx --separator[=@var{char}]
|
||||
@opindex -s
|
||||
@opindex --separator
|
||||
Separate columns by a string @var{separator}. Don't use
|
||||
@samp{-s @var{separator}}, no space between flag and argument. If this
|
||||
option is omitted altogether, the default is @key{TAB} together with
|
||||
@samp{-j} option and space otherwise (same as @samp{-s" "}). With
|
||||
@samp{-s} only, no separator is used (same as @samp{-s""}). @samp{-s}
|
||||
does not affect line truncation or column alignment.
|
||||
Separate columns by a single character @var{char}. Default for @var{char}
|
||||
is the @key{TAB} character without @samp{-w} and @samp{no character} with
|
||||
@samp{-w}. Without @samp{-s} default separator @samp{space} is set.
|
||||
@samp{-s[char]} turns off line truncation of all three column options
|
||||
(@samp{-COLUMN}|@samp{-a -COLUMN}|@samp{-m}) except @samp{-w} is set.
|
||||
That is a @var{posix} compliant formulation.
|
||||
|
||||
|
||||
@item -S[@var{string}]
|
||||
@itemx --sep-string[=@var{string}]
|
||||
@opindex -S
|
||||
@opindex --sep-string
|
||||
Separate columns by any string @var{string}. The @samp{-S} option doesn't
|
||||
react upon the @samp{-W/-w} option (unlike @samp{-s} option does). It
|
||||
does not affect line truncation or column alignment. A separator is
|
||||
defined, nothing else. Without @samp{-S}: default separator @key{TAB}
|
||||
is used with @samp{-J} and @samp{space} otherwise (same as @samp{-S" "}).
|
||||
With @samp{-S} only: no separator is used, same as @samp{-S""}. Quotes
|
||||
should be used with blanks and some shell active characters. Some of the
|
||||
@code{pr} options don't allow the option letter to be separated from its
|
||||
argument. @samp{-S/-s} is one of them. Don't use @samp{-S "STRING"}.
|
||||
That's @var{posix} compliant.
|
||||
|
||||
@item -t
|
||||
@itemx --omit-header
|
||||
@opindex -t
|
||||
@opindex --omit-header
|
||||
Do not print the usual header [and footer] on each page, and do not fill
|
||||
out the bottoms of pages (with blank lines or a form feed). No page
|
||||
structure is produced, but retain form feeds set in the input files. The
|
||||
predefined page layout is not changed. @samp{-t} or @samp{-T} may be
|
||||
useful together with other options; e.g.: @samp{-t -e4}, expand
|
||||
@key{TAB} in the input file to 4 spaces but do not do any other changes.
|
||||
Use of @samp{-t} overrides @samp{-h}.
|
||||
out the bottom of pages (with blank lines or a form feed). No page
|
||||
structure is produced, but form feeds set in the input files are retained.
|
||||
The predefined pagination is not changed. @samp{-t} or @samp{-T} may be
|
||||
useful together with other options; e.g.: @samp{-t -e4}, expand @key{TAB}
|
||||
in the input file to 4 spaces but don't make any other changes. Use of
|
||||
@samp{-t} overrides @samp{-h}.
|
||||
|
||||
@item -T
|
||||
@itemx --omit-pagination
|
||||
@opindex -T
|
||||
@opindex --omit-pagination
|
||||
Do not print header [and footer]. In addition eliminate all form feeds
|
||||
Do not print header [and footer]. In addition eliminate all form feeds
|
||||
set in the input files.
|
||||
|
||||
@item -v
|
||||
@@ -1180,14 +1243,28 @@ Print unprintable characters in octal backslash notation.
|
||||
@itemx --width=@var{page_width}
|
||||
@opindex -w
|
||||
@opindex --width
|
||||
Set the page width to @var{page_width} (default 72) characters.
|
||||
With/without @samp{-w}, header lines are always truncated to
|
||||
@var{page_width} characters. With @samp{-w}, text lines are truncated,
|
||||
unless @samp{-j} is used. Without @samp{-w} together with one of the
|
||||
column options @samp{-@var{column}}, @samp{-a -@var{column}} or
|
||||
@samp{-m}, default truncation of text lines to 72 characters is used.
|
||||
Without @samp{-w} and without any of the column options, no line
|
||||
truncation is used. That's equivalent to @samp{-w 72 -j}.
|
||||
Set page width to @var{page_width} characters for multiple text-column
|
||||
output only (default for @var{page_width} is 72). @samp{-s[CHAR]} turns
|
||||
off the default page width and any line truncation and column alignment.
|
||||
Lines of full length are merged, regardless of the column options
|
||||
set. No @var{page_width} setting is possible with single column output.
|
||||
A @var{posix} compliant formulation.
|
||||
|
||||
@item -W @var{page_width}
|
||||
@itemx --page_width=@var{page_width}
|
||||
@opindex -W
|
||||
@opindex --page_width
|
||||
Set the page width to @var{page_width} characters. That's valid with and
|
||||
without a column option. Text lines are truncated, unless @samp{-J}
|
||||
is used. Together with one of the three column options
|
||||
(@samp{-@var{column}}, @samp{-a -@var{column}} or @samp{-m}) column
|
||||
alignment is always used. The separator options @samp{-S} or @samp{-s}
|
||||
don't affect the @samp{-W} option. Default is 72 characters. Without
|
||||
@samp{-W @var{page_width}} and without any of the column options NO line
|
||||
truncation is used (defined to keep downward compatibility and to meet
|
||||
most frequent tasks). That's equivalent to @samp{-W 72 -J}. With and
|
||||
without @samp{-W @var{page_width}} the header line is always truncated
|
||||
to avoid line overflow.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -1207,7 +1284,7 @@ lines. Synopsis:
|
||||
fold [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@end example
|
||||
|
||||
By default, @code{fold} breaks lines wider than 80 columns. The output
|
||||
By default, @code{fold} breaks lines wider than 80 columns. The output
|
||||
is split into as many lines as necessary.
|
||||
|
||||
@cindex screen columns
|
||||
@@ -1991,7 +2068,7 @@ addition, if the final byte of an input file is not a newline, GNU
|
||||
Upon any error, @code{sort} exits with a status of @samp{2}.
|
||||
|
||||
@vindex TMPDIR
|
||||
If the environment variable @code{TMPDIR} is set, @code{sort} uses its
|
||||
If the environment variable @env{TMPDIR} is set, @code{sort} uses its
|
||||
value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@samp{-T @var{tempdir}} option in turn overrides the environment
|
||||
variable.
|
||||
@@ -2884,7 +2961,7 @@ line width computations.
|
||||
All 256 characters, even @kbd{NUL}s, are always read and processed from
|
||||
input file with no adverse effect, even if GNU extensions are disabled.
|
||||
However, System V @code{ptx} does not accept 8-bit characters, a few
|
||||
control characters are rejected, and the tilda @kbd{~} is condemned.
|
||||
control characters are rejected, and the tilde @kbd{~} is condemned.
|
||||
|
||||
@item
|
||||
Input line length is only limited by available memory, even if GNU
|
||||
@@ -2967,12 +3044,12 @@ take up 1 character.
|
||||
Print only the fields listed in @var{field-list}. Fields are
|
||||
separated by a @key{TAB} by default.
|
||||
|
||||
@item -d @var{delim}
|
||||
@itemx --delimiter=@var{delim}
|
||||
@item -d @var{input_delim_byte}
|
||||
@itemx --delimiter=@var{input_delim_byte}
|
||||
@opindex -d
|
||||
@opindex --delimiter
|
||||
For @samp{-f}, fields are separated by the first character in @var{delim}
|
||||
(default is @key{TAB}).
|
||||
For @samp{-f}, fields are separated in the input by the first character
|
||||
in @var{input_delim_byte} (default is @key{TAB}).
|
||||
|
||||
@item -n
|
||||
@opindex -n
|
||||
@@ -2985,6 +3062,12 @@ Do not split multi-byte characters (no-op for now).
|
||||
For @samp{-f}, do not print lines that do not contain the field separator
|
||||
character.
|
||||
|
||||
@itemx --output-delimiter=@var{output_delim_string}
|
||||
@opindex --output-delimiter
|
||||
For @samp{-f}, output fields are separated by @var{output_delim_string}
|
||||
The default is to use the input delimiter.
|
||||
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -3443,7 +3526,7 @@ cat "$@@" \
|
||||
@subsection Warning messages
|
||||
|
||||
@vindex POSIXLY_CORRECT
|
||||
Setting the environment variable @code{POSIXLY_CORRECT} turns off the
|
||||
Setting the environment variable @env{POSIXLY_CORRECT} turns off the
|
||||
following warning and error messages, for strict compliance with
|
||||
@sc{POSIX.2}. Otherwise, the following diagnostics are issued:
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
|
||||
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c \
|
||||
version-etc.c xgetcwd.c xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
@@ -22,7 +22,7 @@ dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
version-etc.h xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c lstat.c stat.c
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -66,6 +66,7 @@ DF_PROG = @DF_PROG@
|
||||
GENCAT = @GENCAT@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -90,19 +91,20 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = ../src/ansi2knr
|
||||
|
||||
noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c addext.c argmatch.c backupfile.c basename.c closeout.c dirname.c exclude.c filemode.c full-write.c human.c idcache.c isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c addext.c argmatch.c backupfile.c basename.c closeout.c dirname.c exclude.c filemode.c full-write.c human.c idcache.c isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c version-etc.c xgetcwd.c xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
|
||||
|
||||
|
||||
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h version-etc.h xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
|
||||
BUILT_SOURCES = getdate.c lstat.c stat.c
|
||||
@@ -124,13 +126,13 @@ addext$U.o argmatch$U.o backupfile$U.o basename$U.o closeout$U.o \
|
||||
dirname$U.o exclude$U.o filemode$U.o full-write$U.o human$U.o \
|
||||
idcache$U.o isdir$U.o long-options$U.o makepath$U.o modechange$U.o \
|
||||
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
|
||||
savedir$U.o stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o \
|
||||
xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
|
||||
savedir$U.o stripslash$U.o userspec$U.o version-etc$U.o xgetcwd$U.o \
|
||||
xmalloc$U.o xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
|
||||
AR = ar
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in TODO alloca.c chown.c error.c \
|
||||
@@ -162,8 +164,8 @@ DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
|
||||
.deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P \
|
||||
.deps/stripslash.P .deps/strncasecmp.P .deps/strndup.P .deps/strstr.P \
|
||||
.deps/strtol.P .deps/strtoul.P .deps/strverscmp.P .deps/userspec.P \
|
||||
.deps/utime.P .deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P \
|
||||
.deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
|
||||
.deps/utime.P .deps/version-etc.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)
|
||||
|
||||
@@ -352,6 +354,8 @@ userspec_.c: userspec.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/userspec.c; then echo $(srcdir)/userspec.c; else echo userspec.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > userspec_.c
|
||||
utime_.c: utime.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/utime.c; then echo $(srcdir)/utime.c; else echo utime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > utime_.c
|
||||
version-etc_.c: version-etc.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/version-etc.c; then echo $(srcdir)/version-etc.c; else echo version-etc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > version-etc_.c
|
||||
xgetcwd_.c: xgetcwd.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xgetcwd.c; then echo $(srcdir)/xgetcwd.c; else echo xgetcwd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xgetcwd_.c
|
||||
xmalloc_.c: xmalloc.c $(ANSI2KNR)
|
||||
@@ -374,8 +378,9 @@ modechange_.o mountlist_.o obstack_.o path-concat_.o posixtm_.o \
|
||||
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o \
|
||||
safe-read_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
|
||||
strdup_.o strftime_.o stripslash_.o strncasecmp_.o strndup_.o strstr_.o \
|
||||
strtol_.o strtoul_.o strverscmp_.o userspec_.o utime_.o xgetcwd_.o \
|
||||
xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
|
||||
strtol_.o strtoul_.o strverscmp_.o userspec_.o utime_.o version-etc_.o \
|
||||
xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : \
|
||||
$(ANSI2KNR)
|
||||
.y.c:
|
||||
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
|
||||
if test -f y.tab.h; then \
|
||||
@@ -426,7 +431,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
@@ -487,7 +492,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
@@ -500,7 +505,7 @@ distclean-generic:
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
-test -z "getdatehgetdatec$(BUILT_SOURCES)" || rm -f getdateh getdatec $(BUILT_SOURCES)
|
||||
-test -z "getdate.hgetdate.c$(BUILT_SOURCES)" || rm -f getdate.h getdate.c $(BUILT_SOURCES)
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-kr mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename.c -- return the last element in a path
|
||||
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -29,16 +29,27 @@
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument. */
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
If NAME is all slashes, be sure to return `/'. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
int all_slashes = 1;
|
||||
char const *p;
|
||||
|
||||
for (; *name; name++)
|
||||
if (ISSLASH (*name))
|
||||
base = name + 1;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
base = p + 1;
|
||||
else
|
||||
all_slashes = 0;
|
||||
}
|
||||
|
||||
/* If NAME is all slashes, arrange to return `/'. */
|
||||
if (*base == '\0' && ISSLASH (*name) && all_slashes)
|
||||
--base;
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
void free ();
|
||||
|
||||
/* Returns the canonical hostname associated with HOST (allocated in a static
|
||||
buffer), or 0 if it can't be determined. */
|
||||
char *
|
||||
@@ -67,9 +69,23 @@ canon_host (const char *host)
|
||||
}
|
||||
|
||||
if (addr && strcmp (he->h_name, addr) == 0)
|
||||
/* gethostbyname() cheated! Lookup the host name via the address
|
||||
this time to get the actual host name. */
|
||||
he = gethostbyaddr (he->h_addr, he->h_length, he->h_addrtype);
|
||||
{
|
||||
/* gethostbyname has returned a string representation of the IP
|
||||
address, for example, "127.0.0.1". So now, look up the host
|
||||
name via the address. Although it may seem reasonable to look
|
||||
up the host name via the address, we must not pass `he->h_addr'
|
||||
directly to gethostbyaddr because on some systems he->h_addr
|
||||
is located in a static library buffer that is reused in the
|
||||
gethostbyaddr call. Make a copy and use that instead. */
|
||||
char *h_addr_copy = strdup (he->h_addr);
|
||||
if (h_addr_copy == NULL)
|
||||
he = NULL;
|
||||
else
|
||||
{
|
||||
he = gethostbyaddr (h_addr_copy, he->h_length, he->h_addrtype);
|
||||
free (h_addr_copy);
|
||||
}
|
||||
}
|
||||
# endif /* HAVE_GETHOSTBYADDR */
|
||||
|
||||
if (he)
|
||||
|
||||
@@ -43,14 +43,19 @@ extern int errno;
|
||||
#include "error.h"
|
||||
|
||||
/* Close standard output, exiting with status STATUS on failure.
|
||||
If a program writes *anything* to stdout, that program should close
|
||||
stdout and make sure that the close succeeds. Otherwise, suppose that
|
||||
you go to the extreme of checking the return status of every function
|
||||
that does an explicit write to stdout. The last printf can succeed in
|
||||
writing to the internal stream buffer, and yet the fclose(stdout) could
|
||||
still fail (due e.g., to a disk full error) when it tries to write
|
||||
out that buffered data. Thus, you would be left with an incomplete
|
||||
output file and the offending program would exit successfully.
|
||||
If a program writes *anything* to stdout, that program should `fflush'
|
||||
stdout and make sure that it succeeds before exiting. Otherwise,
|
||||
suppose that you go to the extreme of checking the return status
|
||||
of every function that does an explicit write to stdout. The last
|
||||
printf can succeed in writing to the internal stream buffer, and yet
|
||||
the fclose(stdout) could still fail (due e.g., to a disk full error)
|
||||
when it tries to write out that buffered data. Thus, you would be
|
||||
left with an incomplete output file and the offending program would
|
||||
exit successfully.
|
||||
|
||||
FIXME: note the fflush suggested above is implicit in the fclose
|
||||
we actually do below. Consider doing only the fflush and/or using
|
||||
setvbuf to inhibit buffering.
|
||||
|
||||
Besides, it's wasteful to check the return value from every call
|
||||
that writes to stdout -- just let the internal stream state record
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# ifdef FORCE_ALLOCA_H
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
@@ -906,12 +906,15 @@ get_date (const char *p, const time_t *now)
|
||||
yyInput = p;
|
||||
Start = now ? *now : time ((time_t *) NULL);
|
||||
tmp = localtime (&Start);
|
||||
if (!tmp)
|
||||
return -1;
|
||||
yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
|
||||
yyMonth = tmp->tm_mon + 1;
|
||||
yyDay = tmp->tm_mday;
|
||||
yyHour = tmp->tm_hour;
|
||||
yyMinutes = tmp->tm_min;
|
||||
yySeconds = tmp->tm_sec;
|
||||
tm.tm_isdst = tmp->tm_isdst;
|
||||
yyMeridian = MER24;
|
||||
yyRelSeconds = 0;
|
||||
yyRelMinutes = 0;
|
||||
@@ -947,7 +950,6 @@ get_date (const char *p, const time_t *now)
|
||||
tm.tm_hour += yyRelHour;
|
||||
tm.tm_min += yyRelMinutes;
|
||||
tm.tm_sec += yyRelSeconds;
|
||||
tm.tm_isdst = -1;
|
||||
tm0 = tm;
|
||||
|
||||
Start = mktime (&tm);
|
||||
@@ -994,7 +996,11 @@ get_date (const char *p, const time_t *now)
|
||||
|
||||
if (yyHaveZone)
|
||||
{
|
||||
long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
|
||||
long delta;
|
||||
struct tm *gmt = gmtime (&Start);
|
||||
if (!gmt)
|
||||
return -1;
|
||||
delta = yyTimezone * 60L + difftm (&tm, gmt);
|
||||
if ((Start + delta < Start) != (delta < 0))
|
||||
return -1; /* time_t overflow */
|
||||
Start += delta;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* provide consistent interface to getgroups for systems that don't allow N==0
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,14 +25,11 @@ char *xmalloc ();
|
||||
|
||||
/* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, 0) always fails.
|
||||
On other systems, it returns the number of supplemental groups for the
|
||||
process is returned.
|
||||
This function handles that special case and lets the system-
|
||||
provided function handle all others. */
|
||||
process. This function handles that special case and lets the system-
|
||||
provided function handle all others. */
|
||||
|
||||
int
|
||||
getgroups (n, group)
|
||||
size_t n;
|
||||
GETGROUPS_T *group;
|
||||
getgroups (size_t n, GETGROUPS_T *group)
|
||||
{
|
||||
int n_groups;
|
||||
GETGROUPS_T *gbuf;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* getugroups.c -- return a list of the groups a user is in
|
||||
Copyright (C) 1990, 1991, 1998 Free Software Foundation.
|
||||
Copyright (C) 1990, 1991, 1998, 1999 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -41,16 +41,27 @@ struct group *getgrent ();
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* Like `getgroups', but for user USERNAME instead of for
|
||||
the current process. */
|
||||
/* Like `getgroups', but for user USERNAME instead of for the current
|
||||
process. Store at most MAXCOUNT group IDs in the GROUPLIST array.
|
||||
If GID is not -1, store it first (if possible). GID should be the
|
||||
group ID (pw_gid) obtained from getpwuid, in case USERNAME is not
|
||||
listed in /etc/groups.
|
||||
Always return the number of groups of which USERNAME is a member. */
|
||||
|
||||
int
|
||||
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username)
|
||||
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid)
|
||||
{
|
||||
struct group *grp;
|
||||
register char **cp;
|
||||
register int count = 0;
|
||||
|
||||
if (gid != -1)
|
||||
{
|
||||
if (maxcount != 0)
|
||||
grouplist[count] = gid;
|
||||
++count;
|
||||
}
|
||||
|
||||
setgrent ();
|
||||
while ((grp = getgrent ()) != 0)
|
||||
for (cp = grp->gr_mem; *cp; ++cp)
|
||||
|
||||
371
lib/hash.c
371
lib/hash.c
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering, 1992.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -54,10 +54,10 @@ char *malloc ();
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
/* An hash table contains many internal entries, each holding a pointer to
|
||||
/* A hash table contains many internal entries, each holding a pointer to
|
||||
some user provided data (also called a user entry). An entry indistinctly
|
||||
refers to both the internal entry and its associated user entry. A user
|
||||
entry contents may be hashed by a randomisation function (the hashing
|
||||
entry contents may be hashed by a randomization function (the hashing
|
||||
function, or just `hasher' for short) into a number (or `slot') between 0
|
||||
and the current table size. At each slot position in the hash table,
|
||||
starts a linked chain of entries for which the user data all hash to this
|
||||
@@ -66,32 +66,58 @@ char *malloc ();
|
||||
A good `hasher' function will distribute entries rather evenly in buckets.
|
||||
In the ideal case, the length of each bucket is roughly the number of
|
||||
entries divided by the table size. Finding the slot for a data is usually
|
||||
done at constant speed by the `hasher', and the later finding of a precise
|
||||
done in constant time by the `hasher', and the later finding of a precise
|
||||
entry is linear in time with the size of the bucket. Consequently, a
|
||||
bigger hash table size (that is, a bigger number of buckets) is prone to
|
||||
yielding shorter buckets, *given* the `hasher' function behaves properly.
|
||||
larger hash table size (that is, a larger number of buckets) is prone to
|
||||
yielding shorter chains, *given* the `hasher' function behaves properly.
|
||||
|
||||
Long buckets slow down the lookup algorithm. One might use big hash table
|
||||
sizes in hope to reduce the average length of buckets, but this might
|
||||
become inordinate, as unused slots in the hash table take some space. The
|
||||
best bet is to make sure you are using a good `hasher' function (beware
|
||||
that those are not that easy to write! :-), and to use a table size at
|
||||
least bigger than the actual number of entries.
|
||||
that those are not that easy to write! :-), and to use a table size
|
||||
larger than the actual number of entries. */
|
||||
|
||||
Currently, whenever the addition of an entry gets 80% of buckets to be
|
||||
non-empty, this package automatically doubles the number of buckets. */
|
||||
/* If an insertion makes the ratio of nonempty buckets to table size larger
|
||||
than the growth threshold (a number between 0.0 and 1.0), then increase
|
||||
the table size by multiplying by the growth factor (a number greater than
|
||||
1.0). The growth threshold defaults to 0.8, and the growth factor
|
||||
defaults to 1.414, meaning that the table will have doubled its size
|
||||
every second time 80% of the buckets get used. */
|
||||
#define DEFAULT_GROWTH_THRESHOLD 0.8
|
||||
#define DEFAULT_GROWTH_FACTOR 1.414
|
||||
|
||||
/* If a deletion empties a bucket and causes the ratio of used buckets to
|
||||
table size to become smaller than the shrink threshold (a number between
|
||||
0.0 and 1.0), then shrink the table by multiplying by the shrink factor (a
|
||||
number greater than the shrink threshold but smaller than 1.0). The shrink
|
||||
threshold and factor default to 0.0 and 1.0, meaning that the table never
|
||||
shrinks. */
|
||||
#define DEFAULT_SHRINK_THRESHOLD 0.0
|
||||
#define DEFAULT_SHRINK_FACTOR 1.0
|
||||
|
||||
/* Use this to initialize or reset a TUNING structure to
|
||||
some sensible values. */
|
||||
static const Hash_tuning default_tuning =
|
||||
{
|
||||
DEFAULT_SHRINK_THRESHOLD,
|
||||
DEFAULT_SHRINK_FACTOR,
|
||||
DEFAULT_GROWTH_THRESHOLD,
|
||||
DEFAULT_GROWTH_FACTOR,
|
||||
false
|
||||
};
|
||||
|
||||
/* Information and lookup. */
|
||||
|
||||
/* The following few functions provide information about the overall hash
|
||||
table organisation: the number of entries, number of buckets and maximum
|
||||
table organization: the number of entries, number of buckets and maximum
|
||||
length of buckets. */
|
||||
|
||||
/* Return the number of buckets in the hash table. The table size, the total
|
||||
number of buckets (used plus unused), or the maximum number of slots, are
|
||||
the same quantity. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_buckets (const Hash_table *table)
|
||||
{
|
||||
return table->n_buckets;
|
||||
@@ -99,7 +125,7 @@ hash_get_n_buckets (const Hash_table *table)
|
||||
|
||||
/* Return the number of slots in use (non-empty buckets). */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_buckets_used (const Hash_table *table)
|
||||
{
|
||||
return table->n_buckets_used;
|
||||
@@ -107,26 +133,26 @@ hash_get_n_buckets_used (const Hash_table *table)
|
||||
|
||||
/* Return the number of active entries. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_n_entries (const Hash_table *table)
|
||||
{
|
||||
return table->n_entries;
|
||||
}
|
||||
|
||||
/* Return the length of the most lenghty chain (bucket). */
|
||||
/* Return the length of the longest chain (bucket). */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_max_bucket_length (const Hash_table *table)
|
||||
{
|
||||
struct hash_entry *bucket;
|
||||
unsigned int max_bucket_length = 0;
|
||||
unsigned max_bucket_length = 0;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
if (bucket->data)
|
||||
{
|
||||
struct hash_entry *cursor = bucket;
|
||||
unsigned int bucket_length = 1;
|
||||
unsigned bucket_length = 1;
|
||||
|
||||
while (cursor = cursor->next, cursor)
|
||||
bucket_length++;
|
||||
@@ -139,15 +165,15 @@ hash_get_max_bucket_length (const Hash_table *table)
|
||||
return max_bucket_length;
|
||||
}
|
||||
|
||||
/* Do a mild validation of an hash table, by traversing it and checking two
|
||||
/* Do a mild validation of a hash table, by traversing it and checking two
|
||||
statistics. */
|
||||
|
||||
bool
|
||||
hash_table_ok (const Hash_table *table)
|
||||
{
|
||||
struct hash_entry *bucket;
|
||||
unsigned int n_buckets_used = 0;
|
||||
unsigned int n_entries = 0;
|
||||
unsigned n_buckets_used = 0;
|
||||
unsigned n_entries = 0;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
@@ -174,10 +200,10 @@ hash_table_ok (const Hash_table *table)
|
||||
void
|
||||
hash_print_statistics (const Hash_table *table, FILE *stream)
|
||||
{
|
||||
unsigned int n_entries = hash_get_n_entries (table);
|
||||
unsigned int n_buckets = hash_get_n_buckets (table);
|
||||
unsigned int n_buckets_used = hash_get_n_buckets_used (table);
|
||||
unsigned int max_bucket_length = hash_get_max_bucket_length (table);
|
||||
unsigned n_entries = hash_get_n_entries (table);
|
||||
unsigned n_buckets = hash_get_n_buckets (table);
|
||||
unsigned n_buckets_used = hash_get_n_buckets_used (table);
|
||||
unsigned max_bucket_length = hash_get_max_bucket_length (table);
|
||||
|
||||
fprintf (stream, "# entries: %u\n", n_entries);
|
||||
fprintf (stream, "# buckets: %u\n", n_buckets);
|
||||
@@ -186,8 +212,8 @@ hash_print_statistics (const Hash_table *table, FILE *stream)
|
||||
fprintf (stream, "max bucket length: %u\n", max_bucket_length);
|
||||
}
|
||||
|
||||
/* Return the user entry from the hash table, if some entry in the hash table
|
||||
compares equally with ENTRY, or NULL otherwise. */
|
||||
/* If ENTRY matches an entry already in the hash table, return the
|
||||
entry from the table. Otherwise, return NULL. */
|
||||
|
||||
void *
|
||||
hash_lookup (const Hash_table *table, const void *entry)
|
||||
@@ -229,7 +255,7 @@ hash_get_first (const Hash_table *table)
|
||||
if (bucket->data)
|
||||
return bucket->data;
|
||||
|
||||
abort ();
|
||||
assert (0);
|
||||
}
|
||||
|
||||
/* Return the user data for the entry following ENTRY, where ENTRY has been
|
||||
@@ -263,11 +289,11 @@ hash_get_next (const Hash_table *table, const void *entry)
|
||||
return the number of pointers copied. Do not copy more than BUFFER_SIZE
|
||||
pointers. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_get_entries (const Hash_table *table, void **buffer,
|
||||
unsigned int buffer_size)
|
||||
unsigned buffer_size)
|
||||
{
|
||||
unsigned int counter = 0;
|
||||
unsigned counter = 0;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
|
||||
@@ -287,7 +313,7 @@ hash_get_entries (const Hash_table *table, void **buffer,
|
||||
return counter;
|
||||
}
|
||||
|
||||
/* Call a PROCESSOR function for each entry of an hash table, and return the
|
||||
/* Call a PROCESSOR function for each entry of a hash table, and return the
|
||||
number of entries for which the processor function returned success. A
|
||||
pointer to some PROCESSOR_DATA which will be made available to each call to
|
||||
the processor function. The PROCESSOR accepts two arguments: the first is
|
||||
@@ -295,11 +321,11 @@ hash_get_entries (const Hash_table *table, void **buffer,
|
||||
as received. The walking continue for as long as the PROCESSOR function
|
||||
returns nonzero. When it returns zero, the walking is interrupted. */
|
||||
|
||||
unsigned int
|
||||
unsigned
|
||||
hash_do_for_each (const Hash_table *table, Hash_processor processor,
|
||||
void *processor_data)
|
||||
{
|
||||
unsigned int counter = 0;
|
||||
unsigned counter = 0;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
|
||||
@@ -332,8 +358,8 @@ hash_do_for_each (const Hash_table *table, Hash_processor processor,
|
||||
algorithms tend to be domain-specific, so what's good for [diffutils'] io.c
|
||||
may not be good for your application." */
|
||||
|
||||
unsigned int
|
||||
hash_string (const char *string, unsigned int n_buckets)
|
||||
unsigned
|
||||
hash_string (const char *string, unsigned n_buckets)
|
||||
{
|
||||
# ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
@@ -360,8 +386,8 @@ hash_string (const char *string, unsigned int n_buckets)
|
||||
very old Cyber `snoop', itself written in typical Greg Mansfield style.
|
||||
(By the way, what happened to this excellent man? Is he still alive?) */
|
||||
|
||||
unsigned int
|
||||
hash_string (const char *string, unsigned int n_buckets)
|
||||
unsigned
|
||||
hash_string (const char *string, unsigned n_buckets)
|
||||
{
|
||||
unsigned value = 0;
|
||||
|
||||
@@ -376,7 +402,7 @@ hash_string (const char *string, unsigned int n_buckets)
|
||||
/* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd
|
||||
number at least equal to 11. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
is_prime (unsigned long candidate)
|
||||
{
|
||||
unsigned long divisor = 3;
|
||||
@@ -393,12 +419,14 @@ is_prime (unsigned long candidate)
|
||||
}
|
||||
|
||||
/* Round a given CANDIDATE number up to the nearest prime, and return that
|
||||
prime. CANDIDATE should be at least equal to 10. */
|
||||
prime. Primes lower than 10 are merely skipped. */
|
||||
|
||||
static unsigned long
|
||||
next_prime (unsigned long candidate)
|
||||
{
|
||||
assert (candidate >= 10);
|
||||
/* Skip small primes. */
|
||||
if (candidate < 10)
|
||||
candidate = 10;
|
||||
|
||||
/* Make it definitely odd. */
|
||||
candidate |= 1;
|
||||
@@ -409,33 +437,73 @@ next_prime (unsigned long candidate)
|
||||
return candidate;
|
||||
}
|
||||
|
||||
/* Allocate and return a new hash table, or NULL if an error is met. The
|
||||
initial number of buckets would be at least CANDIDATE (which need not be
|
||||
prime).
|
||||
void
|
||||
hash_reset_tuning (Hash_tuning *tuning)
|
||||
{
|
||||
*tuning = default_tuning;
|
||||
}
|
||||
|
||||
If DATA_FREER is not NULL, this function may be later called with the data
|
||||
as an argument, just before they entry containing the data gets freed. The
|
||||
HASHER function should be supplied, and FIXME. The COMPARATOR function
|
||||
should also be supplied, and FIXME. */
|
||||
/* For the given hash TABLE, check the user supplied tuning structure for
|
||||
reasonable values, and return true if there is no gross error with it.
|
||||
Otherwise, definitvely reset the TUNING field to some acceptable default in
|
||||
the hash table (that is, the user loses the right of further modifying
|
||||
tuning arguments), and return false. */
|
||||
|
||||
/* User-supplied function for freeing datas. It is specified in
|
||||
hash_initialize. If non-null, it is used by hash_free and hash_clear.
|
||||
You should specify `free' here only if you want these functions to free
|
||||
all of your `data' data. This is typically the case when your data is
|
||||
simply an auxilliary struct that you have malloc'd to aggregate several
|
||||
values. */
|
||||
static bool
|
||||
check_tuning (Hash_table *table)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
|
||||
/* User-supplied hash function that hashes entry ENTRY to an integer in
|
||||
the range 0..TABLE_SIZE-1. */
|
||||
if (tuning->growth_threshold > 0.0
|
||||
&& tuning->growth_threshold < 1.0
|
||||
&& tuning->growth_factor > 1.0
|
||||
&& tuning->shrink_threshold >= 0.0
|
||||
&& tuning->shrink_threshold < 1.0
|
||||
&& tuning->shrink_factor > tuning->shrink_threshold
|
||||
&& tuning->shrink_factor <= 1.0
|
||||
&& tuning->shrink_threshold < tuning->growth_threshold)
|
||||
return true;
|
||||
|
||||
/* User-supplied function that determines whether a new entry is unique by
|
||||
comparing the new entry to entries that hashed to the same bucket
|
||||
index. It should return zero for a pair of entries that compare equal,
|
||||
non-zero otherwise. */
|
||||
table->tuning = &default_tuning;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Allocate and return a new hash table, or NULL upon failure. The
|
||||
initial number of buckets is automatically selected so as to _guarantee_ that
|
||||
you may insert at least CANDIDATE different user entries before any growth
|
||||
of the hash table size occurs. So, if have a reasonably tight a-priori
|
||||
upper bound on the
|
||||
number of entries you intend to insert in the hash table, you may save some
|
||||
table memory and insertion time, by specifying it here. If the
|
||||
IS_N_BUCKETS field of the TUNING structure is true, the CANDIDATE argument
|
||||
has its meaning changed to the wanted number of buckets.
|
||||
|
||||
TUNING points to a structure of user-supplied values, in case some fine
|
||||
tuning is wanted over the default behavior of the hasher. If TUNING is
|
||||
NULL, the default tuning parameters are used instead.
|
||||
|
||||
The user-supplied HASHER function should be provided. It accepts two
|
||||
arguments ENTRY and TABLE_SIZE. It computes, by hashing ENTRY contents, a
|
||||
slot number for that entry which should be in the range 0..TABLE_SIZE-1.
|
||||
This slot number is then returned.
|
||||
|
||||
The user-supplied COMPARATOR function should be provided. It accepts two
|
||||
arguments pointing to user data, it then returns true for a pair of entries
|
||||
that compare equal, or false otherwise. This function is internally called
|
||||
on entries which are already known to hash to the same bucket index.
|
||||
|
||||
The user-supplied DATA_FREER function, when not NULL, may be later called
|
||||
with the user data as an argument, just before the entry containing the
|
||||
data gets freed. This happens from within `hash_free' or `hash_clear'.
|
||||
You should specify this function only if you want these functions to free
|
||||
all of your `data' data. This is typically the case when your data is
|
||||
simply an auxiliary struct that you have malloc'd to aggregate several
|
||||
values. */
|
||||
|
||||
Hash_table *
|
||||
hash_initialize (unsigned int candidate, Hash_hasher hasher,
|
||||
Hash_comparator comparator, Hash_data_freer data_freer)
|
||||
hash_initialize (unsigned candidate, const Hash_tuning *tuning,
|
||||
Hash_hasher hasher, Hash_comparator comparator,
|
||||
Hash_data_freer data_freer)
|
||||
{
|
||||
Hash_table *table;
|
||||
struct hash_entry *bucket;
|
||||
@@ -447,7 +515,24 @@ hash_initialize (unsigned int candidate, Hash_hasher hasher,
|
||||
if (table == NULL)
|
||||
return NULL;
|
||||
|
||||
table->n_buckets = next_prime (candidate < 10 ? 10 : candidate);
|
||||
if (!tuning)
|
||||
tuning = &default_tuning;
|
||||
table->tuning = tuning;
|
||||
if (!check_tuning (table))
|
||||
{
|
||||
/* Fail if the tuning options are invalid. This is the only occasion
|
||||
when the user gets some feedback about it. Once the table is created,
|
||||
if the user provides invalid tuning options, we silently revert to
|
||||
using the defaults, and ignore further request to change the tuning
|
||||
options. */
|
||||
free (table);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table->n_buckets
|
||||
= next_prime (tuning->is_n_buckets ? candidate
|
||||
: (unsigned) (candidate / tuning->growth_threshold));
|
||||
|
||||
table->bucket = (struct hash_entry *)
|
||||
malloc (table->n_buckets * sizeof (struct hash_entry));
|
||||
if (table->bucket == NULL)
|
||||
@@ -515,7 +600,7 @@ hash_clear (Hash_table *table)
|
||||
table->n_entries = 0;
|
||||
}
|
||||
|
||||
/* Reclaim all storage associated with an hash table. If a data_freer
|
||||
/* Reclaim all storage associated with a hash table. If a data_freer
|
||||
function has been supplied by the user when the hash table was created,
|
||||
this function applies it to the data of each entry before freeing that
|
||||
entry. */
|
||||
@@ -682,21 +767,23 @@ hash_find_entry (Hash_table *table, const void *entry,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For an already existing hash table, change the number of buckets and make
|
||||
it NEW_TABLE_SIZE. The contents of the hash table are preserved. */
|
||||
/* For an already existing hash table, change the number of buckets through
|
||||
specifying CANDIDATE. The contents of the hash table are preserved. The
|
||||
new number of buckets is automatically selected so as to _guarantee_ that the
|
||||
table may receive at least CANDIDATE different user entries, including
|
||||
those already in the table, before any other growth of the hash table size
|
||||
occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
|
||||
exact number of buckets desired. */
|
||||
|
||||
bool
|
||||
hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
hash_rehash (Hash_table *table, unsigned candidate)
|
||||
{
|
||||
Hash_table *new_table;
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
struct hash_entry *next;
|
||||
|
||||
if (table->n_buckets <= 0 || new_n_buckets == 0)
|
||||
return false;
|
||||
|
||||
new_table = hash_initialize (new_n_buckets, table->hasher,
|
||||
new_table = hash_initialize (candidate, table->tuning, table->hasher,
|
||||
table->comparator, table->data_freer);
|
||||
if (new_table == NULL)
|
||||
return false;
|
||||
@@ -709,26 +796,23 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
new_table->free_entry_list = table->free_entry_list;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
if (bucket->data)
|
||||
if (bucket->data)
|
||||
for (cursor = bucket; cursor; cursor = next)
|
||||
{
|
||||
for (cursor = bucket; cursor; cursor = next)
|
||||
void *data = cursor->data;
|
||||
struct hash_entry *new_bucket
|
||||
= (new_table->bucket
|
||||
+ new_table->hasher (data, new_table->n_buckets));
|
||||
|
||||
assert (new_bucket < new_table->bucket_limit);
|
||||
next = cursor->next;
|
||||
|
||||
if (new_bucket->data)
|
||||
{
|
||||
void *data = cursor->data;
|
||||
struct hash_entry *new_bucket
|
||||
= new_table->bucket + new_table->hasher (data, new_n_buckets);
|
||||
|
||||
assert (new_bucket < new_table->bucket_limit);
|
||||
|
||||
/* Free overflow entries as soon as possible, moving them from the
|
||||
old hash table into the new one, as they may be needed now. */
|
||||
next = cursor->next;
|
||||
if (cursor != bucket)
|
||||
free_entry (new_table, cursor);
|
||||
|
||||
/* Insert the entry into the new hash table. */
|
||||
if (new_bucket->data)
|
||||
if (cursor == bucket)
|
||||
{
|
||||
/* Allocate or recycle an entry, when moving from a bucket
|
||||
header into a bucket overflow. */
|
||||
struct hash_entry *new_entry = allocate_entry (new_table);
|
||||
|
||||
if (new_entry == NULL)
|
||||
@@ -740,12 +824,24 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
}
|
||||
else
|
||||
{
|
||||
new_bucket->data = data;
|
||||
new_table->n_buckets_used++;
|
||||
/* Merely relink an existing entry, when moving from a
|
||||
bucket overflow into a bucket overflow. */
|
||||
cursor->next = new_bucket->next;
|
||||
new_bucket->next = cursor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free an existing entry, when moving from a bucket
|
||||
overflow into a bucket header. Also take care of the
|
||||
simple case of moving from a bucket header into a bucket
|
||||
header. */
|
||||
new_bucket->data = data;
|
||||
new_table->n_buckets_used++;
|
||||
if (cursor != bucket)
|
||||
free_entry (new_table, cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (table->bucket);
|
||||
table->bucket = new_table->bucket;
|
||||
@@ -761,68 +857,74 @@ hash_rehash (Hash_table *table, unsigned int new_n_buckets)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If ENTRY matches an entry already in the hash table, don't modify the table
|
||||
and return the matched entry. Otherwise, insert ENTRY and return NULL.
|
||||
*DONE is set to true in all cases, unless the storage required for
|
||||
insertion cannot be allocated. */
|
||||
/* If ENTRY matches an entry already in the hash table, return the pointer
|
||||
to the entry from the table. Otherwise, insert ENTRY and return ENTRY.
|
||||
Return NULL if the storage required for insertion cannot be allocated. */
|
||||
|
||||
void *
|
||||
hash_insert (Hash_table *table, const void *entry, bool *done)
|
||||
hash_insert (Hash_table *table, const void *entry)
|
||||
{
|
||||
void *data;
|
||||
struct hash_entry *bucket;
|
||||
|
||||
assert (entry); /* cannot insert a NULL data */
|
||||
assert (entry); /* cannot insert a NULL entry */
|
||||
|
||||
if (data = hash_find_entry (table, entry, &bucket, false), data)
|
||||
{
|
||||
*done = true;
|
||||
return data;
|
||||
}
|
||||
/* If there's a matching entry already in the table, return that. */
|
||||
if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
|
||||
return data;
|
||||
|
||||
/* ENTRY is not matched, it should be inserted. */
|
||||
|
||||
table->n_entries++;
|
||||
|
||||
if (bucket->data)
|
||||
{
|
||||
struct hash_entry *new_entry = allocate_entry (table);
|
||||
|
||||
if (new_entry == NULL)
|
||||
{
|
||||
*done = false;
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/* Add ENTRY in the overflow of the bucket. */
|
||||
|
||||
new_entry->data = (void *) entry;
|
||||
new_entry->next = bucket->next;
|
||||
bucket->next = new_entry;
|
||||
*done = true;
|
||||
return NULL;
|
||||
table->n_entries++;
|
||||
return (void *) entry;
|
||||
}
|
||||
|
||||
/* Add ENTRY right in the bucket head. */
|
||||
|
||||
bucket->data = (void *) entry;
|
||||
table->n_entries++;
|
||||
table->n_buckets_used++;
|
||||
|
||||
/* If more than 80% of the buckets are in use, rehash the table two
|
||||
times bigger. It's no real use checking the number of entries, as if
|
||||
the hashing function is ill-conditioned, rehashing is not likely to
|
||||
improve it. */
|
||||
/* If the growth threshold of the buckets in use has been reached, increase
|
||||
the table size and rehash. There's no point in checking the number of
|
||||
entries: if the hashing function is ill-conditioned, rehashing is not
|
||||
likely to improve it. */
|
||||
|
||||
if (5 * table->n_buckets_used > 4 * table->n_buckets)
|
||||
if (table->n_buckets_used
|
||||
> table->tuning->growth_threshold * table->n_buckets)
|
||||
{
|
||||
unsigned int new_n_buckets = next_prime (2 * table->n_buckets + 1);
|
||||
/* Check more fully, before starting real work. If tuning arguments
|
||||
became invalid, the second check will rely on proper defaults. */
|
||||
check_tuning (table);
|
||||
if (table->n_buckets_used
|
||||
> table->tuning->growth_threshold * table->n_buckets)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
unsigned candidate
|
||||
= (unsigned) (tuning->is_n_buckets
|
||||
? (table->n_buckets * tuning->growth_factor)
|
||||
: (table->n_buckets * tuning->growth_factor
|
||||
* tuning->growth_threshold));
|
||||
|
||||
*done = hash_rehash (table, new_n_buckets);
|
||||
return NULL;
|
||||
/* If the rehash fails, arrange to return NULL. */
|
||||
if (!hash_rehash (table, candidate))
|
||||
entry = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*done = true;
|
||||
return NULL;
|
||||
return (void *) entry;
|
||||
}
|
||||
|
||||
/* If ENTRY is already in the table, remove it and return the just-deleted
|
||||
@@ -838,9 +940,34 @@ hash_delete (Hash_table *table, const void *entry)
|
||||
if (data = hash_find_entry (table, entry, &bucket, true), !data)
|
||||
return NULL;
|
||||
|
||||
if (!bucket->data)
|
||||
table->n_buckets_used--;
|
||||
table->n_entries--;
|
||||
if (!bucket->data)
|
||||
{
|
||||
table->n_buckets_used--;
|
||||
|
||||
/* If the shrink threshold of the buckets in use has been reached,
|
||||
rehash into a smaller table. */
|
||||
|
||||
if (table->n_buckets_used
|
||||
< table->tuning->shrink_threshold * table->n_buckets)
|
||||
{
|
||||
/* Check more fully, before starting real work. If tuning arguments
|
||||
became invalid, the second check will rely on proper defaults. */
|
||||
check_tuning (table);
|
||||
if (table->n_buckets_used
|
||||
< table->tuning->shrink_threshold * table->n_buckets)
|
||||
{
|
||||
const Hash_tuning *tuning = table->tuning;
|
||||
unsigned candidate
|
||||
= (unsigned) (tuning->is_n_buckets
|
||||
? table->n_buckets * tuning->shrink_factor
|
||||
: (table->n_buckets * tuning->shrink_factor
|
||||
* tuning->growth_threshold));
|
||||
|
||||
hash_rehash (table, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
53
lib/hash.h
53
lib/hash.h
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <meyering@ascend.com>, 1998.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef unsigned int (*Hash_hasher) PARAMS ((const void *, unsigned int));
|
||||
typedef unsigned (*Hash_hasher) PARAMS ((const void *, unsigned));
|
||||
typedef bool (*Hash_comparator) PARAMS ((const void *, const void *));
|
||||
typedef void (*Hash_data_freer) PARAMS ((void *));
|
||||
typedef bool (*Hash_processor) PARAMS ((void *, void *));
|
||||
@@ -40,6 +40,20 @@ struct hash_entry
|
||||
struct hash_entry *next;
|
||||
};
|
||||
|
||||
struct hash_tuning
|
||||
{
|
||||
/* This structure is mainly used for `hash_initialize', see the block
|
||||
documentation of `hash_reset_tuning' for more complete comments. */
|
||||
|
||||
float shrink_threshold; /* ratio of used buckets to trigger a shrink */
|
||||
float shrink_factor; /* ratio of new smaller size to original size */
|
||||
float growth_threshold; /* ratio of used buckets to trigger a growth */
|
||||
float growth_factor; /* ratio of new bigger size to original size */
|
||||
bool is_n_buckets; /* if CANDIDATE really means table size */
|
||||
};
|
||||
|
||||
typedef struct hash_tuning Hash_tuning;
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
/* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
|
||||
@@ -47,9 +61,12 @@ struct hash_table
|
||||
are not empty, there are N_ENTRIES active entries in the table. */
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *bucket_limit;
|
||||
unsigned int n_buckets;
|
||||
unsigned int n_buckets_used;
|
||||
unsigned int n_entries;
|
||||
unsigned n_buckets;
|
||||
unsigned n_buckets_used;
|
||||
unsigned n_entries;
|
||||
|
||||
/* Tuning arguments, kept in a physicaly separate structure. */
|
||||
const Hash_tuning *tuning;
|
||||
|
||||
/* Three functions are given to `hash_initialize', see the documentation
|
||||
block for this function. In a word, HASHER randomizes a user entry
|
||||
@@ -74,10 +91,10 @@ struct hash_table
|
||||
typedef struct hash_table Hash_table;
|
||||
|
||||
/* Information and lookup. */
|
||||
unsigned int hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_n_entries PARAMS ((const Hash_table *));
|
||||
unsigned int hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_buckets PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_buckets_used PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_n_entries PARAMS ((const Hash_table *));
|
||||
unsigned hash_get_max_bucket_length PARAMS ((const Hash_table *));
|
||||
bool hash_table_ok PARAMS ((const Hash_table *));
|
||||
void hash_print_statistics PARAMS ((const Hash_table *, FILE *));
|
||||
void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||
@@ -85,19 +102,19 @@ void *hash_lookup PARAMS ((const Hash_table *, const void *));
|
||||
/* Walking. */
|
||||
void *hash_get_first PARAMS ((const Hash_table *));
|
||||
void *hash_get_next PARAMS ((const Hash_table *, const void *));
|
||||
unsigned int hash_get_entries PARAMS ((const Hash_table *, void **,
|
||||
unsigned int));
|
||||
unsigned int hash_do_for_each PARAMS ((const Hash_table *, Hash_processor,
|
||||
void *));
|
||||
unsigned hash_get_entries PARAMS ((const Hash_table *, void **, unsigned));
|
||||
unsigned hash_do_for_each PARAMS ((const Hash_table *, Hash_processor, void *));
|
||||
|
||||
/* Allocation and clean-up. */
|
||||
unsigned int hash_string PARAMS ((const char *, unsigned int));
|
||||
Hash_table *hash_initialize PARAMS ((unsigned int, Hash_hasher,
|
||||
Hash_comparator, Hash_data_freer));
|
||||
unsigned hash_string PARAMS ((const char *, unsigned));
|
||||
void hash_reset_tuning PARAMS ((Hash_tuning *));
|
||||
Hash_table *hash_initialize PARAMS ((unsigned, const Hash_tuning *,
|
||||
Hash_hasher, Hash_comparator,
|
||||
Hash_data_freer));
|
||||
void hash_clear PARAMS ((Hash_table *));
|
||||
void hash_free PARAMS ((Hash_table *));
|
||||
|
||||
/* Insertion and deletion. */
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned int));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *, bool *));
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *));
|
||||
void *hash_delete PARAMS ((Hash_table *, const void *));
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
#include <getopt.h>
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
@@ -37,8 +45,12 @@ static struct option const long_options[] =
|
||||
Be careful not to gobble up `--'. */
|
||||
|
||||
void
|
||||
parse_long_options (int argc, char **argv, const char *command_name,
|
||||
const char *package, const char *version,
|
||||
parse_long_options (int argc,
|
||||
char **argv,
|
||||
const char *command_name,
|
||||
const char *package,
|
||||
const char *version,
|
||||
const char *authors,
|
||||
void (*usage_func)())
|
||||
{
|
||||
int c;
|
||||
@@ -58,7 +70,7 @@ parse_long_options (int argc, char **argv, const char *command_name,
|
||||
(*usage_func) (0);
|
||||
|
||||
case 'v':
|
||||
printf ("%s (%s) %s\n", command_name, package, version);
|
||||
version_etc (stdout, command_name, package, version, authors);
|
||||
close_stdout (); /* FIXME: output failure exit status
|
||||
should be settable via an arg. */
|
||||
exit (0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* long-options.h -- declaration for --help- and --version-handling function.
|
||||
Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,7 +26,10 @@
|
||||
#endif
|
||||
|
||||
void
|
||||
parse_long_options PARAMS ((int _argc, char **_argv,
|
||||
parse_long_options PARAMS ((int _argc,
|
||||
char **_argv,
|
||||
const char *_command_name,
|
||||
const char *_package,
|
||||
const char *_version, void (*_usage) (int)));
|
||||
const char *_version,
|
||||
const char *_authors,
|
||||
void (*_usage) (int)));
|
||||
|
||||
@@ -50,7 +50,8 @@ extern int errno;
|
||||
int
|
||||
mkdir (const char *dpath, int dmode)
|
||||
{
|
||||
int cpid, status;
|
||||
pid_t cpid;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) == 0)
|
||||
@@ -84,7 +85,7 @@ mkdir (const char *dpath, int dmode)
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status & 0xFFFF)
|
||||
if (status)
|
||||
{
|
||||
/* /bin/mkdir failed. */
|
||||
errno = EIO;
|
||||
|
||||
74
lib/mktime.c
74
lib/mktime.c
@@ -1,24 +1,22 @@
|
||||
/* mktime: convert a `struct tm' to a time_t value
|
||||
Copyright (C) 1993-1998, 1999 Free Software Foundation, Inc.
|
||||
/* Convert a `struct tm' to a time_t value.
|
||||
Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Paul Eggert (eggert@twinsun.com).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Define this to have a standalone program to test this implementation of
|
||||
mktime. */
|
||||
@@ -109,14 +107,6 @@ const unsigned short int __mon_yday[2][13] =
|
||||
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
||||
};
|
||||
|
||||
static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *,
|
||||
struct tm *)),
|
||||
time_t *, struct tm *));
|
||||
static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *));
|
||||
time_t __mktime_internal __P ((struct tm *,
|
||||
struct tm *(*) (const time_t *, struct tm *),
|
||||
time_t *));
|
||||
|
||||
|
||||
#ifdef _LIBC
|
||||
# define my_mktime_localtime_r __localtime_r
|
||||
@@ -124,7 +114,6 @@ time_t __mktime_internal __P ((struct tm *,
|
||||
/* If we're a mktime substitute in a GNU program, then prefer
|
||||
localtime to localtime_r, since many localtime_r implementations
|
||||
are buggy. */
|
||||
static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *));
|
||||
static struct tm *
|
||||
my_mktime_localtime_r (const time_t *t, struct tm *tp)
|
||||
{
|
||||
@@ -172,23 +161,6 @@ ydhms_tm_diff (int year, int yday, int hour, int min, int sec,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static time_t localtime_offset;
|
||||
|
||||
/* Convert *TP to a time_t value. */
|
||||
time_t
|
||||
mktime (struct tm *tp)
|
||||
{
|
||||
#ifdef _LIBC
|
||||
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
|
||||
time zone names contained in the external variable `tzname' shall
|
||||
be set as if the tzset() function had been called. */
|
||||
__tzset ();
|
||||
#endif
|
||||
|
||||
return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
|
||||
}
|
||||
|
||||
/* Use CONVERT to convert *T to a broken down time in *TP.
|
||||
If *T is out of range for conversion, adjust it so that
|
||||
it is the nearest in-range value and then convert that. */
|
||||
@@ -389,6 +361,24 @@ __mktime_internal (struct tm *tp,
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static time_t localtime_offset;
|
||||
|
||||
/* Convert *TP to a time_t value. */
|
||||
time_t
|
||||
mktime (tp)
|
||||
struct tm *tp;
|
||||
{
|
||||
#ifdef _LIBC
|
||||
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
|
||||
time zone names contained in the external variable `tzname' shall
|
||||
be set as if the tzset() function had been called. */
|
||||
__tzset ();
|
||||
#endif
|
||||
|
||||
return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
weak_alias (mktime, timelocal)
|
||||
#endif
|
||||
|
||||
115
lib/modechange.c
115
lib/modechange.c
@@ -1,5 +1,5 @@
|
||||
/* modechange.c -- file mode manipulation
|
||||
Copyright (C) 1989, 1990, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -72,6 +72,42 @@ oatoi (const char *s)
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Create a mode_change entry with the specified `=ddd'-style
|
||||
mode change operation, where NEW_MODE is `ddd'. Return the
|
||||
new entry, or NULL upon failure. */
|
||||
|
||||
static struct mode_change *
|
||||
make_node_op_equals (int new_mode)
|
||||
{
|
||||
struct mode_change *p;
|
||||
p = talloc (struct mode_change);
|
||||
if (p == NULL)
|
||||
return p;
|
||||
p->next = NULL;
|
||||
p->op = '=';
|
||||
p->flags = 0;
|
||||
p->value = new_mode;
|
||||
p->affected = 07777; /* Affect all permissions. */
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Append entry E to the end of the link list with the specified
|
||||
HEAD and TAIL. */
|
||||
|
||||
static void
|
||||
mode_append_entry (struct mode_change **head,
|
||||
struct mode_change **tail,
|
||||
struct mode_change *e)
|
||||
{
|
||||
if (*head == NULL)
|
||||
*head = *tail = e;
|
||||
else
|
||||
{
|
||||
(*tail)->next = e;
|
||||
*tail = e;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a linked list of file mode change operations created from
|
||||
MODE_STRING, an ASCII string that contains either an octal number
|
||||
specifying an absolute mode, or symbolic mode change operations with
|
||||
@@ -89,41 +125,44 @@ struct mode_change *
|
||||
mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
{
|
||||
struct mode_change *head; /* First element of the linked list. */
|
||||
struct mode_change *change; /* An element of the linked list. */
|
||||
struct mode_change *tail; /* An element of the linked list. */
|
||||
int i; /* General purpose temporary. */
|
||||
int umask_value; /* The umask value (surprise). */
|
||||
unsigned short affected_bits; /* Which bits in the mode are operated on. */
|
||||
unsigned short affected_masked; /* `affected_bits' modified by umask. */
|
||||
unsigned ops_to_mask; /* Operators to actually use umask on. */
|
||||
|
||||
head = NULL;
|
||||
#ifdef lint
|
||||
tail = NULL;
|
||||
#endif
|
||||
|
||||
i = oatoi (mode_string);
|
||||
if (i >= 0)
|
||||
{
|
||||
struct mode_change *p;
|
||||
if (i > 07777)
|
||||
return MODE_INVALID;
|
||||
head = talloc (struct mode_change);
|
||||
if (head == NULL)
|
||||
p = make_node_op_equals (i);
|
||||
if (p == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
head->next = NULL;
|
||||
head->op = '=';
|
||||
head->flags = 0;
|
||||
head->value = i;
|
||||
head->affected = 07777; /* Affect all permissions. */
|
||||
mode_append_entry (&head, &tail, p);
|
||||
return head;
|
||||
}
|
||||
|
||||
umask_value = umask (0);
|
||||
umask (umask_value); /* Restore the old value. */
|
||||
|
||||
head = NULL;
|
||||
#ifdef lint
|
||||
change = NULL;
|
||||
#endif
|
||||
--mode_string;
|
||||
|
||||
/* One loop iteration for each "ugoa...=+-rwxXstugo...[=+-rwxXstugo...]". */
|
||||
do
|
||||
{
|
||||
/* Which bits in the mode are operated on. */
|
||||
unsigned short affected_bits = 0;
|
||||
/* `affected_bits' modified by umask. */
|
||||
unsigned short affected_masked;
|
||||
/* Operators to actually use umask on. */
|
||||
unsigned ops_to_mask = 0;
|
||||
|
||||
int who_specified_p;
|
||||
|
||||
affected_bits = 0;
|
||||
ops_to_mask = 0;
|
||||
/* Turn on all the bits in `affected_bits' for each group given. */
|
||||
@@ -149,37 +188,39 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
no_more_affected:
|
||||
/* If none specified, affect all bits, except perhaps those
|
||||
set in the umask. */
|
||||
if (affected_bits == 0)
|
||||
if (affected_bits)
|
||||
who_specified_p = 1;
|
||||
else
|
||||
{
|
||||
who_specified_p = 0;
|
||||
affected_bits = 07777;
|
||||
ops_to_mask = masked_ops;
|
||||
}
|
||||
|
||||
while (*mode_string == '=' || *mode_string == '+' || *mode_string == '-')
|
||||
{
|
||||
/* Add the element to the tail of the list, so the operations
|
||||
are performed in the correct order. */
|
||||
if (head == NULL)
|
||||
struct mode_change *change = talloc (struct mode_change);
|
||||
if (change == NULL)
|
||||
{
|
||||
head = talloc (struct mode_change);
|
||||
if (head == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
change = head;
|
||||
}
|
||||
else
|
||||
{
|
||||
change->next = talloc (struct mode_change);
|
||||
if (change->next == NULL)
|
||||
{
|
||||
mode_free (change);
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
}
|
||||
change = change->next;
|
||||
mode_free (head);
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
}
|
||||
|
||||
change->next = NULL;
|
||||
change->op = *mode_string; /* One of "=+-". */
|
||||
affected_masked = affected_bits;
|
||||
|
||||
/* Per the Single Unix Spec, if `who' is not specified and the
|
||||
`=' operator is used, then clear all the bits first. */
|
||||
if (!who_specified_p &&
|
||||
ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS : 0))
|
||||
{
|
||||
struct mode_change *p = make_node_op_equals (0);
|
||||
if (p == NULL)
|
||||
return MODE_MEMORY_EXHAUSTED;
|
||||
mode_append_entry (&head, &tail, p);
|
||||
}
|
||||
|
||||
if (ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS
|
||||
: *mode_string == '+' ? MODE_MASK_PLUS
|
||||
: MODE_MASK_MINUS))
|
||||
@@ -188,6 +229,10 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
change->value = 0;
|
||||
change->flags = 0;
|
||||
|
||||
/* Add the element to the tail of the list, so the operations
|
||||
are performed in the correct order. */
|
||||
mode_append_entry (&head, &tail, change);
|
||||
|
||||
/* Set `value' according to the bits set in `affected_masked'. */
|
||||
for (++mode_string;; ++mode_string)
|
||||
switch (*mode_string)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GNU's read utmp module.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
@@ -29,6 +31,7 @@
|
||||
#include "readutmp.h"
|
||||
|
||||
char *xmalloc ();
|
||||
char *realloc ();
|
||||
|
||||
/* Copy UT->ut_name into storage obtained from malloc. Then remove any
|
||||
trailing spaces from the copy, NUL terminate it, and return the copy. */
|
||||
@@ -49,70 +52,39 @@ extract_trimmed_name (const STRUCT_UTMP *ut)
|
||||
return trimmed_name;
|
||||
}
|
||||
|
||||
/* Read the utmp file FILENAME into *UTMP_BUF, set *N_ENTRIES to the
|
||||
number of entries read, and return zero. If there is any error,
|
||||
/* Read the utmp entries corresponding to file FILENAME into freshly-
|
||||
malloc'd storage, set *UTMP_BUF to that pointer, set *N_ENTRIES to
|
||||
the number of entries, and return zero. If there is any error,
|
||||
return non-zero and don't modify the parameters. */
|
||||
|
||||
#ifdef HAVE_UTMPNAME
|
||||
#if HAVE_UTMPNAME
|
||||
|
||||
int
|
||||
read_utmp (const char *filename, int *n_entries, STRUCT_UTMP **utmp_buf)
|
||||
{
|
||||
int count_utmp = 0;
|
||||
int n_read;
|
||||
STRUCT_UTMP *u;
|
||||
STRUCT_UTMP *uptr;
|
||||
STRUCT_UTMP *utmp_contents;
|
||||
STRUCT_UTMP *utmp = NULL;
|
||||
|
||||
if (utmpname (filename))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
|
||||
/* FIXME: going through the list twice is wasteful. */
|
||||
|
||||
/* count the entries in utmp */
|
||||
setutent ();
|
||||
while ((u = getutent ()) != NULL)
|
||||
++count_utmp;
|
||||
|
||||
if (count_utmp == 0)
|
||||
return 0;
|
||||
|
||||
utmp_contents = (STRUCT_UTMP *) xmalloc (count_utmp * sizeof (STRUCT_UTMP));
|
||||
|
||||
/* read the entries in utmp */
|
||||
|
||||
/* FIXME: can this fail? */
|
||||
setutent ();
|
||||
|
||||
n_read = 0;
|
||||
uptr = utmp_contents;
|
||||
while ((u = getutent ()) != NULL)
|
||||
{
|
||||
++n_read;
|
||||
if (n_read > count_utmp)
|
||||
{
|
||||
STRUCT_UTMP *old_utmp_contents = utmp_contents;
|
||||
++count_utmp;
|
||||
utmp_contents = (STRUCT_UTMP *) xrealloc (utmp_contents,
|
||||
(count_utmp
|
||||
* sizeof (STRUCT_UTMP)));
|
||||
uptr = utmp_contents + (uptr - old_utmp_contents);
|
||||
}
|
||||
*uptr = *u;
|
||||
++uptr;
|
||||
utmp = (STRUCT_UTMP *) realloc (utmp, n_read * sizeof (STRUCT_UTMP));
|
||||
if (utmp == NULL)
|
||||
return 1;
|
||||
utmp[n_read - 1] = *u;
|
||||
}
|
||||
|
||||
if (n_read != count_utmp)
|
||||
utmp_contents = (STRUCT_UTMP *) xrealloc (utmp_contents,
|
||||
n_read * sizeof (STRUCT_UTMP));
|
||||
|
||||
/* FIXME: can this fail? */
|
||||
endutent ();
|
||||
|
||||
*n_entries = n_read;
|
||||
*utmp_buf = utmp_contents;
|
||||
*utmp_buf = utmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declarations for GNU's read utmp module.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,7 +28,6 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifdef HAVE_UTMPX_H
|
||||
|
||||
15
lib/rename.c
15
lib/rename.c
@@ -41,7 +41,6 @@ int
|
||||
rename (char *from, char *to)
|
||||
{
|
||||
struct stat from_stats, to_stats;
|
||||
int pid, status;
|
||||
|
||||
if (stat (from, &from_stats))
|
||||
return -1;
|
||||
@@ -74,23 +73,27 @@ rename (char *from, char *to)
|
||||
if (S_ISDIR (from_stats.st_mode))
|
||||
{
|
||||
/* Need a setuid root process to link and unlink directories. */
|
||||
pid = fork ();
|
||||
int status;
|
||||
pid_t pid = fork ();
|
||||
switch (pid)
|
||||
{
|
||||
case -1: /* Error. */
|
||||
error (1, errno, "cannot fork");
|
||||
return -1; /* errno already set */
|
||||
|
||||
case 0: /* Child. */
|
||||
execl (MVDIR, "mvdir", from, to, (char *) 0);
|
||||
error (255, errno, "cannot run `%s'", MVDIR);
|
||||
_exit (1);
|
||||
|
||||
default: /* Parent. */
|
||||
while (wait (&status) != pid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
errno = 0; /* mvdir printed the system error message. */
|
||||
if (status)
|
||||
return -1;
|
||||
{
|
||||
/* MVDIR failed. */
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -44,7 +44,8 @@ int
|
||||
rmdir (dpath)
|
||||
char *dpath;
|
||||
{
|
||||
int cpid, status;
|
||||
pid_t cpid;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (dpath, &statbuf) != 0)
|
||||
@@ -73,7 +74,7 @@ rmdir (dpath)
|
||||
while (wait (&status) != cpid)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
if (status & 0xFFFF)
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* /bin/rmdir failed. */
|
||||
|
||||
47
lib/version-etc.c
Normal file
47
lib/version-etc.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
void
|
||||
version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors)
|
||||
{
|
||||
fprintf (stream, "%s (%s) %s\n", command_name, package, version);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.\n\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
||||
\n\
|
||||
"
|
||||
), stream);
|
||||
fprintf (stream, _("Written by %s.\n"), authors);
|
||||
}
|
||||
17
lib/version-etc.h
Normal file
17
lib/version-etc.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef VERSION_ETC_H
|
||||
# define VERSION_ETC_H 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
void
|
||||
version_etc PARAMS ((FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors));
|
||||
|
||||
#endif /* VERSION_ETC_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1997, 98 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 98, 99 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -70,7 +70,7 @@ xalloc_fail (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted);
|
||||
error (xalloc_exit_failure, 0, "%s", xalloc_msg_memory_exhausted);
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
36
m4/ChangeLog
36
m4/ChangeLog
@@ -1,3 +1,39 @@
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4 (jm_CHECK_ALL_TYPES): New macro, contains the
|
||||
superset of the AC_TYPE_* checks in the textutils, fileutils,
|
||||
and sh-utils, plus AC_TYPE_PID_T. Paul Eggert suggested adding
|
||||
AC_TYPE_PID_T.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Define GNU_PACKAGE here.
|
||||
Be sure to AC_SUBST it, once again, so that @GNU_PACKAGE@ is
|
||||
replaced e.g., in the *.sh files of the sh-utils.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: s/jm_WITH_REGEX/jm_INCLUDED_REGEX/.
|
||||
* regex.m4 (jm_INCLUDED_REGEX): Rename from jm_WITH_REGEX.
|
||||
Don't depend on AM_GLIBC. Suggestions from Alain Magloire.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-winsz1.m4 (jm_WINSIZE_IN_PTEM): New macro.
|
||||
|
||||
1999-03-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Use AC_FUNC_SETVBUF_REVERSED.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-glibc-io.m4: Use only those *_unlocked macros that are declared.
|
||||
|
||||
1999-02-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* gettext.m4 (AM_GNU_GETTEXT): Do `changequote' around use of brackets
|
||||
in macro definition. From Eli Zaretskii and Alain Magloire.
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* group-member.m4: New file -- extracted from sh-utils' configure.in.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
@@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
@@ -66,6 +66,7 @@ GENCAT = @GENCAT@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
@@ -98,6 +99,7 @@ VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
|
||||
EXTRA_DIST = README Makefile.am.in afs.m4 assert.m4 check-decl.m4 check-type.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fnmatch.m4 fstypename.m4 getgroups.m4 getline.m4 getloadavg.m4 gettext.m4 glibc.m4 group-member.m4 inttypes_h.m4 isc-posix.m4 jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 st_dm_mode.m4 st_mtim.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 utimes.m4
|
||||
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
@@ -136,7 +138,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
@@ -165,7 +167,7 @@ uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
|
||||
@@ -314,11 +314,13 @@ strdup __argz_count __argz_stringify __argz_next])
|
||||
dnl be included in po/Makefile.
|
||||
test -d po || mkdir po
|
||||
if test "x$srcdir" != "x."; then
|
||||
changequote(, )dnl
|
||||
if test "x`echo $srcdir | sed -e 's@^[A-z]:@@' -e 's@/.*@@'`" = "x"; then
|
||||
posrcprefix="$srcdir/"
|
||||
else
|
||||
posrcprefix="../$srcdir/"
|
||||
fi
|
||||
changequote([, ])dnl
|
||||
else
|
||||
posrcprefix="../"
|
||||
fi
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl See if the glibc *_unlocked I/O macros are available.
|
||||
dnl Use only those *_unlocked macros that are declared.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
|
||||
[AC_CHECK_FUNCS( \
|
||||
clearerr_unlocked \
|
||||
feof_unlocked \
|
||||
ferror_unlocked \
|
||||
fflush_unlocked \
|
||||
fputc_unlocked \
|
||||
fread_unlocked \
|
||||
fwrite_unlocked \
|
||||
getc_unlocked \
|
||||
getchar_unlocked \
|
||||
putc_unlocked \
|
||||
putchar_unlocked \
|
||||
)
|
||||
[
|
||||
io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
|
||||
fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
|
||||
getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
|
||||
for jm_io_func in $io_functions; do
|
||||
# Check for the existence of each function only if its declared.
|
||||
# Otherwise, we'd get the Solaris5.5.1 functions that are not
|
||||
# declared, and that have been removed from Solaris5.6. The resulting
|
||||
# 5.5.1 binaries would not run on 5.6 due to shared library differences.
|
||||
jm_CHECK_DECLARATIONS([#include <stdio.h>
|
||||
], $jm_io_func,
|
||||
jm_declared=yes,
|
||||
jm_declared=no)
|
||||
if test $jm_declared = yes; then
|
||||
AC_CHECK_FUNCS($jm_io_func)
|
||||
fi
|
||||
done
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 6
|
||||
#serial 7
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -6,15 +6,18 @@ AC_DEFUN(jm_MACROS,
|
||||
[
|
||||
AC_PREREQ(2.13) dnl Minimum Autoconf version required.
|
||||
|
||||
GNU_PACKAGE="GNU $PACKAGE"
|
||||
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
|
||||
[The concatenation of the strings \`GNU ', and PACKAGE.])
|
||||
AC_SUBST(GNU_PACKAGE)
|
||||
|
||||
dnl This macro actually runs replacement code. See isc-posix.m4.
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
|
||||
jm_WITH_REGEX([lib/regex.c])
|
||||
jm_INCLUDED_REGEX([lib/regex.c])
|
||||
|
||||
AC_REQUIRE([jm_ASSERT])
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_REQUIRE([jm_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_TYPE])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_INO])
|
||||
@@ -41,4 +44,22 @@ AC_DEFUN(jm_MACROS,
|
||||
[Define to the function xargmatch calls on failures.])
|
||||
AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
|
||||
dnl Used to define SETVBUF in sys2.h.
|
||||
AC_FUNC_SETVBUF_REVERSED
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN(jm_CHECK_ALL_TYPES,
|
||||
[
|
||||
AC_TYPE_GETGROUPS
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_UID_T
|
||||
AC_CHECK_TYPE(ino_t, unsigned long)
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
dnl From Jim Meyering.
|
||||
#serial 1
|
||||
#serial 2
|
||||
AC_DEFUN(jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H,
|
||||
[AC_REQUIRE([AM_SYS_POSIX_TERMIOS])
|
||||
AC_CACHE_CHECK([whether use of TIOCGWINSZ requires termios.h],
|
||||
@@ -17,3 +17,10 @@ AC_DEFUN(jm_HEADER_TIOCGWINSZ_IN_TERMIOS_H,
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN(jm_WINSIZE_IN_PTEM,
|
||||
[AC_CHECK_HEADER([sys/ptem.h],
|
||||
AC_DEFINE(WINSIZE_IN_PTEM, 1,
|
||||
[Define if your system defines \`struct winsize' in sys/ptem.h.]))
|
||||
]
|
||||
)
|
||||
|
||||
73
m4/regex.m4
73
m4/regex.m4
@@ -1,54 +1,51 @@
|
||||
#serial 4
|
||||
#serial 5
|
||||
|
||||
dnl Initially derived from code in GNU grep.
|
||||
dnl Mostly written by Jim Meyering.
|
||||
|
||||
AC_DEFUN(jm_WITH_REGEX,
|
||||
dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
|
||||
dnl
|
||||
AC_DEFUN(jm_INCLUDED_REGEX,
|
||||
[
|
||||
AC_REQUIRE([AM_GLIBC])
|
||||
|
||||
dnl Even packages that don't use regex.c can use this macro.
|
||||
dnl Of course, for them it doesn't do anything.
|
||||
|
||||
# By default, don't use the included regex.c on systems with a version
|
||||
# of glibc 2 that's new enough to pass the following run test.
|
||||
# If cross compiling, assume the test would fail and use the included
|
||||
# regex.c. The failing regular expression is from `Spencer ere test
|
||||
# #75' in grep-2.2f.
|
||||
# Assume we'll default to using the included regex.c.
|
||||
ac_use_included_regex=yes
|
||||
|
||||
if test "$ac_cv_glibc" = yes; then
|
||||
# Without this run-test, on older glibc2 systems we'd end up
|
||||
# using the buggy system regex.
|
||||
AC_CACHE_CHECK([for working re_compile_pattern],
|
||||
jm_cv_func_working_re_compile_pattern,
|
||||
AC_TRY_RUN(
|
||||
changequote(<<, >>)dnl
|
||||
<<
|
||||
# However, if the system regex support is good enough that it passes the
|
||||
# the following run test, then default to *not* using the included regex.c.
|
||||
# If cross compiling, assume the test would fail and use the included
|
||||
# regex.c. The failing regular expression is from `Spencer ere test #75'
|
||||
# in grep-2.3.
|
||||
AC_CACHE_CHECK([for working re_compile_pattern],
|
||||
jm_cv_func_working_re_compile_pattern,
|
||||
AC_TRY_RUN(
|
||||
changequote(<<, >>)dnl
|
||||
<<
|
||||
#include <stdio.h>
|
||||
#include <regex.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
static struct re_pattern_buffer regex;
|
||||
const char *s;
|
||||
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
|
||||
/* Add this third left square bracket, [, to balance the
|
||||
three right ones below. Otherwise autoconf-2.14 chokes. */
|
||||
s = re_compile_pattern ("a[[:]:]]b\n", 9, ®ex);
|
||||
/* This should fail with _Invalid character class name_ error. */
|
||||
exit (s ? 0 : 1);
|
||||
}
|
||||
>>,
|
||||
changequote([, ])dnl
|
||||
int
|
||||
main ()
|
||||
{
|
||||
static struct re_pattern_buffer regex;
|
||||
const char *s;
|
||||
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
|
||||
/* Add this third left square bracket, [, to balance the
|
||||
three right ones below. Otherwise autoconf-2.14 chokes. */
|
||||
s = re_compile_pattern ("a[[:]:]]b\n", 9, ®ex);
|
||||
/* This should fail with _Invalid character class name_ error. */
|
||||
exit (s ? 0 : 1);
|
||||
}
|
||||
>>,
|
||||
changequote([, ])dnl
|
||||
|
||||
jm_cv_func_working_re_compile_pattern=yes,
|
||||
jm_cv_func_working_re_compile_pattern=no,
|
||||
dnl When crosscompiling, assume it's broken.
|
||||
jm_cv_func_working_re_compile_pattern=no))
|
||||
if test $jm_cv_func_working_re_compile_pattern = yes; then
|
||||
ac_use_included_regex=no
|
||||
fi
|
||||
jm_cv_func_working_re_compile_pattern=yes,
|
||||
jm_cv_func_working_re_compile_pattern=no,
|
||||
dnl When crosscompiling, assume it's broken.
|
||||
jm_cv_func_working_re_compile_pattern=no))
|
||||
if test $jm_cv_func_working_re_compile_pattern = yes; then
|
||||
ac_use_included_regex=no
|
||||
fi
|
||||
|
||||
test -n "$1" || AC_MSG_ERROR([missing argument])
|
||||
|
||||
75
man/help2man
75
man/help2man
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/sw/tools/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright © 1997, 98 Free Software Foundation, Inc.
|
||||
# Copyright © 1997, 98, 99 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -25,11 +25,11 @@ use Getopt::Long;
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.007';
|
||||
my $this_version = '1.010';
|
||||
my $version_info = <<EOT;
|
||||
$this_program $this_version
|
||||
|
||||
Copyright (C) 1997, 98 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 98, 99 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
@@ -252,11 +252,11 @@ for (@help)
|
||||
next;
|
||||
}
|
||||
|
||||
# Catch start of options.
|
||||
if (/^Options:/)
|
||||
# Convert some standard paragraph names
|
||||
if (s/^(Options|Examples):\s*\n//)
|
||||
{
|
||||
print qq(.SH OPTIONS\n);
|
||||
s/Options://;
|
||||
print qq(.SH \U$1\n);
|
||||
next unless length;
|
||||
}
|
||||
|
||||
# Catch bug report text.
|
||||
@@ -271,35 +271,50 @@ for (@help)
|
||||
{$1$2$1\\&...=PATTERN };
|
||||
|
||||
# Convert options.
|
||||
s/(\s)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/ge;
|
||||
s/((?:^|,)\s+)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/mge;
|
||||
|
||||
# Option subsections have second line indented.
|
||||
print qq(.SS "$1"\n) if s/^(\S.*)\n(\s)/$2/;
|
||||
|
||||
# Lines indented more than about 10 spaces may be assumed to be
|
||||
# continuations of the previous line.
|
||||
s/\n {10,}/ /g;
|
||||
|
||||
# Lines following dotted (*) or numbered points may also be
|
||||
# continued if indented to the same level as the text following
|
||||
# the point.
|
||||
1 while s{((?:^|\n)(\s+)(?:[1-9][.)]|\*)(\s+)(?:[^\n]+))\n\2 \3(\S)}
|
||||
{$1 $4}g;
|
||||
|
||||
# Indented paragraph.
|
||||
if (/^\s/)
|
||||
my $ind = 0;
|
||||
for (split /\n/)
|
||||
{
|
||||
for (split /\n/)
|
||||
# indented paragraph
|
||||
if (/^\s/)
|
||||
{
|
||||
s/^\s+//;
|
||||
s/([^,])\s+/$1\n/;
|
||||
print ".TP\n$_\n" if $_;
|
||||
# Join continued lines when indented to the same point as
|
||||
# text following at least two spaces on the previous line.
|
||||
if ($ind > 0 and /^ {$ind}\S/)
|
||||
{
|
||||
s/^\s+//;
|
||||
print "$_\n" if $_;
|
||||
}
|
||||
else
|
||||
{
|
||||
# use the words(s) before two or more spaces for the
|
||||
# tag
|
||||
s/^(\s+)//;
|
||||
$ind = length $1;
|
||||
|
||||
if (s/(\s\s+)/\n/)
|
||||
{
|
||||
$ind += (length $1) + index $_, "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ind = 0;
|
||||
}
|
||||
|
||||
print ".TP\n$_\n" if $_;
|
||||
}
|
||||
}
|
||||
# Anything else.
|
||||
else
|
||||
{
|
||||
print ".PP\n" unless $ind < 0;
|
||||
print "$_\n";
|
||||
$ind = -1;
|
||||
}
|
||||
}
|
||||
# Anything else.
|
||||
else
|
||||
{
|
||||
print ".PP\n$_\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
man/pinky.x
Normal file
2
man/pinky.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
@@ -1,3 +1,408 @@
|
||||
1999-04-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0e
|
||||
|
||||
* tests/cp/same-file: Change the sed command used to extract the
|
||||
filename from ls -l output, to accommodate the change in format.
|
||||
|
||||
* src/ls.c (print_long_format): Add a space between %s and %3u. This
|
||||
assures that even when modebuf has the trailing `+' and there are more
|
||||
than 99 hard links to a file, the permissions string and the link count
|
||||
will be separated.
|
||||
|
||||
1999-04-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c (dopass): add curly braces to avoid warning about
|
||||
ambiguous `else'.
|
||||
(wipefd): Add parentheses suggested by gcc.
|
||||
(do_wipefd): Remove declaration of unused local.
|
||||
|
||||
1999-04-02 Colin Plumb <colin@nyx.net>
|
||||
|
||||
* shred.c [!HAVE_CONFIG_H] (xstrtoul, error, close_stdout): Added stubs
|
||||
to allow standalone compilation.
|
||||
|
||||
(wipefile): Added support for emulating /dev/fd/# files even if
|
||||
the OS doesn't support them. From Paul Eggert.
|
||||
|
||||
(main, usage): Changed --device short option to -D.
|
||||
|
||||
(wipefd, do_wipefd): Renamed function to do_wipefd and added
|
||||
separate wipefd that performs sanity checks on externally-opened file
|
||||
descriptors, such as not append-only. From Paul Eggert.
|
||||
|
||||
(do_wipefd, isaac_seedfd): Do not read file for any reason.
|
||||
if the file is low-entropy, it's a security hole.
|
||||
(wipefile) Changed to open O_WRONLY and chmod to write-only when
|
||||
forcing.
|
||||
(isaac_seedfd) Function deleted as unnecessary.
|
||||
From Paul Eggert.
|
||||
|
||||
(dopass): Dynamically fall back to fsync() if fdatasync() fails,
|
||||
since POSIX, in their infinitesimal wisdom, encourage implementations
|
||||
that return constant -1, making compile-time testing useless.
|
||||
From Paul Eggert.
|
||||
|
||||
(dopass): Changed to support a size of -1 to mean "unknown".
|
||||
This entailed changing to a counting-up offset rather than couting-down
|
||||
cursize for the central state variable. Also changed size argument to
|
||||
be call-by-reference so that it can be passed back once known.
|
||||
(sizer) Function deleted as unnecessary.
|
||||
(wipefd): Changed to match. From Paul Eggert
|
||||
|
||||
(dopass): Try to skip over bad blocks in destination files.
|
||||
Also added ftruncate() for more complete destruction of metadata.
|
||||
|
||||
(main, usage): Changed "-" to stand for standard output.
|
||||
(wipefd): Added error message to detect conflict with -v.
|
||||
|
||||
(dopass): Added periodic fsync() calls to keep the pass progress
|
||||
display in sync with reality. Hopefully they're sufficiently far spaced
|
||||
that throughput isn't affected. It might be a good thing to do even in
|
||||
non-verbose mode, to avoid filling up the kernel caches with dirty data.
|
||||
Also added ftruncate() for more complete destruction of metadata.
|
||||
|
||||
(quotearg_colon): New function to print
|
||||
pathological filenames properly.
|
||||
[!HAVE_CONFIG_H] (quotearg_colon_buf) New internal helper function
|
||||
that does most of the work.
|
||||
(wipefd, do_wipefd, dopass) Now take a qname (pre-quoted name) argument.
|
||||
(wipename, wipefile, main) Changed diagnostics to use quotearg_colon.
|
||||
Error messages are also in a more uniform format.
|
||||
From Paul Eggert.
|
||||
|
||||
(struct Options, main, do_wipefd): Added -s/--size=N flag.
|
||||
(xstrtoul): Added support for valid_suffixes to help this.
|
||||
(usage) Documented it.
|
||||
|
||||
(error): Changed some arguments from N_() to _(), since error()
|
||||
does not translate its argument. I think this is a bug.
|
||||
|
||||
(struct Options do_wipefd, wipefd, wipefile, main): moved passes
|
||||
argument into the Options structure as n_iterations, which is now a
|
||||
size_t. From Paul Eggert.
|
||||
|
||||
(isaac_seed_start, isaac_seed_data, isaac_seed_finish): New functions
|
||||
to manage seeding of RNG with arbitrary-sized data.
|
||||
(isaac_init): commented out as dead code.
|
||||
(isaac_seed): changed to use new functions to prevent any possibility of
|
||||
a buffer overflow.
|
||||
|
||||
(isaac_seed): Added support for Solaris' gethrtime()
|
||||
configure.in: Corresponding feature test. From Paul Eggert.
|
||||
|
||||
(wipename): Change remove() to unlink() for speed & portability.
|
||||
Use lstat() instead of access() to see if a filename is taken. This
|
||||
works even on dangling symlinks and avoids the suid problems of
|
||||
access(2). From Paul Eggert.
|
||||
|
||||
(isaac_seed_machdep): New function for reading cycle counters
|
||||
|
||||
1999-04-02 Paul Eggert <eggert@shade.twinsun.com>
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add gethrtime.
|
||||
|
||||
* src/shred.c (isaac_seed): Don't overrun the s->mm buffer.
|
||||
Use gethrtime if available. Don't assume that clock_gettime succeeds.
|
||||
Put most random sources first.
|
||||
|
||||
1999-04-02 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
shred: Add new options -bcCklL and fix some porting problems.
|
||||
Remove options -dp. Do not read output files.
|
||||
|
||||
* src/shred.c (long_opts, usage, main, wipefile): Adjust to
|
||||
new options.
|
||||
("human.h", "quotearg.h"): New includes.
|
||||
(struct Options): New members contents, links, n_iterations.
|
||||
Remove allow_devices, remove_file. Change n_iterations to size_t.
|
||||
All uses changed.
|
||||
(output_block_size): New var.
|
||||
(usage): Declare __noreturn__ attribute.
|
||||
(fdatasync): Define to -1 if not present, since we need to invoke both
|
||||
fdatasync and fsync if both are present. All invokers of fdatasync
|
||||
now try fdatasync, then fsync.
|
||||
(MIXIN): New macro.
|
||||
(isaac_seed): Use it to mix in values. Add uid, gid to mix.
|
||||
Don't use gettimeofday, as it has too many porting problems.
|
||||
(isaac_seedfd): Remove, since we no longer read the output files.
|
||||
(sizefd): Remove; we now determine size by writing sequentially.
|
||||
(dopass, wipename, wipefile, main): Clean up error messages.
|
||||
(dopass): Keep track of offset relative to start of file, not
|
||||
end, since we may not know how large the file is. If size is
|
||||
negative, write until we fall off the end of the file.
|
||||
(wipefd): Do not read output file.
|
||||
Return 0 if successful, -1 if not; do not make a special case for
|
||||
non-regular files, since our callers have that info now.
|
||||
(wipename): Now static. Return errno if error.
|
||||
(main): "-" now stands for standard output.
|
||||
Do not shred append-only standard output.
|
||||
(wipefile): Do not grant read permission to file when wiping it.
|
||||
Use symbolic permission (S_IWUSR), not octal.
|
||||
|
||||
* src/system.h (S_IWUSR): Define if not already defined.
|
||||
|
||||
* configure.in (AC_SEARCH_LIBS): Prefer rt to posix4, for Solaris 7.
|
||||
(AC_CHECK_FUNCS): Remove gettimeofday.
|
||||
|
||||
* doc/fileutils.texi: Document recent changes.
|
||||
|
||||
1999-04-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (AC_CHECK_FUNCS): Add acl.
|
||||
(AC_CHECK_HEADERS): Add sys/acl.h.
|
||||
* src/ls.c [HAVE_SYS_ACL_H]: Include sys/acl.h.
|
||||
(struct fileinfo): New member `have_acl'.
|
||||
(gobble_file): Initialize it.
|
||||
(print_long_format): Use it.
|
||||
Mostly from Alen Muzinic.
|
||||
|
||||
* src/touch.c (open_maybe_create): New function.
|
||||
(touch): Rewrite not to use `creat' and to eliminate a race
|
||||
condition that could make touch truncate a nonempty file.
|
||||
Report and suggestions from Andrew Tridgell.
|
||||
|
||||
1999-03-31 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/du.c: Remove prototypes and tsort function definitions.
|
||||
|
||||
* src/chown.c (main): Move the declaration of `e' into the scope
|
||||
where it's used and make it `const'.
|
||||
|
||||
* src/install.c (main): Qualify a char* with the `const' keyword.
|
||||
(install_file_in_dir): Likewise.
|
||||
* src/ln.c (main): Likewise.
|
||||
* src/mkdir.c (main): Likewise.
|
||||
* src/mkfifo.c (main): Likewise.
|
||||
* src/mknod.c (main): Likewise.
|
||||
* src/mv.c (main): Likewise.
|
||||
* src/touch.c (touch): Likewise.
|
||||
|
||||
1999-03-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/*.c: Don't include closeout.h or version-etc.h explicitly.
|
||||
Now, they're included via sys2.h.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Minor lint removal in code that forks and execs.
|
||||
|
||||
* lib/mkdir.c (mkdir): Use pid_t instead of int; check status
|
||||
against zero. This is to improve portability.
|
||||
* lib/rename.c (rename): Likewise.
|
||||
* lib/rmdir.c (rmdir): Likewise.
|
||||
|
||||
* lib/rename.c (rename):
|
||||
(rename): Do not print any error messages, so that the messages
|
||||
are internationalized properly.
|
||||
|
||||
* src/install.c (strip): Use standard "cannot fork" message.
|
||||
Check for strip nonzero exit status.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
`chmod =OP' did not properly apply the umask
|
||||
* lib/modechange.c (make_node_op_equals): New function.
|
||||
(mode_append_entry): Likewise.
|
||||
(mode_compile): When none of [ugoa] is specified in an `=OP' change
|
||||
mode request, insert a `=0' entry into the linked list so that all
|
||||
bits are cleared first. Use the new functions.
|
||||
Reported by Andrew Dalke.
|
||||
|
||||
New test for the above.
|
||||
* configure.in (AC_OUTPUT): Add tests/chmod/Makefile.
|
||||
* tests/Makefile.am (SUBDIRS): Add chmod.
|
||||
* tests/chmod: New directory
|
||||
* tests/chmod/equal-x: New file.
|
||||
|
||||
1999-03-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/modechange.c (mode_compile): Upon allocation failure, free
|
||||
everything starting with the head, not the tail.
|
||||
|
||||
* src/install.c (strip): Use pid_t, not int. From John Bley.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dd.c (PROGRAM_NAME, AUTHORS): Define
|
||||
(long_options): Remove unused struct.
|
||||
(scanargs): Remove useless loop.
|
||||
(main): Use PROGRAM_NAME and AUTHORS in call to parse_long_options.
|
||||
* src/mvdir.c: Likewise.
|
||||
* src/sync.c (PROGRAM_NAME, AUTHORS): Define and use.
|
||||
|
||||
1999-03-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
* lib/long-options.c (parse_long_options): Remove version-, copyright-,
|
||||
and author-printing code. Do it via version_etc.
|
||||
|
||||
* lib/version-etc.c: New file.
|
||||
* lib/version-etc.h: Prototype for same.
|
||||
|
||||
* src/sys2.h (GETOPT_HELP_CHAR): Define.
|
||||
(GETOPT_VERSION_CHAR): Define.
|
||||
(GETOPT_HELP_OPTION_DECL): Define.
|
||||
(GETOPT_VERSION_OPTION_DECL): Define.
|
||||
(case_GETOPT_HELP_CHAR): Define.
|
||||
(case_GETOPT_VERSION_CHAR): Define.
|
||||
|
||||
* src/chgrp.c: No longer include long-options.h.
|
||||
Include version-etc.h instead.
|
||||
(PROGRAM_NAME, AUTHORS): Define.
|
||||
[long_options]: Add entries for --help and --version.
|
||||
Remove parse_long_options call.
|
||||
(main) [getopt switch]: Add a case for each of --help and --version.
|
||||
* src/chgrp.c: Likewise.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/cp.c: Likewise.
|
||||
* src/df.c: Likewise.
|
||||
* src/dircolors.c: Likewise.
|
||||
* src/du.c: Likewise.
|
||||
* src/install.c: Likewise.
|
||||
* src/ln.c: Likewise.
|
||||
* src/ls.c: Likewise.
|
||||
* src/mkdir.c: Likewise.
|
||||
* src/mkfifo.c: Likewise.
|
||||
* src/mknod.c: Likewise.
|
||||
* src/mv.c: Likewise.
|
||||
* src/rm.c: Likewise.
|
||||
* src/rmdir.c: Likewise.
|
||||
* src/shred.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
1999-03-24 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* man/help2man: Import version 1.010.
|
||||
|
||||
1999-03-22 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/chmod.c (usage): Add one-liner. Suggestion from Karl Berry.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/automake-wrap: Rewrite the automake-generated rule for
|
||||
clean-binPROGRAMS so that it removes rm even with a losing PATH on a
|
||||
losing system (PATH with `.' before /bin on a system where you can't
|
||||
unlink a running executable). Reported by William Bader.
|
||||
|
||||
* configure.in: Use jm_WINSIZE_IN_PTEM.
|
||||
* src/ls.c [WINSIZE_IN_PTEM]: Include sys/stream.h and sys/ptem.h.
|
||||
Required by SCO ODT 2.0 systems. Reported by William Bader.
|
||||
|
||||
1999-03-18 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/remove.c (remove_cwd_entries): Reflect changes in hash_insert.
|
||||
(remove_init): Call hash_initialize with one more argument.
|
||||
|
||||
1999-03-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Revamp to allow fine-tuning to control when and by how
|
||||
much the table grows and shrinks.
|
||||
* lib/hash.c (next_prime): Don't assert.
|
||||
(hash_reset_tuning): New function.
|
||||
(check_tuning): New function.
|
||||
(hash_initialize): Accept and use new tuning parameter.
|
||||
(hash_rehash): Rewrite, updating for tuning.
|
||||
(hash_insert): Honor tuning semantics.
|
||||
(hash_delete): Likewise.
|
||||
From François Pinard.
|
||||
|
||||
* lib/hash.h (struct hash_tuning): Define.
|
||||
(struct hash_table) [tuning]: Add member.
|
||||
(hash_initialize): Add `tuning' parameter.
|
||||
|
||||
* lib/hash.c (hash_insert): Remove last parameter and change semantics.
|
||||
* lib/hash.h (hash_insert): Update prototype.
|
||||
|
||||
* lib/hash.c (hash_insert): Don't increment n_entries unconditionally --
|
||||
otherwise, we'd do so even when the insertion failed.
|
||||
From François Pinard.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/xmalloc.c (xalloc_fail): Use "%s" format so the message doesn't
|
||||
have to be scanned for % signs. Suggestion from François Pinard.
|
||||
|
||||
* Makefile.maint: Add two more URLs and the loops to use them.
|
||||
|
||||
* lib/long-options.c (parse_long_options): Include `Copyright...' line
|
||||
in --version output.
|
||||
Add the `...NO warranty...' message.
|
||||
|
||||
1999-03-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/long-options.c (_): Define it.
|
||||
(parse_long_options): Accept new parameter, authors, and print it.
|
||||
|
||||
* lib/long-options.h: Update prototype.
|
||||
|
||||
* src/chgrp.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/chown.c: Likewise.
|
||||
* src/cp.c: Likewise.
|
||||
* src/dd.c: Likewise.
|
||||
* src/df.c: Likewise.
|
||||
* src/dircolors.c: Likewise.
|
||||
* src/du.c: Likewise.
|
||||
* src/install.c: Likewise.
|
||||
* src/ln.c: Likewise.
|
||||
* src/ls.c: Likewise.
|
||||
* src/mkdir.c: Likewise.
|
||||
* src/mkfifo.c: Likewise.
|
||||
* src/mknod.c: Likewise.
|
||||
* src/mv.c: Likewise.
|
||||
* src/mvdir.c: Likewise.
|
||||
* src/rm.c: Likewise.
|
||||
* src/rmdir.c: Likewise.
|
||||
* src/shred.c: Likewise.
|
||||
* src/sync.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
1999-02-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* getdate.y: <alloca.h>: Include if HAVE_ALLOCA_H, not FORCE_ALLOCA_H.
|
||||
The FORCE_ALLOCA_H was a relic of the bad old pre-autoconf Emacs days.
|
||||
|
||||
1999-02-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/shred.c (wipename): Fix string thinko. Now, shredding files
|
||||
in subdirectories works (dir/file). From Janos Farkas.
|
||||
|
||||
1999-02-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dircolors.c (dc_parse_stream): Don't try to dereference
|
||||
NULL if there's an error in our built-in list.
|
||||
Suggestion from François Pinard.
|
||||
|
||||
1999-02-13 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
||||
|
||||
* src/install.c (main): Set x.backup_type only if backups are requested.
|
||||
(cp_option_init): Initialize backup_type.
|
||||
(backup_type): Remove unused variable.
|
||||
|
||||
* doc/fileutils.texi: Fix use of @item vs @itemx.
|
||||
|
||||
1999-02-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/dircolors.c (slack_codes): Add "DOOR".
|
||||
(ls_codes): Add corresponding "do".
|
||||
Reported by John Gotts.
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Italian (it).
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0d (aka 4.1-b4).
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
Changes in release 4.1:
|
||||
[4.0e]
|
||||
* shred --devices option renamed to -D so that -d, -i and -r can be
|
||||
compatible with rm.
|
||||
* shred -s/--size=N option added to specify the size of the object to be
|
||||
shredded.
|
||||
* `shred -' now shreds stdout rather than stdin. This is incompatible with -v.
|
||||
* shred now does not need to read from its output file, so opens it O_WRONLY
|
||||
* `ls -l' uses `+' to designate each file that has a custom ACL
|
||||
* eliminate race condition that could make touch truncate a nonempty file
|
||||
* No longer use *_unlocked I/O macros on systems (like solaris5.5.1) where
|
||||
they're not declared, so selected executables (e.g., rm) that are linked
|
||||
with shared libraries will once again run on solaris5.6 systems.
|
||||
[4.0d (aka 4.1-b3)]
|
||||
* ls recognizes solaris 2 `doors'
|
||||
* new program: shred
|
||||
|
||||
@@ -1,5 +1,188 @@
|
||||
1999-03-30 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h: Include "closeout.h" and "version-etc.h"
|
||||
|
||||
* src/*.c (PROGRAM_NAME, AUTHORS): Define and use.
|
||||
|
||||
* src/date.c: No longer include long-options.h.
|
||||
[long_options]: Add entries for --help and --version.
|
||||
Remove parse_long_options call.
|
||||
(main) [getopt switch]: Add a case for each of --help and --version.
|
||||
* src/env.c: Likewise.
|
||||
* src/id.c: Likewise.
|
||||
* src/pinky.c: Likewise.
|
||||
* src/seq.c: Likewise.
|
||||
* src/su.c: Likewise.
|
||||
* src/sys2.h: Likewise.
|
||||
* src/tee.c: Likewise.
|
||||
* src/tty.c: Likewise.
|
||||
* src/uname.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-28 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/test.c (PROGRAM_NAME): Rename from COMMAND_NAME.
|
||||
|
||||
1999-03-28 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/getdate.y (get_date): Reuse tm_isdst of first localtime
|
||||
call; this is an improvement on a bug fix suggested by
|
||||
martin@dresden.nacamar.de. Do not assume that localtime and
|
||||
gmtime return non-null.
|
||||
|
||||
1999-03-27 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/false.sh (usage): Change `[OPTION]...' to `[OPTION]' to show
|
||||
that only one of --help or --version is recognized at a time.
|
||||
Reported by Meelis Roos.
|
||||
* src/true.sh: Likewise.
|
||||
|
||||
* src/id.c (print_user): Use uid_t instead of int.
|
||||
(print_group): Use gid_t instead of int.
|
||||
From John Bley.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/nohup.sh: Don't modify PATH just to get GNU nice. Instead,
|
||||
try to find an absolute path for GNU nice. From Bruno Haible.
|
||||
|
||||
1999-03-19 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in: Use new macro, jm_WINSIZE_IN_PTEM, instead of
|
||||
open-coding it.
|
||||
|
||||
1999-03-17 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Italian (it) and Slovak (sk).
|
||||
|
||||
1999-03-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/basename.c (base_name): If NAME is all slashes, return `/' (in
|
||||
conformance with the single unix spec). Reported by Peter Moulder.
|
||||
|
||||
1999-03-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/uptime.c: Declare getloadavg so I can build with -Werror.
|
||||
|
||||
* tests/stty/basic-1: Skip failing tests: parenb, -parenb, -cread.
|
||||
|
||||
* lib/canon-host.c (canon_host): Don't use he->h_addr directly.
|
||||
Based on a patch from Savochkin Andrey Vladimirovich.
|
||||
|
||||
1999-03-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Running `id USER' doesn't report any groups if there is no entry
|
||||
for USER in /etc/group. Always include the one from /etc/passwd.
|
||||
* src/id.c: (xgetgroups): Take new parameter, gid, and pass
|
||||
it to getugroups.
|
||||
(print_group_list): Call getpwuid and adjust calls to xgetgroups
|
||||
to include new parameter.
|
||||
* lib/getugroups.c (getugroups): Take new parameter, gid.
|
||||
Add gid to the list of groups.
|
||||
From Ulrich Drepper.
|
||||
* lib/getgroups.c (getgroups): Protoize.
|
||||
|
||||
1999-03-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/basename: New directory and tests.
|
||||
* tests/Makefile.am (SUBDIRS): Add basename.
|
||||
* configure.in (AC_OUTPUT): Add tests/basename/Makefile.
|
||||
|
||||
1999-03-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/date.c (batch_convert): Use a `%s' format in error call,
|
||||
in case the argument string contains a `%'.
|
||||
|
||||
* man/Makefile.am (man_MANS): Add pinky.1.
|
||||
* man/Makefile.summ (pinky-summary): Define.
|
||||
|
||||
* src/date.c: Include long-options.h.
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/env.c: Likewise.
|
||||
* src/id.c: Likewise.
|
||||
* src/logname.c: Likewise.
|
||||
* src/pathchk.c: Likewise.
|
||||
* src/pinky.c: Likewise.
|
||||
* src/printenv.c: Likewise.
|
||||
* src/seq.c: Likewise.
|
||||
* src/sleep.c: Likewise.
|
||||
* src/su.c: Likewise.
|
||||
* src/tee.c: Likewise.
|
||||
* src/tty.c: Likewise.
|
||||
* src/uname.c: Likewise.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
* src/whoami.c: Likewise.
|
||||
|
||||
1999-03-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/basename.c (main): Include author name argument in call to
|
||||
parse_long_options.
|
||||
* src/chroot.c: Likewise.
|
||||
* src/dirname.c: Likewise.
|
||||
* src/echo.c: Likewise.
|
||||
* src/expr.c: Likewise.
|
||||
* src/factor.c: Likewise.
|
||||
* src/hostid.c: Likewise.
|
||||
* src/hostname.c: Likewise.
|
||||
* src/nice.c: Likewise.
|
||||
* src/printf.c: Likewise.
|
||||
* src/pwd.c: Likewise.
|
||||
* src/stty.c: Likewise.
|
||||
* src/test.c: Likewise.
|
||||
* src/yes.c: Likewise.
|
||||
|
||||
1999-03-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/readutmp.c (read_utmp) [HAVE_UTMPNAME]: Rewrite.
|
||||
|
||||
1999-02-15 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/stty.c (main): #ifdef-out unreachable code.
|
||||
|
||||
* src/pinky.c (usage): Add a one-line description.
|
||||
Suggestion from Karl Berry.
|
||||
|
||||
1999-02-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Czech (cs).
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/stty/basic-1: Run all tests even if some fail.
|
||||
Don't use trap.
|
||||
|
||||
* tests/stty/basic-1: Use `stty', not $STTY.
|
||||
Fix typo in VERBOSE code: s/\$RM/stty/.
|
||||
* tests/stty/row-col-1: Likewise.
|
||||
|
||||
* tests/stty/Makefile.am (TESTS_ENVIRONMENT): Set PATH, not STTY.
|
||||
|
||||
Include stdio.h before defining `_unlocked' macros.
|
||||
* src/pinky.c: Include stdio.h.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
* lib/readutmp.c: Include stdio.h here...
|
||||
* lib/readutmp.h: ...not here.
|
||||
From Ulrich Drepper.
|
||||
|
||||
* Version 1.16f.
|
||||
|
||||
* Makefile.maint (my-distcheck): Don't depend on dist, now that this
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
Changes in release 1.17
|
||||
[1.16g]
|
||||
* nohup no longer modifies the shell's search path
|
||||
* `basename /' now prints `/', per the single unix spec
|
||||
* `who --lookup' no longer erroneously reports `localhost' for IP addresses
|
||||
for which it could not do a reverse lookup.
|
||||
* `id user' wouldn't report a group id in some situations. Now it always does.
|
||||
[1.16f]
|
||||
* chroot now calls chdir ("/") after chroot.
|
||||
* `date -s' now exits with nonzero status upon failure
|
||||
|
||||
@@ -1,3 +1,177 @@
|
||||
1999-04-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cat.c: Standardize --help and --version processing.
|
||||
* src/comm.c: Likewise.
|
||||
* src/csplit.c: Likewise.
|
||||
* src/cut.c: Likewise.
|
||||
* src/expand.c: Likewise.
|
||||
* src/fmt.c: Likewise.
|
||||
* src/fold.c: Likewise.
|
||||
* src/head.c: Likewise.
|
||||
* src/join.c: Likewise.
|
||||
* src/md5sum.c: Likewise.
|
||||
* src/nl.c: Likewise.
|
||||
* src/od.c: Likewise.
|
||||
* src/paste.c: Likewise.
|
||||
* src/pr.c: Likewise.
|
||||
* src/ptx.c: Likewise.
|
||||
* src/split.c: Likewise.
|
||||
* src/sum.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
* src/tail.c: Likewise.
|
||||
* src/tr.c: Likewise.
|
||||
* src/unexpand.c: Likewise.
|
||||
* src/uniq.c: Likewise.
|
||||
* src/wc.c: Likewise.
|
||||
|
||||
1999-03-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (GNU_PACKAGE): Remove related code -- now it's in
|
||||
the catch-all for shared autoconf code, m4/jm-macros.m4.
|
||||
(jm_CHECK_ALL_TYPES): Remove explicit AC_TYPE_* macros and use
|
||||
this instead.
|
||||
|
||||
1999-03-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Add version-etc.c.
|
||||
(noinst_HEADERS): Add version-etc.h.
|
||||
|
||||
1999-03-25 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tail.c (recheck): Factor out a block of duplicated code.
|
||||
Set f->size to 0 upon encountering a new file so we read it from
|
||||
the beginning rather than from then end of the first line or
|
||||
block. Otherwise, after a log rotation, tail would omit the first
|
||||
line or block of the new file. Reported by Ed Avis.
|
||||
|
||||
1999-03-20 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am (SUBDIRS): Temporarily remove pr.
|
||||
|
||||
1999-03-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/tac.c: (tac_mem): `#if-0'-out this unused function.
|
||||
(tac_stdin_to_mem): Likewise.
|
||||
|
||||
* doc/textutils.texi (cut invocation): Describe --output-delimiter.
|
||||
|
||||
1999-03-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/sys2.h (SETVBUF): Define new macro.
|
||||
* src/tail.c (dump_remainder): Don't fflush stdout here.
|
||||
(main) [if forever]: Make stdout unbuffered, instead.
|
||||
Akim Demaille pointed out that when running `echo x>a; tail -f a>>a' ,
|
||||
the file `a' didn't grow longer than two lines. Now it grows
|
||||
without bound.
|
||||
|
||||
1999-03-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/md5sum/newline-1: Test for the actual feature.
|
||||
With help from Eli Zaretskii.
|
||||
|
||||
* src/pr.c (usage): Add missing \n\.
|
||||
|
||||
The newline test would always fail on MSDOS/Windows systems --
|
||||
so move it to a separate file where we can test for that.
|
||||
* tests/md5sum/basic-1: Remove newline test.
|
||||
* tests/md5sum/newline-1: New file.
|
||||
* tests/md5sum/Makefile.am (TESTS): Add newline-1.
|
||||
Pointed out by Eli Zaretskii.
|
||||
|
||||
1999-02-13 Roland Huebner <rh@pelikan.cologne.de>
|
||||
* src/pr.c
|
||||
(main): Redefine options -s, -w to be POSIX compliant; introduce
|
||||
new options -J, -S, -W to disentangle -s and -w when used together
|
||||
with the three column options;
|
||||
(add_line_number): Make POSIX compliant; use default number
|
||||
separator TAB with single column output.
|
||||
(add_line_number): Make POSIX compliant; with multicolumn output
|
||||
now prefer `text columns of equal width' rather than a consequent
|
||||
use of `default n-separator TAB'.
|
||||
(add_line_number): Change line number cut-off from lower-oder to
|
||||
higher-oder digit to avoid loss of information; no consequent
|
||||
handling exists in different utilities and other UNIXes.
|
||||
(char_to_clump): Expand input text tabs to 8 spaces, if
|
||||
input_tab_char doesn't equal TAB (adapted to other UNIXes).
|
||||
(usage): Update POSIX compliant options -s, -w; add new options -J,
|
||||
-S, -W.
|
||||
(main): Update the source internal documentation.
|
||||
Some smaller BUGFIXES (print_sep_string, init_header, skip_to_page,
|
||||
reset_status, print_header).
|
||||
|
||||
* tests/md5sum/basic-1 (backslash): Use .\foo instead of \.foo so we
|
||||
don't tramp on root directory in MSDOS/Windows.
|
||||
Suggestion from Eli Zaretskii.
|
||||
|
||||
1999-02-15 Eli Zaretskii <eliz@is.elta.co.il>
|
||||
|
||||
* tests/md5sum/Makefile.am (TESTS_ENVIRONMENT): Run md5sum with the
|
||||
--text option (for MSDOS).
|
||||
|
||||
1999-03-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cut.c (getstr): Change type of `delim' parameter from char to int.
|
||||
(cut_fields): Cast to `unsigned char' before comparing.
|
||||
(main): Cast to `unsigned char' before assigning.
|
||||
From Arne Juul.
|
||||
* tests/cut/Test.pm: Add a test to exercise the bug.
|
||||
|
||||
* src/ptx.c (swallow_file_in_memory): Use a `%s' format in error call,
|
||||
in case the argument string contains a `%'.
|
||||
(main): Likewise.
|
||||
* src/fmt.c (main): Likewise.
|
||||
* src/sort.c (main): Likewise.
|
||||
|
||||
1999-02-13 Eli Zaretskii <eliz@is.elta.co.il>
|
||||
|
||||
* src/sys2.h [__DJGPP__]: Include <io.h> and <sys/exceptn.h>.
|
||||
|
||||
* src/ptx.c (swallow_file_in_memory): Slurp up the whole file at
|
||||
once on MSDOS as well, but we have to relax the test for whether
|
||||
reading it succeeded.
|
||||
|
||||
1999-03-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/cat.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
* src/cksum.c: Likewise.
|
||||
* src/comm.c: Likewise.
|
||||
* src/csplit.c: Likewise.
|
||||
* src/cut.c: Likewise.
|
||||
* src/expand.c: Likewise.
|
||||
* src/fmt.c: Likewise.
|
||||
* src/fold.c: Likewise.
|
||||
* src/head.c: Likewise.
|
||||
* src/nl.c: Likewise.
|
||||
* src/od.c: Likewise.
|
||||
* src/paste.c: Likewise.
|
||||
* src/pr.c: Likewise.
|
||||
* src/split.c: Likewise.
|
||||
* src/sum.c: Likewise.
|
||||
* src/tac.c: Likewise.
|
||||
* src/tail.c: Likewise.
|
||||
* src/tr.c: Likewise.
|
||||
* src/unexpand.c: Likewise.
|
||||
* src/uniq.c: Likewise.
|
||||
* src/wc.c: Likewise.
|
||||
|
||||
* src/ptx.c: Include long-options.h
|
||||
[long_options]: Remove the "help" and "version" entries.
|
||||
Remove declarations of show_help and show_version.
|
||||
(main): Remove `const' attribute from dcl of argv parameter.
|
||||
Call bindtextdomain and textdomain.
|
||||
Use parse_long_options, including author name(s).
|
||||
Remove the show_version and show_help blocks.
|
||||
|
||||
* src/join.c (main): Include author name argument in call to
|
||||
parse_long_options.
|
||||
* src/md5sum.c (main): Likewise.
|
||||
* src/sort.c (main): Likewise.
|
||||
* src/tsort.c (main): Likewise.
|
||||
|
||||
1999-02-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22h.
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
Changes in release 1.23
|
||||
[1.22i]
|
||||
* `tail -f' now ensures that stdout is unbuffered
|
||||
* fix a bug in cut to allow use of 8-bit delimiters
|
||||
* pr accepts POSIX compliant options -s and -w,
|
||||
the new capital letter options -J, -S and _W turn off the
|
||||
unexpected interferences of the small letter options -s and -w
|
||||
if used together with the column options.
|
||||
* pr output has been adapted to other UNIXes in some cases.
|
||||
[1.22h]
|
||||
* portability tweaks
|
||||
* Window/NT/DOS support
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from filenames
|
||||
Copyright (C) 90,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -33,6 +33,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "basename"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
char *base_name ();
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
@@ -93,7 +98,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "basename", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc == 1 || argc > 3)
|
||||
{
|
||||
|
||||
30
src/cat.c
30
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 88, 90, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "error.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cat"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund and Richard M. Stallman"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef max
|
||||
#define max(h,i) ((h) > (i) ? (h) : (i))
|
||||
@@ -510,12 +515,6 @@ main (int argc, char **argv)
|
||||
/* If nonzero, call cat, otherwise call simple_cat to do the actual work. */
|
||||
int options = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"number-nonblank", no_argument, NULL, 'b'},
|
||||
@@ -528,8 +527,8 @@ main (int argc, char **argv)
|
||||
#if O_BINARY
|
||||
{"binary", no_argument, NULL, 'B'},
|
||||
#endif
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -614,20 +613,15 @@ main (int argc, char **argv)
|
||||
output_tabs = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cat (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
output_desc = 1;
|
||||
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
36
src/chgrp.c
36
src/chgrp.c
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,11 +24,15 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "group-member.h"
|
||||
#include "savedir.h"
|
||||
#include "xstrtoul.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chgrp"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* MAXUID may come from limits.h *or* sys/params.h (via system.h) above. */
|
||||
#ifndef MAXUID
|
||||
@@ -97,12 +101,6 @@ static const char *groupname;
|
||||
This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
@@ -112,8 +110,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -303,7 +301,7 @@ usage (int status)
|
||||
Usage: %s [OPTION]... GROUP FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
program_name, program_name);
|
||||
printf (_("\
|
||||
Change the group membership of each FILE to GROUP.\n\
|
||||
\n\
|
||||
@@ -361,21 +359,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
37
src/chmod.c
37
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,12 +22,16 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "modechange.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "filemode.h"
|
||||
#include "modechange.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chmod"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
enum Change_status
|
||||
{
|
||||
@@ -70,12 +74,6 @@ static enum Verbosity verbosity = V_off;
|
||||
of this file. This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
@@ -84,8 +82,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -239,11 +237,12 @@ usage (int status)
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
|
||||
or: %s [OPTION]... OCTAL_MODE FILE...\n\
|
||||
or: %s [OPTION]... OCTAL-MODE FILE...\n\
|
||||
or: %s [OPTION]... --reference=RFILE FILE...\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
printf (_("\
|
||||
Change the mode of each FILE to MODE.\n\
|
||||
\n\
|
||||
-c, --changes like verbose but report only when a change is made\n\
|
||||
-f, --silent, --quiet suppress most error messages\n\
|
||||
@@ -326,21 +325,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chmod (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (modeind == 0 && reference_file == NULL)
|
||||
modeind = optind++;
|
||||
|
||||
|
||||
36
src/chown.c
36
src/chown.c
@@ -1,5 +1,5 @@
|
||||
/* chown -- change user and group ownership of files
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -36,10 +36,14 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "savedir.h"
|
||||
#include "lchown.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chown"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwnam ();
|
||||
@@ -103,12 +107,6 @@ static char *groupname;
|
||||
of this file. This file must exist. */
|
||||
static char *reference_file;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
@@ -119,8 +117,8 @@ static struct option const long_options[] =
|
||||
{"silent", no_argument, 0, 'f'},
|
||||
{"reference", required_argument, 0, CHAR_MAX + 1},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -326,7 +324,6 @@ main (int argc, char **argv)
|
||||
gid_t group = (uid_t) -1; /* New gid; -1 if not to be changed. */
|
||||
int errors = 0;
|
||||
int optc;
|
||||
char *e;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -362,21 +359,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
verbosity = V_high;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chown (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
@@ -395,7 +384,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
|
||||
const char *e = parse_user_spec (argv[optind], &user, &group,
|
||||
&username, &groupname);
|
||||
if (e)
|
||||
error (1, 0, "%s: %s", argv[optind], e);
|
||||
if (username == NULL)
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chroot"
|
||||
|
||||
#define AUTHORS "Roland McGrath"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
@@ -61,8 +66,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "chroot", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
if (argc == 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
32
src/cksum.c
32
src/cksum.c
@@ -1,5 +1,5 @@
|
||||
/* cksum -- calculate and print POSIX.2 checksums and sizes of files
|
||||
Copyright (C) 92, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -12,8 +12,8 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Q. Frank Xia, qx@math.columbia.edu.
|
||||
Cosmetic changes and reorganization by David MacKenzie, djm@gnu.ai.mit.edu.
|
||||
@@ -42,6 +42,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cksum"
|
||||
|
||||
#define AUTHORS "Q. Frank Xia"
|
||||
|
||||
#ifdef CRCTAB
|
||||
|
||||
# include <stdio.h>
|
||||
@@ -108,6 +113,7 @@ main ()
|
||||
# include <getopt.h>
|
||||
# include <sys/types.h>
|
||||
# include "system.h"
|
||||
# include "long-options.h"
|
||||
# include "error.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
@@ -116,16 +122,8 @@ main ()
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -294,6 +292,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
have_read_stdin = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
@@ -308,15 +309,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cksum (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
if (cksum ("-", 0) < 0)
|
||||
|
||||
30
src/comm.c
30
src/comm.c
@@ -1,5 +1,5 @@
|
||||
/* comm -- compare two sorted files line by line.
|
||||
Copyright (C) 86, 90, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +26,11 @@
|
||||
#include "linebuffer.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "comm"
|
||||
|
||||
#define AUTHORS "Richard Stallman and David MacKenzie"
|
||||
|
||||
/* Undefine, to avoid warning about redefinition on some systems. */
|
||||
#undef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
@@ -42,16 +47,10 @@ static int only_file_2;
|
||||
/* If nonzero, print lines that are found in both files. */
|
||||
static int both;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -243,19 +242,14 @@ main (int argc, char **argv)
|
||||
both = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("comm (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind + 2 != argc)
|
||||
usage (1);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* cp-hash.c -- file copying (hash search routines)
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
38
src/cp.c
38
src/cp.c
@@ -1,5 +1,5 @@
|
||||
/* cp.c -- file copying (main routines)
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,14 +28,18 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "argmatch.h"
|
||||
#include "path-concat.h"
|
||||
#include "closeout.h"
|
||||
#include "cp-hash.h"
|
||||
#include "backupfile.h"
|
||||
#include "copy.h"
|
||||
#include "cp-hash.h"
|
||||
#include "error.h"
|
||||
#include "dirname.h"
|
||||
#include "path-concat.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cp"
|
||||
|
||||
#define AUTHORS "Torbjorn Granlund, David MacKenzie, and Jim Meyering"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
uid_t geteuid ();
|
||||
@@ -83,12 +87,6 @@ static enum Sparse_type const sparse_type[] =
|
||||
/* The error code to return to the system. */
|
||||
static int exit_status = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
@@ -108,8 +106,8 @@ static struct option const long_opts[] =
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -741,21 +739,15 @@ main (int argc, char **argv)
|
||||
version = optarg;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cp (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (x.hard_link && x.symbolic_link)
|
||||
{
|
||||
error (0, 0, _("cannot make both hard and symbolic links"));
|
||||
|
||||
32
src/csplit.c
32
src/csplit.c
@@ -1,5 +1,5 @@
|
||||
/* csplit - split a file into sections determined by context lines
|
||||
Copyright (C) 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,9 +31,14 @@
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "safe-read.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "xalloc.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "csplit"
|
||||
|
||||
#define AUTHORS "Stuart Kemp and David MacKenzie"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
@@ -202,12 +207,6 @@ static struct control *controls;
|
||||
/* Number of elements in `controls'. */
|
||||
static unsigned int control_used;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"digits", required_argument, NULL, 'n'},
|
||||
@@ -217,8 +216,8 @@ static struct option const longopts[] =
|
||||
{"elide-empty-files", no_argument, NULL, 'z'},
|
||||
{"prefix", required_argument, NULL, 'f'},
|
||||
{"suffix-format", required_argument, NULL, 'b'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -1454,19 +1453,14 @@ main (int argc, char **argv)
|
||||
elide_empty_files = TRUE;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("csplit (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind < 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
40
src/cut.c
40
src/cut.c
@@ -1,5 +1,5 @@
|
||||
/* cut - remove parts of lines of files
|
||||
Copyright (C) 1984, 1997, 1998 by David M. Ihnat
|
||||
Copyright (C) 1984, 1997, 1998, 1999 by David M. Ihnat
|
||||
|
||||
This program is a total rewrite of the Bell Laboratories Unix(Tm)
|
||||
command of the same name, as of System V. It contains no proprietary
|
||||
@@ -68,12 +68,17 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "cut"
|
||||
|
||||
#define AUTHORS "David Ihnat, David MacKenzie, and Jim Meyering"
|
||||
|
||||
char *xstrdup ();
|
||||
|
||||
#define FATAL_ERROR(s) \
|
||||
#define FATAL_ERROR(Message) \
|
||||
do \
|
||||
{ \
|
||||
error (0, 0, (s)); \
|
||||
error (0, 0, (Message)); \
|
||||
usage (2); \
|
||||
} \
|
||||
while (0)
|
||||
@@ -168,12 +173,6 @@ static char *output_delimiter_string;
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", required_argument, 0, 'b'},
|
||||
@@ -182,8 +181,8 @@ static struct option const longopts[] =
|
||||
{"delimiter", required_argument, 0, 'd'},
|
||||
{"only-delimited", no_argument, 0, 's'},
|
||||
{"output-delimiter", required_argument, 0, CHAR_MAX + 1},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -245,7 +244,7 @@ With no FILE, or when FILE is -, read standard input.\n\
|
||||
including the null terminator), or -1 on error or EOF. */
|
||||
|
||||
static int
|
||||
getstr (char **lineptr, int *n, FILE *stream, char terminator)
|
||||
getstr (char **lineptr, int *n, FILE *stream, int terminator)
|
||||
{
|
||||
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||
char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||
@@ -562,7 +561,7 @@ cut_fields (FILE *stream)
|
||||
/* If the first field extends to the end of line (it is not
|
||||
delimited) and we are printing all non-delimited lines,
|
||||
print this one. */
|
||||
if (field_1_buffer[len - 1] != delim)
|
||||
if ((unsigned char) field_1_buffer[len - 1] != delim)
|
||||
{
|
||||
if (suppress_non_delimited)
|
||||
{
|
||||
@@ -735,7 +734,7 @@ main (int argc, char **argv)
|
||||
/* Interpret -d '' to mean `use the NUL byte as the delimiter.' */
|
||||
if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
delim = optarg[0];
|
||||
delim = (unsigned char) optarg[0];
|
||||
delim_specified = 1;
|
||||
break;
|
||||
|
||||
@@ -754,20 +753,15 @@ main (int argc, char **argv)
|
||||
suppress_non_delimited = 1;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (2);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("cut (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (operating_mode == undefined_mode)
|
||||
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
|
||||
|
||||
|
||||
30
src/date.c
30
src/date.c
@@ -24,11 +24,16 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "getline.h"
|
||||
#include "error.h"
|
||||
#include "getdate.h"
|
||||
#include "getline.h"
|
||||
#include "posixtm.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "date"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
size_t strftime ();
|
||||
time_t time ();
|
||||
@@ -44,12 +49,6 @@ static void show_date PARAMS ((const char *format, time_t when));
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If non-zero, display time in RFC-822 format for mail or news. */
|
||||
static int rfc_format = 0;
|
||||
|
||||
@@ -60,14 +59,14 @@ static struct option const long_options[] =
|
||||
{
|
||||
{"date", required_argument, NULL, 'd'},
|
||||
{"file", required_argument, NULL, 'f'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"reference", required_argument, NULL, 'r'},
|
||||
{"rfc-822", no_argument, NULL, 'R'},
|
||||
{"set", required_argument, NULL, 's'},
|
||||
{"uct", no_argument, NULL, 'u'},
|
||||
{"utc", no_argument, NULL, 'u'},
|
||||
{"universal", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -258,7 +257,7 @@ batch_convert (const char *input_filename, const char *format)
|
||||
free (initial_TZ);
|
||||
|
||||
if (fclose (in_stream) == EOF)
|
||||
error (2, errno, input_filename);
|
||||
error (2, errno, "`%s'", input_filename);
|
||||
|
||||
if (line != NULL)
|
||||
free (line);
|
||||
@@ -312,19 +311,12 @@ main (int argc, char **argv)
|
||||
case 'u':
|
||||
universal_time = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("date (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
n_args = argc - optind;
|
||||
|
||||
option_specified_date = ((datestr ? 1 : 0)
|
||||
|
||||
50
src/dd.c
50
src/dd.c
@@ -1,5 +1,5 @@
|
||||
/* dd -- convert a file while copying it.
|
||||
Copyright (C) 85, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 85, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -29,12 +29,17 @@
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "human.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "long-options.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dd"
|
||||
|
||||
#define AUTHORS "Paul Rubin, David MacKenzie, and Stuart Kemp"
|
||||
|
||||
#ifndef SIGINFO
|
||||
# define SIGINFO SIGUSR1
|
||||
#endif
|
||||
@@ -266,19 +271,6 @@ static unsigned char const ebcdic_to_ascii[] =
|
||||
070, 071, 0372, 0373, 0374, 0375, 0376, 0377
|
||||
};
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -591,19 +583,6 @@ static void
|
||||
scanargs (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int c;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
@@ -1111,6 +1090,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
/* Initialize translation table to identity translation. */
|
||||
for (i = 0; i < 256; i++)
|
||||
trans_table[i] = i;
|
||||
@@ -1118,16 +1100,6 @@ main (int argc, char **argv)
|
||||
/* Decode arguments. */
|
||||
scanargs (argc, argv);
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("dd (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
apply_translations ();
|
||||
|
||||
if (input_file != NULL)
|
||||
|
||||
43
src/df.c
43
src/df.c
@@ -1,5 +1,5 @@
|
||||
/* df - summarize free disk space
|
||||
Copyright (C) 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,14 +28,19 @@
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "mountlist.h"
|
||||
#include "fsusage.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "dirname.h"
|
||||
#include "error.h"
|
||||
#include "fsusage.h"
|
||||
#include "human.h"
|
||||
#include "mountlist.h"
|
||||
#include "save-cwd.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "df"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
char *xstrdup ();
|
||||
@@ -103,12 +108,6 @@ static struct fs_type_list *fs_exclude_list;
|
||||
/* Linked list of mounted filesystems. */
|
||||
static struct mount_entry *mount_list;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If nonzero, print filesystem type as well. */
|
||||
static int print_type;
|
||||
|
||||
@@ -128,8 +127,8 @@ static struct option const long_options[] =
|
||||
{"no-sync", no_argument, NULL, CHAR_MAX + 2},
|
||||
{"type", required_argument, NULL, 't'},
|
||||
{"exclude-type", required_argument, NULL, 'x'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -691,21 +690,15 @@ main (int argc, char **argv)
|
||||
case 'x':
|
||||
add_excluded_fs_type (optarg);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("df (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
/* Fail if the same file system type was both selected and excluded. */
|
||||
{
|
||||
int match = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1994, 1995, 1997, 1998, 1999 H. Peter Anvin
|
||||
Copyright (C) 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,12 +26,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "getline.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "dircolors.h"
|
||||
#include "error.h"
|
||||
#include "getline.h"
|
||||
#include "obstack.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dircolors"
|
||||
|
||||
#define AUTHORS "H. Peter Anvin"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -66,14 +69,14 @@ static const char *const slack_codes[] =
|
||||
{
|
||||
"NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK",
|
||||
"SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
|
||||
"CHR", "CHAR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE", "END",
|
||||
"ENDCODE", NULL
|
||||
"CHR", "CHAR", "DOOR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE",
|
||||
"END", "ENDCODE", NULL
|
||||
};
|
||||
|
||||
static const char *const ls_codes[] =
|
||||
{
|
||||
"no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
|
||||
"so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", "rc", "ec", "ec"
|
||||
"so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec"
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -82,9 +85,9 @@ static struct option const long_options[] =
|
||||
{"sh", no_argument, NULL, 'b'},
|
||||
{"csh", no_argument, NULL, 'c'},
|
||||
{"c-shell", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"print-database", no_argument, NULL, 'p'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -366,7 +369,8 @@ dc_parse_stream (FILE *fp, const char *filename)
|
||||
if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES))
|
||||
{
|
||||
error (0, 0, _("%s:%lu: unrecognized keyword `%s'"),
|
||||
filename, (long unsigned) line_number, keywd);
|
||||
(filename ? filename : _("<internal>")),
|
||||
(long unsigned) line_number, keywd);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
@@ -427,8 +431,6 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dircolors", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
|
||||
switch (optc)
|
||||
{
|
||||
@@ -444,6 +446,10 @@ main (int argc, char **argv)
|
||||
print_database = 1;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dirname -- strip filename suffix from pathname
|
||||
Copyright (C) 90,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dirname"
|
||||
|
||||
#define AUTHORS "David MacKenzie and Jim Meyering"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -66,7 +71,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "dirname", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
|
||||
761
src/du.c
761
src/du.c
@@ -1,5 +1,5 @@
|
||||
/* du -- summarize disk usage
|
||||
Copyright (C) 88, 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -51,14 +51,19 @@
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "exclude.h"
|
||||
#include "system.h"
|
||||
#include "save-cwd.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "exclude.h"
|
||||
#include "human.h"
|
||||
#include "xstrtol.h"
|
||||
#include "save-cwd.h"
|
||||
#include "savedir.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "du"
|
||||
|
||||
#define AUTHORS \
|
||||
"Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert"
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
@@ -104,19 +109,6 @@ typedef struct String String;
|
||||
int stat ();
|
||||
int lstat ();
|
||||
|
||||
static int hash_insert PARAMS ((ino_t ino, dev_t dev));
|
||||
static int hash_insert2 PARAMS ((struct htab *_htab, ino_t ino, dev_t dev));
|
||||
static uintmax_t count_entry PARAMS ((const char *ent, int top, dev_t last_dev,
|
||||
int depth));
|
||||
static void du_files PARAMS ((char **files));
|
||||
static void hash_init PARAMS ((unsigned int modulus,
|
||||
unsigned int entry_tab_size));
|
||||
static void hash_reset PARAMS ((void));
|
||||
static void str_concatc PARAMS ((String *s1, char *cstr));
|
||||
static void str_copyc PARAMS ((String *s1, char *cstr));
|
||||
static void str_init PARAMS ((String **s1, unsigned int size));
|
||||
static void str_trunc PARAMS ((String *s1, unsigned int length));
|
||||
|
||||
/* Name under which this program was invoked. */
|
||||
char *program_name;
|
||||
|
||||
@@ -163,12 +155,6 @@ static int (*xstat) ();
|
||||
/* The exit status to use if we don't get any fatal errors. */
|
||||
static int exit_status;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* File name patterns to exclude. */
|
||||
static struct exclude *exclude;
|
||||
|
||||
@@ -194,18 +180,14 @@ static struct option const long_options[] =
|
||||
{"separate-dirs", no_argument, NULL, 'S'},
|
||||
{"summarize", no_argument, NULL, 's'},
|
||||
{"total", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
void
|
||||
usage (int status, char *reason)
|
||||
usage (int status)
|
||||
{
|
||||
if (reason != NULL)
|
||||
fprintf (status == 0 ? stdout : stderr, "%s: %s\n",
|
||||
program_name, reason);
|
||||
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
@@ -244,156 +226,63 @@ Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
/* Initialize string S1 to hold SIZE characters. */
|
||||
|
||||
static void
|
||||
str_init (String **s1, unsigned int size)
|
||||
{
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
int max_depth_specified = 0;
|
||||
String *s;
|
||||
|
||||
/* If nonzero, display only a total for each argument. */
|
||||
int opt_summarize_only = 0;
|
||||
s = (String *) xmalloc (sizeof (struct String));
|
||||
s->text = xmalloc (size + 1);
|
||||
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
s->alloc = size;
|
||||
*s1 = s;
|
||||
}
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
|
||||
!= -1)
|
||||
static void
|
||||
ensure_space (String *s, unsigned int size)
|
||||
{
|
||||
if (s->alloc < size)
|
||||
{
|
||||
long int tmp_long;
|
||||
switch (c)
|
||||
{
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
opt_all = 1;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
opt_combined_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3: /* --max-depth=N */
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > INT_MAX)
|
||||
error (1, 0, _("invalid maximum depth `%s'"), optarg);
|
||||
|
||||
max_depth_specified = 1;
|
||||
max_depth = (int) tmp_long;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
opt_count_all = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
opt_summarize_only = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
opt_one_file_system = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
opt_dereference_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
xstat = stat;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
opt_separate_dirs = 1;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
if (add_exclude_file (exclude, optarg, '\n') != 0)
|
||||
error (1, errno, "%s", optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
add_exclude (exclude, optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1, (char *) 0);
|
||||
}
|
||||
s->text = xrealloc (s->text, size + 1);
|
||||
s->alloc = size;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
/* Assign the null-terminated C-string CSTR to S1. */
|
||||
|
||||
static void
|
||||
str_copyc (String *s1, const char *cstr)
|
||||
{
|
||||
unsigned l = strlen (cstr);
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
static void
|
||||
str_concatc (String *s1, const char *cstr)
|
||||
{
|
||||
unsigned l1 = s1->length;
|
||||
unsigned l2 = strlen (cstr);
|
||||
unsigned l = l1 + l2;
|
||||
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text + l1, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
/* Truncate the string S1 to have length LENGTH. */
|
||||
|
||||
static void
|
||||
str_trunc (String *s1, unsigned int length)
|
||||
{
|
||||
if (s1->length > length)
|
||||
{
|
||||
printf ("du (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
s1->text[length] = 0;
|
||||
s1->length = length;
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0, NULL);
|
||||
|
||||
if (opt_all && opt_summarize_only)
|
||||
usage (1, _("cannot both summarize and show all entries"));
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth == 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing is the same as using --max-depth=0"));
|
||||
}
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth != 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing conflicts with --max-depth=%d"),
|
||||
max_depth);
|
||||
usage (1, NULL);
|
||||
}
|
||||
|
||||
if (opt_summarize_only)
|
||||
max_depth = 0;
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
|
||||
str_init (&path, INITIAL_PATH_SIZE);
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
/* Print N_BLOCKS followed by STRING on a line. NBLOCKS is the number of
|
||||
@@ -411,66 +300,152 @@ print_size (uintmax_t n_blocks, const char *string)
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL. */
|
||||
/* Reset the hash structure in the global variable `htab' to
|
||||
contain no entries. */
|
||||
|
||||
static void
|
||||
du_files (char **files)
|
||||
hash_reset (void)
|
||||
{
|
||||
struct saved_cwd cwd;
|
||||
ino_t initial_ino; /* Initial directory's inode. */
|
||||
dev_t initial_dev; /* Initial directory's device. */
|
||||
int i; /* Index in FILES. */
|
||||
int i;
|
||||
struct entry **p;
|
||||
|
||||
if (save_cwd (&cwd))
|
||||
exit (1);
|
||||
htab->first_free_entry = 0;
|
||||
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, _("current directory"));
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
p = htab->hash;
|
||||
for (i = htab->modulus; i > 0; i--)
|
||||
*p++ = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; files[i]; i++)
|
||||
/* Allocate space for the hash structures, and set the global
|
||||
variable `htab' to point to it. The initial hash module is specified in
|
||||
MODULUS, and the number of entries are specified in ENTRY_TAB_SIZE. (The
|
||||
hash structure will be rebuilt when ENTRY_TAB_SIZE entries have been
|
||||
inserted, and MODULUS and ENTRY_TAB_SIZE in the global `htab' will be
|
||||
doubled.) */
|
||||
|
||||
static void
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xmalloc (sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xmalloc (sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
hash_reset ();
|
||||
}
|
||||
|
||||
/* Insert INO and DEV in the hash structure HTAB, if not
|
||||
already present. Return zero if inserted and nonzero if it
|
||||
already existed. */
|
||||
|
||||
static int
|
||||
hash_insert2 (struct htab *ht, ino_t ino, dev_t dev)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &ht->hash[ino % ht->modulus];
|
||||
ep2 = *hp;
|
||||
|
||||
/* Collision? */
|
||||
|
||||
if (ep2 != NULL)
|
||||
{
|
||||
char *arg;
|
||||
int s;
|
||||
ep = ep2;
|
||||
|
||||
arg = files[i];
|
||||
/* Search for an entry with the same data. */
|
||||
|
||||
/* Delete final slash in the argument, unless the slash is alone. */
|
||||
s = strlen (arg) - 1;
|
||||
if (s != 0)
|
||||
do
|
||||
{
|
||||
if (arg[s] == '/')
|
||||
arg[s] = 0;
|
||||
|
||||
str_copyc (path, arg);
|
||||
if (ep->ino == ino && ep->dev == dev)
|
||||
return 1; /* Found an entry with the same data. */
|
||||
ep = ep->coll_link;
|
||||
}
|
||||
else if (arg[0] == '/')
|
||||
str_trunc (path, 0); /* Null path for root directory. */
|
||||
else
|
||||
str_copyc (path, arg);
|
||||
while (ep != NULL);
|
||||
|
||||
if (!opt_combined_arguments)
|
||||
hash_reset ();
|
||||
/* Did not find it. */
|
||||
|
||||
count_entry (arg, 1, 0, 0);
|
||||
}
|
||||
|
||||
/* chdir if `count_entry' has changed the working directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
ep = *hp = &ht->entry_tab[ht->first_free_entry++];
|
||||
ep->ino = ino;
|
||||
ep->dev = dev;
|
||||
ep->coll_link = ep2; /* `ep2' is NULL if no collision. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Insert an item (inode INO and device DEV) in the hash
|
||||
structure in the global variable `htab', if an entry with the same data
|
||||
was not found already. Return zero if the item was inserted and nonzero
|
||||
if it wasn't. */
|
||||
|
||||
static int
|
||||
hash_insert (ino_t ino, dev_t dev)
|
||||
{
|
||||
struct htab *htab_r = htab; /* Initially a copy of the global `htab'. */
|
||||
|
||||
if (htab_r->first_free_entry >= htab_r->entry_tab_size)
|
||||
{
|
||||
int i;
|
||||
struct entry *ep;
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
|
||||
/* Increase the number of hash entries, and re-hash the data.
|
||||
The method of shrimping and increasing is made to compactify
|
||||
the heap. If twice as much data would be allocated
|
||||
straightforwardly, we would never re-use a byte of memory. */
|
||||
|
||||
/* Let `htab' shrimp. Keep only the header, not the pointer vector. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r, sizeof (struct htab));
|
||||
|
||||
modulus = 2 * htab_r->modulus;
|
||||
entry_tab_size = 2 * htab_r->entry_tab_size;
|
||||
|
||||
/* Increase the number of possible entries. */
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xrealloc ((char *) htab_r->entry_tab,
|
||||
sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
/* Increase the size of htab again. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r,
|
||||
sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
i = htab_r->first_free_entry;
|
||||
|
||||
/* Make the increased hash table empty. The entries are still
|
||||
available in htab->entry_tab. */
|
||||
|
||||
hash_reset ();
|
||||
|
||||
/* Go through the entries and install them in the pointer vector
|
||||
htab->hash. The items are actually inserted in htab->entry_tab at
|
||||
the position where they already are. The htab->coll_link need
|
||||
however be updated. Could be made a little more efficient. */
|
||||
|
||||
for (ep = htab_r->entry_tab; i > 0; i--)
|
||||
{
|
||||
if (restore_cwd (&cwd, _("starting directory"), NULL))
|
||||
exit (1);
|
||||
hash_insert2 (htab_r, ep->ino, ep->dev);
|
||||
ep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_combined_arguments)
|
||||
print_size (tot_size, _("total"));
|
||||
|
||||
free_cwd (&cwd);
|
||||
return hash_insert2 (htab_r, ino, dev);
|
||||
}
|
||||
|
||||
/* Print (if appropriate) the size (in units determined by `output_block_size')
|
||||
@@ -602,209 +577,213 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Allocate space for the hash structures, and set the global
|
||||
variable `htab' to point to it. The initial hash module is specified in
|
||||
MODULUS, and the number of entries are specified in ENTRY_TAB_SIZE. (The
|
||||
hash structure will be rebuilt when ENTRY_TAB_SIZE entries have been
|
||||
inserted, and MODULUS and ENTRY_TAB_SIZE in the global `htab' will be
|
||||
doubled.) */
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL. */
|
||||
|
||||
static void
|
||||
hash_init (unsigned int modulus, unsigned int entry_tab_size)
|
||||
du_files (char **files)
|
||||
{
|
||||
struct htab *htab_r;
|
||||
struct saved_cwd cwd;
|
||||
ino_t initial_ino; /* Initial directory's inode. */
|
||||
dev_t initial_dev; /* Initial directory's device. */
|
||||
int i; /* Index in FILES. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xmalloc (sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
if (save_cwd (&cwd))
|
||||
exit (1);
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xmalloc (sizeof (struct entry) * entry_tab_size);
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, _("current directory"));
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
hash_reset ();
|
||||
}
|
||||
|
||||
/* Reset the hash structure in the global variable `htab' to
|
||||
contain no entries. */
|
||||
|
||||
static void
|
||||
hash_reset (void)
|
||||
{
|
||||
int i;
|
||||
struct entry **p;
|
||||
|
||||
htab->first_free_entry = 0;
|
||||
|
||||
p = htab->hash;
|
||||
for (i = htab->modulus; i > 0; i--)
|
||||
*p++ = NULL;
|
||||
}
|
||||
|
||||
/* Insert an item (inode INO and device DEV) in the hash
|
||||
structure in the global variable `htab', if an entry with the same data
|
||||
was not found already. Return zero if the item was inserted and nonzero
|
||||
if it wasn't. */
|
||||
|
||||
static int
|
||||
hash_insert (ino_t ino, dev_t dev)
|
||||
{
|
||||
struct htab *htab_r = htab; /* Initially a copy of the global `htab'. */
|
||||
|
||||
if (htab_r->first_free_entry >= htab_r->entry_tab_size)
|
||||
for (i = 0; files[i]; i++)
|
||||
{
|
||||
int i;
|
||||
struct entry *ep;
|
||||
unsigned modulus;
|
||||
unsigned entry_tab_size;
|
||||
char *arg;
|
||||
int s;
|
||||
|
||||
/* Increase the number of hash entries, and re-hash the data.
|
||||
The method of shrimping and increasing is made to compactify
|
||||
the heap. If twice as much data would be allocated
|
||||
straightforwardly, we would never re-use a byte of memory. */
|
||||
arg = files[i];
|
||||
|
||||
/* Let `htab' shrimp. Keep only the header, not the pointer vector. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r, sizeof (struct htab));
|
||||
|
||||
modulus = 2 * htab_r->modulus;
|
||||
entry_tab_size = 2 * htab_r->entry_tab_size;
|
||||
|
||||
/* Increase the number of possible entries. */
|
||||
|
||||
htab_r->entry_tab = (struct entry *)
|
||||
xrealloc ((char *) htab_r->entry_tab,
|
||||
sizeof (struct entry) * entry_tab_size);
|
||||
|
||||
/* Increase the size of htab again. */
|
||||
|
||||
htab_r = (struct htab *)
|
||||
xrealloc ((char *) htab_r,
|
||||
sizeof (struct htab) + sizeof (struct entry *) * modulus);
|
||||
|
||||
htab_r->modulus = modulus;
|
||||
htab_r->entry_tab_size = entry_tab_size;
|
||||
htab = htab_r;
|
||||
|
||||
i = htab_r->first_free_entry;
|
||||
|
||||
/* Make the increased hash table empty. The entries are still
|
||||
available in htab->entry_tab. */
|
||||
|
||||
hash_reset ();
|
||||
|
||||
/* Go through the entries and install them in the pointer vector
|
||||
htab->hash. The items are actually inserted in htab->entry_tab at
|
||||
the position where they already are. The htab->coll_link need
|
||||
however be updated. Could be made a little more efficient. */
|
||||
|
||||
for (ep = htab_r->entry_tab; i > 0; i--)
|
||||
/* Delete final slash in the argument, unless the slash is alone. */
|
||||
s = strlen (arg) - 1;
|
||||
if (s != 0)
|
||||
{
|
||||
hash_insert2 (htab_r, ep->ino, ep->dev);
|
||||
ep++;
|
||||
if (arg[s] == '/')
|
||||
arg[s] = 0;
|
||||
|
||||
str_copyc (path, arg);
|
||||
}
|
||||
else if (arg[0] == '/')
|
||||
str_trunc (path, 0); /* Null path for root directory. */
|
||||
else
|
||||
str_copyc (path, arg);
|
||||
|
||||
if (!opt_combined_arguments)
|
||||
hash_reset ();
|
||||
|
||||
count_entry (arg, 1, 0, 0);
|
||||
|
||||
/* chdir if `count_entry' has changed the working directory. */
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
{
|
||||
if (restore_cwd (&cwd, _("starting directory"), NULL))
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
return hash_insert2 (htab_r, ino, dev);
|
||||
if (opt_combined_arguments)
|
||||
print_size (tot_size, _("total"));
|
||||
|
||||
free_cwd (&cwd);
|
||||
}
|
||||
|
||||
/* Insert INO and DEV in the hash structure HTAB, if not
|
||||
already present. Return zero if inserted and nonzero if it
|
||||
already existed. */
|
||||
|
||||
static int
|
||||
hash_insert2 (struct htab *ht, ino_t ino, dev_t dev)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct entry **hp, *ep2, *ep;
|
||||
hp = &ht->hash[ino % ht->modulus];
|
||||
ep2 = *hp;
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
int max_depth_specified = 0;
|
||||
|
||||
/* Collision? */
|
||||
/* If nonzero, display only a total for each argument. */
|
||||
int opt_summarize_only = 0;
|
||||
|
||||
if (ep2 != NULL)
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
ep = ep2;
|
||||
|
||||
/* Search for an entry with the same data. */
|
||||
|
||||
do
|
||||
long int tmp_long;
|
||||
switch (c)
|
||||
{
|
||||
if (ep->ino == ino && ep->dev == dev)
|
||||
return 1; /* Found an entry with the same data. */
|
||||
ep = ep->coll_link;
|
||||
case 0: /* Long option. */
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
opt_all = 1;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
output_block_size = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
opt_combined_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
output_block_size = -1024;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
output_block_size = -1000;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
output_block_size = 1024;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3: /* --max-depth=N */
|
||||
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|
||||
|| tmp_long < 0 || tmp_long > INT_MAX)
|
||||
error (1, 0, _("invalid maximum depth `%s'"), optarg);
|
||||
|
||||
max_depth_specified = 1;
|
||||
max_depth = (int) tmp_long;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
output_block_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
opt_count_all = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
opt_summarize_only = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
opt_one_file_system = 1;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
opt_dereference_arguments = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
xstat = stat;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
opt_separate_dirs = 1;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
if (add_exclude_file (exclude, optarg, '\n') != 0)
|
||||
error (1, errno, "%s", optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
add_exclude (exclude, optarg);
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
while (ep != NULL);
|
||||
|
||||
/* Did not find it. */
|
||||
|
||||
}
|
||||
|
||||
ep = *hp = &ht->entry_tab[ht->first_free_entry++];
|
||||
ep->ino = ino;
|
||||
ep->dev = dev;
|
||||
ep->coll_link = ep2; /* `ep2' is NULL if no collision. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize string S1 to hold SIZE characters. */
|
||||
|
||||
static void
|
||||
str_init (String **s1, unsigned int size)
|
||||
{
|
||||
String *s;
|
||||
|
||||
s = (String *) xmalloc (sizeof (struct String));
|
||||
s->text = xmalloc (size + 1);
|
||||
|
||||
s->alloc = size;
|
||||
*s1 = s;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_space (String *s, unsigned int size)
|
||||
{
|
||||
if (s->alloc < size)
|
||||
if (opt_all && opt_summarize_only)
|
||||
{
|
||||
s->text = xrealloc (s->text, size + 1);
|
||||
s->alloc = size;
|
||||
error (0, 0, _("cannot both summarize and show all entries"));
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign the null-terminated C-string CSTR to S1. */
|
||||
|
||||
static void
|
||||
str_copyc (String *s1, char *cstr)
|
||||
{
|
||||
unsigned l = strlen (cstr);
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
static void
|
||||
str_concatc (String *s1, char *cstr)
|
||||
{
|
||||
unsigned l1 = s1->length;
|
||||
unsigned l2 = strlen (cstr);
|
||||
unsigned l = l1 + l2;
|
||||
|
||||
ensure_space (s1, l);
|
||||
strcpy (s1->text + l1, cstr);
|
||||
s1->length = l;
|
||||
}
|
||||
|
||||
/* Truncate the string S1 to have length LENGTH. */
|
||||
|
||||
static void
|
||||
str_trunc (String *s1, unsigned int length)
|
||||
{
|
||||
if (s1->length > length)
|
||||
if (opt_summarize_only && max_depth_specified && max_depth == 0)
|
||||
{
|
||||
s1->text[length] = 0;
|
||||
s1->length = length;
|
||||
error (0, 0,
|
||||
_("warning: summarizing is the same as using --max-depth=0"));
|
||||
}
|
||||
|
||||
if (opt_summarize_only && max_depth_specified && max_depth != 0)
|
||||
{
|
||||
error (0, 0,
|
||||
_("warning: summarizing conflicts with --max-depth=%d"),
|
||||
max_depth);
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (opt_summarize_only)
|
||||
max_depth = 0;
|
||||
|
||||
/* Initialize the hash structure for inode numbers. */
|
||||
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
|
||||
|
||||
str_init (&path, INITIAL_PATH_SIZE);
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
10
src/echo.c
10
src/echo.c
@@ -1,5 +1,5 @@
|
||||
/* echo.c, derived from code echo.c in Bash.
|
||||
Copyright (C) 87,89,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 87,89, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +21,11 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "echo"
|
||||
|
||||
#define AUTHORS "FIXME unknown"
|
||||
|
||||
/* echo [-neE] [arg ...]
|
||||
Output the ARGs. If -n is specified, the trailing newline is
|
||||
suppressed. If the -e option is given, interpretation of the
|
||||
@@ -114,7 +119,8 @@ main (int argc, char **argv)
|
||||
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, "echo", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
else
|
||||
allow_options = 0;
|
||||
|
||||
|
||||
26
src/env.c
26
src/env.c
@@ -86,6 +86,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "env"
|
||||
|
||||
#define AUTHORS "Richard Mlynarik and David MacKenzie"
|
||||
|
||||
int putenv ();
|
||||
|
||||
extern char **environ;
|
||||
@@ -93,18 +98,12 @@ extern char **environ;
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"ignore-environment", no_argument, NULL, 'i'},
|
||||
{"unset", required_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -157,20 +156,13 @@ main (register int argc, register char **argv, char **envp)
|
||||
break;
|
||||
case 'u':
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (2);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("env (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "-"))
|
||||
ignore_environment = 1;
|
||||
|
||||
|
||||
28
src/expand.c
28
src/expand.c
@@ -1,5 +1,5 @@
|
||||
/* expand - convert tabs to spaces
|
||||
Copyright (C) 89, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -41,6 +41,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expand"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The number of bytes added at a time to the amount of memory
|
||||
allocated for the output line. */
|
||||
#define OUTPUT_BLOCK 256
|
||||
@@ -83,18 +88,12 @@ static int have_read_stdin;
|
||||
/* Status to return to the system. */
|
||||
static int exit_status;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"tabs", required_argument, NULL, 't'},
|
||||
{"initial", no_argument, NULL, 'i'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -359,6 +358,8 @@ main (int argc, char **argv)
|
||||
add_tabstop (tabval);
|
||||
tabval = -1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
if (tabval == -1)
|
||||
tabval = 0;
|
||||
@@ -367,15 +368,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("expand (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
add_tabstop (tabval);
|
||||
|
||||
validate_tabstops (tab_list, first_free_tab);
|
||||
|
||||
10
src/expr.c
10
src/expr.c
@@ -1,5 +1,5 @@
|
||||
/* expr -- evaluate expressions.
|
||||
Copyright (C) 86,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -37,6 +37,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expr"
|
||||
|
||||
#define AUTHORS "Mike Parker"
|
||||
|
||||
#define NEW(type) ((type *) xmalloc (sizeof (type)))
|
||||
#define OLD(x) free ((char *) x)
|
||||
|
||||
@@ -167,7 +172,8 @@ main (int argc, char **argv)
|
||||
|
||||
/* Recognize --help or --version only if POSIXLY_CORRECT is not set. */
|
||||
if (!posixly_correct)
|
||||
parse_long_options (argc, argv, "expr", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
|
||||
10
src/factor.c
10
src/factor.c
@@ -1,5 +1,5 @@
|
||||
/* factor -- print factors of n. lose if n > 2^32.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,6 +31,11 @@
|
||||
#include "xstrtoul.h"
|
||||
#include "readtokens.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "factor"
|
||||
|
||||
#define AUTHORS "Paul Rubin"
|
||||
|
||||
/* Token delimiters when reading from a file. */
|
||||
#define DELIM "\n\t "
|
||||
|
||||
@@ -174,7 +179,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "factor", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
fail = 0;
|
||||
if (argc == 1)
|
||||
|
||||
34
src/fmt.c
34
src/fmt.c
@@ -1,5 +1,5 @@
|
||||
/* GNU fmt -- simple text formatter.
|
||||
Copyright (C) 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +30,11 @@
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fmt"
|
||||
|
||||
#define AUTHORS "Ross Paterson"
|
||||
|
||||
/* The following parameters represent the program's idea of what is
|
||||
"best". Adjust to taste, subject to the caveats given. */
|
||||
|
||||
@@ -164,12 +169,6 @@ static void put_space PARAMS ((int space));
|
||||
/* The name this program was run with. */
|
||||
const char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help = 0;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version = 0;
|
||||
|
||||
/* Option values. */
|
||||
|
||||
/* If TRUE, first 2 lines may have different indent (default FALSE). */
|
||||
@@ -297,13 +296,13 @@ In -wNUMBER, the letter `w' may be omitted.\n"),
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{"crown-margin", no_argument, NULL, 'c'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"prefix", required_argument, NULL, 'p'},
|
||||
{"split-only", no_argument, NULL, 's'},
|
||||
{"tagged-paragraph", no_argument, NULL, 't'},
|
||||
{"uniform-spacing", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -380,17 +379,12 @@ main (register int argc, register char **argv)
|
||||
set_prefix (optarg);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fmt (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
best_width = max_width * (2 * (100 - LEEWAY) + 1) / 200;
|
||||
|
||||
if (optind == argc)
|
||||
@@ -410,10 +404,10 @@ main (register int argc, register char **argv)
|
||||
{
|
||||
fmt (in_stream);
|
||||
if (fclose (in_stream) == EOF)
|
||||
error (EXIT_FAILURE, errno, file);
|
||||
error (EXIT_FAILURE, errno, "%s", file);
|
||||
}
|
||||
else
|
||||
error (0, errno, file);
|
||||
error (0, errno, "%s", file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
src/fold.c
32
src/fold.c
@@ -1,5 +1,5 @@
|
||||
/* fold -- wrap each input line to fit in specified width.
|
||||
Copyright (C) 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,8 +24,13 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "fold"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -39,19 +44,13 @@ static int count_bytes;
|
||||
/* If nonzero, at least one of the files we read was standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", no_argument, NULL, 'b'},
|
||||
{"spaces", no_argument, NULL, 's'},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -286,20 +285,15 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("fold (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc == optind)
|
||||
errs |= fold_file ("-", width);
|
||||
else
|
||||
|
||||
30
src/head.c
30
src/head.c
@@ -1,5 +1,5 @@
|
||||
/* head -- output first part of file(s)
|
||||
Copyright (C) 89, 90, 91, 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "xstrtoul.h"
|
||||
#include "safe-read.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "head"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* FIXME: someday, make this really *be* `long long'. */
|
||||
typedef long int U_LONG_LONG;
|
||||
|
||||
@@ -58,12 +63,6 @@ char *program_name;
|
||||
/* Have we ever read standard input? */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"bytes", required_argument, NULL, 'c'},
|
||||
@@ -71,8 +70,8 @@ static struct option const long_options[] =
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"silent", no_argument, NULL, 'q'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -367,20 +366,15 @@ main (int argc, char **argv)
|
||||
header_mode = always;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("head (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (header_mode == always
|
||||
|| (header_mode == multiple_files && optind < argc - 1))
|
||||
print_headers = 1;
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostid"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
/* The name this program was run with, for error messages. */
|
||||
char *program_name;
|
||||
|
||||
@@ -63,7 +68,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "hostid", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hostname - set or print the name of current host system
|
||||
Copyright (C) 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostname"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
#if !defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) && \
|
||||
defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)
|
||||
# include <sys/systeminfo.h>
|
||||
@@ -82,7 +87,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "hostname", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
#ifdef HAVE_SETHOSTNAME
|
||||
if (argc == 2)
|
||||
|
||||
53
src/id.c
53
src/id.c
@@ -29,6 +29,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "id"
|
||||
|
||||
#define AUTHORS "Arnold Robbins and David MacKenzie"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwuid ();
|
||||
struct group *getgrgid ();
|
||||
@@ -40,8 +45,8 @@ gid_t getegid ();
|
||||
|
||||
int getugroups ();
|
||||
|
||||
static void print_user PARAMS ((int uid));
|
||||
static void print_group PARAMS ((int gid));
|
||||
static void print_user PARAMS ((uid_t uid));
|
||||
static void print_group PARAMS ((gid_t gid));
|
||||
static void print_group_list PARAMS ((const char *username));
|
||||
static void print_full_info PARAMS ((const char *username));
|
||||
|
||||
@@ -70,21 +75,15 @@ static gid_t rgid, egid;
|
||||
/* The number of errors encountered so far. */
|
||||
static int problems = 0;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"group", no_argument, NULL, 'g'},
|
||||
{"groups", no_argument, NULL, 'G'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"name", no_argument, NULL, 'n'},
|
||||
{"real", no_argument, NULL, 'r'},
|
||||
{"user", no_argument, NULL, 'u'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -150,20 +149,13 @@ main (int argc, char **argv)
|
||||
case 'G':
|
||||
just_group_list = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("id (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (just_user + just_group + just_group_list > 1)
|
||||
error (1, 0, _("cannot print only user and only group"));
|
||||
|
||||
@@ -205,7 +197,7 @@ main (int argc, char **argv)
|
||||
/* Print the name or value of user ID UID. */
|
||||
|
||||
static void
|
||||
print_user (int uid)
|
||||
print_user (uid_t uid)
|
||||
{
|
||||
struct passwd *pwd = NULL;
|
||||
|
||||
@@ -225,7 +217,7 @@ print_user (int uid)
|
||||
/* Print the name or value of group ID GID. */
|
||||
|
||||
static void
|
||||
print_group (int gid)
|
||||
print_group (gid_t gid)
|
||||
{
|
||||
struct group *grp = NULL;
|
||||
|
||||
@@ -244,8 +236,11 @@ print_group (int gid)
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
|
||||
/* FIXME: document */
|
||||
|
||||
static int
|
||||
xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
xgetgroups (const char *username, gid_t gid, int *n_groups,
|
||||
GETGROUPS_T **groups)
|
||||
{
|
||||
int max_n_groups;
|
||||
int ng;
|
||||
@@ -255,14 +250,14 @@ xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
if (username == 0)
|
||||
max_n_groups = getgroups (0, NULL);
|
||||
else
|
||||
max_n_groups = getugroups (0, NULL, username);
|
||||
max_n_groups = getugroups (0, NULL, username, gid);
|
||||
|
||||
/* Add 1 just in case max_n_groups is zero. */
|
||||
g = (GETGROUPS_T *) xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1);
|
||||
if (username == 0)
|
||||
ng = getgroups (max_n_groups, g);
|
||||
else
|
||||
ng = getugroups (max_n_groups, g, username);
|
||||
ng = getugroups (max_n_groups, g, username, gid);
|
||||
|
||||
if (ng < 0)
|
||||
{
|
||||
@@ -285,6 +280,12 @@ xgetgroups (const char *username, int *n_groups, GETGROUPS_T **groups)
|
||||
static void
|
||||
print_group_list (const char *username)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
||||
pwd = getpwuid (ruid);
|
||||
if (pwd == NULL)
|
||||
problems++;
|
||||
|
||||
print_group (rgid);
|
||||
if (egid != rgid)
|
||||
{
|
||||
@@ -298,7 +299,7 @@ print_group_list (const char *username)
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
if (xgetgroups (username, pwd ? pwd->pw_gid : -1, &n_groups, &groups))
|
||||
{
|
||||
++problems;
|
||||
return;
|
||||
@@ -363,7 +364,7 @@ print_full_info (const char *username)
|
||||
GETGROUPS_T *groups;
|
||||
register int i;
|
||||
|
||||
if (xgetgroups (username, &n_groups, &groups))
|
||||
if (xgetgroups (username, pwd ? pwd->pw_gid : -1, &n_groups, &groups))
|
||||
{
|
||||
++problems;
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* install - copy files and set attributes
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -73,15 +73,19 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
#include "path-concat.h"
|
||||
#include "cp-hash.h"
|
||||
#include "copy.h"
|
||||
#include "dirname.h"
|
||||
#include "makepath.h"
|
||||
#include "modechange.h"
|
||||
#include "path-concat.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "install"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
@@ -141,9 +145,6 @@ 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;
|
||||
@@ -168,12 +169,6 @@ static int strip_files;
|
||||
/* If nonzero, install a directory instead of a regular file. */
|
||||
static int dir_arg;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"strip", no_argument, NULL, 's'},
|
||||
@@ -186,8 +181,8 @@ static struct option const long_options[] =
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -213,6 +208,7 @@ cp_option_init (struct cp_options *x)
|
||||
x->recursive = 0;
|
||||
x->sparse_mode = SPARSE_AUTO;
|
||||
x->symbolic_link = 0;
|
||||
x->backup_type = none;
|
||||
|
||||
/* Create destination files initially writable so we can run strip on them.
|
||||
Although GNU strip works fine on read-only files, some others
|
||||
@@ -231,9 +227,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
int errors = 0;
|
||||
char *symbolic_mode = NULL;
|
||||
const char *symbolic_mode = NULL;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
const char *version;
|
||||
int mkdir_and_install = 0;
|
||||
struct cp_options x;
|
||||
int n_files;
|
||||
@@ -301,27 +297,20 @@ main (int argc, char **argv)
|
||||
case 'V':
|
||||
version = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("install (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
/* Check for invalid combinations of arguments. */
|
||||
if (dir_arg && strip_files)
|
||||
error (1, 0,
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
|
||||
x.backup_type = xget_version ("--version-control", version);
|
||||
if (make_backups)
|
||||
x.backup_type = xget_version ("--version-control", version);
|
||||
|
||||
n_files = argc - optind;
|
||||
file = argv + optind;
|
||||
@@ -457,7 +446,7 @@ static int
|
||||
install_file_in_dir (const char *from, const char *to_dir,
|
||||
const struct cp_options *x)
|
||||
{
|
||||
char *from_base;
|
||||
const char *from_base;
|
||||
char *to;
|
||||
int ret;
|
||||
|
||||
@@ -567,13 +556,13 @@ change_timestamps (const char *from, const char *to)
|
||||
static void
|
||||
strip (const char *path)
|
||||
{
|
||||
int pid, status;
|
||||
int status;
|
||||
pid_t pid = fork ();
|
||||
|
||||
pid = fork ();
|
||||
switch (pid)
|
||||
{
|
||||
case -1:
|
||||
error (1, errno, _("fork system call failed"));
|
||||
error (1, errno, _("cannot fork"));
|
||||
break;
|
||||
case 0: /* Child. */
|
||||
execlp ("strip", "strip", path, NULL);
|
||||
@@ -583,6 +572,8 @@ strip (const char *path)
|
||||
/* Parent process. */
|
||||
while (pid != wait (&status)) /* Wait for kid to finish. */
|
||||
/* Do nothing. */ ;
|
||||
if (status)
|
||||
error (1, 0, _("strip failed"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
20
src/join.c
20
src/join.c
@@ -1,5 +1,5 @@
|
||||
/* join - join lines of two files on a common field
|
||||
Copyright (C) 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,10 +31,14 @@
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "xstrtol.h"
|
||||
#include "error.h"
|
||||
#include "memcasecmp.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "join"
|
||||
|
||||
#define AUTHORS "Mike Haertel"
|
||||
|
||||
#define join system_join
|
||||
|
||||
@@ -118,6 +122,8 @@ static struct option const longopts[] =
|
||||
{"j", required_argument, NULL, 'j'},
|
||||
{"j1", required_argument, NULL, '1'},
|
||||
{"j2", required_argument, NULL, '2'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -737,8 +743,6 @@ main (int argc, char **argv)
|
||||
it may be increased. */
|
||||
uni_blank.nfields = 1;
|
||||
|
||||
parse_long_options (argc, argv, "join", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
nfiles = 0;
|
||||
print_pairables = 1;
|
||||
|
||||
@@ -826,7 +830,11 @@ main (int argc, char **argv)
|
||||
names[nfiles++] = optarg;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
prev_optc = optc;
|
||||
|
||||
36
src/ln.c
36
src/ln.c
@@ -28,9 +28,13 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "dirname.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "ln"
|
||||
|
||||
#define AUTHORS "Mike Parker and David MacKenzie"
|
||||
|
||||
int link (); /* Some systems don't declare this anywhere. */
|
||||
|
||||
@@ -44,7 +48,7 @@ int symlink ();
|
||||
#define PATH_BASENAME_CONCAT(new_dest, dest, source) \
|
||||
do \
|
||||
{ \
|
||||
char *source_base; \
|
||||
const char *source_base; \
|
||||
char *tmp_source; \
|
||||
\
|
||||
tmp_source = (char *) alloca (strlen ((source)) + 1); \
|
||||
@@ -97,12 +101,6 @@ static int hard_dir_link;
|
||||
symlink-to-dir before creating the new link. */
|
||||
static int dereference_dest_dir_symlinks = 1;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
@@ -114,8 +112,8 @@ static struct option const long_options[] =
|
||||
{"symbolic", no_argument, NULL, 's'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -379,7 +377,7 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
int errors;
|
||||
int make_backups = 0;
|
||||
char *version;
|
||||
const char *version;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -438,22 +436,14 @@ main (int argc, char **argv)
|
||||
case 'V':
|
||||
version = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("ln (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("missing file argument"));
|
||||
@@ -484,7 +474,7 @@ main (int argc, char **argv)
|
||||
else if (optind == argc - 2)
|
||||
{
|
||||
struct stat source_stats;
|
||||
char *source;
|
||||
const char *source;
|
||||
char *dest;
|
||||
char *new_dest;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* logname -- print user's login name
|
||||
Copyright (C) 90,91,92,93,94,95,96,1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,20 +21,18 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "logname"
|
||||
|
||||
#define AUTHORS "FIXME: unknown"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -69,6 +67,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -81,15 +82,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("logname (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind != 0)
|
||||
usage (1);
|
||||
|
||||
|
||||
87
src/ls.c
87
src/ls.c
@@ -55,6 +55,15 @@
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef WINSIZE_IN_PTEM
|
||||
# include <sys/stream.h>
|
||||
# include <sys/ptem.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_ACL_H
|
||||
# include <sys/acl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
@@ -63,17 +72,22 @@
|
||||
#include "system.h"
|
||||
#include <fnmatch.h>
|
||||
|
||||
#include "obstack.h"
|
||||
#include "ls.h"
|
||||
#include "closeout.h"
|
||||
#include "argmatch.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "argmatch.h"
|
||||
#include "xstrtol.h"
|
||||
#include "strverscmp.h"
|
||||
#include "quotearg.h"
|
||||
#include "filemode.h"
|
||||
#include "ls.h"
|
||||
#include "obstack.h"
|
||||
#include "path-concat.h"
|
||||
#include "quotearg.h"
|
||||
#include "strverscmp.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
#define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \
|
||||
: (ls_mode == LS_MULTI_COL \
|
||||
? "dir" : "vdir"))
|
||||
|
||||
#define AUTHORS "Richard Stallman and David MacKenzie"
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -148,8 +162,20 @@ struct fileinfo
|
||||
int linkok;
|
||||
|
||||
enum filetype filetype;
|
||||
|
||||
#if HAVE_ACL
|
||||
/* For long listings, nonzero if the file has an access control list,
|
||||
otherwise zero. */
|
||||
int have_acl;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if HAVE_ACL
|
||||
# define FILE_HAS_ACL(F) ((F)->have_acl)
|
||||
#else
|
||||
# define FILE_HAS_ACL(F) 0
|
||||
#endif
|
||||
|
||||
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
|
||||
|
||||
/* Null is a valid character in a color indicator (think about Epson
|
||||
@@ -528,12 +554,6 @@ static int format_needs_stat;
|
||||
|
||||
static int exit_status;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, 0, 'a'},
|
||||
@@ -567,10 +587,10 @@ static struct option const long_options[] =
|
||||
{"sort", required_argument, 0, 10},
|
||||
{"tabsize", required_argument, 0, 'T'},
|
||||
{"time", required_argument, 0, 11},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"color", optional_argument, 0, 13},
|
||||
{"block-size", required_argument, 0, 17},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -728,19 +748,6 @@ main (int argc, char **argv)
|
||||
|
||||
i = decode_switches (argc, argv);
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("%s (%s) %s\n",
|
||||
(ls_mode == LS_LS ? "ls"
|
||||
: (ls_mode == LS_MULTI_COL ? "dir" : "vdir")),
|
||||
GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
if (print_with_color)
|
||||
{
|
||||
parse_ls_color ();
|
||||
@@ -1183,6 +1190,10 @@ decode_switches (int argc, char **argv)
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
@@ -1720,13 +1731,18 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
|
||||
{
|
||||
val = stat (path, &files[files_index].stat);
|
||||
if (val < 0)
|
||||
/* Perhaps a symbolically-linked to file doesn't exist; stat
|
||||
the link instead. */
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
{
|
||||
/* Perhaps a symbolically-linked to file doesn't exist; stat
|
||||
the link instead. */
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
#if HAVE_ACL
|
||||
files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (val < 0)
|
||||
@@ -2156,7 +2172,7 @@ print_current_files (void)
|
||||
static void
|
||||
print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
char modebuf[11];
|
||||
char modebuf[12];
|
||||
|
||||
/* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
|
||||
1 10-byte mode string,
|
||||
@@ -2183,7 +2199,8 @@ print_long_format (const struct fileinfo *f)
|
||||
mode_string (f->stat.st_mode, modebuf);
|
||||
#endif
|
||||
|
||||
modebuf[10] = '\0';
|
||||
modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
|
||||
modebuf[11] = '\0';
|
||||
|
||||
switch (time_type)
|
||||
{
|
||||
@@ -2240,8 +2257,8 @@ print_long_format (const struct fileinfo *f)
|
||||
p += strlen (p);
|
||||
}
|
||||
|
||||
/* The space between the mode and the number of links is the POSIX
|
||||
"optional alternate access method flag". */
|
||||
/* The last byte of the mode string is the POSIX
|
||||
"optional alternate access method flag". */
|
||||
sprintf (p, "%s %3u ", modebuf, (unsigned int) f->stat.st_nlink);
|
||||
p += strlen (p);
|
||||
|
||||
|
||||
14
src/md5sum.c
14
src/md5sum.c
@@ -1,6 +1,6 @@
|
||||
/* Compute MD5 checksum of files or strings according to the definition
|
||||
of MD5 in RFC 1321 from April 1992.
|
||||
Copyright (C) 1995-1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,12 +26,16 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "long-options.h"
|
||||
#include "md5.h"
|
||||
#include "getline.h"
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "md5sum"
|
||||
|
||||
#define AUTHORS "Ulrich Drepper"
|
||||
|
||||
/* Most systems do not distinguish between external and internal
|
||||
text representations. */
|
||||
/* FIXME: This begs for an autoconf test. */
|
||||
@@ -90,6 +94,8 @@ static const struct option long_options[] =
|
||||
{ "string", required_argument, 0, 1 },
|
||||
{ "text", no_argument, 0, 't' },
|
||||
{ "warn", no_argument, 0, 'w' },
|
||||
{ GETOPT_HELP_OPTION_DECL },
|
||||
{ GETOPT_VERSION_OPTION_DECL },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -472,8 +478,6 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "md5sum", GNU_PACKAGE, VERSION, usage);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
@@ -508,6 +512,8 @@ main (int argc, char **argv)
|
||||
status_only = 0;
|
||||
warn = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
36
src/mkdir.c
36
src/mkdir.c
@@ -1,5 +1,5 @@
|
||||
/* mkdir -- make directories
|
||||
Copyright (C) 90, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -23,10 +23,14 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "makepath.h"
|
||||
#include "modechange.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "mkdir"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -34,19 +38,13 @@ char *program_name;
|
||||
/* If nonzero, ensure that all parents of the specified directory exist. */
|
||||
static int path_mode;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"verbose", no_argument, NULL, 2},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -79,7 +77,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
unsigned int newmode;
|
||||
unsigned int parent_mode;
|
||||
char *symbolic_mode = NULL;
|
||||
const char *symbolic_mode = NULL;
|
||||
const char *verbose_fmt_string = NULL;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
@@ -106,21 +104,13 @@ main (int argc, char **argv)
|
||||
case 2: /* --verbose */
|
||||
verbose_fmt_string = _("created directory `%s'");
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mkdir (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
34
src/mkfifo.c
34
src/mkfifo.c
@@ -1,5 +1,5 @@
|
||||
/* mkfifo -- make fifo's (named pipes)
|
||||
Copyright (C) 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,24 +28,22 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "modechange.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "mkfifo"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -78,7 +76,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
unsigned short newmode;
|
||||
struct mode_change *change;
|
||||
char *symbolic_mode;
|
||||
const char *symbolic_mode;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
@@ -101,21 +99,13 @@ main (int argc, char **argv)
|
||||
case 'm':
|
||||
symbolic_mode = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mkfifo (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
34
src/mknod.c
34
src/mknod.c
@@ -1,5 +1,5 @@
|
||||
/* mknod -- make special files
|
||||
Copyright (C) 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -33,25 +33,23 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "modechange.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "modechange.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "mknod"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -88,7 +86,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
unsigned short newmode;
|
||||
struct mode_change *change;
|
||||
char *symbolic_mode;
|
||||
const char *symbolic_mode;
|
||||
int optc;
|
||||
int i_major, i_minor;
|
||||
long int tmp_major, tmp_minor;
|
||||
@@ -110,21 +108,13 @@ main (int argc, char **argv)
|
||||
case 'm':
|
||||
symbolic_mode = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mknod (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
newmode = 0666 & ~umask (0);
|
||||
if (symbolic_mode)
|
||||
{
|
||||
|
||||
40
src/mv.c
40
src/mv.c
@@ -1,5 +1,5 @@
|
||||
/* mv -- move or rename files
|
||||
Copyright (C) 86, 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -35,7 +35,7 @@
|
||||
-V, --version-control
|
||||
Backup file creation.
|
||||
|
||||
Written by Mike Parker and David MacKenzie */
|
||||
Written by Mike Parker, David MacKenzie, and Jim Meyering */
|
||||
|
||||
#ifdef _AIX
|
||||
#pragma alloca
|
||||
@@ -48,13 +48,17 @@
|
||||
#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 "cp-hash.h"
|
||||
#include "error.h"
|
||||
#include "path-concat.h"
|
||||
#include "remove.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "mv"
|
||||
|
||||
#define AUTHORS "Mike Parker, David MacKenzie, and Jim Meyering"
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
#define INITIAL_HASH_MODULE 100
|
||||
@@ -74,12 +78,6 @@ char *program_name;
|
||||
/* If nonzero, stdin is a tty. */
|
||||
static int stdin_tty;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
@@ -89,8 +87,8 @@ static struct option const long_options[] =
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version-control", required_argument, NULL, 'V'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -367,7 +365,7 @@ main (int argc, char **argv)
|
||||
int errors;
|
||||
int make_backups = 0;
|
||||
int dest_is_dir;
|
||||
char *version;
|
||||
const char *version;
|
||||
struct cp_options x;
|
||||
|
||||
program_name = argv[0];
|
||||
@@ -415,21 +413,13 @@ main (int argc, char **argv)
|
||||
case 'V':
|
||||
version = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("mv (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc < optind + 2)
|
||||
{
|
||||
error (0, 0, "%s", (argc == optind
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "nice"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifdef NICE_PRIORITY
|
||||
# define GET_PRIORITY() nice (0)
|
||||
#else
|
||||
@@ -88,7 +93,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "nice", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
for (i = 1; i < argc; /* empty */)
|
||||
{
|
||||
|
||||
30
src/nl.c
30
src/nl.c
@@ -1,5 +1,5 @@
|
||||
/* nl -- number lines of files
|
||||
Copyright (C) 89, 92, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 92, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,14 +24,19 @@
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "linebuffer.h"
|
||||
#include "system.h"
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "linebuffer.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "nl"
|
||||
|
||||
#define AUTHORS "Scott Bartram and David MacKenzie"
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
@@ -139,12 +144,6 @@ static int line_no;
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"header-numbering", required_argument, NULL, 'h'},
|
||||
@@ -158,8 +157,8 @@ static struct option const longopts[] =
|
||||
{"number-width", required_argument, NULL, 'w'},
|
||||
{"number-format", required_argument, NULL, 'n'},
|
||||
{"section-delimiter", required_argument, NULL, 'd'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -553,21 +552,14 @@ main (int argc, char **argv)
|
||||
case 'd':
|
||||
section_del = optarg;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("nl (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
/* Initialize the section delimiters. */
|
||||
c = strlen (section_del);
|
||||
|
||||
|
||||
27
src/nohup.sh
27
src/nohup.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# nohup -- run a command immume to hangups, with output to a non-tty
|
||||
# Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
# Written by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
|
||||
# Make sure we get GNU nice, if possible; also allow
|
||||
# it to be somewhere else in PATH if not installed yet.
|
||||
PATH=@bindir@:$PATH
|
||||
|
||||
usage="Usage: $0 COMMAND [ARG]...
|
||||
or: $0 OPTION"
|
||||
|
||||
@@ -54,6 +50,21 @@ case $# in
|
||||
* ) ;;
|
||||
esac
|
||||
|
||||
# Make sure we get GNU nice, if possible; also allow
|
||||
# it to be somewhere else in PATH if not installed yet.
|
||||
# But do not modify PATH itself.
|
||||
IFS="${IFS= }"; save_ifs="$IFS"; IFS=":"
|
||||
nicepath="@bindir@:$PATH"
|
||||
niceprog="nice"
|
||||
for nicedir in $nicepath; do
|
||||
test -z "$nicedir" && nicedir="."
|
||||
if test -x "$nicedir/nice"; then
|
||||
niceprog="$nicedir/nice"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
|
||||
trap "" 1
|
||||
oldmask=`umask`; umask 077
|
||||
# Only redirect the output if the user didn't already do it.
|
||||
@@ -62,14 +73,14 @@ if [ -t 1 ]; then
|
||||
if cat /dev/null >> nohup.out; then
|
||||
echo "nohup: appending output to \`nohup.out'" 2>&1
|
||||
umask $oldmask
|
||||
exec nice -5 -- "$@" >> nohup.out 2>&1
|
||||
exec "$niceprog" -5 -- "$@" >> nohup.out 2>&1
|
||||
else
|
||||
cat /dev/null >> $HOME/nohup.out
|
||||
echo "nohup: appending output to \`$HOME/nohup.out'" 2>&1
|
||||
umask $oldmask
|
||||
exec nice -5 -- "$@" >> $HOME/nohup.out 2>&1
|
||||
exec "$niceprog" -5 -- "$@" >> $HOME/nohup.out 2>&1
|
||||
fi
|
||||
else
|
||||
umask $oldmask
|
||||
exec nice -5 -- "$@"
|
||||
exec "$niceprog" -5 -- "$@"
|
||||
fi
|
||||
|
||||
33
src/od.c
33
src/od.c
@@ -1,5 +1,5 @@
|
||||
/* od -- dump files in octal and other formats
|
||||
Copyright (C) 92, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,8 +24,13 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "xstrtoul.h"
|
||||
#include "error.h"
|
||||
#include "xstrtoul.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "od"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
#if defined(__GNUC__) || defined(STDC_HEADERS)
|
||||
# include <float.h>
|
||||
@@ -239,12 +244,6 @@ static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];
|
||||
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
|
||||
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
/* POSIX options. */
|
||||
@@ -258,8 +257,9 @@ static struct option const long_options[] =
|
||||
{"strings", optional_argument, NULL, 's'},
|
||||
{"traditional", no_argument, NULL, 'B'},
|
||||
{"width", optional_argument, NULL, 'w'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -1760,6 +1760,10 @@ the maximum\nrepresentable value of type `long'"), optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
break;
|
||||
@@ -1769,15 +1773,6 @@ the maximum\nrepresentable value of type `long'"), optarg);
|
||||
if (n_failed_decodes > 0)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("od (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (flag_dump_strings && n_specs > 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("no type may be specified when dumping strings"));
|
||||
|
||||
30
src/paste.c
30
src/paste.c
@@ -1,5 +1,5 @@
|
||||
/* paste - merge lines of files
|
||||
Copyright (C) 1984, 1997, 1998 by David M. Ihnat
|
||||
Copyright (C) 1984, 1997, 1998, 1999 by David M. Ihnat
|
||||
|
||||
This program is a total rewrite of the Bell Laboratories Unix(Tm)
|
||||
command of the same name, as of System V. It contains no proprietary
|
||||
@@ -46,6 +46,11 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "paste"
|
||||
|
||||
#define AUTHORS "David M. Ihnat"
|
||||
|
||||
/* Indicates that no delimiter should be added in the current position. */
|
||||
#define EMPTY_DELIM '\0'
|
||||
|
||||
@@ -73,18 +78,12 @@ static char *delims;
|
||||
/* A pointer to the character after the end of `delims'. */
|
||||
static char *delim_end;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output then exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"serial", no_argument, 0, 's'},
|
||||
{"delimiters", required_argument, 0, 'd'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -462,20 +461,15 @@ main (int argc, char **argv)
|
||||
serial_merge++;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("paste (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
argv[argc++] = "-";
|
||||
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pathchk"
|
||||
|
||||
#define AUTHORS "David MacKenzie and Jim Meyering"
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
# ifndef PATH_MAX
|
||||
@@ -96,17 +102,8 @@ static int validate_path PARAMS ((char *path, int portability));
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"portability", no_argument, NULL, 'p'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -143,6 +140,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -159,15 +159,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("pathchk (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
37
src/pinky.c
37
src/pinky.c
@@ -1,5 +1,5 @@
|
||||
/* GNU's pinky.
|
||||
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,11 +20,17 @@
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pinky"
|
||||
|
||||
#define AUTHORS "Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi"
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 64
|
||||
#endif
|
||||
@@ -39,12 +45,6 @@ char *ttyname ();
|
||||
/* The name this program was run with. */
|
||||
const char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* If nonzero, display the hours:minutes since each user has touched
|
||||
the keyboard, or blank if within the last minute, or days followed
|
||||
by a 'd' if not within the last day. */
|
||||
@@ -76,8 +76,8 @@ static int include_where = 1;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -423,6 +423,7 @@ usage (int status)
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
A lightweight `finger' program; print user information.\n\
|
||||
The utmp file will be %s.\n\
|
||||
"), UTMP_FILE);
|
||||
puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
|
||||
@@ -431,7 +432,7 @@ The utmp file will be %s.\n\
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *const argv[])
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc, longind;
|
||||
|
||||
@@ -440,7 +441,8 @@ main (int argc, char *const argv[])
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, &longind)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, &longind))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -490,20 +492,15 @@ main (int argc, char *const argv[])
|
||||
include_home_and_shell = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("pinky (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (do_short_format)
|
||||
short_pinky (UTMP_FILE, argc - optind, argv + optind);
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* printenv -- print all or part of environment
|
||||
Copyright (C) 89,90,91,92,93,94,95,96,1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -35,20 +35,18 @@
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "printenv"
|
||||
|
||||
#define AUTHORS "David MacKenzie and Richard Mlynarik"
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -88,6 +86,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -100,15 +101,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("printenv (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
for (env = environ; *env != NULL; ++env)
|
||||
|
||||
10
src/printf.c
10
src/printf.c
@@ -1,5 +1,5 @@
|
||||
/* printf - format and print data
|
||||
Copyright (C) 90,91,92,93,94,95,96,97,1998 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
|
||||
@@ -52,6 +52,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "printf"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
double strtod ();
|
||||
long int strtol ();
|
||||
@@ -491,7 +496,8 @@ main (int argc, char **argv)
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
|
||||
if (!posixly_correct)
|
||||
parse_long_options (argc, argv, "printf", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
|
||||
75
src/ptx.c
75
src/ptx.c
@@ -1,5 +1,5 @@
|
||||
/* Permuted index for GNU, with keywords in their context.
|
||||
Copyright © 1990, 1991, 1993, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1991, 1993, 1998-1999 Free Software Foundation, Inc.
|
||||
François Pinard <pinard@iro.umontreal.ca>, 1988.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -30,6 +30,11 @@
|
||||
#include "error.h"
|
||||
#include "regex.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "ptx"
|
||||
|
||||
#define AUTHORS "François Pinard"
|
||||
|
||||
/* Number of possible characters in a byte. */
|
||||
#define CHAR_SET_SIZE 256
|
||||
|
||||
@@ -80,12 +85,6 @@
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help = 0;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version = 0;
|
||||
|
||||
/* Program options. */
|
||||
|
||||
enum Format
|
||||
@@ -552,7 +551,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block)
|
||||
file_handle = fileno (stdin);
|
||||
else
|
||||
if ((file_handle = open (file_name, O_RDONLY)) < 0)
|
||||
error (EXIT_FAILURE, errno, file_name);
|
||||
error (EXIT_FAILURE, errno, "%s", file_name);
|
||||
|
||||
/* If the file is a plain, regular file, allocate the memory buffer all at
|
||||
once and swallow the file in one blow. In other cases, read the file
|
||||
@@ -560,27 +559,35 @@ swallow_file_in_memory (const char *file_name, BLOCK *block)
|
||||
once in a while, as we go. */
|
||||
|
||||
if (fstat (file_handle, &stat_block) < 0)
|
||||
error (EXIT_FAILURE, errno, file_name);
|
||||
|
||||
#if !MSDOS
|
||||
|
||||
/* On MSDOS, we cannot predict in memory size from file size, because of
|
||||
end of line conversions. */
|
||||
error (EXIT_FAILURE, errno, "%s", file_name);
|
||||
|
||||
if (S_ISREG (stat_block.st_mode))
|
||||
{
|
||||
size_t in_memory_size;
|
||||
|
||||
block->start = (char *) xmalloc ((size_t) stat_block.st_size);
|
||||
|
||||
if (read (file_handle, block->start, (size_t) stat_block.st_size)
|
||||
if ((in_memory_size = read (file_handle,
|
||||
block->start, (size_t) stat_block.st_size))
|
||||
!= stat_block.st_size)
|
||||
error (EXIT_FAILURE, errno, file_name);
|
||||
|
||||
block->end = block->start + stat_block.st_size;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
#if MSDOS
|
||||
/* On MSDOS, in memory size may be smaller than the file
|
||||
size, because of end of line conversions. But it can
|
||||
never be smaller than half the file size, because the
|
||||
minimum is when all lines are empty and terminated by
|
||||
CR+LF. */
|
||||
if (in_memory_size != (size_t)-1
|
||||
&& in_memory_size >= stat_block.st_size / 2)
|
||||
block->start = (char *) xrealloc (block->start, in_memory_size);
|
||||
else
|
||||
#endif /* not MSDOS */
|
||||
|
||||
error (EXIT_FAILURE, errno, "%s", file_name);
|
||||
}
|
||||
block->end = block->start + in_memory_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
block->start = (char *) xmalloc ((size_t) 1 << SWALLOW_REALLOC_LOG);
|
||||
used_length = 0;
|
||||
@@ -601,7 +608,7 @@ swallow_file_in_memory (const char *file_name, BLOCK *block)
|
||||
}
|
||||
|
||||
if (read_length < 0)
|
||||
error (EXIT_FAILURE, errno, file_name);
|
||||
error (EXIT_FAILURE, errno, "%s", file_name);
|
||||
|
||||
block->end = block->start + used_length;
|
||||
}
|
||||
@@ -1919,7 +1926,6 @@ static const struct option long_options[] =
|
||||
{"flag-truncation", required_argument, NULL, 'F'},
|
||||
{"ignore-case", no_argument, NULL, 'f'},
|
||||
{"gap-size", required_argument, NULL, 'g'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"ignore-file", required_argument, NULL, 'i'},
|
||||
{"macro-name", required_argument, NULL, 'M'},
|
||||
{"only-file", required_argument, NULL, 'o'},
|
||||
@@ -1929,9 +1935,10 @@ static const struct option long_options[] =
|
||||
{"sentence-regexp", required_argument, NULL, 'S'},
|
||||
{"traditional", no_argument, NULL, 'G'},
|
||||
{"typeset-mode", no_argument, NULL, 't'},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{"word-regexp", required_argument, NULL, 'W'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -1946,7 +1953,7 @@ static enum Format const format_vals[] =
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char *const argv[])
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optchar; /* argument character */
|
||||
int file_index; /* index in text input file arrays */
|
||||
@@ -1955,6 +1962,8 @@ main (int argc, char *const argv[])
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
#if HAVE_SETCHRCLASS
|
||||
setchrclass (NULL);
|
||||
@@ -2062,20 +2071,12 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"),
|
||||
case 10:
|
||||
output_format = XARGMATCH ("--format", optarg,
|
||||
format_args, format_vals);
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process trivial options. */
|
||||
|
||||
if (show_help)
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("ptx (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Change the default Ignore file if one is defined. */
|
||||
|
||||
#ifdef DEFAULT_IGNORE_FILE
|
||||
@@ -2135,7 +2136,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"),
|
||||
{
|
||||
fclose (stdout);
|
||||
if (fopen (argv[optind], "w") == NULL)
|
||||
error (EXIT_FAILURE, errno, argv[optind]);
|
||||
error (EXIT_FAILURE, errno, "%s", argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
|
||||
10
src/pwd.c
10
src/pwd.c
@@ -1,5 +1,5 @@
|
||||
/* pwd - print current directory
|
||||
Copyright (C) 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,6 +25,11 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pwd"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
|
||||
char *xgetcwd ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
@@ -60,7 +65,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
parse_long_options (argc, argv, "pwd", GNU_PACKAGE, VERSION, usage);
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (argc != 1)
|
||||
error (0, 0, _("ignoring non-option arguments"));
|
||||
|
||||
31
src/remove.c
31
src/remove.c
@@ -1,5 +1,5 @@
|
||||
/* remove.c -- core functions for removing files and directories
|
||||
Copyright (C) 88, 90, 91, 94, 95, 96, 97, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1994-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -34,7 +34,6 @@ typedef enum {false = 0, true = 1} bool;
|
||||
|
||||
#include "save-cwd.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "hash.h"
|
||||
@@ -552,17 +551,14 @@ remove_cwd_entries (const struct rm_options *x)
|
||||
we don't consider it again if we reopen this directory later. */
|
||||
if (status != RM_OK)
|
||||
{
|
||||
bool done;
|
||||
|
||||
if (ht == NULL)
|
||||
{
|
||||
ht = hash_initialize (HT_INITIAL_CAPACITY, hash_pjw,
|
||||
ht = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_pjw,
|
||||
hash_compare_strings, NULL);
|
||||
if (ht == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
hash_insert (ht, entry_name, &done);
|
||||
if (!done)
|
||||
if (! hash_insert (ht, entry_name))
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
else
|
||||
@@ -808,24 +804,19 @@ rm (struct File_spec *fs, int user_specified_name, const struct rm_options *x)
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
if (S_ISDIR (filetype_mode))
|
||||
{
|
||||
bool done;
|
||||
struct active_dir_ent *old_ent;
|
||||
struct active_dir_ent *new_ent;
|
||||
|
||||
/* Insert this directory in the active_dir_map.
|
||||
If there is already a directory in the map with the same inum,
|
||||
/* 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
|
||||
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 (active_dir_map,
|
||||
make_active_dir_ent (fs->inum, current_depth ()),
|
||||
&done);
|
||||
if (!done)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
|
||||
if (old_ent)
|
||||
new_ent = make_active_dir_ent (fs->inum, current_depth ());
|
||||
if (hash_lookup (active_dir_map, new_ent))
|
||||
{
|
||||
error (0, 0, _("\
|
||||
WARNING: Circular directory structure.\n\
|
||||
@@ -849,6 +840,10 @@ The following two directories have the same inode number:\n"));
|
||||
}
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Put this directory in the active_dir_map. */
|
||||
if (! hash_insert (active_dir_map, new_ent))
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -891,7 +886,7 @@ remove_init (void)
|
||||
obstack_init (&len_stack);
|
||||
|
||||
#ifdef ENABLE_CYCLE_CHECK
|
||||
active_dir_map = hash_initialize (ACTIVE_DIR_INITIAL_CAPACITY,
|
||||
active_dir_map = hash_initialize (ACTIVE_DIR_INITIAL_CAPACITY, NULL,
|
||||
hash_active_dir_ent,
|
||||
hash_compare_active_dir_ents, free);
|
||||
#endif
|
||||
|
||||
33
src/rm.c
33
src/rm.c
@@ -1,5 +1,5 @@
|
||||
/* `rm' file deletion utility for GNU.
|
||||
Copyright (C) 88, 90, 91, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1994-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -49,23 +49,22 @@
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "save-cwd.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "remove.h"
|
||||
#include "save-cwd.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "rm"
|
||||
|
||||
#define AUTHORS \
|
||||
"Paul Rubin, David MacKenzie, Richard Stallman, and Jim Meyering"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
/* Name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"directory", no_argument, NULL, 'd'},
|
||||
@@ -73,8 +72,8 @@ static struct option const long_opts[] =
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"recursive", no_argument, NULL, 'r'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -153,21 +152,13 @@ main (int argc, char **argv)
|
||||
case 'v':
|
||||
x.verbose = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("rm (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
if (x.ignore_missing_files)
|
||||
|
||||
30
src/rmdir.c
30
src/rmdir.c
@@ -1,5 +1,5 @@
|
||||
/* rmdir -- remove directories
|
||||
Copyright (C) 90, 91, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,9 +28,13 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "rmdir"
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
#ifndef EEXIST
|
||||
# define EEXIST 0
|
||||
#endif
|
||||
@@ -54,12 +58,6 @@ static int ignore_fail_on_non_empty;
|
||||
/* If nonzero, output a diagnostic for every directory processed. */
|
||||
static int verbose;
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
/* Don't name this `--force' because it's not close enough in meaning
|
||||
@@ -69,8 +67,8 @@ static struct option const longopts[] =
|
||||
{"path", no_argument, NULL, 'p'},
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
{"verbose", no_argument, NULL, 14},
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -169,21 +167,13 @@ main (int argc, char **argv)
|
||||
case 14:
|
||||
verbose = 1;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("rmdir (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
close_stdout ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
33
src/seq.c
33
src/seq.c
@@ -1,5 +1,5 @@
|
||||
/* seq - print sequence of numbers to standard output.
|
||||
Copyright (C) 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -27,6 +27,11 @@
|
||||
#include "error.h"
|
||||
#include "xstrtod.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "seq"
|
||||
|
||||
#define AUTHORS "Ulrich Drepper"
|
||||
|
||||
static double scan_double_arg PARAMS ((const char *arg));
|
||||
static int check_format PARAMS ((const char *format_string));
|
||||
static char *get_width_format PARAMS ((void));
|
||||
@@ -52,12 +57,6 @@ static char *separator;
|
||||
/* FIXME: make this an option. */
|
||||
static char *terminator = "\n";
|
||||
|
||||
/* If nonzero, display usage information and exit. */
|
||||
static int show_help;
|
||||
|
||||
/* If nonzero, print the version on standard output and exit. */
|
||||
static int show_version;
|
||||
|
||||
/* The increment. */
|
||||
static double step;
|
||||
|
||||
@@ -68,9 +67,9 @@ static struct option const long_options[] =
|
||||
{
|
||||
{ "equal-width", no_argument, NULL, 'w'},
|
||||
{ "format", required_argument, NULL, 'f'},
|
||||
{ "help", no_argument, &show_help, 1},
|
||||
{ "separator", required_argument, NULL, 's'},
|
||||
{ "version", no_argument, &show_version, 1},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -156,24 +155,16 @@ main (int argc, char **argv)
|
||||
equal_width = 1;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("seq (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
{
|
||||
usage (0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
|
||||
1095
src/shred.c
1095
src/shred.c
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user