Compare commits

...

77 Commits

Author SHA1 Message Date
Jim Meyering
0ecb6ace02 . 1998-03-15 20:36:02 +00:00
Jim Meyering
6d42c7e9d7 *** empty log message *** 1998-03-15 18:05:05 +00:00
Jim Meyering
6684ffa826 Use #if, not #ifdef with HAVE_ macros.
Use #if !, not #ifndef with HAVE_ macros.
1998-03-15 17:54:50 +00:00
Jim Meyering
bfbc3ce20c Use #if, not #ifdef with HAVE_ macros 1998-03-15 11:09:10 +00:00
Jim Meyering
0f5f23cb9e . 1998-03-15 09:52:09 +00:00
Jim Meyering
93494dde07 *** empty log message *** 1998-03-15 09:48:52 +00:00
Jim Meyering
be3b9520ad (EXTRA_DIST): Add prereq.m4. 1998-03-15 09:47:28 +00:00
Jim Meyering
c2c6f081c5 *** empty log message *** 1998-03-15 09:47:03 +00:00
Jim Meyering
36b10d9f21 . 1998-03-15 09:45:00 +00:00
Jim Meyering
72c0980585 *** empty log message *** 1998-03-15 09:43:27 +00:00
Jim Meyering
58647fd63d *** empty log message *** 1998-03-15 09:11:44 +00:00
Jim Meyering
6eb5e899e1 *** empty log message *** 1998-03-15 09:10:21 +00:00
Jim Meyering
a01c762a81 *** empty log message *** 1998-03-15 09:08:51 +00:00
Jim Meyering
c29025e6ed (EXTRA_DIST): Add error.m4. 1998-03-15 09:08:39 +00:00
Jim Meyering
b3582e7533 . 1998-03-15 09:07:39 +00:00
Jim Meyering
12f49aa1ae update from fsf 1998-03-15 08:11:02 +00:00
Jim Meyering
f31f7e1c75 *** empty log message *** 1998-03-14 19:53:21 +00:00
Jim Meyering
d34d42ca05 . 1998-03-14 16:39:09 +00:00
Jim Meyering
6974d67aa2 *** empty log message *** 1998-03-14 16:38:41 +00:00
Jim Meyering
85d9447441 . 1998-03-14 16:38:35 +00:00
Jim Meyering
45c381f4ba s/get-date.h/getdate.h/ 1998-03-14 16:35:24 +00:00
Jim Meyering
184c0062a4 s/get-date.h/getdate.h/ 1998-03-14 16:32:35 +00:00
Jim Meyering
7024c7d55c s/get-date.h/getdate.h/ 1998-03-14 16:31:51 +00:00
Jim Meyering
d84a21ea2d . 1998-03-14 16:30:52 +00:00
Jim Meyering
2f6fa9d160 . 1998-03-14 16:26:41 +00:00
Jim Meyering
4ac374c8e5 *** empty log message *** 1998-03-14 16:26:14 +00:00
Jim Meyering
17070ae7bf . 1998-03-14 16:25:42 +00:00
Jim Meyering
a1cc8f5961 *** empty log message *** 1998-03-14 15:56:46 +00:00
Jim Meyering
27caa20d7b *** empty log message *** 1998-03-14 15:32:55 +00:00
Jim Meyering
757555a4dc . 1998-03-14 15:31:41 +00:00
Jim Meyering
ada5e63612 . 1998-03-14 10:42:01 +00:00
Jim Meyering
a8d20df6b2 (TESTS): Add into-self. 1998-03-14 10:41:39 +00:00
Jim Meyering
4a28ea9bd6 *** empty log message *** 1998-03-14 10:41:26 +00:00
Jim Meyering
e4a1ead494 *** empty log message *** 1998-03-14 10:41:02 +00:00
Jim Meyering
ad1a2f76ce *** empty log message *** 1998-03-14 10:40:30 +00:00
Jim Meyering
a7a6111f81 . 1998-03-14 10:37:29 +00:00
Jim Meyering
7c579a0231 . 1998-03-13 23:39:48 +00:00
Jim Meyering
6630a24b7a (copy): Update prototype. 1998-03-13 23:39:39 +00:00
Jim Meyering
6429ffabbb *** empty log message *** 1998-03-13 23:39:10 +00:00
Jim Meyering
e558629ce1 (do_move): Add &copy_into_self arg in call to copy.
Don't remove source directory when copy_into_self is nonzero.
Reported by Arne Henrik Juul.
1998-03-13 23:38:50 +00:00
Jim Meyering
fefa8511b8 (do_copy): Add unused arg in calls to copy. 1998-03-13 23:38:27 +00:00
Jim Meyering
347db9ce77 (copy_dir): Add new parameter, copy_into_self, and set it.
(copy_internal): Likewise.
(copy): Likewise.
Update all callers.
1998-03-13 23:37:42 +00:00
Jim Meyering
92da57a7be Use `virtual memory exhausted' message, not
`Memory exhausted' to be consistent with the majority of other
such messages.
Say `removing all...', not `removing any...'.
1998-03-13 23:35:43 +00:00
Jim Meyering
4078ae8de8 (remove_parents): Be consistent with documentation of
--verbose option and with remove.c in saying `removing...' before
the operation is attempted.
(main): Likewise.
Suggestions from Santiago Vila.
1998-03-13 23:35:25 +00:00
Jim Meyering
3086193091 (usage): Tweak spacing 1998-03-13 15:32:28 +00:00
Jim Meyering
823425b310 *** empty log message *** 1998-03-13 15:27:10 +00:00
Jim Meyering
e03fc9bc82 protoize 1998-03-13 15:25:49 +00:00
Jim Meyering
64379c5cd8 (getugroups): Don't add a group number if it would be a duplicate.
From Ulrich Drepper.
1998-03-13 15:24:43 +00:00
Jim Meyering
d4825df6cf *** empty log message *** 1998-03-11 11:55:31 +00:00
Jim Meyering
cb3b5ed486 (save_stdin): Open temporary file exclusively, to
foil a common denial-of-service attack.
From Paul Eggert.
1998-03-11 11:54:11 +00:00
Jim Meyering
7ee8ed7e37 (xtmpfopen): Open temporary file exclusively, to
foil a common denial-of-service attack.
From Paul Eggert.
1998-03-11 11:53:29 +00:00
Jim Meyering
a991132f3e (getuidbyname) [__DJGPP__]: Make function know about
any arbitrary user name.
(getgidbyname) [__DJGPP__]: Make function know about any arbitrary
group name.
From Eli.
1998-03-10 22:55:20 +00:00
Jim Meyering
7f0867df00 (parse_user_spec) [__DJGPP__]: Make function know
about any arbitrary user and group by pretending to be the user
and to belong to the group specified in `spec_arg' argument.
1998-03-10 22:49:04 +00:00
Jim Meyering
6354d07ea0 . 1998-02-25 23:47:36 +00:00
Jim Meyering
3216105fbb . 1998-02-25 23:46:59 +00:00
Jim Meyering
8d5c4784b8 . 1998-02-25 23:46:13 +00:00
Jim Meyering
ec47f73107 . 1998-02-25 23:36:33 +00:00
Jim Meyering
94cd0c09f6 . 1998-02-25 23:35:53 +00:00
Jim Meyering
db3440d444 . 1998-02-25 22:40:24 +00:00
Jim Meyering
e8bec0725e *** empty log message *** 1998-02-25 22:39:46 +00:00
Jim Meyering
8598c54bb1 Use -include, not `include' for aclocal-files. 1998-02-25 22:39:29 +00:00
Jim Meyering
e457645eac Include new file quotearg.h.
(enum indicator_style): Rename all to classify, and not_programs
to file_type, to match option spellings.  All users changed.
(indicator_style_args): New constant.
(quote_funny_chars, quote_as_string, quote_shell): Remove;
(filename_quoting_options, dirname_quoting_options): Use these
variables instead.
(long_options): Add --indicator-style, --quoting-style,
--show-control-chars.  Remove --quote-shell.
(dired_dump_obstack): Remove style parameter and don't output style.
(main): Go back to previous method of outputting //DIRED//
and //SUBDIRED// lines, without style.  But add a new
//DIRED-OPTIONS// line that does output style.
(decode_switches, usage): Add --indicator-style, --quoting-style,
--show-control-chars.  Remove --quote-shell.
(decode_switches): Default from QUOTING_STYLE environment variable.
Set new quoting vars.
(quote_name): Renamed from quote_filename.
Take new arg specifying quoting options.
Always print; do not have a special case for null FILE * argument.
All callers changed.
Move the guts of this function to new file quotearg.c.
(length_of_file_name_and_frills): Use quotearg_buffer instead
of (old) quote_filename to find length of file name.
(decode_switches, parse_ls_color, print_dir, gobble_file,
get_link_name):	Quote output in diagnostics.
1998-02-25 22:38:12 +00:00
Jim Meyering
a14303dbc9 *** empty log message *** 1998-02-25 08:20:55 +00:00
Jim Meyering
84ad5c47c8 (TYPE_SIGNED): Define.
(TYPE_MAXIMUM): Define.
(ULONG_MAX): Use TYPE_MAXIMUM.
(LONG_MAX): Use TYPE_MAXIMUM.
1998-02-24 23:33:41 +00:00
Jim Meyering
998b3a148c (libfu_a_SOURCES): Add quotearg.c.
(noinst_HEADERS): Add quotearg.h.
1998-02-24 23:31:40 +00:00
Jim Meyering
71ee764f1e . 1998-02-24 23:31:11 +00:00
Jim Meyering
07a6f7a9e2 protoize 1998-02-24 23:19:33 +00:00
Jim Meyering
0f5ca22215 add comment 1998-02-24 23:19:13 +00:00
Jim Meyering
fc50286759 update from libit 1998-02-24 23:18:23 +00:00
Jim Meyering
0a1fd1d2ad protoize 1998-02-24 23:17:38 +00:00
Jim Meyering
7a04e95c62 capitalize macro params and protoize 1998-02-24 22:59:34 +00:00
Jim Meyering
938e7fe7ef add copyright 1998-02-24 22:58:26 +00:00
Jim Meyering
d8ab75cedc Update from libit. 1998-02-24 22:54:10 +00:00
Jim Meyering
650b182278 . 1998-02-23 10:16:53 +00:00
Jim Meyering
f31f7889fb *** empty log message *** 1998-02-22 12:36:32 +00:00
Jim Meyering
b1f2e5a7fd *** empty log message *** 1998-02-22 12:31:06 +00:00
Jim Meyering
34141257cf . 1998-02-22 12:30:47 +00:00
88 changed files with 1520 additions and 585 deletions

View File

@@ -55,7 +55,7 @@ aclocal-files: configure.in m4/Makefile.am
echo >> $@-tmp
mv $@-tmp $@
include aclocal-files
-include aclocal-files
# Override default rule to use --acdir option
$(srcdir)/aclocal.m4: configure.in $(acfiles)

1
THANKS
View File

@@ -11,6 +11,7 @@ Charles Karney: karney@pppl.gov
Eirik Fuller: eirik@netcom.com
Eli Zaretskii: eliz@is.elta.co.il
Emile LeBlanc: leblanc@math.toronto.edu
François Pinard: pinard@iro.umontreal.ca
Galen Hazelwood: galenh@micron.net
Greg McGary: gkm@eng.ascend.com
Hugh Daniel: hugh@xanadu.com

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -114,7 +114,7 @@ GZIP = --best
default: all
.SUFFIXES:
.SUFFIXES: .dvi .info .ps .texi .texinfo
.SUFFIXES: .dvi .info .ps .texi .texinfo .txi
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits doc/Makefile
@@ -179,6 +179,20 @@ DVIPS = dvips
.texinfo.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi.info:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.txi.dvi:
TEXINPUTS=$(srcdir):$$TEXINPUTS \
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
.txi:
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
cd $(srcdir) \
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
.dvi.ps:
$(DVIPS) $< -o $@
@@ -211,7 +225,7 @@ uninstall-info:
test -z "$ii" \
|| install-info --info-dir=$(infodir) --remove $$file; \
done
$(NORMAL_UNINSTALL)
@$(NORMAL_UNINSTALL)
for file in $(INFO_DEPS); do \
(cd $(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
done

View File

@@ -14,7 +14,7 @@ addext.c argmatch.c backupfile.c basename.c \
closeout.c dirname.c exclude.c filemode.c \
full-write.c human.c idcache.c \
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
@@ -22,8 +22,8 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
get-date.h getline.h getopt.h group-member.h human.h long-options.h \
getdate.h getline.h getopt.h group-member.h human.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
quotearg.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -101,7 +101,7 @@ addext.c argmatch.c backupfile.c basename.c \
closeout.c dirname.c exclude.c filemode.c \
full-write.c human.c idcache.c \
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c xgetcwd.c \
xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
@@ -109,9 +109,9 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
get-date.h getline.h getopt.h group-member.h human.h long-options.h \
getdate.h getline.h getopt.h group-member.h human.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
quotearg.h save-cwd.h savedir.h strverscmp.h xalloc.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -129,9 +129,9 @@ libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
addext$U.o argmatch$U.o backupfile$U.o basename$U.o closeout$U.o \
dirname$U.o exclude$U.o filemode$U.o full-write$U.o human$U.o \
idcache$U.o isdir$U.o long-options$U.o makepath$U.o modechange$U.o \
hash$U.o path-concat$U.o safe-read$U.o save-cwd$U.o savedir$U.o \
stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o xstrdup$U.o \
xstrtol$U.o xstrtoul$U.o yesno$U.o
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
savedir$U.o stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o \
xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
AR = ar
YLWRAP = $(srcdir)/ylwrap
CFLAGS = @CFLAGS@
@@ -156,27 +156,27 @@ DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
.deps/backupfile.P .deps/basename.P .deps/chown.P .deps/closeout.P \
.deps/dirname.P .deps/error.P .deps/euidaccess.P .deps/exclude.P \
.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/fsusage.P \
.deps/ftruncate.P .deps/full-write.P .deps/getdate.P .deps/getgroups.P \
.deps/getline.P .deps/getopt.P .deps/getopt1.P .deps/group-member.P \
.deps/hash.P .deps/human.P .deps/idcache.P .deps/isdir.P \
.deps/long-options.P .deps/lstat.P .deps/makepath.P .deps/malloc.P \
.deps/memcmp.P .deps/memcpy.P .deps/memset.P .deps/mkdir.P \
.deps/mktime.P .deps/modechange.P .deps/mountlist.P .deps/obstack.P \
.deps/path-concat.P .deps/posixtm.P .deps/realloc.P .deps/regex.P \
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.P \
.deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stat.P \
.deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P \
.deps/stripslash.P .deps/strndup.P .deps/strstr.P .deps/strtol.P \
.deps/strtoul.P .deps/strverscmp.P .deps/userspec.P .deps/xgetcwd.P \
.deps/xmalloc.P .deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P \
.deps/yesno.P
.deps/ftruncate.P .deps/full-write.P .deps/getdate .deps/getdate.P \
.deps/getgroups.P .deps/getline.P .deps/getopt.P .deps/getopt1.P \
.deps/group-member.P .deps/hash.P .deps/human.P .deps/idcache.P \
.deps/isdir.P .deps/long-options.P .deps/lstat.P .deps/makepath.P \
.deps/malloc.P .deps/memcmp.P .deps/memcpy.P .deps/memset.P \
.deps/mkdir.P .deps/mktime.P .deps/modechange.P .deps/mountlist.P \
.deps/obstack.P .deps/path-concat.P .deps/posixtm .deps/posixtm.P \
.deps/quotearg.P .deps/realloc.P .deps/regex.P .deps/rename.P \
.deps/rmdir.P .deps/rpmatch.P .deps/rx.P .deps/safe-read.P \
.deps/save-cwd.P .deps/savedir.P .deps/stat.P .deps/stpcpy.P \
.deps/strcasecmp.P .deps/strdup.P .deps/strftime.P .deps/stripslash.P \
.deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \
.deps/strverscmp.P .deps/userspec.P .deps/xgetcwd.P .deps/xmalloc.P \
.deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
SOURCES = $(libfu_a_SOURCES)
OBJECTS = $(libfu_a_OBJECTS)
default: all
.SUFFIXES:
.SUFFIXES: .S .c .h .o .s .y
.SUFFIXES: .S .c .o .s .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile
@@ -194,9 +194,6 @@ distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
@@ -204,7 +201,7 @@ maintainer-clean-noinstLIBRARIES:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core
-rm -f *.o core *.core
clean-compile:
@@ -231,8 +228,9 @@ libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
$(RANLIB) libfu.a
.y.c:
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
.y.h:
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
posixtm.h: posixtm.c
getdate.h: getdate.c
addext_.c: addext.c $(ANSI2KNR)
$(ANSI2KNR) `if test -f $(srcdir)/addext.c; then echo $(srcdir)/addext.c; else echo addext.c; fi` addext_.c
alloca_.c: alloca.c $(ANSI2KNR)
@@ -315,6 +313,8 @@ path-concat_.c: path-concat.c $(ANSI2KNR)
$(ANSI2KNR) `if test -f $(srcdir)/path-concat.c; then echo $(srcdir)/path-concat.c; else echo path-concat.c; fi` path-concat_.c
posixtm_.c: posixtm.c $(ANSI2KNR)
$(ANSI2KNR) `if test -f $(srcdir)/posixtm.c; then echo $(srcdir)/posixtm.c; else echo posixtm.c; fi` posixtm_.c
quotearg_.c: quotearg.c $(ANSI2KNR)
$(ANSI2KNR) `if test -f $(srcdir)/quotearg.c; then echo $(srcdir)/quotearg.c; else echo quotearg.c; fi` quotearg_.c
realloc_.c: realloc.c $(ANSI2KNR)
$(ANSI2KNR) `if test -f $(srcdir)/realloc.c; then echo $(srcdir)/realloc.c; else echo realloc.c; fi` realloc_.c
regex_.c: regex.c $(ANSI2KNR)
@@ -376,11 +376,11 @@ getgroups_.o getline_.o getopt_.o getopt1_.o group-member_.o hash_.o \
human_.o idcache_.o isdir_.o long-options_.o lstat_.o makepath_.o \
malloc_.o memcmp_.o memcpy_.o memset_.o mkdir_.o mktime_.o \
modechange_.o mountlist_.o obstack_.o path-concat_.o posixtm_.o \
realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o rx_.o safe-read_.o \
save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o strdup_.o \
strftime_.o stripslash_.o strndup_.o strstr_.o strtol_.o strtoul_.o \
strverscmp_.o userspec_.o xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o \
xstrtoul_.o yesno_.o : $(ANSI2KNR)
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o rx_.o \
safe-read_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
strdup_.o strftime_.o stripslash_.o strndup_.o strstr_.o strtol_.o \
strtoul_.o strverscmp_.o userspec_.o xgetcwd_.o xmalloc_.o xstrdup_.o \
xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
tags: TAGS
@@ -391,8 +391,12 @@ ID: $(HEADERS) $(SOURCES) $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) $(LISP) -o $$here/TAGS)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
@@ -420,12 +424,7 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file; \
done
MKDEP = $(CC) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include .deps/.P
.deps/.P: $(BUILT_SOURCES)
echo > $@
-include $(DEP_FILES)
@@ -438,13 +437,16 @@ distclean-depend:
maintainer-clean-depend:
-rm -rf .deps
.deps/%.P: %.c
@echo "Computing dependencies for $<..."
@o='o'; \
test -n "$o" && o='$$o'; \
$(MKDEP) $< >$@.tmp \
&& sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," < $@.tmp > $@ \
&& rm -f $@.tmp
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).P -c $<
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<
@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
< .deps/$(*F).p > .deps/$(*F).P
@-rm -f .deps/$(*F).p
info:
dvi:
check: all

View File

@@ -1,15 +1,30 @@
/* basename.c -- return the last element in a path */
/* basename.c -- return the last element in a path
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef FILESYSTEM_PREFIX_LEN
# define FILESYSTEM_PREFIX_LEN(f) 0
# define FILESYSTEM_PREFIX_LEN(Filename) 0
#endif
#ifndef ISSLASH
# define ISSLASH(c) ((c) == '/')
# define ISSLASH(C) ((C) == '/')
#endif
/* In general, we can't use the builtin `basename' function if available,
@@ -17,8 +32,7 @@
In some environments the builtin `basename' modifies its argument. */
char *
base_name (name)
char const *name;
base_name (char const *name)
{
char const *base = name += FILESYSTEM_PREFIX_LEN (name);

View File

@@ -27,7 +27,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#if HAVE_UNISTD_H
# include <unistd.h>
#endif

View File

@@ -26,7 +26,7 @@
# define _(Text) Text
#endif
#ifdef HAVE_STDLIB_H
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifndef EXIT_FAILURE

View File

@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif

View File

@@ -1,10 +1,14 @@
/* error.c -- error handler for noninteractive utilities
Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
/* Error handler for noninteractive utilities
Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -12,13 +16,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#if HAVE_CONFIG_H
# include <config.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
@@ -43,12 +48,11 @@
void exit ();
#endif
#ifndef _
# define _(String) String
#endif
#include "error.h"
/* Get prototypes for the functions defined here. */
#include <error.h>
#ifndef _
#define _(String) String
#endif
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
@@ -65,15 +69,21 @@ unsigned int error_message_count;
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */
# define program_name program_invocation_name
# include <errno.h>
#define program_name program_invocation_name
#include <errno.h>
#else /* not _LIBC */
/* In GNU libc we want do not want to use the common name `error' directly.
Instead make it a weak alias. */
#define error __error
#define error_at_line __error_at_line
#else
/* The calling program should define program_name and set it to the
name of the executing program. */
extern char *program_name;
#ifndef HAVE_STRERROR_R
# if HAVE_STRERROR
# ifndef strerror /* On some systems, strerror is a macro */
char *strerror ();
@@ -87,13 +97,13 @@ private_strerror (errnum)
extern int sys_nerr;
if (errnum > 0 && errnum <= sys_nerr)
return sys_errlist[errnum];
return _(sys_errlist[errnum]);
return _("Unknown system error");
}
# define strerror private_strerror
# endif /* HAVE_STRERROR */
#endif /* not _LIBC */
#endif /* HAVE_STRERROR_R */
#endif /* _LIBC */
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
@@ -138,7 +148,14 @@ error (status, errnum, message, va_alist)
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
{
#if defined HAVE_STRERROR_R || defined _LIBC
char errbuf[1024];
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
#else
fprintf (stderr, ": %s", strerror (errnum));
#endif
}
putc ('\n', stderr);
fflush (stderr);
if (status)
@@ -206,9 +223,24 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
++error_message_count;
if (errnum)
fprintf (stderr, ": %s", strerror (errnum));
{
#if defined HAVE_STRERROR_R || defined _LIBC
char errbuf[1024];
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
#else
fprintf (stderr, ": %s", strerror (errnum));
#endif
}
putc ('\n', stderr);
fflush (stderr);
if (status)
exit (status);
}
#ifdef _LIBC
/* Make the weak alias. */
#undef error
#undef error_at_line
weak_alias (__error, error)
weak_alias (__error_at_line, error_at_line)
#endif

