Compare commits

...

59 Commits

Author SHA1 Message Date
Jim Meyering
9df5f7720b *** empty log message *** 2000-01-02 09:13:17 +00:00
Jim Meyering
f2de5d5212 *** empty log message *** 2000-01-02 09:12:55 +00:00
Jim Meyering
c5ed5e05ea . 2000-01-02 09:11:55 +00:00
Jim Meyering
7092835d3b *** empty log message *** 2000-01-02 08:57:49 +00:00
Jim Meyering
af6d4ad6ca Remove non-POSIX warning about trailing-slashed symlink-to-directory. 2000-01-02 08:53:30 +00:00
Jim Meyering
70cc369588 New option: --strip-trailing-slashes. 2000-01-02 08:51:39 +00:00
Jim Meyering
b3faf79a75 *** empty log message *** 2000-01-02 08:45:43 +00:00
Jim Meyering
50de4d0751 *** empty log message *** 2000-01-02 07:41:02 +00:00
Jim Meyering
60f3f576c7 (#pragma alloca): Add if _AIX is defined.
(path-concat.h): Include.
(show_point): If HAVE_REALPATH or HAVE_RESOLVEPATH is defined,
find the real absolute path for PATH, and use that to find the
mount point.

(show_point): Prefer non-dummy entries in shortcuts, too.
Disable bogus mount dirs instead of restatting them each time.
2000-01-02 07:40:24 +00:00
Jim Meyering
05fcf7df27 (my_strftime): Some old compilers object to
'\a', so don't bother optimizing for it.
2000-01-02 07:09:54 +00:00
Jim Meyering
d5d6d965ed *** empty log message *** 2000-01-01 20:00:28 +00:00
Jim Meyering
d9fd3ba617 . 2000-01-01 19:56:56 +00:00
Jim Meyering
8c3df2e678 *** empty log message *** 2000-01-01 09:43:40 +00:00
Jim Meyering
847d050688 *** empty log message *** 1999-12-30 09:09:38 +00:00
Jim Meyering
18f381afea *** empty log message *** 1999-12-30 09:09:03 +00:00
Jim Meyering
1128d1dffb *** empty log message *** 1999-12-30 09:07:31 +00:00
Jim Meyering
1d54f66fd0 (remove_parents, main): Don't pass errno to error
when printing "removing directory" message.  Failure of rmdir is
handled elsewhere.
1999-12-30 09:07:13 +00:00
Jim Meyering
84226463b1 . 1999-12-27 16:31:56 +00:00
Jim Meyering
b32cecce88 . 1999-12-27 16:30:45 +00:00
Jim Meyering
99c51ad97e minor var. renamings 1999-12-27 16:30:20 +00:00
Jim Meyering
4c746d7a4c tweak --help 1999-12-27 15:57:26 +00:00
Jim Meyering
dc33452012 *** empty log message *** 1999-12-27 14:17:39 +00:00
Jim Meyering
f71e656070 *** empty log message *** 1999-12-26 10:19:40 +00:00
Jim Meyering
34c6851c4a *** empty log message *** 1999-12-26 10:16:18 +00:00
Jim Meyering
b1dee02eb1 *** empty log message *** 1999-12-26 10:03:46 +00:00
Jim Meyering
0335111c76 (jm_FUNC_NANOSLEEP): New file/macro. 1999-12-26 10:02:31 +00:00
Jim Meyering
2dc33d421e *** empty log message *** 1999-12-26 09:40:16 +00:00
Jim Meyering
0ac76a646b *** empty log message *** 1999-12-25 22:15:23 +00:00
Jim Meyering
64003d937b Use < rather than >.
(main): Normalize ts_stop.
1999-12-25 20:00:21 +00:00
Jim Meyering
936a26728a . 1999-12-23 15:28:02 +00:00
Jim Meyering
5f22e8234b *** empty log message *** 1999-12-23 15:09:17 +00:00
Jim Meyering
0ecbb73025 (USE_CLOCK_GETTIME): Define.
[USE_CLOCK_GETTIME]: Include sys/time.h.
(timespec_subtract): New function.
(clock_get_realtime): New function.
(sighandler): Remove function.
(main): Reimplement again, using nanosleep and clock_gettime.
1999-12-23 14:34:38 +00:00
Jim Meyering
fc7ceba21b *** empty log message *** 1999-12-23 14:25:17 +00:00
Jim Meyering
c5494ca49a *** empty log message *** 1999-12-23 11:56:32 +00:00
Jim Meyering
c94e214238 Check for clock_gettime (moved from fileutils/configure.in)
Check for gettimeofday.
1999-12-23 11:55:58 +00:00
Jim Meyering
5db04594ae *** empty log message *** 1999-12-23 11:54:36 +00:00
Jim Meyering
eb19369c84 *** empty log message *** 1999-12-23 09:56:01 +00:00
Jim Meyering
1c49904e91 *** empty log message *** 1999-12-23 09:51:50 +00:00
Jim Meyering
d134d00bb4 . 1999-12-23 09:50:31 +00:00
Jim Meyering
9cd6962a4a . 1999-12-23 09:49:59 +00:00
Jim Meyering
21039f0b39 *** empty log message *** 1999-12-23 09:34:57 +00:00
Jim Meyering
ff9eed5ff5 (usage): Correct typos.
List new --target-directory=... usage.
Reported by Gran Uddeborg
1999-12-23 09:34:48 +00:00
Jim Meyering
176efa5092 (usage): List new --target-directory=... usage. 1999-12-23 09:34:25 +00:00
Jim Meyering
1206a834dd rewrite expression (equivalently) at request of Paul Eggert 1999-12-22 20:49:19 +00:00
Jim Meyering
bda1bae801 *** empty log message *** 1999-12-22 16:51:48 +00:00
Jim Meyering
67e3d46292 *** empty log message *** 1999-12-22 16:32:24 +00:00
Jim Meyering
3551f63a62 (ceil_percent): Remove.
(show_dev): Avoid overflow problems when calculating percent.
Do not display negative percents.
1999-12-22 16:32:07 +00:00
Jim Meyering
38d48aa7e9 *** empty log message *** 1999-12-22 14:30:45 +00:00
Jim Meyering
94aebe4774 Use $file, not $tmp/file. Exit 77 if run as root. 1999-12-22 14:30:23 +00:00
Jim Meyering
759da836f6 *** empty log message *** 1999-12-22 11:18:06 +00:00
Jim Meyering
222389a6d0 *** empty log message *** 1999-12-22 11:15:26 +00:00
Jim Meyering
621a5a5d61 (regress-1): New test for the above. 1999-12-22 11:15:15 +00:00
Jim Meyering
1796cbe0c6 *** empty log message *** 1999-12-22 11:14:30 +00:00
Jim Meyering
aa07786952 (get_date): Fix typo in time_t overflow test.
From Michael Stone.
1999-12-22 11:14:05 +00:00
Jim Meyering
771ec09cd4 . 1999-12-20 10:42:32 +00:00
Jim Meyering
f9dd65cfc8 Remove kludge, now that I'm using the fixed autoconf-2.14a-1999-12-20. 1999-12-20 10:37:27 +00:00
Jim Meyering
372ce8d3ce *** empty log message *** 1999-12-20 10:11:28 +00:00
Jim Meyering
7769c416ef tweak comment 1999-12-19 15:51:32 +00:00
Jim Meyering
c077ecf83c tweak comment 1999-12-19 15:21:19 +00:00
28 changed files with 598 additions and 110 deletions

1
THANKS
View File

@@ -56,6 +56,7 @@ John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th
John Gotts: jgotts@umich.edu
Jürgen Fluk: louis@dachau.marco.de
jvogel: jvogel@linkny.com
Kalle Olavi Niemitalo: tosi@stekt.oulu.fi
Karl Heuer: kwzh@gnu.org
Kjetil Torgrim Homme: kjetilho@ifi.uio.no
Larry McVoy: lm@sgi.com

View File

@@ -169,10 +169,10 @@ DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in TODO alloca.c \
chown.c dup2.c error.c error.h euidaccess.c fileblocks.c fnmatch.c \
fsusage.c ftruncate.c getdate.c getgroups.c getline.c group-member.c \
lchown.c malloc.c memchr.c memcmp.c memcpy.c memmove.c memset.c mkdir.c \
mktime.c mountlist.c obstack.c obstack.h realloc.c regex.c rmdir.c \
rpmatch.c stpcpy.c strcasecmp.c strdup.c strftime.c strncasecmp.c \
strndup.c strstr.c strtol.c strtoul.c strtoull.c strtoumax.c \
strverscmp.c utime.c
mktime.c mountlist.c nanosleep.c obstack.c obstack.h realloc.c regex.c \
rmdir.c rpmatch.c stpcpy.c strcasecmp.c strdup.c strftime.c \
strncasecmp.c strndup.c strstr.c strtol.c strtoul.c strtoull.c \
strtoumax.c strverscmp.c utime.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -193,8 +193,8 @@ $(DEPDIR)/lchown.Po $(DEPDIR)/long-options$U.Po $(DEPDIR)/lstat.Po \
$(DEPDIR)/makepath$U.Po $(DEPDIR)/malloc.Po $(DEPDIR)/memchr.Po \
$(DEPDIR)/memcmp.Po $(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po \
$(DEPDIR)/memset.Po $(DEPDIR)/mkdir.Po $(DEPDIR)/mktime.Po \
$(DEPDIR)/modechange$U.Po $(DEPDIR)/mountlist.Po $(DEPDIR)/obstack.Po \
$(DEPDIR)/path-concat$U.Po $(DEPDIR)/posixtm$U.Po \
$(DEPDIR)/modechange$U.Po $(DEPDIR)/mountlist.Po $(DEPDIR)/nanosleep.Po \
$(DEPDIR)/obstack.Po $(DEPDIR)/path-concat$U.Po $(DEPDIR)/posixtm$U.Po \
$(DEPDIR)/quotearg$U.Po $(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po \
$(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po \
$(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po \
@@ -342,6 +342,8 @@ modechange_.c: modechange.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/modechange.c; then echo $(srcdir)/modechange.c; else echo modechange.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > modechange_.c
mountlist_.c: mountlist.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mountlist.c; then echo $(srcdir)/mountlist.c; else echo mountlist.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > mountlist_.c
nanosleep_.c: nanosleep.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/nanosleep.c; then echo $(srcdir)/nanosleep.c; else echo nanosleep.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > nanosleep_.c
obstack_.c: obstack.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/obstack.c; then echo $(srcdir)/obstack.c; else echo obstack.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > obstack_.c
path-concat_.c: path-concat.c $(ANSI2KNR)
@@ -421,13 +423,13 @@ full-write_.o getdate_.o getgroups_.o getline_.o getopt_.o getopt1_.o \
group-member_.o hash_.o human_.o idcache_.o isdir_.o lchown_.o \
long-options_.o lstat_.o makepath_.o malloc_.o memchr_.o memcmp_.o \
memcpy_.o memmove_.o memset_.o mkdir_.o mktime_.o modechange_.o \
mountlist_.o obstack_.o path-concat_.o posixtm_.o quotearg_.o \
realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o same_.o \
save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o strdup_.o \
strftime_.o stripslash_.o strncasecmp_.o strndup_.o strstr_.o strtol_.o \
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o userspec_.o utime_.o \
version-etc_.o xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o \
xstrtoumax_.o yesno_.o : $(ANSI2KNR)
mountlist_.o nanosleep_.o obstack_.o path-concat_.o posixtm_.o \
quotearg_.o realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o \
same_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
strdup_.o strftime_.o stripslash_.o strncasecmp_.o strndup_.o strstr_.o \
strtol_.o strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o userspec_.o \
utime_.o version-etc_.o xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o \
xstrtoul_.o xstrtoumax_.o yesno_.o : $(ANSI2KNR)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
@@ -524,6 +526,7 @@ distdir: $(DISTFILES)
@AMDEP@include $(DEPDIR)/mktime.Po
@AMDEP@include $(DEPDIR)/modechange$U.Po
@AMDEP@include $(DEPDIR)/mountlist.Po
@AMDEP@include $(DEPDIR)/nanosleep.Po
@AMDEP@include $(DEPDIR)/obstack.Po
@AMDEP@include $(DEPDIR)/path-concat$U.Po
@AMDEP@include $(DEPDIR)/posixtm$U.Po

View File

@@ -99,7 +99,7 @@ enum { MERam, MERpm, MER24 };
/* Information passed to and from the parser. */
struct parser_control
{
{
/* The input string remaining to be parsed. */
const char *input;
@@ -1014,7 +1014,7 @@ get_date (const char *p, const time_t *now)
if (! gmt)
return -1;
delta = pc.time_zone * 60 + difftm (gmt, &tm);
if ((Start - delta < Start) != (delta < 0))
if ((Start < Start - delta) != (delta < 0))
return -1; /* time_t overflow */
Start -= delta;
}

104
lib/nanosleep.c Normal file
View File

@@ -0,0 +1,104 @@
/* Provide a replacement for the POSIX nanosleep function.
Copyright (C) 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* written by Jim Meyering */
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <time.h>
/* FIXME: is including both like this kosher? */
#include <sys/time.h>
static int suspended;
int first_call = 1;
/* Handle SIGCONT. */
static void
sighandler (int sig)
{
suspended = 1;
}
/* FIXME: comment */
static void
my_usleep (const struct timespec *ts_delay)
{
struct timeval tv_delay;
tv_delay.tv_sec = ts_delay->tv_sec;
tv_delay.tv_usec = ts_delay->tv_nsec / 1000;
select (0, (void *) 0, (void *) 0, (void *) 0, &tv_delay);
}
/* FIXME: comment */
int
nanosleep (const struct timespec *requested_delay,
struct timespec *remaining_delay)
{
#ifdef SA_INTERRUPT
struct sigaction oldact, newact;
#endif
suspended = 0;
/* set up sig handler */
if (first_call)
{
#ifdef SA_INTERRUPT
newact.sa_handler = sighandler;
sigemptyset (&newact.sa_mask);
newact.sa_flags = 0;
sigaction (SIGCONT, NULL, &oldact);
if (oldact.sa_handler != SIG_IGN)
sigaction (SIGCONT, &newact, NULL);
#else
if (signal (SIGCONT, SIG_IGN) != SIG_IGN)
signal (SIGCONT, sighandler);
#endif
first_call = 0;
}
my_usleep (requested_delay);
if (suspended)
{
/* Calculate time remaining. */
/* FIXME: the code in sleep doesn't use this, so there's no
rush to implement it. */
errno = EINTR;
}
/* FIXME: Restore sig handler? */
return suspended;
}

View File

@@ -493,7 +493,7 @@ my_strftime (char *s, size_t maxsize, const char *format, const struct tm *tp
case '%':
break;
case '\a': case '\b': case '\t': case '\n':
case '\b': case '\t': case '\n':
case '\v': case '\f': case '\r':
case ' ': case '!': case '"': case '#': case '&': case'\'':
case '(': case ')': case '*': case '+': case ',': case '-':
@@ -511,10 +511,11 @@ my_strftime (char *s, size_t maxsize, const char *format, const struct tm *tp
case 'r': case 's': case 't': case 'u': case 'v': case 'w':
case 'x': case 'y': case 'z': case '{': case '|': case '}':
case '~':
/* The C Standard requires these 98 characters (plus '%') to
/* The C Standard requires these 97 characters (plus '%', '\a') to
be in the basic execution character set. None of these
characters can start a multibyte sequence, so they need
not be analyzed further. */
not be analyzed further. Some old compilers object to
'\a', so don't bother optimizing for it. */
add (1, *p = *f);
continue;

View File

@@ -1,3 +1,19 @@
1999-12-26 Jim Meyering <meyering@ascend.com>
* jm-macros.m4: Use it here.
* nanosleep.m4 (jm_FUNC_NANOSLEEP): New file/macro.
1999-12-23 Jim Meyering <meyering@ascend.com>
* jm-macros.m4: Check for clock_gettime (moved from
fileutils/configure.in)
Check for gettimeofday.
1999-12-20 Jim Meyering <meyering@ascend.com>
* strftime.m4: Remove kludge, now that I'm using the fixed
autoconf-2.14a-1999-12-20.
1999-12-19 Jim Meyering <meyering@ascend.com>
* lstat-slash.m4: New file.

View File

@@ -35,6 +35,7 @@ lstat-slash.m4 \
lstat.m4 \
malloc.m4 \
memcmp.m4 \
nanosleep.m4 \
perl.m4 \
prereq.m4 \
progtest.m4 \

View File

@@ -135,6 +135,7 @@ lstat-slash.m4 \
lstat.m4 \
malloc.m4 \
memcmp.m4 \
nanosleep.m4 \
perl.m4 \
prereq.m4 \
progtest.m4 \

View File

@@ -34,6 +34,7 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([jm_FUNC_STAT])
AC_REQUIRE([jm_FUNC_REALLOC])
AC_REQUIRE([jm_FUNC_MALLOC])
AC_REQUIRE([jm_FUNC_NANOSLEEP])
AC_REQUIRE([jm_FUNC_READDIR])
AC_REQUIRE([jm_FUNC_MEMCMP])
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
@@ -63,6 +64,13 @@ AC_DEFUN(jm_MACROS,
dnl ...: warning: AC_TRY_RUN called without default to allow cross compiling
AC_FUNC_SETVBUF_REVERSED
# used by sleep and shred
# Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
AC_CHECK_FUNCS(clock_gettime)
AC_CHECK_FUNCS(gettimeofday)
AM_FUNC_GETLINE
if test $am_cv_func_working_getline != yes; then
AC_CHECK_FUNCS(getdelim)

34
m4/nanosleep.m4 Normal file
View File

@@ -0,0 +1,34 @@
#serial 1
dnl From Jim Meyering.
dnl FIXME
dnl
AC_DEFUN(jm_FUNC_NANOSLEEP,
[
AC_CACHE_CHECK([whether nanosleep works],
jm_cv_func_nanosleep_works,
[AC_TRY_RUN([
# include <time.h>
int
main ()
{
struct timespec ts_sleep, ts_remaining;
ts_sleep.tv_sec = 0;
ts_sleep.tv_nsec = 1;
exit (nanosleep (&ts_sleep, &ts_remaining) == 0 ? 0 : 1);
}
],
jm_cv_func_nanosleep_works=yes,
jm_cv_func_nanosleep_works=no,
dnl When crosscompiling, assume the worst.
jm_cv_func_nanosleep_works=yes)
])
if test $jm_cv_func_nanosleep_works = no; then
AC_SUBST(LIBOBJS)
LIBOBJS="$LIBOBJS nanosleep.$ac_objext"
AC_DEFINE_UNQUOTED(nanosleep, gnu_nanosleep,
[Define to gnu_nanosleep if the replacement function should be used.])
fi
])

View File

@@ -1,4 +1,4 @@
#serial 7
#serial 8
dnl This macro is intended to be used solely in this file.
dnl These are the prerequisite macros for GNU's strftime.c replacement.
@@ -19,12 +19,7 @@ AC_DEFUN(_jm_STRFTIME_PREREQS,
[AC_DEFINE(HAVE_TM_GMTOFF, 1,
[Define if struct tm has the tm_gmtoff member.])],
,
dnl FIXME: having to put the closing square bracket on the
dnl FIXME: next line is a gross kludge to work around an
dnl FIXME: infelicity in how the new autoconf works.
dnl FIXME: This should be fixed pretty soon.
[#include <time.h>
])
[#include <time.h>])
])
dnl Determine if the strftime function has all the features of the GNU one.

View File

@@ -1,3 +1,62 @@
2000-01-02 Jim Meyering <meyering@ascend.com>
* Version 4.0m.
* src/mv.c: New option: --strip-trailing-slashes.
1999-11-18 Paul Eggert <eggert@twinsun.com>
* lib/strftime.c (my_strftime): Some old compilers object to
'\a', so don't bother optimizing for it.
2000-01-01 Paul Eggert <eggert@twinsun.com>
Fix bug: `df PATH' sometimes misbehaves when there is an
inaccessible mount point unrelated to PATH.
* configure.in (AC_CHECK_FUNCS): Add realpath, resolvepath.
* src/df.c (#pragma alloca): Add if _AIX is defined.
(path-concat.h): Include.
(show_point): If HAVE_REALPATH or HAVE_RESOLVEPATH is defined,
find the real absolute path for PATH, and use that to find the
mount point.
(show_point): Prefer non-dummy entries in shortcuts, too.
Disable bogus mount dirs instead of restatting them each time.
1999-12-30 Jim Meyering <meyering@ascend.com>
1999-12-17 Kalle Olavi Niemitalo <tosi@stekt.oulu.fi>
* src/rmdir.c (remove_parents, main): Don't pass errno to error
when printing "removing directory" message. Failure of rmdir is
handled elsewhere.
1999-12-23 Jim Meyering <meyering@ascend.com>
* configure.in: Remove clock_gettime tests.
Now they're in m4/jm-macros.m4.
* src/ln.c (usage): Correct typos.
List new --target-directory=... usage.
Reported by Göran Uddeborg
* src/mv.c (usage): List new --target-directory=... usage.
1999-12-22 Jim Meyering <meyering@ascend.com>
* lib/getdate.y (get_date): Fix typo in time_t overflow test.
From Michael Stone.
1999-12-21 Andreas Schwab <schwab@suse.de>
* tests/shred/remove: Use $file, not $tmp/file. Exit 77 if run as
root.
1999-12-20 Paul Eggert <eggert@twinsun.com>
* src/df.c (ceil_percent): Remove.
(show_dev): Avoid overflow problems when calculating percent.
Do not display negative percents.
1999-12-19 Jim Meyering <meyering@ascend.com>
* Version 4.0l.

View File

@@ -1,4 +1,11 @@
Changes in release 4.1:
[4.0m]
* mv accepts new option: --strip-trailing-slashes (soon, many other
programs will, too)
* df no longer hangs when there is inaccessible mount point unrelated to PATH
* rmdir --verbose no longer prints extra, bogus diagnosic upon failure
* fix df bug that made it print bogus values in the `Use%' column.
* touch -d once again parses dates with `hh:mm ZONE' time zone info.
[4.0l]
* ls -l honors a trailing slash on a symlink argument, per POSIX.
* shred no longer appears to infloop when asked to remove files in

View File

@@ -1,3 +1,28 @@
1999-12-26 Jim Meyering <meyering@ascend.com>
* lib/nanosleep.c (nanosleep): New file.
1999-12-23 Jim Meyering <meyering@ascend.com>
* src/sleep.c (USE_CLOCK_GETTIME): Define.
[USE_CLOCK_GETTIME]: Include sys/time.h.
(timespec_subtract): New function.
(clock_get_realtime): New function.
(sighandler): Remove function.
(main): Reimplement again, using nanosleep and clock_gettime.
* configure.in: Remove check for gettimeofday.
Now it's in m4/jm-macros.m4
* man/Makefile.summ: Remove now-unused summaries.
1999-12-22 Jim Meyering <meyering@ascend.com>
* lib/getdate.y (get_date): Fix typo in time_t overflow test.
From Michael Stone.
* tests/date/Test.pm (regress-1): New test for the above.
1999-12-18 Jim Meyering <meyering@ascend.com>
* src/who.c (print_entry): Correct do_lookup test so that who

View File

@@ -1,6 +1,8 @@
Changes in release 2.1
[2.0a]
* sleep accepts floating point arguments on command line
* sleep continues sleeping after being suspended and continued
* who once again prints whatever host information it has, even without --lookup
Changes in release 2.0
* disable stty tests (otherwise they fail) when `make check' is run via rsh
[1.16m]

View File

@@ -1,7 +1,18 @@
1999-12-09 Jim Meyering <meyering@ascend.com>
2000-01-01 Jim Meyering <meyering@ascend.com>
* Version 2.0a.
* lib/Makefile.am (lstat.c): Adapt rule to handle new parts of xstat.in.
1999-12-12 Jim Meyering <meyering@ascend.com>
Move 120+ lines of stat.h-related macros from system.h (not shared)
to sys2.h, which is shared between fileutils, sh-utils, textutils.
* src/system.h: Move them from here...
* src/sys2.h: ... to here.
1999-12-09 Jim Meyering <meyering@ascend.com>
* configure.in (ALL_LINGUAS): Add Galician (gl).
1999-12-06 Jim Meyering <meyering@ascend.com>

View File

@@ -151,7 +151,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
-R, --recursive copy directories recursively\n\
-s, --symbolic-link make symbolic links instead of copying\n\
-S, --suffix=SUFFIX override the usual backup suffix\n\
--target-directory=DIR move all SOURCE arguments into directory DIR\n\
--target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY\n\
-u, --update copy only when the SOURCE file is newer\n\
than the destination file or when the\n\
destination file is missing\n\

203
src/df.c
View File

@@ -1,5 +1,5 @@
/* df - summarize free disk space
Copyright (C) 91, 1995-1999 Free Software Foundation, Inc.
Copyright (C) 91, 1995-2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,10 @@
--human-readable and --megabyte options added by lm@sgi.com.
--si and large file support added by eggert@twinsun.com. */
#ifdef _AIX
#pragma alloca
#endif
#include <config.h>
#if HAVE_INTTYPES_H
# include <inttypes.h>
@@ -34,6 +38,7 @@
#include "fsusage.h"
#include "human.h"
#include "mountlist.h"
#include "path-concat.h"
#include "save-cwd.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -227,31 +232,6 @@ df_readable (int negative, uintmax_t n, char *buf,
}
}
/* Return the ceiling of N * 100 / D. Avoid the ceil function, so that
we needn't link the math library. */
static double
ceil_percent (uintmax_t n, uintmax_t d)
{
if (n <= (uintmax_t) -1 / 100)
{
uintmax_t n100 = n * 100;
return n100 / d + (n100 % d != 0);
}
else
{
/* Avoid integer overflow. We should use multiple precision
arithmetic here, but we'll be lazy and resort to floating
point. This can yield answers that are slightly off. In
practice it is quite rare to overflow uintmax_t, so this is
good enough for now. */
double pct = n * 100.0 / d;
double ipct = (int) pct;
if (ipct - 1 < pct && pct <= ipct + 1)
pct = ipct + (ipct < pct);
return pct;
}
}
/* Display a space listing for the disk device with absolute path DISK.
If MOUNT_POINT is non-NULL, it is the path of the root of the
filesystem on DISK.
@@ -277,7 +257,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
uintmax_t available_to_root;
uintmax_t used;
int negate_used;
uintmax_t nonroot_total;
double pct = -1;
if (me_remote && show_local_fs)
return;
@@ -373,15 +353,36 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
width, df_readable (negate_available, available,
buf[2], input_units, output_units));
if (used == -1 || available == -1
|| ! (nonroot_total = ((negate_used ? - used : used)
+ (negate_available ? - available : available))))
printf ("%*s", use_width, "- ");
if (used != -1 && available != -1)
{
/* The following floating-point calculations can suffer from
minor rounding errors, but making them precise requires
multiple precision arithmetic, and it's not worth the
aggravation. */
double u = used;
double a = available;
double nonroot_total = ((negate_used ? - u : u)
+ (negate_available ? - a : a));
if (nonroot_total)
{
pct = u * 100 / nonroot_total;
if (posix_format)
{
/* Like `pct = ceil (pct);', but avoid ceil so that
the math library needn't be linked. */
double ipct = (long) pct;
if (ipct - 1 < pct && pct <= ipct + 1)
pct = ipct + (ipct < pct);
}
}
}
if (0 <= pct)
printf ("%*.0f%%", use_width - 1, pct);
else
printf ("%*.0f%%", use_width - 1,
(posix_format
? ceil_percent (used, nonroot_total)
: used * 100.0 / nonroot_total));
printf ("%*s", use_width, "- ");
if (mount_point)
{
@@ -498,6 +499,7 @@ show_point (const char *point, const struct stat *statp)
struct stat disk_stats;
struct mount_entry *me;
struct mount_entry *matching_dummy = NULL;
char *needs_freeing = NULL;
/* If POINT is an absolute path name, see if we can find the
mount point without performing any extra stat calls at all. */
@@ -507,13 +509,104 @@ show_point (const char *point, const struct stat *statp)
{
if (STREQ (me->me_mountdir, point))
{
show_dev (me->me_devname, me->me_mountdir, me->me_type,
me->me_dummy, me->me_remote);
return;
/* Prefer non-dummy entries. */
if (! me->me_dummy)
goto show_me;
matching_dummy = me;
}
}
if (matching_dummy)
goto show_matching_dummy;
}
#if HAVE_REALPATH || HAVE_RESOLVEPATH
/* Calculate the real absolute path for POINT, and use that to find
the mount point. This avoids statting unavailable mount points,
which can hang df. */
{
char const *abspoint = point;
char *resolved;
ssize_t resolved_len;
struct mount_entry *best_match = NULL;
# if HAVE_RESOLVEPATH
/* All known hosts with resolvepath (e.g. Solaris 7) don't turn
relative names into absolute ones, so prepend the working
directory if the path is not absolute. */
if (*point != '/')
{
static char const *wd;
if (! wd)
{
struct stat pwd_stats;
struct stat dot_stats;
/* Use PWD if it is correct; this is usually cheaper than
xgetcwd. */
wd = getenv ("PWD");
if (! (wd
&& stat (wd, &pwd_stats) == 0
&& stat (".", &dot_stats) == 0
&& SAME_INODE (pwd_stats, dot_stats)))
wd = xgetcwd ();
}
if (wd)
{
needs_freeing = path_concat (wd, point, NULL);
if (needs_freeing)
abspoint = needs_freeing;
}
}
# endif
# if HAVE_RESOLVEPATH
{
size_t resolved_size = strlen (abspoint);
do
{
resolved_size = 2 * resolved_size + 1;
resolved = alloca (resolved_size);
resolved_len = resolvepath (abspoint, resolved, resolved_size);
}
while (resolved_len == resolved_size);
}
# else
resolved = alloca (PATH_MAX + 1);
resolved = realpath (abspoint, resolved);
resolved_len = resolved ? strlen (resolved) : -1;
# endif
if (1 <= resolved_len && resolved[0] == '/')
{
size_t best_match_len = 0;
for (me = mount_list; me; me = me->me_next)
if (! me->me_dummy)
{
size_t len = strlen (me->me_mountdir);
if (best_match_len < len && len <= resolved_len
&& (len == 1 /* root file system */
|| ((len == resolved_len || resolved[len] == '/')
&& strncmp (me->me_mountdir, resolved, len) == 0)))
{
best_match = me;
best_match_len = len;
}
}
}
if (best_match)
{
me = best_match;
goto show_me;
}
}
#endif
for (me = mount_list; me; me = me->me_next)
{
if (me->me_dev == (dev_t) -1)
@@ -532,29 +625,22 @@ show_point (const char *point, const struct stat *statp)
if (statp->st_dev == me->me_dev)
{
/* Skip bogus mtab entries. */
if (stat (me->me_mountdir, &disk_stats) != 0 ||
disk_stats.st_dev != me->me_dev)
continue;
/* Prefer non-dummy entries. */
if (me->me_dummy)
if (stat (me->me_mountdir, &disk_stats) != 0
|| disk_stats.st_dev != me->me_dev)
{
matching_dummy = me;
me->me_dev = (dev_t) -2;
continue;
}
show_dev (me->me_devname, me->me_mountdir, me->me_type,
me->me_dummy, me->me_remote);
return;
/* Prefer non-dummy entries. */
if (! me->me_dummy)
goto show_me;
matching_dummy = me;
}
}
if (matching_dummy)
{
show_dev (matching_dummy->me_devname, matching_dummy->me_mountdir,
matching_dummy->me_type, 1, matching_dummy->me_remote);
return;
}
goto show_matching_dummy;
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
print as much info as we can; methods that require the device to be
@@ -570,6 +656,17 @@ show_point (const char *point, const struct stat *statp)
else
error (0, errno, "%s", point);
}
goto free_then_return;
show_matching_dummy:
me = matching_dummy;
show_me:
show_dev (me->me_devname, me->me_mountdir, me->me_type, me->me_dummy,
me->me_remote);
free_then_return:
if (needs_freeing)
free (needs_freeing);
}
/* Determine what kind of node PATH is and show the disk usage

View File

@@ -324,8 +324,9 @@ usage (int status)
printf (_("\
Usage: %s [OPTION]... TARGET [LINK_NAME]\n\
or: %s [OPTION]... TARGET... DIRECTORY\n\
or: %s [OPTION]... --target-directory=DIRECTORY TARGET...\n\
"),
program_name, program_name);
program_name, program_name, program_name);
printf (_("\
Create a link to the specified TARGET with optional LINK_NAME. If there is\n\
more than one TARGET, the last argument must be a directory; create links\n\
@@ -340,7 +341,8 @@ with --symbolic. When creating hard links, each TARGET must exist.\n\
-i, --interactive prompt whether to remove destinations\n\
-s, --symbolic make symbolic links instead of hard links\n\
-S, --suffix=SUFFIX override the usual backup suffix\n\
--target-directory=DIR move all SOURCE arguments into directory DIR\n\
--target-directory=DIRECTORY specify the DIRECTORY in which to create\n\
the links\n\
-v, --verbose print name of each file before linking\n\
--help display this help and exit\n\
--version output version information and exit\n\

View File

@@ -1,5 +1,5 @@
/* mv -- move or rename files
Copyright (C) 86, 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
Copyright (C) 86, 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,7 +70,8 @@
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
TARGET_DIRECTORY_OPTION = CHAR_MAX + 1
TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
STRIP_TRAILING_SLASHES_OPTION
};
int euidaccess ();
@@ -82,11 +83,14 @@ int yesno ();
/* The name this program was run with. */
char *program_name;
static int remove_trailing_slashes;
static struct option const long_options[] =
{
{"backup", optional_argument, NULL, 'b'},
{"force", no_argument, NULL, 'f'},
{"interactive", no_argument, NULL, 'i'},
{"strip-trailing-slash", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
{"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
{"update", no_argument, NULL, 'u'},
@@ -288,6 +292,16 @@ movefile (char *source, char *dest, int dest_is_dir,
int dest_had_trailing_slash = strip_trailing_slashes_2 (dest);
int fail;
/* This code was introduced to handle the ambiguity in the semantics
of mv that is induced by the varying semantics of the rename function.
Some systems (e.g., Linux) have a rename function that honors a
trailing slash, while others (like Solaris 5,6,7) have a rename
function that ignores a trailing slash. I believe the Linux
rename semantics are POSIX and susv2 compliant. */
if (remove_trailing_slashes)
strip_trailing_slashes_2 (source);
/* In addition to when DEST is a directory, if DEST has a trailing
slash and neither SOURCE nor DEST is a directory, presume the target
is DEST/`basename source`. This converts `mv x y/' to `mv x y/x'.
@@ -333,16 +347,19 @@ usage (int status)
printf (_("\
Usage: %s [OPTION]... SOURCE DEST\n\
or: %s [OPTION]... SOURCE... DIRECTORY\n\
or: %s [OPTION]... --target-directory=DIRECTORY SOURCE...\n\
"),
program_name, program_name);
program_name, program_name, program_name);
printf (_("\
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\
\n\
-b, --backup[=CONTROL] make backup before removal\n\
-f, --force remove existing destinations, never prompt\n\
-i, --interactive prompt before overwrite\n\
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
argument\n\
-S, --suffix=SUFFIX override the usual backup suffix\n\
--target-directory=DIR move all SOURCE arguments into directory DIR\n\
--target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY\n\
-u, --update move only older or brand new non-directories\n\
-v, --verbose explain what is being done\n\
--help display this help and exit\n\
@@ -420,6 +437,9 @@ main (int argc, char **argv)
x.interactive = 1;
x.force = 0;
break;
case STRIP_TRAILING_SLASHES_OPTION:
remove_trailing_slashes = 1;
break;
case TARGET_DIRECTORY_OPTION:
target_directory = optarg;
break;

View File

@@ -113,7 +113,7 @@ remove_parents (char *path)
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
error (0, errno, _("removing directory, %s"), path);
error (0, 0, _("removing directory, %s"), path);
fail = rmdir (path);
@@ -215,7 +215,7 @@ main (int argc, char **argv)
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
error (0, errno, _("removing directory, %s"), dir);
error (0, 0, _("removing directory, %s"), dir);
fail = rmdir (dir);

View File

@@ -22,6 +22,11 @@
#include <time.h>
#include <getopt.h>
#define USE_CLOCK_GETTIME (defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME)
#if ! USE_CLOCK_GETTIME
# include <sys/time.h>
#endif
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
#endif
@@ -104,6 +109,59 @@ apply_suffix (double *s, char suffix_char)
return 0;
}
/* Subtract the `struct timespec' values X and Y,
storing the difference in DIFF.
Return 1 if the difference is positive, otherwise 0.
Derived from code in the GNU libc manual. */
static int
timespec_subtract (struct timespec *diff,
const struct timespec *x, struct timespec *y)
{
/* Perform the carry for the later subtraction by updating Y. */
if (x->tv_nsec < y->tv_nsec)
{
int nsec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1;
y->tv_nsec -= 1000000000 * nsec;
y->tv_sec += nsec;
}
if (1000000000 < x->tv_nsec - y->tv_nsec)
{
int nsec = (y->tv_nsec - x->tv_nsec) / 1000000000;
y->tv_nsec += 1000000000 * nsec;
y->tv_sec -= nsec;
}
/* Compute the time remaining to wait.
`tv_nsec' is certainly positive. */
diff->tv_sec = x->tv_sec - y->tv_sec;
diff->tv_nsec = x->tv_nsec - y->tv_nsec;
/* Return 1 if result is positive. */
return y->tv_sec < x->tv_sec;
}
static void
clock_get_realtime (struct timespec *ts)
{
int fail;
#if USE_CLOCK_GETTIME
fail = clock_gettime (CLOCK_REALTIME, &ts);
#else
struct timeval tv;
fail = gettimeofday (&tv, NULL);
if (!fail)
{
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = 1000 * tv.tv_usec;
}
#endif
if (fail)
error (1, errno, _("cannot read realtime clock"));
}
int
main (int argc, char **argv)
{
@@ -111,8 +169,12 @@ main (int argc, char **argv)
double seconds = 0.0;
int c;
int fail = 0;
int interrupted;
struct timespec ts;
struct timespec ts_start;
struct timespec ts_stop;
struct timespec ts_sleep;
/* Record start time. */
clock_get_realtime (&ts_start);
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -148,13 +210,13 @@ main (int argc, char **argv)
/* No negative intervals. */
|| s < 0
/* S must fit in a time_t. */
|| s > TIME_T_MAX
/* No extra chars after the number and an optional s,m,h,d char. */
|| TIME_T_MAX < s
/* No extra chars after the number and an optional s,m,h,d char. */
|| (*p && *(p+1))
/* Check any suffix char and update S based on the suffix. */
|| apply_suffix (&s, *p)
/* Make sure the sum fits in a time_t. */
|| (seconds += s) > TIME_T_MAX
|| TIME_T_MAX < (seconds += s)
)
{
error (0, 0, _("invalid time interval `%s'"), argv[i]);
@@ -165,22 +227,34 @@ main (int argc, char **argv)
if (fail)
usage (1);
/* Round to the nearest nanosecond here so that tv_nsec will be
no larger than 999,999,999. */
/* Add this here so we end up rounding to the nearest nanosecond.
This ensures that that tv_nsec will be no larger than 999,999,999. */
seconds += .0000000005;
/* Separate whole seconds from nanoseconds. */
ts.tv_sec = seconds;
ts.tv_nsec = (seconds - ts.tv_sec) * 1000000000;
ts_sleep.tv_sec = seconds;
ts_sleep.tv_nsec = (seconds - ts_sleep.tv_sec) * 1000000000;
ts_stop.tv_sec = ts_start.tv_sec + ts_sleep.tv_sec;
ts_stop.tv_nsec = ts_start.tv_nsec + ts_sleep.tv_nsec;
if (1000000000 <= ts_stop.tv_nsec)
{
++ts_stop.tv_sec;
ts_stop.tv_nsec -= 1000000000;
}
while (1)
{
struct timespec remaining;
interrupted = nanosleep (&ts, &remaining);
/* assert (!interrupted || errno == EINTR); */
if (!interrupted)
struct timespec ts_now;
int any_remaining;
int suspended = nanosleep (&ts_sleep, &remaining);
if (!suspended)
break;
clock_get_realtime (&ts_now);
any_remaining = timespec_subtract (&ts_sleep, &ts_stop, &ts_now);
if (! any_remaining)
break;
ts = remaining;
}
exit (0);

View File

@@ -9,7 +9,7 @@ W92-3.X millen-1.X rel-0.X rel-1a.X rel-1b.X rel-2a.X rel-2b.X rel-2c.X \
rel-2d.X rel-2e.X rel-2f.X rel-2g.X rel-3a.X next-s.X next-m.X next-h.X \
next-d.X next-w.X next-mo.X next-y.X utc-0.X utc-0a.X utc-1.I utc-1.X \
utc-1a.I utc-1a.X date2sec-0.X date2sec-0a.X date2sec-1.X sec2date-0.X \
this-m.X this-h.X this-w.X this-mo.X this-y.X risks-1.X
this-m.X this-h.X this-w.X this-mo.X this-y.X risks-1.X regress-1.X
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
9.E leap-1.O leap-1.E U95-1.O U95-1.E U95-2.O U95-2.E U95-3.O U95-3.E U92-1.O \
U92-1.E U92-2.O U92-2.E U92-3.O U92-3.E V92-1.O V92-1.E V92-2.O V92-2.E \
@@ -22,7 +22,7 @@ next-w.E next-mo.O next-mo.E next-y.O next-y.E utc-0.O utc-0.E utc-0a.O \
utc-0a.E utc-1.O utc-1.E utc-1a.O utc-1a.E date2sec-0.O date2sec-0.E \
date2sec-0a.O date2sec-0a.E date2sec-1.O date2sec-1.E sec2date-0.O \
sec2date-0.E this-m.O this-m.E this-h.O this-h.E this-w.O this-w.E this-mo.O \
this-mo.E this-y.O this-y.E risks-1.O risks-1.E
this-mo.E this-y.O this-y.E risks-1.O risks-1.E regress-1.O regress-1.E
##test-files-end
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -118,7 +118,7 @@ W92-3.X millen-1.X rel-0.X rel-1a.X rel-1b.X rel-2a.X rel-2b.X rel-2c.X \
rel-2d.X rel-2e.X rel-2f.X rel-2g.X rel-3a.X next-s.X next-m.X next-h.X \
next-d.X next-w.X next-mo.X next-y.X utc-0.X utc-0a.X utc-1.I utc-1.X \
utc-1a.I utc-1a.X date2sec-0.X date2sec-0a.X date2sec-1.X sec2date-0.X \
this-m.X this-h.X this-w.X this-mo.X this-y.X risks-1.X
this-m.X this-h.X this-w.X this-mo.X this-y.X risks-1.X regress-1.X
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
9.E leap-1.O leap-1.E U95-1.O U95-1.E U95-2.O U95-2.E U95-3.O U95-3.E U92-1.O \
@@ -132,7 +132,7 @@ next-w.E next-mo.O next-mo.E next-y.O next-y.E utc-0.O utc-0.E utc-0a.O \
utc-0a.E utc-1.O utc-1.E utc-1a.O utc-1a.E date2sec-0.O date2sec-0.E \
date2sec-0a.O date2sec-0a.E date2sec-1.O date2sec-1.E sec2date-0.O \
sec2date-0.E this-m.O this-m.E this-h.O this-h.E this-w.O this-w.E this-mo.O \
this-mo.E this-y.O this-y.E risks-1.O risks-1.E
this-mo.E this-y.O this-y.E risks-1.O risks-1.E regress-1.O regress-1.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -113,6 +113,9 @@ sub test_vector
['risks-1', "-d 'Nov 10 1996' $fmt", {}, "1996-11-10 00:00:00", 0],
['regress-1', "-u -d '1996-11-10 0:00:00 +0' $fmt", {},
"1996-11-10 00:00:00", 0],
# FIXME: add a lot more...
);
@@ -127,6 +130,10 @@ sub test_vector
$Test::env{'utc-0'} = ['TZ=UTC+4'];
# This one would pass if TZ (with any, or even no, value) were in
# the environment.
$Test::env{'regress-1'} = ['LANG=C'];
$Test::env{'utc-1'} = ['TZ=UTC+1'];
$Test::input_via{'utc-1'} = {REDIR => 0};
$Test::input_via{'utc-1a'} = {REDIR => 0};

View File

@@ -953,8 +953,25 @@ else
esac
fi
test -s risks-1.E || rm -f risks-1.E
LANG=C $xx -u -d '1996-11-10 0:00:00 +0' '+%Y-%m-%d %T' > regress-1.O 2> regress-1.E
code=$?
if test $code != 0 ; then
$echo "Test regress-1(LANG=C) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp regress-1.O $srcdir/regress-1.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed regress-1(LANG=C)"; fi ;;
1) $echo "Test regress-1(LANG=C) failed: files regress-1.O and $srcdir/regress-1.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test regress-1(LANG=C) may have failed." 1>&2;
$echo The command "cmp regress-1.O $srcdir/regress-1.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s regress-1.E || rm -f regress-1.E
if test $errors = 0 ; then
$echo Passed all 55 tests. 1>&2
$echo Passed all 56 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi

View File

@@ -15,7 +15,7 @@ file=$tmp/0123456789
framework_failure=0
mkdir $tmp || framework_failure=1
touch $tmp/file || framework_failure=1
touch $file || framework_failure=1
chmod u-w $tmp || framework_failure=1
if test $framework_failure = 1; then
@@ -23,12 +23,17 @@ if test $framework_failure = 1; then
exit 1
fi
touch $tmp/file >/dev/null 2>&1 && {
echo 'This test case can not be run as root'
exit 77
}
fail=0
# This would take so long that it appears to infloop
# when using version from fileutils-4.0k.
# When the command completes, expect it to fail.
shred -u $tmp/file > /dev/null 2>&1 && fail=1
shred -u $file > /dev/null 2>&1 && fail=1
chmod u+w $tmp
rm -rf $tmp

View File

@@ -30,9 +30,7 @@ echo fubar > in
tail -f in | cat > out &
pid=$!
sleep 1
echo out: `cat out`
kill $pid
echo out: `cat out`
fail=0
test "`cat out`" = fubar || fail=1