mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
114 Commits
FILEUTILS-
...
SH-UTILS-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80fd95a91d | ||
|
|
ca974b3755 | ||
|
|
9f5307f1d3 | ||
|
|
97085c8df7 | ||
|
|
de1cb33196 | ||
|
|
741c7303a5 | ||
|
|
f23b3eb47a | ||
|
|
f488edddf7 | ||
|
|
60dabf5cd1 | ||
|
|
44381ed288 | ||
|
|
4717bb93f2 | ||
|
|
9442b6050b | ||
|
|
6adb0e4d56 | ||
|
|
6f06aad852 | ||
|
|
baf8720297 | ||
|
|
94966b9515 | ||
|
|
55d80ad41a | ||
|
|
7b9c964fde | ||
|
|
c4b800d7b6 | ||
|
|
913e134b2d | ||
|
|
5f2d0e3d6c | ||
|
|
58cba22668 | ||
|
|
efe3229edb | ||
|
|
1279be6f8a | ||
|
|
c852bc40d3 | ||
|
|
e02fd60260 | ||
|
|
299882b8a4 | ||
|
|
fee7991cbc | ||
|
|
d486a2e744 | ||
|
|
6752f5570a | ||
|
|
00c9ad3937 | ||
|
|
9a0a8e29b0 | ||
|
|
e5f283604b | ||
|
|
1650a9459a | ||
|
|
58edea6508 | ||
|
|
d15ab2c1be | ||
|
|
cabbdf7bbf | ||
|
|
92999d559c | ||
|
|
625ce6a036 | ||
|
|
dfbeb59dc0 | ||
|
|
b8342a9a20 | ||
|
|
2170503967 | ||
|
|
5693e5c586 | ||
|
|
b830d441bb | ||
|
|
923a32a0a8 | ||
|
|
a86b522044 | ||
|
|
11eebed20f | ||
|
|
9bcff27f18 | ||
|
|
858254d559 | ||
|
|
f90f8cea87 | ||
|
|
30a1c917c7 | ||
|
|
36a3a59284 | ||
|
|
aac32d403c | ||
|
|
8606b093e4 | ||
|
|
4e4c0e24d5 | ||
|
|
76bc7db5e2 | ||
|
|
fd3e041f5b | ||
|
|
ce2bd26821 | ||
|
|
1b470586fd | ||
|
|
198bd22923 | ||
|
|
8c5a80b069 | ||
|
|
a2e08f3047 | ||
|
|
eff6393e39 | ||
|
|
bbe0894eb2 | ||
|
|
c2d329d6c8 | ||
|
|
136a8efd10 | ||
|
|
567dae8b9c | ||
|
|
f8c6ea241d | ||
|
|
6784d83a62 | ||
|
|
2f8c0d5542 | ||
|
|
1150e89832 | ||
|
|
dd282c588b | ||
|
|
8301c1310b | ||
|
|
8c0752d9be | ||
|
|
d9b2187a8c | ||
|
|
d50599ae1a | ||
|
|
6cb491d9df | ||
|
|
21b43e0fe9 | ||
|
|
2315cbdeaa | ||
|
|
eee26242bb | ||
|
|
757861331e | ||
|
|
e1cc2ace3c | ||
|
|
f8d2a3f723 | ||
|
|
3a673ed728 | ||
|
|
fd0797a4e4 | ||
|
|
3b979cf095 | ||
|
|
7f1c659ce3 | ||
|
|
ec266f43d5 | ||
|
|
1885aeaaa4 | ||
|
|
a2bee2bc6f | ||
|
|
1e01103713 | ||
|
|
ce17dc2e94 | ||
|
|
6ed0893953 | ||
|
|
483ed4cbfd | ||
|
|
b75698cf72 | ||
|
|
c26299c3d2 | ||
|
|
82ca413ae4 | ||
|
|
0d30a49178 | ||
|
|
cdff473cd3 | ||
|
|
9a74f64d12 | ||
|
|
8714cce36a | ||
|
|
1a7010a87f | ||
|
|
556a7ac657 | ||
|
|
eed8a2f5e1 | ||
|
|
2ff3485a8d | ||
|
|
3206a63225 | ||
|
|
ef4c445a55 | ||
|
|
20ca1d8601 | ||
|
|
60ff88e110 | ||
|
|
6e5a32d58f | ||
|
|
5f55b410a6 | ||
|
|
27f7343bf6 | ||
|
|
141036e2ea | ||
|
|
34c324d786 |
@@ -38,6 +38,15 @@ cvs-dist: maintainer-check
|
||||
cvs tag -c $(this-cvs-tag)
|
||||
$(MAKE) dist
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
# from a virgin tgz file, below.
|
||||
null_AM_MAKEFLAGS = \
|
||||
ACLOCAL=false \
|
||||
AUTOCONF=false \
|
||||
AUTOMAKE=false \
|
||||
AUTOHEADER=false \
|
||||
MAKEINFO=false
|
||||
|
||||
t=./=test
|
||||
my-distcheck:
|
||||
-rm -rf $(t)
|
||||
@@ -48,6 +57,7 @@ my-distcheck:
|
||||
cd $(t)/$(distdir) \
|
||||
&& ./configure --disable-nls \
|
||||
&& $(MAKE) CFLAGS='-Wformat -Werror' \
|
||||
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
||||
&& $(MAKE) dvi \
|
||||
&& $(MAKE) check \
|
||||
&& rm -rf $(DEPDIR) \
|
||||
@@ -62,7 +72,7 @@ my-distcheck:
|
||||
|
||||
THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
|
||||
# FIXME: this works only for Gnits-style test releases.
|
||||
PREV_VERSION := $(shell echo $(VERSION)|tr a-z Xa-y)
|
||||
PREV_VERSION := $(shell echo $(VERSION)|tr b-z a-y|sed 's/a$$//')
|
||||
PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
|
||||
v = Version
|
||||
|
||||
@@ -76,7 +86,6 @@ a_real_dir=/fs/share/ftp/gnu/fetish
|
||||
b_real_dir=/home/ftp/pub/gnu/fetish
|
||||
|
||||
url_dir_list = $(foreach x,a b,ftp://$($(x)_host)/$($(x)_url_dir))
|
||||
real_dir_list = $(foreach x,a b,ftp://$($(x)_host)$($(x)_real_dir))
|
||||
|
||||
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
|
||||
@@ -89,6 +98,10 @@ rel-check:
|
||||
echo "$(md5) -" > $$md5_tmp; \
|
||||
md5sum -c $$md5_tmp < $$tarz
|
||||
|
||||
release-archive-dir = ../release
|
||||
prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
|
||||
xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
|
||||
|
||||
announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
@( \
|
||||
echo Subject: $(distdir) released; \
|
||||
@@ -99,6 +112,12 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
echo " $$url/$(distdir).tar.gz"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo And here are xdelta-style diffs; \
|
||||
echo; \
|
||||
for url in $(url_dir_list); do \
|
||||
echo " $$url/$(xd-delta)"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo "$(md5) $(distdir).tar.gz"; \
|
||||
echo; \
|
||||
echo NEWS:; \
|
||||
@@ -119,10 +138,14 @@ alpha:
|
||||
$(MAKE) -s announcement > /tmp/announce-$(distdir)
|
||||
ln $(distdir).tar.gz ../release
|
||||
chmod a-w $(distdir).tar.gz
|
||||
cd $(release-archive-dir) \
|
||||
&& xdelta delta -9 $(prev-tgz) $(distdir).tar.gz $(xd-delta) || :
|
||||
ln $(release-archive-dir)/$(xd-delta) .
|
||||
chmod a-w $(release-archive-dir)/$(xd-delta)
|
||||
@echo =====================================
|
||||
@for url in $(real_dir_list); do \
|
||||
echo "ncftp -u $$url/"; \
|
||||
done
|
||||
@echo '# put $(distdir).tar.gz'
|
||||
@echo =====================================
|
||||
@echo 'scp $(xd-delta) $(distdir).tar.gz \'
|
||||
@echo ' $(b_host):$(b_real_dir)'
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
|
||||
@@ -3059,6 +3059,10 @@ hours
|
||||
days
|
||||
@end table
|
||||
|
||||
Historical implementations of @code{sleep} have required that
|
||||
@var{number} be an integer. However, GNU @code{sleep} accepts
|
||||
arbitrary floating point numbers.
|
||||
|
||||
The only options are @samp{--help} and @samp{--version}. @xref{Common
|
||||
options}.
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h getpagesize.h \
|
||||
group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
group-member.h hash.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h nanosleep.h path-concat.h pathmax.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h same.h save-cwd.h \
|
||||
savedir.h strverscmp.h \
|
||||
version-etc.h xalloc.h xstrtol.h
|
||||
|
||||
@@ -123,8 +123,8 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
|
||||
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h getpagesize.h \
|
||||
group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
group-member.h hash.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h nanosleep.h path-concat.h pathmax.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h same.h save-cwd.h \
|
||||
savedir.h strverscmp.h \
|
||||
version-etc.h xalloc.h xstrtol.h
|
||||
@@ -576,7 +576,7 @@ maintainer-clean-depend:
|
||||
@AMDEP@CCDEPMODE = @CCDEPMODE@
|
||||
|
||||
.c.o:
|
||||
@AMDEP@ source='$<' object='$@' @AMDEPBACKSLASH@
|
||||
@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
$(COMPILE) -c -o $@ $<
|
||||
|
||||
14
lib/error.c
14
lib/error.c
@@ -1,5 +1,5 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990,91,92,93,94,95,96,97,98, 99 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@@ -150,12 +150,16 @@ error (status, errnum, message, va_alist)
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
{
|
||||
#if defined HAVE_STRERROR_R || defined _LIBC
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
||||
# else
|
||||
/* Don't use __strerror_r's return value because on some systems
|
||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
fprintf (stderr, ": %s", errbuf);
|
||||
# endif
|
||||
#else
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
#endif
|
||||
@@ -228,12 +232,16 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
{
|
||||
#if defined HAVE_STRERROR_R || defined _LIBC
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
||||
# else
|
||||
/* Don't use __strerror_r's return value because on some systems
|
||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
fprintf (stderr, ": %s", errbuf);
|
||||
# endif
|
||||
#else
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* euidaccess -- check if effective user id can access file
|
||||
Copyright (C) 1990, 1991, 1995, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1991, 1995, 1998, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@@ -66,6 +66,9 @@ gid_t getegid ();
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(val) errno = (val)
|
||||
#endif
|
||||
|
||||
#if defined(EACCES) && !defined(EACCESS)
|
||||
# define EACCESS EACCES
|
||||
@@ -93,6 +96,7 @@ extern int errno;
|
||||
#ifdef _LIBC
|
||||
|
||||
# define group_member __group_member
|
||||
# define euidaccess __euidaccess
|
||||
|
||||
#else
|
||||
|
||||
@@ -102,15 +106,6 @@ static uid_t uid;
|
||||
/* The user's real group id. */
|
||||
static gid_t gid;
|
||||
|
||||
/* The user's effective user id. */
|
||||
static uid_t euid;
|
||||
|
||||
/* The user's effective group id. */
|
||||
static gid_t egid;
|
||||
|
||||
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
|
||||
static int have_ids = 0;
|
||||
|
||||
# if HAVE_GETGROUPS
|
||||
int group_member ();
|
||||
# else
|
||||
@@ -119,6 +114,15 @@ int group_member ();
|
||||
|
||||
#endif
|
||||
|
||||
/* The user's effective user id. */
|
||||
static uid_t euid;
|
||||
|
||||
/* The user's effective group id. */
|
||||
static gid_t egid;
|
||||
|
||||
/* Nonzero if UID, GID, EUID, and EGID have valid values. */
|
||||
static int have_ids;
|
||||
|
||||
|
||||
/* Return 0 if the user has permission of type MODE on file PATH;
|
||||
otherwise, return -1 and set `errno' to EACCESS.
|
||||
@@ -133,8 +137,9 @@ euidaccess (const char *path, int mode)
|
||||
int granted;
|
||||
|
||||
#ifdef _LIBC
|
||||
uid_t uid = getuid (), euid = geteuid ();
|
||||
gid_t gid = getgid (), egid = getegid ();
|
||||
if (! __libc_enable_secure)
|
||||
/* If we are not set-uid or set-gid, access does the same. */
|
||||
return __access (path, mode);
|
||||
#else
|
||||
if (have_ids == 0)
|
||||
{
|
||||
@@ -144,11 +149,11 @@ euidaccess (const char *path, int mode)
|
||||
euid = geteuid ();
|
||||
egid = getegid ();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uid == euid && gid == egid)
|
||||
/* If we are not set-uid or set-gid, access does the same. */
|
||||
return access (path, mode);
|
||||
#endif
|
||||
|
||||
if (stat (path, &stats))
|
||||
return -1;
|
||||
@@ -161,6 +166,16 @@ euidaccess (const char *path, int mode)
|
||||
if (mode == F_OK)
|
||||
return 0; /* The file exists. */
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Now we need the IDs. */
|
||||
if (have_ids == 0)
|
||||
{
|
||||
have_ids = 1;
|
||||
euid = __geteuid ();
|
||||
egid = __getegid ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The super-user can read and write any file, and execute any file
|
||||
that anyone can execute. */
|
||||
if (euid == 0 && ((mode & X_OK) == 0
|
||||
@@ -175,6 +190,40 @@ euidaccess (const char *path, int mode)
|
||||
granted = (stats.st_mode & mode);
|
||||
if (granted == mode)
|
||||
return 0;
|
||||
errno = EACCESS;
|
||||
__set_errno (EACCESS);
|
||||
return -1;
|
||||
}
|
||||
#undef euidaccess
|
||||
#ifdef weak_alias
|
||||
weak_alias (__euidaccess, euidaccess)
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include "error.h"
|
||||
|
||||
char *program_name;
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *file;
|
||||
int mode;
|
||||
int err;
|
||||
|
||||
program_name = argv[0];
|
||||
if (argc < 3)
|
||||
abort ();
|
||||
file = argv[1];
|
||||
mode = atoi (argv[2]);
|
||||
|
||||
err = euidaccess (file, mode);
|
||||
printf ("%d\n", err);
|
||||
if (err != 0)
|
||||
error (0, errno, "%s", file);
|
||||
exit (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#endif
|
||||
|
||||
#define EPOCH_YEAR 1970
|
||||
#define TM_YEAR_ORIGIN 1900
|
||||
#define TM_YEAR_BASE 1900
|
||||
|
||||
#define HOUR(x) ((x) * 60)
|
||||
|
||||
@@ -664,26 +664,32 @@ lookup_zone (struct parser_control const *pc, char const *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Yield A - B, measured in seconds. */
|
||||
#if ! HAVE_TM_GMTOFF
|
||||
/* Yield the difference between *A and *B,
|
||||
measured in seconds, ignoring leap seconds.
|
||||
The body of this function is taken directly from the GNU C Library;
|
||||
see src/strftime.c. */
|
||||
static int
|
||||
difftm (struct tm *a, struct tm *b)
|
||||
tm_diff (struct tm const *a, struct tm const *b)
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int days = (
|
||||
/* difference in day of year */
|
||||
a->tm_yday - b->tm_yday
|
||||
/* + intervening leap days */
|
||||
+ ((ay >> 2) - (by >> 2))
|
||||
- (ay / 100 - by / 100)
|
||||
+ ((ay / 100 >> 2) - (by / 100 >> 2))
|
||||
/* + difference in years * 365 */
|
||||
+ (int) (ay - by) * 365
|
||||
);
|
||||
/* Compute intervening leap days correctly even if year is negative.
|
||||
Take care to avoid int overflow in leap day calculations,
|
||||
but it's OK to assume that A and B are close to each other. */
|
||||
int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
|
||||
int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
|
||||
int a100 = a4 / 25 - (a4 % 25 < 0);
|
||||
int b100 = b4 / 25 - (b4 % 25 < 0);
|
||||
int a400 = a100 >> 2;
|
||||
int b400 = b100 >> 2;
|
||||
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
|
||||
int years = a->tm_year - b->tm_year;
|
||||
int days = (365 * years + intervening_leap_days
|
||||
+ (a->tm_yday - b->tm_yday));
|
||||
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
|
||||
+ (a->tm_min - b->tm_min))
|
||||
+ (a->tm_sec - b->tm_sec));
|
||||
}
|
||||
#endif /* ! HAVE_TM_GMTOFF */
|
||||
|
||||
static table const *
|
||||
lookup_word (struct parser_control const *pc, char *word)
|
||||
@@ -848,7 +854,7 @@ get_date (const char *p, const time_t *now)
|
||||
return -1;
|
||||
|
||||
pc.input = p;
|
||||
pc.year = tmp->tm_year + TM_YEAR_ORIGIN;
|
||||
pc.year = tmp->tm_year + TM_YEAR_BASE;
|
||||
pc.month = tmp->tm_mon + 1;
|
||||
pc.day = tmp->tm_mday;
|
||||
pc.hour = tmp->tm_hour;
|
||||
@@ -934,7 +940,7 @@ get_date (const char *p, const time_t *now)
|
||||
|| (pc.local_zones_seen && 1 < pc.local_isdst))
|
||||
return -1;
|
||||
|
||||
tm.tm_year = to_year (pc.year) - TM_YEAR_ORIGIN + pc.rel_year;
|
||||
tm.tm_year = to_year (pc.year) - TM_YEAR_BASE + pc.rel_year;
|
||||
tm.tm_mon = pc.month - 1 + pc.rel_month;
|
||||
tm.tm_mday = pc.day + pc.rel_day;
|
||||
if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
|
||||
@@ -981,7 +987,7 @@ get_date (const char *p, const time_t *now)
|
||||
if (pc.zones_seen)
|
||||
{
|
||||
tm = tm0;
|
||||
if (tm.tm_year <= EPOCH_YEAR - TM_YEAR_ORIGIN)
|
||||
if (tm.tm_year <= EPOCH_YEAR - TM_YEAR_BASE)
|
||||
{
|
||||
tm.tm_mday++;
|
||||
pc.time_zone += 24 * 60;
|
||||
@@ -1009,11 +1015,15 @@ get_date (const char *p, const time_t *now)
|
||||
|
||||
if (pc.zones_seen)
|
||||
{
|
||||
int delta;
|
||||
int delta = pc.time_zone * 60;
|
||||
#ifdef HAVE_TM_GMTOFF
|
||||
delta -= tm.tm_gmtoff;
|
||||
#else
|
||||
struct tm *gmt = gmtime (&Start);
|
||||
if (! gmt)
|
||||
return -1;
|
||||
delta = pc.time_zone * 60 + difftm (gmt, &tm);
|
||||
delta -= tm_diff (&tm, gmt);
|
||||
#endif
|
||||
if ((Start < Start - delta) != (delta < 0))
|
||||
return -1; /* time_t overflow */
|
||||
Start -= delta;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Case-insensitive buffer comparator.
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -15,9 +15,9 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Jim Meyering (meyering@na-net.ornl.gov) */
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -25,16 +25,16 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
# define IN_CTYPE_DOMAIN(Char) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
# define IN_CTYPE_DOMAIN(Char) isascii(Char)
|
||||
#endif
|
||||
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
|
||||
#define ISLOWER(Char) (IN_CTYPE_DOMAIN (Char) && islower (Char))
|
||||
|
||||
#if _LIBC || STDC_HEADERS
|
||||
# define TOUPPER(c) toupper (c)
|
||||
# define TOUPPER(Char) toupper (Char)
|
||||
#else
|
||||
# define TOUPPER(c) (ISLOWER (c) ? toupper (c) : (c))
|
||||
# define TOUPPER(Char) (ISLOWER (Char) ? toupper (Char) : (Char))
|
||||
#endif
|
||||
|
||||
#include "memcasecmp.h"
|
||||
@@ -44,14 +44,11 @@
|
||||
join -i works with sort -f. */
|
||||
|
||||
int
|
||||
memcasecmp (vs1, vs2, n)
|
||||
const void *vs1;
|
||||
const void *vs2;
|
||||
size_t n;
|
||||
memcasecmp (const void *vs1, const void *vs2, size_t n)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *s1 = (unsigned char *) vs1;
|
||||
unsigned char *s2 = (unsigned char *) vs2;
|
||||
unsigned char const *s1 = (unsigned char const *) vs1;
|
||||
unsigned char const *s2 = (unsigned char const *) vs2;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
unsigned char u1 = *s1++;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Provide a replacement for the POSIX nanosleep function.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -31,9 +31,7 @@ extern int errno;
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
/* FIXME: is including both like this kosher? */
|
||||
#include <sys/time.h>
|
||||
#include "nanosleep.h"
|
||||
|
||||
static int suspended;
|
||||
int first_call = 1;
|
||||
|
||||
57
lib/nanosleep.h
Normal file
57
lib/nanosleep.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (C) 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
|
||||
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 ! defined NANOSLEEP_H
|
||||
# define NANOSLEEP_H
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
# if ! HAVE_STRUCT_TIMESPEC
|
||||
/* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3. */
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
# endif
|
||||
|
||||
int
|
||||
nanosleep PARAMS ((const struct timespec *requested_delay,
|
||||
struct timespec *remaining_delay));
|
||||
|
||||
#endif
|
||||
19
lib/same.c
19
lib/same.c
@@ -1,3 +1,22 @@
|
||||
/* Determine whether two file names refer to the same file.
|
||||
Copyright (C) 1997-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
17
lib/same.h
17
lib/same.h
@@ -1,3 +1,20 @@
|
||||
/* Determine whether two file names refer to the same file.
|
||||
Copyright (C) 1997-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
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. */
|
||||
|
||||
#ifndef SAME_H_
|
||||
# define SAME_H_ 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* savedir.c -- save the list of files in a directory in a string
|
||||
Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -87,6 +87,10 @@ savedir (const char *dir, off_t name_size)
|
||||
if (dirp == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Be sure name_size is at least `1' so there's room for
|
||||
the final NUL byte. */
|
||||
name_size += !name_size;
|
||||
|
||||
name_space = (char *) malloc (name_size);
|
||||
if (name_space == NULL)
|
||||
{
|
||||
|
||||
528
lib/strftime.c
528
lib/strftime.c
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1994 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1994, 2000 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
@@ -16,15 +16,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
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Find the first ocurrence in S of any character in ACCEPT. */
|
||||
char *
|
||||
strpbrk (s, accept)
|
||||
register const char *s;
|
||||
register const char *accept;
|
||||
strpbrk (const char *s, const char *accept)
|
||||
{
|
||||
while (*s != '\0')
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/* Work around the bug in some systems whereby @xstat@ succeeds when
|
||||
given the zero-length file name argument. The @xstat@ from SunOS4.1.4
|
||||
has this bug.
|
||||
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xstrtod.c - error-checking interface to strtod
|
||||
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -32,6 +32,11 @@ double strtod ();
|
||||
#include <limits.h>
|
||||
#include "xstrtod.h"
|
||||
|
||||
/* Tell the compiler that non-default rounding modes are used. */
|
||||
#if 199901 <= __STDC_VERSION__
|
||||
#pragma STDC FENV_ACCESS ON
|
||||
#endif
|
||||
|
||||
/* An interface to strtod that encapsulates all the error checking
|
||||
one should usually perform. Like strtod, but upon successful
|
||||
conversion put the result in *RESULT and return zero. Return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1998-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
29
m4/ChangeLog
29
m4/ChangeLog
@@ -1,3 +1,32 @@
|
||||
2000-01-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* strerror_r.m4 (jm_FUNC_STRERROR_R): New file/macro.
|
||||
* jm-macros.m4 (jm_FUNC_STRERROR_R): Require it.
|
||||
|
||||
2000-01-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* d-type.m4 (jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Rename from
|
||||
jm_STRUCT_DIRENT_D_TYPE.
|
||||
* d-ino.m4: (jm_CHECK_TYPE_STRUCT_DIRENT_D_INO): Rename from
|
||||
jm_STRUCT_DIRENT_D_INO.
|
||||
* utimbuf.m4 (jm_CHECK_TYPE_STRUCT_UTIMBUF): Rename from
|
||||
jm_STRUCT_UTIMBUF.
|
||||
* jm-macros.m4: Reflect s/jm_STRUCT_/jm_CHECK_TYPE_STRUCT_/ renamings.
|
||||
* utime.m4: Likewise.
|
||||
|
||||
* timespec.m4 (jm_CHECK_TYPE_STRUCT_TIMESPEC): New file, macro.
|
||||
* jm-macros.m4 (jm_CHECK_TYPE_STRUCT_TIMESPEC): Require it.
|
||||
|
||||
2000-01-03 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* nanosleep.m4 (jm_FUNC_NANOSLEEP): Search for nanosleep in -lrt
|
||||
(for Solaris 7) and in -lposix4 (for Solaris 2.5.1).
|
||||
|
||||
2000-01-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* search-libs.m4: Escape `$' in $3 of dnl comment. I no longer
|
||||
remember if this is necessary.
|
||||
|
||||
1999-12-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Use it here.
|
||||
|
||||
@@ -47,7 +47,9 @@ search-libs.m4 \
|
||||
st_dm_mode.m4 \
|
||||
st_mtim.m4 \
|
||||
stat.m4 \
|
||||
strerror_r.m4 \
|
||||
strftime.m4 \
|
||||
timespec.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
uptime.m4 \
|
||||
|
||||
@@ -70,9 +70,10 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
DF_PROG = @DF_PROG@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
@@ -83,15 +84,24 @@ INSTOBJEXT = @INSTOBJEXT@
|
||||
INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
NEED_SETGID = @NEED_SETGID@
|
||||
OPTIONAL_BIN_PROGS = @OPTIONAL_BIN_PROGS@
|
||||
OPTIONAL_BIN_ZCRIPTS = @OPTIONAL_BIN_ZCRIPTS@
|
||||
PACKAGE = @PACKAGE@
|
||||
PERL = @PERL@
|
||||
POFILES = @POFILES@
|
||||
POSUB = @POSUB@
|
||||
POW_LIBM = @POW_LIBM@
|
||||
RANLIB = @RANLIB@
|
||||
SEQ_LIBM = @SEQ_LIBM@
|
||||
SQRT_LIBM = @SQRT_LIBM@
|
||||
U = @U@
|
||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
|
||||
USE_NLS = @USE_NLS@
|
||||
@@ -147,7 +157,9 @@ search-libs.m4 \
|
||||
st_dm_mode.m4 \
|
||||
st_mtim.m4 \
|
||||
stat.m4 \
|
||||
strerror_r.m4 \
|
||||
strftime.m4 \
|
||||
timespec.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
uptime.m4 \
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl Check whether struct dirent has a member named d_ino.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_STRUCT_DIRENT_D_INO,
|
||||
AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_INO,
|
||||
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
|
||||
AC_CACHE_CHECK([for d_ino member in directory struct],
|
||||
jm_cv_struct_dirent_d_ino,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
dnl Check whether struct dirent has a member named d_type.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_STRUCT_DIRENT_D_TYPE,
|
||||
AC_DEFUN(jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE,
|
||||
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
|
||||
AC_CACHE_CHECK([for d_type member in directory struct],
|
||||
jm_cv_struct_dirent_d_type,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 11
|
||||
#serial 12
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -19,9 +19,9 @@ AC_DEFUN(jm_MACROS,
|
||||
AC_REQUIRE([jm_BISON])
|
||||
AC_REQUIRE([jm_ASSERT])
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_TYPE])
|
||||
AC_REQUIRE([jm_STRUCT_DIRENT_D_INO])
|
||||
AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
|
||||
AC_REQUIRE([jm_CHECK_TYPE_STRUCT_DIRENT_D_INO])
|
||||
AC_REQUIRE([jm_CHECK_DECLS])
|
||||
|
||||
AC_REQUIRE([jm_PREREQ])
|
||||
@@ -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_STRERROR_R])
|
||||
AC_REQUIRE([jm_FUNC_NANOSLEEP])
|
||||
AC_REQUIRE([jm_FUNC_READDIR])
|
||||
AC_REQUIRE([jm_FUNC_MEMCMP])
|
||||
@@ -97,6 +98,7 @@ AC_DEFUN(jm_CHECK_ALL_TYPES,
|
||||
AC_HEADER_STAT
|
||||
AC_STRUCT_ST_MTIM_NSEC
|
||||
AC_STRUCT_ST_DM_MODE
|
||||
AC_REQUIRE([jm_CHECK_TYPE_STRUCT_TIMESPEC])
|
||||
|
||||
AC_TYPE_GETGROUPS
|
||||
AC_TYPE_MODE_T
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl FIXME
|
||||
dnl Check for the nanosleep function.
|
||||
dnl If not found, use the supplied replacement.
|
||||
dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_NANOSLEEP,
|
||||
[
|
||||
# Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
|
||||
# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
|
||||
AC_SEARCH_LIBS(nanosleep, [rt posix4])
|
||||
|
||||
AC_CACHE_CHECK([whether nanosleep works],
|
||||
jm_cv_func_nanosleep_works,
|
||||
[AC_TRY_RUN([
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl A replacement for autoconf's macro by the same name. This version
|
||||
dnl uses `ac_lib' rather than `i' for the loop variable, but more importantly
|
||||
dnl moves the ACTION-IF-FOUND ($3) into the inner `if'-block so that it is
|
||||
dnl moves the ACTION-IF-FOUND ([$]3) into the inner `if'-block so that it is
|
||||
dnl run only if one of the listed libraries ends up being used (and not in
|
||||
dnl the `none required' case.
|
||||
dnl I hope it's only temporary while we wait for that version to be fixed.
|
||||
|
||||
40
m4/strerror_r.m4
Normal file
40
m4/strerror_r.m4
Normal file
@@ -0,0 +1,40 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether the strerror_r implementation is one of
|
||||
dnl the broken ones that returns `int' rather than `char*'.
|
||||
dnl Actually, this tests only whether it returns a scalar
|
||||
dnl or an array, but that should be enough.
|
||||
dnl On at least DEC UNIX 4.0[A-D], strerror_r returns `int'.
|
||||
dnl This is used by lib/error.c.
|
||||
|
||||
AC_DEFUN(jm_FUNC_STRERROR_R,
|
||||
[
|
||||
# Check strerror_r
|
||||
AC_CHECK_FUNCS([strerror_r])
|
||||
if test $ac_cv_func_strerror_r = yes; then
|
||||
AC_CHECK_HEADERS(string.h)
|
||||
AC_CACHE_CHECK([for working strerror_r],
|
||||
jm_cv_func_working_strerror_r,
|
||||
[
|
||||
AC_TRY_COMPILE(
|
||||
[
|
||||
# include <stdio.h>
|
||||
# if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# endif
|
||||
],
|
||||
[
|
||||
int buf; /* avoiding square brackets makes this easier */
|
||||
char x = *strerror_r (0, buf, sizeof buf);
|
||||
],
|
||||
jm_cv_func_working_strerror_r=yes,
|
||||
jm_cv_func_working_strerror_r=no
|
||||
)
|
||||
if test $jm_cv_func_working_strerror_r = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
|
||||
[Define to 1 if strerror_r returns a string.])
|
||||
fi
|
||||
])
|
||||
fi
|
||||
])
|
||||
23
m4/timespec.m4
Normal file
23
m4/timespec.m4
Normal file
@@ -0,0 +1,23 @@
|
||||
#serial 1
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared in time.h.
|
||||
|
||||
AC_DEFUN(jm_CHECK_TYPE_STRUCT_TIMESPEC,
|
||||
[
|
||||
AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
|
||||
[AC_TRY_COMPILE(
|
||||
[
|
||||
#include <time.h>
|
||||
],
|
||||
[static struct timespec x; x.tv_sec = x.tv_nsec;],
|
||||
fu_cv_sys_struct_timespec=yes,
|
||||
fu_cv_sys_struct_timespec=no)
|
||||
])
|
||||
|
||||
if test $fu_cv_sys_struct_timespec = yes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
|
||||
[Define if struct timespec is declared in <time.h>. ])
|
||||
fi
|
||||
])
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
@@ -6,7 +6,7 @@ dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared --
|
||||
dnl usually in <utime.h>.
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
|
||||
AC_DEFUN(jm_STRUCT_UTIMBUF,
|
||||
AC_DEFUN(jm_CHECK_TYPE_STRUCT_UTIMBUF,
|
||||
[
|
||||
AC_CHECK_HEADERS(utime.h)
|
||||
AC_REQUIRE([AC_HEADER_TIME])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering
|
||||
dnl Replace the utime function on systems that need it.
|
||||
@@ -8,7 +8,7 @@ dnl FIXME
|
||||
AC_DEFUN(jm_FUNC_UTIME,
|
||||
[
|
||||
AC_CHECK_HEADERS(utime.h)
|
||||
AC_REQUIRE([jm_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([jm_CHECK_TYPE_STRUCT_UTIMBUF])
|
||||
AC_REQUIRE([AC_FUNC_UTIME_NULL])
|
||||
|
||||
if test $ac_cv_func_utime_null = no; then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/sw/tools/bin/perl -w
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright © 1997, 98, 99 Free Software Foundation, Inc.
|
||||
@@ -27,7 +27,7 @@ use Text::Tabs qw(expand);
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.019';
|
||||
my $this_version = '1.020';
|
||||
my $version_info = <<EOT;
|
||||
$this_program $this_version
|
||||
|
||||
@@ -239,7 +239,8 @@ if ($help_text =~ s/^Usage:( +(\S+))(.*)((?:\n(?: {6}\1| *or: +\S).*)*)//m)
|
||||
for (@syn)
|
||||
{
|
||||
$synopsis .= ".br\n" if $synopsis;
|
||||
s/(\S+) *//;
|
||||
s!^\S*/!!;
|
||||
s/^(\S+) *//;
|
||||
$synopsis .= ".B $1\n";
|
||||
s/\s+$//;
|
||||
s/(([][]|\.\.+)+)/\\fR$1\\fI/g;
|
||||
|
||||
@@ -1,3 +1,69 @@
|
||||
2000-01-10 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0o.
|
||||
|
||||
* lib/Makefile.am (noinst_HEADERS): Add nanosleep.h.
|
||||
|
||||
2000-01-09 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0n.
|
||||
|
||||
* src/ln.c (do_link): Produce the same sort of one-line output for
|
||||
`--backup --verbose' as cp, mv, install. Before this, the backup
|
||||
file name wasn't printed at all.
|
||||
|
||||
This affects cp, install, and mv.
|
||||
* src/copy.c (copy_internal): When making backup files in verbose
|
||||
mode, print the backup file name on the same line as the rest of the
|
||||
information, e.g., `a -> b (backup: b.~13~)' rather than on a separate
|
||||
line by itself. Suggestion from Karl Berry.
|
||||
|
||||
2000-01-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/error.c (error): Use __strerror_r's return value only if
|
||||
HAVE_WORKING_STRERROR_R.
|
||||
(error_at_line): Likewise.
|
||||
|
||||
* Makefile.maint (null_AM_MAKEFLAGS): Define.
|
||||
(my-distcheck): Use it to avoid distributing out of date files
|
||||
whose derivation would require a maintainer tool.
|
||||
|
||||
2000-01-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/euidaccess.c: Sync with the GNU C library.
|
||||
|
||||
* tests/dir/Makefile.am: (TESTS_ENVIRONMENT): Add `pwd`/ prefix
|
||||
to exported PATH value (though not strictly necessary, here).
|
||||
* tests/dd/Makefile.am: Likewise.
|
||||
* tests/dircolors/Makefile.am: Likewise.
|
||||
* tests/rm/Makefile.am: Likewise.
|
||||
* tests/rmdir/Makefile.am: Likewise.
|
||||
* tests/shred/Makefile.am: Likewise.
|
||||
* tests/touch/Makefile.am: Likewise.
|
||||
* tests/shred/Makefile.am: Likewise.
|
||||
|
||||
2000-01-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* man/help2man: Import version 1.020.
|
||||
|
||||
* lib/strftime.c: Sync with the GNU C Library.
|
||||
|
||||
2000-01-06 Paul Eggert <eggert@set.twinsun.com>
|
||||
|
||||
* tar/lib/getdate.y: Sync tm_diff with the GNU C Library.
|
||||
(TM_YEAR_BASE): Renamed from TM_YEAR_ORIGIN. All uses changed.
|
||||
(tm_diff): Renamed from difftm. All uses changed.
|
||||
Replace body with that taken from GNU C Library 2.1.3pre1.
|
||||
(get_date): Prefer tm_gmtoff to tm_diff if available.
|
||||
|
||||
2000-01-04 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* savedir.c (savedir): Don't store past the end of an array if
|
||||
name_size is zero and the directory is empty.
|
||||
|
||||
* Makefile.maint (PREV_VERSION): Tweak so it handles e.g., 2.0a -> 2.0.
|
||||
(alpha): Create xdelta diffs.
|
||||
|
||||
2000-01-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.0m.
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
Changes in release 4.1:
|
||||
[4.0o]
|
||||
* Include lib/nanosleep.h.
|
||||
[4.0n]
|
||||
* cp, install, ln, and mv: when making backup files in verbose mode, these
|
||||
commands now print the backup file name on the same line as the rest of the
|
||||
information, e.g., `a -> b (backup: b.~13~)' rather than on a separate line
|
||||
as all but ln used to do. ln didn't output the backup file name at all.
|
||||
[4.0m]
|
||||
* mv accepts new option: --strip-trailing-slashes (soon, many other
|
||||
programs will, too)
|
||||
|
||||
@@ -1,3 +1,80 @@
|
||||
2000-01-10 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0d.
|
||||
|
||||
* src/Makefile.am (sleep_LDADD): Add @POW_LIBM@, for systems that use
|
||||
lib/strtod.c and need -lm to resolve its pow reference.
|
||||
|
||||
2000-01-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 2.0c.
|
||||
|
||||
* tests/basename/Makefile.am (TESTS_ENVIRONMENT): Add `pwd`/ prefix
|
||||
to exported PATH value (though not strictly necessary, here).
|
||||
* tests/factor/Makefile.am (TESTS_ENVIRONMENT): Likewise.
|
||||
* tests/seq/Makefile.am (TESTS_ENVIRONMENT): Likewise.
|
||||
* tests/stty/Makefile.am (TESTS_ENVIRONMENT): Likewise.
|
||||
|
||||
2000-01-06 Paul Eggert <eggert@set.twinsun.com>
|
||||
|
||||
* tar/lib/getdate.y: Sync tm_diff with the GNU C Library.
|
||||
(TM_YEAR_BASE): Renamed from TM_YEAR_ORIGIN. All uses changed.
|
||||
(tm_diff): Renamed from difftm. All uses changed.
|
||||
Replace body with that taken from GNU C Library 2.1.3pre1.
|
||||
(get_date): Prefer tm_gmtoff to tm_diff if available.
|
||||
|
||||
2000-01-05 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Minor code cleanup.
|
||||
* src/sleep.c (clock_get_realtime): Return argument, for convenience.
|
||||
(main): Use this to simplify main sleep loop.
|
||||
|
||||
2000-01-05 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
Some systems lack a definition of struct timespec (AIX, Ultrix)
|
||||
Reported by Christian Krackowizer.
|
||||
* lib/Makefile.am (noinst_HEADERS): Add nanosleep.h.
|
||||
* lib/nanosleep.h: New file.
|
||||
* lib/nanosleep.c: Include it.
|
||||
Don't include time.h or sys/time.h here.
|
||||
* src/sleep.c: Include it.
|
||||
(AUTHORS): Add Paul Eggert.
|
||||
|
||||
2000-01-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/nanosleep.c: Include both time.h and sys/time.h only
|
||||
#if TIME_WITH_SYS_TIME.
|
||||
|
||||
2000-01-03 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Fix some porting and rounding problems with the new `sleep' code.
|
||||
|
||||
* configure.in (AC_CHECK_HEADERS): Add fenv.h.
|
||||
(FESETROUND_LIBM): New macro.
|
||||
|
||||
* lib/xstrtod.c: Add #pragma STDC FENV_ACCESS ON if C99.
|
||||
* src/sleep.c: Likewise.
|
||||
|
||||
* src/Makefile.am (sleep_LDADD, sleep_DEPENDENCIES): New macros.
|
||||
|
||||
* src/sleep.c (<fenv.h>): Include if available.
|
||||
(main): Always round floating-point interval calculations upwards,
|
||||
as we must sleep for at least the specified time.
|
||||
Do the right thing with NaNs.
|
||||
|
||||
(main): Sleep forever if the time calculations overflow.
|
||||
(apply_suffix): Don't assert that *s <= TIME_T_MAX.
|
||||
|
||||
(clock_get_realtime): Fix typo; address was improperly taken.
|
||||
|
||||
2000-01-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 2.0b.
|
||||
|
||||
* lib/Makefile.in: Regenerate.
|
||||
|
||||
* Version 2.0a.
|
||||
|
||||
1999-12-26 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/nanosleep.c (nanosleep): New file.
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
Changes in release 2.1
|
||||
[2.0d]
|
||||
* fix portability problem with sleep vs lib/strtod.c's requirement for -lm
|
||||
[2.0c]
|
||||
* fix portability problems with nanosleep.c and with the new code in sleep.c
|
||||
[2.0b]
|
||||
* Regenerate lib/Makefile.in so that nanosleep.c is distributed.
|
||||
[2.0a]
|
||||
* sleep accepts floating point arguments on command line
|
||||
* sleep continues sleeping after being suspended and continued
|
||||
* sleep's clock continues counting down when sleep is suspended
|
||||
* when a suspended sleep process is resumed, it continues sleeping if
|
||||
there is any time remaining
|
||||
* 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,3 +1,43 @@
|
||||
2000-01-10 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0c.
|
||||
|
||||
* Makefile.maint (announcement): Include URLs for xdelta files.
|
||||
(alpha): Use scp, not ncftp.
|
||||
|
||||
* lib/Makefile.am (noinst_HEADERS): Add nanosleep.h.
|
||||
|
||||
2000-01-08 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 2.0b.
|
||||
|
||||
More nits.
|
||||
* src/cut.c (OUTPUT_DELIMITER_OPTION): Define this and use it
|
||||
instead of `CHAR_MAX + n'.
|
||||
* src/pr.c (PAGES_OPTION, COLUMNS_OPTION): Likewise.
|
||||
|
||||
2000-01-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/tsort/Makefile.am (TESTS_ENVIRONMENT): Add `pwd`/ prefix
|
||||
to exported PATH value (though not strictly necessary, here).
|
||||
* tests/md5sum/Makefile.am: Likewise.
|
||||
|
||||
Nits.
|
||||
* lib/memcasecmp.c: Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'.
|
||||
Capitalize all macro parameters.
|
||||
(memcasecmp): Ansideclify.
|
||||
Don't cast away `const'ness of parameters.
|
||||
* lib/strpbrk.c (strpbrk): Ansideclify.
|
||||
Use `#if' instead of `#ifdef' for `HAVE_CONFIG_H'.
|
||||
Suggestions from François Pinard.
|
||||
|
||||
2000-01-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/tail-2/assert: Tell the user just before sleeping for 7 seconds.
|
||||
|
||||
* tests/tail-2/Makefile.am (TESTS): Remove fflush test. It didn't
|
||||
test the losing behavior, and left a stray tail process to boot.
|
||||
|
||||
2000-01-01 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 2.0a.
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
Changes in release 2.1
|
||||
[2.0c]
|
||||
* include lib/nanosleep.h.
|
||||
[2.0b]
|
||||
* portability tweaks for error.c vs. systems with deficient strerror_r
|
||||
[2.0a]
|
||||
* `tail --follow=name' no longer gets a failed assertion for a
|
||||
dev,inode-reusing race condition
|
||||
|
||||
18
src/copy.c
18
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 1995-2000 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
|
||||
@@ -370,6 +370,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
int src_type;
|
||||
char *earlier_file;
|
||||
char *dst_backup = NULL;
|
||||
int backup_succeeded = 0;
|
||||
int fix_mode = 0;
|
||||
int rename_errno;
|
||||
|
||||
@@ -546,13 +547,13 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
dst_backup = NULL;
|
||||
{
|
||||
dst_backup = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rename succeeded */
|
||||
if (x->verbose)
|
||||
printf (_("%s -> %s (backup)\n"), dst_path, dst_backup);
|
||||
backup_succeeded = 1;
|
||||
}
|
||||
new_dst = 1;
|
||||
}
|
||||
@@ -594,7 +595,12 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
directory. So --verbose should not announce anything until we're
|
||||
sure we'll create a directory. */
|
||||
if (x->verbose && !S_ISDIR (src_type))
|
||||
printf ("%s -> %s\n", src_path, dst_path);
|
||||
{
|
||||
printf ("%s -> %s", src_path, dst_path);
|
||||
if (backup_succeeded)
|
||||
printf (_(" (backup: %s)"), dst_backup);
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
/* Did we copy this inode somewhere else (in this command line argument)
|
||||
and therefore this is a second hard link to the inode? */
|
||||
|
||||
11
src/cut.c
11
src/cut.c
@@ -171,6 +171,13 @@ static char *output_delimiter_string;
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
static int have_read_stdin;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
OUTPUT_DELIMITER_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", required_argument, 0, 'b'},
|
||||
@@ -178,7 +185,7 @@ static struct option const longopts[] =
|
||||
{"fields", required_argument, 0, 'f'},
|
||||
{"delimiter", required_argument, 0, 'd'},
|
||||
{"only-delimited", no_argument, 0, 's'},
|
||||
{"output-delimiter", required_argument, 0, CHAR_MAX + 1},
|
||||
{"output-delimiter", required_argument, 0, OUTPUT_DELIMITER_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0}
|
||||
@@ -736,7 +743,7 @@ main (int argc, char **argv)
|
||||
delim_specified = 1;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1:
|
||||
case OUTPUT_DELIMITER_OPTION:
|
||||
/* Interpret --output-delimiter='' to mean
|
||||
`use the NUL byte as the delimiter.' */
|
||||
output_delimiter_length = (optarg[0] == '\0'
|
||||
|
||||
14
src/ln.c
14
src/ln.c
@@ -1,5 +1,5 @@
|
||||
/* `ln' program to create links between 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
|
||||
@@ -151,6 +151,7 @@ do_link (const char *source, const char *dest)
|
||||
struct stat dest_stats;
|
||||
char *dest_backup = NULL;
|
||||
int lstat_status;
|
||||
int backup_succeeded = 0;
|
||||
|
||||
/* Use stat here instead of lstat.
|
||||
On SVR4, link does not follow symlinks, so this check disallows
|
||||
@@ -276,6 +277,10 @@ do_link (const char *source, const char *dest)
|
||||
else
|
||||
dest_backup = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
backup_succeeded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to unlink DEST even if we may have renamed it. In some unusual
|
||||
@@ -295,7 +300,12 @@ do_link (const char *source, const char *dest)
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf (_("create %s %s to %s\n"), link_type_string, dest, source);
|
||||
{
|
||||
printf (_("create %s %s to %s"), link_type_string, dest, source);
|
||||
if (backup_succeeded)
|
||||
printf (_(" (backup: %s)"), dest_backup);
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
if ((*linkfunc) (source, dest) == 0)
|
||||
{
|
||||
|
||||
18
src/pr.c
18
src/pr.c
@@ -1,5 +1,5 @@
|
||||
/* pr -- convert text files for printing.
|
||||
Copyright (C) 88, 91, 1995-1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 88, 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
|
||||
@@ -725,11 +725,19 @@ static int last_line = FALSE;
|
||||
-h HEADER using pr test-suite */
|
||||
static int test_suite;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
PAGES_OPTION = CHAR_MAX + 1,
|
||||
COLUMNS_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"test", no_argument, &test_suite, 1},
|
||||
{"pages", required_argument, NULL, CHAR_MAX + 1},
|
||||
{"columns", required_argument, NULL, CHAR_MAX + 2},
|
||||
{"pages", required_argument, NULL, PAGES_OPTION},
|
||||
{"columns", required_argument, NULL, COLUMNS_OPTION},
|
||||
{"across", no_argument, NULL, 'a'},
|
||||
{"show-control-chars", no_argument, NULL, 'c'},
|
||||
{"double-space", no_argument, NULL, 'd'},
|
||||
@@ -901,7 +909,7 @@ main (int argc, char **argv)
|
||||
case 0: /* getopt long option */
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 1: /* --pages=FIRST_PAGE[:LAST_PAGE] */
|
||||
case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */
|
||||
{ /* dominates old opt +... */
|
||||
if (optarg)
|
||||
first_last_page (optarg);
|
||||
@@ -911,7 +919,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAR_MAX + 2: /* --columns=COLUMN */
|
||||
case COLUMNS_OPTION: /* --columns=COLUMN */
|
||||
{
|
||||
long int tmp_long;
|
||||
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|
||||
|
||||
112
src/sleep.c
112
src/sleep.c
@@ -1,5 +1,5 @@
|
||||
/* sleep - delay for a specified amount of time.
|
||||
Copyright (C) 84, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 84, 1991-1997, 1999-2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -34,12 +34,22 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "nanosleep.h"
|
||||
#include "xstrtod.h"
|
||||
|
||||
#if HAVE_FENV_H
|
||||
# include <fenv.h>
|
||||
#endif
|
||||
|
||||
/* Tell the compiler that non-default rounding modes are used. */
|
||||
#if 199901 <= __STDC_VERSION__
|
||||
#pragma STDC FENV_ACCESS ON
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "sleep"
|
||||
|
||||
#define AUTHORS "Jim Meyering"
|
||||
#define AUTHORS "Jim Meyering and Paul Eggert"
|
||||
|
||||
/* The name by which this program was run. */
|
||||
char *program_name;
|
||||
@@ -60,9 +70,10 @@ usage (int status)
|
||||
printf (_("\
|
||||
Usage: %s NUMBER[SUFFIX]...\n\
|
||||
or: %s OPTION\n\
|
||||
Pause for NUMBER seconds.\n\
|
||||
SUFFIX may be s for seconds (the default), m for minutes,\n\
|
||||
h for hours or d for days.\n\
|
||||
Pause for NUMBER seconds. SUFFIX may be `s' for seconds (the default),\n\
|
||||
`m' for minutes, `h' for hours or `d' for days. Unlike most implementations\n\
|
||||
that require NUMBER be an integer, here NUMBER may be an arbitrary floating\n\
|
||||
point number.\n\
|
||||
\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
@@ -73,15 +84,17 @@ h for hours or d for days.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* FIXME: describe */
|
||||
/* Given a floating point value *X, and a suffix character, SUFFIX_CHAR,
|
||||
scale *X by the multiplier implied by SUFFIX_CHAR. SUFFIX_CHAR may
|
||||
be the NUL byte or `s' to denote seconds, `m' for minutes, `h' for
|
||||
hours, or `d' for days. If SUFFIX_CHAR is invalid, don't modify *X
|
||||
and return nonzero. Otherwise return zero. */
|
||||
|
||||
static int
|
||||
apply_suffix (double *s, char suffix_char)
|
||||
apply_suffix (double *x, char suffix_char)
|
||||
{
|
||||
unsigned int multiplier;
|
||||
|
||||
assert (*s <= TIME_T_MAX);
|
||||
|
||||
switch (suffix_char)
|
||||
{
|
||||
case 0:
|
||||
@@ -104,7 +117,7 @@ apply_suffix (double *s, char suffix_char)
|
||||
if (multiplier == 0)
|
||||
return 1;
|
||||
|
||||
*s *= multiplier;
|
||||
*x *= multiplier;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -142,12 +155,12 @@ timespec_subtract (struct timespec *diff,
|
||||
return y->tv_sec < x->tv_sec;
|
||||
}
|
||||
|
||||
static void
|
||||
static struct timespec *
|
||||
clock_get_realtime (struct timespec *ts)
|
||||
{
|
||||
int fail;
|
||||
#if USE_CLOCK_GETTIME
|
||||
fail = clock_gettime (CLOCK_REALTIME, &ts);
|
||||
fail = clock_gettime (CLOCK_REALTIME, ts);
|
||||
#else
|
||||
struct timeval tv;
|
||||
fail = gettimeofday (&tv, NULL);
|
||||
@@ -160,6 +173,8 @@ clock_get_realtime (struct timespec *ts)
|
||||
|
||||
if (fail)
|
||||
error (1, errno, _("cannot read realtime clock"));
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -167,8 +182,10 @@ main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
double seconds = 0.0;
|
||||
double ns;
|
||||
int c;
|
||||
int fail = 0;
|
||||
int forever;
|
||||
struct timespec ts_start;
|
||||
struct timespec ts_stop;
|
||||
struct timespec ts_sleep;
|
||||
@@ -202,38 +219,56 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
#ifdef FE_UPWARD
|
||||
/* Always round up, since we must sleep for at least the specified
|
||||
interval. */
|
||||
fesetround (FE_UPWARD);
|
||||
#endif
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
double s;
|
||||
const char *p;
|
||||
if (xstrtod (argv[i], &p, &s)
|
||||
/* No negative intervals. */
|
||||
|| s < 0
|
||||
/* S must fit in a time_t. */
|
||||
|| TIME_T_MAX < s
|
||||
/* Nonnegative interval. */
|
||||
|| ! (0 <= 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. */
|
||||
|| TIME_T_MAX < (seconds += s)
|
||||
)
|
||||
|| apply_suffix (&s, *p))
|
||||
{
|
||||
error (0, 0, _("invalid time interval `%s'"), argv[i]);
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
seconds += s;
|
||||
}
|
||||
|
||||
if (fail)
|
||||
usage (1);
|
||||
|
||||
/* 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. */
|
||||
/* Separate whole seconds from nanoseconds.
|
||||
Be careful to detect any overflow. */
|
||||
ts_sleep.tv_sec = seconds;
|
||||
ts_sleep.tv_nsec = (seconds - ts_sleep.tv_sec) * 1000000000;
|
||||
ns = 1e9 * (seconds - ts_sleep.tv_sec);
|
||||
forever = ! (ts_sleep.tv_sec <= seconds && 0 <= ns && ns <= 1e9);
|
||||
ts_sleep.tv_nsec = ns;
|
||||
|
||||
/* Round up to the next whole number, if necessary, so that we
|
||||
always sleep for at least the requested amount of time. */
|
||||
ts_sleep.tv_nsec += (ts_sleep.tv_nsec < ns);
|
||||
|
||||
/* Normalize the interval length. nanosleep requires this. */
|
||||
if (1000000000 <= ts_sleep.tv_nsec)
|
||||
{
|
||||
time_t t = ts_sleep.tv_sec + 1;
|
||||
|
||||
/* Detect integer overflow. */
|
||||
forever |= (t < ts_sleep.tv_sec);
|
||||
|
||||
ts_sleep.tv_sec = t;
|
||||
ts_sleep.tv_nsec -= 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;
|
||||
@@ -243,19 +278,22 @@ main (int argc, char **argv)
|
||||
ts_stop.tv_nsec -= 1000000000;
|
||||
}
|
||||
|
||||
while (1)
|
||||
/* Detect integer overflow. */
|
||||
forever |= (ts_stop.tv_sec < ts_start.tv_sec
|
||||
|| (ts_stop.tv_sec == ts_start.tv_sec
|
||||
&& ts_stop.tv_nsec < ts_start.tv_nsec));
|
||||
|
||||
if (forever)
|
||||
{
|
||||
struct timespec remaining;
|
||||
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;
|
||||
/* Fix ts_sleep and ts_stop, which may be garbage due to overflow. */
|
||||
ts_sleep.tv_sec = ts_stop.tv_sec = TIME_T_MAX;
|
||||
ts_sleep.tv_nsec = ts_stop.tv_nsec = 999999999;
|
||||
}
|
||||
|
||||
while (nanosleep (&ts_sleep, NULL) != 0
|
||||
&& timespec_subtract (&ts_sleep, &ts_stop,
|
||||
clock_get_realtime (&ts_start)))
|
||||
continue;
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=basename
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
@@ -118,7 +119,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=basename
|
||||
|
||||
subdir = tests/basename
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
|
||||
@@ -6,7 +6,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=ls
|
||||
|
||||
TESTS = misc
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=ls
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=dircolors
|
||||
|
||||
TESTS = simple
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=dircolors
|
||||
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=factor
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
@@ -118,7 +119,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=factor
|
||||
|
||||
subdir = tests/factor
|
||||
|
||||
@@ -6,7 +6,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=ls
|
||||
|
||||
TESTS = tests
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=ls
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=md5sum
|
||||
|
||||
TESTS = basic-1 newline-1
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=md5sum
|
||||
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=rm
|
||||
|
||||
@@ -111,7 +111,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=rm
|
||||
|
||||
subdir = tests/rm
|
||||
|
||||
@@ -7,5 +7,5 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=rmdir
|
||||
|
||||
@@ -109,7 +109,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=rmdir
|
||||
|
||||
subdir = tests/rmdir
|
||||
|
||||
@@ -7,5 +7,5 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=seq
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
@@ -118,7 +119,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=seq
|
||||
|
||||
subdir = tests/seq
|
||||
|
||||
@@ -6,6 +6,6 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
TESTS = remove
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
|
||||
TESTS = remove
|
||||
|
||||
@@ -3,4 +3,4 @@ AUTOMAKE_OPTIONS = 1.2f gnits
|
||||
|
||||
TESTS = row-col-1 basic-1
|
||||
EXTRA_DIST = $(TESTS) input-tty
|
||||
TESTS_ENVIRONMENT = PATH=../../src:$$PATH
|
||||
TESTS_ENVIRONMENT = PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
@@ -114,7 +115,7 @@ AUTOMAKE_OPTIONS = 1.2f gnits
|
||||
|
||||
TESTS = row-col-1 basic-1
|
||||
EXTRA_DIST = $(TESTS) input-tty
|
||||
TESTS_ENVIRONMENT = PATH=../../src:$$PATH
|
||||
TESTS_ENVIRONMENT = PATH=`pwd`/../../src:$$PATH
|
||||
subdir = tests/stty
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
|
||||
@@ -9,4 +9,4 @@ TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=tail
|
||||
|
||||
TESTS = assert fflush
|
||||
TESTS = assert
|
||||
|
||||
@@ -111,7 +111,7 @@ TESTS_ENVIRONMENT = \
|
||||
PROG=tail
|
||||
|
||||
|
||||
TESTS = assert fflush
|
||||
TESTS = assert
|
||||
subdir = tests/tail-2
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
|
||||
@@ -31,7 +31,7 @@ tail_pid=$!
|
||||
# Arrange for the tail process to die after 12 seconds.
|
||||
(sleep 12; kill $tail_pid) &
|
||||
rm -f foo
|
||||
# echo sleep 7...
|
||||
echo sleeping for 7 seconds...
|
||||
sleep 7
|
||||
echo $ok > f
|
||||
mv f foo
|
||||
|
||||
@@ -70,6 +70,7 @@ CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETCONF = @GETCONF@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
|
||||
@@ -4,4 +4,4 @@ AUTOMAKE_OPTIONS = 1.3 gnits
|
||||
TESTS = empty-file dir-1 dangling-symlink no-rights
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=../../src:$$PATH
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
@@ -106,7 +106,7 @@ AUTOMAKE_OPTIONS = 1.3 gnits
|
||||
TESTS = empty-file dir-1 dangling-symlink no-rights
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=../../src:$$PATH
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
subdir = tests/touch
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
||||
@@ -6,7 +6,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=tsort
|
||||
|
||||
TESTS = basic-1
|
||||
|
||||
@@ -107,7 +107,7 @@ TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir) \
|
||||
PERL="@PERL@" \
|
||||
PATH=../../src:$$PATH \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=tsort
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user