View File

@@ -1,10 +1,14 @@
/* error.h -- declaration for error-reporting function
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
/* Declaration for error-reporting function
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -12,26 +16,31 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef ERROR_H_
# define ERROR_H_
#ifndef _ERROR_H
#define _ERROR_H 1
# ifndef __attribute__
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __format__ format
# define __printf__ printf
# endif
#endif
# if defined (__STDC__) && __STDC__
#ifdef __cplusplus
extern "C" {
#endif
#if defined (__STDC__) && __STDC__
/* Print a message with `fprintf (stderr, FORMAT, ...)';
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
@@ -49,11 +58,11 @@ extern void error_at_line (int status, int errnum, const char *fname,
function without parameters instead. */
extern void (*error_print_progname) (void);
# else
#else
void error ();
void error_at_line ();
extern void (*error_print_progname) ();
# endif
#endif
/* This variable is incremented each time `error' is called. */
extern unsigned int error_message_count;
@@ -62,4 +71,8 @@ extern unsigned int error_message_count;
variable controls whether this mode is selected or not. */
extern int error_one_per_line;
#endif /* not ERROR_H_ */
#ifdef __cplusplus
}
#endif
#endif /* error.h */

View File

@@ -21,7 +21,7 @@ Suite 330, Boston, MA 02111-1307, USA. */
/* Written by David MacKenzie and Torbjorn Granlund.
Adapted for GNU C library by Roland McGrath. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@@ -111,7 +111,7 @@ static gid_t egid;
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
static int have_ids = 0;
# ifdef HAVE_GETGROUPS
# if HAVE_GETGROUPS
int group_member ();
# else
# define group_member(gid) 0

View File

@@ -17,7 +17,7 @@
/* Written by Brian L. Matthews, blm@6sceng.UUCP. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif

View File

@@ -1,5 +1,5 @@
/* filemode.c -- make a string describing file modes
Copyright (C) 1985, 1990, 1993 Free Software Foundation, Inc.
Copyright (C) 1985, 1990, 1993, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
@@ -47,45 +47,45 @@
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISBLK
#undef S_ISCHR
#undef S_ISDIR
#undef S_ISFIFO
#undef S_ISLNK
#undef S_ISMPB
#undef S_ISMPC
#undef S_ISNWK
#undef S_ISREG
#undef S_ISSOCK
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISBLK) && defined(S_IFBLK)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined(S_ISCHR) && defined(S_IFCHR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG) && defined(S_IFREG)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISFIFO) && defined(S_IFIFO)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
#endif
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
void mode_string ();

View File

@@ -1,37 +1,52 @@
/* Copyright (C) 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
/* Enable GNU extensions in fnmatch.h. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#if defined (STDC_HEADERS) || !defined (isascii)
# define ISASCII(c) 1
#else
# define ISASCII(c) isascii(c)
#endif
#define ISUPPER(c) (ISASCII (c) && isupper (c))
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined _LIBC || !defined __GNU_LIBRARY__
# if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
# else
# define ISASCII(c) isascii(c)
# endif
# define ISUPPER(c) (ISASCII (c) && isupper (c))
# ifndef errno
extern int errno;
@@ -49,7 +64,7 @@ fnmatch (pattern, string, flags)
register char c;
/* Note that this evaluates C many times. */
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
while ((c = *p++) != '\0')
{
@@ -71,6 +86,9 @@ fnmatch (pattern, string, flags)
if (!(flags & FNM_NOESCAPE))
{
c = *p++;
if (c == '\0')
/* Trailing \ loses. */
return FNM_NOMATCH;
c = FOLD (c);
}
if (FOLD (*n) != c)
@@ -82,10 +100,24 @@ fnmatch (pattern, string, flags)
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
if (((flags & FNM_FILE_NAME) && *n == '/') ||
(c == '?' && *n == '\0'))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++)
{
if ((flags & FNM_FILE_NAME) && *n == '/')
/* A slash does not match a wildcard under FNM_FILE_NAME. */
return FNM_NOMATCH;
else if (c == '?')
{
/* A ? needs to match one character. */
if (*n == '\0')
/* There isn't another character; no match. */
return FNM_NOMATCH;
else
/* One character of the string is consumed in matching
this ? wildcard, so *??? won't match if there are
less than three characters. */
++n;
}
}
if (c == '\0')
return 0;
@@ -122,7 +154,11 @@ fnmatch (pattern, string, flags)
register char cstart = c, cend = c;
if (!(flags & FNM_NOESCAPE) && c == '\\')
cstart = cend = *p++;
{
if (*p == '\0')
return FNM_NOMATCH;
cstart = cend = *p++;
}
cstart = cend = FOLD (cstart);
@@ -169,8 +205,12 @@ fnmatch (pattern, string, flags)
c = *p++;
if (!(flags & FNM_NOESCAPE) && c == '\\')
/* XXX 1003.2d11 is unclear if this is right. */
++p;
{
if (*p == '\0')
return FNM_NOMATCH;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
}
if (not)
return FNM_NOMATCH;
@@ -196,3 +236,5 @@ fnmatch (pattern, string, flags)
# undef FOLD
}
#endif /* _LIBC or not __GNU_LIBRARY__. */

