mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
222 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
482aa7fc64 | ||
|
|
8985201718 | ||
|
|
7de6407b72 | ||
|
|
579105347d | ||
|
|
039c76fc63 | ||
|
|
8f8938e366 | ||
|
|
15ecc0f435 | ||
|
|
b34c9d22e4 | ||
|
|
97b943feb3 | ||
|
|
836e28186c | ||
|
|
91d525cd50 | ||
|
|
586b7bf510 | ||
|
|
d0cc040dd8 | ||
|
|
358c9c706a | ||
|
|
dd19256dcd | ||
|
|
8fad3eb9e0 | ||
|
|
1adc899668 | ||
|
|
de4a1fe053 | ||
|
|
5c34a06b45 | ||
|
|
f5fb72e12c | ||
|
|
8fd90d4b2b | ||
|
|
d402b210ea | ||
|
|
619ffb2bff | ||
|
|
abd2b295f2 | ||
|
|
396069fce5 | ||
|
|
a5c0da5365 | ||
|
|
bc009f5b5f | ||
|
|
5c136d939e | ||
|
|
b55a5cc86c | ||
|
|
4d453f5691 | ||
|
|
9d67112156 | ||
|
|
c880f6f9e0 | ||
|
|
8469888ca2 | ||
|
|
83616b114e | ||
|
|
f01f28a92a | ||
|
|
ba798c5998 | ||
|
|
aa78add2de | ||
|
|
3cf14979b7 | ||
|
|
1ca5f870b6 | ||
|
|
1cd58148cd | ||
|
|
a4f0b7b42e | ||
|
|
71f60a998c | ||
|
|
f13c5ee9ce | ||
|
|
6385fbd99a | ||
|
|
73417841eb | ||
|
|
dba50eec49 | ||
|
|
3400cc7f78 | ||
|
|
3c5405d298 | ||
|
|
be72ac078c | ||
|
|
6d38725e21 | ||
|
|
4e5d2ac6d2 | ||
|
|
cbd2839f1d | ||
|
|
a3ac01b48d | ||
|
|
00df9725bb | ||
|
|
81b16373ae | ||
|
|
47827e2ec2 | ||
|
|
68c6a5d828 | ||
|
|
30c412049f | ||
|
|
f2d53500ae | ||
|
|
fc64ba37d4 | ||
|
|
a5c02a198b | ||
|
|
12bf65f915 | ||
|
|
48ebc7d0b7 | ||
|
|
b0fd0aa567 | ||
|
|
a1eab797d0 | ||
|
|
7f0b022e0d | ||
|
|
1224b48d7f | ||
|
|
3b8a52ccbe | ||
|
|
605768d957 | ||
|
|
45dcf53e6e | ||
|
|
3f0c7988cf | ||
|
|
51dbb91fdd | ||
|
|
9590fbf43c | ||
|
|
5a3d9df9a1 | ||
|
|
70e5178bde | ||
|
|
c693c5940b | ||
|
|
8c8e4286b5 | ||
|
|
ce8cf50e0a | ||
|
|
4071f9dcd5 | ||
|
|
ebd41d46d8 | ||
|
|
a210d7d35c | ||
|
|
b9c210715c | ||
|
|
101160bdf9 | ||
|
|
5c4406f731 | ||
|
|
721557bb21 | ||
|
|
d7f56af947 | ||
|
|
17bd8fb7fa | ||
|
|
babf9bb7ac | ||
|
|
28ee33a9d8 | ||
|
|
e90fed0bf7 | ||
|
|
41a1348544 | ||
|
|
2f925e9403 | ||
|
|
1068a0005a | ||
|
|
cf197bb14a | ||
|
|
34b63c88da | ||
|
|
2fd73df635 | ||
|
|
31f5c39ace | ||
|
|
aa1ddd2e7d | ||
|
|
fca7b20092 | ||
|
|
a90650cd3a | ||
|
|
03faf39b22 | ||
|
|
acd3390874 | ||
|
|
c263f45884 | ||
|
|
a41b145094 | ||
|
|
661f74698e | ||
|
|
c6b0fefde1 | ||
|
|
2d4fd1ab6e | ||
|
|
c4d7de4d1c | ||
|
|
7942b60d47 | ||
|
|
c6bd79ad34 | ||
|
|
52150ef51d | ||
|
|
071e5e3b25 | ||
|
|
21f7f8fb60 | ||
|
|
1a898f0449 | ||
|
|
ab241ac3be | ||
|
|
d3683509b3 | ||
|
|
ddb8aa8b9f | ||
|
|
73ed5ed51e | ||
|
|
a3d40a9447 | ||
|
|
309c1c3e47 | ||
|
|
72bdac7271 | ||
|
|
f1013a1535 | ||
|
|
e1133c7a28 | ||
|
|
011b92f1c9 | ||
|
|
5aa90a9946 | ||
|
|
c610f47650 | ||
|
|
d9e1e1dbd2 | ||
|
|
b700e5cdfe | ||
|
|
a83332dcd2 | ||
|
|
20d55109b5 | ||
|
|
95fad10ba3 | ||
|
|
e580f2a576 | ||
|
|
0a63562cfa | ||
|
|
55b7281ec2 | ||
|
|
b00705596d | ||
|
|
6507fa63ce | ||
|
|
e074cde09b | ||
|
|
9b6eb98d41 | ||
|
|
72efca1195 | ||
|
|
884af44da8 | ||
|
|
c2a761780e | ||
|
|
2c1ae1f436 | ||
|
|
ed0f130ea1 | ||
|
|
a23b2bb948 | ||
|
|
669034433d | ||
|
|
97df7c4729 | ||
|
|
6206ee75ea | ||
|
|
6b54234726 | ||
|
|
c141f3a34e | ||
|
|
3140984fab | ||
|
|
19c397acdc | ||
|
|
80b5341cb8 | ||
|
|
f2fde491db | ||
|
|
e1c98ab3fb | ||
|
|
be9e62c6e0 | ||
|
|
df9a764cbd | ||
|
|
3684b16708 | ||
|
|
7dad7fd5c6 | ||
|
|
856071f1da | ||
|
|
ff1e216579 | ||
|
|
554b19b9d1 | ||
|
|
98e69d378e | ||
|
|
00c483746f | ||
|
|
7d4bd8f671 | ||
|
|
46b48d2e0e | ||
|
|
87a766e71a | ||
|
|
5d65fd5e99 | ||
|
|
6a4a7cfe00 | ||
|
|
2961a41dc3 | ||
|
|
a0f78c6a82 | ||
|
|
3e5e4aa3ac | ||
|
|
f4d3d21b14 | ||
|
|
6a0899b4b6 | ||
|
|
3d21ae4853 | ||
|
|
6405a85879 | ||
|
|
91aee8ad4d | ||
|
|
3c13ac6c36 | ||
|
|
0605601f99 | ||
|
|
c8fa96131e | ||
|
|
cea745beaa | ||
|
|
647d5e6a70 | ||
|
|
b53fe736bc | ||
|
|
f7fcc8c622 | ||
|
|
be579a52e7 | ||
|
|
c2262fcd90 | ||
|
|
93e3e3a5a8 | ||
|
|
92d235c21a | ||
|
|
900011c7de | ||
|
|
0cb358268d | ||
|
|
e6d69926e6 | ||
|
|
7e3bd1d897 | ||
|
|
cd8042a77c | ||
|
|
44bdb2f05a | ||
|
|
38a059bf64 | ||
|
|
950eba9ba0 | ||
|
|
5fdc4f4666 | ||
|
|
4c69db64f2 | ||
|
|
acd9c429c0 | ||
|
|
e0263e15f1 | ||
|
|
cb58624cef | ||
|
|
c488f85c66 | ||
|
|
aa435d9982 | ||
|
|
624dd54796 | ||
|
|
ef34c8704c | ||
|
|
b0d42f0a5c | ||
|
|
3491fe9797 | ||
|
|
951abbe274 | ||
|
|
392dd7af09 | ||
|
|
9561e02b6a | ||
|
|
e6bf5ecaf8 | ||
|
|
e511c84abe | ||
|
|
cc5b8b2e79 | ||
|
|
56b16d84df | ||
|
|
034fbbd8ac | ||
|
|
a65db32955 | ||
|
|
72d2131b0e | ||
|
|
2edc7371bc | ||
|
|
5e7a7d23f5 | ||
|
|
d0e30069c0 | ||
|
|
9a7f0b1542 | ||
|
|
9a909400ba | ||
|
|
9e60f6cc06 |
@@ -49,7 +49,6 @@ null_AM_MAKEFLAGS = \
|
||||
|
||||
t=./=test
|
||||
my-distcheck: writable-files po-check
|
||||
|
||||
-rm -rf $(t)
|
||||
mkdir $(t)
|
||||
GZIP=$(GZIP) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
||||
@@ -61,8 +60,8 @@ my-distcheck: writable-files po-check
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& rm -rf $(DEPDIR) \
|
||||
&& $(MAKE) distclean
|
||||
&& $(MAKE) distclean \
|
||||
&& rm -rf $(DEPDIR)
|
||||
cd $(t) && mv $(distdir) $(distdir).old \
|
||||
&& $(AMTAR) -zxf ../$(distdir).tar.gz
|
||||
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
||||
|
||||
9
THANKS
9
THANKS
@@ -61,6 +61,7 @@ Dirk-Jan Faber djfaber@snow.nl
|
||||
Don Parsons dparsons@synapse.kent.edu
|
||||
Donni Erpel donald@appc11.gsi.de
|
||||
Doug McLaren dougmc@comco.com
|
||||
Dragos Harabor dharabor@us.oracle.com
|
||||
Ed Avis epa98@doc.ic.ac.uk
|
||||
Edzer Pebesma Edzer.Pebesma@rivm.nl
|
||||
Eirik Fuller eirik@netcom.com
|
||||
@@ -87,12 +88,13 @@ GOTO Masanori gotom@debian.or.jp
|
||||
Greg McGary gkm@gnu.org
|
||||
Greg Troxel gdt@bbn.com
|
||||
Greg Wooledge gawooledge@sherwin.com
|
||||
Gregory Leblanc gleblanc@cu-portland.edu>
|
||||
Gregory Leblanc gleblanc@cu-portland.edu
|
||||
Göran Uddeborg goeran@uddeborg.pp.se
|
||||
H. J. Lu hjl@valinux.com
|
||||
Hans Verkuil hans@wyst.hobby.nl
|
||||
Holger Berger hberger@ess.nec.de
|
||||
Hugh Daniel hugh@xanadu.com
|
||||
Ian Jackson ijackson@chiark.greenend.org.uk
|
||||
Ian Lance Taylor ian@cygnus.com
|
||||
Ian Turner vectro@pipeline.com
|
||||
James james@albion.glarp.com
|
||||
@@ -104,9 +106,11 @@ Jamie Lokier jamie@imbolc.ucc.ie
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
Jarkko Hietaniemi jhi@epsilon.hut.fi
|
||||
Jeff Moore jbm@mordor.com
|
||||
Jeff Sheinberg jeffsh@erols.com
|
||||
Jens Schmidt jms@jsds.hamburg.com
|
||||
Jerome Abela abela@hsc.fr
|
||||
Jesse Thilo jgt2@eecs.lehigh.edu
|
||||
Jie Xu xuj@iag.net
|
||||
Jim Blandy jimb@cyclic.com
|
||||
Jim Dennis jimd@starshine.org
|
||||
Joakim Rosqvist dvljrt@cs.umu.se
|
||||
@@ -145,6 +149,7 @@ Lorne Baker lbaker@nitro.avint.net
|
||||
Manas Garg manas@cygsoft.com
|
||||
Manfred Hollstein manfred@s-direktnet.de
|
||||
Marc Boucher marc@mbsi.ca
|
||||
Marc Olzheim marcolz@stack.nl
|
||||
Marco Franzen Marco.Franzen@Thyron.com
|
||||
Marcus Daniels marcus@ee.pdx.edu
|
||||
Mark A. Thomas thommark@access.digex.net
|
||||
@@ -162,6 +167,7 @@ Masami Takikawa takikawm@CS.ORST.EDU
|
||||
Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matthew Braun matthew@ans.net
|
||||
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
|
||||
Matthew S. Levine mslevine@theory.lcs.mit.edu
|
||||
Matthew Swift swift@alum.mit.edu
|
||||
Matthias Urlichs smurf@noris.de
|
||||
@@ -176,6 +182,7 @@ Michel Robitaille robitail@IRO.UMontreal.CA
|
||||
Michiel Bacchiani bacchian@raven.bu.edu
|
||||
Miles Bader miles@gnu.ai.mit.edu
|
||||
Minh Tran-Le tranle@intellicorp.com
|
||||
Morten Welinder terra@diku.dk
|
||||
Nelson H. F. Beebe beebe@math.utah.edu
|
||||
Niklas Edmundsson nikke@acc.umu.se
|
||||
Noah Friedman friedman@splode.com
|
||||
|
||||
@@ -31,8 +31,6 @@ mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
@@ -90,7 +88,9 @@ INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
LIB_NANOSLEEP = @LIB_NANOSLEEP@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
|
||||
@@ -6,4 +6,5 @@ getopt1.c
|
||||
md5.h
|
||||
obstack.h
|
||||
regex.h
|
||||
regex.c
|
||||
getpagesize.h
|
||||
|
||||
@@ -195,3 +195,6 @@ p u
|
||||
n
|
||||
p u
|
||||
n
|
||||
r -r .aa > k
|
||||
pwd
|
||||
q
|
||||
|
||||
@@ -1,3 +1,80 @@
|
||||
2000-05-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* hash.c (hash_rehash): Fix a nasty bug: copy the free entry list
|
||||
back, too, since it may have been modified by allocate_entry.
|
||||
(hash_delete): Rewrite to use neither the assignment operator
|
||||
nor the comma operator in an if-expression.
|
||||
|
||||
2000-05-15 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/closeout.c:
|
||||
<sys/stat.h>, <sys/types.h>, <unistd.h>, (STDOUT_FILENO):
|
||||
Remove; no longer needed.
|
||||
"quotearg.h": Add include.
|
||||
(file_name): Do not bother to explicitly initialize to NULL; it's less
|
||||
efficient on some hosts.
|
||||
(close_stdout_status): Remove test as to whether stdout was already
|
||||
closed; it breaks for the case "echo x | sort >&-".
|
||||
Quote file name colons.
|
||||
Do not assume that _("write error") lacks format strings.
|
||||
|
||||
2000-05-15 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* version-etc.c (version_etc_copyright): Update the copyright string
|
||||
used in all --version output.
|
||||
|
||||
2000-05-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* closeout.c (close_stdout_set_file_name): New function.
|
||||
(close_stdout_status): Use new file-scoped global.
|
||||
Return right away if fstat says the stdout file descriptor is invalid.
|
||||
* closeout.h (close_stdout_set_file_name): Declare.
|
||||
|
||||
2000-05-10 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* closeout.c [default_exit_status]: New file-scoped variable.
|
||||
(close_stdout_set_status): New function.
|
||||
* closeout.h (close_stdout_set_status): Declare.
|
||||
|
||||
2000-05-08 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* long-options.c: Don't include closeout.h.
|
||||
(parse_long_options): Don't call close_stdout for --version.
|
||||
|
||||
2000-05-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* strnlen.c: Undefine __strnlen and strnlen.
|
||||
[!weak_alias]: Define __strnlen to strnlen.
|
||||
|
||||
* atexit.c: New file, from libiberty.
|
||||
|
||||
2000-05-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* closeout.c (close_stdout_status): Also check for errors on the
|
||||
stderr stream.
|
||||
|
||||
2000-05-05 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* localcharset.c (get_charset_aliases): Use malloc, realloc and memcpy
|
||||
instead of xmalloc, xrealloc, path_concat.
|
||||
(locale_charset): Treat empty environment variables as absent.
|
||||
(DIRECTORY_SEPARATOR, ISSLASH): New macros.
|
||||
|
||||
2000-05-04 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* getopt.c: Update from glibc.
|
||||
* obstack.c: Likewise.
|
||||
* obstack.h: Likewise.
|
||||
* regex.c: Likewise. NB: K&R compiler support is dropped for this file
|
||||
|
||||
* regex.h: Likewise.
|
||||
* strndup.c: Likewise.
|
||||
* strnlen.c: New file, from glibc.
|
||||
|
||||
2000-05-01 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* full-write.c (full_write): Remove `FIXME' part of comment.
|
||||
|
||||
2000-04-29 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* path-concat.c: Declare strdup only if it's not defined.
|
||||
|
||||
@@ -9,7 +9,7 @@ DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
|
||||
|
||||
libfetish_a_SOURCES = \
|
||||
getdate.y posixtm.c addext.c argmatch.c backupfile.c basename.c \
|
||||
canon-host.c closeout.c dirname.c exclude.c filemode.c diacrit.c \
|
||||
canon-host.c closeout.c diacrit.c dirname.c exclude.c filemode.c \
|
||||
full-write.c getopt.c getopt1.c getugroups.c hard-locale.c hash.c \
|
||||
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
|
||||
makepath.c md5.c memcasecmp.c memcoll.c modechange.c path-concat.c \
|
||||
|
||||
@@ -31,8 +31,6 @@ mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
@@ -90,7 +88,9 @@ INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
LIB_NANOSLEEP = @LIB_NANOSLEEP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
@@ -123,7 +123,7 @@ DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
|
||||
|
||||
libfetish_a_SOURCES = \
|
||||
getdate.y posixtm.c addext.c argmatch.c backupfile.c basename.c \
|
||||
canon-host.c closeout.c dirname.c exclude.c filemode.c diacrit.c \
|
||||
canon-host.c closeout.c diacrit.c dirname.c exclude.c filemode.c \
|
||||
full-write.c getopt.c getopt1.c getugroups.c hard-locale.c hash.c \
|
||||
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
|
||||
makepath.c md5.c memcasecmp.c memcoll.c modechange.c path-concat.c \
|
||||
@@ -172,7 +172,7 @@ ANSI2KNR = ../src/ansi2knr
|
||||
libfetish_a_AR = $(AR) cru
|
||||
am_libfetish_a_OBJECTS = getdate$U.o posixtm$U.o addext$U.o \
|
||||
argmatch$U.o backupfile$U.o basename$U.o canon-host$U.o closeout$U.o \
|
||||
dirname$U.o exclude$U.o filemode$U.o diacrit$U.o full-write$U.o \
|
||||
diacrit$U.o dirname$U.o exclude$U.o filemode$U.o full-write$U.o \
|
||||
getopt$U.o getopt1$U.o getugroups$U.o hard-locale$U.o hash$U.o \
|
||||
human$U.o idcache$U.o isdir$U.o linebuffer$U.o localcharset$U.o \
|
||||
long-options$U.o makepath$U.o md5$U.o memcasecmp$U.o memcoll$U.o \
|
||||
@@ -192,7 +192,7 @@ HEADERS = $(noinst_HEADERS)
|
||||
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
DEP_FILES = @AMDEP@ $(DEPDIR)/addext$U.Po $(DEPDIR)/alloca.Po \
|
||||
$(DEPDIR)/argmatch$U.Po $(DEPDIR)/backupfile$U.Po \
|
||||
$(DEPDIR)/argmatch$U.Po $(DEPDIR)/atexit.Po $(DEPDIR)/backupfile$U.Po \
|
||||
$(DEPDIR)/basename$U.Po $(DEPDIR)/canon-host$U.Po $(DEPDIR)/chown.Po \
|
||||
$(DEPDIR)/closeout$U.Po $(DEPDIR)/diacrit$U.Po $(DEPDIR)/dirname$U.Po \
|
||||
$(DEPDIR)/dup2.Po $(DEPDIR)/error.Po $(DEPDIR)/euidaccess.Po \
|
||||
@@ -219,24 +219,25 @@ $(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po \
|
||||
$(DEPDIR)/stat.Po $(DEPDIR)/stime.Po $(DEPDIR)/stpcpy.Po \
|
||||
$(DEPDIR)/strcasecmp.Po $(DEPDIR)/strcspn.Po $(DEPDIR)/strdup.Po \
|
||||
$(DEPDIR)/strftime.Po $(DEPDIR)/stripslash$U.Po \
|
||||
$(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po $(DEPDIR)/strpbrk.Po \
|
||||
$(DEPDIR)/strstr.Po $(DEPDIR)/strtod.Po $(DEPDIR)/strtol.Po \
|
||||
$(DEPDIR)/strtoul.Po $(DEPDIR)/strtoull.Po $(DEPDIR)/strtoumax.Po \
|
||||
$(DEPDIR)/strverscmp.Po $(DEPDIR)/unicodeio$U.Po \
|
||||
$(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po $(DEPDIR)/strnlen.Po \
|
||||
$(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po $(DEPDIR)/strtod.Po \
|
||||
$(DEPDIR)/strtol.Po $(DEPDIR)/strtoul.Po $(DEPDIR)/strtoull.Po \
|
||||
$(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po $(DEPDIR)/unicodeio$U.Po \
|
||||
$(DEPDIR)/userspec$U.Po $(DEPDIR)/utime.Po $(DEPDIR)/version-etc$U.Po \
|
||||
$(DEPDIR)/xgetcwd$U.Po $(DEPDIR)/xgethostname$U.Po \
|
||||
$(DEPDIR)/xmalloc$U.Po $(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtod$U.Po \
|
||||
$(DEPDIR)/xstrtol$U.Po $(DEPDIR)/xstrtoul$U.Po \
|
||||
$(DEPDIR)/xstrtoumax$U.Po $(DEPDIR)/yesno$U.Po
|
||||
DIST_COMMON = README $(noinst_HEADERS) ChangeLog Makefile.am \
|
||||
Makefile.in TODO alloca.c chown.c dup2.c error.c error.h euidaccess.c \
|
||||
fileblocks.c fnmatch.c fsusage.c ftruncate.c getdate.c getgroups.c \
|
||||
gethostname.c getline.c getloadavg.c getusershell.c group-member.c \
|
||||
lchown.c malloc.c memchr.c memcmp.c memcpy.c memmove.c memset.c mkdir.c \
|
||||
mktime.c mountlist.c nanosleep.c obstack.c obstack.h putenv.c realloc.c \
|
||||
regex.c rmdir.c rpmatch.c stime.c stpcpy.c strcasecmp.c strcspn.c \
|
||||
strdup.c strftime.c strncasecmp.c strndup.c strpbrk.c strstr.c strtod.c \
|
||||
strtol.c strtoul.c strtoull.c strtoumax.c strverscmp.c utime.c
|
||||
Makefile.in TODO alloca.c atexit.c chown.c dup2.c error.c error.h \
|
||||
euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c getdate.c \
|
||||
getgroups.c gethostname.c getline.c getloadavg.c getusershell.c \
|
||||
group-member.c lchown.c malloc.c memchr.c memcmp.c memcpy.c memmove.c \
|
||||
memset.c mkdir.c mktime.c mountlist.c nanosleep.c obstack.c obstack.h \
|
||||
putenv.c realloc.c regex.c rmdir.c rpmatch.c stime.c stpcpy.c \
|
||||
strcasecmp.c strcspn.c strdup.c strftime.c strncasecmp.c strndup.c \
|
||||
strnlen.c strpbrk.c strstr.c strtod.c strtol.c strtoul.c strtoull.c \
|
||||
strtoumax.c strverscmp.c utime.c
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@@ -300,6 +301,8 @@ alloca_.c: alloca.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/alloca.c; then echo $(srcdir)/alloca.c; else echo alloca.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > alloca_.c
|
||||
argmatch_.c: argmatch.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/argmatch.c; then echo $(srcdir)/argmatch.c; else echo argmatch.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > argmatch_.c
|
||||
atexit_.c: atexit.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/atexit.c; then echo $(srcdir)/atexit.c; else echo atexit.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > atexit_.c
|
||||
backupfile_.c: backupfile.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/backupfile.c; then echo $(srcdir)/backupfile.c; else echo backupfile.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > backupfile_.c
|
||||
basename_.c: basename.c $(ANSI2KNR)
|
||||
@@ -454,6 +457,8 @@ strncasecmp_.c: strncasecmp.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strncasecmp.c; then echo $(srcdir)/strncasecmp.c; else echo strncasecmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strncasecmp_.c
|
||||
strndup_.c: strndup.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strndup.c; then echo $(srcdir)/strndup.c; else echo strndup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strndup_.c
|
||||
strnlen_.c: strnlen.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strnlen.c; then echo $(srcdir)/strnlen.c; else echo strnlen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strnlen_.c
|
||||
strpbrk_.c: strpbrk.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strpbrk.c; then echo $(srcdir)/strpbrk.c; else echo strpbrk.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strpbrk_.c
|
||||
strstr_.c: strstr.c $(ANSI2KNR)
|
||||
@@ -496,9 +501,9 @@ xstrtoumax_.c: xstrtoumax.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoumax.c; then echo $(srcdir)/xstrtoumax.c; else echo xstrtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoumax_.c
|
||||
yesno_.c: yesno.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > yesno_.c
|
||||
addext_.o alloca_.o argmatch_.o backupfile_.o basename_.o canon-host_.o \
|
||||
chown_.o closeout_.o diacrit_.o dirname_.o dup2_.o error_.o \
|
||||
euidaccess_.o exclude_.o fileblocks_.o filemode_.o fnmatch_.o \
|
||||
addext_.o alloca_.o argmatch_.o atexit_.o backupfile_.o basename_.o \
|
||||
canon-host_.o chown_.o closeout_.o diacrit_.o dirname_.o dup2_.o \
|
||||
error_.o euidaccess_.o exclude_.o fileblocks_.o filemode_.o fnmatch_.o \
|
||||
fsusage_.o ftruncate_.o full-write_.o getdate_.o getgroups_.o \
|
||||
gethostname_.o getline_.o getloadavg_.o getopt_.o getopt1_.o \
|
||||
getugroups_.o getusershell_.o group-member_.o hard-locale_.o hash_.o \
|
||||
@@ -510,11 +515,11 @@ path-concat_.o posixtm_.o putenv_.o quotearg_.o readtokens_.o \
|
||||
readutmp_.o realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o \
|
||||
same_.o save-cwd_.o savedir_.o stat_.o stime_.o stpcpy_.o strcasecmp_.o \
|
||||
strcspn_.o strdup_.o strftime_.o stripslash_.o strncasecmp_.o \
|
||||
strndup_.o strpbrk_.o strstr_.o strtod_.o strtol_.o strtoul_.o \
|
||||
strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o userspec_.o \
|
||||
utime_.o version-etc_.o xgetcwd_.o xgethostname_.o xmalloc_.o \
|
||||
xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o yesno_.o : \
|
||||
$(ANSI2KNR)
|
||||
strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o strtol_.o \
|
||||
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o \
|
||||
userspec_.o utime_.o version-etc_.o xgetcwd_.o xgethostname_.o \
|
||||
xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
|
||||
yesno_.o : $(ANSI2KNR)
|
||||
.y.c:
|
||||
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
|
||||
if test -f y.tab.h; then \
|
||||
@@ -558,6 +563,7 @@ maintainer-clean-tags:
|
||||
@AMDEP@include $(DEPDIR)/addext$U.Po
|
||||
@AMDEP@include $(DEPDIR)/alloca.Po
|
||||
@AMDEP@include $(DEPDIR)/argmatch$U.Po
|
||||
@AMDEP@include $(DEPDIR)/atexit.Po
|
||||
@AMDEP@include $(DEPDIR)/backupfile$U.Po
|
||||
@AMDEP@include $(DEPDIR)/basename$U.Po
|
||||
@AMDEP@include $(DEPDIR)/canon-host$U.Po
|
||||
@@ -635,6 +641,7 @@ maintainer-clean-tags:
|
||||
@AMDEP@include $(DEPDIR)/stripslash$U.Po
|
||||
@AMDEP@include $(DEPDIR)/strncasecmp.Po
|
||||
@AMDEP@include $(DEPDIR)/strndup.Po
|
||||
@AMDEP@include $(DEPDIR)/strnlen.Po
|
||||
@AMDEP@include $(DEPDIR)/strpbrk.Po
|
||||
@AMDEP@include $(DEPDIR)/strstr.Po
|
||||
@AMDEP@include $(DEPDIR)/strtod.Po
|
||||
|
||||
14
lib/atexit.c
Normal file
14
lib/atexit.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */
|
||||
/* This function is in the public domain. --Mike Stump. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int
|
||||
atexit(f)
|
||||
void (*f)();
|
||||
{
|
||||
/* If the system doesn't provide a definition for atexit, use on_exit
|
||||
if the system provides that. */
|
||||
on_exit (f, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* closeout.c - close standard output
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000 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,14 +33,36 @@
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
|
||||
static int default_exit_status = EXIT_FAILURE;
|
||||
static const char *file_name;
|
||||
|
||||
/* Set the value to be used for the exit status when close_stdout is called.
|
||||
This is useful when it is not convenient to call close_stdout_status,
|
||||
e.g., when close_stdout is called via atexit. */
|
||||
void
|
||||
close_stdout_set_status (int status)
|
||||
{
|
||||
default_exit_status = status;
|
||||
}
|
||||
|
||||
/* Set the file name to be reported in the event an error is detected
|
||||
by close_stdout_status. */
|
||||
void
|
||||
close_stdout_set_file_name (const char *file)
|
||||
{
|
||||
file_name = file;
|
||||
}
|
||||
|
||||
/* Close standard output, exiting with status STATUS on failure.
|
||||
If a program writes *anything* to stdout, that program should `fflush'
|
||||
@@ -67,15 +89,24 @@ extern int errno;
|
||||
void
|
||||
close_stdout_status (int status)
|
||||
{
|
||||
if (ferror (stdout))
|
||||
error (status, 0, _("write error"));
|
||||
int e = ferror (stdout) ? 0 : -1;
|
||||
|
||||
if (fclose (stdout) != 0)
|
||||
error (status, errno, _("write error"));
|
||||
e = errno;
|
||||
|
||||
if (0 <= e)
|
||||
{
|
||||
char const *write_error = _("write error");
|
||||
if (file_name)
|
||||
error (status, e, "%s: %s", quotearg_colon (file_name), write_error);
|
||||
else
|
||||
error (status, e, "%s", write_error);
|
||||
}
|
||||
}
|
||||
|
||||
/* Close standard output, exiting with status EXIT_FAILURE on failure. */
|
||||
void
|
||||
close_stdout (void)
|
||||
{
|
||||
close_stdout_status (EXIT_FAILURE);
|
||||
close_stdout_status (default_exit_status);
|
||||
}
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void close_stdout_set_status PARAMS ((int status));
|
||||
void close_stdout_set_file_name PARAMS ((const char *file));
|
||||
void close_stdout PARAMS ((void));
|
||||
void close_stdout_status PARAMS ((int status));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
|
||||
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
|
||||
70
lib/fatal.c
Normal file
70
lib/fatal.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* FIXME: define EXIT_FAILURE */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||
# if __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(args, lastarg) va_start(args, lastarg)
|
||||
# else
|
||||
# include <varargs.h>
|
||||
# define VA_START(args, lastarg) va_start(args)
|
||||
# endif
|
||||
#else
|
||||
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
|
||||
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || _LIBC
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
void exit ();
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# define program_name program_invocation_name
|
||||
#else /* not _LIBC */
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
#endif
|
||||
|
||||
#include "fatal.h"
|
||||
|
||||
/* Like error, but always exit with EXIT_FAILURE. */
|
||||
|
||||
void
|
||||
#if defined VA_START && __STDC__
|
||||
fatal (int errnum, const char *message, ...)
|
||||
#else
|
||||
fatal (errnum, message, va_alist)
|
||||
int errnum;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
fflush (stdout);
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
error (EXIT_FAILURE, errnum, message, args);
|
||||
va_end (args);
|
||||
#else
|
||||
error (EXIT_FAILURE, errnum, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
#endif
|
||||
}
|
||||
68
lib/fatal.h
Normal file
68
lib/fatal.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "error.h"
|
||||
|
||||
/* FIXME: this is all from ansidecl. better to simply swipe
|
||||
that file from egcs/include and include it from here. */
|
||||
|
||||
/* Using MACRO(x,y) in cpp #if conditionals does not work with some
|
||||
older preprocessors. Thus we can't define something like this:
|
||||
|
||||
#define HAVE_GCC_VERSION(MAJOR, MINOR) \
|
||||
(__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
|
||||
|
||||
and then test "#if HAVE_GCC_VERSION(2,7)".
|
||||
|
||||
So instead we use the macro below and test it against specific values. */
|
||||
|
||||
/* This macro simplifies testing whether we are using gcc, and if it
|
||||
is of a particular minimum version. (Both major & minor numbers are
|
||||
significant.) This macro will evaluate to 0 if we are not using
|
||||
gcc at all. */
|
||||
#ifndef GCC_VERSION
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif /* GCC_VERSION */
|
||||
|
||||
/* Define macros for some gcc attributes. This permits us to use the
|
||||
macros freely, and know that they will come into play for the
|
||||
version of gcc in which they are supported. */
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
|
||||
#ifndef ATTRIBUTE_MALLOC
|
||||
# if (GCC_VERSION >= 2096)
|
||||
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
# else
|
||||
# define ATTRIBUTE_MALLOC
|
||||
# endif /* GNUC >= 2.96 */
|
||||
#endif /* ATTRIBUTE_MALLOC */
|
||||
|
||||
/* Attributes on labels were valid as of gcc 2.93. */
|
||||
#ifndef ATTRIBUTE_UNUSED_LABEL
|
||||
# if (GCC_VERSION >= 2093)
|
||||
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
|
||||
# else
|
||||
# define ATTRIBUTE_UNUSED_LABEL
|
||||
# endif /* GNUC >= 2.93 */
|
||||
#endif /* ATTRIBUTE_UNUSED_LABEL */
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif /* ATTRIBUTE_UNUSED */
|
||||
|
||||
#ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
#endif /* ATTRIBUTE_NORETURN */
|
||||
|
||||
#ifndef ATTRIBUTE_PRINTF
|
||||
# define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
|
||||
# define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
|
||||
# define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
|
||||
# define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
|
||||
# define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
|
||||
# define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_PRINTF */
|
||||
|
||||
extern void fatal (int errnum, const char *format, ...)
|
||||
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_2;
|
||||
@@ -1,5 +1,5 @@
|
||||
/* full-write.c -- an interface to write that retries after interrupts
|
||||
Copyright (C) 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1997, 1998, 2000 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
|
||||
@@ -45,10 +45,11 @@ full_write (int desc, const char *ptr, size_t len)
|
||||
while (len > 0)
|
||||
{
|
||||
int written = write (desc, ptr, len);
|
||||
/* FIXME: write on my slackware Linux 1.2.13 returns zero when
|
||||
/* write on an old Slackware Linux 1.2.13 returns zero when
|
||||
I try to write more data than there is room on a floppy disk.
|
||||
This puts dd into an infinite loop. Reproduce with
|
||||
dd if=/dev/zero of=/dev/fd0. */
|
||||
dd if=/dev/zero of=/dev/fd0. If you have this problem,
|
||||
consider upgrading to a newer kernel. */
|
||||
if (written < 0)
|
||||
{
|
||||
#ifdef EINTR
|
||||
|
||||
33
lib/getopt.c
33
lib/getopt.c
@@ -2,7 +2,7 @@
|
||||
NOTE: The canonical source of this file is maintained with the GNU
|
||||
C Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
@@ -515,6 +515,13 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
int *longind;
|
||||
int long_only;
|
||||
{
|
||||
int print_errors = opterr;
|
||||
if (optstring[0] == ':')
|
||||
print_errors = 0;
|
||||
|
||||
if (argc < 1)
|
||||
return -1;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (optind == 0 || !__getopt_initialized)
|
||||
@@ -671,7 +678,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
@@ -692,7 +699,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
@@ -718,7 +725,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
fprintf (stderr,
|
||||
_("%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]);
|
||||
@@ -745,7 +752,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
@@ -775,7 +782,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
{
|
||||
if (posixly_correct)
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
@@ -809,7 +816,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
||||
@@ -858,7 +865,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
}
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
@@ -876,7 +883,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
fprintf (stderr, _("\
|
||||
%s: option `-W %s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
@@ -891,7 +898,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
fprintf (stderr,
|
||||
_("%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]);
|
||||
@@ -938,12 +945,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
if (print_errors)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr,
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c);
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
|
||||
@@ -723,7 +723,7 @@ hash_find_entry (Hash_table *table, const void *entry,
|
||||
if (bucket->data == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Check if then entry is found as the bucket head. */
|
||||
/* See if the entry is the first in the bucket. */
|
||||
if ((*table->comparator) (entry, bucket->data))
|
||||
{
|
||||
void *data = bucket->data;
|
||||
@@ -854,6 +854,7 @@ hash_rehash (Hash_table *table, unsigned candidate)
|
||||
table->bucket_limit = new_table->bucket_limit;
|
||||
table->n_buckets = new_table->n_buckets;
|
||||
table->n_buckets_used = new_table->n_buckets_used;
|
||||
table->free_entry_list = new_table->free_entry_list;
|
||||
/* table->n_entries already holds its value. */
|
||||
#if USE_OBSTACK
|
||||
table->entry_stack = new_table->entry_stack;
|
||||
@@ -943,7 +944,8 @@ hash_delete (Hash_table *table, const void *entry)
|
||||
void *data;
|
||||
struct hash_entry *bucket;
|
||||
|
||||
if (data = hash_find_entry (table, entry, &bucket, true), !data)
|
||||
data = hash_find_entry (table, entry, &bucket, true);
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
table->n_entries--;
|
||||
|
||||
@@ -45,10 +45,13 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "path-concat.h"
|
||||
#ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
#endif
|
||||
|
||||
/* The following static variable is declared 'volatile' to avoid a
|
||||
possible multithread problem in the function get_charset_aliases. If we
|
||||
@@ -71,7 +74,24 @@ get_charset_aliases ()
|
||||
if (cp == NULL)
|
||||
{
|
||||
FILE *fp;
|
||||
char *file_name = path_concat (LIBDIR, "charset.alias", NULL);
|
||||
const char *dir = LIBDIR;
|
||||
const char *base = "charset.alias";
|
||||
char *file_name;
|
||||
|
||||
/* Concatenate dir and base into freshly allocated file_name. */
|
||||
{
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
|
||||
/* Out of memory or file not found, treat it as empty. */
|
||||
@@ -111,12 +131,18 @@ get_charset_aliases ()
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = xmalloc (res_size + 1);
|
||||
res_ptr = malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = xrealloc (res_ptr, res_size + 1);
|
||||
res_ptr = realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
@@ -167,13 +193,13 @@ locale_charset ()
|
||||
# if HAVE_SETLOCALE
|
||||
locale = setlocale (LC_CTYPE, NULL);
|
||||
# endif
|
||||
if (locale == NULL)
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL)
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL)
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
}
|
||||
@@ -185,7 +211,7 @@ locale_charset ()
|
||||
|
||||
#endif
|
||||
|
||||
if (codeset != NULL)
|
||||
if (codeset != NULL && codeset[0] != '\0')
|
||||
{
|
||||
/* Resolve alias. */
|
||||
for (aliases = get_charset_aliases ();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Utility to accept --help and --version options as unobtrusively as possible.
|
||||
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1998, 1999, 2000 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,7 +23,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
@@ -71,8 +70,6 @@ parse_long_options (int argc,
|
||||
|
||||
case 'v':
|
||||
version_etc (stdout, command_name, package, version, authors);
|
||||
close_stdout (); /* FIXME: output failure exit status
|
||||
should be settable via an arg. */
|
||||
exit (0);
|
||||
|
||||
default:
|
||||
|
||||
112
lib/mountlist.c
112
lib/mountlist.c
@@ -1,5 +1,5 @@
|
||||
/* mountlist.c -- return a list of mounted filesystems
|
||||
Copyright (C) 1991, 1992, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -85,6 +85,11 @@ extern int errno;
|
||||
# include <sys/fs_types.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_NEXT_DEV /* BeOS. */
|
||||
# include <fs_info.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FREAD /* SVR2. */
|
||||
# include <mnttab.h>
|
||||
#endif
|
||||
@@ -413,6 +418,111 @@ read_filesystem_list (int need_fs_type)
|
||||
}
|
||||
#endif /* MOUNTED_GETMNT. */
|
||||
|
||||
#if defined (MOUNTED_NEXT_DEV) /* BeOS */
|
||||
{
|
||||
/* The next_dev() and fs_stat_dev() system calls give the list of
|
||||
all filesystems, including the information returned by statvfs()
|
||||
(fs type, total blocks, free blocks etc.), but without the mount
|
||||
point. But on BeOS all filesystems except / are mounted in the
|
||||
rootfs, directly under /.
|
||||
The directory name of the mount point is often, but not always,
|
||||
identical to the volume name of the device.
|
||||
We therefore get the list of subdirectories of /, and the list
|
||||
of all filesystems, and match the two lists. */
|
||||
|
||||
DIR *dirp;
|
||||
struct rootdir_entry
|
||||
{
|
||||
char *name;
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
struct rootdir_entry *next;
|
||||
};
|
||||
struct rootdir_entry *rootdir_list;
|
||||
struct rootdir_entry **rootdir_tail;
|
||||
int32 pos;
|
||||
dev_t dev;
|
||||
fs_info fi;
|
||||
|
||||
/* All volumes are mounted in the rootfs, directly under /. */
|
||||
rootdir_list = NULL;
|
||||
rootdir_tail = &rootdir_list;
|
||||
dirp = opendir ("/");
|
||||
if (dirp)
|
||||
{
|
||||
struct dirent *d;
|
||||
|
||||
while ((d = readdir (dirp)) != NULL)
|
||||
{
|
||||
char *name;
|
||||
struct stat statbuf;
|
||||
|
||||
if (strcmp (d->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if (strcmp (d->d_name, ".") == 0)
|
||||
name = xstrdup ("/");
|
||||
else
|
||||
{
|
||||
name = xmalloc (1 + strlen (d->d_name) + 1);
|
||||
name[0] = '/';
|
||||
strcpy (name + 1, d->d_name);
|
||||
}
|
||||
|
||||
if (stat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
|
||||
{
|
||||
struct rootdir_entry *re;
|
||||
|
||||
re = (struct rootdir_entry *) xmalloc (sizeof (struct rootdir_entry));
|
||||
re->name = name;
|
||||
re->dev = statbuf.st_dev;
|
||||
re->ino = statbuf.st_ino;
|
||||
|
||||
/* Add to the linked list. */
|
||||
*rootdir_tail = re;
|
||||
rootdir_tail = &re->next;
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
}
|
||||
closedir (dirp);
|
||||
}
|
||||
*rootdir_tail = NULL;
|
||||
|
||||
for (pos = 0; (dev = next_dev (&pos)) >= 0; )
|
||||
if (fs_stat_dev (dev, &fi) >= 0)
|
||||
{
|
||||
/* Note: fi.dev == dev. */
|
||||
struct rootdir_entry *re;
|
||||
|
||||
for (re = rootdir_list; re; re = re->next)
|
||||
if (re->dev == fi.dev && re->ino == fi.root)
|
||||
break;
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
|
||||
me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
|
||||
me->me_type = xstrdup (fi.fsh_name);
|
||||
me->me_dev = fi.dev;
|
||||
me->me_dummy = 0;
|
||||
me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0;
|
||||
|
||||
/* Add to the linked list. */
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
*mtail = NULL;
|
||||
|
||||
while (rootdir_list != NULL)
|
||||
{
|
||||
struct rootdir_entry *re = rootdir_list;
|
||||
rootdir_list = re->next;
|
||||
free (re->name);
|
||||
free (re);
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_NEXT_DEV */
|
||||
|
||||
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
|
||||
{
|
||||
int numsys, counter, bufsize;
|
||||
|
||||
146
lib/obstack.c
146
lib/obstack.c
@@ -1,5 +1,5 @@
|
||||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-1994,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@@ -19,6 +19,10 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
|
||||
@@ -37,60 +41,62 @@
|
||||
|
||||
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
||||
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
# include <gnu-versions.h>
|
||||
# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||
# define ELIDE_CODE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define POINTER void *
|
||||
#else
|
||||
#define POINTER char *
|
||||
#endif
|
||||
# if defined (__STDC__) && __STDC__
|
||||
# define POINTER void *
|
||||
# else
|
||||
# define POINTER char *
|
||||
# endif
|
||||
|
||||
/* Determine default alignment. */
|
||||
struct fooalign {char x; double d;};
|
||||
#define DEFAULT_ALIGNMENT \
|
||||
# define DEFAULT_ALIGNMENT \
|
||||
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
||||
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
||||
But in fact it might be less smart and round addresses to as much as
|
||||
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
||||
union fooround {long x; double d;};
|
||||
#define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||
# define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||
|
||||
/* When we copy a long block of data, this is the unit to do it with.
|
||||
On some machines, copying successive ints does not work;
|
||||
in such a case, redefine COPYING_UNIT to `long' (if that works)
|
||||
or `char' as a last resort. */
|
||||
#ifndef COPYING_UNIT
|
||||
#define COPYING_UNIT int
|
||||
#endif
|
||||
# ifndef COPYING_UNIT
|
||||
# define COPYING_UNIT int
|
||||
# endif
|
||||
|
||||
|
||||
/* The functions allocating more room by calling `obstack_chunk_alloc'
|
||||
jump to the handler pointed to by `obstack_alloc_failed_handler'.
|
||||
This variable by default points to the internal function
|
||||
This can be set to a user defined function which should either
|
||||
abort gracefully or use longjump - but shouldn't return. This
|
||||
variable by default points to the internal function
|
||||
`print_and_abort'. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
static void print_and_abort (void);
|
||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||
#else
|
||||
# else
|
||||
static void print_and_abort ();
|
||||
void (*obstack_alloc_failed_handler) () = print_and_abort;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* Exit value used when `print_and_abort' is used. */
|
||||
#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
# if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
# endif
|
||||
int obstack_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* The non-GNU-C macros copy the obstack into this global variable
|
||||
@@ -104,33 +110,33 @@ struct obstack *_obstack;
|
||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||
do not allow (expr) ? void : void. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define CALL_CHUNKFUN(h, size) \
|
||||
# if defined (__STDC__) && __STDC__
|
||||
# define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
|
||||
|
||||
#define CALL_FREEFUN(h, old_chunk) \
|
||||
# define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define CALL_CHUNKFUN(h, size) \
|
||||
# else
|
||||
# define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
|
||||
|
||||
#define CALL_FREEFUN(h, old_chunk) \
|
||||
# define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
#endif
|
||||
# endif
|
||||
|
||||
|
||||
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
|
||||
@@ -138,27 +144,26 @@ struct obstack *_obstack;
|
||||
CHUNKFUN is the function to use to allocate chunks,
|
||||
and FREEFUN the function to free them.
|
||||
|
||||
Return nonzero if successful, zero if out of memory.
|
||||
To recover from an out of memory error,
|
||||
free up some memory, then call this again. */
|
||||
Return nonzero if successful, calls obstack_alloc_failed_handler if
|
||||
allocation fails. */
|
||||
|
||||
int
|
||||
_obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
POINTER (*chunkfun) (long);
|
||||
void (*freefun) (void *);
|
||||
#else
|
||||
# else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
#endif
|
||||
# endif
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = DEFAULT_ALIGNMENT;
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
@@ -176,13 +181,13 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
#else
|
||||
# else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
#endif
|
||||
# endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->use_extra_arg = 0;
|
||||
@@ -205,19 +210,19 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
POINTER (*chunkfun) (POINTER, long);
|
||||
void (*freefun) (POINTER, POINTER);
|
||||
#else
|
||||
# else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
#endif
|
||||
# endif
|
||||
POINTER arg;
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = DEFAULT_ALIGNMENT;
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
@@ -235,13 +240,13 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
#if defined(__STDC__) && __STDC__
|
||||
# if defined(__STDC__) && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
#else
|
||||
# else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
#endif
|
||||
# endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->extra_arg = arg;
|
||||
@@ -274,9 +279,9 @@ _obstack_newchunk (h, length)
|
||||
register struct _obstack_chunk *old_chunk = h->chunk;
|
||||
register struct _obstack_chunk *new_chunk;
|
||||
register long new_size;
|
||||
register int obj_size = h->next_free - h->object_base;
|
||||
register int i;
|
||||
int already;
|
||||
register long obj_size = h->next_free - h->object_base;
|
||||
register long i;
|
||||
long already;
|
||||
|
||||
/* Compute size for new chunk. */
|
||||
new_size = (obj_size + length) + (obj_size >> 3) + 100;
|
||||
@@ -330,11 +335,11 @@ _obstack_newchunk (h, length)
|
||||
This is here for debugging.
|
||||
If you use it in a program, you are probably losing. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||
obstack.h because it is just for debugging. */
|
||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||
#endif
|
||||
# endif
|
||||
|
||||
int
|
||||
_obstack_allocated_p (h, obj)
|
||||
@@ -359,7 +364,7 @@ _obstack_allocated_p (h, obj)
|
||||
/* Free objects in obstack H, including OBJ and everything allocate
|
||||
more recently than OBJ. If OBJ is zero, free everything in H. */
|
||||
|
||||
#undef obstack_free
|
||||
# undef obstack_free
|
||||
|
||||
/* This function has two names with identical definitions.
|
||||
This is the first one, called from non-ANSI code. */
|
||||
@@ -445,32 +450,37 @@ _obstack_memory_used (h)
|
||||
}
|
||||
|
||||
/* Define the error handler. */
|
||||
#ifndef _
|
||||
# ifdef HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# ifndef _
|
||||
# define _(Str) gettext (Str)
|
||||
# ifndef _
|
||||
# ifdef HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# ifndef _
|
||||
# define _(Str) gettext (Str)
|
||||
# endif
|
||||
# else
|
||||
# define _(Str) (Str)
|
||||
# endif
|
||||
# else
|
||||
# define _(Str) (Str)
|
||||
# endif
|
||||
#endif
|
||||
# if defined _LIBC && defined USE_IN_LIBIO
|
||||
# include <libio/iolibio.h>
|
||||
# define fputs(s, f) _IO_fputs (s, f)
|
||||
# endif
|
||||
|
||||
static void
|
||||
print_and_abort ()
|
||||
{
|
||||
fputs (_("memory exhausted\n"), stderr);
|
||||
fputs (_("memory exhausted"), stderr);
|
||||
fputc ('\n', stderr);
|
||||
exit (obstack_exit_failure);
|
||||
}
|
||||
|
||||
#if 0
|
||||
# if 0
|
||||
/* These are now turned off because the applications do not use it
|
||||
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
|
||||
|
||||
/* Now define the functional versions of the obstack macros.
|
||||
Define them to simply use the corresponding macros to do the job. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
# if defined (__STDC__) && __STDC__
|
||||
/* These function definitions do not work with non-ANSI preprocessors;
|
||||
they won't pass through the macro names in parentheses. */
|
||||
|
||||
@@ -581,8 +591,8 @@ POINTER (obstack_copy0) (obstack, pointer, length)
|
||||
return obstack_copy0 (obstack, pointer, length);
|
||||
}
|
||||
|
||||
#endif /* __STDC__ */
|
||||
# endif /* __STDC__ */
|
||||
|
||||
#endif /* 0 */
|
||||
# endif /* 0 */
|
||||
|
||||
#endif /* !ELIDE_CODE */
|
||||
|
||||
179
lib/obstack.h
179
lib/obstack.h
@@ -1,5 +1,5 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
@@ -118,45 +118,39 @@ extern "C" {
|
||||
may ignore the byte-within-word field of the pointer. */
|
||||
|
||||
#ifndef __PTR_TO_INT
|
||||
#define __PTR_TO_INT(P) ((P) - (char *) 0)
|
||||
# define __PTR_TO_INT(P) ((P) - (char *) 0)
|
||||
#endif
|
||||
|
||||
#ifndef __INT_TO_PTR
|
||||
#define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
#endif
|
||||
|
||||
/* We need the type of the resulting object. In ANSI C it is ptrdiff_t
|
||||
but in traditional C it is usually long. If we are in ANSI C and
|
||||
don't already have ptrdiff_t get it. */
|
||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||
defined, as with GNU C, use that; that way we don't pollute the
|
||||
namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is
|
||||
available, include it and use ptrdiff_t. In traditional C, long is
|
||||
the best that we can do. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__ && ! defined (offsetof)
|
||||
#if defined (__GNUC__) && defined (IN_GCC)
|
||||
/* On Next machine, the system's stddef.h screws up if included
|
||||
after we have defined just ptrdiff_t, so include all of stddef.h.
|
||||
Otherwise, define just ptrdiff_t, which is all we need. */
|
||||
#ifndef __NeXT__
|
||||
#define __need_ptrdiff_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define PTR_INT_TYPE ptrdiff_t
|
||||
#ifdef __PTRDIFF_TYPE__
|
||||
# define PTR_INT_TYPE __PTRDIFF_TYPE__
|
||||
#else
|
||||
#define PTR_INT_TYPE long
|
||||
# ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
# define PTR_INT_TYPE ptrdiff_t
|
||||
# else
|
||||
# define PTR_INT_TYPE long
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_LIBC) || defined (HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
#if defined _LIBC || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
#else
|
||||
#ifdef memcpy
|
||||
#define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
#else
|
||||
#define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
|
||||
#endif
|
||||
# ifdef memcpy
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
# else
|
||||
# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct _obstack_chunk /* Lives at front of each chunk. */
|
||||
@@ -175,7 +169,7 @@ struct obstack /* control current object in current chunk */
|
||||
char *chunk_limit; /* address of char after current chunk */
|
||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||
int alignment_mask; /* Mask of alignment for each object. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
/* These prototypes vary based on `use_extra_arg', and we use
|
||||
casts to the prototypeless function type in all assignments,
|
||||
but having prototypes here quiets -Wstrict-prototypes. */
|
||||
@@ -199,7 +193,7 @@ struct obstack /* control current object in current chunk */
|
||||
|
||||
/* Declare the external functions we use; they are in obstack.c. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void _obstack_newchunk (struct obstack *, int);
|
||||
extern void _obstack_free (struct obstack *, void *);
|
||||
extern int _obstack_begin (struct obstack *, int, int,
|
||||
@@ -216,7 +210,7 @@ extern int _obstack_begin_1 ();
|
||||
extern int _obstack_memory_used ();
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
/* Do the function-declarations after the structs
|
||||
but before defining the macros. */
|
||||
@@ -262,9 +256,10 @@ int obstack_memory_used (struct obstack *obstack);
|
||||
so we do not declare them. */
|
||||
|
||||
/* Error handler called when `obstack_chunk_alloc' failed to allocate
|
||||
more memory. This can be set to a user defined function. The
|
||||
default action is to print a message and abort. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
more memory. This can be set to a user defined function which
|
||||
should either abort gracefully or use longjump - but shouldn't
|
||||
return. The default action is to print a message and abort. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void (*obstack_alloc_failed_handler) (void);
|
||||
#else
|
||||
extern void (*obstack_alloc_failed_handler) ();
|
||||
@@ -293,53 +288,53 @@ extern int obstack_exit_failure;
|
||||
|
||||
/* To prevent prototype warnings provide complete argument list in
|
||||
standard C version. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
#define obstack_init(h) \
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
#define obstack_begin(h, size) \
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
|
||||
|
||||
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) (void *, long)) (chunkfun), \
|
||||
(void (*) (void *, void *)) (freefun), (arg))
|
||||
|
||||
#define obstack_chunkfun(h, newchunkfun) \
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
|
||||
|
||||
#define obstack_freefun(h, newfreefun) \
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
|
||||
|
||||
#else
|
||||
|
||||
#define obstack_init(h) \
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
|
||||
#define obstack_begin(h, size) \
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
|
||||
#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun))
|
||||
|
||||
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
|
||||
|
||||
#define obstack_chunkfun(h, newchunkfun) \
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
|
||||
|
||||
#define obstack_freefun(h, newfreefun) \
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)()) (newfreefun))
|
||||
|
||||
#endif
|
||||
@@ -350,30 +345,30 @@ extern int obstack_exit_failure;
|
||||
|
||||
#define obstack_memory_used(h) _obstack_memory_used (h)
|
||||
|
||||
#if defined (__GNUC__) && defined (__STDC__) && __STDC__
|
||||
#if defined __GNUC__ && defined __STDC__ && __STDC__
|
||||
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
|
||||
does not implement __extension__. But that compiler doesn't define
|
||||
__GNUC_MINOR__. */
|
||||
#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
|
||||
#define __extension__
|
||||
#endif
|
||||
# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
|
||||
# define __extension__
|
||||
# endif
|
||||
|
||||
/* For GNU C, if not -traditional,
|
||||
we can define these macros to compute all args only once
|
||||
without using a global variable.
|
||||
Also, we can avoid using the `temp' slot, to make faster code. */
|
||||
|
||||
#define obstack_object_size(OBSTACK) \
|
||||
# define obstack_object_size(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->next_free - __o->object_base); })
|
||||
|
||||
#define obstack_room(OBSTACK) \
|
||||
# define obstack_room(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->chunk_limit - __o->next_free); })
|
||||
|
||||
#define obstack_make_room(OBSTACK,length) \
|
||||
# define obstack_make_room(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
@@ -381,12 +376,12 @@ __extension__ \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_empty_p(OBSTACK) \
|
||||
# define obstack_empty_p(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
|
||||
|
||||
#define obstack_grow(OBSTACK,where,length) \
|
||||
# define obstack_grow(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
@@ -396,7 +391,7 @@ __extension__ \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_grow0(OBSTACK,where,length) \
|
||||
# define obstack_grow0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
@@ -407,7 +402,7 @@ __extension__ \
|
||||
*(__o->next_free)++ = 0; \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_1grow(OBSTACK,datum) \
|
||||
# define obstack_1grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + 1 > __o->chunk_limit) \
|
||||
@@ -419,7 +414,7 @@ __extension__ \
|
||||
and that the data added so far to the current object
|
||||
shares that much alignment. */
|
||||
|
||||
#define obstack_ptr_grow(OBSTACK,datum) \
|
||||
# define obstack_ptr_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||
@@ -427,7 +422,7 @@ __extension__ \
|
||||
*((void **)__o->next_free)++ = ((void *)datum); \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_int_grow(OBSTACK,datum) \
|
||||
# define obstack_int_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
|
||||
@@ -435,10 +430,10 @@ __extension__ \
|
||||
*((int *)__o->next_free)++ = ((int)datum); \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
|
||||
#define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
|
||||
#define obstack_blank(OBSTACK,length) \
|
||||
# define obstack_blank(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
@@ -447,19 +442,19 @@ __extension__ \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
#define obstack_alloc(OBSTACK,length) \
|
||||
# define obstack_alloc(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_blank (__h, (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
#define obstack_copy(OBSTACK,where,length) \
|
||||
# define obstack_copy(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow (__h, (where), (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
#define obstack_copy0(OBSTACK,where,length) \
|
||||
# define obstack_copy0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow0 (__h, (where), (length)); \
|
||||
@@ -467,7 +462,7 @@ __extension__ \
|
||||
|
||||
/* The local variable is named __o1 to avoid a name conflict
|
||||
when obstack_blank is called. */
|
||||
#define obstack_finish(OBSTACK) \
|
||||
# define obstack_finish(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o1 = (OBSTACK); \
|
||||
void *value; \
|
||||
@@ -483,23 +478,23 @@ __extension__ \
|
||||
__o1->object_base = __o1->next_free; \
|
||||
value; })
|
||||
|
||||
#define obstack_free(OBSTACK, OBJ) \
|
||||
# define obstack_free(OBSTACK, OBJ) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
void *__obj = (OBJ); \
|
||||
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
|
||||
__o->next_free = __o->object_base = __obj; \
|
||||
__o->next_free = __o->object_base = (char *)__obj; \
|
||||
else (obstack_free) (__o, __obj); })
|
||||
|
||||
#else /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
#define obstack_object_size(h) \
|
||||
# define obstack_object_size(h) \
|
||||
(unsigned) ((h)->next_free - (h)->object_base)
|
||||
|
||||
#define obstack_room(h) \
|
||||
# define obstack_room(h) \
|
||||
(unsigned) ((h)->chunk_limit - (h)->next_free)
|
||||
|
||||
#define obstack_empty_p(h) \
|
||||
# define obstack_empty_p(h) \
|
||||
((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
|
||||
|
||||
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
|
||||
@@ -508,19 +503,19 @@ __extension__ \
|
||||
Casting the third operand to void was tried before,
|
||||
but some compilers won't accept it. */
|
||||
|
||||
#define obstack_make_room(h,length) \
|
||||
# define obstack_make_room(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
|
||||
|
||||
#define obstack_grow(h,where,length) \
|
||||
# define obstack_grow(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp)
|
||||
|
||||
#define obstack_grow0(h,where,length) \
|
||||
# define obstack_grow0(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
|
||||
@@ -528,40 +523,40 @@ __extension__ \
|
||||
(h)->next_free += (h)->temp, \
|
||||
*((h)->next_free)++ = 0)
|
||||
|
||||
#define obstack_1grow(h,datum) \
|
||||
# define obstack_1grow(h,datum) \
|
||||
( (((h)->next_free + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), 1), 0) : 0), \
|
||||
(*((h)->next_free)++ = (datum)))
|
||||
|
||||
#define obstack_ptr_grow(h,datum) \
|
||||
# define obstack_ptr_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
|
||||
(*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
|
||||
|
||||
#define obstack_int_grow(h,datum) \
|
||||
# define obstack_int_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
|
||||
|
||||
#define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
|
||||
#define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
|
||||
#define obstack_blank(h,length) \
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
((h)->next_free += (h)->temp))
|
||||
|
||||
#define obstack_alloc(h,length) \
|
||||
# define obstack_alloc(h,length) \
|
||||
(obstack_blank ((h), (length)), obstack_finish ((h)))
|
||||
|
||||
#define obstack_copy(h,where,length) \
|
||||
# define obstack_copy(h,where,length) \
|
||||
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
#define obstack_copy0(h,where,length) \
|
||||
# define obstack_copy0(h,where,length) \
|
||||
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
#define obstack_finish(h) \
|
||||
# define obstack_finish(h) \
|
||||
( ((h)->next_free == (h)->object_base \
|
||||
? (((h)->maybe_empty_object = 1), 0) \
|
||||
: 0), \
|
||||
@@ -575,21 +570,21 @@ __extension__ \
|
||||
(h)->object_base = (h)->next_free, \
|
||||
__INT_TO_PTR ((h)->temp))
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define obstack_free(h,obj) \
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
|
||||
#else
|
||||
#define obstack_free(h,obj) \
|
||||
# else
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#endif /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
|
||||
666
lib/regex.c
666
lib/regex.c
@@ -2,7 +2,7 @@
|
||||
version 0.12.
|
||||
(Implements POSIX draft P1003.2/D11.2, except for some of the
|
||||
internationalization features.)
|
||||
Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993-1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
@@ -78,7 +78,12 @@
|
||||
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
|
||||
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
|
||||
|
||||
#define btowc __btowc
|
||||
# define btowc __btowc
|
||||
|
||||
/* We are also using some library internals. */
|
||||
# include <locale/localeinfo.h>
|
||||
# include <locale/elem-hash.h>
|
||||
# include <langinfo.h>
|
||||
#endif
|
||||
|
||||
/* This is for other GNU distributions with internationalized messages. */
|
||||
@@ -164,47 +169,15 @@ char *realloc ();
|
||||
# define SWITCH_ENUM_CAST(x) (x)
|
||||
# endif
|
||||
|
||||
/* How many characters in the character set. */
|
||||
# define CHAR_SET_SIZE 256
|
||||
|
||||
# ifdef SYNTAX_TABLE
|
||||
|
||||
extern char *re_syntax_table;
|
||||
|
||||
# else /* not SYNTAX_TABLE */
|
||||
|
||||
static char re_syntax_table[CHAR_SET_SIZE];
|
||||
|
||||
static void
|
||||
init_syntax_once ()
|
||||
{
|
||||
register int c;
|
||||
static int done = 0;
|
||||
|
||||
if (done)
|
||||
return;
|
||||
|
||||
bzero (re_syntax_table, sizeof re_syntax_table);
|
||||
|
||||
for (c = 'a'; c <= 'z'; c++)
|
||||
re_syntax_table[c] = Sword;
|
||||
|
||||
for (c = 'A'; c <= 'Z'; c++)
|
||||
re_syntax_table[c] = Sword;
|
||||
|
||||
for (c = '0'; c <= '9'; c++)
|
||||
re_syntax_table[c] = Sword;
|
||||
|
||||
re_syntax_table['_'] = Sword;
|
||||
|
||||
done = 1;
|
||||
}
|
||||
|
||||
# endif /* not SYNTAX_TABLE */
|
||||
|
||||
# define SYNTAX(c) re_syntax_table[c]
|
||||
|
||||
#endif /* not emacs */
|
||||
|
||||
#if defined _LIBC || HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef MB_LEN_MAX
|
||||
# define MB_LEN_MAX 1
|
||||
#endif
|
||||
|
||||
/* Get the interface, including the syntax bits. */
|
||||
#include <regex.h>
|
||||
@@ -276,6 +249,43 @@ init_syntax_once ()
|
||||
# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
|
||||
#endif
|
||||
|
||||
#ifndef emacs
|
||||
/* How many characters in the character set. */
|
||||
# define CHAR_SET_SIZE 256
|
||||
|
||||
# ifdef SYNTAX_TABLE
|
||||
|
||||
extern char *re_syntax_table;
|
||||
|
||||
# else /* not SYNTAX_TABLE */
|
||||
|
||||
static char re_syntax_table[CHAR_SET_SIZE];
|
||||
|
||||
static void
|
||||
init_syntax_once ()
|
||||
{
|
||||
register int c;
|
||||
static int done = 0;
|
||||
|
||||
if (done)
|
||||
return;
|
||||
bzero (re_syntax_table, sizeof re_syntax_table);
|
||||
|
||||
for (c = 0; c < CHAR_SET_SIZE; ++c)
|
||||
if (ISALNUM (c))
|
||||
re_syntax_table[c] = Sword;
|
||||
|
||||
re_syntax_table['_'] = Sword;
|
||||
|
||||
done = 1;
|
||||
}
|
||||
|
||||
# endif /* not SYNTAX_TABLE */
|
||||
|
||||
# define SYNTAX(c) re_syntax_table[(unsigned char) (c)]
|
||||
|
||||
#endif /* emacs */
|
||||
|
||||
/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
|
||||
use `alloca' instead of `malloc'. This is because using malloc in
|
||||
re_search* or re_match* could cause memory leaks when C-g is used in
|
||||
@@ -615,7 +625,7 @@ extract_number_and_incr (destination, source)
|
||||
/* It is useful to test things that ``must'' be true when debugging. */
|
||||
# include <assert.h>
|
||||
|
||||
static int debug = 0;
|
||||
static int debug;
|
||||
|
||||
# define DEBUG_STATEMENT(e) e
|
||||
# define DEBUG_PRINT1(x) if (debug) printf (x)
|
||||
@@ -681,7 +691,11 @@ print_partial_compiled_pattern (start, end)
|
||||
/* Loop over pattern commands. */
|
||||
while (p < pend)
|
||||
{
|
||||
printf ("%d:\t", p - start);
|
||||
#ifdef _LIBC
|
||||
printf ("%t:\t", p - start);
|
||||
#else
|
||||
printf ("%ld:\t", (long int) (p - start));
|
||||
#endif
|
||||
|
||||
switch ((re_opcode_t) *p++)
|
||||
{
|
||||
@@ -771,17 +785,30 @@ print_partial_compiled_pattern (start, end)
|
||||
|
||||
case on_failure_jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/on_failure_jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/on_failure_jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/on_failure_jump to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case on_failure_keep_string_jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/on_failure_keep_string_jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/on_failure_keep_string_jump to %ld",
|
||||
(long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case dummy_failure_jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/dummy_failure_jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/dummy_failure_jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/dummy_failure_jump to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case push_dummy_failure:
|
||||
@@ -790,29 +817,50 @@ print_partial_compiled_pattern (start, end)
|
||||
|
||||
case maybe_pop_jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/maybe_pop_jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/maybe_pop_jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/maybe_pop_jump to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case pop_failure_jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/pop_failure_jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/pop_failure_jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/pop_failure_jump to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case jump_past_alt:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/jump_past_alt to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/jump_past_alt to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/jump_past_alt to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case jump:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
printf ("/jump to %d", p + mcnt - start);
|
||||
#ifdef _LIBC
|
||||
printf ("/jump to %t", p + mcnt - start);
|
||||
#else
|
||||
printf ("/jump to %ld", (long int) (p + mcnt - start));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case succeed_n:
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
p1 = p + mcnt;
|
||||
extract_number_and_incr (&mcnt2, &p);
|
||||
printf ("/succeed_n to %d, %d times", p1 - start, mcnt2);
|
||||
#ifdef _LIBC
|
||||
printf ("/succeed_n to %t, %d times", p1 - start, mcnt2);
|
||||
#else
|
||||
printf ("/succeed_n to %ld, %d times",
|
||||
(long int) (p1 - start), mcnt2);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case jump_n:
|
||||
@@ -826,7 +874,12 @@ print_partial_compiled_pattern (start, end)
|
||||
extract_number_and_incr (&mcnt, &p);
|
||||
p1 = p + mcnt;
|
||||
extract_number_and_incr (&mcnt2, &p);
|
||||
printf ("/set_number_at location %d to %d", p1 - start, mcnt2);
|
||||
#ifdef _LIBC
|
||||
printf ("/set_number_at location %t to %d", p1 - start, mcnt2);
|
||||
#else
|
||||
printf ("/set_number_at location %ld to %d",
|
||||
(long int) (p1 - start), mcnt2);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case wordbound:
|
||||
@@ -893,7 +946,11 @@ print_partial_compiled_pattern (start, end)
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
printf ("%d:\tend of pattern.\n", p - start);
|
||||
#ifdef _LIBC
|
||||
printf ("%t:\tend of pattern.\n", p - start);
|
||||
#else
|
||||
printf ("%ld:\tend of pattern.\n", (long int) (p - start));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -913,7 +970,11 @@ print_compiled_pattern (bufp)
|
||||
print_fastmap (bufp->fastmap);
|
||||
}
|
||||
|
||||
printf ("re_nsub: %d\t", bufp->re_nsub);
|
||||
#ifdef _LIBC
|
||||
printf ("re_nsub: %Zd\t", bufp->re_nsub);
|
||||
#else
|
||||
printf ("re_nsub: %ld\t", (long int) bufp->re_nsub);
|
||||
#endif
|
||||
printf ("regs_alloc: %d\t", bufp->regs_allocated);
|
||||
printf ("can_be_null: %d\t", bufp->can_be_null);
|
||||
printf ("newline_anchor: %d\n", bufp->newline_anchor);
|
||||
@@ -1013,25 +1074,79 @@ weak_alias (__re_set_syntax, re_set_syntax)
|
||||
POSIX doesn't require that we do anything for REG_NOERROR,
|
||||
but why not be nice? */
|
||||
|
||||
static const char *re_error_msgid[] =
|
||||
static const char re_error_msgid[] =
|
||||
{
|
||||
gettext_noop ("Success"), /* REG_NOERROR */
|
||||
gettext_noop ("No match"), /* REG_NOMATCH */
|
||||
gettext_noop ("Invalid regular expression"), /* REG_BADPAT */
|
||||
gettext_noop ("Invalid collation character"), /* REG_ECOLLATE */
|
||||
gettext_noop ("Invalid character class name"), /* REG_ECTYPE */
|
||||
gettext_noop ("Trailing backslash"), /* REG_EESCAPE */
|
||||
gettext_noop ("Invalid back reference"), /* REG_ESUBREG */
|
||||
gettext_noop ("Unmatched [ or [^"), /* REG_EBRACK */
|
||||
gettext_noop ("Unmatched ( or \\("), /* REG_EPAREN */
|
||||
gettext_noop ("Unmatched \\{"), /* REG_EBRACE */
|
||||
gettext_noop ("Invalid content of \\{\\}"), /* REG_BADBR */
|
||||
gettext_noop ("Invalid range end"), /* REG_ERANGE */
|
||||
gettext_noop ("Memory exhausted"), /* REG_ESPACE */
|
||||
gettext_noop ("Invalid preceding regular expression"), /* REG_BADRPT */
|
||||
gettext_noop ("Premature end of regular expression"), /* REG_EEND */
|
||||
gettext_noop ("Regular expression too big"), /* REG_ESIZE */
|
||||
gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */
|
||||
#define REG_NOERROR_IDX 0
|
||||
gettext_noop ("Success") /* REG_NOERROR */
|
||||
"\0"
|
||||
#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
|
||||
gettext_noop ("No match") /* REG_NOMATCH */
|
||||
"\0"
|
||||
#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
|
||||
gettext_noop ("Invalid regular expression") /* REG_BADPAT */
|
||||
"\0"
|
||||
#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
|
||||
gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
|
||||
"\0"
|
||||
#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
|
||||
gettext_noop ("Invalid character class name") /* REG_ECTYPE */
|
||||
"\0"
|
||||
#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
|
||||
gettext_noop ("Trailing backslash") /* REG_EESCAPE */
|
||||
"\0"
|
||||
#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
|
||||
gettext_noop ("Invalid back reference") /* REG_ESUBREG */
|
||||
"\0"
|
||||
#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
|
||||
gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
|
||||
"\0"
|
||||
#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
|
||||
gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
|
||||
"\0"
|
||||
#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
|
||||
gettext_noop ("Unmatched \\{") /* REG_EBRACE */
|
||||
"\0"
|
||||
#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
|
||||
gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
|
||||
"\0"
|
||||
#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
|
||||
gettext_noop ("Invalid range end") /* REG_ERANGE */
|
||||
"\0"
|
||||
#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
|
||||
gettext_noop ("Memory exhausted") /* REG_ESPACE */
|
||||
"\0"
|
||||
#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
|
||||
gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
|
||||
"\0"
|
||||
#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
|
||||
gettext_noop ("Premature end of regular expression") /* REG_EEND */
|
||||
"\0"
|
||||
#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
|
||||
gettext_noop ("Regular expression too big") /* REG_ESIZE */
|
||||
"\0"
|
||||
#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
|
||||
gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
|
||||
};
|
||||
|
||||
static const size_t re_error_msgid_idx[] =
|
||||
{
|
||||
REG_NOERROR_IDX,
|
||||
REG_NOMATCH_IDX,
|
||||
REG_BADPAT_IDX,
|
||||
REG_ECOLLATE_IDX,
|
||||
REG_ECTYPE_IDX,
|
||||
REG_EESCAPE_IDX,
|
||||
REG_ESUBREG_IDX,
|
||||
REG_EBRACK_IDX,
|
||||
REG_EPAREN_IDX,
|
||||
REG_EBRACE_IDX,
|
||||
REG_BADBR_IDX,
|
||||
REG_ERANGE_IDX,
|
||||
REG_ESPACE_IDX,
|
||||
REG_BADRPT_IDX,
|
||||
REG_EEND_IDX,
|
||||
REG_ESIZE_IDX,
|
||||
REG_ERPAREN_IDX
|
||||
};
|
||||
|
||||
/* Avoiding alloca during matching, to placate r_alloc. */
|
||||
@@ -1514,7 +1629,8 @@ static boolean at_begline_loc_p _RE_ARGS ((const char *pattern, const char *p,
|
||||
reg_syntax_t syntax));
|
||||
static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend,
|
||||
reg_syntax_t syntax));
|
||||
static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr,
|
||||
static reg_errcode_t compile_range _RE_ARGS ((unsigned int range_start,
|
||||
const char **p_ptr,
|
||||
const char *pend,
|
||||
char *translate,
|
||||
reg_syntax_t syntax,
|
||||
@@ -1712,7 +1828,7 @@ typedef struct
|
||||
{ if (p != pend) \
|
||||
{ \
|
||||
PATFETCH (c); \
|
||||
while (ISDIGIT (c)) \
|
||||
while ('0' <= c && c <= '9') \
|
||||
{ \
|
||||
if (num < 0) \
|
||||
num = 0; \
|
||||
@@ -2118,6 +2234,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
case '[':
|
||||
{
|
||||
boolean had_char_class = false;
|
||||
unsigned int range_start = 0xffffffff;
|
||||
|
||||
if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
|
||||
|
||||
@@ -2161,6 +2278,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
PATFETCH (c1);
|
||||
SET_LIST_BIT (c1);
|
||||
range_start = c1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2185,8 +2303,10 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
&& *p != ']')
|
||||
{
|
||||
reg_errcode_t ret
|
||||
= compile_range (&p, pend, translate, syntax, b);
|
||||
= compile_range (range_start, &p, pend, translate,
|
||||
syntax, b);
|
||||
if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
|
||||
range_start = 0xffffffff;
|
||||
}
|
||||
|
||||
else if (p[0] == '-' && p[1] != ']')
|
||||
@@ -2196,8 +2316,9 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
/* Move past the `-'. */
|
||||
PATFETCH (c1);
|
||||
|
||||
ret = compile_range (&p, pend, translate, syntax, b);
|
||||
ret = compile_range (c, &p, pend, translate, syntax, b);
|
||||
if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
|
||||
range_start = 0xffffffff;
|
||||
}
|
||||
|
||||
/* See if we're at the beginning of a possible character
|
||||
@@ -2320,13 +2441,289 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
PATUNFETCH;
|
||||
SET_LIST_BIT ('[');
|
||||
SET_LIST_BIT (':');
|
||||
range_start = ':';
|
||||
had_char_class = false;
|
||||
}
|
||||
}
|
||||
else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == '=')
|
||||
{
|
||||
unsigned char str[MB_LEN_MAX + 1];
|
||||
#ifdef _LIBC
|
||||
uint32_t nrules =
|
||||
_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
||||
#endif
|
||||
|
||||
PATFETCH (c);
|
||||
c1 = 0;
|
||||
|
||||
/* If pattern is `[[='. */
|
||||
if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
PATFETCH (c);
|
||||
if ((c == '=' && *p == ']') || p == pend)
|
||||
break;
|
||||
if (c1 < MB_LEN_MAX)
|
||||
str[c1++] = c;
|
||||
else
|
||||
/* This is in any case an invalid class name. */
|
||||
str[0] = '\0';
|
||||
}
|
||||
str[c1] = '\0';
|
||||
|
||||
if (c == '=' && *p == ']' && str[0] != '\0')
|
||||
{
|
||||
/* If we have no collation data we use the default
|
||||
collation in which each character is in a class
|
||||
by itself. It also means that ASCII is the
|
||||
character set and therefore we cannot have character
|
||||
with more than one byte in the multibyte
|
||||
representation. */
|
||||
#ifdef _LIBC
|
||||
if (nrules == 0)
|
||||
#endif
|
||||
{
|
||||
if (c1 != 1)
|
||||
FREE_STACK_RETURN (REG_ECOLLATE);
|
||||
|
||||
/* Throw away the ] at the end of the equivalence
|
||||
class. */
|
||||
PATFETCH (c);
|
||||
|
||||
/* Set the bit for the character. */
|
||||
SET_LIST_BIT (str[0]);
|
||||
}
|
||||
#ifdef _LIBC
|
||||
else
|
||||
{
|
||||
/* Try to match the byte sequence in `str' against
|
||||
those known to the collate implementation.
|
||||
First find out whether the bytes in `str' are
|
||||
actually from exactly one character. */
|
||||
const int32_t *table;
|
||||
const unsigned char *weights;
|
||||
const unsigned char *extra;
|
||||
const int32_t *indirect;
|
||||
int32_t idx;
|
||||
const unsigned char *cp = str;
|
||||
int ch;
|
||||
|
||||
/* This #include defines a local function! */
|
||||
# include <locale/weight.h>
|
||||
|
||||
table = (const int32_t *)
|
||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
||||
weights = (const unsigned char *)
|
||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
|
||||
extra = (const unsigned char *)
|
||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
||||
indirect = (const int32_t *)
|
||||
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
|
||||
|
||||
idx = findidx (&cp);
|
||||
if (idx == 0 || cp < str + c1)
|
||||
/* This is no valid character. */
|
||||
FREE_STACK_RETURN (REG_ECOLLATE);
|
||||
|
||||
/* Throw away the ] at the end of the equivalence
|
||||
class. */
|
||||
PATFETCH (c);
|
||||
|
||||
/* Now we have to go throught the whole table
|
||||
and find all characters which have the same
|
||||
first level weight.
|
||||
|
||||
XXX Note that this is not entirely correct.
|
||||
we would have to match multibyte sequences
|
||||
but this is not possible with the current
|
||||
implementation. */
|
||||
for (ch = 1; ch < 256; ++ch)
|
||||
/* XXX This test would have to be changed if we
|
||||
would allow matching multibyte sequences. */
|
||||
if (table[ch] > 0)
|
||||
{
|
||||
int32_t idx2 = table[ch];
|
||||
size_t len = weights[idx2];
|
||||
|
||||
/* Test whether the lenghts match. */
|
||||
if (weights[idx] == len)
|
||||
{
|
||||
/* They do. New compare the bytes of
|
||||
the weight. */
|
||||
size_t cnt = 0;
|
||||
|
||||
while (cnt < len
|
||||
&& (weights[idx + 1 + cnt]
|
||||
== weights[idx2 + 1 + cnt]))
|
||||
++len;
|
||||
|
||||
if (cnt == len)
|
||||
/* They match. Mark the character as
|
||||
acceptable. */
|
||||
SET_LIST_BIT (ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
had_char_class = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
c1++;
|
||||
while (c1--)
|
||||
PATUNFETCH;
|
||||
SET_LIST_BIT ('[');
|
||||
SET_LIST_BIT ('=');
|
||||
range_start = '=';
|
||||
had_char_class = false;
|
||||
}
|
||||
}
|
||||
else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == '.')
|
||||
{
|
||||
unsigned char str[128]; /* Should be large enough. */
|
||||
#ifdef _LIBC
|
||||
uint32_t nrules =
|
||||
_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
||||
#endif
|
||||
|
||||
PATFETCH (c);
|
||||
c1 = 0;
|
||||
|
||||
/* If pattern is `[[='. */
|
||||
if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
PATFETCH (c);
|
||||
if ((c == '.' && *p == ']') || p == pend)
|
||||
break;
|
||||
if (c1 < sizeof (str))
|
||||
str[c1++] = c;
|
||||
else
|
||||
/* This is in any case an invalid class name. */
|
||||
str[0] = '\0';
|
||||
}
|
||||
str[c1] = '\0';
|
||||
|
||||
if (c == '.' && *p == ']' && str[0] != '\0')
|
||||
{
|
||||
/* If we have no collation data we use the default
|
||||
collation in which each character is the name
|
||||
for its own class which contains only the one
|
||||
character. It also means that ASCII is the
|
||||
character set and therefore we cannot have character
|
||||
with more than one byte in the multibyte
|
||||
representation. */
|
||||
#ifdef _LIBC
|
||||
if (nrules == 0)
|
||||
#endif
|
||||
{
|
||||
if (c1 != 1)
|
||||
FREE_STACK_RETURN (REG_ECOLLATE);
|
||||
|
||||
/* Throw away the ] at the end of the equivalence
|
||||
class. */
|
||||
PATFETCH (c);
|
||||
|
||||
/* Set the bit for the character. */
|
||||
SET_LIST_BIT (str[0]);
|
||||
range_start = ((const unsigned char *) str)[0];
|
||||
}
|
||||
#ifdef _LIBC
|
||||
else
|
||||
{
|
||||
/* Try to match the byte sequence in `str' against
|
||||
those known to the collate implementation.
|
||||
First find out whether the bytes in `str' are
|
||||
actually from exactly one character. */
|
||||
int32_t table_size;
|
||||
const int32_t *symb_table;
|
||||
const unsigned char *extra;
|
||||
int32_t idx;
|
||||
int32_t elem;
|
||||
int32_t second;
|
||||
int32_t hash;
|
||||
|
||||
table_size =
|
||||
_NL_CURRENT_WORD (LC_COLLATE,
|
||||
_NL_COLLATE_SYMB_HASH_SIZEMB);
|
||||
symb_table = (const int32_t *)
|
||||
_NL_CURRENT (LC_COLLATE,
|
||||
_NL_COLLATE_SYMB_TABLEMB);
|
||||
extra = (const unsigned char *)
|
||||
_NL_CURRENT (LC_COLLATE,
|
||||
_NL_COLLATE_SYMB_EXTRAMB);
|
||||
|
||||
/* Locate the character in the hashing table. */
|
||||
hash = elem_hash (str, c1);
|
||||
|
||||
idx = 0;
|
||||
elem = hash % table_size;
|
||||
second = hash % (table_size - 2);
|
||||
while (symb_table[2 * elem] != 0)
|
||||
{
|
||||
/* First compare the hashing value. */
|
||||
if (symb_table[2 * elem] == hash
|
||||
&& c1 == extra[symb_table[2 * elem + 1]]
|
||||
&& memcmp (str,
|
||||
&extra[symb_table[2 * elem + 1]
|
||||
+ 1],
|
||||
c1) == 0)
|
||||
{
|
||||
/* Yep, this is the entry. */
|
||||
idx = symb_table[2 * elem + 1];
|
||||
idx += 1 + extra[idx];
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next entry. */
|
||||
elem += second;
|
||||
}
|
||||
|
||||
if (symb_table[2 * elem] == 0)
|
||||
/* This is no valid character. */
|
||||
FREE_STACK_RETURN (REG_ECOLLATE);
|
||||
|
||||
/* Throw away the ] at the end of the equivalence
|
||||
class. */
|
||||
PATFETCH (c);
|
||||
|
||||
/* Now add the multibyte character(s) we found
|
||||
to the acceptabed list.
|
||||
|
||||
XXX Note that this is not entirely correct.
|
||||
we would have to match multibyte sequences
|
||||
but this is not possible with the current
|
||||
implementation. Also, we have to match
|
||||
collating symbols, which expand to more than
|
||||
one file, as a whole and not allow the
|
||||
individual bytes. */
|
||||
c1 = extra[idx++];
|
||||
if (c1 == 1)
|
||||
range_start = extra[idx];
|
||||
while (c1-- > 0)
|
||||
SET_LIST_BIT (extra[idx++]);
|
||||
}
|
||||
#endif
|
||||
had_char_class = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
c1++;
|
||||
while (c1--)
|
||||
PATUNFETCH;
|
||||
SET_LIST_BIT ('[');
|
||||
SET_LIST_BIT ('.');
|
||||
range_start = '.';
|
||||
had_char_class = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
had_char_class = false;
|
||||
SET_LIST_BIT (c);
|
||||
range_start = c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2553,8 +2950,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
if (!(syntax & RE_INTERVALS)
|
||||
/* If we're at `\{' and it's not the open-interval
|
||||
operator. */
|
||||
|| ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
|| (p - 2 == pattern && p == pend))
|
||||
|| (syntax & RE_NO_BK_BRACES))
|
||||
goto normal_backslash;
|
||||
|
||||
handle_interval:
|
||||
@@ -2568,7 +2964,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
if (p == pend)
|
||||
{
|
||||
if (syntax & RE_NO_BK_BRACES)
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_EBRACE);
|
||||
@@ -2579,7 +2975,12 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
if (c == ',')
|
||||
{
|
||||
GET_UNSIGNED_NUMBER (upper_bound);
|
||||
if (upper_bound < 0) upper_bound = RE_DUP_MAX;
|
||||
if ((!(syntax & RE_NO_BK_BRACES) && c != '\\')
|
||||
|| ((syntax & RE_NO_BK_BRACES) && c != '}'))
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
|
||||
if (upper_bound < 0)
|
||||
upper_bound = RE_DUP_MAX;
|
||||
}
|
||||
else
|
||||
/* Interval such as `{1}' => match exactly once. */
|
||||
@@ -2588,7 +2989,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
if (lower_bound < 0 || upper_bound > RE_DUP_MAX
|
||||
|| lower_bound > upper_bound)
|
||||
{
|
||||
if (syntax & RE_NO_BK_BRACES)
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
@@ -2603,7 +3004,7 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
if (c != '}')
|
||||
{
|
||||
if (syntax & RE_NO_BK_BRACES)
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
@@ -3076,49 +3477,53 @@ group_in_compile_stack (compile_stack, regnum)
|
||||
`regex_compile' itself. */
|
||||
|
||||
static reg_errcode_t
|
||||
compile_range (p_ptr, pend, translate, syntax, b)
|
||||
const char **p_ptr, *pend;
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
reg_syntax_t syntax;
|
||||
unsigned char *b;
|
||||
compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
|
||||
unsigned int range_start_char;
|
||||
const char **p_ptr, *pend;
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
reg_syntax_t syntax;
|
||||
unsigned char *b;
|
||||
{
|
||||
unsigned this_char;
|
||||
|
||||
const char *p = *p_ptr;
|
||||
unsigned int range_start, range_end;
|
||||
reg_errcode_t ret;
|
||||
char range_start[2];
|
||||
char range_end[2];
|
||||
char ch[2];
|
||||
|
||||
if (p == pend)
|
||||
return REG_ERANGE;
|
||||
|
||||
/* Even though the pattern is a signed `char *', we need to fetch
|
||||
with unsigned char *'s; if the high bit of the pattern character
|
||||
is set, the range endpoints will be negative if we fetch using a
|
||||
signed char *.
|
||||
|
||||
We also want to fetch the endpoints without translating them; the
|
||||
/* Fetch the endpoints without translating them; the
|
||||
appropriate translation is done in the bit-setting loop below. */
|
||||
/* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */
|
||||
range_start = ((const unsigned char *) p)[-2];
|
||||
range_end = ((const unsigned char *) p)[0];
|
||||
range_start[0] = range_start_char;
|
||||
range_start[1] = '\0';
|
||||
range_end[0] = p[0];
|
||||
range_end[1] = '\0';
|
||||
|
||||
/* Have to increment the pointer into the pattern string, so the
|
||||
caller isn't still at the ending character. */
|
||||
(*p_ptr)++;
|
||||
|
||||
/* If the start is after the end, the range is empty. */
|
||||
if (range_start > range_end)
|
||||
return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
|
||||
/* Report an error if the range is empty and the syntax prohibits this. */
|
||||
ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
|
||||
|
||||
/* Here we see why `this_char' has to be larger than an `unsigned
|
||||
char' -- the range is inclusive, so if `range_end' == 0xff
|
||||
(assuming 8-bit characters), we would otherwise go into an infinite
|
||||
loop, since all characters <= 0xff. */
|
||||
for (this_char = range_start; this_char <= range_end; this_char++)
|
||||
char' -- we would otherwise go into an infinite loop, since all
|
||||
characters <= 0xff. */
|
||||
ch[1] = '\0';
|
||||
for (this_char = 0; this_char <= (unsigned char) -1; ++this_char)
|
||||
{
|
||||
SET_LIST_BIT (TRANSLATE (this_char));
|
||||
ch[0] = this_char;
|
||||
if (strcoll (range_start, ch) <= 0 && strcoll (ch, range_end) <= 0)
|
||||
{
|
||||
SET_LIST_BIT (TRANSLATE (this_char));
|
||||
ret = REG_NOERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return REG_NOERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
|
||||
@@ -3848,7 +4253,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
fail_stack_type fail_stack;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
static unsigned failure_id = 0;
|
||||
static unsigned failure_id;
|
||||
unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
|
||||
#endif
|
||||
|
||||
@@ -4779,26 +5184,15 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
}
|
||||
else if ((re_opcode_t) *p2 == charset)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
register unsigned char c
|
||||
= *p2 == (unsigned char) endline ? '\n' : p2[2];
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* We win if the first character of the loop is not part
|
||||
of the charset. */
|
||||
if ((re_opcode_t) p1[3] == exactn
|
||||
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
|
||||
&& (p2[2 + p1[5] / BYTEWIDTH]
|
||||
& (1 << (p1[5] % BYTEWIDTH)))))
|
||||
#else
|
||||
if ((re_opcode_t) p1[3] == exactn
|
||||
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[4]
|
||||
&& (p2[2 + p1[4] / BYTEWIDTH]
|
||||
& (1 << (p1[4] % BYTEWIDTH)))))
|
||||
#endif
|
||||
{
|
||||
p[-3] = (unsigned char) pop_failure_jump;
|
||||
DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
|
||||
c, p1[5]);
|
||||
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
|
||||
&& (p2[2 + p1[5] / BYTEWIDTH]
|
||||
& (1 << (p1[5] % BYTEWIDTH)))))
|
||||
{
|
||||
p[-3] = (unsigned char) pop_failure_jump;
|
||||
DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
|
||||
}
|
||||
|
||||
else if ((re_opcode_t) p1[3] == charset_not)
|
||||
@@ -5489,7 +5883,7 @@ re_compile_pattern (pattern, length, bufp)
|
||||
|
||||
if (!ret)
|
||||
return NULL;
|
||||
return gettext (re_error_msgid[(int) ret]);
|
||||
return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
|
||||
}
|
||||
#ifdef _LIBC
|
||||
weak_alias (__re_compile_pattern, re_compile_pattern)
|
||||
@@ -5526,12 +5920,14 @@ re_comp (s)
|
||||
{
|
||||
re_comp_buf.buffer = (unsigned char *) malloc (200);
|
||||
if (re_comp_buf.buffer == NULL)
|
||||
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
return (char *) gettext (re_error_msgid
|
||||
+ re_error_msgid_idx[(int) REG_ESPACE]);
|
||||
re_comp_buf.allocated = 200;
|
||||
|
||||
re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
|
||||
if (re_comp_buf.fastmap == NULL)
|
||||
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
|
||||
return (char *) gettext (re_error_msgid
|
||||
+ re_error_msgid_idx[(int) REG_ESPACE]);
|
||||
}
|
||||
|
||||
/* Since `re_exec' always passes NULL for the `regs' argument, we
|
||||
@@ -5546,7 +5942,7 @@ re_comp (s)
|
||||
return NULL;
|
||||
|
||||
/* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
|
||||
return (char *) gettext (re_error_msgid[(int) ret]);
|
||||
return (char *) gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5666,7 +6062,7 @@ regcomp (preg, pattern, cflags)
|
||||
buffer. */
|
||||
if (re_compile_fastmap (preg) == -2)
|
||||
{
|
||||
/* Some error occured while computing the fastmap, just forget
|
||||
/* Some error occurred while computing the fastmap, just forget
|
||||
about it. */
|
||||
free (preg->fastmap);
|
||||
preg->fastmap = NULL;
|
||||
@@ -5772,15 +6168,15 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
size_t msg_size;
|
||||
|
||||
if (errcode < 0
|
||||
|| errcode >= (int) (sizeof (re_error_msgid)
|
||||
/ sizeof (re_error_msgid[0])))
|
||||
|| errcode >= (int) (sizeof (re_error_msgid_idx)
|
||||
/ sizeof (re_error_msgid_idx[0])))
|
||||
/* Only error codes returned by the rest of the code should be passed
|
||||
to this routine. If we are given anything else, or if other regex
|
||||
code generates an invalid error code, then the program has a bug.
|
||||
Dump core so we can fix it. */
|
||||
abort ();
|
||||
|
||||
msg = gettext (re_error_msgid[errcode]);
|
||||
msg = gettext (re_error_msgid + re_error_msgid_idx[errcode]);
|
||||
|
||||
msg_size = strlen (msg) + 1; /* Includes the null. */
|
||||
|
||||
|
||||
14
lib/regex.h
14
lib/regex.h
@@ -1,6 +1,6 @@
|
||||
/* Definitions for data structures and routines for the regular
|
||||
expression library, version 0.12.
|
||||
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
|
||||
Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@@ -221,13 +221,13 @@ extern reg_syntax_t re_syntax_options;
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
|
||||
replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
|
||||
removed and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
@@ -24,22 +24,32 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#if defined _LIBC || defined STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
/* Duplicate S, returning an identical malloc'd string. */
|
||||
#undef __strndup
|
||||
#undef strndup
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __strndup strndup
|
||||
#endif
|
||||
|
||||
char *
|
||||
strndup (const char *s, size_t n)
|
||||
__strndup (const char *s, size_t n)
|
||||
{
|
||||
char *new = malloc (n + 1);
|
||||
size_t len = strnlen (s, n);
|
||||
char *new = malloc (len + 1);
|
||||
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
new[n] = '\0';
|
||||
return (char *) memcpy (new, s, n);
|
||||
new[len] = '\0';
|
||||
return (char *) memcpy (new, s, len);
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__strndup, strndup)
|
||||
#endif
|
||||
|
||||
40
lib/strnlen.c
Normal file
40
lib/strnlen.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
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. */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#undef __strnlen
|
||||
#undef strnlen
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __strnlen strnlen
|
||||
#endif
|
||||
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
If no '\0' terminator is found in that many characters, return MAXLEN. */
|
||||
|
||||
size_t
|
||||
__strnlen (const char *string, size_t maxlen)
|
||||
{
|
||||
const char *end = memchr (string, '\0', maxlen);
|
||||
return end ? end - string : maxlen;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__strnlen, strnlen)
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000 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 @@
|
||||
/* Default copyright goes to the FSF. */
|
||||
|
||||
char* version_etc_copyright =
|
||||
N_("Copyright (C) 1999 Free Software Foundation, Inc.");
|
||||
N_("Copyright (C) 2000 Free Software Foundation, Inc.");
|
||||
|
||||
|
||||
/* Display the --version information the standard way.
|
||||
|
||||
59
m4/ChangeLog
59
m4/ChangeLog
@@ -1,3 +1,62 @@
|
||||
2000-05-20 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* prereq.m4 (jm_PREREQ_HUMAN): New macro.
|
||||
(jm_PREREQ): Use it.
|
||||
|
||||
2000-05-09 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* gettext.m4: Rename this...
|
||||
* libintl.m4: ...to this.
|
||||
|
||||
2000-05-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* jm-macros.m4 (AC_REPLACE_FUNCS): Add atexit.
|
||||
(AC_REPLACE_FUNCS): Add strnlen.
|
||||
|
||||
* rmdir-errno.m4 (fetish_FUNC_RMDIR_NOTEMPTY): New macro and file.
|
||||
* jm-macros.m4: Require fetish_FUNC_RMDIR_NOTEMPTY.
|
||||
|
||||
* nanosleep.m4: (jm_FUNC_NANOSLEEP): Save and restore LIBS around
|
||||
AC_SEARCH_LIBS call for nanosleep.
|
||||
(LIB_NANOSLEEP): Set and AC_SUBST.
|
||||
|
||||
2000-05-03 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* largefile.m4 (AC_SYS_LARGEFILE): Define _XOPEN_SOURCE to
|
||||
be 500, instead of _GNU_SOURCE to be 1, to work around glibc
|
||||
2.1.3 bug. This avoids a clash when files like regex.c define
|
||||
_GNU_SOURCE.
|
||||
|
||||
2000-05-05 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* jm-macros.m4 (jm_MACROS): Save and restore LIBS around AC_SEARCH_LIBS
|
||||
call for clock_gettime.
|
||||
(LIB_CLOCK_GETTIME): Set and AC_SUBST.
|
||||
|
||||
* search-libs.m4: Update from autoconf.
|
||||
|
||||
su doesn't work on Solaris2.6.
|
||||
* lib-check.m4: When checking for struct spwd.sp_pwdp, also include
|
||||
<shadow.h>. Reported by Dragos Harabor.
|
||||
|
||||
2000-05-03 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* check-decl.m4 (AC_CHECK_DECLS): Add strndup.
|
||||
|
||||
2000-05-02 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* largefile.m4 (AC_SYS_LARGEFILE): Define _GNU_SOURCE if
|
||||
this is needed to make ftello visible (e.g. glibc 2.1.3). Use
|
||||
compile-time test, rather than inspecting host and OS, to
|
||||
decide whether to define _LARGEFILE_SOURCE.
|
||||
|
||||
2000-05-01 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* fsusage.m4: Use AC_MSG_CHECKING instead of obsolete AC_CHECKING.
|
||||
|
||||
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Add BeOS support.
|
||||
Based on a patch from Bruno Haible.
|
||||
|
||||
2000-04-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* prereq.m4 (jm_PREREQ_GETPAGESIZE): New macro.
|
||||
|
||||
@@ -19,7 +19,6 @@ ftruncate.m4 \
|
||||
getgroups.m4 \
|
||||
getline.m4 \
|
||||
getloadavg.m4 \
|
||||
gettext.m4 \
|
||||
glibc.m4 \
|
||||
group-member.m4 \
|
||||
iconv.m4 \
|
||||
@@ -34,6 +33,7 @@ largefile.m4 \
|
||||
lchown.m4 \
|
||||
lcmessage.m4 \
|
||||
lib-check.m4 \
|
||||
libintl.m4 \
|
||||
link-follow.m4 \
|
||||
ls-mntd-fs.m4 \
|
||||
lstat-slash.m4 \
|
||||
@@ -48,6 +48,7 @@ putenv.m4 \
|
||||
readdir.m4 \
|
||||
realloc.m4 \
|
||||
regex.m4 \
|
||||
rmdir-errno.m4 \
|
||||
search-libs.m4 \
|
||||
st_dm_mode.m4 \
|
||||
st_mtim.m4 \
|
||||
|
||||
@@ -31,8 +31,6 @@ mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
@@ -90,7 +88,9 @@ INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
LIB_NANOSLEEP = @LIB_NANOSLEEP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
@@ -132,7 +132,6 @@ ftruncate.m4 \
|
||||
getgroups.m4 \
|
||||
getline.m4 \
|
||||
getloadavg.m4 \
|
||||
gettext.m4 \
|
||||
glibc.m4 \
|
||||
group-member.m4 \
|
||||
iconv.m4 \
|
||||
@@ -147,6 +146,7 @@ largefile.m4 \
|
||||
lchown.m4 \
|
||||
lcmessage.m4 \
|
||||
lib-check.m4 \
|
||||
libintl.m4 \
|
||||
link-follow.m4 \
|
||||
ls-mntd-fs.m4 \
|
||||
lstat-slash.m4 \
|
||||
@@ -161,6 +161,7 @@ putenv.m4 \
|
||||
readdir.m4 \
|
||||
realloc.m4 \
|
||||
regex.m4 \
|
||||
rmdir-errno.m4 \
|
||||
search-libs.m4 \
|
||||
st_dm_mode.m4 \
|
||||
st_mtim.m4 \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
AC_DEFUN(jm_AFS,
|
||||
AC_CHECKING(for AFS)
|
||||
AC_MSG_CHECKING(for AFS)
|
||||
test -d /afs \
|
||||
&& AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.])
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 10
|
||||
#serial 11
|
||||
|
||||
dnl This is just a wrapper function to encapsulate this kludge.
|
||||
dnl Putting it in a separate file like this helps share it between
|
||||
@@ -55,6 +55,7 @@ AC_DEFUN(jm_CHECK_DECLS,
|
||||
nanosleep,
|
||||
realloc,
|
||||
stpcpy,
|
||||
strndup,
|
||||
strstr,
|
||||
strtoul,
|
||||
strtoull,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
# From fileutils/configure.in
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
AC_DEFUN(jm_FILE_SYSTEM_USAGE,
|
||||
[
|
||||
|
||||
AC_CHECKING(how to get filesystem space usage)
|
||||
AC_MSG_CHECKING(how to get filesystem space usage)
|
||||
ac_fsusage_space=no
|
||||
|
||||
# Perform only the link test since it seems there are no variants of the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 16
|
||||
#serial 17
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -70,6 +70,7 @@ AC_DEFUN(jm_MACROS,
|
||||
AC_REQUIRE([jm_PREREQ])
|
||||
|
||||
AC_REQUIRE([jm_FUNC_LCHOWN])
|
||||
AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
|
||||
AC_REQUIRE([jm_FUNC_CHOWN])
|
||||
AC_REQUIRE([jm_FUNC_MKTIME])
|
||||
AC_REQUIRE([jm_FUNC_LSTAT])
|
||||
@@ -107,6 +108,8 @@ AC_DEFUN(jm_MACROS,
|
||||
AC_REPLACE_FUNCS(stime strcspn stpcpy strstr strtol strtoul)
|
||||
AC_REPLACE_FUNCS(strpbrk)
|
||||
AC_REPLACE_FUNCS(euidaccess memcmp mkdir rmdir rpmatch strndup strverscmp)
|
||||
AC_REPLACE_FUNCS(atexit)
|
||||
AC_REPLACE_FUNCS(strnlen)
|
||||
|
||||
dnl used by e.g. intl/*domain.c and lib/canon-host.c
|
||||
AC_REPLACE_FUNCS(strdup)
|
||||
@@ -128,8 +131,16 @@ AC_DEFUN(jm_MACROS,
|
||||
# used by sleep and shred
|
||||
# Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
|
||||
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
|
||||
# Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all*
|
||||
# programs in the package would end up linked with that potentially-shared
|
||||
# library, inducing unnecessary run-time overhead.
|
||||
fetish_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt posix4],
|
||||
[LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
|
||||
AC_SUBST(LIB_CLOCK_GETTIME)
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
LIBS=$fetish_saved_libs
|
||||
AC_CHECK_FUNCS(gettimeofday)
|
||||
|
||||
AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 9
|
||||
#serial 11
|
||||
|
||||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
@@ -109,12 +109,11 @@ AC_DEFUN(AC_SYS_LARGEFILE,
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
[ hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)]
|
||||
ac_cv_sys_largefile_source=1 ;;
|
||||
esac])
|
||||
[Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
|
||||
[AC_TRY_COMPILE([#include <stdio.h>], [return !ftello;], ,
|
||||
[AC_TRY_COMPILE([#define _LARGEFILE_SOURCE 1
|
||||
#include <stdio.h>], [return !ftello;],
|
||||
ac_cv_sys_largefile_source=1)])])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
@@ -123,5 +122,13 @@ AC_DEFUN(AC_SYS_LARGEFILE,
|
||||
[ aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)]
|
||||
ac_cv_sys_large_files=1 ;;
|
||||
esac])
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE,
|
||||
ac_cv_sys_xopen_source,
|
||||
[Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
|
||||
[AC_TRY_COMPILE([#include <stdio.h>], [return !ftello;], ,
|
||||
[AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
|
||||
#include <stdio.h>],
|
||||
[return !ftello;],
|
||||
ac_cv_sys_xopen_source=500)])])
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -42,11 +42,18 @@ AC_DEFUN(jm_LIB_CHECK,
|
||||
# shadow passwords. UnixWare 7 needs -lgen.
|
||||
AC_SEARCH_LIBS(getspnam, [shadow sec gen])
|
||||
|
||||
# Requirements for su.c.
|
||||
AC_CHECK_MEMBERS((struct spwd.sp_pwdp))
|
||||
AC_CHECK_FUNCS(getspnam)
|
||||
AC_CHECK_HEADERS(shadow.h)
|
||||
|
||||
# Requirements for su.c.
|
||||
shadow_includes="\
|
||||
$ac_includes_default
|
||||
#if HAVE_SHADOW_H
|
||||
# include <shadow.h>
|
||||
#endif
|
||||
"
|
||||
AC_CHECK_MEMBERS((struct spwd.sp_pwdp),,,[$shadow_includes])
|
||||
AC_CHECK_FUNCS(getspnam)
|
||||
|
||||
# SCO-ODT-3.0 is reported to need -lufc for crypt.
|
||||
# NetBSD needs -lcrypt for crypt.
|
||||
ac_su_saved_lib="$LIBS"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 3
|
||||
#serial 4
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
@@ -180,8 +180,6 @@ if test -z "$ac_list_mounted_fs"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# FIXME: add a test for netbsd-1.1 here
|
||||
|
||||
if test -z "$ac_list_mounted_fs"; then
|
||||
# Ultrix
|
||||
AC_MSG_CHECKING([for getmnt function])
|
||||
@@ -200,6 +198,27 @@ if test -z "$ac_list_mounted_fs"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$ac_list_mounted_fs"; then
|
||||
# BeOS
|
||||
AC_CHECK_FUNCS(next_dev fs_stat_dev)
|
||||
AC_CHECK_HEADERS(fs_info.h)
|
||||
AC_MSG_CHECKING([for BEOS mounted file system support functions])
|
||||
if test $ac_cv_header_fs_info_h = yes \
|
||||
&& test $ac_cv_func_next_dev = yes \
|
||||
&& test $ac_cv_func_fs_stat_dev = yes; then
|
||||
fu_result=yes
|
||||
else
|
||||
fu_result=no
|
||||
fi
|
||||
AC_MSG_RESULT($fu_result)
|
||||
if test $fu_result = yes; then
|
||||
ac_list_mounted_fs=found
|
||||
AC_DEFINE(MOUNTED_NEXT_DEV, 1,
|
||||
[Define if there are functions named next_dev and fs_stat_dev for
|
||||
reading the list of mounted filesystems. (BeOS)])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$ac_list_mounted_fs"; then
|
||||
# SVR2
|
||||
AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 5
|
||||
#serial 6
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Check for the nanosleep function.
|
||||
@@ -7,9 +7,12 @@ dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_NANOSLEEP,
|
||||
[
|
||||
nanosleep_save_libs=$LIBS
|
||||
|
||||
# Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
|
||||
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
|
||||
AC_SEARCH_LIBS(nanosleep, [rt posix4])
|
||||
AC_SEARCH_LIBS(nanosleep, [rt posix4], [LIB_NANOSLEEP=$ac_cv_search_nanosleep])
|
||||
AC_SUBST(LIB_NANOSLEEP)
|
||||
|
||||
AC_CACHE_CHECK([whether nanosleep works],
|
||||
jm_cv_func_nanosleep_works,
|
||||
@@ -47,4 +50,6 @@ AC_DEFUN(jm_FUNC_NANOSLEEP,
|
||||
AC_DEFINE_UNQUOTED(nanosleep, rpl_nanosleep,
|
||||
[Define to rpl_nanosleep if the replacement function should be used.])
|
||||
fi
|
||||
|
||||
LIBS=$nanosleep_save_libs
|
||||
])
|
||||
|
||||
13
m4/prereq.m4
13
m4/prereq.m4
@@ -1,4 +1,4 @@
|
||||
#serial 6
|
||||
#serial 7
|
||||
|
||||
dnl These are the prerequisite macros for files in the lib/
|
||||
dnl directories of the fileutils, sh-utils, and textutils packages.
|
||||
@@ -9,6 +9,7 @@ AC_DEFUN(jm_PREREQ,
|
||||
jm_PREREQ_CANON_HOST
|
||||
jm_PREREQ_ERROR
|
||||
jm_PREREQ_GETPAGESIZE
|
||||
jm_PREREQ_HUMAN
|
||||
jm_PREREQ_QUOTEARG
|
||||
jm_PREREQ_READUTMP
|
||||
jm_PREREQ_REGEX
|
||||
@@ -37,6 +38,16 @@ AC_DEFUN(jm_PREREQ_CANON_HOST,
|
||||
netinet/in.h arpa/inet.h)
|
||||
])
|
||||
|
||||
# If you use human.c, you need the following files:
|
||||
# uintmax_t.m4 inttypes_h.m4 ulonglong.m4
|
||||
AC_DEFUN(jm_PREREQ_HUMAN,
|
||||
[
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h string.h)
|
||||
AC_CHECK_DECLS((getenv))
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
])
|
||||
|
||||
AC_DEFUN(jm_PREREQ_GETPAGESIZE,
|
||||
[
|
||||
AC_CHECK_FUNCS(getpagesize)
|
||||
|
||||
43
m4/rmdir-errno.m4
Normal file
43
m4/rmdir-errno.m4
Normal file
@@ -0,0 +1,43 @@
|
||||
#serial 1
|
||||
|
||||
# When rmdir fails because the specified directory is not empty, it sets
|
||||
# errno to some value, usually ENOTEMPTY. However, on some AIX systems,
|
||||
# ENOTEMPTY is mistakenly defined to be EEXIST. To work around this, and
|
||||
# in general, to avoid depending on the use of any particular symbol, this
|
||||
# test runs a test to determine the actual numeric value.
|
||||
AC_DEFUN(fetish_FUNC_RMDIR_NOTEMPTY,
|
||||
[dnl
|
||||
AC_CACHE_CHECK([for rmdir-not-empty errno value],
|
||||
fetish_cv_func_rmdir_errno_not_empty,
|
||||
[
|
||||
# Arrange for deletion of the temporary directory this test creates.
|
||||
ac_clean_files="$ac_clean_files confdir2"
|
||||
mkdir confdir2; : > confdir2/file
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
int main ()
|
||||
{
|
||||
FILE *s;
|
||||
int val;
|
||||
rmdir ("confdir2");
|
||||
val = errno;
|
||||
s = fopen ("confdir2/file", "w");
|
||||
fprintf (s, "%d\n", val);
|
||||
exit (0);
|
||||
}
|
||||
],
|
||||
fetish_cv_func_rmdir_errno_not_empty=`cat confdir2/file`,
|
||||
fetish_cv_func_rmdir_errno_not_empty='configure error in rmdir-errno.m4',
|
||||
fetish_cv_func_rmdir_errno_not_empty=ENOTEMPTY
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
AC_DEFINE_UNQUOTED([RMDIR_ERRNO_NOT_EMPTY],
|
||||
$fetish_cv_func_rmdir_errno_not_empty,
|
||||
[the value to which errno is set when rmdir fails on a nonempty directory])
|
||||
])
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 3
|
||||
#serial 4
|
||||
|
||||
dnl A replacement for autoconf's macro by the same name. This version
|
||||
dnl uses `ac_lib' rather than `i' for the loop variable, but more importantly
|
||||
@@ -8,33 +8,31 @@ dnl the `none required' case.
|
||||
dnl I hope it's only temporary while we wait for that version to be fixed.
|
||||
undefine([AC_SEARCH_LIBS])
|
||||
|
||||
dnl AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
|
||||
dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
|
||||
dnl Search for a library defining FUNC, if it's not already available.
|
||||
|
||||
# AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS,
|
||||
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
|
||||
# [OTHER-LIBRARIES])
|
||||
# --------------------------------------------------------
|
||||
# Search for a library defining FUNC, if it's not already available.
|
||||
AC_DEFUN(AC_SEARCH_LIBS,
|
||||
[
|
||||
AC_PREREQ([2.13])
|
||||
AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
|
||||
[
|
||||
ac_func_search_save_LIBS="$LIBS"
|
||||
ac_cv_search_$1="no"
|
||||
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
|
||||
if test "$ac_cv_search_$1" = "no"; then
|
||||
ac_func_search_save_LIBS=$LIBS
|
||||
ac_cv_search_$1=no
|
||||
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1='none required'])
|
||||
if test "$ac_cv_search_$1" = no; then
|
||||
for ac_lib in $2; do
|
||||
LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
|
||||
AC_TRY_LINK_FUNC([$1],
|
||||
[ac_cv_search_$1="-l$ac_lib"
|
||||
break])
|
||||
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="-l$ac_lib"; break])
|
||||
done
|
||||
fi
|
||||
LIBS="$ac_func_search_save_LIBS"
|
||||
LIBS=$ac_func_search_save_LIBS
|
||||
])
|
||||
|
||||
if test "$ac_cv_search_$1" = "no"; then :
|
||||
if test "$ac_cv_search_$1" = no; then :
|
||||
$4
|
||||
else
|
||||
if test "$ac_cv_search_$1" = "none required"; then :
|
||||
if test "$ac_cv_search_$1" = 'none required'; then :
|
||||
$4
|
||||
else
|
||||
LIBS="$ac_cv_search_$1 $LIBS"
|
||||
|
||||
@@ -1,3 +1,144 @@
|
||||
2000-05-20 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0s.
|
||||
|
||||
* tests/mv/Makefile.am (TESTS): Add i-2, for 2000-05-12 change.
|
||||
|
||||
* tests/rm/r-2: Clean up.
|
||||
* tests/ls/time-1 (LC_ALL): Set it unconditionally.
|
||||
|
||||
2000-05-19 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
Save device number as well as inode number for each directory,
|
||||
and use both in comparisons. This makes the directory cycle
|
||||
test more robust, and closes the small remaining hole whereby
|
||||
an attacker could subvert a running `rm -r' command.
|
||||
|
||||
* src/remove.c (struct active_dir_ent) [st_dev]: New member.
|
||||
[st_ino]: Rename from `inum'.
|
||||
(make_active_dir_ent) [device]: New parameter.
|
||||
(hash_compare_active_dir_ents): Compare using SAME_INODE macro.
|
||||
(fspec_init_common): New function, factored out.
|
||||
(fspec_init_file): Initialize have_device member.
|
||||
(fspec_get_full_mode): Remove parameter. Update caller.
|
||||
Set have_device and st_dev members.
|
||||
* src/remove.h (struct File_spec) [have_device, st_dev]: New members
|
||||
|
||||
2000-05-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/remove.c (rm): Combine adjacent fputc and fprintf.
|
||||
|
||||
* tests/rm/Makefile.am (TESTS): Add hash.
|
||||
* tests/rm/hash: New test for the fix in lib/hash.c.
|
||||
|
||||
2000-05-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/remove.c (remove_dir): Detect (and fail upon) attempt to subvert
|
||||
a running `rm -r'. Reported by Morten Welinder.
|
||||
|
||||
2000-05-15 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/ln.c (do_link): Use complete strings in diagnostics so they
|
||||
are easier to translate. Reported by Michel Robitaille.
|
||||
(main): Drop support for the case in which S_ISLNK wasn't defined.
|
||||
It was broken in any case.
|
||||
|
||||
* tests/ls/time-1: Set LC_ALL to `C' to avoid failure when the
|
||||
current locale is not C (POSIX). From Matthew Clarke.
|
||||
|
||||
2000-05-13 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/help-version: New test.
|
||||
* src/Makefile.am (TESTS): Define.
|
||||
(TESTS_ENVIRONMENT): Likewise.
|
||||
(EXTRA_DIST): Add help-version.
|
||||
|
||||
* src/chgrp.c: Arrange to call close_stdout only upon exit.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/chown.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/sync.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
* src/dd.c: Include closeout.h.
|
||||
(usage): Don't call close_stdout here.
|
||||
(close_stdout_wrapper): New, kludgey, function and file-scoped global.
|
||||
(main): Register it with atexit.
|
||||
|
||||
2000-05-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
Unlike for mv, -i doesn't cancel the effect of -f
|
||||
and -f doesn't cancel the effect of -i.
|
||||
* src/cp.c (main) ['f']: Don't reset `x.interactive'.
|
||||
['i']: Don't reset `x.force'.
|
||||
* src/copy.c (copy_internal): Fix force and interactive tests.
|
||||
Patch from Michael Stone, reported by Jeff Sheinberg.
|
||||
|
||||
2000-05-09 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/shred.c: Include sys/types.h in shred.c before including
|
||||
sys/stat.h or system.h. From John David Anglin.
|
||||
|
||||
2000-05-08 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/shred/remove: Don't use touch in root test. Instead, append to
|
||||
the test file, since now touch operates even on files which deny owner
|
||||
write access.
|
||||
|
||||
2000-05-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/Makefile.am (shred_LDADD): Add @LIB_CLOCK_GETTIME@.
|
||||
|
||||
* src/rmdir.c (EEXIST): Remove now-unused definition.
|
||||
(ENOTEMPTY): Likewise.
|
||||
(errno_rmdir_non_empty): Rewrite to use RMDIR_ERRNO_NOT_EMPTY,
|
||||
which is determined by the autoconf test in m4/rmdir-errno.m4.
|
||||
|
||||
2000-05-03 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
Don't fail when running `make check' with non-`C' locale.
|
||||
* tests/cp/symlink-slash: During ls, set LANGUAGE (for GNU gettext)
|
||||
and LC_ALL (for systems which look at LC_MESSAGES).
|
||||
* tests/rm/r-2: Define LC_ALL instead of LANG, in case the user has
|
||||
LC_CTYPE or LC_ALL set. Define it and LANGUAGE before the first use
|
||||
of sort.
|
||||
|
||||
2000-05-03 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
With a recent glibc, _GNU_SOURCE, and -O, strndup may be a macro.
|
||||
* src/sys2.h (!HAVE_DECL_STRNDUP): Declare strndup.
|
||||
* src/dircolors.c: Remove declaration of strndup.
|
||||
Reported by Bruno Haible.
|
||||
|
||||
2000-05-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/rm.c (usage): Add the answer to `How do I remove a file named -f?'
|
||||
|
||||
2000-05-01 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/install.c (change_attributes): Don't even attempt the chmod
|
||||
if the chown fails. Before, when a non-root user ran `install -m 4755
|
||||
-o nobody FILE DEST', DEST would set-uid not to `nobody' but rather to
|
||||
the ID of the installing user. Reported by Marc Olzheim.
|
||||
|
||||
2000-04-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/touch.c (O_NOCTTY): Define if not defined already.
|
||||
(touch): Add O_NOCTTY to the flags passed to open.
|
||||
|
||||
2000-04-29 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0r.
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
Changes in release 4.1:
|
||||
[4.0s]
|
||||
* rm no longer segfaults on certain very deep hierarchies
|
||||
* IMPORTANT SECURITY FIX: a running `rm -r' may no longer be subverted to
|
||||
remove unintended directories
|
||||
* cp can now remove unwritable files in interactive mode; contrary to how mv
|
||||
works, cp's --interactive (-i) option does *not* cancel the effect of a
|
||||
preceding --force (-f) option.
|
||||
* all programs fail when printing --help or --version output to a full device
|
||||
* install no longer performs chmod if chown fails (see ChangeLog for example)
|
||||
[4.0r]
|
||||
* `du dir/subdir1 dir/subdir2' no longer fails
|
||||
* chown accepts new option: --from=CURRENT_OWNER:CURRENT_GROUP
|
||||
@@ -36,7 +45,7 @@ Changes in release 4.1:
|
||||
[4.0m]
|
||||
* mv accepts new option: --strip-trailing-slashes (soon, many other
|
||||
programs will, too)
|
||||
* df no longer hangs when there is inaccessible mount point unrelated to PATH
|
||||
* df no longer hangs when there is an inaccessible mount point unrelated to PATH
|
||||
* rmdir --verbose no longer prints extra, bogus diagnosic upon failure
|
||||
* fix df bug that made it print bogus values in the `Use%' column.
|
||||
* touch -d once again parses dates with `hh:mm ZONE' time zone info.
|
||||
|
||||
@@ -1,3 +1,105 @@
|
||||
2000-05-15 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/date/Test.pm (test_vector): Skip the %c test on SunOS4 systems.
|
||||
Suggested by Paul Eggert. Reported by Volker Borchert.
|
||||
|
||||
2000-05-13 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/groups.sh: Detect and report write failure of --help/--version.
|
||||
* src/nohup.sh: Likewise.
|
||||
|
||||
2000-05-11 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/date.c (usage): Don't call close_stdout_status directly,
|
||||
since that didn't cover --version output.
|
||||
(main): Instead, call close_stdout_set_status and arrange to
|
||||
call close_stdout via atexit.
|
||||
* src/printenv.c: Likewise.
|
||||
* src/tty.c: Likewise.
|
||||
|
||||
* src/true.c (usage): Don't call close_stdout directly, since that
|
||||
didn't cover --version output.
|
||||
(main): Arrange to call close_stdout via atexit, instead.
|
||||
* src/yes.c: Likewise.
|
||||
* src/sleep.c: Likewise.
|
||||
|
||||
2000-05-09 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sys2.h (case_GETOPT_VERSION_CHAR): Don't call close_stdout.
|
||||
* src/help-version: New test.
|
||||
* src/Makefile.am (TESTS): Define.
|
||||
(TESTS_ENVIRONMENT): Likewise.
|
||||
(EXTRA_DIST): Add help-version.
|
||||
|
||||
2000-05-08 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0i.
|
||||
|
||||
2000-05-07 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0h.
|
||||
|
||||
* src/basename.c: Include "closeout.h".
|
||||
(main): Call atexit with close_stdout.
|
||||
* src/chroot.c: Likewise.
|
||||
* src/dirname.c: Likewise.
|
||||
* src/echo.c: Likewise.
|
||||
* src/env.c: Likewise.
|
||||
* src/expr.c: Likewise.
|
||||
* src/factor.c: Likewise.
|
||||
* src/hostid.c: Likewise.
|
||||
* src/hostname.c: Likewise.
|
||||
* src/id.c: Likewise.
|
||||
* src/logname.c: Likewise.
|
||||
* src/nice.c: Likewise.
|
||||
* src/pathchk.c: Likewise.
|
||||
* src/pinky.c: Likewise.
|
||||
* src/printf.c: Likewise.
|
||||
* src/pwd.c: Likewise.
|
||||
* src/seq.c: Likewise.
|
||||
* src/stty.c: Likewise.
|
||||
* src/su.c: Likewise.
|
||||
* src/test.c: Likewise.
|
||||
* src/uname.c: Likewise.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
* src/whoami.c: Likewise.
|
||||
* src/tee.c: Likewise. Remove explicit close_stdout.
|
||||
|
||||
* src/yes.c Include "closeout.h".
|
||||
(usage): Call close_stdout just before exit.
|
||||
* src/sleep.c: Likewise.
|
||||
* src/true.c: Likewise.
|
||||
* src/date.c (usage): Call close_stdout_status.
|
||||
* src/printenv.c (usage): Likewise.
|
||||
|
||||
* tests/date/Test.pm ($Test::env{'rfc822-1'}): Add TZ=UTC0.
|
||||
|
||||
2000-05-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/Makefile.am (sleep_LDADD): Add @LIB_CLOCK_GETTIME@ and
|
||||
@LIB_NANOSLEEP@.
|
||||
|
||||
* src/tty.c (main): Warn about arguments, don't fail.
|
||||
(usage): Call close_stdout_status from here as well as from main.
|
||||
|
||||
2000-05-05 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
Exit nonzero upon write failure.
|
||||
* src/printf.c: Include "closeout.h".
|
||||
(main): Call close_stdout.
|
||||
Reported by Ian Jackson via Michael Stone.
|
||||
|
||||
2000-05-04 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Makefile.maint (my-distcheck): Remove spurious blank line.
|
||||
Remove $(DEPDIR) *after* making distclean, not before.
|
||||
|
||||
2000-04-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/yes.c: Detect and terminate upon write failure.
|
||||
|
||||
2000-04-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/seq.c: Shorten `#ifdef HAVE_...' to `#if HAVE_...' and
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
Changes in release 2.1
|
||||
[2.0j]
|
||||
[2.0i]
|
||||
* fixed a bug introduced in 2.0h that made many programs fail with a
|
||||
`write error' when invoked with the --version option
|
||||
[2.0h]
|
||||
* all programs fail when printing --help or --version output to a full device
|
||||
* printf exits nonzero upon write failure
|
||||
* yes now detects and terminates upon write failure
|
||||
* date --rfc-822 now always emits day and month names from the `C' locale
|
||||
* portability tweaks for Solaris8, Ultrix, and DOS
|
||||
[2.0g]
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
2000-05-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/head.c (string_to_integer): Restrict base to 10.
|
||||
Reported by Joseph S. Myers.
|
||||
* tests/head/Test.pm: Add a few tests for this.
|
||||
|
||||
New option: --first-only
|
||||
* src/unexpand.c (anonymous enum) [CONVERT_FIRST_ONLY_OPTION]: Define.
|
||||
(long_options): Add `first-only'.
|
||||
(main): Handle new option.
|
||||
|
||||
2000-05-11 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/unexpand/basic-1: New tests.
|
||||
|
||||
2000-04-17 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* src/system.h [__BEOS__]: Ignore O_BINARY and O_TEXT.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Changes in release 2.1
|
||||
[2.0f]
|
||||
* unexpand accepts new option: --first-only
|
||||
[2.0e]
|
||||
* `tail -f directory' no longer gets a failed assertion
|
||||
* sort: big performance improvement when sorting many small files;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from filenames
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "basename"
|
||||
@@ -98,6 +99,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2000 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
|
||||
@@ -356,7 +356,6 @@ Change the group membership of each FILE to GROUP.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -373,6 +372,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
|
||||
@@ -434,7 +435,5 @@ main (int argc, char **argv)
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (1, argv[optind], group);
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2000 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
|
||||
@@ -263,7 +263,6 @@ Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n\
|
||||
one or more of the letters rwxXstugo.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -285,6 +284,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while (1)
|
||||
@@ -364,7 +365,5 @@ main (int argc, char **argv)
|
||||
errors |= change_file_mode (argv[optind], changes, 1);
|
||||
}
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,6 @@ to login group if implied by a `:'. OWNER and GROUP may be numeric as well\n\
|
||||
as symbolic.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -361,6 +360,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
recurse = force_silent = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
|
||||
@@ -441,7 +442,5 @@ main (int argc, char **argv)
|
||||
old_user, old_group);
|
||||
}
|
||||
|
||||
if (verbosity != V_off)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chroot -- run command or shell with special root directory
|
||||
Copyright (C) 95, 96, 1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 95, 96, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "chroot"
|
||||
@@ -66,6 +67,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
if (argc == 1)
|
||||
|
||||
@@ -489,9 +489,9 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (src_type) && !x->force && x->interactive)
|
||||
if (!S_ISDIR (src_type) && x->interactive)
|
||||
{
|
||||
if (euidaccess (dst_path, W_OK) != 0)
|
||||
if (euidaccess (dst_path, W_OK) != 0 && x->force)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s: overwrite `%s', overriding mode %04lo? "),
|
||||
|
||||
7
src/cp.c
7
src/cp.c
@@ -201,7 +201,6 @@ options are given and SOURCE and DEST are the same name for an existing,\n\
|
||||
regular file.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -683,6 +682,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
cp_option_init (&x);
|
||||
|
||||
/* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
|
||||
@@ -731,11 +732,9 @@ main (int argc, char **argv)
|
||||
|
||||
case 'f':
|
||||
x.force = 1;
|
||||
x.interactive = 0;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
x.force = 0;
|
||||
x.interactive = 1;
|
||||
break;
|
||||
|
||||
@@ -837,7 +836,5 @@ main (int argc, char **argv)
|
||||
|
||||
exit_status |= do_copy (argc - optind, argv + optind, target_directory, &x);
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -319,6 +319,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
close_stdout_set_status (2);
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "d:f:I::r:Rs:u", long_options, NULL))
|
||||
!= -1)
|
||||
switch (optc)
|
||||
@@ -463,8 +466,6 @@ argument must be a format string beginning with `+'."),
|
||||
show_date (format, when);
|
||||
}
|
||||
|
||||
close_stdout_status (2);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
19
src/dd.c
19
src/dd.c
@@ -30,6 +30,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "getpagesize.h"
|
||||
#include "human.h"
|
||||
@@ -314,7 +315,6 @@ Each KEYWORD may be:\n\
|
||||
sync pad every input block with NULs to ibs-size\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -1048,6 +1048,17 @@ dd_copy (void)
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
/* This is gross, but necessary, because of the way close_stdout
|
||||
works and because this program closes STDOUT_FILENO directly. */
|
||||
static void (*closeout_func) (void) = close_stdout;
|
||||
|
||||
static void
|
||||
close_stdout_wrapper (void)
|
||||
{
|
||||
if (*closeout_func)
|
||||
(*closeout_func) ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -1059,9 +1070,15 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* Arrange to close stdout if parse_long_options exits. */
|
||||
atexit (close_stdout_wrapper);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
/* Don't close stdout on exit from here on. */
|
||||
closeout_func = NULL;
|
||||
|
||||
/* Initialize translation table to identity translation. */
|
||||
for (i = 0; i < 256; i++)
|
||||
trans_table[i] = i;
|
||||
|
||||
4
src/df.c
4
src/df.c
@@ -752,7 +752,6 @@ or all filesystems by default.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -769,6 +768,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
fs_select_list = NULL;
|
||||
fs_exclude_list = NULL;
|
||||
inode_format = 0;
|
||||
@@ -932,6 +933,5 @@ main (int argc, char **argv)
|
||||
show_entry (argv[i], &stats[i - optind]);
|
||||
}
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dircolors - output commands to set the LS_COLOR environment variable
|
||||
Copyright (C) 1994, 1995, 1997, 1998, 1999 H. Peter Anvin
|
||||
Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin
|
||||
Copyright (C) 1996-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -39,8 +39,6 @@
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
char *strndup();
|
||||
|
||||
enum Shell_syntax
|
||||
{
|
||||
SHELL_SYNTAX_BOURNE,
|
||||
@@ -117,7 +115,6 @@ file types and extensions. Otherwise, a precompiled database is used.\n\
|
||||
For details on the format of these files, run `dircolors --print-database'.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
|
||||
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
@@ -431,6 +428,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
|
||||
switch (optc)
|
||||
{
|
||||
@@ -532,7 +531,6 @@ dircolors' internal database"));
|
||||
}
|
||||
}
|
||||
|
||||
close_stdout ();
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* dirname -- strip filename suffix from pathname
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dirname"
|
||||
@@ -71,6 +72,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
|
||||
4
src/du.c
4
src/du.c
@@ -227,7 +227,6 @@ Summarize disk usage of each FILE, recursively for directories.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -656,6 +655,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
exclude = new_exclude ();
|
||||
xstat = lstat;
|
||||
|
||||
@@ -783,6 +784,5 @@ main (int argc, char **argv)
|
||||
|
||||
du_files (optind == argc ? cwd_only : argv + optind);
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* echo.c, derived from code echo.c in Bash.
|
||||
Copyright (C) 87,89, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 87,89, 1991-1997, 1999, 2000 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,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -117,6 +118,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* env - run a program in a modified environment
|
||||
Copyright (C) 1986, 1991-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -85,6 +85,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "env"
|
||||
@@ -145,6 +146,8 @@ main (register int argc, register char **argv, char **envp)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* expr -- evaluate expressions.
|
||||
Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 1991-1997, 1999, 2000 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,7 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "xalloc.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "expr"
|
||||
@@ -168,6 +169,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
|
||||
|
||||
/* Recognize --help or --version only if POSIXLY_CORRECT is not set. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* factor -- print factors of n.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 95, 96, 1997, 1998, 1999, 2000 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,9 +26,10 @@
|
||||
#define NDEBUG 1
|
||||
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "human.h"
|
||||
#include "long-options.h"
|
||||
#include "readtokens.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -181,6 +182,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
/* The above handles --help and --version.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# groups -- print the groups a user is in
|
||||
# Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1997, 2000 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,13 +31,14 @@ Same as id -Gn. If no USERNAME, use current process.
|
||||
|
||||
Report bugs to <sh-utils-bugs@gnu.org>."
|
||||
|
||||
fail=0
|
||||
case $# in
|
||||
1 )
|
||||
case "z${1}" in
|
||||
z--help )
|
||||
echo "$usage"; exit 0 ;;
|
||||
echo "$usage" || fail=1; exit $fail;;
|
||||
z--version )
|
||||
echo "groups (@GNU_PACKAGE@) @VERSION@"; exit 0 ;;
|
||||
echo "groups (@GNU_PACKAGE@) @VERSION@" || fail=1; exit $fail;;
|
||||
* ) ;;
|
||||
esac
|
||||
;;
|
||||
@@ -48,7 +49,6 @@ if [ $# -eq 0 ]; then
|
||||
id -Gn
|
||||
fail=$?
|
||||
else
|
||||
fail=0
|
||||
for name in "$@"; do
|
||||
groups=`id -Gn -- $name`
|
||||
status=$?
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* head -- output first part of file(s)
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 89, 90, 91, 1995-2000 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
|
||||
@@ -211,7 +211,7 @@ head_file (const char *filename, uintmax_t n_units, int count_lines)
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert a string of digits, N_STRING, with a single, optional suffix
|
||||
/* Convert a string of decimal digits, N_STRING, with a single, optional suffix
|
||||
character (b, k, or m) to an integral value. Upon successful conversion,
|
||||
return that value. If it cannot be converted, give a diagnostic and exit.
|
||||
COUNT_LINES indicates whether N_STRING is a number of bytes or a number
|
||||
@@ -223,7 +223,7 @@ string_to_integer (int count_lines, const char *n_string)
|
||||
strtol_error s_err;
|
||||
uintmax_t n;
|
||||
|
||||
s_err = xstrtoumax (n_string, NULL, 0, &n, "bkm");
|
||||
s_err = xstrtoumax (n_string, NULL, 10, &n, "bkm");
|
||||
|
||||
if (s_err == LONGINT_INVALID)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* print the hexadecimal identifier for the current host
|
||||
Copyright (C) 1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1999, 2000 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,6 +70,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
@@ -82,7 +84,5 @@ main (int argc, char **argv)
|
||||
id = gethostid ();
|
||||
printf ("%lx\n", id);
|
||||
|
||||
close_stdout ();
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hostname - set or print the name of current host system
|
||||
Copyright (C) 1994-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1997, 1999, 2000 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,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -87,6 +88,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
5
src/id.c
5
src/id.c
@@ -1,5 +1,5 @@
|
||||
/* id -- print real and effective UIDs and GIDs
|
||||
Copyright (C) 1989-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "id"
|
||||
@@ -125,6 +126,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "agnruG", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
|
||||
@@ -238,6 +238,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
cp_option_init (&x);
|
||||
|
||||
owner_name = NULL;
|
||||
@@ -380,8 +382,6 @@ is not a directory"),
|
||||
}
|
||||
}
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
@@ -506,15 +506,18 @@ change_attributes (const char *path)
|
||||
&& errno != EPERM
|
||||
#endif
|
||||
)
|
||||
err = errno;
|
||||
if (chmod (path, mode))
|
||||
err = errno;
|
||||
if (err)
|
||||
{
|
||||
error (0, err, "%s", path);
|
||||
return 1;
|
||||
error (0, errno, "cannot change ownership of `%s'", path);
|
||||
err = 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
if (!err && chmod (path, mode))
|
||||
{
|
||||
error (0, errno, "cannot change permissions of `%s'", path);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Set the timestamps of file TO to match those of file FROM.
|
||||
@@ -671,7 +674,6 @@ the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
simple, never always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
33
src/ln.c
33
src/ln.c
@@ -100,10 +100,6 @@ static int (*linkfunc) ();
|
||||
/* If nonzero, make symbolic links; otherwise, make hard links. */
|
||||
static int symbolic_link;
|
||||
|
||||
/* A string describing type of link to make. For use in verbose
|
||||
diagnostics and in error messages. */
|
||||
static const char *link_type_string;
|
||||
|
||||
/* If nonzero, ask the user before removing existing files. */
|
||||
static int interactive;
|
||||
|
||||
@@ -301,7 +297,10 @@ do_link (const char *source, const char *dest)
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf (_("create %s %s to %s"), link_type_string, dest, source);
|
||||
printf ((symbolic_link
|
||||
? _("create symbolic link `%s' to `%s'")
|
||||
: _("create hard link `%s' to `%s'")),
|
||||
dest, source);
|
||||
if (backup_succeeded)
|
||||
printf (_(" (backup: %s)"), dest_backup);
|
||||
putchar ('\n');
|
||||
@@ -312,7 +311,10 @@ do_link (const char *source, const char *dest)
|
||||
return 0;
|
||||
}
|
||||
|
||||
error (0, errno, _("cannot create %s `%s' to `%s'"), link_type_string,
|
||||
error (0, errno,
|
||||
(symbolic_link
|
||||
? _("create symbolic link `%s' to `%s'")
|
||||
: _("create hard link `%s' to `%s'")),
|
||||
dest, source);
|
||||
|
||||
if (dest_backup)
|
||||
@@ -372,7 +374,6 @@ the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
simple, never always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -396,6 +397,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
/* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
|
||||
we'll actually use backup_suffix_string. */
|
||||
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
@@ -493,20 +496,10 @@ main (int argc, char **argv)
|
||||
dest_is_dir = isdir (target_directory);
|
||||
}
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (symbolic_link)
|
||||
{
|
||||
linkfunc = symlink;
|
||||
link_type_string = _("symbolic link");
|
||||
}
|
||||
linkfunc = symlink;
|
||||
else
|
||||
{
|
||||
linkfunc = link;
|
||||
link_type_string = _("hard link");
|
||||
}
|
||||
#else
|
||||
link_type_string = _("link");
|
||||
#endif
|
||||
linkfunc = link;
|
||||
|
||||
if (target_directory_specified && !dest_is_dir)
|
||||
{
|
||||
@@ -560,7 +553,5 @@ main (int argc, char **argv)
|
||||
errors = do_link (source, new_dest);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
close_stdout ();
|
||||
exit (errors != 0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* logname -- print user's login name
|
||||
Copyright (C) 1990-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1997, 1999, 2000 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,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -67,6 +68,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
4
src/ls.c
4
src/ls.c
@@ -774,6 +774,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
#define N_ENTRIES(Array) (sizeof Array / sizeof *(Array))
|
||||
assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name));
|
||||
|
||||
@@ -873,7 +875,6 @@ main (int argc, char **argv)
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
}
|
||||
|
||||
close_stdout ();
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -3002,7 +3003,6 @@ optional WHEN argument is equivalent to using --color=always. With\n\
|
||||
to a terminal (tty).\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -91,6 +90,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
create_parents = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "pm:", longopts, NULL)) != -1)
|
||||
|
||||
@@ -65,7 +65,6 @@ Create named pipes (FIFOs) with the given NAMEs.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -85,6 +84,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
symbolic_mode = NULL;
|
||||
|
||||
#ifndef S_ISFIFO
|
||||
|
||||
@@ -76,7 +76,6 @@ MAJOR MINOR are forbidden for TYPE p, mandatory otherwise. TYPE may be:\n\
|
||||
p create a FIFO\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -97,6 +96,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
symbolic_mode = NULL;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1)
|
||||
|
||||
5
src/mv.c
5
src/mv.c
@@ -379,7 +379,6 @@ the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
simple, never always make simple backups\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -404,6 +403,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
cp_option_init (&x);
|
||||
|
||||
/* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
|
||||
@@ -522,7 +523,5 @@ main (int argc, char **argv)
|
||||
errors |= movefile (file[i], target_directory, dest_is_dir, &x);
|
||||
}
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* nice -- run a program with modified scheduling priority
|
||||
Copyright (C) 1990-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2000 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,7 @@
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "xstrtol.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "nice"
|
||||
@@ -91,6 +92,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# nohup -- run a command immume to hangups, with output to a non-tty
|
||||
# Copyright (C) 1991, 1997, 1999 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 1997, 1999, 2000 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,13 +37,14 @@ if [ $# -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail=0
|
||||
case $# in
|
||||
1 )
|
||||
case "z${1}" in
|
||||
z--help )
|
||||
echo "$usage"; echo "$usage_help"; exit 0 ;;
|
||||
echo "$usage" || fail=1; echo "$usage_help" || fail=1; exit $fail;;
|
||||
z--version )
|
||||
echo "nohup (@GNU_PACKAGE@) @VERSION@"; exit 0 ;;
|
||||
echo "nohup (@GNU_PACKAGE@) @VERSION@" || fail=1; exit $fail;;
|
||||
* ) ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* pathchk -- check whether pathnames are valid or portable
|
||||
Copyright (C) 1991-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pathchk"
|
||||
@@ -139,6 +140,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pinky"
|
||||
@@ -497,6 +498,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, &longind))
|
||||
!= -1)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* printenv -- print all or part of environment
|
||||
Copyright (C) 1989-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1997, 1999, 2000 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
|
||||
@@ -89,6 +89,9 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
close_stdout_set_status (2);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
@@ -132,7 +135,5 @@ main (int argc, char **argv)
|
||||
exit_status = (matches != argc - optind);
|
||||
}
|
||||
|
||||
close_stdout_status (2);
|
||||
|
||||
exit (exit_status);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "closeout.h"
|
||||
#include "unicodeio.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -525,6 +526,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
exit_status = 0;
|
||||
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* pwd - print current directory
|
||||
Copyright (C) 1994-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-1997, 1999, 2000 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,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -65,6 +66,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
132
src/remove.c
132
src/remove.c
@@ -1,5 +1,5 @@
|
||||
/* remove.c -- core functions for removing files and directories
|
||||
Copyright (C) 88, 90, 91, 1994-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1994-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -65,7 +65,7 @@ int rpl_lstat PARAMS((const char *, struct stat *));
|
||||
# define D_INO(dp) 1
|
||||
#endif
|
||||
|
||||
#if !defined (S_ISLNK)
|
||||
#if !defined S_ISLNK
|
||||
# define S_ISLNK(Mode) 0
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,8 @@ extern char *program_name;
|
||||
/* An entry in the active_dir_map. */
|
||||
struct active_dir_ent
|
||||
{
|
||||
ino_t inum;
|
||||
ino_t st_ino;
|
||||
dev_t st_dev;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
@@ -160,11 +161,12 @@ print_nth_dir (FILE *stream, unsigned int depth)
|
||||
}
|
||||
|
||||
static inline struct active_dir_ent *
|
||||
make_active_dir_ent (ino_t inum, unsigned int depth)
|
||||
make_active_dir_ent (ino_t inum, dev_t device, unsigned int depth)
|
||||
{
|
||||
struct active_dir_ent *ent;
|
||||
ent = (struct active_dir_ent *) xmalloc (sizeof *ent);
|
||||
ent->inum = inum;
|
||||
ent->st_ino = inum;
|
||||
ent->st_dev = device;
|
||||
ent->depth = depth;
|
||||
return ent;
|
||||
}
|
||||
@@ -173,7 +175,9 @@ static unsigned int
|
||||
hash_active_dir_ent (void const *x, unsigned int table_size)
|
||||
{
|
||||
struct active_dir_ent const *ade = x;
|
||||
return ade->inum % table_size;
|
||||
|
||||
/* Ignoring the device number here should be fine. */
|
||||
return ade->st_ino % table_size;
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -181,7 +185,7 @@ hash_compare_active_dir_ents (void const *x, void const *y)
|
||||
{
|
||||
struct active_dir_ent const *a = x;
|
||||
struct active_dir_ent const *b = y;
|
||||
return a->inum == b->inum;
|
||||
return SAME_INODE (*a, *b);
|
||||
}
|
||||
|
||||
/* A hash function for null-terminated char* strings using
|
||||
@@ -340,23 +344,29 @@ full_filename (const char *filename)
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline void
|
||||
fspec_init_common (struct File_spec *fs)
|
||||
{
|
||||
fs->have_full_mode = 0;
|
||||
fs->have_filetype_mode = 0;
|
||||
fs->have_device = 0;
|
||||
}
|
||||
|
||||
void
|
||||
fspec_init_file (struct File_spec *fs, const char *filename)
|
||||
{
|
||||
fs->filename = (char *) filename;
|
||||
fs->have_full_mode = 0;
|
||||
fs->have_filetype_mode = 0;
|
||||
fspec_init_common (fs);
|
||||
}
|
||||
|
||||
static inline void
|
||||
fspec_init_dp (struct File_spec *fs, struct dirent *dp)
|
||||
{
|
||||
fs->filename = dp->d_name;
|
||||
fs->have_full_mode = 0;
|
||||
fs->have_filetype_mode = 0;
|
||||
fs->inum = D_INO (dp);
|
||||
fspec_init_common (fs);
|
||||
fs->st_ino = D_INO (dp);
|
||||
|
||||
#if D_TYPE_IN_DIRENT && defined (DT_UNKNOWN) && defined (DTTOIF)
|
||||
#if D_TYPE_IN_DIRENT && defined DT_UNKNOWN && defined DTTOIF
|
||||
if (dp->d_type != DT_UNKNOWN)
|
||||
{
|
||||
fs->have_filetype_mode = 1;
|
||||
@@ -366,15 +376,12 @@ fspec_init_dp (struct File_spec *fs, struct dirent *dp)
|
||||
}
|
||||
|
||||
static inline int
|
||||
fspec_get_full_mode (struct File_spec *fs, mode_t *full_mode)
|
||||
fspec_get_full_mode (struct File_spec *fs)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
|
||||
if (fs->have_full_mode)
|
||||
{
|
||||
*full_mode = fs->mode;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
if (lstat (fs->filename, &stat_buf))
|
||||
return 1;
|
||||
@@ -382,9 +389,31 @@ fspec_get_full_mode (struct File_spec *fs, mode_t *full_mode)
|
||||
fs->have_full_mode = 1;
|
||||
fs->have_filetype_mode = 1;
|
||||
fs->mode = stat_buf.st_mode;
|
||||
fs->inum = stat_buf.st_ino;
|
||||
fs->st_ino = stat_buf.st_ino;
|
||||
fs->have_device = 1;
|
||||
fs->st_dev = stat_buf.st_dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
fspec_get_device_number (struct File_spec *fs)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
|
||||
if (fs->have_device)
|
||||
return 0;
|
||||
|
||||
if (lstat (fs->filename, &stat_buf))
|
||||
return 1;
|
||||
|
||||
fs->have_full_mode = 1;
|
||||
fs->have_filetype_mode = 1;
|
||||
fs->mode = stat_buf.st_mode;
|
||||
fs->st_ino = stat_buf.st_ino;
|
||||
fs->have_device = 1;
|
||||
fs->st_dev = stat_buf.st_dev;
|
||||
|
||||
*full_mode = stat_buf.st_mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -393,15 +422,9 @@ fspec_get_filetype_mode (struct File_spec *fs, mode_t *filetype_mode)
|
||||
{
|
||||
int fail;
|
||||
|
||||
if (fs->have_filetype_mode)
|
||||
{
|
||||
*filetype_mode = fs->mode;
|
||||
fail = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = fspec_get_full_mode (fs, filetype_mode);
|
||||
}
|
||||
fail = fs->have_filetype_mode ? 0 : fspec_get_full_mode (fs);
|
||||
if (!fail)
|
||||
*filetype_mode = fs->mode;
|
||||
|
||||
return fail;
|
||||
}
|
||||
@@ -701,6 +724,34 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
|
||||
return RM_ERROR;
|
||||
}
|
||||
|
||||
/* Verify that the device and inode numbers of `.' are the same as
|
||||
the ones we recorded for dir_name before we cd'd into it. This
|
||||
detects the scenario in which an attacker tries to make Bob's rm
|
||||
command remove some other directory belonging to Bob. The method
|
||||
would be to replace an existing lstat'd but-not-yet-removed directory
|
||||
with a symlink to the target directory. */
|
||||
{
|
||||
struct stat sb;
|
||||
if (lstat (".", &sb))
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("cannot lstat `.' in `%s'"), full_filename (dir_name));
|
||||
|
||||
assert (fs->have_device);
|
||||
if (!SAME_INODE (sb, *fs))
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("ERROR: the directory `%s' initially had device/inode\n\
|
||||
numbers %lu/%lu, but now (after a chdir into it), the numbers for `.'\n\
|
||||
are %lu/%lu. That means that while rm was running, the directory\n\
|
||||
was replaced with either another directory or a link to another directory."),
|
||||
full_filename (dir_name),
|
||||
(unsigned long)(fs->st_dev),
|
||||
(unsigned long)(fs->st_ino),
|
||||
(unsigned long)(sb.st_dev),
|
||||
(unsigned long)(sb.st_ino));
|
||||
}
|
||||
}
|
||||
|
||||
push_dir (dir_name);
|
||||
|
||||
/* Save a copy of dir_name. Otherwise, remove_cwd_entries may clobber
|
||||
@@ -807,15 +858,15 @@ rm (struct File_spec *fs, int user_specified_name, const struct rm_options *x)
|
||||
struct active_dir_ent *old_ent;
|
||||
struct active_dir_ent *new_ent;
|
||||
|
||||
/* If there is already a directory in the map with the same inum,
|
||||
then there's *probably* a directory cycle. This test can get
|
||||
a false positive if two directories have the same inode number
|
||||
but different device numbers, and one directory contains the
|
||||
other. But since people don't often try to delete hierarchies
|
||||
containing mount points, and when they do, duplicate inode
|
||||
numbers are not that likely, this isn't worth detecting. */
|
||||
/* If there is already a directory in the map with the same device
|
||||
and inode numbers, then there is a directory cycle. */
|
||||
|
||||
new_ent = make_active_dir_ent (fs->inum, current_depth ());
|
||||
if (fspec_get_device_number (fs))
|
||||
{
|
||||
error (0, errno, _("cannot stat `%s'"), full_filename (fs->filename));
|
||||
return RM_ERROR;
|
||||
}
|
||||
new_ent = make_active_dir_ent (fs->st_ino, fs->st_dev, current_depth ());
|
||||
old_ent = hash_lookup (active_dir_map, new_ent);
|
||||
if (old_ent)
|
||||
{
|
||||
@@ -825,8 +876,7 @@ This almost certainly means that you have a corrupted file system.\n\
|
||||
NOTIFY YOUR SYSTEM MANAGER.\n\
|
||||
The following two directories have the same inode number:\n"));
|
||||
print_nth_dir (stderr, old_ent->depth);
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, "%s\n", full_filename (fs->filename));
|
||||
fprintf (stderr, "\n%s\n", full_filename (fs->filename));
|
||||
fflush (stderr);
|
||||
|
||||
if (x->interactive)
|
||||
@@ -864,7 +914,9 @@ The following two directories have the same inode number:\n"));
|
||||
struct active_dir_ent *old_ent;
|
||||
|
||||
/* Remove this directory from the active_dir_map. */
|
||||
tmp.inum = fs->inum;
|
||||
tmp.st_ino = fs->st_ino;
|
||||
assert (fs->have_device);
|
||||
tmp.st_dev = fs->st_dev;
|
||||
old_ent = hash_delete (active_dir_map, &tmp);
|
||||
assert (old_ent != NULL);
|
||||
free (old_ent);
|
||||
|
||||
@@ -38,8 +38,10 @@ struct File_spec
|
||||
char *filename;
|
||||
unsigned int have_filetype_mode:1;
|
||||
unsigned int have_full_mode:1;
|
||||
unsigned int have_device:1;
|
||||
mode_t mode;
|
||||
ino_t inum;
|
||||
ino_t st_ino;
|
||||
dev_t st_dev;
|
||||
};
|
||||
|
||||
enum RM_status rm PARAMS ((struct File_spec *fs, int user_specified_name,
|
||||
|
||||
15
src/rm.c
15
src/rm.c
@@ -1,5 +1,5 @@
|
||||
/* `rm' file deletion utility for GNU.
|
||||
Copyright (C) 88, 90, 91, 1994-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 90, 91, 1994-2000 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
|
||||
@@ -96,9 +96,14 @@ Remove (unlink) the FILE(s).\n\
|
||||
-v, --verbose explain what is being done\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
\n\
|
||||
To remove a file whose name starts with a `-', for example `-foo',\n\
|
||||
use one of these commands:\n\
|
||||
%s -- -foo\n\
|
||||
%s ./-foo\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -126,6 +131,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
rm_option_init (&x);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "dfirvR", long_opts, NULL)) != -1)
|
||||
@@ -189,7 +196,5 @@ main (int argc, char **argv)
|
||||
|
||||
remove_fini ();
|
||||
|
||||
if (x.verbose)
|
||||
close_stdout ();
|
||||
exit (fail);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* rmdir -- remove directories
|
||||
Copyright (C) 90, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 90, 91, 1995-2000 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
|
||||
@@ -86,8 +86,7 @@ static struct option const longopts[] =
|
||||
static int
|
||||
errno_rmdir_non_empty (int error_number)
|
||||
{
|
||||
return (error_number == ENOTEMPTY
|
||||
|| error_number == EEXIST);
|
||||
return (error_number == RMDIR_ERRNO_NOT_EMPTY);
|
||||
}
|
||||
|
||||
/* Remove any empty parent directories of PATH.
|
||||
@@ -158,7 +157,6 @@ Remove the DIRECTORY(ies), if they are empty.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -174,6 +172,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
empty_paths = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
#include "xstrtod.h"
|
||||
@@ -338,6 +339,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
equal_width = 0;
|
||||
separator = "\n";
|
||||
first = 1.0;
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
/* Default fileutils build */
|
||||
@@ -476,7 +477,6 @@ Delete a file securely, first overwriting it to hide its contents.\n\
|
||||
\n\
|
||||
FIXME maybe add more discussion here?"), DEFAULT_PASSES);
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -1714,6 +1714,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
isaac_seed (&s);
|
||||
|
||||
memset (&flags, 0, sizeof flags);
|
||||
@@ -1812,8 +1814,6 @@ main (int argc, char **argv)
|
||||
/* Just on general principles, wipe s. */
|
||||
memset (&s, 0, sizeof s);
|
||||
|
||||
close_stdout ();
|
||||
|
||||
exit (err);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "long-options.h"
|
||||
#include "nanosleep.h"
|
||||
#include "xstrtod.h"
|
||||
#include "closeout.h"
|
||||
|
||||
#if HAVE_FENV_H
|
||||
# include <fenv.h>
|
||||
@@ -198,6 +199,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "xstrtol.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "stty"
|
||||
@@ -717,6 +718,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
2
src/su.c
2
src/su.c
@@ -82,6 +82,7 @@
|
||||
#define getusershell _getusershell_sys_proto_
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
|
||||
#undef getusershell
|
||||
|
||||
@@ -449,6 +450,7 @@ Change the effective user id and group id to that of USER.\n\
|
||||
A mere - implies -l. If USER not given, assume root.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ Force changed blocks to disk, update the super block.\n\
|
||||
--version output version information and exit\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -62,6 +61,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
|
||||
@@ -283,6 +283,10 @@ char *stpcpy ();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRNDUP
|
||||
char *strndup ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRSTR
|
||||
char *strstr ();
|
||||
#endif
|
||||
@@ -423,7 +427,6 @@ char *base_name PARAMS ((char const *));
|
||||
#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \
|
||||
case GETOPT_VERSION_CHAR: \
|
||||
version_etc (stdout, Program_name, GNU_PACKAGE, VERSION, Authors); \
|
||||
close_stdout (); \
|
||||
exit (EXIT_SUCCESS); \
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* tee - read from standard input and write to standard output and files.
|
||||
Copyright (C) 85,1990-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 85,1990-2000 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
|
||||
@@ -87,6 +87,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
append = 0;
|
||||
ignore_interrupts = 0;
|
||||
|
||||
@@ -150,8 +152,6 @@ main (int argc, char **argv)
|
||||
if (close (0) != 0)
|
||||
error (1, errno, _("standard input"));
|
||||
|
||||
close_stdout ();
|
||||
|
||||
exit (errs);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Modified to run with the GNU shell by bfox. */
|
||||
|
||||
/* Copyright (C) 1987-1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -973,6 +973,7 @@ posixtest (void)
|
||||
|
||||
#if defined (TEST_STANDALONE)
|
||||
# include "long-options.h"
|
||||
# include "closeout.h"
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
@@ -1080,6 +1081,8 @@ main (int margc, char **margv)
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
#endif /* TEST_STANDALONE */
|
||||
|
||||
argv = margv;
|
||||
|
||||
@@ -52,6 +52,10 @@ time_t time ();
|
||||
# define O_NONBLOCK O_NDELAY
|
||||
#endif
|
||||
|
||||
#if !defined O_NOCTTY
|
||||
# define O_NOCTTY 0
|
||||
#endif
|
||||
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
|
||||
@@ -131,7 +135,7 @@ touch (const char *file)
|
||||
if (! no_create)
|
||||
{
|
||||
/* Try to open FILE, creating it if necessary. */
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK,
|
||||
fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd == -1)
|
||||
open_errno = errno;
|
||||
@@ -227,7 +231,6 @@ Note that the three time-date formats recognized for the -d and -t options\n\
|
||||
and for the obsolescent argument are all different.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
|
||||
close_stdout ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -244,6 +247,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
change_times = no_create = use_ref = posix_date = flexible_date = 0;
|
||||
newtime = (time_t) -1;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "version-etc.h"
|
||||
#include "closeout.h"
|
||||
|
||||
#define PROGRAM_NAME "true"
|
||||
#define AUTHORS "no one"
|
||||
@@ -36,6 +37,8 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
/* Recognize --help or --version only if it's the only command-line
|
||||
argument and if POSIXLY_CORRECT is not set. */
|
||||
if (argc == 2 && getenv ("POSIXLY_CORRECT") == NULL)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user