View File

@@ -1,8 +1,8 @@
/* ftruncate emulations that work on some System V's.
This file is in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
@@ -19,15 +19,15 @@ ftruncate (fd, length)
}
#else /* not F_CHSIZE */
#ifdef F_FREESP
# ifdef F_FREESP
/* By William Kucharski <kucharsk@netcom.com>. */
#include <sys/stat.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
# include <sys/stat.h>
# include <errno.h>
# if HAVE_UNISTD_H
# include <unistd.h>
# endif
int
ftruncate (fd, length)
@@ -71,8 +71,8 @@ ftruncate (fd, length)
return 0;
}
#else /* not F_CHSIZE nor F_FREESP */
#ifdef HAVE_CHSIZE
# else /* not F_CHSIZE nor F_FREESP */
# if HAVE_CHSIZE
int
ftruncate (fd, length)
@@ -82,12 +82,12 @@ ftruncate (fd, length)
return chsize (fd, length);
}
#else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
# else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
#include <errno.h>
#ifndef errno
# include <errno.h>
# ifndef errno
extern int errno;
#endif
# endif
int
ftruncate (fd, length)
@@ -98,6 +98,6 @@ ftruncate (fd, length)
return -1;
}
#endif /* not HAVE_CHSIZE */
#endif /* not F_FREESP */
# endif /* not HAVE_CHSIZE */
# endif /* not F_FREESP */
#endif /* not F_CHSIZE */

View File

@@ -1,5 +1,5 @@
/* full-write.c -- an interface to write that retries after interrupts
Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,10 +37,7 @@ extern int errno;
Return LEN upon success, write's (negative) error code otherwise. */
int
full_write (desc, ptr, len)
int desc;
char *ptr;
size_t len;
full_write (int desc, const char *ptr, size_t len)
{
int total_written;

46
lib/getdate.h Normal file
View File

@@ -0,0 +1,46 @@
/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
#ifdef vms
# include <types.h>
# include <time.h>
#else
# include <sys/types.h>
# if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
#endif /* defined (vms) */
time_t get_date PARAMS ((const char *p, const time_t *now));

View File

@@ -439,7 +439,7 @@ o_merid : /* NULL */
/* Include this file down here because bison inserts code above which
may define-away `const'. We want the prototype for get_date to have
the same signature as the function definition does. */
#include "get-date.h"
#include "getdate.h"
extern struct tm *gmtime ();
extern struct tm *localtime ();

View File

@@ -1,5 +1,5 @@
/* getugroups.c -- return a list of the groups a user is in
Copyright (C) 1990, 1991 Free Software Foundation.
Copyright (C) 1990, 1991, 1998 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,10 +45,7 @@ struct group *getgrent ();
the current process. */
int
getugroups (maxcount, grouplist, username)
int maxcount;
GETGROUPS_T *grouplist;
char *username;
getugroups (int maxcount, GETGROUPS_T *grouplist, char *username)
{
struct group *grp;
register char **cp;
@@ -59,16 +56,27 @@ getugroups (maxcount, grouplist, username)
for (cp = grp->gr_mem; *cp; ++cp)
if (!strcmp (username, *cp))
{
if (maxcount != 0)
int n;
/* See if this group number is already on the list. */
for (n = 0; n < count; ++n)
if (grouplist[n] == grp->gr_gid)
break;
/* If it's a new group number, then try to add it to the list. */
if (n == count)
{
if (count >= maxcount)
if (maxcount != 0)
{
endgrent ();
return count;
if (count >= maxcount)
{
endgrent ();
return count;
}
grouplist[count] = grp->gr_gid;
}
grouplist[count] = grp->gr_gid;
count++;
}
count++;
}
endgrent ();
return count;

View File

@@ -1,5 +1,5 @@
/* group-member.c -- determine whether group id is in calling user's group list
Copyright (C) 1994, 1997 Free Software Foundation, Inc.
Copyright (C) 1994, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@@ -26,7 +26,7 @@
# include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -41,7 +41,7 @@ struct group_info
GETGROUPS_T *group;
};
#ifdef HAVE_GETGROUPS
#if HAVE_GETGROUPS
static void
free_group_info (struct group_info *g)

View File

@@ -1,5 +1,5 @@
/* idcache.c -- map user and group IDs, cached for speed
Copyright (C) 1985, 1988, 1989, 1990, 1997 Free Software Foundation, Inc.
Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
#include <pwd.h>
#include <grp.h>
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#if STDC_HEADERS || HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
@@ -44,6 +44,10 @@ struct group *getgrnam ();
char *xmalloc ();
char *xstrdup ();
#ifdef __DJGPP__
static char digits[] = "0123456789";
#endif
struct userid
{
union
@@ -55,23 +59,15 @@ struct userid
struct userid *next;
};
/* The members of this list have already been looked up.
If a name is NULL, the corresponding id is not in the password file. */
static struct userid *user_alist;
#ifdef NOT_USED
/* The members of this list are names not in the local passwd file;
their names are always not NULL, and their ids are irrelevant. */
/* The members of this list have names not in the local passwd file. */
static struct userid *nouser_alist;
#endif /* NOT_USED */
/* Translate UID to a login name, with cache.
If UID cannot be resolved, return NULL.
Cache lookup failures, too. */
/* Translate UID to a login name, with cache, or NULL if unresolved. */
char *
getuser (uid)
uid_t uid;
getuser (uid_t uid)
{
register struct userid *tail;
struct passwd *pwent;
@@ -83,31 +79,28 @@ getuser (uid)
pwent = getpwuid (uid);
tail = (struct userid *) xmalloc (sizeof (struct userid));
tail->id.u = uid;
tail->name = (pwent ? xstrdup (pwent->pw_name) : NULL);
tail->name = pwent ? xstrdup (pwent->pw_name) : NULL;
/* Add to the head of the list, so most recently added is first. */
/* Add to the head of the list, so most recently used is first. */
tail->next = user_alist;
user_alist = tail;
return tail->name;
}
#ifdef NOT_USED
/* Translate USER to a UID, with cache.
Return NULL if there is no such user.
(We also cache which user names have no passwd entry,
so we don't keep looking them up.) */
uid_t *
getuidbyname (user)
const char *user;
getuidbyname (const char *user)
{
register struct userid *tail;
struct passwd *pwent;
for (tail = user_alist; tail; tail = tail->next)
/* Avoid a function call for the most common case. */
if (tail->name && *tail->name == *user && !strcmp (tail->name, user))
if (*tail->name == *user && !strcmp (tail->name, user))
return &tail->id.u;
for (tail = nouser_alist; tail; tail = tail->next)
@@ -116,11 +109,20 @@ getuidbyname (user)
return 0;
pwent = getpwnam (user);
#ifdef __DJGPP__
/* We need to pretend to be the user USER, to make
pwd functions know about an arbitrary user name. */
if (!pwent && strspn (user, digits) < strlen (user))
{
setenv ("USER", user, 1);
pwent = getpwnam (user); /* now it will succeed */
}
#endif
tail = (struct userid *) xmalloc (sizeof (struct userid));
tail->name = xstrdup (user);
/* Add to the head of the list, so most recently added is first. */
/* Add to the head of the list, so most recently used is first. */
if (pwent)
{
tail->id.u = pwent->pw_uid;
@@ -134,20 +136,14 @@ getuidbyname (user)
return 0;
}
#endif /* NOT_USED */
/* Use the same struct as for userids. */
static struct userid *group_alist;
#ifdef NOT_USED
static struct userid *nogroup_alist;
#endif
/* Translate GID to a group name, with cache.
Return NULL if the group has no name. */
/* Translate GID to a group name, with cache, or NULL if unresolved. */
char *
getgroup (gid)
gid_t gid;
getgroup (gid_t gid)
{
register struct userid *tail;
struct group *grent;
@@ -159,7 +155,7 @@ getgroup (gid)
grent = getgrgid (gid);
tail = (struct userid *) xmalloc (sizeof (struct userid));
tail->id.g = gid;
tail->name = (grent ? xstrdup (grent->gr_name) : NULL);
tail->name = grent ? xstrdup (grent->gr_name) : NULL;
/* Add to the head of the list, so most recently used is first. */
tail->next = group_alist;
@@ -167,23 +163,20 @@ getgroup (gid)
return tail->name;
}
#ifdef NOT_USED
/* Translate GROUP to a GID, with cache.
Return NULL if there is no such group.
(We also cache which group names have no group entry,
so we don't keep looking them up.) */
gid_t *
getgidbyname (group)
const char *group;
getgidbyname (const char *group)
{
register struct userid *tail;
struct group *grent;
for (tail = group_alist; tail; tail = tail->next)
/* Avoid a function call for the most common case. */
if (tail->name && *tail->name == *group && !strcmp (tail->name, group))
if (*tail->name == *group && !strcmp (tail->name, group))
return &tail->id.g;
for (tail = nogroup_alist; tail; tail = tail->next)
@@ -192,6 +185,15 @@ getgidbyname (group)
return 0;
grent = getgrnam (group);
#ifdef __DJGPP__
/* We need to pretend to belong to group GROUP, to make
grp functions know about any arbitrary group name. */
if (!grent && strspn (group, digits) < strlen (group))
{
setenv ("GROUP", group, 1);
grent = getgrnam (group); /* now it will succeed */
}
#endif
tail = (struct userid *) xmalloc (sizeof (struct userid));
tail->name = xstrdup (group);
@@ -209,5 +211,3 @@ getgidbyname (group)
nogroup_alist = tail;
return 0;
}
#endif /* NOT_USED */

View File

@@ -1,5 +1,5 @@
/* isdir.c -- determine whether a directory exists
Copyright (C) 1990 Free Software Foundation, Inc.
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,19 +15,19 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
# undef S_ISDIR
#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* If PATH is an existing directory or symbolic link to a directory,

View File

@@ -17,7 +17,7 @@
/* Written by Jim Meyering. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif

View File

@@ -1,4 +1,5 @@
/* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
/* mktime: convert a `struct tm' to a time_t value
Copyright (C) 1993-1997, 1998 Free Software Foundation, Inc.
Contributed by Paul Eggert (eggert@twinsun.com).
NOTE: The canonical source of this file is maintained with the GNU C Library.

View File

@@ -1,5 +1,5 @@
/* mountlist.c -- return a list of mounted filesystems
Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@@ -42,7 +42,7 @@ char *xrealloc ();
char *xstrdup ();
void error ();
#ifdef HAVE_SYS_PARAM_H
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
@@ -101,7 +101,7 @@ void error ();
# define MOUNTED_GETMNTTBL
#endif
#ifdef HAVE_SYS_MNTENT_H
#if HAVE_SYS_MNTENT_H
/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
# include <sys/mntent.h>
#endif

View File

@@ -1,5 +1,5 @@
/* path-concat.c -- concatenate two arbitrary pathnames
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
/* Written by Jim Meyering. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@@ -26,7 +26,7 @@
#endif
#include <stdio.h>
#ifdef HAVE_STRING_H
#if HAVE_STRING_H
# include <string.h>
#endif
#include <sys/types.h>

346
lib/quotearg.c Normal file
View File

@@ -0,0 +1,346 @@
/* quotearg.c - quote arguments for output
Copyright (C) 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert <eggert@twinsun.com> */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <quotearg.h>
#include <xalloc.h>
#include <ctype.h>
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define ISASCII(c) 1
#else
# define ISASCII(c) isascii (c)
#endif
#ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
#else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
#endif
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
#ifndef UCHAR_MAX
# define UCHAR_MAX ((unsigned char) -1)
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#define INT_BITS (sizeof (int) * CHAR_BIT)
struct quoting_options
{
/* Basic quoting style. */
enum quoting_style style;
/* Quote the chararacters indicated by this bit vector even if the
quoting style would not normally require them to be quoted. */
int quote_these_too[((UCHAR_MAX + 1) / INT_BITS
+ ((UCHAR_MAX + 1) % INT_BITS != 0))];
};
/* Names of quoting styles. */
char const *const quoting_style_args[] =
{
"literal", "shell", "shell-always", "c", "escape", 0
};
/* Allocate a new set of quoting options, with contents initially identical
to O if O is not null, or to a default value if O is null.
It is the caller's responsibility to free the result. */
struct quoting_options *
clone_quoting_options (struct quoting_options *o)
{
struct quoting_options *p
= (struct quoting_options *) xmalloc (sizeof (struct quoting_options));
if (o)
*p = *o;
else
memset (p, 0, sizeof *p);
return p;
}
/* Get the value of O's quoting style. */
enum quoting_style
get_quoting_style (struct quoting_options *o)
{
return o->style;
}
/* In O, set the value of the quoting style to S. */
void
set_quoting_style (struct quoting_options *o, enum quoting_style s)
{
o->style = s;
}
/* In O, set the value of the quoting options for character C to I.
Return the old value. Currently, the only values defined for I are
0 (the default) and 1 (which means to quote the character even if
it would not otherwise be quoted). */
int
set_char_quoting (struct quoting_options *o, char c, int i)
{
unsigned char uc = c;
int *p = o->quote_these_too + uc / INT_BITS;
int shift = uc % INT_BITS;
int r = (*p >> shift) & 1;
*p ^= ((i & 1) ^ r) << shift;
return r;
}
/* Place into buffer BUF (of size BUFSIZE) a quoted version of
argument ARG (of size ARGSIZE), using O to control quoting.
Terminate the output with a null character, and return the written
size of the output, not counting the terminating null.
If BUFSIZE is too small to store the output string, return the
value that would have been returned had BUFSIZE been large enough.
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
size_t
quotearg_buffer (char *buf, size_t bufsize,
char const *arg, size_t argsize,
struct quoting_options const *o)
{
unsigned char c;
size_t i;
size_t len;
int quote_mark;
enum quoting_style quoting_style = o->style;
#define STORE(c) do { if (len < bufsize) buf[len] = (c); len++; } while (0)
switch (quoting_style)
{
case shell_quoting_style:
if (! (argsize == -1 ? arg[0] == '\0' : argsize == 0))
{
switch (arg[0])
{
case '#': case '~':
break;
default:
len = 0;
for (i = 0; ; i++)
{
if (argsize == -1 ? arg[i] == '\0' : i == argsize)
goto done;
c = arg[i];
switch (c)
{
case '\t': case '\n': case ' ':
case '!': /* special in csh */
case '"': case '$': case '&': case '\'':
case '(': case ')': case '*': case ';':
case '<': case '>': case '?': case '[': case '\\':
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
case '`': case '|':
goto needs_quoting;
}
if (o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))
goto needs_quoting;
STORE (c);
}
needs_quoting:;
break;
}
}
/* Fall through. */
case shell_always_quoting_style:
quote_mark = '\'';
break;
case c_quoting_style:
quote_mark = '"';
break;
default:
quote_mark = 0;
break;
}
len = 0;
if (quote_mark)
STORE (quote_mark);
for (i = 0; ! (argsize == -1 ? arg[i] == '\0' : i == argsize); i++)
{
c = arg[i];
switch (quoting_style)
{
case literal_quoting_style:
break;
case shell_quoting_style:
case shell_always_quoting_style:
if (c == '\'')
{
STORE ('\'');
STORE ('\\');
STORE ('\'');
}
break;
case c_quoting_style:
case escape_quoting_style:
switch (c)
{
case '?': /* Do not generate trigraphs. */
case '\\': goto store_escape;
/* Not all C compilers know what \a means. */
case 7 : c = 'a'; goto store_escape;
case '\b': c = 'b'; goto store_escape;
case '\f': c = 'f'; goto store_escape;
case '\n': c = 'n'; goto store_escape;
case '\r': c = 'r'; goto store_escape;
case '\t': c = 't'; goto store_escape;
case '\v': c = 'v'; goto store_escape;
case ' ':
if (quoting_style == escape_quoting_style)
goto store_escape;
break;
case '"':
if (quoting_style == c_quoting_style)
goto store_escape;
break;
default:
if (!ISGRAPH (c))
{
STORE ('\\');
STORE ('0' + (c >> 6));
STORE ('0' + ((c >> 3) & 3));
c = '0' + (c & 3);
goto store_c;
}
break;
}
if (! (o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
goto store_c;
store_escape:
STORE ('\\');
}
store_c:
STORE (c);
}
if (quote_mark)
STORE (quote_mark);
done:
if (len < bufsize)
buf[len] = '\0';
return len;
}
/* Use storage slot N to return a quoted version of the string ARG.
OPTIONS specifies the quoting options.
The returned value points to static storage that can be
reused by the next call to this function with the same value of N.
N must be nonnegative. */
static char *
quotearg_n_options (int n, char const *arg, struct quoting_options *options)
{
static unsigned nslots;
static struct slotvec
{
size_t size;
char *val;
} *slotvec;
if (nslots <= n)
{
int n1 = n + 1;
size_t s = n1 * sizeof (struct slotvec);
if (! (0 < n1 && n1 == s / sizeof (struct slotvec)))
abort ();
slotvec = (struct slotvec *) xrealloc (slotvec, s);
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec));
nslots = n;
}
{
size_t size = slotvec[n].size;
char *val = slotvec[n].val;
size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options);
if (size <= qsize)
{
slotvec[n].size = size = qsize + 1;
slotvec[n].val = val = xrealloc (val, size);
quotearg_buffer (val, size, arg, (size_t) -1, options);
}
return val;
}
}
struct quoting_options quotearg_quoting_options;
char *
quotearg_n (int n, char const *arg)
{
return quotearg_n_options (n, arg, &quotearg_quoting_options);
}
char *
quotearg (char const *arg)
{
return quotearg_n (0, arg);
}
char *
quotearg_char (char const *arg, char ch)
{
struct quoting_options options;
options = quotearg_quoting_options;
set_char_quoting (&options, ch, 1);
return quotearg_n_options (0, arg, &options);
}
char *
quotearg_colon (char const *arg)
{
return quotearg_char (arg, ':');
}

97
lib/quotearg.h Normal file
View File

@@ -0,0 +1,97 @@
/* quotearg.h - quote arguments for output
Copyright (C) 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert <eggert@twinsun.com> */
/* Basic quoting styles. */
enum quoting_style
{
literal_quoting_style, /* --quoting-style=literal */
shell_quoting_style, /* --quoting-style=shell */
shell_always_quoting_style, /* --quoting-style=shell-always */
c_quoting_style, /* --quoting-style=c */
escape_quoting_style /* --quoting-style=escape */
};
/* For now, --quoting-style=literal is the default, but
this is planned to change to --quoting-style=shell in the future. */
#ifndef DEFAULT_QUOTING_STYLE
# define DEFAULT_QUOTING_STYLE literal_quoting_style
#endif
/* Names of quoting styles. */
extern char const *const quoting_style_args[];
struct quoting_options;
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
/* Allocate a new set of quoting options, with contents initially identical
to O if O is not null, or to a default value if O is null.
It is the caller's responsibility to free the result. */
struct quoting_options *clone_quoting_options
PARAMS ((struct quoting_options *o));
/* Get the value of O's quoting style. */
enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o));
/* In O, set the value of the quoting style to S. */
void set_quoting_style PARAMS ((struct quoting_options *o,
enum quoting_style s));
/* In O, set the value of the quoting options for character C to I.
Return the old value. Currently, the only values defined for I are
0 (the default) and 1 (which means to quote the character even if
it would not otherwise be quoted). */
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
/* Place into buffer BUF (of size BUFSIZE) a quoted version of
argument ARG (of size ARGSIZE), using O to control quoting.
Terminate the output with a null character, and return the written
size of the output, not counting the terminating null.
If BUFSIZE is too small to store the output string, return the
value that would have been returned had BUFSIZE been large enough.
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
size_t quotearg_buffer PARAMS ((char *buf, size_t bufsize,
char const *arg, size_t argsize,
struct quoting_options const *o));
/* The quoting options used by the convenience functions listed below. */
extern struct quoting_options quotearg_quoting_options;
/* Use storage slot N to return a quoted version of the string ARG.
The variable quotearg_quoting_options specifies the quoting options.
The returned value points to static storage that can be
reused by the next call to this function with the same value of N.
N must be nonnegative. */
char *quotearg_n PARAMS ((int n, char const *arg));
/* Equivalent to quotearg_n (ARG, 0). */
char *quotearg PARAMS ((char const *arg));
/* Like quotearg (ARG), except also quote any instances of CH. */
char *quotearg_char PARAMS ((char const *arg, char ch));
/* Equivalent to quotearg_char (ARG, ':'). */
char *quotearg_colon PARAMS ((char const *arg));

View File

@@ -1,5 +1,5 @@
/* save-cwd.c -- Save and restore current working directory.
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
/* Written by Jim Meyering <meyering@na-net.ornl.gov>. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include "config.h"
#endif
@@ -27,11 +27,11 @@
# include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_FCNTL_H
#if HAVE_FCNTL_H
# include <fcntl.h>
#else
# include <sys/file.h>
@@ -67,7 +67,7 @@ save_cwd (cwd)
if (have_working_fchdir)
{
#ifdef HAVE_FCHDIR
#if HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY);
if (cwd->desc < 0)
{

View File

@@ -1,5 +1,5 @@
/* savedir.c -- save the list of files in a directory in a string
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
Copyright (C) 1990, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,13 +17,13 @@
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#if HAVE_UNISTD_H
# include <unistd.h>
#endif

View File

@@ -1,5 +1,5 @@
/* strdup.c -- return a newly allocated copy of a string
Copyright (C) 1990 Free Software Foundation, Inc.
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,13 +15,13 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef STDC_HEADERS
#include <string.h>
#include <stdlib.h>
# include <string.h>
# include <stdlib.h>
#else
char *malloc ();
char *strcpy ();

View File

@@ -1,5 +1,5 @@
/* userspec.c -- Parse a user and group string.
Copyright (C) 1989, 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
Copyright (C) 1989, 1990, 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef HAVE_ALLOCA_H
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
@@ -153,6 +153,15 @@ parse_user_spec (spec_arg, uid, gid, username_arg, groupname_arg)
if (u == NULL && g == NULL)
return "can not omit both user and group";
#ifdef __DJGPP__
/* Pretend that we are the user U whose group is G. This makes
pwd and grp functions ``know'' about the UID and GID of these. */
if (u && !is_number (u))
setenv ("USER", u, 1);
if (g && !is_number (g))
setenv ("GROUP", g, 1);
#endif
if (u != NULL)
{
pwd = getpwnam (u);

View File

@@ -1,5 +1,5 @@
/* xstrdup.c -- copy a string with out of memory checking
Copyright (C) 1990, 1996 Free Software Foundation, Inc.
Copyright (C) 1990, 1996, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,24 +19,28 @@
# include <config.h>
#endif
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
#if STDC_HEADERS || HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#if defined (__STDC__) && __STDC__
char *xmalloc (size_t);
char *xstrdup (char *string);
#else
char *xmalloc ();
#endif
#include <sys/types.h>
char *xmalloc PARAMS ((size_t n));
/* Return a newly allocated copy of STRING. */
char *
xstrdup (string)
char *string;
xstrdup (const char *string)
{
return strcpy (xmalloc (strlen (string) + 1), string);
}

View File

@@ -1,5 +1,5 @@
/* A more useful interface to strtol.
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,12 +46,24 @@ extern int errno;
# include <limits.h>
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t))
#ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
# define ULONG_MAX TYPE_MAXIMUM (unsigned long int)
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
# define LONG_MAX TYPE_MAXIMUM (long int)
#endif
#include "xstrtol.h"

View File

@@ -1,5 +1,5 @@
/* yesno.c -- read a yes/no response from stdin
Copyright (C) 1990 Free Software Foundation, Inc.
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,12 +15,12 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#ifdef HAVE_STDLIB_H
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <stdio.h>

View File

@@ -1,3 +1,9 @@
1998-03-15 Jim Meyering <meyering@eng.ascend.com>
* prereq.m4: New file.
* error.m4: New file.
* Makefile.am (EXTRA_DIST): Add error.m4 and prereq.m4.
1998-02-07 Jim Meyering <meyering@eng.ascend.com>
* getline.m4: Don't set am_cv_func_working_getline before the

View File

@@ -4,8 +4,8 @@
# find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \
# |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
EXTRA_DIST = README \
check-decl.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 getgroups.m4 \
getline.m4 getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 \
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 putenv.m4 \
check-decl.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 \
getgroups.m4 getline.m4 getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 \
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 putenv.m4 \
readdir.m4 realloc.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 \
mktime.m4

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -92,9 +92,9 @@ YACC = @YACC@
l = @l@
EXTRA_DIST = README \
check-decl.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 getgroups.m4 \
getline.m4 getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 \
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 putenv.m4 \
check-decl.m4 chown.m4 const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 \
getgroups.m4 getline.m4 getloadavg.m4 inttypes_h.m4 jm-mktime.m4 jm-winsz1.m4 \
jm-winsz2.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 perl.m4 prereq.m4 putenv.m4 \
readdir.m4 realloc.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 \
mktime.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs

11
m4/error.m4 Normal file
View File

@@ -0,0 +1,11 @@
#serial 1
dnl FIXME: put these prerequisite-only *.m4 files in a separate
dnl directory -- otherwise, they'll conflict with existing files.
dnl These are the prerequisite macros for GNU's error.c file.
AC_DEFUN(jm_PREREQ_ERROR,
[
AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
AC_HEADER_STDC
])

9
m4/prereq.m4 Normal file
View File

@@ -0,0 +1,9 @@
#serial 1
dnl These are the prerequisite macros for files in the lib/
dnl directories of the fileutils, sh-utils, and textutils packages.
AC_DEFUN(jm_PREREQ,
[
jm_PREREQ_ERROR
])

View File

@@ -1,3 +1,126 @@
1998-03-15 Jim Meyering <meyering@eng.ascend.com>
* Version 3.16n.
* lib/chown.c: Use #if, not #ifdef with HAVE_ macros.
* lib/closeout.c: Likewise.
* lib/dirname.c: Likewise.
* lib/euidaccess.c: Likewise.
* lib/fileblocks.c: Likewise.
* lib/filemode.c: Likewise.
* lib/ftruncate.c: Likewise.
* lib/group-member.c: Likewise.
* lib/isdir.c: Likewise.
* lib/long-options.c: Likewise.
* lib/mountlist.c: Likewise.
* lib/path-concat.c: Likewise.
* lib/save-cwd.c: Likewise.
* lib/savedir.c: Likewise.
* lib/strcasecmp.c: Likewise.
* lib/strdup.c: Likewise.
* lib/userspec.c: Likewise.
* lib/yesno.c:: Likewise.
* src/chgrp.c: Use #if, not #ifdef with HAVE_ macros.
Use #if !, not #ifndef with HAVE_ macros.
* src/chown.c: Likewise.
* src/copy.c: Likewise.
* src/dd.c: Likewise.
* src/dircolors.c: Likewise.
* src/install.c: Likewise.
* src/ls.c: Likewise.
* src/mv.c: Likewise.
* src/touch.c: Likewise.
* configure.in: Use jm_PREREQ.
1998-03-14 Jim Meyering <meyering@eng.ascend.com>
Revert most `getdate.h -> get-date.h' changes of 1998-02-20.
With automake-1.2f, that hack is no longer needed.
* src/remove.c: Use `virtual memory exhausted' message, not
`Memory exhausted' to be consistent with the majority of other
such messages.
Say `removing all...', not `removing any...'.
* src/rmdir.c (remove_parents): Be consistent with documentation of
--verbose option and with remove.c in saying `removing...' before
the operation is attempted.
(main): Likewise.
Suggestions from Santiago Vila.
* src/copy.c (copy_dir): Add new parameter, copy_into_self, and set it.
(copy_internal): Likewise.
(copy): Likewise.
Update all callers.
* src/copy.h (copy): Update prototype.
* src/cp.c (do_copy): Add unused arg in calls to copy.
* src/mv.c (do_move): Add &copy_into_self arg in call to copy.
Don't remove source directory when copy_into_self is nonzero.
Reported by Arne Henrik Juul.
* tests/mv/into-self: Test for the above.
* tests/mv/Makefile.am (TESTS): Add into-self.
1998-02-28 Eli Zaretskii <eliz@is.elta.co.il>
* userspec.c (parse_user_spec) [__DJGPP__]: Make function know
about any arbitrary user and group by pretending to be the user
and to belong to the group specified in `spec_arg' argument.
* idcache.c (getuidbyname) [__DJGPP__]: Make function know about
any arbitrary user name.
(getgidbyname) [__DJGPP__]: Make function know about any arbitrary
group name.
1998-02-24 Jim Meyering <meyering@eng.ascend.com>
* lib/xstrtol.c (TYPE_SIGNED): Define.
(TYPE_MAXIMUM): Define.
(ULONG_MAX): Use TYPE_MAXIMUM.
(LONG_MAX): Use TYPE_MAXIMUM.
* lib/fnmatch.c: Update from libit.
* lib/idcache.c: Update from libit.
1998-02-23 Paul Eggert <eggert@twinsun.com>
* lib/quotearg.h, lib/quotearg.c: New files.
* lib/Makefile.am (libfu_a_SOURCES): Add quotearg.c.
(noinst_HEADERS): Add quotearg.h.
* src/ls.c: Include new file quotearg.h.
(enum indicator_style): Rename all to classify, and not_programs
to file_type, to match option spellings. All users changed.
(indicator_style_args): New constant.
(quote_funny_chars, quote_as_string, quote_shell): Remove;
(filename_quoting_options, dirname_quoting_options): Use these
variables instead.
(long_options): Add --indicator-style, --quoting-style,
--show-control-chars. Remove --quote-shell.
(dired_dump_obstack): Remove style parameter and don't output style.
(main): Go back to previous method of outputting //DIRED//
and //SUBDIRED// lines, without style. But add a new
//DIRED-OPTIONS// line that does output style.
(decode_switches, usage): Add --indicator-style, --quoting-style,
--show-control-chars. Remove --quote-shell.
(decode_switches): Default from QUOTING_STYLE environment variable.
Set new quoting vars.
(quote_name): Renamed from quote_filename.
Take new arg specifying quoting options.
Always print; do not have a special case for null FILE * argument.
All callers changed.
Move the guts of this function to new file quotearg.c.
(length_of_file_name_and_frills): Use quotearg_buffer instead
of (old) quote_filename to find length of file name.
(decode_switches, parse_ls_color, print_dir, gobble_file,
get_link_name): Quote output in diagnostics.
* NEWS, doc/fileutils.texi: Describe above changes.
* doc/fileutils.texi: Mention that control characters are output
as question marks if output is a terminal.
1998-02-22 Jim Meyering <meyering@eng.ascend.com>
* Version 3.16m.

View File

@@ -1,4 +1,34 @@
Changes in release 3.17:
[3.16n]
* `mv dir dir' once again does *not* remove dir/
* ls accepts new options:
--indicator-style=none (no indicators, the default)
--indicator-style=classify (all indicators)
(equivalent to -F or --classify)
--indicator-style=file-type (file type indicators)
(equivalent to -p or --file-type)
--quoting-style=literal (do not quote output)
--quoting-style=shell (minimally quote output for the shell)
--quoting-style=shell-always (always quote output with '' for the shell)
--quoting-style=c (quote output as for a C-language string)
(equivalent to -Q or --quote-name)
--quoting-style=escape (like c but omit enclosing "")
(equivalent to -b or --escape)
--show-control-chars is the opposite of --hide-control-chars
This option can be useful if output is to a terminal,
to override the default beahvior of hiding control characters.
* The QUOTING_STYLE environment variable can now be used to specify the
default value for ls's --quoting-style option. If not specified,
the default quoting style is 'literal', but this default may change to
'shell' in a future version of this package.
* ls's quoting style now affects operands in diagnostics, too.
* ls's --dired option now outputs the quoting style
using the format of the new --quoting-style option.
* ls's -e or --quote-shell option (introduced in 3.16j) has been removed;
use --quoting-style=shell to get its functionality.
[3.16m]
* mv can move (and doesn't read) special files
* remove maintainer mode

View File

@@ -1,3 +1,41 @@
1998-03-13 Jim Meyering <meyering@eng.ascend.com>
* lib/getugroups.c (getugroups): Don't add a group number if it
would be a duplicate. From Ulrich Drepper.
1998-02-22 Jim Meyering <meyering@eng.ascend.com>
* tests/Makefile.am (EXTRA_DIST): Add mk-script.
* tests/Makefile.am.in (EXTRA_DIST): Remove mk-script.pl.
(mk_script): Set to ../mk-script.
(x-tests): Use `$(PERL) -w -- $(mk_script)', not ./mk-script.
Remove @MAINT@ cruft.
(Makefile.am): Likewise.
Remove @MAINT@ cruft. Now `missing' will explain the failure
when people don't have Perl yet modify a file whose rebuilding
would lead to the use of Perl.
* src/Makefile.am (pinky_LDADD): Explicitly add @GETHOSTBYNAME_LIB@.
(who_LDADD): Likewise.
(pinky_DEPENDENCIES): Set to $(LDADD)
(who_DEPENDENCIES): Likewise.
1998-02-20 Jim Meyering <meyering@eng.ascend.com>
* lib/getdate.h: Removed. Could cause confusion with an
automake-generated `.y.h' rule.
* lib/get-date.h: Renamed from getdate.h.
* lib/getdate.y: s/getdate.h/get-date.h/
* lib/Makefile.am (noinst_HEADERS): s/getdate.h/get-date.h/
* src/date.c: s/getdate.h/get-date.h/
1998-02-16 Jim Meyering <meyering@eng.ascend.com>
* configure.in (jm_FUNC_LSTAT): Use it.
(jm_FUNC_STAT): Use it.
* acconfig.h: Add lstat.
* lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c.
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
* tests/nice: Fail immediately if this test is run with `nice'

View File

@@ -1,3 +1,15 @@
1998-03-03 Paul Eggert <eggert@twinsun.com>
* src/sort.c (xtmpfopen): Open temporary file exclusively, to
foil a common denial-of-service attack.
* src/tac.c (save_stdin): Likewise.
1998-02-16 Jim Meyering <meyering@eng.ascend.com>
* configure.in (jm_FUNC_LSTAT): Use it.
(jm_FUNC_STAT): Use it.
* lib/Makefile.am (EXTRA_DIST): Add lstat.c and stat.c.
1998-02-06 Jim Meyering <meyering@eng.ascend.com>
* Version 1.22e.

View File

@@ -39,11 +39,11 @@
struct group *getgrnam ();
#endif
#ifndef HAVE_ENDGRENT
#if ! HAVE_ENDGRENT
# define endgrent() ((void) 0)
#endif
#ifdef HAVE_LCHOWN
#if HAVE_LCHOWN
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
#else
# define LCHOWN(FILE, OWNER, GROUP) 1
@@ -379,7 +379,7 @@ main (int argc, char **argv)
usage (1);
}
#ifndef HAVE_LCHOWN
#if ! HAVE_LCHOWN
if (change_symlinks)
{
error (1, 0, _("--no-dereference (-h) is not supported on this system"));

View File

@@ -46,11 +46,11 @@ struct group *getgrnam ();
struct group *getgrgid ();
#endif
#ifndef HAVE_ENDPWENT
#if ! HAVE_ENDPWENT
# define endpwent() ((void) 0)
#endif
#ifdef HAVE_LCHOWN
#if HAVE_LCHOWN
# define LCHOWN(FILE, OWNER, GROUP) lchown (FILE, OWNER, GROUP)
#else
# define LCHOWN(FILE, OWNER, GROUP) 1
@@ -356,7 +356,7 @@ main (int argc, char **argv)
usage (1);
}
#ifndef HAVE_LCHOWN
#if ! HAVE_LCHOWN
if (change_symlinks)
{
error (1, 0, _("--no-dereference (-h) is not supported on this system"));

View File

@@ -43,7 +43,8 @@ int yesno ();
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
int new_dst, dev_t device,
struct dir_list *ancestors,
const struct cp_options *x));
const struct cp_options *x,
int *copy_into_self));
/* The invocation name of this program. */
extern char *program_name;
@@ -64,17 +65,17 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
copy the contents to DST_PATH_IN. NEW_DST is nonzero if
DST_PATH_IN is a directory that was created previously in the
recursion. SRC_SB and ANCESTORS describe SRC_PATH_IN.
Set *COPY_INTO_SELF to nonzero if SRC_PATH_IN is a parent of
(or the same as) DST_PATH_IN; otherwise, set it to zero.
Return 0 if successful, -1 if an error occurs. */
static int
copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
const struct stat *src_sb, struct dir_list *ancestors,
const struct cp_options *x)
const struct cp_options *x, int *copy_into_self)
{
char *name_space;
char *namep;
char *src_path;
char *dst_path;
int ret = 0;
errno = 0;
@@ -93,13 +94,16 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
namep = name_space;
while (*namep != '\0')
{
src_path = path_concat (src_path_in, namep, NULL);
dst_path = path_concat (dst_path_in, namep, NULL);
int local_copy_into_self;
char *src_path = path_concat (src_path_in, namep, NULL);
char *dst_path = path_concat (dst_path_in, namep, NULL);
if (dst_path == NULL || src_path == NULL)
error (1, 0, _("virtual memory exhausted"));
ret |= copy_internal (src_path, dst_path, new_dst, src_sb->st_dev,
ancestors, x);
ancestors, x, &local_copy_into_self);
*copy_into_self |= local_copy_into_self;
/* Free the memory for `src_path'. The memory for `dst_path'
cannot be deallocated, since it is used to create multiple
@@ -166,7 +170,7 @@ copy_reg (const char *src_path, const char *dst_path,
buf_size = ST_BLKSIZE (sb);
#ifdef HAVE_ST_BLOCKS
#if HAVE_ST_BLOCKS
if (sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
{
/* Use a heuristic to determine whether SRC_PATH contains any
@@ -263,7 +267,7 @@ copy_reg (const char *src_path, const char *dst_path,
if (last_write_made_hole)
{
#ifdef HAVE_FTRUNCATE
#if HAVE_FTRUNCATE
/* Write a null character and truncate it again. */
if (full_write (dest_desc, "", 1) < 0
|| ftruncate (dest_desc, n_read_total) < 0)
@@ -301,12 +305,14 @@ ret2:
number of the parent directory, or 0 if the parent of this file is
not known. ANCESTORS points to a linked, null terminated list of
devices and inodes of parent directories of SRC_PATH.
Set *COPY_INTO_SELF to nonzero if SRC_PATH is a parent of (or the
same as) DST_PATH; otherwise, set it to zero.
Return 0 if successful, 1 if an error occurs. */
static int
copy_internal (const char *src_path, const char *dst_path,
int new_dst, dev_t device, struct dir_list *ancestors,
const struct cp_options *x)
const struct cp_options *x, int *copy_into_self)
{
struct stat src_sb;
struct stat dst_sb;
@@ -316,6 +322,7 @@ copy_internal (const char *src_path, const char *dst_path,
char *dst_backup = NULL;
int fix_mode = 0;
*copy_into_self = 0;
if ((*(x->xstat)) (src_path, &src_sb))
{
error (0, errno, "%s", src_path);
@@ -335,7 +342,10 @@ copy_internal (const char *src_path, const char *dst_path,
/* Did we just create this file? */
if (earlier_file == &new_file)
return 0;
{
*copy_into_self = 1;
return 0;
}
src_mode = src_sb.st_mode;
src_type = src_sb.st_mode;
@@ -552,7 +562,8 @@ copy_internal (const char *src_path, const char *dst_path,
/* Copy the contents of the directory. */
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x))
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x,
copy_into_self))
return 1;
}
#ifdef S_ISLNK
@@ -648,7 +659,7 @@ copy_internal (const char *src_path, const char *dst_path,
{
/* Preserve the owner and group of the just-`copied'
symbolic link, if possible. */
# ifdef HAVE_LCHOWN
# if HAVE_LCHOWN
if (DO_CHOWN (lchown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), dst_path);
@@ -771,12 +782,16 @@ valid_options (const struct cp_options *co)
is known not to exist (e.g., because its parent directory was just
created); NONEXISTENT_DST should be zero if DST_PATH might already
exist. OPTIONS is ... FIXME-describe
Set *COPY_INTO_SELF to nonzero if SRC_PATH is a parent of (or the
same as) DST_PATH; otherwise, set it to zero.
Return 0 if successful, 1 if an error occurs. */
int
copy (const char *src_path, const char *dst_path,
int nonexistent_dst, const struct cp_options *options)
int nonexistent_dst, const struct cp_options *options,
int *copy_into_self)
{
assert (valid_options (options));
return copy_internal (src_path, dst_path, nonexistent_dst, 0, NULL, options);
return copy_internal (src_path, dst_path, nonexistent_dst, 0, NULL,
options, copy_into_self);
}

View File

@@ -94,6 +94,7 @@ struct cp_options
int
copy PARAMS ((const char *src_path, const char *dst_path,
int nonexistent_dst, const struct cp_options *options));
int nonexistent_dst, const struct cp_options *options,
int *copy_into_self));
#endif

View File

@@ -485,7 +485,8 @@ do_copy (int argc, char **argv, const struct cp_options *x)
}
else
{
ret |= copy (arg, dst_path, new_dst, x);
int unused;
ret |= copy (arg, dst_path, new_dst, x, &unused);
forget_all ();
if (flag_path)
@@ -506,6 +507,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
{
char *new_dest;
char *source;
int unused;
struct stat source_stats;
if (flag_path)
@@ -572,7 +574,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
new_dest = dest;
}
return copy (source, new_dest, new_dst, x);
return copy (source, new_dest, new_dst, x, &unused);
}
else
{

View File

@@ -26,7 +26,7 @@
#include "system.h"
#include "getline.h"
#include "error.h"
#include "get-date.h"
#include "getdate.h"
#ifndef STDC_HEADERS
size_t strftime ();

View File

@@ -1106,7 +1106,7 @@ main (int argc, char **argv)
output_fd = open (output_file, omode, 0666);
if (output_fd < 0)
error (1, errno, "%s", output_file);
#ifdef HAVE_FTRUNCATE
#if HAVE_FTRUNCATE
if (seek_record != 0 && !(conversions_mask & C_NOTRUNC))
{
off_t o = seek_record * output_blocksize;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif

View File

@@ -95,11 +95,11 @@ uid_t getuid ();
gid_t getgid ();
#endif
#ifndef HAVE_ENDGRENT
#if ! HAVE_ENDGRENT
# define endgrent() ((void) 0)
#endif
#ifndef HAVE_ENDPWENT
#if ! HAVE_ENDPWENT
# define endpwent() ((void) 0)
#endif
@@ -705,8 +705,8 @@ In the third format, create all components of the given DIRECTORY(ies).\n\
-c (ignored)\n\
-d, --directory treat all arguments as directory names; create all\n\
components of the specified directories\n\
-D create all leading components of DEST except the last,\n\
then copy SOURCE to DEST; useful in the 1st format\n\
-D create all leading components of DEST except the last,\n\
then copy SOURCE to DEST; useful in the 1st format\n\
-g, --group=GROUP set group ownership, instead of process' current group\n\
-m, --mode=MODE set permission mode (as in chmod), instead of rwxr-xr-x\n\
-o, --owner=OWNER set ownership (super-user only)\n\

317
src/ls.c
View File

@@ -47,7 +47,7 @@
# include <inttypes.h>
#endif
#ifdef HAVE_TERMIOS_H
#if HAVE_TERMIOS_H
# include <termios.h>
#endif
@@ -71,6 +71,7 @@
#include "argmatch.h"
#include "xstrtol.h"
#include "strverscmp.h"
#include "quotearg.h"
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
@@ -139,7 +140,8 @@ void strip_trailing_slashes ();
char *xstrdup ();
void invalid_arg ();
static size_t quote_filename PARAMS ((FILE *out, const char *filename));
static size_t quote_name PARAMS ((FILE *out, const char *name,
struct quoting_options const *options));
static char *make_link_path PARAMS ((const char *path, const char *linkname));
static int compare_atime PARAMS ((const struct fileinfo *file1,
const struct fileinfo *file2));
@@ -331,20 +333,26 @@ static int output_units;
static int dired;
/* `none' means don't mention the type of files.
`all' means mention the types of all files.
`not_programs' means do so except for executables.
`classify' means mention file types and mark executables.
`file_type' means mention only file types.
Controlled by -F and -p. */
Controlled by -F, -p, and --indicator-style. */
enum indicator_style
{
none, /* default */
all, /* -F */
not_programs /* -p */
none, /* --indicator-style=none */
classify, /* -F, --indicator-style=classify */
file_type /* -p, --indicator-style=file-type */
};
static enum indicator_style indicator_style;
/* Names of indicator styles. */
static char const *const indicator_style_args[] =
{
"none", "classify", "file-type", 0
};
/* Nonzero means use colors to mark types. Also define the different
colors as well as the stuff for the LS_COLORS environment variable.
The LS_COLORS variable is now in a termcap-like format. */
@@ -446,26 +454,14 @@ struct ignore_pattern
static struct ignore_pattern *ignore_patterns;
/* Nonzero means quote nongraphic chars in file names. -b */
static int quote_funny_chars;
/* Nonzero means output nongraphic chars in file names as `?'. -q */
static int qmark_funny_chars;
/* Nonzero means output each file name using C syntax for a string.
Always accompanied by `quote_funny_chars'.
This mode, together with -x or -C or -m,
and without such frills as -F or -s,
is guaranteed to make it possible for a program receiving
the output to tell exactly what file names are present. -Q */
/* Quoting options for file and dir name output. */
static int quote_as_string;
/* Nonzero means use shell style quoting; it is also unambiguous. -e */
static int quote_shell;
static struct quoting_options *filename_quoting_options;
static struct quoting_options *dirname_quoting_options;
/* The number of chars per hardware tab stop. Setting this to zero
inhibits the use of TAB characters for separating columns. -T */
@@ -522,12 +518,14 @@ static struct option const long_options[] =
{"file-type", no_argument, 0, 'F'},
{"si", no_argument, 0, 'H'},
{"ignore", required_argument, 0, 'I'},
{"indicator-style", required_argument, 0, 14},
{"dereference", no_argument, 0, 'L'},
{"literal", no_argument, 0, 'N'},
{"quote-name", no_argument, 0, 'Q'},
{"quote-shell", no_argument, 0, 'e'},
{"quoting-style", required_argument, 0, 15},
{"recursive", no_argument, 0, 'R'},
{"format", required_argument, 0, 12},
{"show-control-chars", no_argument, 0, 16},
{"sort", required_argument, 0, 10},
{"tabsize", required_argument, 0, 'T'},
{"time", required_argument, 0, 11},
@@ -651,11 +649,11 @@ static int max_idx;
#define MIN_COLUMN_WIDTH 3
/* Write to standard output the strings PREFIX and STYLE, followed by
/* Write to standard output PREFIX, followed by the quoting style and
a space-separated list of the integers stored in OS all on one line. */
static void
dired_dump_obstack (const char *prefix, const char *style, struct obstack *os)
dired_dump_obstack (const char *prefix, struct obstack *os)
{
int n_pos;
@@ -667,7 +665,6 @@ dired_dump_obstack (const char *prefix, const char *style, struct obstack *os)
pos = (size_t *) obstack_finish (os);
fputs (prefix, stdout);
fputs (style, stdout);
for (i = 0; i < n_pos; i++)
printf (" %d", (int) pos[i]);
fputs ("\n", stdout);
@@ -775,13 +772,11 @@ main (int argc, char **argv)
if (dired && format == long_format)
{
const char *quoting_style = (quote_shell ? " -e"
: quote_as_string ? " -Q"
: quote_funny_chars ? " -b"
: " -N");
/* No need to free these since we're about to exit. */
dired_dump_obstack ("//DIRED//", quoting_style, &dired_obstack);
dired_dump_obstack ("//SUBDIRED//", quoting_style, &subdired_obstack);
dired_dump_obstack ("//DIRED//", &dired_obstack);
dired_dump_obstack ("//SUBDIRED//", &subdired_obstack);
printf ("//DIRED-OPTIONS// --quoting-style=%s\n",
quoting_style_args[get_quoting_style (filename_quoting_options)]);
}
/* Restore default color before exiting */
@@ -801,13 +796,12 @@ main (int argc, char **argv)
static int
decode_switches (int argc, char **argv)
{
register char *p;
register char const *p;
int c;
int i;
long int tmp_long;
qmark_funny_chars = 0;
quote_funny_chars = 0;
/* initialize all switches to default settings */
@@ -816,13 +810,13 @@ decode_switches (int argc, char **argv)
case LS_MULTI_COL:
/* This is for the `dir' program. */
format = many_per_line;
quote_funny_chars = 1;
set_quoting_style (&quotearg_quoting_options, escape_quoting_style);
break;
case LS_LONG_FORMAT:
/* This is for the `vdir' program. */
format = long_format;
quote_funny_chars = 1;
set_quoting_style (&quotearg_quoting_options, escape_quoting_style);
break;
case LS_LS:
@@ -858,8 +852,10 @@ decode_switches (int argc, char **argv)
all_files = 0;
really_all_files = 0;
ignore_patterns = 0;
quote_as_string = 0;
quote_shell = 1;
if ((p = getenv ("QUOTING_STYLE"))
&& 0 <= (i = argmatch (p, quoting_style_args)))
set_quoting_style (&quotearg_quoting_options, (enum quoting_style) i);
if ((p = getenv ("BLOCKSIZE"))
&& strncmp (p, "HUMAN", sizeof ("HUMAN") - 1) == 0)
@@ -879,7 +875,7 @@ decode_switches (int argc, char **argv)
{
error (0, 0,
_("ignoring invalid width in environment variable COLUMNS: %s"),
p);
quotearg (p));
}
}
@@ -906,7 +902,7 @@ decode_switches (int argc, char **argv)
{
error (0, 0,
_("ignoring invalid tab size in environment variable TABSIZE: %s"),
p);
quotearg (p));
}
}
@@ -925,10 +921,7 @@ decode_switches (int argc, char **argv)
break;
case 'b':
quote_funny_chars = 1;
quote_as_string = 0;
quote_shell = 0;
qmark_funny_chars = 0;
set_quoting_style (&quotearg_quoting_options, escape_quoting_style);
break;
case 'c':
@@ -940,13 +933,6 @@ decode_switches (int argc, char **argv)
immediate_dirs = 1;
break;
case 'e':
quote_shell = 1;
quote_as_string = 0;
quote_funny_chars = 0;
qmark_funny_chars = 0;
break;
case 'f':
/* Same as enabling -a -U and disabling -l -s. */
all_files = 1;
@@ -997,14 +983,11 @@ decode_switches (int argc, char **argv)
break;
case 'p':
indicator_style = not_programs;
indicator_style = file_type;
break;
case 'q':
qmark_funny_chars = 1;
quote_as_string = 0;
quote_funny_chars = 0;
quote_shell = 0;
break;
case 'r':
@@ -1031,7 +1014,8 @@ decode_switches (int argc, char **argv)
case 'w':
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid line width: %s"), optarg);
error (EXIT_FAILURE, 0, _("invalid line width: %s"),
quotearg (optarg));
line_length = (int) tmp_long;
break;
@@ -1058,7 +1042,7 @@ decode_switches (int argc, char **argv)
break;
case 'F':
indicator_style = all;
indicator_style = classify;
break;
case 'G': /* inhibit display of group info */
@@ -1074,17 +1058,11 @@ decode_switches (int argc, char **argv)
break;
case 'N':
quote_as_string = 0;
quote_funny_chars = 0;
quote_shell = 0;
qmark_funny_chars = 0;
set_quoting_style (&quotearg_quoting_options, literal_quoting_style);
break;
case 'Q':
quote_as_string = 1;
quote_funny_chars = 1;
quote_shell = 0;
qmark_funny_chars = 0;
set_quoting_style (&quotearg_quoting_options, c_quoting_style);
break;
case 'R':
@@ -1098,7 +1076,8 @@ decode_switches (int argc, char **argv)
case 'T':
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long < 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid tab size: %s"), optarg);
error (EXIT_FAILURE, 0, _("invalid tab size: %s"),
quotearg (optarg));
tabsize = (int) tmp_long;
break;
@@ -1175,6 +1154,31 @@ decode_switches (int argc, char **argv)
}
break;
case 14: /* --indicator-style */
i = argmatch (optarg, indicator_style_args);
if (i < 0)
{
invalid_arg (_("indicator style"), optarg, i);
usage (EXIT_FAILURE);
}
indicator_style = (enum indicator_style) i;
break;
case 15: /* --quoting-style */
i = argmatch (optarg, quoting_style_args);
if (i < 0)
{
invalid_arg (_("quoting style"), optarg, i);
usage (EXIT_FAILURE);
}
set_quoting_style (&quotearg_quoting_options,
(enum quoting_style) i);
break;
case 16:
qmark_funny_chars = 0;
break;
default:
usage (EXIT_FAILURE);
}
@@ -1183,6 +1187,14 @@ decode_switches (int argc, char **argv)
if (human_readable_base)
output_units = 1;
filename_quoting_options = clone_quoting_options (&quotearg_quoting_options);
if (indicator_style != none)
for (p = "*=@|" + (int) indicator_style - 1; *p; p++)
set_char_quoting (filename_quoting_options, *p, 1);
dirname_quoting_options = clone_quoting_options (&quotearg_quoting_options);
set_char_quoting (dirname_quoting_options, ':', 1);
return optind;
}
@@ -1480,7 +1492,7 @@ parse_ls_color (void)
}
}
if (state == -1)
error (0, 0, _("unrecognized prefix: %s"), label);
error (0, 0, _("unrecognized prefix: %s"), quotearg (label));
}
break;
@@ -1550,7 +1562,7 @@ print_dir (const char *name, const char *realname)
reading = opendir (name);
if (!reading)
{
error (0, errno, "%s", name);
error (0, errno, "%s", quotearg_colon (name));
exit_status = 1;
return;
}
@@ -1566,7 +1578,7 @@ print_dir (const char *name, const char *realname)
if (CLOSEDIR (reading))
{
error (0, errno, "%s", name);
error (0, errno, "%s", quotearg_colon (name));
exit_status = 1;
/* Don't return; print whatever we got. */
}
@@ -1584,7 +1596,8 @@ print_dir (const char *name, const char *realname)
{
DIRED_INDENT ();
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
dired_pos += quote_filename (stdout, realname ? realname : name);
dired_pos += quote_name (stdout, realname ? realname : name,
dirname_quoting_options);
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
FPUTS_LITERAL (":\n", stdout);
}
@@ -1716,7 +1729,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
if (val < 0)
{
error (0, errno, "%s", path);
error (0, errno, "%s", quotearg_colon (path));
exit_status = 1;
return 0;
}
@@ -1821,7 +1834,7 @@ get_link_name (const char *filename, struct fileinfo *f)
linksize = readlink (filename, linkbuf, PATH_MAX + 1);
if (linksize < 0)
{
error (0, errno, "%s", filename);
error (0, errno, "%s", quotearg_colon (filename));
exit_status = 1;
}
else
@@ -2154,7 +2167,7 @@ print_long_format (const struct fileinfo *f)
const char *fmt;
char *user_name;
#ifdef HAVE_ST_DM_MODE
#if HAVE_ST_DM_MODE
mode_string (f->stat.st_dm_mode, modebuf);
#else
mode_string (f->stat.st_mode, modebuf);
@@ -2312,134 +2325,34 @@ print_long_format (const struct fileinfo *f)
print_type_indicator (f->stat.st_mode);
}
/* If OUT is not null, output a quoted representation of the file name P.
/* Output to OUT a quoted representation of the file name P,
using OPTIONS to control quoting.
Return the number of characters in P's quoted representation. */
static size_t
quote_filename (register FILE *out, register const char *p)
quote_name (FILE *out, const char *p, struct quoting_options const *options)
{
register unsigned char c;
register size_t len;
#define OUTCHAR(c) do { len++; if (out) putc (c, out); } while (0)
char smallbuf[BUFSIZ];
size_t len = quotearg_buffer (smallbuf, sizeof smallbuf, p, -1, options);
char *buf;
if (quote_shell)
{
const char *p0 = p;
switch (*p)
{
case '\0': case '#': case '~':
break;
default:
for (;; p++)
{
switch (*p)
{
default:
continue;
case '\t': case '\n': case ' ':
case '!': /* special in csh */
case '"': case '$': case '&': case '\'':
case '(': case ')': case '*': case ';':
case '<': case '>': case '?': case '[': case '\\':
case '^': /* synonym for | in old /bin/sh, e.g. SunOS 4.1.4 */
case '`': case '|':
break;
case '\0':
switch (p[-1])
{
case '=': case '@':
/* These require quoting if at the end of the file name,
to avoid ambiguity with the output of -F or -p. */
break;
default:
len = p - p0;
if (out)
fwrite (p0, 1, len, out);
return len;
}
break;
}
break;
}
}
/* Shell quoting is needed. */
p = p0;
len = 0;
OUTCHAR ('\'');
while ((c = *p++))
{
OUTCHAR (c);
if (c == '\'')
{
OUTCHAR ('\\');
OUTCHAR ('\'');
OUTCHAR ('\'');
}
}
OUTCHAR ('\'');
}
if (len < sizeof smallbuf)
buf = smallbuf;
else
{
len = 0;
if (quote_as_string)
OUTCHAR ('"');
while ((c = *p++))
{
if (quote_funny_chars)
{
switch (c)
{
case '\\': OUTCHAR ('\\'); break;
case '\n': OUTCHAR ('\\'); c = 'n'; break;
case '\b': OUTCHAR ('\\'); c = 'b'; break;
case '\r': OUTCHAR ('\\'); c = 'r'; break;
case '\t': OUTCHAR ('\\'); c = 't'; break;
case '\f': OUTCHAR ('\\'); c = 'f'; break;
case ' ':
if (!quote_as_string)
OUTCHAR ('\\');
break;
case '"':
if (quote_as_string)
OUTCHAR ('\\');
break;
default:
if (!ISGRAPH (c))
{
OUTCHAR ('\\');
OUTCHAR ('0' + (c >> 6));
OUTCHAR ('0' + ((c >> 3) & 3));
c = '0' + (c & 3);
}
}
}
else if (qmark_funny_chars && !ISPRINT (c))
c = '?';
OUTCHAR (c);
}
if (quote_as_string)
OUTCHAR ('"');
buf = (char *) alloca (len + 1);
quotearg_buffer (buf, len + 1, p, -1, options);
}
if (qmark_funny_chars)
{
size_t i;
for (i = 0; i < len; i++)
if (! ISPRINT ((unsigned char) buf[i]))
buf[i] = '?';
}
fwrite (buf, 1, len, out);
return len;
}
@@ -2453,7 +2366,7 @@ print_name_with_quoting (const char *p, unsigned int mode, int linkok,
if (stack)
PUSH_CURRENT_DIRED_POS (stack);
dired_pos += quote_filename (stdout, p);
dired_pos += quote_name (stdout, p, filename_quoting_options);
if (stack)
PUSH_CURRENT_DIRED_POS (stack);
@@ -2520,7 +2433,7 @@ print_type_indicator (unsigned int mode)
PUTCHAR ('=');
#endif
if (S_ISREG (mode) && indicator_style == all
if (S_ISREG (mode) && indicator_style == classify
&& (mode & S_IXUGO))
PUTCHAR ('*');
}
@@ -2620,7 +2533,7 @@ length_of_file_name_and_frills (const struct fileinfo *f)
if (print_block_size)
len += 1 + block_size_size;
len += quote_filename (0, f->name);
len += quotearg_buffer (0, 0, f->name, -1, filename_quoting_options);
if (indicator_style != none)
{
@@ -2628,7 +2541,7 @@ length_of_file_name_and_frills (const struct fileinfo *f)
if (S_ISREG (filetype))
{
if (indicator_style == all
if (indicator_style == classify
&& (f->stat.st_mode & S_IXUGO))
len += 1;
}
@@ -2939,9 +2852,8 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
types. WHEN may be `never', `always', or `auto'\n\
-d, --directory list directory entries instead of contents\n\
-D, --dired generate output designed for Emacs' dired mode\n\
-e, --quote-shell quote entry names for shell (default)\n\
-f do not sort, enable -aU, disable -lst\n\
-F, --classify append a character for typing each entry\n\
-F, --classify append indicator (one of */=@|) to entries\n\
--format=WORD across -x, commas -m, horizontal -x, long -l,\n\
single-column -1, verbose -l, vertical -C\n\
--full-time list both full date and full time\n"));
@@ -2951,6 +2863,8 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
-G, --no-group inhibit display of group information\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
--indicator-style=WORD append indicator with style WORD to entry names:\n\
none (default), classify (-F), file-type (-p)\n\
-i, --inode print index number of each file\n\
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN\n\
-k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
@@ -2961,9 +2875,12 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
-N, --literal print raw entry names (don't treat e.g. control\n\
characters specially)\n\
-o use long listing format without group info\n\
-p append a character for typing each entry\n\
-p, --file-type append indicator (one of /=@|) to entries\n\
-q, --hide-control-chars print ? instead of non graphic characters\n\
--show-control-chars show non graphic characters as-is (default)\n\
-Q, --quote-name enclose entry names in double quotes\n\
--quoting-style=WORD use quoting style WORD for entry names:\n\
literal, shell, shell-always, c, escape\n\
-r, --reverse reverse order while sorting\n\
-R, --recursive list subdirectories recursively\n\
-s, --size print size of each file, in blocks\n"));

View File

@@ -60,7 +60,7 @@
#include "remove.h"
#include "error.h"
#ifdef HAVE_LCHOWN
#if HAVE_LCHOWN
# define chown(PATH, OWNER, GROUP) lchown(PATH, OWNER, GROUP)
#endif
@@ -272,6 +272,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
and set errno to EXDEV. */
static int first = 1;
int copy_into_self;
if (first)
{
@@ -281,13 +282,18 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
}
fail = copy (source, dest, nonexistent_dst, x);
fail = copy (source, dest, nonexistent_dst, x, &copy_into_self);
if (fail)
{
/* Restore original destination file DEST if made a backup. */
if (dest_backup && rename (dest_backup, dest))
error (0, errno, _("cannot un-backup `%s'"), dest);
}
else if (copy_into_self)
{
/* Do *not* remove SOURCE if it is the same as or a parent of DEST.
Otherwise, mv would be removing the original *and* the copy. */
}
else
{
struct rm_options rm_options;

View File

@@ -518,11 +518,11 @@ remove_cwd_entries (const struct rm_options *x)
ht = hash_initialize (HT_INITIAL_CAPACITY, NULL,
hash_pjw, hash_compare_strings);
if (ht == NULL)
error (1, 0, _("Memory exhausted"));
error (1, 0, _("virtual memory exhausted"));
}
HASH_INSERT_NEW_ITEM (ht, entry_name, &fail);
if (fail)
error (1, 0, _("Memory exhausted"));
error (1, 0, _("virtual memory exhausted"));
}
else
{
@@ -644,7 +644,7 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
}
if (x->verbose)
printf (_("removing any entries of directory %s\n"),
printf (_("removing all entries of directory %s\n"),
full_filename (dir_name));
/* Save cwd if needed. */
@@ -762,7 +762,7 @@ rm (struct File_spec *fs, int user_specified_name, const struct rm_options *x)
current_depth ()),
&fail);
if (fail)
error (1, 0, _("Memory exhausted"));
error (1, 0, _("virtual memory exhausted"));
if (old_ent)
{

View File

@@ -86,11 +86,12 @@ remove_parents (char *path)
while (slash > path && *slash == '/')
--slash;
slash[1] = 0;
fail = rmdir (path);
/* Give a diagnostic for each successful removal if --verbose. */
if (verbose && !fail)
error (0, errno, _("removed directory, %s"), path);
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
error (0, errno, _("removing directory, %s"), path);
fail = rmdir (path);
if (fail)
{
@@ -189,11 +190,12 @@ main (int argc, char **argv)
/* Stripping slashes is harmless for rmdir;
if the arg is not a directory, it will fail with ENOTDIR. */
strip_trailing_slashes (dir);
fail = rmdir (dir);
/* Give a diagnostic for each successful removal if --verbose. */
if (verbose && !fail)
error (0, errno, _("removed directory, %s"), dir);
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
error (0, errno, _("removing directory, %s"), dir);
fail = rmdir (dir);
if (fail)
{

View File

@@ -346,7 +346,7 @@ xtmpfopen (const char *file)
FILE *fp;
int fd;
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
{
error (0, errno, "%s", file);

View File

@@ -418,7 +418,7 @@ save_stdin (FILE **g_tmp, char **g_tempfile)
sprintf (template, "%s/tacXXXXXX", tempdir);
tempfile = mktemp (template);
fd = creat (tempfile, 0600);
fd = open (tempfile, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (fd == -1 || (tmp = fdopen (fd, "rw")) == NULL)
error (EXIT_FAILURE, errno, "%s", tempfile);
tmp = fdopen (fd, "rw");

View File

@@ -41,7 +41,7 @@
#include "closeout.h"
#include "error.h"
#include "argmatch.h"
#include "get-date.h"
#include "getdate.h"
#ifndef STDC_HEADERS
time_t time ();
@@ -52,7 +52,7 @@ int safe_read ();
int full_write ();
void invalid_arg ();
#ifndef HAVE_UTIME_NULL
#if ! HAVE_UTIME_NULL
static int utime_now ();
#endif
@@ -171,7 +171,7 @@ touch (char *file)
if (amtime_now)
{
#ifndef HAVE_UTIME_NULL
#if ! HAVE_UTIME_NULL
status = utime_now (file, sbuf.st_size);
#else
/* Pass NULL to utime so it will not fail if we just have
@@ -209,7 +209,7 @@ touch (char *file)
return 0;
}
#ifndef HAVE_UTIME_NULL
#if ! HAVE_UTIME_NULL
/* Emulate utime (file, NULL) for systems (like 4.3BSD) that do not
interpret it to set the access and modification times of FILE to
the current time. FILESIZE is the correct size of FILE, used to

View File

@@ -1,3 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = backup-1 no-deref-link1 no-deref-link2 no-deref-link3

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,5 +1,6 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = sf-1
TESTS = sf-1 misc
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = LN=../../src/ln

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -89,7 +89,7 @@ l = @l@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = sf-1
TESTS = sf-1 misc
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = LN=../../src/ln
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs

89
tests/ln/misc Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/sh
PATH=../../../src:$PATH
tmp=t2-ln.$$
test_failure=0
mkdir $tmp || test_failure=1
cd $tmp || test_failure=1
if test $test_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
t=tln-symlink
d=tln-subdir
ld=tln-symlink-to-subdir
f=tln-file
fail=0
# Create a simple symlink with both source and destination files
# in current directory.
touch $f || test_failure=1
rm -f $t || test_failure=1
ln -s $f $t || fail=1
test -f $t || fail=1
rm $t $f
# Create a symlink with source file and explicit destination directory/file.
touch $f || test_failure=1
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
ln -s ../$f $d/$t || fail=1
test -f $d/$t || fail=1
rm -rf $d $f
# Create a symlink with source file and destination directory.
touch $f || test_failure=1
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
ln -s ../$f $d || fail=1
test -f $d/$f || fail=1
rm -rf $d $f
# Make sure we get a failure with existing dest without -f option
touch $t || test_failure=1
# FIXME: don't ignore the error message but rather test
# it to make sure it's the right one.
ln -s $t $t 2> /dev/null && fail=1
rm $t
# Make sure -sf fails when src and dest are the same
touch $t && test_failure=1
ln -sf $t $t 2> /dev/null && fail=1
rm $t
# Create a symlink with source file and no explicit directory
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
touch $d/$f || test_failure=1
ln -s $d/$f || fail=1
test -f $f || fail=1
rm -rf $d $f
# Create a symlink with source file and destination symlink-to-directory.
rm -rf $d $f $ld || test_failure=1
touch $f || test_failure=1
mkdir $d || test_failure=1
ln -s $d $ld
ln -s ../$f $ld || fail=1
test -f $d/$f || fail=1
rm -rf $d $f $ld
# Create a symlink with source file and destination symlink-to-directory.
# BUT use the new --no-dereference option.
rm -rf $d $f $ld || test_failure=1
touch $f || test_failure=1
mkdir $d || test_failure=1
ln -s $d $ld
af=`pwd`/$f
ln --no-dereference -fs $af $ld || fail=1
test -f $ld || fail=1
rm -rf $d $f $ld
cd ..
rm -rf $tmp
exit $fail

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,3 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = p-1 p-2

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,7 @@
AUTOMAKE_OPTIONS = 1.1 gnits
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = mv-special-1
TESTS = mv-special-1 into-self
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \
DF=../../src/df \

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -87,9 +87,9 @@ VERSION = @VERSION@
YACC = @YACC@
l = @l@
AUTOMAKE_OPTIONS = 1.1 gnits
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = mv-special-1
TESTS = mv-special-1 into-self
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \
DF=../../src/df \

31
tests/mv/into-self Executable file
View File

@@ -0,0 +1,31 @@
#! /bin/sh
: ${MV=mv}
: ${MKDIR=mkdir}
: ${RM=rm}
: ${TOUCH=touch}
dir=into-self-dir
file=into-self-file
test_failure=0
$RM -f $dir $file || test_failure=1
$MKDIR -p $dir/a/b || test_failure=1
$TOUCH $file || test_failure=1
if test $test_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
$MV $dir $file $dir || fail=1
# Make sure the file is gone.
test -f $file && fail=1
# Make sure the directory is *not* gone.
test -d $dir/$dir/a/b || fail=1
# Make sure the file has been moved to the right place.
test -f $dir/$file || fail=1
exit $fail

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,3 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = r-1 r-2 r-3 i-1 ir-1 f-1 sunos-1 deep-1

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -21,8 +21,8 @@ mkdir $tmp/a $tmp/a/a || test_failure=1
> $tmp/b || test_failure=1
cat <<EOF > $tmp/$test.E || test_failure=1
removing any entries of directory $tmp/a
removing any entries of directory $tmp/a/a
removing all entries of directory $tmp/a
removing all entries of directory $tmp/a/a
removing the directory itself: $tmp/a/a
removing the directory itself: $tmp/a
removing non-directory $tmp/b

View File

@@ -18,8 +18,8 @@ mkdir $tmp $tmp/a $tmp/a/b
# FIXME: if this fails, it's a framework failure
cat <<EOF > $tmp/$test.E
removing any entries of directory $tmp/a
removing any entries of directory $tmp/a/b
removing all entries of directory $tmp/a
removing all entries of directory $tmp/a/b
removing non-directory $tmp/a/b/g
removing the directory itself: $tmp/a/b
removing non-directory $tmp/a/f

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.2d from Makefile.am
# Makefile.in generated automatically by automake 1.2f from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.