Compare commits

...

331 Commits

Author SHA1 Message Date
Jim Meyering
97c9216e92 . 1999-05-23 21:06:36 +00:00
Jim Meyering
f914ebb255 *** empty log message *** 1999-05-23 20:46:23 +00:00
Jim Meyering
3fed986eee *** empty log message *** 1999-05-23 20:45:34 +00:00
Jim Meyering
5cd334b32e . 1999-05-23 20:44:48 +00:00
Jim Meyering
a54b71f493 *** empty log message *** 1999-05-23 20:43:11 +00:00
Jim Meyering
08f55c4b7c Correct erroneous expected output from the `cp -f foo foo' tests. 1999-05-23 20:42:25 +00:00
Jim Meyering
994746ffe9 (libfu_a_SOURCES): Add same.c.
(noinst_HEADERS): Add same.h.
1999-05-23 20:40:59 +00:00
Jim Meyering
645015312e Remove today's earlier misguided attempts.
Add a single condition to the existing sameness test.
1999-05-23 20:37:16 +00:00
Jim Meyering
642d250781 Include same.h.
(copy_internal): Qualify SAME_INODE test with (link-count == 1
|| same_name(...)).
1999-05-23 19:45:33 +00:00
Jim Meyering
00fbb65ec1 *** empty log message *** 1999-05-23 19:43:10 +00:00
Jim Meyering
0e96b5d2e7 New file (function extracted from ln.c). 1999-05-23 19:42:59 +00:00
Jim Meyering
2a8c9424f0 (same_name): Remove function.
<same.h>: Include this instead.
<dirname.h>: No longer include this.
1999-05-23 19:41:19 +00:00
Jim Meyering
96074cef79 *** empty log message *** 1999-05-23 19:38:53 +00:00
Jim Meyering
27893412b2 white-space tweak 1999-05-23 19:27:36 +00:00
Jim Meyering
ff08632036 white-space tweak 1999-05-23 19:27:07 +00:00
Jim Meyering
0868b5794a (copy_internal): Make it so `mv -f FILE FILE' does not remove FILE.
Based on a patch from Chris Yeo.
1999-05-23 14:52:32 +00:00
Jim Meyering
46945ad760 *** empty log message *** 1999-05-23 14:49:14 +00:00
Jim Meyering
78d7d7b746 *** empty log message *** 1999-05-23 13:36:37 +00:00
Jim Meyering
77cf4d48dd (TESTS): Add force.
(TESTS_ENVIRONMENT): Change PATH to be absolute.
1999-05-23 13:36:14 +00:00
Jim Meyering
e7eeacebbc *** empty log message *** 1999-05-23 04:19:10 +00:00
Jim Meyering
dee24e9fac *** empty log message *** 1999-05-23 04:01:55 +00:00
Jim Meyering
65ffd691ee *** empty log message *** 1999-05-23 03:59:08 +00:00
Jim Meyering
80ef68e006 *** empty log message *** 1999-05-22 22:10:34 +00:00
Jim Meyering
b5b54d2fed *** empty log message *** 1999-05-22 22:02:54 +00:00
Jim Meyering
1f2dc06993 *** empty log message *** 1999-05-22 22:02:00 +00:00
Jim Meyering
2b477f5dc4 (AC_REPLACE_FUNCS): Add memchr. 1999-05-22 22:00:42 +00:00
Jim Meyering
39d0a166c5 *** empty log message *** 1999-05-22 16:56:40 +00:00
Jim Meyering
dae50ead45 *** empty log message *** 1999-05-22 12:53:07 +00:00
Jim Meyering
be6aea6fb9 Document locale-specific changes to `sort',
as well as the new, POSIX-compliant definition of line comparison,
and -g's more careful treatment of NaNs, infinities and zeros.
1999-05-22 12:52:41 +00:00
Jim Meyering
9e48e223db (general_numcompare): Put exceptional cases
first, not last, to be consistent with -M.
1999-05-22 12:52:14 +00:00
Jim Meyering
59b22bd058 *** empty log message *** 1999-05-22 04:30:36 +00:00
Jim Meyering
77d5a18a9b *** empty log message *** 1999-05-22 04:29:30 +00:00
Jim Meyering
4539e57b3c . 1999-05-22 04:24:10 +00:00
Jim Meyering
668807df85 . 1999-05-22 02:53:08 +00:00
Jim Meyering
b66bd5f56c *** empty log message *** 1999-05-22 02:48:22 +00:00
Jim Meyering
7bac5533d7 (strtod): Declare if STDC_HEADERS is not defined.
(general_numcompare): Use strtod, not xstrtod.
Do not consider partial conversions to be errors.
Put -infinity at the start, and +infinity at the end;
follow +infinity with NaNs (sorted by bit pattern),
and finally by conversion errors.
1999-05-22 02:47:45 +00:00
Jim Meyering
28c635adb2 (use-nl): New test from Paul Eggert. 1999-05-22 02:41:39 +00:00
Jim Meyering
125ce0f85c tweak comment 1999-05-22 02:37:47 +00:00
Jim Meyering
157c31573e (11d): Reverse lines in expected output to reflect latest change. 1999-05-22 02:37:10 +00:00
Jim Meyering
67fbe7e2a0 remove trailing newline 1999-05-21 20:47:18 +00:00
Jim Meyering
c734236a6f *** empty log message *** 1999-05-21 20:24:39 +00:00
Jim Meyering
d6261d35c9 Treat the trailing newline as part of the line, as required by POSIX.2.
(struct line, findlines, compare, checkfp, mergefps, sort):
A line now includes its trailing newline.
(findlines): Do not replace newline with NUL.
(memcoll, keycompare): Work even if the data to be compared are
adjacent strings; this is possible now that lines contain the
trailing newline.
(fillbuf): Always have an unused byte at the end of the	buffer,
since memcoll and keycompare want to modify a byte after the last line.
(sortalloc, mergealloc): Increase by 1, for trailing byte.
1999-05-21 20:24:19 +00:00
Jim Meyering
db0d476b12 *** empty log message *** 1999-05-21 19:53:05 +00:00
Jim Meyering
07add9a796 . 1999-05-20 20:12:17 +00:00
Jim Meyering
46e594f9bc [AC_SEARCH_LIBS]: Quote name in undefine.
Add a colon after each `then' in case $4 is empty.
1999-05-20 20:12:12 +00:00
Jim Meyering
6501594508 . 1999-05-20 20:10:17 +00:00
Jim Meyering
d60127857c . 1999-05-20 16:51:40 +00:00
Jim Meyering
0a4ebdb1d3 *** empty log message *** 1999-05-20 16:51:29 +00:00
Jim Meyering
559f32b40d Add test case from Paul Eggert. 1999-05-20 16:48:56 +00:00
Jim Meyering
bffbff4ff2 *** empty log message *** 1999-05-20 16:29:51 +00:00
Jim Meyering
d30365509d (keycompare): Ignore any length difference if the
localized comparison says the strings are equal.
1999-05-20 16:29:38 +00:00
Jim Meyering
9a27ea2eb2 (memcoll, keycompare, compare): Handle NUL
characters properly when comparing with LC_COLLATE semantics.
(NLS_MEMCMP): Remove.
(memcoll): Renamed from strncoll.
Take separate lengths for each string.
This function is now invoked only when need_locale.
(keycompare): Don't copy strings when ignore and translate
are both NULL.
1999-05-20 16:09:12 +00:00
Jim Meyering
61b2bceab7 (MONTHTAB_CONST): Renamed from NLS_CONST; the use
is also changed.  Define to const also if !HAVE_NL_LANGINFO.

(usage): `,' -> `;' (English typo).
1999-05-20 03:52:15 +00:00
Jim Meyering
0f5bb7dd4e add the comment to go with last change 1999-05-20 03:49:25 +00:00
Jim Meyering
a0766fb80f (get_date): Let mktime deduce tm_isdst if we
have an absolute timestamp, or if the relative timestamp
mentions days, months, or years.
1999-05-20 03:47:24 +00:00
Jim Meyering
867c8b0e85 . 1999-05-19 14:31:53 +00:00
Jim Meyering
98270d63fb (main): When stdout is in binary mode, make sure all
input files are also read in binary mode.
1999-05-18 14:13:33 +00:00
Jim Meyering
d9076a130e *** empty log message *** 1999-05-17 13:10:53 +00:00
Jim Meyering
8d5798a538 *** empty log message *** 1999-05-17 13:10:31 +00:00
Jim Meyering
1ee4fffc88 (human_readable): Allow from_block_size to be zero. 1999-05-17 13:03:46 +00:00
Jim Meyering
4fd5e02337 . 1999-05-16 19:13:59 +00:00
Jim Meyering
92462cca2a . 1999-05-16 19:11:16 +00:00
Jim Meyering
a162f70539 *** empty log message *** 1999-05-16 19:09:25 +00:00
Jim Meyering
cbdd9172f9 . 1999-05-16 16:54:01 +00:00
Jim Meyering
bc48b59612 *** empty log message *** 1999-05-16 16:53:02 +00:00
Jim Meyering
901dc5cba9 *** empty log message *** 1999-05-16 16:43:22 +00:00
Jim Meyering
108ff5810f Don't autodetect the locale of numbers and
months, as this conflicts with POSIX.2 and is tricky to boot.

(FLOATING_COMMA, NLS_STRNCMP, NLS_MAX_GROUPS,
NLS_ONE_CHARACTER_STRING): Remove macros no longer used.

(nls_grouping, nls_fraction_found, nls_month_found, nos_monthtab,
nls_months_collide, nls_keyhead, us_monthtab): Remove variables no
longer used.

(struct nls_keyfield): Remove types no longer used.

(strncoll_s2_readonly, nls_set_fraction, look_for_fraction,
nls_month_is_either_locale, nls_numeric_format): Remove functions no
longer used.

(monthtab): Now has the role that us_monthtab had, but it's const only
if ENABLE_NLS is not defined.

(C_DECIMAL_POINT): Renamed from FLOATING_POINT.  All uses changed.
(MONTHS_PER_YEAR): Renamed from NLS_NUM_MONTHS.  All uses changed.
(struct_month_cmp): Renamed from nls_sort_month_comp.  All uses changed.
Use strcmp, not strcoll, since the user doesn't care about collating
here.

(inittables): Read locale data into monthtab, rather than modifying a
separate month table and futzing with indirection.  Do not worry about
colliding months, since we no longer autodetect month locale.

(fraccompare): Don't set no-longer-used variable nls_fraction_found.

(getmonth): Use strncmp to compare months, since user doesn't care
about collating here.  Fix bug where code incorrectly assumed that
strlen (monthtab[lo].name) == strlen (monthtab[ix].name).

(keycompare, main): Don't autodetect month locale.

(compare): Don't use NLS_MEMCP in code that can't be executed if
need_locale is false, as NLS_MEMCP is equivalent to memcmp in that
case.

(sort, insertkey, main): Don't autodetect numeric locale.
1999-05-16 16:18:46 +00:00
Jim Meyering
4b11c1f734 *** empty log message *** 1999-05-16 15:50:56 +00:00
Jim Meyering
3cf365bf7e *** empty log message *** 1999-05-16 15:50:04 +00:00
Jim Meyering
f2a1097c92 . 1999-05-16 15:48:43 +00:00
Jim Meyering
3d2009b52d New file to override autoconf's AC_SEARCH_LIBS. 1999-05-16 15:48:11 +00:00
Jim Meyering
73a206d970 . 1999-05-15 06:13:00 +00:00
Jim Meyering
dad89f8b93 . 1999-05-15 05:46:45 +00:00
Jim Meyering
23d3bb9416 (usage): Whoops. 1999-05-15 05:46:12 +00:00
Jim Meyering
cd0c914437 *** empty log message *** 1999-05-15 05:42:55 +00:00
Jim Meyering
dace9c7477 . 1999-05-15 05:30:51 +00:00
Jim Meyering
1acf1ddd65 (trailing-sp): New test for this fix. 1999-05-15 05:28:51 +00:00
Jim Meyering
771bc6ea9d (xfields): Don't interpret a trailing blank as a
delimiter when e.g. -t: was specified.  From Tim Smithers.
1999-05-15 05:28:16 +00:00
Jim Meyering
634a39aad5 (getugroups): Don't dereference a null pointer when
running `id USER' for some USER that is listed on the RHS in /etc/group.
From Sander van Malssen.
Add some curly braces, use STREQ, reverse the sense of a test
and use `continue' to save a level of nesting.
1999-05-15 04:50:26 +00:00
Jim Meyering
7af9c3c085 *** empty log message *** 1999-05-15 04:11:13 +00:00
Jim Meyering
d8c0345769 *** empty log message *** 1999-05-15 04:08:29 +00:00
Jim Meyering
0a25564c1c (open_maybe_create): Handle Solaris' failure mode when
FILE is a directory.  Reported by Vin Shelton.
1999-05-15 04:06:51 +00:00
Jim Meyering
7565800a11 (main): When asking for info on an explicit file name,
just warn rather than failing if the table of mounted filesystems
cannot be read.
1999-05-15 01:53:21 +00:00
Jim Meyering
2d97b1c61b (version_etc): Put version info and author names
on the first two lines respectively rather than putting the three
lines of copyright info between them.
1999-05-14 17:11:03 +00:00
Jim Meyering
1fdc84d5a2 *** empty log message *** 1999-05-14 16:59:46 +00:00
Jim Meyering
c93ac403ed Include <string.h> or <strings.h> for strlen prototype. 1999-05-13 20:48:44 +00:00
Jim Meyering
4c9f46a4a1 [__GLIBC__ >= 2]: #if-out prototypes. 1999-05-13 20:44:45 +00:00
Jim Meyering
59d16049d8 (pop_dir): Cast length to `int' to avoid a warning on
64-bit systems.  From Ulrich Drepper.
1999-05-13 20:42:45 +00:00
Jim Meyering
5a83986f79 (main): Put `u' for -u in getopt_long's string argument.
Remove the `R'.
1999-05-12 16:50:54 +00:00
Jim Meyering
150ca569b5 *** empty log message *** 1999-05-12 16:01:29 +00:00
Jim Meyering
048a38dc54 Use `%%' place-holder that Makefile.am rule expects. 1999-05-12 15:54:52 +00:00
Jim Meyering
ece1dc4e51 (usage): Split the --help message into two pieces so that
neither is longer than 2048.  For Irix4's cc.  Reported by Kaveh Ghazi.
1999-05-12 14:58:30 +00:00
Jim Meyering
c1a461273d (usage): Split --help message into two pieces so that
Split the --help message into two pieces so that neither is longer
than 2048.  For Irix4's cc.  Reported by Kaveh Ghazi.
1999-05-12 02:13:45 +00:00
Jim Meyering
da36bbf417 *** empty log message *** 1999-05-12 02:10:38 +00:00
Jim Meyering
74e5374045 *** empty log message *** 1999-05-11 16:30:03 +00:00
Jim Meyering
f039432d03 Fix typos in config.h comments. 1999-05-11 16:29:56 +00:00
Jim Meyering
5af7e261fa Fix typos in config.h comments. 1999-05-11 16:29:33 +00:00
Jim Meyering
ce1d9075d7 *** empty log message *** 1999-05-10 17:25:27 +00:00
Jim Meyering
c23f5758dc (AUTHORS): Reflect reality: add Kaveh. 1999-05-10 15:12:24 +00:00
Jim Meyering
af735060cb Expand each `&' character in the gecos field.
(count_ampersands): New function.
(create_fullname): New function.
(print_entry): Use create_fullname here.
(print_long_entry): Use it here, too.
From Kaveh Ghazi.
1999-05-10 14:17:09 +00:00
Jim Meyering
0ff57399ed *** empty log message *** 1999-05-10 05:24:38 +00:00
Jim Meyering
447527eeb5 Reflect renaming: AM_FUNC_MKTIME -> AC_FUNC_MKTIME. 1999-05-10 05:18:30 +00:00
Jim Meyering
d845b9a5a3 Require 2.14.1, since we use newly-renamed AC_FUNC_MKTIME. 1999-05-10 05:17:38 +00:00
Jim Meyering
f1b3fb4f3b Update from libc. 1999-05-10 04:24:49 +00:00
Jim Meyering
94323ee2a7 uncomment final rm 1999-05-09 15:59:27 +00:00
Jim Meyering
c250ac3ddc *** empty log message *** 1999-05-09 15:56:27 +00:00
Jim Meyering
badacafb98 *** empty log message *** 1999-05-09 15:13:41 +00:00
Jim Meyering
d0672fcf74 *** empty log message *** 1999-05-09 15:13:09 +00:00
Jim Meyering
91e23a4607 *** empty log message *** 1999-05-09 15:11:52 +00:00
Jim Meyering
60d62033fb *** empty log message *** 1999-05-09 15:10:33 +00:00
Jim Meyering
d02a83cba4 *** empty log message *** 1999-05-09 15:10:10 +00:00
Jim Meyering
359c6f7e38 (alpha): Put the announcement in /tmp/announce-$(distdir) 1999-05-09 15:10:02 +00:00
Jim Meyering
1554d14ce1 . 1999-05-09 15:04:17 +00:00
Jim Meyering
11f093839f *** empty log message *** 1999-05-09 15:03:58 +00:00
Jim Meyering
d1520cea68 whoops -- revert last change 1999-05-09 15:03:52 +00:00
Jim Meyering
9cc8d1f6a9 (Makefile.in): Depend on Makefile.maint. 1999-05-09 15:02:44 +00:00
Jim Meyering
48d1df6825 . 1999-05-09 15:02:16 +00:00
Jim Meyering
3a7457ae6c . 1999-05-09 15:01:52 +00:00
Jim Meyering
fe76db396c (neg-nls): New test. 1999-05-09 15:01:40 +00:00
Jim Meyering
dd992130c6 (fraccompare, numcompare): Merge the NLS and
non-NLS versions into a single function.

(decimal_point): Now char, since we no longer convert to unsigned char.
(th_sep): Now int, since we use a value out of char range to denote
the absence of a thousands separator.
(IS_THOUSANDS_SEP): New macro.
(USE_NEW_FRAC_COMPARE): Remove.
(nls_set_fraction): Arg is now char, not unsigned char.
Set th_sep to CHAR_MAX + 1 if there is no thousands separator.
(numcompare): Don't convert to unsigned char unless necessary.
(main): Turn off decimal points and thousand separators if they
are multibyte characters, as we don't support that yet.
1999-05-09 03:27:24 +00:00
Jim Meyering
02d760e232 * src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
and all the *_MIN and *_MAX symbols): Remove definitions.
* src/sys2.h: Put the definitions here instead (this file is shared
between all three *utils packages, while system.h is not).
1999-05-08 23:29:47 +00:00
Jim Meyering
4905751e2f * src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
and all the *_MIN and *_MAX symbols): Remove definitions.
* src/sys2.h: Put the definitions here instead (this file is shared
between all three *utils packages, while system.h is not).
1999-05-08 23:28:42 +00:00
Jim Meyering
d103085de3 (handle_line_error): Use %s, not %d, now that human_readable
converts it to a string.
1999-05-07 19:15:37 +00:00
Jim Meyering
9bc1a80b4e *** empty log message *** 1999-05-07 19:00:44 +00:00
Jim Meyering
99ed77dea6 import latest 1999-05-07 18:54:34 +00:00
Jim Meyering
bda57be904 *** empty log message *** 1999-05-07 18:53:01 +00:00
Jim Meyering
07053344dc . 1999-05-07 18:52:35 +00:00
Jim Meyering
f31052628d *** empty log message *** 1999-05-07 18:49:09 +00:00
Jim Meyering
8e03e30c05 clean up 1999-05-07 18:48:45 +00:00
Jim Meyering
0ef3c5d7fc (TESTS_ENVIRONMENT): Remove individual
upper-case program names.  Add a definition of PATH.
(TESTS): Add dir-1.
1999-05-07 18:47:50 +00:00
Jim Meyering
a06a563ea4 (touch): Only do the fstat if we need to.
Resort to calling stat for directories, but only when necessary.
(usage): Mention --no-create.
1999-05-07 18:44:20 +00:00
Jim Meyering
9250d1a34f (main): Use better wording in diagnostic: `cannot
create directory' rather than `cannot make directory'.  The former
also matches the one in makepath.c.
1999-05-07 18:40:11 +00:00
Jim Meyering
a8d7df994f (apply_translations): Use TOUPPER, not toupper. 1999-05-07 18:36:54 +00:00
Jim Meyering
b10e58db1b (numcompare): Handle comparison of two negative
numbers correctly in the ENABLE_NLS case.
1999-05-06 21:51:06 +00:00
Jim Meyering
a440742330 (make_dir): When reporting a mkdir failure and the
target cannot be `stat'ed, use the errno from the failed mkdir call,
not the one from the stat call.  Before this change, running
`mkdir -p /no-dir/no-dir' as an unprivileged user would wrongly
elicit `No such file or directory' instead of `Permission denied'.
1999-05-06 02:10:34 +00:00
Jim Meyering
f466b6448a *** empty log message *** 1999-05-05 13:34:29 +00:00
Jim Meyering
9f8bc128f0 (read_utmp): Use the new definitions. 1999-05-05 13:34:18 +00:00
Jim Meyering
b0cc976ab9 Add definitions to help read utmpx on systems with utmpname.
(UTMP_NAME_FUNCTION): Define.
(SET_UTMP_ENT): Likewise.
(GET_UTMP_ENT): Likewise.
(END_UTMP_ENT): Likewise.
1999-05-05 13:34:02 +00:00
Jim Meyering
632b63d59c *** empty log message *** 1999-05-05 13:26:22 +00:00
Jim Meyering
1db78f41bf (show_date): Change an automatic aggregate initializer
to be a static one.  For SunOS4's cc.
1999-05-05 13:26:06 +00:00
Jim Meyering
7c48860ed8 *** empty log message *** 1999-05-05 13:21:55 +00:00
Jim Meyering
1b0901bb9e (TYPE_SIGNED, TYPE_MAXIMUM, TYPE_MINIMUM): Define.
(ULONG_LONG_MAX, LONG_LONG_MAX, LONG_LONG_MIN): Define if not defined.
Based on a patch from Kaveh Ghazi.
1999-05-05 13:21:29 +00:00
Jim Meyering
76a9b4dc10 *** empty log message *** 1999-05-05 13:16:42 +00:00
Jim Meyering
19d33cea2b (USE_ACL): Define this only #if
(HAVE_SYS_ACL_H && HAVE_ACL && defined GETACLCNT).
Use `USE_ACL' in place of `HAVE_ACL' everywhere else.  From Kaveh Ghazi.
1999-05-05 13:12:28 +00:00
Jim Meyering
c4ddb7f83a Include makepath.h libintl.h, not after it.
Otherwise, we'd get the wrong definition of PARAMS from libintl.h.
(The method of defining PARAMS in libintl.h doesn't check PROTOTYPES,
which is necessary on Irix4 since cc doesn't define __STDC__.)
From Kaveh Ghazi.
1999-05-05 03:05:11 +00:00
Jim Meyering
431db6c847 add missing backslash-before-newline in usage message 1999-05-05 01:56:45 +00:00
Jim Meyering
207d6b3cda add missing backslash-before-newline in usage message 1999-05-05 01:55:39 +00:00
Jim Meyering
bbefeb160b *** empty log message *** 1999-05-04 21:13:54 +00:00
Jim Meyering
89d0895332 (AC_LFS): -n32, -o32, and -n64 should be in CFLAGS,
not CPPFLAGS, so that linking works correctly in IRIX.
1999-05-04 21:13:47 +00:00
Jim Meyering
cb5153fefa (usage): Break the usage message into 3 pieces instead of
only 2.  The strings had grown to be longer than 2048, which evokes
errors when compiling with Irix4's cc.
1999-05-04 18:46:06 +00:00
Jim Meyering
b08eca15fd (search_item): Use 1' instead of +1'. The latter
elicits a syntax error from SunOS4's cc.  From Kaveh Ghazi.
1999-05-04 14:31:27 +00:00
Jim Meyering
6f922edf2d <ctype.h>: Don't include.
[!STDC_HEADERS]: Remove definitions of ctype macros.
Convert e.g., isspace to ISSPACE to use definitions from sys2.h.
Reported by Kaveh Ghazi.
1999-05-03 18:01:49 +00:00
Jim Meyering
85514c7e0b (TOLOWER): Define.
(TOUPPER): Define.
1999-05-03 17:59:43 +00:00
Jim Meyering
e060631c35 (TOLOWER): Remove definition. 1999-05-03 17:55:53 +00:00
Jim Meyering
cac31ff114 *** empty log message *** 1999-05-03 03:58:40 +00:00
Jim Meyering
f0e23dcff9 *** empty log message *** 1999-05-03 03:56:46 +00:00
Jim Meyering
b3faad27ed . 1999-05-03 02:46:54 +00:00
Jim Meyering
38121144b2 . 1999-05-03 02:45:51 +00:00
Jim Meyering
73bc7f0777 (main): Give a better diagnostic when we fail to set the hostname. 1999-05-03 02:45:37 +00:00
Jim Meyering
99571c629e (main): Manually handle `--', since we no longer call getopt. 1999-05-03 02:42:49 +00:00
Jim Meyering
4f40ac7422 (read_utmp): Ignore the return value from utmpname. 1999-05-03 02:38:50 +00:00
Jim Meyering
1610efe2fd Define several tag-related make variables.
(cvs-dist): Use the make variables instead of shell ones.
(announcement): Automatically generate diffs for all ChangeLog files,
not just the top level one.
1999-05-01 04:33:45 +00:00
Jim Meyering
1c70e83474 *** empty log message *** 1999-05-01 04:15:43 +00:00
Jim Meyering
9a06759937 *** empty log message *** 1999-05-01 04:15:09 +00:00
Jim Meyering
6161d60dde *** empty log message *** 1999-05-01 04:13:56 +00:00
Jim Meyering
e3cd439763 (AC_REPLACE_FUNCS): Add dup2. 1999-05-01 04:13:45 +00:00
Jim Meyering
5e1ffee4d6 (main): Manually handle `--', since we no longer
call getopt.  Reported by Joseph S. Myers.
1999-05-01 02:29:17 +00:00
Jim Meyering
910287474f (main): Manually handle `--', since we no longer
call getopt.  Reported by Joseph S. Myers.
1999-05-01 02:28:54 +00:00
Jim Meyering
6faa50c135 (decode_switches): Use STDIN_FILENO, STDOUT_FILENO instead of 0, 1. 1999-05-01 02:08:30 +00:00
Jim Meyering
9fca49f67c Always use STDIN_FILENO for input and STDOUT_FILENO
for output, to avoid confusion with closed input and output fds.
(input_fd, output_fd): Remove; all uses changed to STDIN_FILENO
and STDOUT_FILENO.
(open_fd): New function.
(main): Use it, instead of open, to ensure that file descriptors
don't get confused.

(skip): Don't fstat the input file; the result is no longer used.
1999-05-01 02:05:56 +00:00
Jim Meyering
8a3c0671e0 *** empty log message *** 1999-05-01 00:13:13 +00:00
Jim Meyering
2f7eb5cdf5 (usage): Document the differences between the
obsolescent, +POS1[-POS2] form, and the POSIX -k option.
1999-05-01 00:12:26 +00:00
Jim Meyering
8fb3745a09 add emphasis that sort's -k M,N is inclusive 1999-04-30 22:35:54 +00:00
Jim Meyering
aaba44e639 *** empty log message *** 1999-04-30 20:59:49 +00:00
Jim Meyering
1cd88b2b5e *** empty log message *** 1999-04-30 16:48:09 +00:00
Jim Meyering
60695039c0 *** empty log message *** 1999-04-30 16:03:53 +00:00
Jim Meyering
806520fdc0 Update to reflect this change by reversing
the order of arguments so the symlink is the source, not the
destination (otherwise, the mv command would now succeed).
1999-04-30 16:03:46 +00:00
Jim Meyering
25a8d1f1e9 (copy_internal): Move the one-file-system test so that
it follows the `if (new_dst || !S_ISDIR (dst_sb.st_mode))' block.
Prior to this change, `cp --one-file-system' would traverse a file-
system boundary if the destination directory existed.
From thospel@mail.dma.be.
1999-04-30 15:40:34 +00:00
Jim Meyering
f0e50d53d5 *** empty log message *** 1999-04-30 15:24:47 +00:00
Jim Meyering
40d99818ef (copy_internal): Don't make `mv foo symlink-to-foo' fail.
That is, even though source and destination are `the same,' don't fail
if the destination is a symlink.  From Peter Samuelson.
1999-04-30 15:15:02 +00:00
Jim Meyering
0d6a1583c6 *** empty log message *** 1999-04-26 15:07:44 +00:00
Jim Meyering
6f48de44ae *** empty log message *** 1999-04-26 13:31:57 +00:00
Jim Meyering
9622d45140 (main): If you can't open an output file (with seek=...) read-write,
then open it for write and report an error if we can't seek.
1999-04-26 13:31:49 +00:00
Jim Meyering
890a087101 . 1999-04-26 13:25:28 +00:00
Jim Meyering
bc2e8cb6ce (utime_null): Don't pass 0666 to open; it's not needed and isn't
guaranteed to be portable.
1999-04-26 13:25:08 +00:00
Jim Meyering
22cce6dadc (S_IRWXU, S_IRWXG, S_IRWXO): Define if not defined.
Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 13:22:23 +00:00
Jim Meyering
82893aff55 (make_node_op_equals, mode_compile, mode_create_from_ref, mode_adjust):
Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
modechange.h now includes sys/types.h.
Include xstrtol.h.
(isodigit, oatoi): Remove.
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP,
S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH, S_IRWXU, S_IRWXG,
S_IRWXO): Define if not defined.
(CHMOD_MODE_BITS): New macro.
(mode_compile): Convert from octal with xstrtoul, not our own routine.
1999-04-26 13:19:37 +00:00
Jim Meyering
c262673191 Don't assume traditional Unix mode numbering. 1999-04-26 13:14:36 +00:00
Jim Meyering
d8071546b1 Include <config.h>, <sys/types.h> for mode_t.
(struct mode_change): Members affected and value are now mode_t instead
of unsigned short.
1999-04-26 13:13:59 +00:00
Jim Meyering
d1e59e17e7 <config.h>, <sys/types.h>: Include for mode_t.
(mode_string): Now takes mode_t.
1999-04-26 13:13:36 +00:00
Jim Meyering
9afd1dd692 (make_path): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRWXU): Define if not defined.
1999-04-26 13:13:00 +00:00
Jim Meyering
c1e3742914 (setst, ftypelet, mode_string): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
(S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH): Define if not defined.
<config.h>, <sys/types.h>: Include for mode_t.
(mode_string): Now takes mode_t.
1999-04-26 13:10:11 +00:00
Jim Meyering
157b3ef61f (main): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 13:03:49 +00:00
Jim Meyering
73e540ea1b (do_copy, cp_option_init, main): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 13:03:11 +00:00
Jim Meyering
12dd796d8a (struct cp_options.umask_kill): Use mode_t, not unsigned int. 1999-04-26 12:55:36 +00:00
Jim Meyering
d1c7f62ba8 (copy_reg, copy_internal): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:54:51 +00:00
Jim Meyering
5d76644c3e (describe_change, change_file_mode): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:51:43 +00:00
Jim Meyering
750e5969ff (main): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:49:59 +00:00
Jim Meyering
6fc1cc1b6a (isodigit): Remove unused macro.
(mode, cp_option_init, DIR_MODE): Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:49:16 +00:00
Jim Meyering
9e37b40aa1 (S_ISUID, S_ISGID, S_ISVTX, S_IRWXU, S_IRWXG, S_IRWXO):
Define if not defined.
(CHMOD_MODE_BITS): New macro.
1999-04-26 12:48:12 +00:00
Jim Meyering
ebb207dc5a (open_maybe_create): Don't pass 0666 to open; it's not needed and isn't
guaranteed to be portable.
1999-04-26 12:47:33 +00:00
Jim Meyering
d0eeabbc32 Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:20:54 +00:00
Jim Meyering
259838277b Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:20:26 +00:00
Jim Meyering
0b6ee7158e Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
1999-04-26 12:19:37 +00:00
Jim Meyering
3baa7fa854 (main): Revert last change.
Instead, loop on `optind < argc' to protect use of argv[optind].
1999-04-26 02:19:51 +00:00
Jim Meyering
0d13ededce revert last change 1999-04-26 02:18:09 +00:00
Jim Meyering
a3a4a31c22 . 1999-04-26 00:40:42 +00:00
Jim Meyering
bf73dd5297 (main): Handle the case in which seq is given no args. 1999-04-26 00:39:47 +00:00
Jim Meyering
6002b5a2ed *** empty log message *** 1999-04-25 19:20:40 +00:00
Jim Meyering
1c9a7ba541 <inttypes.h>: Include it here instead.
<config.h>: Include it here too.
1999-04-25 19:20:18 +00:00
Jim Meyering
e3a368948e Don't include inttypes.h here. 1999-04-25 19:18:55 +00:00
Jim Meyering
12bf2f8f8b [NDEBUG]: Remove definition. 1999-04-25 19:18:20 +00:00
Jim Meyering
d12ba36443 *** empty log message *** 1999-04-25 12:11:52 +00:00
Jim Meyering
007f495c2f *** empty log message *** 1999-04-25 04:38:15 +00:00
Jim Meyering
0de4165e66 *** empty log message *** 1999-04-24 21:38:27 +00:00
Jim Meyering
f90a5e94b8 (print_entry): Use #if', not #ifdef HAVE_UT_HOST'. 1999-04-24 21:29:22 +00:00
Jim Meyering
88fc9ef946 *** empty log message *** 1999-04-24 13:14:25 +00:00
Jim Meyering
fc6db4f55a *** empty log message *** 1999-04-24 13:14:11 +00:00
Jim Meyering
a279b3a84b . 1999-04-24 13:00:16 +00:00
Jim Meyering
a56886d93d *** empty log message *** 1999-04-24 12:59:26 +00:00
Jim Meyering
82105f5876 *** empty log message *** 1999-04-24 12:58:07 +00:00
Jim Meyering
ea07044f83 . 1999-04-24 12:57:43 +00:00
Jim Meyering
b67ee7857a *** empty log message *** 1999-04-24 12:53:50 +00:00
Jim Meyering
6796615496 *** empty log message *** 1999-04-24 12:53:19 +00:00
Jim Meyering
88c9f81346 Include new "xstrtol.h", not "xstrtoul.h". 1999-04-24 12:43:39 +00:00
Jim Meyering
55865fda6c Include new "xstrtol.h", not "xstrtoul.h".
(struct control) [repeat]: Declare as uintmax_t, not int.
(struct control) [lines_required]: Likewise.
(handle_line_error): Use human_readable to print lines_required.
(parse_repeat_count): Parse a uintmax_t.
(parse_patterns): Parse a uintmax_t.
1999-04-24 12:42:53 +00:00
Jim Meyering
bdb9cd3f2c Include new "xstrtol.h", not "xstrtoul.h". 1999-04-24 12:33:56 +00:00
Jim Meyering
cef6937705 Include new "xstrtol.h", not "xstrtoul.h".
Change all U_LONG_LONG to uintmax_t.
(head_lines): Move a couple dcls into an inner scope.
(string_to_integer): Rename from string_to_ull.
1999-04-24 12:33:25 +00:00
Jim Meyering
34942b9da8 import latest 1999-04-23 04:20:42 +00:00
Jim Meyering
4cbb965035 *** empty log message *** 1999-04-22 15:19:11 +00:00
Jim Meyering
62edaf0b55 (word32): Don't use `#error'; it runs afoul of SunOS 4.1.4 cc. 1999-04-22 14:38:50 +00:00
Jim Meyering
c274f255c3 *** empty log message *** 1999-04-22 14:37:17 +00:00
Jim Meyering
e7fa925898 Guard strong_alias and weak_alias with #ifdef _LIBC. 1999-04-22 14:35:59 +00:00
Jim Meyering
b003c8fdfa Don't bother with pot-mail anymore -- Francois needs merely the URL. 1999-04-22 01:24:34 +00:00
Jim Meyering
2279aec4a3 . 1999-04-21 23:17:13 +00:00
Jim Meyering
1f74a371e0 . 1999-04-21 23:16:48 +00:00
Jim Meyering
ae295f9bab . 1999-04-21 04:34:29 +00:00
Jim Meyering
28a81b47c1 . 1999-04-21 04:30:22 +00:00
Jim Meyering
9b56140087 *** empty log message *** 1999-04-21 04:29:00 +00:00
Jim Meyering
8907976270 Remove the temporary strtoumax replacement;
we now have a true replacement in strtoumax.c.
(__strtol): Always define to strtoumax.
(<stdlib.h>): No need to include.
(PARAMS): Remove.
(my_strtoumax): Move this to strtoumax.c,
rename it to strtoumax, and simplify.
1999-04-21 04:28:36 +00:00
Jim Meyering
3354e7502c Update to glibc 2.1.1 version. 1999-04-21 04:27:24 +00:00
Jim Meyering
64bae48df6 . 1999-04-21 04:24:39 +00:00
Jim Meyering
9d3c3cb2c7 *** empty log message *** 1999-04-21 04:22:15 +00:00
Jim Meyering
9a16aa9fde *** empty log message *** 1999-04-21 04:21:50 +00:00
Jim Meyering
a6f5dd6269 (jm_CHECK_ALL_TYPES): Require jm_AC_TYPE_UNSIGNED_LONG_LONG. 1999-04-21 04:21:44 +00:00
Jim Meyering
9174cee25d (AC_CHECK_FUNCS): Remove strtoull, strtoumax, strtouq. 1999-04-21 04:14:59 +00:00
Jim Meyering
7d98d28569 *** empty log message *** 1999-04-21 04:04:20 +00:00
Jim Meyering
e441de9acc (jm_AC_TYPE_UINTMAX_T): Move unsigned long
long check into new jm_AC_TYPE_UNSIGNED_LONG_LONG macro.
1999-04-21 04:04:04 +00:00
Jim Meyering
36ca174d81 *** empty log message *** 1999-04-21 04:00:48 +00:00
Jim Meyering
76659f726f Require jm_AC_TYPE_UNSIGNED_LONG_LONG.
Replace xstroull if necessary.
1999-04-21 04:00:38 +00:00
Jim Meyering
42a64ac80e *** empty log message *** 1999-04-21 03:58:57 +00:00
Jim Meyering
6783ad7832 *** empty log message *** 1999-04-21 03:24:54 +00:00
Jim Meyering
e8b570e45a update comment 1999-04-21 03:19:26 +00:00
Jim Meyering
cf6eaeb03b <xstrtol.h>: Include this, not xstrtoul.h.
<human.h>: Include.
Use uintmax_t in place of unsigned long.
Use human_readable to convert to strings for printing.
1999-04-21 03:18:23 +00:00
Jim Meyering
42ccae28c6 . 1999-04-21 02:30:43 +00:00
Jim Meyering
c850864a19 . 1999-04-21 02:29:50 +00:00
Jim Meyering
c93a59ac4f . 1999-04-21 02:28:20 +00:00
Jim Meyering
abc54153b1 *** empty log message *** 1999-04-21 02:21:57 +00:00
Jim Meyering
c4a52014f7 Port to AIX and HP-UX. Support cross-compilation. 1999-04-21 02:21:47 +00:00
Jim Meyering
c7a0b8f429 <config.h>: Include first, since it can do
things like #define const, and this must be done before
including any system headers.
1999-04-20 13:26:06 +00:00
Jim Meyering
154588d722 (my_strtoumax): Fix typo in computing
whether overflow occurred.  Improve overflow-detection to use
only one conditional branch total, rather than 2N+1
conditional branches for an N-digit number.
1999-04-20 13:24:14 +00:00
Jim Meyering
f9270b650f *** empty log message *** 1999-04-19 14:09:07 +00:00
Jim Meyering
5f724e01b9 *** empty log message *** 1999-04-19 14:06:07 +00:00
Jim Meyering
c37f2f6355 (main): Restore `+' in getopt_long string. Otherwise,
commands like `seq 10 -2 0' wouldn't work.  From Andreas Schwab.
1999-04-19 14:05:34 +00:00
Jim Meyering
dcf32e94d2 *** empty log message *** 1999-04-19 14:03:17 +00:00
Jim Meyering
3e47e246f8 *** empty log message *** 1999-04-19 05:25:52 +00:00
Jim Meyering
d5c056d478 (b_host): Remove /pub suffix. 1999-04-19 05:22:54 +00:00
Jim Meyering
da96ede53c *** empty log message *** 1999-04-19 04:50:25 +00:00
Jim Meyering
6a9f42807f (my-distcheck): Use AMTAR, not TAR. 1999-04-19 04:50:03 +00:00
Jim Meyering
36564cbefd . 1999-04-19 04:45:09 +00:00
Jim Meyering
95836befb3 *** empty log message *** 1999-04-19 04:24:35 +00:00
Jim Meyering
0b8e81aab9 . 1999-04-19 04:20:57 +00:00
Jim Meyering
a0119464b8 *** empty log message *** 1999-04-19 02:56:54 +00:00
Jim Meyering
00811477e8 *** empty log message *** 1999-04-19 02:54:53 +00:00
Jim Meyering
e144c80776 Require jm_AC_PREREQ_XSTRTOUMAX. 1999-04-19 02:54:48 +00:00
Jim Meyering
ac4f985ac9 *** empty log message *** 1999-04-19 02:53:36 +00:00
Jim Meyering
560d7d9dac . 1999-04-19 02:42:58 +00:00
Jim Meyering
e7a7a48ee6 . 1999-04-19 02:39:52 +00:00
Jim Meyering
95e8d410ff (tempname): Wrap after 99999 only for length-impaired file systems. 1999-04-19 02:39:09 +00:00
Jim Meyering
d3b1ca9174 (main, longopts):
Use -u instead of -R for --remove, so that we can preserve
future compatibility with rm.
1999-04-19 02:15:09 +00:00
Jim Meyering
d70fb569fb [!HAVE_CONFIG_H] (ST_BLKSIZE): Define to 65536.
(do_wipefd): Use ST_BLKSIZE instead of referring to the st_blksize
member directly.
1999-04-19 02:13:01 +00:00
Jim Meyering
e5e1c6d4fd *** empty log message *** 1999-04-19 00:20:36 +00:00
Jim Meyering
d17b6bc300 *** empty log message *** 1999-04-18 23:20:24 +00:00
Jim Meyering
114946fdb0 Include xstrtol.h.
(parse_integer): Migrate most of the work into the new xstrtoumax fn.
1999-04-18 23:18:48 +00:00
Jim Meyering
30edff7a36 Include xstrtol.h, not xstrtoul.h, since xstrtol.h now defines all the
xstrto... functions.
1999-04-18 23:18:32 +00:00
Jim Meyering
d3ffbea816 Include xstrtol.h, not obsolete file xstrtoul.h. 1999-04-18 23:18:09 +00:00
Jim Meyering
cc7d631369 <stdlib.h>: Include if HAVE_STDLIB_H, since bison 1.27 invokes "free".
(LookupWord, yylex): Don't pass negative char to ctype macros.
1999-04-18 23:17:30 +00:00
Jim Meyering
4e8d80cad7 (xalloc_fail): Pass xalloc_msg_memory_exhausted through gettext. 1999-04-18 23:17:05 +00:00
Jim Meyering
a1d8c38553 (libfu_a_SOURCES): Add xstrtoumax.c.
(noinst_HEADERS): Remove xstrtoul.h.
1999-04-18 23:16:49 +00:00
Jim Meyering
0501984933 (__xstrtol, __strtol, __unsigned): Remove macro decls.
<inttypes.h>: Include if HAVE_INTTYPES_H.
(_DECLARE_XSTRTOL): New macro.
(xstrtol, xstrtoul, xstrtoumax): Declare all three functions, so that
we need only one include file, not three.
(_STRTOL_ERROR): Do not undef, as this is no longer needed.
Reword overflow message so that it's independent of type.
1999-04-18 23:16:23 +00:00
Jim Meyering
f8474e2421 (__strtol, __strtol_t, __xstrtol):
New macros to specify the
underlying function, its returned type, and our function.  Default to
values suitable for xstrtol.

Include <ctype.h>, since we use its macros.

(ULONG_MAX, LONG_MAX, ISBLANK): Remove: no longer needed.
(ISSPACE): New macro.

(bkm_scale, bkm_scale_by_power, __xstrtol, main): __unsigned long int
-> __strtol_t.

(__xstrtol): Depend on whether __strtol_t is an unsigned type, not on
whether STRING_TO_UNSIGNED is defined.  Skip isspace chars, not
isblank chars, to match strtol.  When returning
LONGINT_INVALID_SUFFIX_CHAR, store the value that we computed into
*val.
1999-04-18 23:15:34 +00:00
Jim Meyering
ddd5fa0ce5 (STRING_TO_UNSIGNED): Remove.
(__strtol, __strtol_t, __xstrtol): New macros.
1999-04-18 23:15:02 +00:00
Jim Meyering
a7a7424b8b Include xstrtol.h, not obsolete file xstrtoul.h.
"human.h", "xalloc.h": Include.
(attribute): Remove; no longer needed.
(xstrdup): New decl.
(STDOUT_FILENO): New macro.
(O_NOCTTY): Make sure it's always defined, even if HAVE_CONFIG_H.

The following changes have effect only if !HAVE_CONFIG_H.
<ctype.h>: New include.
(RETSIGTYPE): Remove bogus semicolon at end.
(STDOUT_FILENO, uintmax_t, human_readable, LONGEST_HUMAN_READABLE):
New macros.
(xstrtoumax): Renamed from xstrtoul, with corresponding type changes.
Handle suffixes like the real routine does.
(error): Remove bogus assignment of errno to errnum.
(xmalloc, xstrdup): New functions.

(O_NOCTTY): Define even if !HAVE_CONFIG_H.
(S_ISFIFO, S_ISSOCK): New macros, if not already defined.
(OUTPUT_BLOCK_SIZE): New macro.
(struct Options.verbose): Now a boolean, since we no longer have two
levels of verbosity.
(long_opts, usage, main): Remove -D or --device option.  Invert -p or
--preserve option, and rename it to -R or --remove.
(usage): Describe G suffix.
(usage): "-" no longer conflicts with -v.
(UCHAR_MAX): Indent `#error' so that SunOS 4.1.4 cc doesn't reject it.
(ind): Portability fixes: return word32, not unsigned; multiply by
sizeof (word32) instead of shifting left by 2.
(isaac_refill, isaac_mix): Comment out size of array parameter, as
ansi2knr mishandles this.
(status_visible, status_pos, pfstatus, flushstatus): Remove, since
pfstatus isn't portable to users with varying width fonts, or
internationalized messages, and vfprintf is problematic.  All callers
of pfstatus changed to use error instead; this removes incompatibility
of -v with -.  All calls to flushstatus removed.
(dopass, do_wipefd): Do not translate non-English msgs with gettext.

(dopass): Cast lseek constant arguments to (off_t) for benefit
of pre-ANSI compilers; fix one lseek call whose args were interchanged.
Remove unnecessary casts to (off_t).  Do not check for EIO
when determining file size; this was just my earlier wild guess.
Use human_readable to print off_t, instead of casting to unsigned long
(which doesn't work in Solaris 2.6, where off_t is longer than long).
Output human-readable sizes, instead of always using "K".
Check for offset overflow (it happened to me in SunOS 4.1.4).
(do_wipefd): Do not insist on regular files, but do check for special
files that cannot possibly be shredded.
Use xmalloc instead of malloc + check.
Do not inspect st_size for non-regular files.
Try to find the size of a non-regular file by seeking to its end.
Do not assume that a regular file of size-0 has unknown size.
Check for regular files with negative sizes,
and for overflow after rounding to next block.
Always try to truncate, even for special files, but do not report an
error if truncation fails on a special file.

(dopass, wipefile): Do not return 1 for special files; the caller
doesn't care any more.

(wipefd): Remove unnecessary (and nonportable) check for
whether the file descriptor is read-only.  Remove
no-longer-needed check for `-v -'.

(incname): Return 1 for carry bit, like the documentation says.

(wipename, wipefile): Accept new argument, specifying the
quoted file name.  All callers changed.

(wipename): Use xstrdup instead of strdup+error check.

(wipefile): Check for ENOTDIR when opening /dev/fd/NNN. Check for
errors in NNN more carefully. Restore errno after the check.
Check for errors when closing the file descriptor.
Use more consistent wording when unable to remove a file.

(main): Do not remove files by default.
Use xstrtoumax instead of xstrtoul uniformly, since xstrtoul won't
exist if !HAVE_CONFIG_H.
In diagnostics, quote invalid operands to -n and -s options.
Allow T, P, E, Z, and Y suffixes in -s operand.
flags.verbose is now a boolean, not a counter.
Use STDOUT_FILENO instead of 1, for clarity.
1999-04-18 23:13:57 +00:00
Jim Meyering
69b1c4026c (tempname): Add a FIXME comment. 1999-04-18 15:57:19 +00:00
Jim Meyering
0fe4e6b443 (NAME_MAX_IN_DIR): Rename from PATH_MAX_IN_DIR. Use _POSIX_NAME_MAX,
not _POSIX_PATH_MAX.  Guard with #if HAVE_PATHCONF rather than
#if HAVE_UNISTD_H.
1999-04-18 15:44:03 +00:00
Jim Meyering
8cee2c6772 Rename global: s/temp_file_prefix/temp_dir/. 1999-04-18 14:40:20 +00:00
Jim Meyering
eb4109b66e (usage): s/DIRECT/DIRECTORY/g 1999-04-18 14:38:24 +00:00
Jim Meyering
e0cbae44cd *** empty log message *** 1999-04-18 13:32:44 +00:00
Jim Meyering
8f913cc64f (main): Open the output file with *read* access
only if we might need to read to satisfy a `seek=' request.
From Matthias Urlichs.
1999-04-18 13:32:35 +00:00
Jim Meyering
64dec9fafb *** empty log message *** 1999-04-18 13:31:34 +00:00
Jim Meyering
a625377e8c *** empty log message *** 1999-04-18 03:25:23 +00:00
Jim Meyering
c5027d831c . 1999-04-18 02:16:56 +00:00
Jim Meyering
f4143898b2 *** empty log message *** 1999-04-17 14:41:38 +00:00
Jim Meyering
5101382ec6 *** empty log message *** 1999-04-17 11:56:21 +00:00
Jim Meyering
dd886e9690 (file_lines): Fix serious bug introduced with last changes.
From Andreas Schwab.
1999-04-17 11:50:03 +00:00
Jim Meyering
6a821331eb . 1999-04-15 14:09:04 +00:00
Jim Meyering
d679966505 *** empty log message *** 1999-04-15 14:03:06 +00:00
Jim Meyering
f01319465c rename .posix-warn to .env-warn 1999-04-15 13:59:14 +00:00
Jim Meyering
1dbd1aff6f . 1999-04-15 13:49:45 +00:00
Jim Meyering
69e1d626bd Add comments.
(init_header): Tweak white space in Date/Time header.
1999-04-15 13:49:13 +00:00
Jim Meyering
609582a161 new tests from Roland 1999-04-15 13:26:50 +00:00
Jim Meyering
bc95e393d8 Updated tests.
From Roland Huebner.
1999-04-15 13:26:44 +00:00
Jim Meyering
379dcf4c48 . 1999-04-15 12:45:57 +00:00
Jim Meyering
ffd4e9684a *** empty log message *** 1999-04-14 03:12:27 +00:00
Jim Meyering
809b33b2ff new version via automake 1999-04-13 14:44:33 +00:00
Jim Meyering
2a8c4e283e *** empty log message *** 1999-04-13 02:57:40 +00:00
Jim Meyering
e6bc0dccbc (main): Declare out_dev to be of type dev_t, not `int'.
Declare out_ino to be of type ino_t, not `int'.
1999-04-13 01:11:46 +00:00
Jim Meyering
b6d265e347 * src/od.c (MIN, MAX): Remove definitions.
* src/sys2.h (MIN, MAX): Define here instead.
1999-04-13 01:09:15 +00:00
Jim Meyering
4de61e5f98 . 1999-04-12 04:28:05 +00:00
Jim Meyering
1f6f06f7de (test_vector): Disable all tests while I wait for an updated suite. 1999-04-12 04:27:46 +00:00
Jim Meyering
69d1c5772e *** empty log message *** 1999-04-12 04:00:10 +00:00
Jim Meyering
d577eef9e4 *** empty log message *** 1999-04-12 03:54:57 +00:00
Jim Meyering
a36f86a13e . 1999-04-12 03:47:40 +00:00
Jim Meyering
924b7e2291 . 1999-04-12 03:47:17 +00:00
Jim Meyering
2e2161c97a (COPY_TO_EOF): Define.
(dump_remainder): Add parameter, n_bytes, and rewrite to use it.
Update callers.
(file_lines): Rename parameter.
(tail_bytes): Remove obsolete comment.
1999-04-12 03:22:24 +00:00
Jim Meyering
f3df8336ae Fix the problem whereby `yes > k & tail -1 k' would infloop.
(dump_remainder): Move this function to precede the new use in file_lines.
(tail_lines): Don't call dump_remainder here.
(file_lines): Call dump_remainder here instead.
1999-04-11 17:59:28 +00:00
Jim Meyering
a66cc3009b *** empty log message *** 1999-04-11 13:26:42 +00:00
Jim Meyering
cf3d3f1e6e (readtoken, readtokens): Protoize. 1999-04-11 13:25:52 +00:00
Jim Meyering
832dfa7e1f (xwrite): Use STDOUT_FILENO instead of literal `1'. 1999-04-11 03:42:21 +00:00
Jim Meyering
35af2e8613 *** empty log message *** 1999-04-11 03:24:12 +00:00
Jim Meyering
de9d4e9f91 (alpha): Add trailing slash for ncftp. 1999-04-11 03:24:04 +00:00
287 changed files with 7814 additions and 4368 deletions

View File

@@ -11,27 +11,32 @@ maintainer-check:
$(MAKE) distcheck
$(MAKE) my-distcheck
prev-version := $(shell echo $(VERSION)|tr a-z Xa-y)
tag-package = $(shell echo "$(PACKAGE)" | tr a-z A-Z)
tag-this-version = $(subst .,_,$(VERSION))
tag-prev-version = $(subst .,_,$(prev-version))
this-cvs-tag = $(tag-package)-$(tag-this-version)
prev-cvs-tag = $(tag-package)-$(tag-prev-version)
# Tag before making distribution. Also, don't make a distribution if
# checks fail. Also, make sure the NEWS file is up-to-date.
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
cvs-dist: maintainer-check
pkg=`echo "$(PACKAGE)" | tr a-z A-Z`; \
ver=`echo "$(VERSION)" | sed 's/\./_/g'`; \
tag="$$pkg-$$ver"; \
echo tag=$$tag; \
if cvs -n log -h README| grep -e $$tag: > /dev/null; then \
echo $(this-cvs-tag); \
if cvs -n log -h README| grep -e $(this-cvs-tag): > /dev/null; then \
echo "VERSION not new; not tagging" 1>&2; \
exit 1; \
fi; \
cvs update po; \
cvs tag -c $$tag
cvs tag -c $(this-cvs-tag)
$(MAKE) dist
t=./=test
my-distcheck:
-rm -rf $(t)
mkdir $(t)
GZIP=$(GZIP) $(TAR) -C $(t) -zxf $(distdir).tar.gz
GZIP=$(GZIP) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
cd $(t)/$(distdir) \
&& ./configure --disable-nls \
&& $(MAKE) CFLAGS='-Wformat -Werror' \
@@ -39,7 +44,7 @@ my-distcheck:
&& $(MAKE) check \
&& $(MAKE) distclean
cd $(t) && mv $(distdir) $(distdir).old \
&& $(TAR) -zxf ../$(distdir).tar.gz
&& $(AMTAR) -zxf ../$(distdir).tar.gz
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-rm -rf $(t)
@echo "========================"; \
@@ -53,7 +58,7 @@ PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
v = Version
a_host=alpha.gnu.org
b_host=tug.org/pub
b_host=tug.org
c_host=ftp.enst.fr
a_url_dir=gnu/fetish
@@ -95,20 +100,22 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
| grep -v '^\['; \
echo; \
echo ChangeLog entries:; \
sed -n "1,/$v $(PREV_VERSION_REGEXP)/p" \
ChangeLog; \
find . -name ChangeLog \
| xargs cvs diff -up -r$(prev-cvs-tag) -rHEAD \
| sed -n 's/^+//p' \
| perl -ne 'm!^\+\+ (\./)?! or print,next;' \
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
)
alpha:
$(MAKE) cvs-dist
$(MAKE) -s announcement > /tmp/announcement
$(MAKE) -s announcement > /tmp/announce-$(distdir)
ln $(distdir).tar.gz ../release
chmod a-w $(distdir).tar.gz
@echo =====================================
@for url in $(real_dir_list); do \
echo "ncftp -u $$url"; \
echo "ncftp -u $$url/"; \
done
@echo '# put $(distdir).tar.gz'
@echo '# send the /tmp/announcement e-mail'
@echo 'pot-mail $(distdir).tar.gz | bash'
@echo =====================================

7
THANKS
View File

@@ -20,6 +20,7 @@ Bjorn Helgaas: helgaas@rsn.hp.com
Bob McCracken: kerouac@ravenet.com
Brendan O'Dea: bod@compusol.com.au
Charles Karney: karney@pppl.gov
Chris Yeo: cyeo@biking.org
Christian von Roques: roques@pond.sub.org
Colin Plumb: colin@nyx.net
Dirk Lattermann: dlatt@t-online.de
@@ -57,12 +58,15 @@ Marty Leisner: leisner@sdsp.mc.xerox.com
Masami Takikawa: takikawm@CS.ORST.EDU
Matthew S. Levine: mslevine@theory.lcs.mit.edu
Matthew Swift: swift@alum.mit.edu
Matthias Urlichs: smurf@noris.de
Michiel Bacchiani: bacchian@raven.bu.edu
Michael Veksler: mveksler@techunix.technion.ac.il
Miles Bader: miles@gnu.ai.mit.edu
Noel Cragg: noel@red-bean.com
Olav Morkrid: olav@funcom.com
Per Kristian Hove: perhov@math.ntnu.no
Peter Eriksson: peter@ifm.liu.se
Peter Samuelson: psamuels@sampo.creighton.edu
Paul Eggert: eggert@twinsun.com
Philippe De Muyter: phdm@macqel.be
Rainer Orth: ro@TechFak.Uni-Bielefeld.DE
@@ -70,10 +74,11 @@ Ross Ridge: rridge@calum.csclub.uwaterloo.ca
Santiago Vila Doncel: sanvila@unex.es
Stuart Kemp: skemp@peter.bmc.com
Thomas Bushnell, n/BSG: thomas@gnu.ai.mit.edu
Ton Hospel: thospel@mail.dma.be
Torbjorn Lindgren: tl@funcom.no
Tony Leneis: tony@plaza.ds.adp.com
Ulrich Drepper: drepper@cygnus.com
Vin Shelton: acs@alumni.princeton.edu
Volker Borchert: bt@teknon.de
Michael Veksler: mveksler@techunix.technion.ac.il
Wayne Stewart: wstewa@atl.com
William Bader: william@nscs.fast.net

View File

@@ -57,6 +57,10 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -64,6 +68,7 @@ CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
@@ -104,9 +109,11 @@ EXTRA_DIST = perm.texi getdate.texi
# and those names all map to one 14-byte name (<package>.info-) on some crufty
# old systems.
MAKEINFO = makeinfo --no-split
subdir = doc
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
TEXI2DVI = texi2dvi
INFO_DEPS = fileutils.info
DVIS = fileutils.dvi
@@ -115,7 +122,7 @@ DIST_COMMON = Makefile.am Makefile.in mdate-sh stamp-vti texinfo.tex \
version.texi
DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
@@ -229,8 +236,9 @@ uninstall-info:
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file"; \
install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
d=$(srcdir); \
echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $$d/$$file"; \
install-info --info-dir=$(DESTDIR)$(infodir) --remove $$d/$$file; \
done; \
else :; fi
@$(NORMAL_UNINSTALL)
@@ -278,8 +286,6 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = doc
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -296,6 +302,7 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
info-am: $(INFO_DEPS)
info: info-am

View File

@@ -430,7 +430,7 @@ the file to all users.
@cindex numeric modes
@cindex file permissions, numeric
@cindex octal numbers for file modes
File permissions are stored internally as 16 bit integers. As an
File permissions are stored internally as integers. As an
alternative to giving a symbolic mode, you can give an octal (base 8)
number that corresponds to the internal representation of the new mode.
This number is always interpreted in octal; you do not have to add a
@@ -440,12 +440,13 @@ A numeric mode is usually shorter than the corresponding symbolic
mode, but it is limited in that it can not take into account a file's
previous permissions; it can only set them absolutely.
The permissions granted to the user, to other users in the file's group,
On most systems, the permissions granted to the user,
to other users in the file's group,
and to other users not in the file's group are each stored as three
bits, which are represented as one octal digit. The three special
permissions are also each stored as one bit, and they are as a group
represented as another octal digit. Here is how the bits are arranged
in the 16 bit integer, starting with the lowest valued bit:
represented as another octal digit. Here is how the bits are arranged,
starting with the lowest valued bit:
@example
Value in Corresponding

View File

@@ -3,7 +3,7 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{1999-03-31.13}%
\def\texinfoversion{1999-04-25.15}%
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
% Free Software Foundation, Inc.
@@ -67,7 +67,6 @@
\catcode`+=\active \catcode`\_=\active}
% Save some parts of plain tex whose names we will redefine.
\let\ptexb=\b
\let\ptexbullet=\bullet
\let\ptexc=\c
@@ -87,6 +86,13 @@
% For @tex, we can use \tabalign.
\let\+ = \relax
% Get ready for pdf.
\newif\ifpdf
\ifx\pdfoutput\undefined\else
\input pdfcolor
\pdfoutput=1
\pdftrue
\fi
\message{Basics,}
\chardef\other=12
@@ -245,6 +251,8 @@
\unvbox\footlinebox
\fi
%
\ifpdf\pdfmkdest{\the\pageno}\fi
%
\ifcropmarks
\egroup % end of \vbox\bgroup
\hfil\egroup % end of (centering) \line\bgroup
@@ -842,6 +850,126 @@ where each line of input produces a line of output.}
\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
\message{pdf,}
% adobe `portable' document format
\newcount\tempnum
\newcount\lnkcount
\newtoks\filename
\newcount\filenamelength
\newcount\pgn
\ifpdf
\def\pdfmkdest#1{\pdfdest name{#1@} xyz}
\def\pdfmkpgn#1{#1@}
% Adding outlines to PDF; macros for calculating structure of outlines
% come from Petr Olsak
\def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
\else \csname#1\endcsname \fi}
\def\advancenumber#1{\tempnum=\expnumber{#1}\relax
\advance\tempnum by1
\expandafter\xdef\csname#1\endcsname{\the\tempnum}}
\def\pdfmakeoutlines{{%
\openin 1 \jobname.toc
\ifeof 1\else\bgroup
\closein 1
\def\code##1{##1}
\def\file##1{##1}
\def\TeX##1{TeX}
\def\tt{}
\def\char{char}
\def\samp##1{##1}
\def\kbd##1{##1}
\def\key##1{##1}
\def\rawbackslashxx{\string\\}
\def\chapentry ##1##2##3{}
\def\unnumbchapentry ##1##2{}
\def\secentry ##1##2##3##4{\advancenumber{chap##2}}
\def\unnumbsecentry ##1##2{}
\def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
\def\unnumbsubsecentry ##1##2{}
\def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
\def\unnumbsubsubsecentry ##1##2{}
\input \jobname.toc
\def\chapentry ##1##2##3{%
\pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
\def\unnumbchapentry ##1##2{%
\pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
\def\secentry ##1##2##3##4{%
\pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
\def\unnumbsecentry ##1##2{%
\pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
\def\subsecentry ##1##2##3##4##5{%
\pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
\def\unnumbsubsecentry ##1##2{%
\pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
\def\subsubsecentry ##1##2##3##4##5##6{%
\pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
\def\unnumbsubsubsecentry ##1##2{%
\pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
\input \jobname.toc
\egroup\fi
}}
\pdfmakeoutlines
\def\makelinks #1,{%
\def\params{#1}\def\E{END}%
\ifx\params\E
\let\nextmakelinks=\relax
\else
\let\nextmakelinks=\makelinks
\ifnum\lnkcount>0,\fi
\picknum{#1}%
\Blue\pdfannotlink attr{/Border [0 0 0]}
goto name{\pdfmkpgn{\the\pgn}}%
#1%
\advance\lnkcount by 1%
\Black\pdfendlink
\fi
\nextmakelinks
}
\def\picknum#1{\expandafter\pn#1}
\def\pn#1{%
\def\p{#1}%
\ifx\p\lbrace
\let\nextpn=\ppn
\else
\let\nextpn=\ppnn
\def\first{#1}
\fi
\nextpn
}
\def\ppn#1{\pgn=#1\gobble}
\def\ppnn{\pgn=\first}
\def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
\def\skipspaces#1{\def\PP{#1}\def\D{|}%
\ifx\PP\D\let\nextsp\relax
\else\let\nextsp\skipspaces
\ifx\p\space\else\addtokens{\filename}{\PP}%
\advance\filenamelength by 1
\fi
\fi
\nextsp}
\def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
\def\pdflink#1{%
\leavevmode\Red
\begingroup
\normalturnoffactive\def\@{@}%
\pdfannotlink
attr{/Border [0 0 0]}%
user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
\endgroup
}
\else
\let\pdflink = \gobble
\fi % end \ifpdf
\message{fonts,}
% Font-change commands.
@@ -1208,23 +1336,43 @@ where each line of input produces a line of output.}
%
\def\uref#1{\douref #1,,,\finish}
\def\douref#1,#2,#3,#4\finish{%
\pdflink{#1}%
\setbox0 = \hbox{\ignorespaces #3}%
\ifdim\wd0 > 0pt
\unhbox0 % third arg given, show only that
\else
\setbox0 = \hbox{\ignorespaces #2}%
\ifdim\wd0 > 0pt
\unhbox0\ (\code{#1})% second arg given, show both it and url
\ifpdf
\unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
\else
\unhbox0 % PDF: 2nd arg given, show only it
\fi
\else
\code{#1}% only url given, so show it
\fi
\fi
%
\ifpdf
\Black\pdfendlink
\fi
}
% rms does not like the angle brackets --karl, 17may97.
% So now @email is just like @uref.
% rms does not like angle brackets --karl, 17may97.
% So now @email is just like @uref, unless we are pdf.
%
%\def\email#1{\angleleft{\tt #1}\angleright}
\let\email=\uref
\ifpdf
\def\email#1{\doemail#1,,\finish}
\def\doemail#1,#2,#3\finish{%
\pdflink{mailto:#1}%
\setbox0 = \hbox{\ignorespaces #2}%
\ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
\Black\pdfendlink
}
\else
\let\email=\uref
\fi
% Check if we are currently using a typewriter font. Since all the
% Computer Modern typewriter fonts have zero interword stretch (and
@@ -1908,10 +2056,11 @@ where each line of input produces a line of output.}
\go
}
% multitable syntax
\def\tab{&\hskip1sp\relax} % 2/2/96
% tiny skip here makes sure this column space is
% maintained, even if it is never used.
% This used to have \hskip1sp. But then the space in a template line is
% not enough. That is bad. So let's go back to just & until we
% encounter the problem it was intended to solve again.
% --karl, nathan@acm.org, 20apr99.
\def\tab{&}
% @multitable ... @end multitable definitions:
%
@@ -3029,7 +3178,7 @@ width0pt\relax} \fi
\message{sectioning,}
% Define chapters, sections, etc.
% Chapters, sections, etc.
\newcount\chapno
\newcount\secno \secno=0
@@ -3037,8 +3186,12 @@ width0pt\relax} \fi
\newcount\subsubsecno \subsubsecno=0
% This counter is funny since it counts through charcodes of letters A, B, ...
% The \the is necessary, despite appearances, because \appendixletter is
% expanded while writing the .toc file. \char\appendixno is not
% expandable, thus it is written literally, thus all appendixes come out
% with the same letter (or @) in the toc without it.
\newcount\appendixno \appendixno = `\@
\def\appendixletter{\char\appendixno}
\def\appendixletter{\char\the\appendixno}
% Each @chapter defines this as the name of the chapter.
% page headings and footings can use it. @section does likewise.
@@ -3511,6 +3664,7 @@ width0pt\relax} \fi
\message{toc,}
% Table of contents.
\newwrite\tocfile
% Write an entry to the toc file, opening it if necessary.
@@ -3607,6 +3761,10 @@ width0pt\relax} \fi
}
\let\shortcontents = \summarycontents
\ifpdf
\pdfcatalog{/PageMode /UseOutlines}%
\fi
% These macros generate individual entries in the table of contents.
% The first argument is the chapter or section name.
% The last argument is the page number.
@@ -3715,6 +3873,7 @@ width0pt\relax} \fi
\message{environments,}
% @foo ... @end foo.
% Since these characters are used in examples, it should be an even number of
% \tt widths. Each \tt character is 1en, so two makes it 1em.
@@ -4038,8 +4197,9 @@ width0pt\relax} \fi
\message{defuns,}
% Define formatter for defuns
% First, allow user to change definition object font (\df) internally
% @defun etc.
% Allow user to change definition object font (\df) internally
\def\setdeffont #1 {\csname DEF#1\endcsname}
\newskip\defbodyindent \defbodyindent=.4in
@@ -4293,12 +4453,13 @@ width0pt\relax} \fi
% First, define the processing that is wanted for arguments of \defun
% Use this to expand the args and terminate the paragraph they make up
\def\defunargs #1{\functionparens \sl
\def\defunargs#1{\functionparens \sl
% Expand, preventing hyphenation at `-' chars.
% Note that groups don't affect changes in \hyphenchar.
\hyphenchar\tensl=0
% Set the font temporarily and use \font in case \setfont made \tensl a macro.
{\tensl\hyphenchar\font=0}%
#1%
\hyphenchar\tensl=45
{\tensl\hyphenchar\font=45}%
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
\interlinepenalty=10000
\advance\rightskip by 0pt plus 1fil
@@ -4843,6 +5004,8 @@ width0pt\relax} \fi
\message{cross references,}
% @xref etc.
\newwrite\auxfile
\newif\ifhavexrefs % True if xref values are known.
@@ -4908,6 +5071,7 @@ width0pt\relax} \fi
%
\def\setref#1#2{{%
\indexdummies
\ifpdf \pdfmkdest{#1}\fi
\dosetq{#1-title}{Ytitle}%
\dosetq{#1-pg}{Ypagenumber}%
\dosetq{#1-snt}{#2}%
@@ -4955,6 +5119,19 @@ width0pt\relax} \fi
% are best written with fairly long node names, containing hyphens, this
% is a loss. Therefore, we give the text of the node name again, so it
% is as if TeX is seeing it for the first time.
\ifpdf
\leavevmode
\getfilename{#4}%
\ifnum\filenamelength>0
\pdfannotlink attr{/Border [0 0 0]}%
goto file{\the\filename.pdf} name{#1@}%
\else
\pdfannotlink attr{/Border [0 0 0]}%
goto name{#1@}%
\fi
\BlueGreen
\fi
%
\ifdim \wd1 > 0pt
\putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
\else
@@ -4974,6 +5151,7 @@ width0pt\relax} \fi
% page 3
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
\fi
\ifpdf \Black\pdfendlink \fi
\endgroup}
% \dosetq is the interface for calls from other macros
@@ -5347,6 +5525,7 @@ width0pt\relax} \fi
\message{localization,}
% and i18n.
% @documentlanguage is usually given very early, just after
% @setfilename. If done too late, it may not override everything
@@ -5406,8 +5585,7 @@ should work if nowhere else does.}
% Allow us to assign to \emergencystretch anyway.
\def\emergencystretch{\dimen0}%
\else
\emergencystretch = \hsize
\divide\emergencystretch by 40
\emergencystretch = .15\hsize
\fi
}
@@ -5517,6 +5695,7 @@ should work if nowhere else does.}
%
\letterpaper
\message{and turning on texinfo input format.}
% Define macros to output various characters with catcode for normal text.

View File

@@ -44,7 +44,7 @@ START-INFO-DIR-ENTRY
* tsort: (textutils)tsort invocation. Topological sort.
* tr: (textutils)tr invocation. Translate characters.
* unexpand: (textutils)unexpand invocation. Convert spaces to tabs.
* uniq: (textutils)uniq invocation. Uniqify files.
* uniq: (textutils)uniq invocation. Uniquify files.
* wc: (textutils)wc invocation. Byte, word, and line counts.
END-INFO-DIR-ENTRY
@end format
@@ -161,7 +161,7 @@ Summarizing files
Operating on sorted files
* sort invocation:: Sort text files.
* uniq invocation:: Uniqify files.
* uniq invocation:: Uniquify files.
* comm invocation:: Compare two sorted files line by line.
* ptx invocation:: Produce a permuted index of file contents.
* tsort invocation:: Topological sort.
@@ -672,7 +672,7 @@ Output at most @var{bytes} bytes of the input. Prefixes and suffixes on
@opindex --strings
@cindex string constants, outputting
Instead of the normal output, output only @dfn{string constants}: at
least @var{n} (3 by default) consecutive ASCII graphic characters,
least @var{n} (3 by default) consecutive @sc{ASCII} graphic characters,
followed by a null (zero) byte.
@item -t @var{type}
@@ -687,14 +687,14 @@ of each output line using each of the data types that you specified,
in the order that you specified.
Adding a trailing ``z'' to any type specification appends a display
of the ASCII character representation of the printable characters
of the @sc{ASCII} character representation of the printable characters
to the output line generated by the type specification.
@table @samp
@item a
named character,
@item c
ASCII character or backslash escape,
@sc{ASCII} character or backslash escape,
@item d
signed decimal,
@item f
@@ -779,7 +779,7 @@ Output as octal bytes. Equivalent to @samp{-toC}.
@item -c
@opindex -c
Output as ASCII characters or backslash escapes. Equivalent to
Output as @sc{ASCII} characters or backslash escapes. Equivalent to
@samp{-tc}.
@item -d
@@ -1998,7 +1998,7 @@ These commands work with (or produce) sorted files.
@menu
* sort invocation:: Sort text files.
* uniq invocation:: Uniqify files.
* uniq invocation:: Uniquify files.
* comm invocation:: Compare two sorted files line by line.
* ptx invocation:: Produce a permuted index of file contents.
* tsort invocation:: Topological sort.
@@ -2043,18 +2043,21 @@ works.
@end table
@vindex LC_COLLATE
A pair of lines is compared as follows: if any key fields have been
specified, @code{sort} compares each pair of fields, in the order
specified on the command line, according to the associated ordering
options, until a difference is found or no fields are left.
Unless otherwise specified, all comparisons use the character
collating sequence specified by the @env{LC_COLLATE} locale.
If any of the global options @samp{Mbdfinr} are given but no key fields
are specified, @code{sort} compares the entire lines according to the
global options.
Finally, as a last resort when all keys compare equal (or if no
ordering options were specified at all), @code{sort} compares the lines
byte by byte in machine collating sequence. The last resort comparison
ordering options were specified at all), @code{sort} compares the entire
lines. The last resort comparison
honors the @samp{-r} global option. The @samp{-s} (stable) option
disables this last-resort comparison so that lines in which all fields
compare equal are left in their original relative order. If no fields
@@ -2063,7 +2066,10 @@ or global options are specified, @samp{-s} has no effect.
GNU @code{sort} (as specified for all GNU utilities) has no limits on
input line length or restrictions on bytes allowed within lines. In
addition, if the final byte of an input file is not a newline, GNU
@code{sort} silently supplies one.
@code{sort} silently supplies one. A line's trailing newline is part of
the line for comparison purposes; for example, with no options in an
@sc{ASCII} locale, a line starting with a tab sorts before an empty line
because tab precedes newline in the @sc{ASCII} collating sequence.
Upon any error, @code{sort} exits with a status of @samp{2}.
@@ -2073,11 +2079,14 @@ value as the directory for temporary files instead of @file{/tmp}. The
@samp{-T @var{tempdir}} option in turn overrides the environment
variable.
@vindex LC_CTYPE
The following options affect the ordering of output lines. They may be
specified globally or as part of a specific key field. If no key
fields are specified, global options apply to comparison of entire
lines; otherwise the global options are inherited by key fields that do
not specify any special options of their own.
not specify any special options of their own. The @samp{-b}, @samp{-d},
@samp{-f} and @samp{-i} options classify characters according to
the @env{LC_CTYPE} locale.
@table @samp
@@ -2102,40 +2111,59 @@ sorting so that, for example, @samp{b} and @samp{B} sort as equal.
@item -g
@opindex -g
@cindex general numeric sort
Sort numerically, but use strtod(3) to arrive at the numeric values.
Sort numerically, using the standard C function @code{strtod} to convert
a prefix of each line to a double-precision floating point number.
This allows floating point numbers to be specified in scientific notation,
like @code{1.0e-34} and @code{10e100}. Use this option only if there
is no alternative; it is much slower than @samp{-n} and numbers with
too many significant digits will be compared as if they had been
truncated. In addition, numbers outside the range of representable
double precision floating point numbers are treated as if they were
zeroes; overflow and underflow are not reported.
like @code{1.0e-34} and @code{10e100}.
Do not report overflow, underflow, or conversion errors.
Use the following collating sequence:
@itemize @bullet
@item
Lines that do not start with numbers (all considered to be equal).
@item
NaNs (``Not a Number'' values, in IEEE floating point arithmetic)
in a consistent but machine-dependent order.
@item
Minus infinity.
@item
Finite numbers in ascending numeric order (with @math{-0} and @math{+0} equal).
@item
Plus infinity.
@end itemize
Use this option only if there is no alternative; it is much slower than
@samp{-n} and it can lose information when converting to floating point.
@item -i
@opindex -i
@cindex unprintable characters, ignoring
Ignore characters outside the printable ASCII range 040-0176 octal
(inclusive) when sorting.
Ignore unprintable characters.
@item -M
@opindex -M
@cindex months, sorting by
@vindex LC_TIME
An initial string, consisting of any amount of whitespace, followed
by three letters abbreviating a month name, is folded to UPPER case and
by a month name abbreviation, is folded to UPPER case and
compared in the order @samp{JAN} < @samp{FEB} < @dots{} < @samp{DEC}.
Invalid names compare low to valid names.
Invalid names compare low to valid names. The @env{LC_TIME} locale
determines the month spellings.
@item -n
@opindex -n
@cindex numeric sort
@vindex LC_NUMERIC
Sort numerically: the number begins each line; specifically, it consists
of optional whitespace, an optional @samp{-} sign, and zero or more
digits, optionally followed by a decimal point and zero or more digits.
digits possibly separated by thousands separators, optionally followed
by a radix character and zero or more digits. The @env{LC_NUMERIC}
locale specifies the radix character and thousands separator.
@code{sort -n} uses what might be considered an unconventional method
to compare strings representing floating point numbers. Rather than
first converting each string to the C @code{double} type and then
comparing those values, sort aligns the decimal points in the two
comparing those values, sort aligns the radix characters in the two
strings and compares the strings a character at a time. One benefit
of using this approach is its speed. In practice this is much more
efficient than performing the two corresponding string-to-double (or even
@@ -2180,7 +2208,7 @@ following.
@item -u
@opindex -u
@cindex uniqifying output
@cindex uniquifying output
For the default case or the @samp{-m} option, only output the first
of a sequence of lines that compare equal. For the @samp{-c} option,
check that no pair of consecutive lines compares equal.
@@ -2190,14 +2218,16 @@ check that no pair of consecutive lines compares equal.
@cindex sort field
The recommended, @sc{POSIX}, option for specifying a sort field. The field
consists of the part of the line between @var{pos1} and @var{pos2} (or the
end of the line, if @var{pos2} is omitted), inclusive. Fields and
character positions are numbered starting with 1. See below.
end of the line, if @var{pos2} is omitted), @emph{inclusive}.
Fields and character positions are numbered starting with 1.
So to sort on the second field, you'd use @samp{-k 2,2}
See below for more examples.
@item -z
@opindex -z
@cindex sort zero-terminated lines
Treat the input as a set of lines, each terminated by a zero byte (@sc{ASCII}
@sc{NUL} (Null) character) instead of a @sc{ASCII} @sc{LF} (Line Feed.)
@sc{NUL} (Null) character) instead of an @sc{ASCII} @sc{LF} (Line Feed).
This option can be useful in conjunction with @samp{perl -0} or
@samp{find -print0} and @samp{xargs -0} which do the same in order to
reliably handle arbitrary pathnames (even those which contain Line Feed
@@ -2340,10 +2370,10 @@ sort -t : -b -k 5,5 -k 3,3n /etc/passwd
@node uniq invocation
@section @code{uniq}: Uniqify files
@section @code{uniq}: Uniquify files
@pindex uniq
@cindex uniqify files
@cindex uniquify files
@code{uniq} writes the unique lines in the given @file{input}, or
standard input if nothing is given or for an @var{input} name of
@@ -2616,7 +2646,7 @@ As it is setup now, the program assumes that the input file is coded
using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
@emph{unless} if it is compiled for MS-DOS, in which case it uses the
character set of the IBM-PC. (GNU @code{ptx} is not known to work on
smaller MS-DOS machines anymore.) Compared to 7-bit ASCII, the set of
smaller MS-DOS machines anymore.) Compared to 7-bit @sc{ASCII}, the set of
characters which are letters is then different, this fact alters the
behaviour of regular expression matching. Thus, the default regular
expression for a keyword allows foreign or diacriticized letters.
@@ -2905,7 +2935,7 @@ sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other
diacriticized characters of the underlying character set produce an
appropriate @TeX{} sequence as far as possible. The other non-graphical
characters, like newline and tab, and all others characters which are
not part of ASCII, are merely changed to exactly one space, with no
not part of @sc{ASCII}, are merely changed to exactly one space, with no
special attempt to compress consecutive spaces. Let me know how to
improve this special character processing for @TeX{}.
@@ -3840,8 +3870,8 @@ yourself using when setting up fancy data plumbing. The @code{sort}
command reads and sorts each file named on the command line. It then
merges the sorted data and writes it to standard output. It will read
standard input if no files are given on the command line (thus
making it into a filter). The sort is based on the machine collating
sequence (@sc{ASCII}) or based on user-supplied ordering criteria.
making it into a filter). The sort is based on the character collating
sequence or based on user-supplied ordering criteria.
@node The uniq command
@@ -4017,7 +4047,7 @@ $ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' | ...
The second @code{tr} command operates on the complement of the listed
characters, which are all the letters, the digits, the underscore, and
the blank. The @samp{\012} represents the newline character; it has to
be left alone. (The ASCII TAB character should also be included for
be left alone. (The @sc{ASCII} tab character should also be included for
good measure in a production script.)
At this point, we have data consisting of words separated by blank space.
@@ -4063,7 +4093,7 @@ with the help of two more @code{sort} options:
@table @samp
@item -n
do a numeric sort, not an ASCII one
do a numeric sort, not a textual one
@item -r
reverse the order of the sort

View File

@@ -11,8 +11,9 @@ addext.c argmatch.c backupfile.c basename.c \
closeout.c dirname.c exclude.c filemode.c \
full-write.c human.c idcache.c \
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c \
version-etc.c xgetcwd.c xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
quotearg.c safe-read.c same.c save-cwd.c savedir.c stripslash.c userspec.c \
version-etc.c xgetcwd.c xmalloc.c xstrdup.c \
xstrtol.c xstrtoul.c xstrtoumax.c yesno.c
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
@@ -21,8 +22,9 @@ noinst_HEADERS = argmatch.h backupfile.h closeout.h \
dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
version-etc.h xalloc.h xstrtol.h xstrtoul.h
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
BUILT_SOURCES = getdate.c lstat.c stat.c

View File

@@ -57,6 +57,10 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -64,6 +68,7 @@ CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
@@ -103,8 +108,9 @@ addext.c argmatch.c backupfile.c basename.c \
closeout.c dirname.c exclude.c filemode.c \
full-write.c human.c idcache.c \
isdir.c long-options.c makepath.c modechange.c hash.c path-concat.c \
quotearg.c safe-read.c save-cwd.c savedir.c stripslash.c userspec.c \
version-etc.c xgetcwd.c xmalloc.c xstrdup.c xstrtol.c xstrtoul.c yesno.c
quotearg.c safe-read.c same.c save-cwd.c savedir.c stripslash.c userspec.c \
version-etc.c xgetcwd.c xmalloc.c xstrdup.c \
xstrtol.c xstrtoul.c xstrtoumax.c yesno.c
libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
@@ -114,13 +120,15 @@ noinst_HEADERS = argmatch.h backupfile.h closeout.h \
dirname.h error.h exclude.h filemode.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
version-etc.h xalloc.h xstrtol.h xstrtoul.h
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
BUILT_SOURCES = getdate.c lstat.c stat.c
EXTRA_DIST = xstat.in
subdir = lib
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
@@ -132,57 +140,63 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
ANSI2KNR = ../src/ansi2knr
libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
libfu_a_AR = $(AR) cru
am_libfu_a_OBJECTS = getdate$U.o posixtm$U.o getopt$U.o getopt1$U.o \
addext$U.o argmatch$U.o backupfile$U.o basename$U.o closeout$U.o \
dirname$U.o exclude$U.o filemode$U.o full-write$U.o human$U.o \
idcache$U.o isdir$U.o long-options$U.o makepath$U.o modechange$U.o \
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
savedir$U.o stripslash$U.o userspec$U.o version-etc$U.o xgetcwd$U.o \
xmalloc$U.o xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o same$U.o \
save-cwd$U.o savedir$U.o stripslash$U.o userspec$U.o version-etc$U.o \
xgetcwd$U.o xmalloc$U.o xstrdup$U.o xstrtol$U.o xstrtoul$U.o \
xstrtoumax$U.o yesno$U.o
libfu_a_OBJECTS = $(am_libfu_a_OBJECTS)
AR = ar
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CFLAGS = @CFLAGS@
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(libfu_a_SOURCES)
HEADERS = $(noinst_HEADERS)
DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in TODO alloca.c \
chown.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 \
lstat.c malloc.c memcmp.c memcpy.c memset.c mkdir.c mktime.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 memset.c mkdir.c mktime.c \
mountlist.c obstack.c obstack.h realloc.c regex.c rename.c rmdir.c \
rpmatch.c stat.c stpcpy.c strcasecmp.c strdup.c strftime.c \
strncasecmp.c strndup.c strstr.c strtol.c strtoul.c strverscmp.c \
utime.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) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
.deps/backupfile.P .deps/basename.P .deps/chown.P .deps/closeout.P \
.deps/dirname.P .deps/error.P .deps/euidaccess.P .deps/exclude.P \
.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/fsusage.P \
.deps/ftruncate.P .deps/full-write.P .deps/getdate.P .deps/getgroups.P \
.deps/getline.P .deps/getopt.P .deps/getopt1.P .deps/group-member.P \
.deps/hash.P .deps/human.P .deps/idcache.P .deps/isdir.P .deps/lchown.P \
.deps/long-options.P .deps/lstat.P .deps/makepath.P .deps/malloc.P \
.deps/memcmp.P .deps/memcpy.P .deps/memset.P .deps/mkdir.P \
.deps/mktime.P .deps/modechange.P .deps/mountlist.P .deps/obstack.P \
.deps/dirname.P .deps/dup2.P .deps/error.P .deps/euidaccess.P \
.deps/exclude.P .deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P \
.deps/fsusage.P .deps/ftruncate.P .deps/full-write.P .deps/getdate.P \
.deps/getgroups.P .deps/getline.P .deps/getopt.P .deps/getopt1.P \
.deps/group-member.P .deps/hash.P .deps/human.P .deps/idcache.P \
.deps/isdir.P .deps/lchown.P .deps/long-options.P .deps/lstat.P \
.deps/makepath.P .deps/malloc.P .deps/memchr.P .deps/memcmp.P \
.deps/memcpy.P .deps/memset.P .deps/mkdir.P .deps/mktime.P \
.deps/modechange.P .deps/mountlist.P .deps/obstack.P \
.deps/path-concat.P .deps/posixtm.P .deps/quotearg.P .deps/realloc.P \
.deps/regex.P .deps/rename.P .deps/rmdir.P .deps/rpmatch.P \
.deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stat.P \
.deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P \
.deps/stripslash.P .deps/strncasecmp.P .deps/strndup.P .deps/strstr.P \
.deps/strtol.P .deps/strtoul.P .deps/strverscmp.P .deps/userspec.P \
.deps/utime.P .deps/version-etc.P .deps/xgetcwd.P .deps/xmalloc.P \
.deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
.deps/safe-read.P .deps/same.P .deps/save-cwd.P .deps/savedir.P \
.deps/stat.P .deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P \
.deps/strftime.P .deps/stripslash.P .deps/strncasecmp.P .deps/strndup.P \
.deps/strstr.P .deps/strtol.P .deps/strtoul.P .deps/strtoull.P \
.deps/strtoumax.P .deps/strverscmp.P .deps/userspec.P .deps/utime.P \
.deps/version-etc.P .deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P \
.deps/xstrtol.P .deps/xstrtoul.P .deps/xstrtoumax.P .deps/yesno.P
SOURCES = $(libfu_a_SOURCES)
OBJECTS = $(libfu_a_OBJECTS)
OBJECTS = $(am_libfu_a_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s .y
.SUFFIXES: .c .o .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile
@@ -200,12 +214,6 @@ distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
@@ -233,8 +241,10 @@ maintainer-clean-kr:
libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
-rm -f libfu.a
$(AR) cru libfu.a $(libfu_a_OBJECTS) $(libfu_a_LIBADD)
$(libfu_a_AR) libfu.a $(libfu_a_OBJECTS) $(libfu_a_LIBADD)
$(RANLIB) libfu.a
.c.o:
$(COMPILE) -c $<
addext_.c: addext.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/addext.c; then echo $(srcdir)/addext.c; else echo addext.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > addext_.c
alloca_.c: alloca.c $(ANSI2KNR)
@@ -251,6 +261,8 @@ closeout_.c: closeout.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/closeout.c; then echo $(srcdir)/closeout.c; else echo closeout.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > closeout_.c
dirname_.c: dirname.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dirname.c; then echo $(srcdir)/dirname.c; else echo dirname.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dirname_.c
dup2_.c: dup2.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dup2.c; then echo $(srcdir)/dup2.c; else echo dup2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dup2_.c
error_.c: error.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/error.c; then echo $(srcdir)/error.c; else echo error.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > error_.c
euidaccess_.c: euidaccess.c $(ANSI2KNR)
@@ -299,6 +311,8 @@ makepath_.c: makepath.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/makepath.c; then echo $(srcdir)/makepath.c; else echo makepath.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > makepath_.c
malloc_.c: malloc.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/malloc.c; then echo $(srcdir)/malloc.c; else echo malloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > malloc_.c
memchr_.c: memchr.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memchr.c; then echo $(srcdir)/memchr.c; else echo memchr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memchr_.c
memcmp_.c: memcmp.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/memcmp.c; then echo $(srcdir)/memcmp.c; else echo memcmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > memcmp_.c
memcpy_.c: memcpy.c $(ANSI2KNR)
@@ -333,6 +347,8 @@ rpmatch_.c: rpmatch.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/rpmatch.c; then echo $(srcdir)/rpmatch.c; else echo rpmatch.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > rpmatch_.c
safe-read_.c: safe-read.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/safe-read.c; then echo $(srcdir)/safe-read.c; else echo safe-read.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > safe-read_.c
same_.c: same.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/same.c; then echo $(srcdir)/same.c; else echo same.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > same_.c
save-cwd_.c: save-cwd.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/save-cwd.c; then echo $(srcdir)/save-cwd.c; else echo save-cwd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > save-cwd_.c
savedir_.c: savedir.c $(ANSI2KNR)
@@ -359,6 +375,10 @@ strtol_.c: strtol.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtol.c; then echo $(srcdir)/strtol.c; else echo strtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtol_.c
strtoul_.c: strtoul.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoul.c; then echo $(srcdir)/strtoul.c; else echo strtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoul_.c
strtoull_.c: strtoull.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoull.c; then echo $(srcdir)/strtoull.c; else echo strtoull.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoull_.c
strtoumax_.c: strtoumax.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoumax.c; then echo $(srcdir)/strtoumax.c; else echo strtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoumax_.c
strverscmp_.c: strverscmp.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strverscmp.c; then echo $(srcdir)/strverscmp.c; else echo strverscmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strverscmp_.c
userspec_.c: userspec.c $(ANSI2KNR)
@@ -377,27 +397,29 @@ xstrtol_.c: xstrtol.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtol.c; then echo $(srcdir)/xstrtol.c; else echo xstrtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtol_.c
xstrtoul_.c: xstrtoul.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoul.c; then echo $(srcdir)/xstrtoul.c; else echo xstrtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoul_.c
xstrtoumax_.c: xstrtoumax.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoumax.c; then echo $(srcdir)/xstrtoumax.c; else echo xstrtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoumax_.c
yesno_.c: yesno.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > yesno_.c
addext_.o alloca_.o argmatch_.o backupfile_.o basename_.o chown_.o \
closeout_.o dirname_.o error_.o euidaccess_.o exclude_.o fileblocks_.o \
filemode_.o fnmatch_.o fsusage_.o ftruncate_.o 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 memcmp_.o memcpy_.o memset_.o mkdir_.o mktime_.o \
modechange_.o mountlist_.o obstack_.o path-concat_.o posixtm_.o \
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o \
safe-read_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
strdup_.o strftime_.o stripslash_.o strncasecmp_.o strndup_.o strstr_.o \
strtol_.o strtoul_.o strverscmp_.o userspec_.o utime_.o version-etc_.o \
xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : \
$(ANSI2KNR)
closeout_.o dirname_.o dup2_.o error_.o euidaccess_.o exclude_.o \
fileblocks_.o filemode_.o fnmatch_.o fsusage_.o ftruncate_.o \
full-write_.o getdate_.o getgroups_.o 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 memset_.o mkdir_.o mktime_.o modechange_.o mountlist_.o \
obstack_.o path-concat_.o posixtm_.o quotearg_.o realloc_.o regex_.o \
rename_.o rmdir_.o rpmatch_.o safe-read_.o 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 \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
getdate..h: getdate.c
tags: TAGS
@@ -431,8 +453,6 @@ maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = lib
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -450,6 +470,7 @@ distdir: $(DISTFILES)
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
@@ -464,23 +485,23 @@ distclean-depend:
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
@echo '$(COMPILE) -c -o $@ $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@-cp .deps/$(*D)/$(*F).pp .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
>> .deps/$(*D)/$(*F).P; \
rm .deps/$(*D)/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@echo '$(LTCOMPILE) -c -o $@ $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
< .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \
tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
>> .deps/$(*D)/$(*F).P; \
rm -f .deps/$(*D)/$(*F).pp
info-am:
info: info-am
dvi-am:
@@ -516,7 +537,7 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-test -z "getdate..hgetdate.c$(BUILT_SOURCES)" || rm -f getdate..h getdate.c $(BUILT_SOURCES)
-test -z "getdate.c$(BUILT_SOURCES)" || rm -f getdate.c $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-kr mostlyclean-tags mostlyclean-depend \
mostlyclean-generic

66
lib/dup2.c Normal file
View File

@@ -0,0 +1,66 @@
/* Duplicate an open file descriptor to a specified file descriptor.
Copyright 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 Paul Eggert */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if HAVE_FCNTL_H
# include <fcntl.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef F_DUPFD
static int
dupfd (int fd, int desired_fd)
{
int duplicated_fd = dup (fd);
if (duplicated_fd < 0 || duplicated_fd == desired_fd)
return duplicated_fd;
else
{
int r = dupfd (fd, desired_fd);
int e = errno;
close (duplicated_fd);
errno = e;
return r;
}
}
#endif
int
dup2 (int fd, int desired_fd)
{
if (fd == desired_fd)
return fd;
close (desired_fd);
#ifdef F_DUPFD
return fcntl (fd, F_DUPFD, desired_fd);
#else
return dupfd (fd, desired_fd);
#endif
}

View File

@@ -48,6 +48,25 @@
# endif
#endif
#if !S_IRGRP
# define S_IRGRP (S_IRUSR >> 3)
#endif
#if !S_IWGRP
# define S_IWGRP (S_IWUSR >> 3)
#endif
#if !S_IXGRP
# define S_IXGRP (S_IXUSR >> 3)
#endif
#if !S_IROTH
# define S_IROTH (S_IRUSR >> 6)
#endif
#if !S_IWOTH
# define S_IWOTH (S_IWUSR >> 6)
#endif
#if !S_IXOTH
# define S_IXOTH (S_IXUSR >> 6)
#endif
#ifdef STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
@@ -93,22 +112,11 @@
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
#endif
/* Look at read, write, and execute bits in BITS and set
flags in CHARS accordingly. */
static void
rwx (short unsigned int bits, char *chars)
{
chars[0] = (bits & S_IRUSR) ? 'r' : '-';
chars[1] = (bits & S_IWUSR) ? 'w' : '-';
chars[2] = (bits & S_IXUSR) ? 'x' : '-';
}
/* Set the 's' and 't' flags in file attributes string CHARS,
according to the file mode BITS. */
static void
setst (short unsigned int bits, char *chars)
setst (mode_t bits, char *chars)
{
#ifdef S_ISUID
if (bits & S_ISUID)
@@ -157,7 +165,7 @@ setst (short unsigned int bits, char *chars)
'?' for any other file type. */
static char
ftypelet (long int bits)
ftypelet (mode_t bits)
{
#ifdef S_ISBLK
if (S_ISBLK (bits))
@@ -216,12 +224,18 @@ ftypelet (long int bits)
is given as an argument. */
void
mode_string (short unsigned int mode, char *str)
mode_string (mode_t mode, char *str)
{
str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
rwx ((mode & 0007) << 6, &str[7]);
str[0] = ftypelet (mode);
str[1] = mode & S_IRUSR ? 'r' : '-';
str[2] = mode & S_IWUSR ? 'w' : '-';
str[3] = mode & S_IXUSR ? 'x' : '-';
str[4] = mode & S_IRGRP ? 'r' : '-';
str[5] = mode & S_IWGRP ? 'w' : '-';
str[6] = mode & S_IXGRP ? 'x' : '-';
str[7] = mode & S_IROTH ? 'r' : '-';
str[8] = mode & S_IWOTH ? 'w' : '-';
str[9] = mode & S_IXOTH ? 'x' : '-';
setst (mode, str);
}

View File

@@ -1,9 +1,19 @@
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
#ifndef FILEMODE_H_
void mode_string PARAMS ((short unsigned int mode, char *str));
# if HAVE_CONFIG_H
# include <config.h>
# endif
# include <sys/types.h>
# ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
# endif
void mode_string PARAMS ((mode_t mode, char *str));
#endif

View File

@@ -28,6 +28,10 @@
#include <stdio.h>
#include <ctype.h>
#if HAVE_STDLIB_H
# include <stdlib.h> /* for `free'; used by Bison 1.27 */
#endif
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
@@ -706,7 +710,7 @@ LookupWord (buff)
/* Make it lowercase. */
for (p = buff; *p; p++)
if (ISUPPER (*p))
if (ISUPPER ((unsigned char) *p))
*p = tolower (*p);
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
@@ -787,7 +791,7 @@ LookupWord (buff)
}
/* Military timezones. */
if (buff[1] == '\0' && ISALPHA (*buff))
if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff))
{
for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0)
@@ -818,7 +822,7 @@ LookupWord (buff)
static int
yylex ()
{
register char c;
register unsigned char c;
register char *p;
char buff[20];
int Count;
@@ -826,7 +830,7 @@ yylex ()
for (;;)
{
while (ISSPACE (*yyInput))
while (ISSPACE ((unsigned char) *yyInput))
yyInput++;
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
@@ -949,6 +953,12 @@ get_date (const char *p, const time_t *now)
tm.tm_hour += yyRelHour;
tm.tm_min += yyRelMinutes;
tm.tm_sec += yyRelSeconds;
/* Let mktime deduce tm_isdst if we have an absolute timestamp,
or if the relative timestamp mentions days, months, or years. */
if (yyHaveDate | yyHaveDay | yyHaveTime | yyRelDay | yyRelMonth | yyRelYear)
tm.tm_isdst = -1;
tm0 = tm;
Start = mktime (&tm);

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1995, 1997, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,10 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
# endif
# endif
# if __GLIBC__ < 2
int
getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream));
int
getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream));
# endif
#endif /* not GETLINE_H_ */

View File

@@ -41,6 +41,8 @@ struct group *getgrent ();
# include <strings.h>
#endif
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
/* Like `getgroups', but for user USERNAME instead of for the current
process. Store at most MAXCOUNT group IDs in the GROUPLIST array.
If GID is not -1, store it first (if possible). GID should be the
@@ -64,14 +66,17 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid)
setgrent ();
while ((grp = getgrent ()) != 0)
for (cp = grp->gr_mem; *cp; ++cp)
if (!strcmp (username, *cp))
{
for (cp = grp->gr_mem; *cp; ++cp)
{
int n;
if ( ! STREQ (username, *cp))
continue;
/* See if this group number is already on the list. */
for (n = 0; n < count; ++n)
if (grouplist[n] == grp->gr_gid)
if (grouplist && grouplist[n] == grp->gr_gid)
break;
/* If it's a new group number, then try to add it to the list. */
@@ -89,6 +94,8 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char *username, gid_t gid)
count++;
}
}
}
endgrent ();
return count;
}

View File

@@ -23,10 +23,6 @@
# include <config.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <stdio.h>
@@ -34,6 +30,12 @@
# include <limits.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
@@ -54,7 +56,7 @@ char *getenv ();
#include <argmatch.h>
#include <error.h>
#include <xstrtoul.h>
#include <xstrtol.h>
#include "human.h"
@@ -74,7 +76,7 @@ static const char suffixes[] =
/* Convert N to a human readable format in BUF.
N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must
be positive.
be nonnegative.
If OUTPUT_BLOCK_SIZE is positive, use units of OUTPUT_BLOCK_SIZE in
the output number. OUTPUT_BLOCK_SIZE must be a multiple of
@@ -99,7 +101,7 @@ human_readable (uintmax_t n, char *buf,
uintmax_t amt;
int base;
int to_block_size;
int tenths;
int tenths = 0;
int power;
char *p;
@@ -107,7 +109,7 @@ human_readable (uintmax_t n, char *buf,
1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05;
2 means adjusted N == AMT.TENTHS + 0.05;
3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */
int rounding;
int rounding = 0;
if (output_block_size < 0)
{
@@ -134,7 +136,6 @@ human_readable (uintmax_t n, char *buf,
{
int multiplier = from_block_size / to_block_size;
amt = n * multiplier;
tenths = rounding = 0;
if (amt / multiplier != n)
{
@@ -170,6 +171,8 @@ human_readable (uintmax_t n, char *buf,
return buf;
}
}
else if (from_block_size == 0)
amt = 0;
else
{
int divisor = to_block_size / from_block_size;

View File

@@ -1,6 +1,14 @@
#ifndef HUMAN_H_
# define HUMAN_H_ 1
# if HAVE_CONFIG_H
# include <config.h>
# endif
# if HAVE_INTTYPES_H
# include <inttypes.h>
# endif
/* A conservative bound on the maximum length of a human-readable string.
The output can be the product of the largest uintmax_t and the largest int,
so add their sizes before converting to a bound on digits. */

View File

@@ -71,16 +71,34 @@ extern int errno;
# endif
#endif
#ifndef S_ISUID
# define S_ISUID 04000
#endif
#ifndef S_ISGID
# define S_ISGID 02000
#endif
#ifndef S_ISVTX
# define S_ISVTX 01000
#endif
#ifndef S_IRUSR
# define S_IRUSR 0200
#endif
#ifndef S_IWUSR
# define S_IWUSR 0200
#endif
#ifndef S_IXUSR
# define S_IXUSR 0100
#endif
#ifndef S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif
#define WX_USR (S_IWUSR | S_IXUSR)
/* Include this before libintl.h so we get our definition of PARAMS. */
#include "makepath.h"
#if HAVE_LOCALE_H
# include <locale.h>
#endif
@@ -98,7 +116,6 @@ typedef int gid_t;
#endif
#include "save-cwd.h"
#include "makepath.h"
#include "error.h"
void strip_trailing_slashes ();
@@ -145,6 +162,7 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
if (!created_dir)
{
struct stat stats;
int saved_errno = errno;
/* The mkdir and stat calls below may appear to be reversed.
They are not. It is important to call mkdir first and then to
@@ -156,7 +174,7 @@ make_dir (const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
if (stat (dir, &stats))
{
error (0, errno, _("cannot create directory `%s'"), dirpath);
error (0, saved_errno, _("cannot create directory `%s'"), dirpath);
fail = 1;
}
else if (!S_ISDIR (stats.st_mode))
@@ -223,7 +241,7 @@ make_path (const char *argpath,
char *dirpath;
/* Temporarily relax umask in case it's overly restrictive. */
int oldmask = umask (0);
mode_t oldmask = umask (0);
/* Make a copy of ARGPATH that we can scribble NULs on. */
dirpath = (char *) alloca (strlen (argpath) + 1);
@@ -235,9 +253,9 @@ make_path (const char *argpath,
their owners, we need to fix their permissions after making them. */
if (((parent_mode & WX_USR) != WX_USR)
|| ((owner != (uid_t) -1 || group != (gid_t) -1)
&& (parent_mode & 07000) != 0))
&& (parent_mode & (S_ISUID | S_ISGID | S_ISVTX)) != 0))
{
tmp_mode = 0700;
tmp_mode = S_IRWXU;
re_protect = 1;
}
else
@@ -363,7 +381,8 @@ make_path (const char *argpath,
retval = 1;
}
/* chown may have turned off some permission bits we wanted. */
if ((mode & 07000) != 0 && chmod (basename_dir, mode))
if ((mode & (S_ISUID | S_ISGID | S_ISVTX))
&& chmod (basename_dir, mode))
{
error (0, errno, _("cannot chmod %s"), dirpath);
retval = 1;

View File

@@ -34,6 +34,16 @@ extern int errno;
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_IRWXU
# define S_IRWXU 0700
#endif
#ifndef S_IRWXG
# define S_IRWXG 0070
#endif
#ifndef S_IRWXO
# define S_IRWXO 0007
#endif
/* mkdir adapted from GNU tar. */
/* Make directory DPATH, with permission mode DMODE.
@@ -48,9 +58,10 @@ extern int errno;
subroutine didn't return EEXIST. It does now. */
int
mkdir (const char *dpath, int dmode)
mkdir (const char *dpath, mode_t dmode)
{
pid_t cpid;
mode_t mode;
int status;
struct stat statbuf;
@@ -75,8 +86,9 @@ mkdir (const char *dpath, int dmode)
process is going away anyway, we zap its umask.
This won't suffice to set SUID, SGID, etc. on this
directory, so the parent process calls chmod afterward. */
status = umask (0); /* Get current umask. */
umask (status | (0777 & ~dmode)); /* Set for mkdir. */
mode = umask (0); /* Get current umask. */
/* Set for mkdir. */
umask (mode | ((S_IRWXU | S_IRWXG | S_IRWXO) & ~dmode));
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
_exit (1);

View File

@@ -28,9 +28,9 @@
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "modechange.h"
#include <sys/stat.h>
#include "xstrtol.h"
#if STDC_HEADERS
# include <stdlib.h>
@@ -50,34 +50,65 @@ char *malloc ();
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISUID
# define S_ISUID 04000
#endif
#ifndef S_ISGID
# define S_ISGID 04000
#endif
#ifndef S_ISVTX
# define S_ISVTX 01000
#endif
#ifndef S_IRUSR
# define S_IRUSR 0400
#endif
#ifndef S_IWUSR
# define S_IWUSR 0200
#endif
#ifndef S_IXUSR
# define S_IXUSR 0100
#endif
#ifndef S_IRGRP
# define S_IRGRP 0040
#endif
#ifndef S_IWGRP
# define S_IWGRP 0020
#endif
#ifndef S_IXGRP
# define S_IXGRP 0010
#endif
#ifndef S_IROTH
# define S_IROTH 0004
#endif
#ifndef S_IWOTH
# define S_IWOTH 0002
#endif
#ifndef S_IXOTH
# define S_IXOTH 0001
#endif
#ifndef S_IRWXU
# define S_IRWXU 0700
#endif
#ifndef S_IRWXG
# define S_IRWXG 0070
#endif
#ifndef S_IRWXO
# define S_IRWXO 0007
#endif
/* All the mode bits that can be affected by chmod. */
#define CHMOD_MODE_BITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
/* Return newly allocated memory to hold one element of type TYPE. */
#define talloc(type) ((type *) malloc (sizeof (type)))
#define isodigit(c) ((c) >= '0' && (c) <= '7')
/* Return a positive integer containing the value of the ASCII
octal number S. If S is not an octal number, return -1. */
static int
oatoi (const char *s)
{
register int i;
if (*s == 0)
return -1;
for (i = 0; isodigit (*s); ++s)
i = i * 8 + *s - '0';
if (*s)
return -1;
return i;
}
/* Create a mode_change entry with the specified `=ddd'-style
mode change operation, where NEW_MODE is `ddd'. Return the
new entry, or NULL upon failure. */
static struct mode_change *
make_node_op_equals (int new_mode)
make_node_op_equals (mode_t new_mode)
{
struct mode_change *p;
p = talloc (struct mode_change);
@@ -87,7 +118,7 @@ make_node_op_equals (int new_mode)
p->op = '=';
p->flags = 0;
p->value = new_mode;
p->affected = 07777; /* Affect all permissions. */
p->affected = CHMOD_MODE_BITS; /* Affect all permissions. */
return p;
}
@@ -126,21 +157,21 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
{
struct mode_change *head; /* First element of the linked list. */
struct mode_change *tail; /* An element of the linked list. */
int i; /* General purpose temporary. */
int umask_value; /* The umask value (surprise). */
unsigned long mode_value; /* The mode value, if octal. */
char *string_end; /* Pointer to end of parsed value. */
mode_t umask_value; /* The umask value (surprise). */
head = NULL;
#ifdef lint
tail = NULL;
#endif
i = oatoi (mode_string);
if (i >= 0)
if (xstrtoul (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK)
{
struct mode_change *p;
if (i > 07777)
if (mode_value > CHMOD_MODE_BITS)
return MODE_INVALID;
p = make_node_op_equals (i);
p = make_node_op_equals ((mode_t) mode_value);
if (p == NULL)
return MODE_MEMORY_EXHAUSTED;
mode_append_entry (&head, &tail, p);
@@ -155,9 +186,9 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
do
{
/* Which bits in the mode are operated on. */
unsigned short affected_bits = 0;
mode_t affected_bits = 0;
/* `affected_bits' modified by umask. */
unsigned short affected_masked;
mode_t affected_masked;
/* Operators to actually use umask on. */
unsigned ops_to_mask = 0;
@@ -170,16 +201,16 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
switch (*mode_string)
{
case 'u':
affected_bits |= 04700;
affected_bits |= S_ISUID | S_IRWXU;
break;
case 'g':
affected_bits |= 02070;
affected_bits |= S_ISGID | S_IRWXG;
break;
case 'o':
affected_bits |= 01007;
affected_bits |= S_ISVTX | S_IRWXO;
break;
case 'a':
affected_bits |= 07777;
affected_bits |= CHMOD_MODE_BITS;
break;
default:
goto no_more_affected;
@@ -193,7 +224,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
else
{
who_specified_p = 0;
affected_bits = 07777;
affected_bits = CHMOD_MODE_BITS;
ops_to_mask = masked_ops;
}
@@ -238,31 +269,34 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
switch (*mode_string)
{
case 'r':
change->value |= 00444 & affected_masked;
change->value |= ((S_IRUSR | S_IRGRP | S_IROTH)
& affected_masked);
break;
case 'w':
change->value |= 00222 & affected_masked;
change->value |= ((S_IWUSR | S_IWGRP | S_IWOTH)
& affected_masked);
break;
case 'X':
change->flags |= MODE_X_IF_ANY_X;
/* Fall through. */
case 'x':
change->value |= 00111 & affected_masked;
change->value |= ((S_IXUSR | S_IXGRP | S_IXOTH)
& affected_masked);
break;
case 's':
/* Set the setuid/gid bits if `u' or `g' is selected. */
change->value |= 06000 & affected_masked;
change->value |= (S_ISUID | S_ISGID) & affected_masked;
break;
case 't':
/* Set the "save text image" bit if `o' is selected. */
change->value |= 01000 & affected_masked;
change->value |= S_ISVTX & affected_masked;
break;
case 'u':
/* Set the affected bits to the value of the `u' bits
on the same file. */
if (change->value)
goto invalid;
change->value = 00700;
change->value = S_IRWXU;
change->flags |= MODE_COPY_EXISTING;
break;
case 'g':
@@ -270,7 +304,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
on the same file. */
if (change->value)
goto invalid;
change->value = 00070;
change->value = S_IRWXG;
change->flags |= MODE_COPY_EXISTING;
break;
case 'o':
@@ -278,7 +312,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
on the same file. */
if (change->value)
goto invalid;
change->value = 00007;
change->value = S_IRWXO;
change->flags |= MODE_COPY_EXISTING;
break;
default:
@@ -313,7 +347,7 @@ mode_create_from_ref (const char *ref_file)
change->op = '=';
change->flags = 0;
change->affected = 07777;
change->affected = CHMOD_MODE_BITS;
change->value = ref_stats.st_mode;
change->next = NULL;
@@ -325,13 +359,13 @@ mode_create_from_ref (const char *ref_file)
change affects it even if no execute bits were set in OLDMODE.
The returned value has the S_IFMT bits cleared. */
unsigned short
mode_adjust (unsigned int oldmode, const struct mode_change *changes)
mode_t
mode_adjust (mode_t oldmode, const struct mode_change *changes)
{
unsigned short newmode; /* The adjusted mode and one operand. */
unsigned short value; /* The other operand. */
mode_t newmode; /* The adjusted mode and one operand. */
mode_t value; /* The other operand. */
newmode = oldmode & 07777;
newmode = oldmode & CHMOD_MODE_BITS;
for (; changes; changes = changes->next)
{
@@ -341,15 +375,21 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes)
the mask `changes->value'. */
value = newmode & changes->value;
if (changes->value & 00700)
if (changes->value & S_IRWXU)
/* Copy `u' permissions onto `g' and `o'. */
value |= (value >> 3) | (value >> 6);
else if (changes->value & 00070)
value |= ((value & S_IRUSR ? S_IRGRP | S_IROTH : 0)
| (value & S_IWUSR ? S_IWGRP | S_IROTH : 0)
| (value & S_IXUSR ? S_IXGRP | S_IXOTH : 0));
else if (changes->value & S_IRWXG)
/* Copy `g' permissions onto `u' and `o'. */
value |= (value << 3) | (value >> 3);
value |= ((value & S_IRGRP ? S_IRUSR | S_IROTH : 0)
| (value & S_IWGRP ? S_IWUSR | S_IROTH : 0)
| (value & S_IXGRP ? S_IXUSR | S_IXOTH : 0));
else
/* Copy `o' permissions onto `u' and `g'. */
value |= (value << 3) | (value << 6);
value |= ((value & S_IROTH ? S_IRUSR | S_IRGRP : 0)
| (value & S_IWOTH ? S_IWUSR | S_IRGRP : 0)
| (value & S_IXOTH ? S_IXUSR | S_IXGRP : 0));
/* In order to change only `u', `g', or `o' permissions,
or some combination thereof, clear unselected bits.
@@ -365,8 +405,9 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes)
directory and no execute bits are already set. */
if ((changes->flags & MODE_X_IF_ANY_X)
&& !S_ISDIR (oldmode)
&& (newmode & 00111) == 0)
value &= ~00111; /* Clear the execute bits. */
&& (newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
/* Clear the execute bits. */
value &= ~ (S_IXUSR | S_IXGRP | S_IXOTH);
}
switch (changes->op)

View File

@@ -20,6 +20,12 @@
#if ! defined MODECHANGE_H_
# define MODECHANGE_H_
# if HAVE_CONFIG_H
# include <config.h>
# endif
# include <sys/types.h>
/* Affect the execute bits only if at least one execute bit is set already,
or if the file is a directory. */
# define MODE_X_IF_ANY_X 01
@@ -33,8 +39,8 @@ struct mode_change
{
char op; /* One of "=+-". */
char flags; /* Special operations. */
unsigned short affected; /* Set for u/g/o/s/s/t, if to be affected. */
unsigned short value; /* Bits to add/remove. */
mode_t affected; /* Set for u/g/o/s/s/t, if to be affected. */
mode_t value; /* Bits to add/remove. */
struct mode_change *next; /* Link to next change in list. */
};
@@ -59,7 +65,7 @@ struct mode_change
struct mode_change *mode_compile PARAMS ((const char *, unsigned));
struct mode_change *mode_create_from_ref PARAMS ((const char *));
unsigned short mode_adjust PARAMS ((unsigned, const struct mode_change *));
mode_t mode_adjust PARAMS ((mode_t, const struct mode_change *));
void mode_free PARAMS ((struct mode_change *));
#endif

View File

@@ -1,5 +1,5 @@
/* readtokens.c -- Functions for reading tokens from an input stream.
Copyright (C) 1990-1991 Jim Meyering.
Copyright (C) 1990-1991, 1999 Jim Meyering.
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
@@ -77,11 +77,10 @@ init_tokenbuffer (tokenbuffer)
and on files that aren't newline-terminated. */
long
readtoken (stream, delim, n_delim, tokenbuffer)
FILE *stream;
const char *delim;
int n_delim;
token_buffer *tokenbuffer;
readtoken (FILE *stream,
const char *delim,
int n_delim,
token_buffer *tokenbuffer)
{
char *p;
int c, i, n;
@@ -164,14 +163,12 @@ readtoken (stream, delim, n_delim, tokenbuffer)
%%% realloc() of `tokens' just before returning? */
int
readtokens (stream, projected_n_tokens, delim, n_delim,
tokens_out, token_lengths)
FILE *stream;
int projected_n_tokens;
const char *delim;
int n_delim;
char ***tokens_out;
long **token_lengths;
readtokens (FILE *stream,
int projected_n_tokens,
const char *delim,
int n_delim,
char ***tokens_out,
long **token_lengths)
{
token_buffer tb, *token = &tb;
int token_length;

View File

@@ -66,13 +66,16 @@ read_utmp (const char *filename, int *n_entries, STRUCT_UTMP **utmp_buf)
STRUCT_UTMP *u;
STRUCT_UTMP *utmp = NULL;
if (utmpname (filename))
return 1;
/* Ignore the return value for now.
Solaris' utmpname returns 1 upon success -- which is contrary
to what the GNU libc version does. In addition, older GNU libc
versions are actually void. */
UTMP_NAME_FUNCTION (filename);
setutent ();
SET_UTMP_ENT ();
n_read = 0;
while ((u = getutent ()) != NULL)
while ((u = GET_UTMP_ENT ()) != NULL)
{
++n_read;
utmp = (STRUCT_UTMP *) realloc (utmp, n_read * sizeof (STRUCT_UTMP));
@@ -81,7 +84,7 @@ read_utmp (const char *filename, int *n_entries, STRUCT_UTMP **utmp_buf)
utmp[n_read - 1] = *u;
}
endutent ();
END_UTMP_ENT ();
*n_entries = n_read;
*utmp_buf = utmp;

View File

@@ -34,10 +34,18 @@
# include <utmpx.h>
# define UTMP_STRUCT_NAME utmpx
# define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_tv.tv_sec)
# define SET_UTMP_ENT setutxent
# define GET_UTMP_ENT getutxent
# define END_UTMP_ENT endutxent
# define UTMP_NAME_FUNCTION utmpxname
# else
# include <utmp.h>
# define UTMP_STRUCT_NAME utmp
# define UT_TIME_MEMBER(UT_PTR) ((UT_PTR)->ut_time)
# define SET_UTMP_ENT setutent
# define GET_UTMP_ENT getutent
# define END_UTMP_ENT endutent
# define UTMP_NAME_FUNCTION utmpname
# endif
typedef struct UTMP_STRUCT_NAME STRUCT_UTMP;

View File

@@ -2,7 +2,7 @@
version 0.12.
(Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.)
Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -254,6 +254,12 @@ init_syntax_once ()
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
#ifdef _tolower
# define TOLOWER(c) _tolower(c)
#else
# define TOLOWER(c) tolower(c)
#endif
#ifndef NULL
# define NULL (void *)0
#endif
@@ -5628,7 +5634,7 @@ regcomp (preg, pattern, cflags)
/* Map uppercase characters to corresponding lowercase ones. */
for (i = 0; i < CHAR_SET_SIZE; i++)
preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : i;
}
else
preg->translate = NULL;

75
lib/same.c Normal file
View File

@@ -0,0 +1,75 @@
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "same.h"
#include "dirname.h"
#include "error.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
#ifndef HAVE_DECL_FREE
void free ();
#endif
char *base_name PARAMS ((char const *));
#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
/* Return nonzero if SOURCE and DEST point to the same name in the same
directory. */
int
same_name (const char *source, const char *dest)
{
struct stat source_dir_stats;
struct stat dest_dir_stats;
char *source_dirname, *dest_dirname;
source_dirname = dir_name (source);
dest_dirname = dir_name (dest);
if (source_dirname == NULL || dest_dirname == NULL)
error (1, 0, _("virtual memory exhausted"));
if (stat (source_dirname, &source_dir_stats))
{
/* Shouldn't happen. */
error (1, errno, "%s", source_dirname);
}
if (stat (dest_dirname, &dest_dir_stats))
{
/* Shouldn't happen. */
error (1, errno, "%s", dest_dirname);
}
free (source_dirname);
free (dest_dirname);
return (SAME_INODE (source_dir_stats, dest_dir_stats)
&& STREQ (base_name (source), base_name (dest)));
}

19
lib/same.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef SAME_H_
# define SAME_H_ 1
# 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
int
same_name PARAMS ((const char *source, const char *dest));
#endif /* SAME_H_ */

View File

@@ -1,7 +1,7 @@
/* strtol - Convert string representation of a number into an integer value.
Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
/* Convert string representation of a number into an integer value.
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 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.
Library. Bugs can be reported to bug-glibc@gnu.org.
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
@@ -54,7 +54,7 @@ extern int errno;
# include "../locale/localeinfo.h"
#endif
/* Nonzero if we are defining `strtoul' or `strtouq', operating on
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
unsigned integers. */
#ifndef UNSIGNED
# define UNSIGNED 0
@@ -64,72 +64,154 @@ extern int errno;
#endif
/* Determine the name. */
#if UNSIGNED
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstouq
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
# if UNSIGNED
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol __wcstoull_l
# else
# define strtol __wcstoul_l
# endif
# else
# define strtol wcstoul
# ifdef QUAD
# define strtol __strtoull_l
# else
# define strtol __strtoul_l
# endif
# endif
# else
# ifdef QUAD
# define strtol strtouq
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol __wcstoll_l
# else
# define strtol __wcstol_l
# endif
# else
# define strtol strtoul
# ifdef QUAD
# define strtol __strtoll_l
# else
# define strtol __strtol_l
# endif
# endif
# endif
#else
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstoq
# if UNSIGNED
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstoull
# else
# define strtol wcstoul
# endif
# else
# define strtol wcstol
# ifdef QUAD
# define strtol strtoull
# else
# define strtol strtoul
# endif
# endif
# else
# ifdef QUAD
# define strtol strtoq
# ifdef USE_WIDE_CHAR
# ifdef QUAD
# define strtol wcstoll
# else
# define strtol wcstol
# endif
# else
# ifdef QUAD
# define strtol strtoll
# endif
# endif
# endif
#endif
/* If QUAD is defined, we are defining `strtoq' or `strtouq',
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
operating on `long long int's. */
#ifdef QUAD
# define LONG long long
# undef LONG_MIN
# define LONG_MIN LONG_LONG_MIN
# undef LONG_MAX
# define LONG_MAX LONG_LONG_MAX
# undef ULONG_MAX
# define ULONG_MAX ULONG_LONG_MAX
# define STRTOL_LONG_MIN LONG_LONG_MIN
# define STRTOL_LONG_MAX LONG_LONG_MAX
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
/* The extra casts work around common compiler bugs,
e.g. Cray C 5.0.3.0 when t == time_t. */
# ifndef TYPE_SIGNED
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
# endif
# ifndef TYPE_MINIMUM
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
: (t) 0))
# endif
# ifndef TYPE_MAXIMUM
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
# endif
# ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
# endif
# ifndef LONG_LONG_MAX
# define LONG_LONG_MAX TYPE_MAXIMUM (long long int)
# endif
# ifndef LONG_LONG_MIN
# define LONG_LONG_MIN TYPE_MINIMUM (long long int)
# endif
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
/* Work around gcc bug with using this constant. */
static const unsigned long long int maxquad = ULONG_LONG_MAX;
# undef ULONG_MAX
# define ULONG_MAX maxquad
# undef STRTOL_ULONG_MAX
# define STRTOL_ULONG_MAX maxquad
# endif
#else
# define LONG long
#ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
# ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
# endif
# ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
# endif
# define STRTOL_LONG_MIN LONG_MIN
# define STRTOL_LONG_MAX LONG_MAX
# define STRTOL_ULONG_MAX ULONG_MAX
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
/* We use this code also for the extended locale handling where the
function gets as an additional argument the locale which has to be
used. To access the values we have to redefine the _NL_CURRENT
macro. */
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
# undef _NL_CURRENT
# define _NL_CURRENT(category, item) \
(current->values[_NL_ITEM_INDEX (item)].string)
# define LOCALE_PARAM , loc
# define LOCALE_PARAM_DECL __locale_t loc;
#else
# define LOCALE_PARAM
# define LOCALE_PARAM_DECL
#endif
#if defined _LIBC || defined HAVE_WCHAR_H
# include <wchar.h>
#endif
#ifdef USE_WIDE_CHAR
# include <wchar.h>
# include <wctype.h>
# define L_(Ch) L##Ch
# define UCHAR_TYPE wint_t
# define STRING_TYPE wchar_t
# define ISSPACE(Ch) iswspace (Ch)
# define ISALPHA(Ch) iswalpha (Ch)
# define TOUPPER(Ch) towupper (Ch)
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
# define ISSPACE(Ch) __iswspace_l ((Ch), loc)
# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
# define TOUPPER(Ch) __towupper_l ((Ch), loc)
# else
# define ISSPACE(Ch) iswspace (Ch)
# define ISALPHA(Ch) iswalpha (Ch)
# define TOUPPER(Ch) towupper (Ch)
# endif
#else
# if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
# define IN_CTYPE_DOMAIN(c) 1
# else
# define IN_CTYPE_DOMAIN(c) isascii(c)
@@ -137,12 +219,20 @@ extern int errno;
# define L_(Ch) Ch
# define UCHAR_TYPE unsigned char
# define STRING_TYPE char
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
# define ISSPACE(Ch) __isspace_l ((Ch), loc)
# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
# define TOUPPER(Ch) __toupper_l ((Ch), loc)
# else
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
# endif
#endif
#ifdef __STDC__
/* For compilers which are ansi but don't define __STDC__, like SGI
Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */
#if defined (__STDC__) || defined (PROTOTYPES)
# define INTERNAL(X) INTERNAL1(X)
# define INTERNAL1(X) __##X##_internal
# define WEAKNAME(X) WEAKNAME1(X)
@@ -156,6 +246,7 @@ extern int errno;
#endif
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
If BASE is 0 the base is determined by the presence of a leading
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
@@ -164,11 +255,12 @@ extern int errno;
one converted is stored in *ENDPTR. */
INT
INTERNAL (strtol) (nptr, endptr, base, group)
INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
const STRING_TYPE *nptr;
STRING_TYPE **endptr;
int base;
int group;
LOCALE_PARAM_DECL
{
int negative;
register unsigned LONG int cutoff;
@@ -180,8 +272,11 @@ INTERNAL (strtol) (nptr, endptr, base, group)
int overflow;
#ifdef USE_NUMBER_GROUPING
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
struct locale_data *current = loc->__locales[LC_NUMERIC];
# endif
/* The thousands character of the current locale. */
wchar_t thousands;
wchar_t thousands = L'\0';
/* The numeric grouping specification of the current locale,
in the format described in <locale.h>. */
const char *grouping;
@@ -194,9 +289,11 @@ INTERNAL (strtol) (nptr, endptr, base, group)
else
{
/* Figure out the thousands separator character. */
if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
# if defined _LIBC || defined _HAVE_BTOWC
thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
if (thousands == WEOF)
thousands = L'\0';
# endif
if (thousands == L'\0')
grouping = NULL;
}
@@ -233,23 +330,19 @@ INTERNAL (strtol) (nptr, endptr, base, group)
else
negative = 0;
if (base == 16 && s[0] == L_('0') && TOUPPER (s[1]) == L_('X'))
s += 2;
/* If BASE is zero, figure it out ourselves. */
if (base == 0)
if (*s == L_('0'))
{
if (TOUPPER (s[1]) == L_('X'))
{
s += 2;
base = 16;
}
else
base = 8;
}
else
base = 10;
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
if (*s == L_('0'))
{
if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
{
s += 2;
base = 16;
}
else if (base == 0)
base = 8;
}
else if (base == 0)
base = 10;
/* Save the pointer so we can check later if anything happened. */
save = s;
@@ -273,8 +366,8 @@ INTERNAL (strtol) (nptr, endptr, base, group)
#endif
end = NULL;
cutoff = ULONG_MAX / (unsigned LONG int) base;
cutlim = ULONG_MAX % (unsigned LONG int) base;
cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
overflow = 0;
i = 0;
@@ -314,25 +407,23 @@ INTERNAL (strtol) (nptr, endptr, base, group)
`unsigned LONG int', but outside the range of `LONG int'. */
if (overflow == 0
&& i > (negative
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
: (unsigned LONG int) LONG_MAX))
? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
: (unsigned LONG int) STRTOL_LONG_MAX))
overflow = 1;
#else
overflow |= negative;
#endif
if (overflow)
{
__set_errno (ERANGE);
#if UNSIGNED
return ULONG_MAX;
return STRTOL_ULONG_MAX;
#else
return negative ? LONG_MIN : LONG_MAX;
return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
#endif
}
/* Return the result of the appropriate sign. */
return (negative ? -i : i);
return negative ? -i : i;
noconv:
/* We must handle a special case here: the base is 0 or 16 and the
@@ -340,12 +431,14 @@ noconv:
hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */
if (endptr != NULL)
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
&& save[-2] == L_('0'))
*endptr = (STRING_TYPE *) &save[-1];
else
/* There was no number to convert. */
*endptr = (STRING_TYPE *) nptr;
{
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
&& save[-2] == L_('0'))
*endptr = (STRING_TYPE *) &save[-1];
else
/* There was no number to convert. */
*endptr = (STRING_TYPE *) nptr;
}
return 0L;
}
@@ -369,10 +462,11 @@ INT
#ifdef weak_function
weak_function
#endif
strtol (nptr, endptr, base)
strtol (nptr, endptr, base LOCALE_PARAM)
const STRING_TYPE *nptr;
STRING_TYPE **endptr;
int base;
LOCALE_PARAM_DECL
{
return INTERNAL (strtol) (nptr, endptr, base, 0);
return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
}

27
lib/strtoull.c Normal file
View File

@@ -0,0 +1,27 @@
/* Function to parse an `unsigned long long int' from text.
Copyright (C) 1995, 1996, 1997, 1999 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@gnu.org.
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. */
#define QUAD 1
#include "strtoul.c"
#ifdef _LIBC
strong_alias (__strtoull_internal, __strtouq_internal)
weak_alias (strtoull, strtouq)
#endif

58
lib/strtoumax.c Normal file
View File

@@ -0,0 +1,58 @@
/* Convert string representation of a number into an uintmax_t value.
Copyright 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 Paul Eggert. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifndef PARAMS
# if defined PROTOTYPES || defined __STDC__
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
#if HAVE_UNSIGNED_LONG_LONG && ! HAVE_STRTOULL
unsigned long long strtoull PARAMS ((char const *, char **, int));
#endif
uintmax_t
strtoumax (char const *ptr, char **endptr, int base)
{
#define USE_IF_EQUIVALENT(function) \
if (sizeof (uintmax_t) == sizeof function (ptr, endptr, base)) \
return function (ptr, endptr, base);
#if HAVE_UNSIGNED_LONG_LONG
USE_IF_EQUIVALENT (strtoull)
#endif
USE_IF_EQUIVALENT (strtoul)
abort ();
}

View File

@@ -54,7 +54,7 @@ utime_null (const char *file)
int status = 0;
struct stat sb;
fd = open (file, O_RDWR, 0666);
fd = open (file, O_RDWR);
if (fd < 0
|| fstat (fd, &sb) < 0
|| safe_read (fd, &c, sizeof (char)) < 0

View File

@@ -35,13 +35,12 @@ version_etc (FILE *stream,
const char *version, const char *authors)
{
fprintf (stream, "%s (%s) %s\n", command_name, package, version);
fprintf (stream, _("Written by %s.\n"), authors);
fputs (_("\
\n\
Copyright (C) 1999 Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
\n\
"
), stream);
fprintf (stream, _("Written by %s.\n"), authors);
}

View File

@@ -70,7 +70,7 @@ xalloc_fail (void)
{
if (xalloc_fail_func)
(*xalloc_fail_func) ();
error (xalloc_exit_failure, 0, "%s", xalloc_msg_memory_exhausted);
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
}
/* Allocate N bytes of memory dynamically, with error checking. */

View File

@@ -1,5 +1,5 @@
/* xstrtod.c - error-checking interface to strtod
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -68,4 +68,3 @@ xstrtod (str, ptr, result)
*result = val;
return fail;
}

View File

@@ -1,5 +1,5 @@
/* A more useful interface to strtol.
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
Copyright 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,12 @@
# include <config.h>
#endif
#ifndef __strtol
# define __strtol strtol
# define __strtol_t long int
# define __xstrtol xstrtol
#endif
/* Some pre-ANSI implementations (e.g. SunOS 4)
need stderr defined if assertion checking is enabled. */
#include <stdio.h>
@@ -39,6 +45,7 @@
#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#ifndef errno
@@ -61,34 +68,22 @@ extern int errno;
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t))
#ifndef ULONG_MAX
# define ULONG_MAX TYPE_MAXIMUM (unsigned long int)
#endif
#ifndef LONG_MAX
# define LONG_MAX TYPE_MAXIMUM (long int)
#endif
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#ifdef isblank
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
#include "xstrtol.h"
__unsigned long int __strtol ();
__strtol_t __strtol ();
static int
bkm_scale (__unsigned long int *x, int scale_factor)
bkm_scale (__strtol_t *x, int scale_factor)
{
__unsigned long int product = *x * scale_factor;
__strtol_t product = *x * scale_factor;
if (*x != product / scale_factor)
return 1;
*x = product;
@@ -96,7 +91,7 @@ bkm_scale (__unsigned long int *x, int scale_factor)
}
static int
bkm_scale_by_power (__unsigned long int *x, int base, int power)
bkm_scale_by_power (__strtol_t *x, int base, int power)
{
while (power--)
if (bkm_scale (x, base))
@@ -109,27 +104,24 @@ bkm_scale_by_power (__unsigned long int *x, int base, int power)
strtol_error
__xstrtol (const char *s, char **ptr, int strtol_base,
__unsigned long int *val, const char *valid_suffixes)
__strtol_t *val, const char *valid_suffixes)
{
char *t_ptr;
char **p;
__unsigned long int tmp;
__strtol_t tmp;
assert (0 <= strtol_base && strtol_base <= 36);
p = (ptr ? ptr : &t_ptr);
#if STRING_TO_UNSIGNED
{
const char *q = s;
while (ISBLANK (*q))
{
if (! TYPE_SIGNED (__strtol_t))
{
const char *q = s;
while (ISSPACE ((unsigned char) *q))
++q;
}
if (*q == '-')
return LONGINT_INVALID;
}
#endif
if (*q == '-')
return LONGINT_INVALID;
}
errno = 0;
tmp = __strtol (s, p, strtol_base);
@@ -139,8 +131,8 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
return LONGINT_INVALID;
/* Let valid_suffixes == NULL mean `allow any suffix'. */
/* FIXME: update all callers except the one in tail.c changing
last parameter NULL to `""'. */
/* FIXME: update all callers except the ones that allow suffixes
after the number, changing last parameter NULL to `""'. */
if (!valid_suffixes)
{
*val = tmp;
@@ -154,7 +146,10 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
int overflow;
if (!strchr (valid_suffixes, **p))
return LONGINT_INVALID_SUFFIX_CHAR;
{
*val = tmp;
return LONGINT_INVALID_SUFFIX_CHAR;
}
if (strchr (valid_suffixes, '0'))
{
@@ -227,6 +222,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
break;
default:
*val = tmp;
return LONGINT_INVALID_SUFFIX_CHAR;
break;
}
@@ -258,7 +254,7 @@ main (int argc, char** argv)
for (i=1; i<argc; i++)
{
char *p;
__unsigned long int val;
__strtol_t val;
s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw");
if (s_err == LONGINT_OK)

View File

@@ -1,14 +1,8 @@
#ifndef XSTRTOL_H_
# define XSTRTOL_H_ 1
# if STRING_TO_UNSIGNED
# define __xstrtol xstrtoul
# define __strtol strtoul
# define __unsigned unsigned
# else
# define __xstrtol xstrtol
# define __strtol strtol
# define __unsigned /* empty */
# if HAVE_INTTYPES_H
# include <inttypes.h> /* for uintmax_t */
# endif
# ifndef PARAMS
@@ -27,11 +21,14 @@ enum strtol_error
typedef enum strtol_error strtol_error;
# endif
strtol_error
__xstrtol PARAMS ((const char *s, char **ptr, int base,
__unsigned long int *val, const char *valid_suffixes));
# define _DECLARE_XSTRTOL(name, type) \
strtol_error \
name PARAMS ((const char *s, char **ptr, int base, \
type *val, const char *valid_suffixes));
_DECLARE_XSTRTOL (xstrtol, long int)
_DECLARE_XSTRTOL (xstrtoul, unsigned long int)
_DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
# undef _STRTOL_ERROR
# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
do \
{ \
@@ -51,8 +48,7 @@ strtol_error
break; \
\
case LONGINT_OVERFLOW: \
/* FIXME: make this message dependent on STRING_TO_UNSIGNED */\
error ((Exit_code), 0, "%s `%s' larger than maximum long int",\
error ((Exit_code), 0, "%s `%s' too large", \
(Argument_type_string), (Str)); \
break; \
} \

View File

@@ -1,2 +1,4 @@
#define STRING_TO_UNSIGNED 1
#define __strtol strtoul
#define __strtol_t unsigned long int
#define __xstrtol xstrtoul
#include "xstrtol.c"

View File

@@ -1,13 +0,0 @@
#ifndef XSTRTOUL_H_
# define XSTRTOUL_H_ 1
# define STRING_TO_UNSIGNED 1
/* Undefine this symbol so we can include xstrtol.h a second time.
Otherwise, a program that wanted both xstrtol.h and xstrtoul.h
would never get the declaration corresponding to the header file
included after the first one. */
# undef XSTRTOL_H_
# include "xstrtol.h"
#endif /* not XSTRTOUL_H_ */

31
lib/xstrtoumax.c Normal file
View File

@@ -0,0 +1,31 @@
/* xstrtoumax.c -- A more useful interface to strtoumax.
Copyright 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 Paul Eggert. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#define __strtol strtoumax
#define __strtol_t uintmax_t
#define __xstrtol xstrtoumax
#include "xstrtol.c"

View File

@@ -1,3 +1,57 @@
1999-05-22 Jim Meyering <meyering@ascend.com>
* jm-macros.m4 (AC_REPLACE_FUNCS): Add memchr.
1999-05-20 Jim Meyering <meyering@ascend.com>
* search-libs.m4 [AC_SEARCH_LIBS]: Quote name in undefine.
Add a colon after each `then' in case $4 is empty.
1999-05-16 Jim Meyering <meyering@ascend.com>
* search-libs.m4: New file to override autoconf's AC_SEARCH_LIBS.
1999-05-10 Jim Meyering <meyering@ascend.com>
* jm-mktime.m4: Reflect renaming: AM_FUNC_MKTIME -> AC_FUNC_MKTIME.
* jm-macros.m4: Require 2.14.1, since we use newly-renamed
AC_FUNC_MKTIME.
1999-05-10 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
* jm-mktime.m4, putenv.m4: Fix typos in config.h comments.
1999-05-04 Paul Eggert <eggert@twinsun.com>
* lfs.m4 (AC_LFS): -n32, -o32, and -n64 should be in CFLAGS,
not CPPFLAGS, so that linking works correctly in IRIX.
1999-04-30 Paul Eggert <eggert@twinsun.com>
* jm-macros.m4 (AC_REPLACE_FUNCS): Add dup2.
1999-04-20 Jim Meyering <meyering@ascend.com>
* xstrtoumax.m4: Require jm_AC_TYPE_UNSIGNED_LONG_LONG.
AC_REPLACE xstroull if necessary. From Paul Eggert.
(AC_CHECK_FUNCS): Remove strtoull, strtoumax, strtouq.
1999-04-20 Paul Eggert <eggert@twinsun.com>
* uintmax_t.m4 (jm_AC_TYPE_UINTMAX_T): Move unsigned long
long check into new jm_AC_TYPE_UNSIGNED_LONG_LONG macro.
* jm-macros.m4 (jm_CHECK_ALL_TYPES): Require
jm_AC_TYPE_UNSIGNED_LONG_LONG.
* ulonglong.m4 (jm_AC_TYPE_UNSIGNED_LONG_LONG): New file/macro.
* lfs.m4: Port to AIX and HP-UX. Support cross-compilation.
1999-04-18 Jim Meyering <meyering@ascend.com>
* xstrtoumax.m4 (jm_AC_PREREQ_XSTRTOUMAX): New file/macro.
* jm-macros.m4: Use it.
1999-04-06 Jim Meyering <meyering@ascend.com>
* strftime.m4: Remove test for %f.

View File

@@ -41,15 +41,18 @@ putenv.m4 \
readdir.m4 \
realloc.m4 \
regex.m4 \
search-libs.m4 \
st_dm_mode.m4 \
st_mtim.m4 \
stat.m4 \
strftime.m4 \
uintmax_t.m4 \
ulonglong.m4 \
uptime.m4 \
utimbuf.m4 \
utime.m4 \
utimes.m4
utimes.m4 \
xstrtoumax.m4
##m4-files-end
Makefile.am: Makefile.am.in

View File

@@ -57,6 +57,10 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -64,6 +68,7 @@ CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
@@ -132,23 +137,28 @@ putenv.m4 \
readdir.m4 \
realloc.m4 \
regex.m4 \
search-libs.m4 \
st_dm_mode.m4 \
st_mtim.m4 \
stat.m4 \
strftime.m4 \
uintmax_t.m4 \
ulonglong.m4 \
uptime.m4 \
utimbuf.m4 \
utime.m4 \
utimes.m4
utimes.m4 \
xstrtoumax.m4
subdir = m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = README ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
@@ -166,8 +176,6 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = m4
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -184,6 +192,7 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:

View File

@@ -4,7 +4,7 @@ dnl Misc type-related macros for fileutils, sh-utils, textutils.
AC_DEFUN(jm_MACROS,
[
AC_PREREQ(2.13) dnl Minimum Autoconf version required.
AC_PREREQ(2.14.1) dnl Minimum Autoconf version required.
GNU_PACKAGE="GNU $PACKAGE"
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
@@ -37,7 +37,10 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
AC_REQUIRE([jm_FUNC_FNMATCH])
AC_REQUIRE([jm_AFS])
AC_REQUIRE([jm_AC_PREREQ_XSTRTOUMAX])
AC_REPLACE_FUNCS(strcasecmp strncasecmp)
AC_REPLACE_FUNCS(dup2)
AC_REPLACE_FUNCS(memchr)
# By default, argmatch should fail calling usage (1).
AC_DEFINE(ARGMATCH_DIE, [usage (1)],
@@ -62,4 +65,5 @@ AC_DEFUN(jm_CHECK_ALL_TYPES,
AC_CHECK_TYPE(ino_t, unsigned long)
AC_CHECK_TYPE(ssize_t, int)
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
])

View File

@@ -1,16 +1,16 @@
#serial 5
#serial 7
dnl From Jim Meyering.
dnl A wrapper around AM_FUNC_MKTIME.
dnl A wrapper around AC_FUNC_MKTIME.
AC_DEFUN(jm_FUNC_MKTIME,
[AC_REQUIRE([AM_FUNC_MKTIME])dnl
[AC_REQUIRE([AC_FUNC_MKTIME])dnl
dnl mktime.c uses localtime_r if it exists. Check for it.
AC_CHECK_FUNCS(localtime_r)
if test $am_cv_func_working_mktime = no; then
if test $ac_cv_func_working_mktime = no; then
AC_DEFINE_UNQUOTED(mktime, rpl_mktime,
[Define to gnu_mktime if the replacement function should be used.])
[Define to rpl_mktime if the replacement function should be used.])
fi
])

143
m4/lfs.m4
View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
dnl The problem is that the default compilation flags in Solaris 2.6 won't
dnl let programs access large files; you need to tell the compiler that
@@ -8,50 +8,99 @@ dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl Written by Paul Eggert <eggert@twinsun.com>.
dnl Internal subroutine of AC_LFS.
dnl AC_LFS_FLAGS(FLAGSNAME)
AC_DEFUN(AC_LFS_FLAGS,
[AC_CACHE_CHECK([for $1 value to request large file support], ac_cv_lfs_$1,
[ac_cv_lfs_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
ac_cv_lfs_$1=no
ifelse($1, CFLAGS,
[case "$host_os" in
# IRIX 6.2 and later
irix6.[[2-9]]* | irix6.1[[0-9]]* | irix[[7-9]].* | irix[[1-9]][[0-9]]*)
if test "$GCC" != yes; then
ac_cv_lfs_CFLAGS=-n32
fi
ac_save_CC="$CC"
CC="$ac_save_CC $ac_cv_lfs_CFLAGS"
AC_TRY_LINK(, , , ac_cv_lfs_CFLAGS=no)
CC="$ac_save_CC"
esac])
}])])
dnl Internal subroutine of AC_LFS.
dnl AC_LFS_SPACE_APPEND(VAR, VAL)
AC_DEFUN(AC_LFS_SPACE_APPEND,
[case $2 in
no) ;;
?*)
case "[$]$1" in
'') $1=$2 ;;
*) $1=[$]$1' '$2 ;;
esac ;;
esac])
dnl Internal subroutine of AC_LFS.
dnl AC_LFS_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
AC_DEFUN(AC_LFS_MACRO_VALUE,
[AC_CACHE_CHECK([for $1], $2,
[[$2=no
$4
for ac_flag in $ac_cv_lfs_CFLAGS no; do
case "$ac_flag" in
-D$1)
$2=1 ;;
-D$1=*)
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
esac
done]])
if test "[$]$2" != no; then
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
fi])
AC_DEFUN(AC_LFS,
[dnl
# If available, prefer support for large files unless the user specified
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
AC_MSG_CHECKING(whether large file support needs explicit enabling)
ac_getconfs=''
ac_result=yes
ac_set=''
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
for ac_shellvar in $ac_shellvars; do
case $ac_shellvar in
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
*) ac_lfsvar=LFS_$ac_shellvar ;;
esac
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
ac_getconf=`getconf $ac_lfsvar`
ac_getconfs=$ac_getconfs$ac_getconf
eval ac_test_$ac_shellvar=\$ac_getconf
done
case "$ac_result" in
no)
case "`(uname -s -r) 2>/dev/null`" in
HP-UX' '?.10.[[2-9]][[0-9]]* | HP-UX' '?.1[[1-9]]* | HP-UX' '?.[[2-9]][[0-9]]*)
# HP-UX 10.20 and later support large files,
# but do not support `getconf LFS_CFLAGS'.
ac_test_CPPFLAGS='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
ac_test_LDFLAGS=
ac_test_LIBS=
ac_getconfs=nonempty
ac_result=yes ;;
esac ;;
esac
case "$ac_result$ac_getconfs" in
yes) ac_result=no ;;
esac
case "$ac_result$ac_set" in
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
esac
AC_MSG_RESULT($ac_result)
case $ac_result in
yes)
for ac_shellvar in $ac_shellvars; do
eval $ac_shellvar=\$ac_test_$ac_shellvar
done ;;
esac
])
[AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_ENABLE(lfs,
[ --disable-lfs omit Large File Support])
if test "$enable_lfs" != no; then
AC_CHECK_TOOL(GETCONF, getconf)
AC_LFS_FLAGS(CFLAGS)
AC_LFS_FLAGS(LDFLAGS)
AC_LFS_FLAGS(LIBS)
for ac_flag in $ac_cv_lfs_CFLAGS no; do
case "$ac_flag" in
no) ;;
-D_FILE_OFFSET_BITS=*) ;;
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
-[[DI]]?*)
AC_LFS_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
*)
AC_LFS_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
esac
done
AC_LFS_SPACE_APPEND(LDFLAGS, "$ac_cv_lfs_LDFLAGS")
AC_LFS_SPACE_APPEND(LIBS, "$ac_cv_lfs_LIBS")
AC_LFS_MACRO_VALUE(_FILE_OFFSET_BITS, ac_cv_file_offset_bits,
[Number of bits in a file offset, on hosts where this is settable. ],
[case "$host_os" in
# HP-UX 10.20 and later
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
ac_cv_file_offset_bits=64 ;;
esac])
AC_LFS_MACRO_VALUE(_LARGEFILE_SOURCE, ac_cv_largefile_source,
[Define to make fseeko etc. visible, on some hosts. ],
[case "$host_os" in
# HP-UX 10.20 and later
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
ac_cv_largefile_source=1 ;;
esac])
AC_LFS_MACRO_VALUE(_LARGE_FILES, ac_cv_large_files,
[Define for large files, on AIX-style hosts. ],
[case "$host_os" in
# AIX 4.2 and later
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
ac_cv_large_files=1 ;;
esac])
fi
])

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
dnl From Jim Meyering.
dnl
@@ -36,6 +36,6 @@ AC_DEFUN(jm_FUNC_PUTENV,
AC_SUBST(LIBOBJS)
LIBOBJS="$LIBOBJS putenv.$ac_objext"
AC_DEFINE_UNQUOTED(putenv, rpl_putenv,
[Define to rpl_memcmp if the replacement function should be used.])
[Define to rpl_putenv if the replacement function should be used.])
fi
])

44
m4/search-libs.m4 Normal file
View File

@@ -0,0 +1,44 @@
#serial 2
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 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.
undefine([AC_SEARCH_LIBS])
dnl AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
dnl Search for a library defining FUNC, if it's not already available.
AC_DEFUN(AC_SEARCH_LIBS,
[
AC_PREREQ([2.13])
AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
[
ac_func_search_save_LIBS="$LIBS"
ac_cv_search_$1="no"
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
if test "$ac_cv_search_$1" = "no"; then
for ac_lib in $2; do
LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
AC_TRY_LINK_FUNC([$1],
[ac_cv_search_$1="-l$ac_lib"
break])
done
fi
LIBS="$ac_func_search_save_LIBS"
])
if test "$ac_cv_search_$1" = "no"; then :
$4
else
if test "$ac_cv_search_$1" = "none required"; then :
$4
else
LIBS="$ac_cv_search_$1 $LIBS"
$3
fi
fi
])

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
dnl From Paul Eggert.
@@ -11,11 +11,7 @@ AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
[
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
if test $jm_ac_cv_header_inttypes_h = no; then
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
[AC_TRY_COMPILE([],
[unsigned long long i = (unsigned long long) -1;],
ac_cv_type_unsigned_long_long=yes,
ac_cv_type_unsigned_long_long=no)])
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
test $ac_cv_type_unsigned_long_long = yes \
&& ac_type='unsigned long long' \
|| ac_type='unsigned long'

16
m4/ulonglong.m4 Normal file
View File

@@ -0,0 +1,16 @@
#serial 1
dnl From Paul Eggert.
AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
[
AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
[AC_TRY_COMPILE([],
[unsigned long long i = (unsigned long long) -1;],
ac_cv_type_unsigned_long_long=yes,
ac_cv_type_unsigned_long_long=no)])
if test $ac_cv_type_unsigned_long_long = yes; then
AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
[Define if you have the unsigned long long type.])
fi
])

22
m4/xstrtoumax.m4 Normal file
View File

@@ -0,0 +1,22 @@
#serial 1
# autoconf tests required for use of xstrtoumax.c
AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
[
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
AC_CHECK_HEADERS(stdlib.h)
AC_REPLACE_FUNCS(strtoumax)
dnl We don't need (and can't compile) the replacement strtoull
dnl unless the type `unsigned long long' exists.
dnl Also, only the replacement strtoumax invokes strtoull,
dnl so we need the replacement strtoull only if strtoumax does not exist.
case "$ac_cv_type_unsigned_long_long,$ac_cv_func_strtoumax" in
yes,no)
AC_REPLACE_FUNCS(strtoull)
;;
esac
])

View File

@@ -1,5 +1,481 @@
1999-05-23 Jim Meyering <meyering@ascend.com>
* Version 4.0i.
* tests/cp/same-file: Correct erroneous expected output from
the `cp -f foo foo' tests.
* po/POTFILES.in: Add same.c.
* lib/same.h: New file.
* lib/same.c: New file (function extracted from ln.c).
* lib/Makefile.am (libfu_a_SOURCES): Add same.c.
(noinst_HEADERS): Add same.h.
* src/copy.c: Include same.h.
* src/ln.c (same_name): Remove function.
<same.h>: Include this instead.
<dirname.h>: No longer include this.
* tests/mv/force: Be sure we still allow `mv -f FILE LINK-TO-FILE'.
* src/copy.c (copy_internal): Make it so `cp/mv -f FILE FILE' does not
remove FILE. Suggestion from Chris Yeo.
* tests/mv/force: New test, for the above fix.
* tests/mv/Makefile.am (TESTS): Add force.
(TESTS_ENVIRONMENT): Change PATH to be absolute.
* tests/mv/force (mv): New test.
1999-05-17 Paul Eggert <eggert@twinsun.com>
* lib/getdate.y (get_date): Let mktime deduce tm_isdst if we
have an absolute timestamp, or if the relative timestamp
mentions days, months, or years. Reported by Volker Borchert.
* lib/human.c (human_readable): Allow from_block_size to be zero.
1999-05-14 Jim Meyering <meyering@ascend.com>
* tests/Makefile.am (envvar-check): Renamed from check-local.
(check): Depend on envvar-check so the envvar check is performed
before all other tests. Reported by Volker Borchert.
* tests/.env-warn: Use `%%' place-holder that Makefile.am rule expects,
so CDPATH is mentioned in the message. Reported by Volker Borchert.
* src/df.c (main): When asking for info on an explicit file name,
just warn rather than failing if the table of mounted filesystems
cannot be read. Based on a patch from Mark Kettenis.
* lib/version-etc.c (version_etc): Put version info and author names
on the first two lines respectively rather than putting the three
lines of copyright info between them.
* src/touch.c (open_maybe_create): Handle Solaris' failure mode when
FILE is a directory. Reported by Vin Shelton.
* lib/human.c: Include <string.h> or <strings.h> for strlen prototype.
* lib/getline.h [__GLIBC__ >= 2]: #if-out prototypes.
* src/remove.c (pop_dir): Cast length to `int' to avoid a warning on
64-bit systems. From Ulrich Drepper.
1999-05-12 Jim Meyering <meyering@ascend.com>
* src/shred.c (main): Put `u' for -u in getopt_long's string argument.
Remove the `R'.
1999-05-07 Jim Meyering <meyering@ascend.com>
* Version 4.0h.
* tests/touch/dir-1: New test.
* tests/touch/Makefile.am (TESTS_ENVIRONMENT): Remove individual
upper-case program names. Add a definition of PATH.
(TESTS): Add dir-1.
* src/mkdir.c (main): Use better wording in diagnostic: `cannot
create directory' rather than `cannot make directory'. The former
also matches the one in makepath.c.
* src/dd.c: (apply_translations): Use TOUPPER and TOLOWER,
not toupper and tolower.
1999-05-05 Jim Meyering <meyering@ascend.com>
* lib/makepath.c (make_dir): When reporting a mkdir failure and the
target cannot be `stat'ed, use the errno from the failed mkdir call,
not the one from the stat call. Before this change, running
`mkdir -p /no-dir/no-dir' as an unprivileged user would wrongly
elicit `No such file or directory' instead of `Permission denied'.
* lib/strtol.c (TYPE_SIGNED, TYPE_MAXIMUM, TYPE_MINIMUM): Define.
(ULONG_LONG_MAX, LONG_LONG_MAX, LONG_LONG_MIN): Define if not defined.
Based on a patch from Kaveh Ghazi.
* src/ls.c (USE_ACL): Define this only #if
(HAVE_SYS_ACL_H && HAVE_ACL && defined GETACLCNT).
Use `USE_ACL' in place of `HAVE_ACL' everywhere else. From Kaveh Ghazi.
1999-05-04 Jim Meyering <meyering@ascend.com>
* lib/makepath.c: Include makepath.h libintl.h, not after it.
Otherwise, we'd get the wrong definition of PARAMS from libintl.h.
(The method of defining PARAMS in libintl.h doesn't check PROTOTYPES,
which is necessary on Irix4 since cc doesn't define __STDC__.)
From Kaveh Ghazi.
1999-04-30 Jim Meyering <meyering@ascend.com>
* Makefile.maint: Define several tag-related make variables.
(cvs-dist): Use the make variables instead of shell ones.
(announcement): Automatically generate diffs for all ChangeLog files,
not just the top level one.
1999-04-30 Paul Eggert <eggert@twinsun.com>
* lib/dup2.c: New file.
1999-04-30 Jim Meyering <meyering@ascend.com>
* src/touch.c (touch): Only do the fstat if we need to.
Resort to calling stat for directories, but only when necessary.
(usage): Mention --no-create.
* src/copy.c (copy_internal): Move the one-file-system test so that
it follows the `if (new_dst || !S_ISDIR (dst_sb.st_mode))' block.
Prior to this change, `cp --one-file-system' would traverse a file-
system boundary if the destination directory existed. From Ton Hospel.
1999-04-27 Paul Eggert <eggert@twinsun.com>
* src/dd.c: Always use STDIN_FILENO for input and STDOUT_FILENO
for output, to avoid confusion with closed input and output fds.
(input_fd, output_fd): Remove; all uses changed to STDIN_FILENO
and STDOUT_FILENO.
(open_fd): New function.
(main): Use it, instead of open, to ensure that file descriptors
don't get confused.
1999-04-26 Paul Eggert <eggert@twinsun.com>
* src/ls.c (decode_switches): Use STDIN_FILENO, STDOUT_FILENO instead
of 0, 1.
* src/dd.c (skip): Don't fstat the input file; the result is
no longer used.
1999-04-26 Jim Meyering <meyering@ascend.com>
* tests/mv/into-self-2: Update to reflect this change by reversing
the order of arguments so the symlink is the source, not the
destination (otherwise, the mv command would now succeed).
* src/copy.c (copy_internal): Don't make `mv foo symlink-to-foo' fail.
That is, even though source and destination are `the same,' don't fail
if the destination is a symlink. From Peter Samuelson.
1999-04-26 Paul Eggert <eggert@twinsun.com>
* src/dd.c (main): If you can't open an output file (with
seek=...) read-write, then open it for write and report an
error if we can't seek.
* lib/filemode.c (setst, ftypelet, mode_string):
* lib/mkdir.c (mkdir):
* lib/makepath.c (make_path):
* lib/modechange.c (make_node_op_equals, mode_compile,
mode_create_from_ref, mode_adjust):
* lib/modechange.h (mode_adjust):
* src/chmod.c (describe_change, change_file_mode):
* src/copy.c (copy_reg, copy_internal):
* src/copy.h (struct cp_options.umask_kill):
* src/cp.c (do_copy, cp_option_init, main):
* src/dd.c (main):
* src/install.c (mode, cp_option_init, DIR_MODE):
* src/mkdir.c (main):
* src/mkfifo.c (main):
* src/mknod.c (main):
* src/mv.c (cp_option_init):
* src/touch.c (open_maybe_create):
Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
* lib/filemode.c (S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH,
S_IXOTH): Define if not defined.
(rwx): Remove.
* lib/mkdir.c (S_IRWXU, S_IRWXG, S_IRWXO): Define if not defined.
* lib/makepath.c (S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRWXU):
Define if not defined.
* src/system.h (S_ISUID, S_ISGID, S_ISVTX, S_IRWXU, S_IRWXG, S_IRWXO):
Define if not defined.
(CHMOD_MODE_BITS): New macro.
* src/install.c (isodigit): Remove unused macro.
* src/mkfifo.c, src/mknod.c (usage):
Use symbolic mode as default, not octal.
* lib/utime.c (utime_null):
Don't pass 0666 to open; it's not needed and isn't
guaranteed to be portable.
* lib/filemode.h: <config.h>, <sys/types.h>: Include for mode_t.
(mode_string): Now takes mode_t.
* lib/modechange.h: Include <config.h>, <sys/types.h> for mode_t.
(struct mode_change): Members affected and value are now mode_t instead
of unsigned short.
* doc/fileutils.texi, doc/perm.texi:
Don't assume traditional Unix mode numbering.
* lib/modechange.c: modechange.h now includes sys/types.h.
Include xstrtol.h.
(isodigit, oatoi): Remove.
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP,
S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH, S_IRWXU, S_IRWXG,
S_IRWXO): Define if not defined.
(CHMOD_MODE_BITS): New macro.
(mode_compile): Convert from octal with xstrtoul, not our own routine.
1999-04-24 Jim Meyering <meyering@ascend.com>
* Version 4.0g.
1999-04-22 Jim Meyering <meyering@ascend.com>
* src/shred.c (word32): Don't use `#error'; it runs afoul of
SunOS 4.1.4 cc. From Paul Eggert.
* lib/strtoull.c: Guard strong_alias and weak_alias with #ifdef _LIBC.
1999-04-20 Paul Eggert <eggert@twinsun.com>
Replace our temporary hack implementation of strtoumax with
something very close to the real code in glibc.
* lib/xstrtoumax.c: Remove the temporary strtoumax replacement;
we now have a true replacement in strtoumax.c.
(__strtol): Always define to strtoumax.
(<stdlib.h>): No need to include.
(PARAMS): Remove.
(my_strtoumax): Move this to strtoumax.c,
rename it to strtoumax, and simplify.
* lib/strtoull.c, lib/strtoumax.c: New files.
* lib/strtol.c: Update to glibc 2.1.1 version.
1999-04-20 Jim Meyering <meyering@ascend.com>
* tests/Makefile.am (EXTRA_DIST): s/posix-warn/env-warn/.
(check-local): Also test and warn if CDPATH is set.
1999-04-20 Paul Eggert <eggert@twinsun.com>
* configure.in (AC_CANONICAL_HOST): Add; needed for new AC_LFS's
cross-compilation.
* config.guess: New file (from autoconf).
* config.sub: New file (from autoconf).
* src/shred.c <config.h>: Include first, since it can do
things like #define const, and this must be done before
including any system headers.
* lib/xstrtoumax.c (my_strtoumax): Fix typo in computing
whether overflow occurred. Improve overflow-detection to use
only one conditional branch total, rather than 2N+1
conditional branches for an N-digit number.
1999-04-18 Jim Meyering <meyering@ascend.com>
* configure.in (AC_CHECK_FUNCS): Remove strtoull, strtoumax, and
strtouq, now that they're checked in m4/xstrtoumax.m4.
1999-04-18 Paul Eggert <eggert@twinsun.com>
* doc/fileutils.texi, src/shred.c (main, longopts):
Use -u instead of -R for --remove, so that we can preserve
future compatibility with rm.
1999-04-18 Jim Meyering <meyering@ascend.com>
* src/shred.c [!HAVE_CONFIG_H] (ST_BLKSIZE): Define to 65536.
(do_wipefd): Use ST_BLKSIZE instead of referring to the st_blksize
member directly.
1999-04-18 Paul Eggert <eggert@twinsun.com>
Fix shred to do the right thing with off_t longer than long.
Merge large-integer parsing code with similar code in dd.c,
and put the resulting in lib/xstrtoumax.c so that other programs
can use it. Instead of adding a new lib/xstrtoumax.h I thought
it cleaner to put all the xstroto* declarations into a single
header, which for now is lib/xstrtol.h for lack of a better place.
(Mayby lib/xstdlib.h would be better? :-)
I thought of several other problems with shredding regular files;
shredding devices is much more reliable. So I changed the defaults
to be more suitable for shredding devices; this should help encourage
users to do the right thing.
pfstatus isn't portable to environments with varying width
fonts, or with internationalized environments where the byte
count of the message is not the same as its print width.
Rather than deal with this, I just simplified it to not do
tricks with carriage-returns and spaces. (I'm also worried
that vprintf may not return the right value on some hosts; I
vaguelly recall this being a problem.) As a result, -v and -
no longer conflict.
When removing a special file, try to truncate it first, but don't
worry if this reports an error.
Try to find the size of a non-regular file by seeking to its end.
Various porting fixes, mostly because of a port to SunOS 4.1.4 cc.
Some other minor bug fixes.
* lib/xstrtoul.h: Remove this file.
* lib/xstrtoumax.c: New file.
* configure.in (AC_CHECK_FUNCS): Add strtoull, strtoumax, strtouq.
* lib/xstrtoul.c (STRING_TO_UNSIGNED): Remove.
(__strtol, __strtol_t, __xstrtol): New macros.
* lib/xstrtol.c (__strtol, __strtol_t, __xstrtol):
New macros to specify the
underlying function, its returned type, and our function. Default to
values suitable for xstrtol.
Include <ctype.h>, since we use its macros.
(ULONG_MAX, LONG_MAX, ISBLANK): Remove: no longer needed.
(ISSPACE): New macro.
(bkm_scale, bkm_scale_by_power, __xstrtol, main): __unsigned long int
-> __strtol_t.
(__xstrtol): Depend on whether __strtol_t is an unsigned type, not on
whether STRING_TO_UNSIGNED is defined. Skip isspace chars, not
isblank chars, to match strtol. When returning
LONGINT_INVALID_SUFFIX_CHAR, store the value that we computed into
*val.
* lib/xstrtol.h (__xstrtol, __strtol, __unsigned): Remove macro decls.
<inttypes.h>: Include if HAVE_INTTYPES_H.
(_DECLARE_XSTRTOL): New macro.
(xstrtol, xstrtoul, xstrtoumax): Declare all three functions, so that
we need only one include file, not three.
(_STRTOL_ERROR): Do not undef, as this is no longer needed.
Reword overflow message so that it's independent of type.
* lib/Makefile.am (libfu_a_SOURCES): Add xstrtoumax.c.
(noinst_HEADERS): Remove xstrtoul.h.
* lib/xmalloc.c (xalloc_fail):
Pass xalloc_msg_memory_exhausted through gettext.
* lib/getdate.y:
<stdlib.h>: Include if HAVE_STDLIB_H, since bison 1.27 invokes "free".
(LookupWord, yylex): Don't pass negative char to ctype macros.
* doc/fileutils.texi:
Explain why shredding devices is more reliable, and why the
default options are more suitable for devices.
Remove withdrawn options -b or --no-contents, -c or --freed-contents,
-C or --all-contents, -k or --no-links, -l or --ordinary-links, -L or
--all-links.
Add -R or --remove, -s or --size.
-v can no longer be doubled.
`file system' --> `filesystem' uniformly.
* src/chgrp.c: Include xstrtol.h, not obsolete file xstrtoul.h.
* src/shred.c: Include xstrtol.h, not obsolete file xstrtoul.h.
"human.h", "xalloc.h": Include.
(attribute): Remove; no longer needed.
(xstrdup): New decl.
(STDOUT_FILENO): New macro.
(O_NOCTTY): Make sure it's always defined, even if HAVE_CONFIG_H.
The following changes have effect only if !HAVE_CONFIG_H.
<ctype.h>: New include.
(RETSIGTYPE): Remove bogus semicolon at end.
(STDOUT_FILENO, uintmax_t, human_readable, LONGEST_HUMAN_READABLE):
New macros.
(xstrtoumax): Renamed from xstrtoul, with corresponding type changes.
Handle suffixes like the real routine does.
(error): Remove bogus assignment of errno to errnum.
(xmalloc, xstrdup): New functions.
(O_NOCTTY): Define even if !HAVE_CONFIG_H.
(S_ISFIFO, S_ISSOCK): New macros, if not already defined.
(OUTPUT_BLOCK_SIZE): New macro.
(struct Options.verbose): Now a boolean, since we no longer have two
levels of verbosity.
(long_opts, usage, main): Remove -D or --device option. Invert -p or
--preserve option, and rename it to -R or --remove.
(usage): Describe G suffix.
(usage): "-" no longer conflicts with -v.
(UCHAR_MAX): Indent `#error' so that SunOS 4.1.4 cc doesn't reject it.
(ind): Portability fixes: return word32, not unsigned; multiply by
sizeof (word32) instead of shifting left by 2.
(isaac_refill, isaac_mix): Comment out size of array parameter, as
ansi2knr mishandles this.
(status_visible, status_pos, pfstatus, flushstatus): Remove, since
pfstatus isn't portable to users with varying width fonts, or
internationalized messages, and vfprintf is problematic. All callers
of pfstatus changed to use error instead; this removes incompatibility
of -v with -. All calls to flushstatus removed.
(dopass, do_wipefd): Do not translate non-English msgs with gettext.
(dopass): Cast lseek constant arguments to (off_t) for benefit
of pre-ANSI compilers; fix one lseek call whose args were interchanged.
Remove unnecessary casts to (off_t). Do not check for EIO
when determining file size; this was just my earlier wild guess.
Use human_readable to print off_t, instead of casting to unsigned long
(which doesn't work in Solaris 2.6, where off_t is longer than long).
Output human-readable sizes, instead of always using "K".
Check for offset overflow (it happened to me in SunOS 4.1.4).
(do_wipefd): Do not insist on regular files, but do check for special
files that cannot possibly be shredded.
Use xmalloc instead of malloc + check.
Do not inspect st_size for non-regular files.
Try to find the size of a non-regular file by seeking to its end.
Do not assume that a regular file of size-0 has unknown size.
Check for regular files with negative sizes,
and for overflow after rounding to next block.
Always try to truncate, even for special files, but do not report an
error if truncation fails on a special file.
(dopass, wipefile): Do not return 1 for special files; the caller
doesn't care any more.
(wipefd): Remove unnecessary (and nonportable) check for
whether the file descriptor is read-only. Remove
no-longer-needed check for `-v -'.
(incname): Return 1 for carry bit, like the documentation says.
(wipename, wipefile): Accept new argument, specifying the
quoted file name. All callers changed.
(wipename): Use xstrdup instead of strdup+error check.
(wipefile): Check for ENOTDIR when opening /dev/fd/NNN. Check for
errors in NNN more carefully. Restore errno after the check.
Check for errors when closing the file descriptor.
Use more consistent wording when unable to remove a file.
(main): Do not remove files by default.
Use xstrtoumax instead of xstrtoul uniformly, since xstrtoul won't
exist if !HAVE_CONFIG_H.
In diagnostics, quote invalid operands to -n and -s options.
Allow T, P, E, Z, and Y suffixes in -s operand.
flags.verbose is now a boolean, not a counter.
Use STDOUT_FILENO instead of 1, for clarity.
* lib/human.c:
Include xstrtol.h, not xstrtoul.h, since xstrtol.h now defines all the
xstrto... functions.
* src/dd.c: Include xstrtol.h.
(parse_integer): Migrate most of the work into the new xstrtoumax fn.
* lib/xstrtoumax.c: New file.
1999-04-18 Jim Meyering <meyering@ascend.com>
* src/dd.c (main): Open the output file with *read* access
only if we might need to read to satisfy a `seek=' request.
From Matthias Urlichs.
1999-04-10 Jim Meyering <meyering@ascend.com>
* Makefile.maint (alpha): Add trailing slash for ncftp.
* Version 4.0f.
* configure.in (AC_OUTPUT): Add tests/dd/Makefile.

View File

@@ -1,4 +1,22 @@
Changes in release 4.1:
[4.0i]
* `cp -f FILE FILE' and `mv -f FILE FILE' no longer remove FILE
* touch works once again (DST-wise) when certain `--date DATE-TIME'
values are specified.
* shred's -u option (short form of --remove) is now accepted
[4.0h]
* cp --one-file-system (-x) no longer crosses filesystem boundaries.
* touch can once again operate on directories
[4.0g]
* New large-file support for AIX and HP-UX, and for cross-compiles.
* shred's default options are now suitable for devices, not files, since
shred is more reliable on devices. shred now does not remove by default;
the old -p or --preserve option was inverted and renamed to -u or --remove.
* shred -u now attempts to truncate devices before removing them.
* shred -v no longer outputs carriage-returns; shred -vv has no extra effect;
shred -v now outputs to stderr.
* shred now tries to find the size of a non-regular file by seeking to its end.
* dd now opens the output file for *read* access only if `seek=' is used.
[4.0f]
* `ls --color' no longer segfaults
* dd works once again

View File

@@ -1,3 +1,145 @@
1999-05-21 Jim Meyering <meyering@ascend.com>
* Version 1.16k.
* configuration fixes: see m4/ChangeLog.
1999-05-16 Jim Meyering <meyering@ascend.com>
* Version 1.16j.
* configure.in (AC_SEARCH_LIBS): Set LIB_CRYPT to $ac_cv_search_crypt,
to go along with the new macro in m4/search-libs.m4.
1999-05-14 Jim Meyering <meyering@ascend.com>
* lib/getugroups.c (getugroups): Don't dereference a null pointer when
running `id USER' for some USER that is listed on the RHS in /etc/group.
From Sander van Malssen.
Add some curly braces, use STREQ, reverse the sense of a test
and use `continue' to save a level of nesting.
* tests/Makefile.am (envvar-check): Renamed from check-local.
(check): Depend on envvar-check so the envvar check is performed
before all other tests. Reported by Volker Borchert.
* tests/.env-warn: Use `%%' place-holder that Makefile.am rule expects,
so CDPATH is mentioned in the message. Reported by Volker Borchert.
1999-05-10 Jim Meyering <meyering@ascend.com>
* src/uptime.c (AUTHORS): add Kaveh.
Expand each `&' character in the gecos field.
* src/pinky.c (count_ampersands): New function.
(create_fullname): New function.
(print_entry): Use create_fullname here.
(print_long_entry): Use it here, too.
From Kaveh Ghazi.
1999-05-09 Jim Meyering <meyering@ascend.com>
* lib/regex.c: Update from libc.
* Version 1.16i.
* configure.in: Clean up checks for libraries so that we don't add
-lshadow unless necessary. Reported by Joseph S. Myers.
1999-05-05 Jim Meyering <meyering@ascend.com>
Add definitions to help read utmpx on systems with utmpname.
* lib/readutmp.h (UTMP_NAME_FUNCTION): Define.
(SET_UTMP_ENT): Likewise.
(GET_UTMP_ENT): Likewise.
(END_UTMP_ENT): Likewise.
* lib/readutmp.c (read_utmp): Use the new definitions.
From Kaveh Ghazi.
* src/date.c (show_date): Change an automatic aggregate initializer
to be a static one. For SunOS4's cc. From Kaveh Ghazi.
1999-05-03 Jim Meyering <meyering@ascend.com>
* configure.in: Remove duplicate use of jm_FUNC_GNU_STRFTIME.
Kaveh Ghazi reported that strftime.o was listed twice in the command
to build libsu.a.
1999-05-02 Jim Meyering <meyering@ascend.com>
* Version 1.16h.
* src/hostname.c (main): Give a better diagnostic when we fail to
set the hostname.
* man/Makefile.summ (hostid-summary): Use correct description.
Reported by Joseph S. Myers.
* lib/readutmp.c (read_utmp): Ignore the return value from utmpname.
1999-04-30 Jim Meyering <meyering@ascend.com>
* src/dirname.c (main): Manually handle `--', since we no longer
call getopt. Reported by Joseph S. Myers.
* src/basename.c (main): Likewise.
* src/factor.c (main): Likewise.
1999-04-25 Jim Meyering <meyering@ascend.com>
* src/seq.c (main): Handle the case in which seq is given no args.
Reported by John Gotts.
(main): Revert last change.
Instead, loop on `optind < argc' to protect use of argv[optind].
* lib/human.c <inttypes.h>: Don't include it here.
* lib/human.h <inttypes.h>: Include it here instead.
<config.h>: Include it here too.
Reported by Andreas Jaeger.
* src/nice.c [NDEBUG]: Remove definition.
Reported by Andreas Jaeger.
1999-04-24 Jim Meyering <meyering@ascend.com>
* src/who.c (print_entry): Use `#if', not `#ifdef HAVE_UT_HOST'.
* Version 1.16g.
* configure.in: Use AC_CANONICAL_HOST.
1999-04-20 Jim Meyering <meyering@ascend.com>
Update factor to use `uintmax_t'.
* src/factor.c <xstrtol.h>: Include this, not xstrtoul.h.
<human.h>: Include.
Use uintmax_t in place of unsigned long.
Use human_readable to convert to strings for printing.
* lib/xstrtoumax.c: New file.
* lib/human.c: New file.
* lib/human.h: New file.
* lib/Makefile.am (libsu_a_SOURCES): Add human.c and xstrtoumax.c.
(noinst_HEADERS): Add human.h. Remove xstrtoul.h.
1999-04-19 Jim Meyering <meyering@ascend.com>
* src/seq.c (main): Restore `+' in getopt_long string. Otherwise,
commands like `seq 10 -2 0' wouldn't work. From Andreas Schwab.
* tests/seq/basic: Add tests for that.
1999-04-17 Jim Meyering <meyering@ascend.com>
* tests/seq: New directory and basic tests.
* tests/Makefile.am (SUBDIRS): Add seq.
* configure.in (AC_OUTPUT): Add tests/seq/Makefile.
1999-04-17 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
* configure.in: Check for localeconv.
* src/seq.c (decimal_point): New variable.
(main): Set it to locale's decimal point. Fix recognition of
negative number as argument.
(get_width_format): Correctly handle a negative min_val or step
when computing fraction width. Use decimal_point.
1999-04-08 Jim Meyering <meyering@ascend.com>
1999-03-25 James R. Van Zandt <jrv@vanzandt.mv.com>

View File

@@ -1,5 +1,19 @@
Changes in release 1.17
[1.16k]
* fix typos in my version of AC_SEARCH_LIBS.
* fix dates on config files so builders don't need autoconf/automake
[1.16j]
* work around problems with my use of AC_SEARCH_LIBS
* fix a bug in id
[1.16i]
* portability tweaks for lib/readutmp.[ch] and src/date.c
[1.16h]
* seq with no arguments now elicits a useful diagnostic rather than a segfault
* portability tweaks to work around utmpname differences
* who works on Solaris
[1.16g]
* factor now uses uintmax_t, so the largest number it can factor is now 2^64 - 1
on systems with type `long long'.
* nohup no longer modifies the shell's search path
* `basename /' now prints `/', per the single unix spec
* `who --lookup' no longer erroneously reports `localhost' for IP addresses

View File

@@ -1,3 +1,311 @@
1999-05-22 Jim Meyering <meyering@ascend.com>
* lib/Makefile.am (libtu_a_SOURCES): Remove memchr.c.
From Ulrich Drepper.
* Version 1.22m.
1999-05-22 Paul Eggert <eggert@twinsun.com>
* doc/textutils.texi: Document locale-specific changes to `sort',
as well as the new, POSIX-compliant definition of line comparison,
and -g's more careful treatment of NaNs, infinities and zeros.
* src/sort.c (general_numcompare): Put exceptional cases
first, not last, to be consistent with -M.
1999-05-21 Paul Eggert <eggert@twinsun.com>
* src/sort.c (strtod): Declare if STDC_HEADERS is not defined.
(general_numcompare): Use strtod, not xstrtod.
Do not consider partial conversions to be errors.
Put -infinity at the start, and +infinity at the end;
follow +infinity with NaNs (sorted by bit pattern),
and finally by conversion errors.
1999-05-21 Jim Meyering <meyering@ascend.com>
* tests/sort/Test.pm (11d): Reverse lines in expected output
to reflect latest change.
(use-nl): New test from Paul Eggert.
1999-05-20 Paul Eggert <eggert@twinsun.com>
* src/sort.c: Treat the trailing newline as part of the line,
as required by POSIX.2.
(struct line, findlines, compare, checkfp, mergefps, sort):
A line now includes its trailing newline.
(findlines): Do not replace newline with NUL.
(memcoll, keycompare): Work even if the data to be compared are
adjacent strings; this is possible now that lines contain the
trailing newline.
(fillbuf): Always have an unused byte at the end of the buffer,
since memcoll and keycompare want to modify a byte after the last line.
(sortalloc, mergealloc): Increase by 1, for trailing byte.
1999-05-20 Jim Meyering <meyering@ascend.com>
* tests/sort/Test.pm: Add test case from Paul Eggert.
1999-05-20 Paul Eggert <eggert@twinsun.com>
* src/sort.c (keycompare): Ignore any length difference if the
localized comparison says the strings are equal.
* src/sort.c (memcoll, keycompare, compare): Handle NUL
characters properly when comparing with LC_COLLATE semantics.
(NLS_MEMCMP): Remove.
(memcoll): Renamed from strncoll.
Take separate lengths for each string.
This function is now invoked only when need_locale.
(keycompare): Don't copy strings when ignore and translate
are both NULL.
1999-05-18 Paul Eggert <eggert@twinsun.com>
* src/sort.c (MONTHTAB_CONST): Renamed from NLS_CONST; the use
is also changed. Define to const also if !HAVE_NL_LANGINFO.
(usage): `,' -> `;' (English typo).
1999-05-17 Eli Zaretskii <eliz@is.elta.co.il>
* src/cat.c (main): When stdout is in binary mode, make sure all
input files are also read in binary mode.
1999-05-16 Jim Meyering <meyering@ascend.com>
* Version 1.22l.
1999-05-11 Paul Eggert <eggert@twinsun.com>
* src/sort.c: Don't autodetect the locale of numbers and
months, as this conflicts with POSIX.2 and is tricky to boot.
(FLOATING_COMMA, NLS_STRNCMP, NLS_MAX_GROUPS,
NLS_ONE_CHARACTER_STRING): Remove macros no longer used.
(nls_grouping, nls_fraction_found, nls_month_found, nos_monthtab,
nls_months_collide, nls_keyhead, us_monthtab): Remove variables no
longer used.
(struct nls_keyfield): Remove types no longer used.
(strncoll_s2_readonly, nls_set_fraction, look_for_fraction,
nls_month_is_either_locale, nls_numeric_format): Remove functions no
longer used.
(monthtab): Now has the role that us_monthtab had, but it's const only
if ENABLE_NLS is not defined.
(C_DECIMAL_POINT): Renamed from FLOATING_POINT. All uses changed.
(MONTHS_PER_YEAR): Renamed from NLS_NUM_MONTHS. All uses changed.
(struct_month_cmp): Renamed from nls_sort_month_comp. All uses changed.
Use strcmp, not strcoll, since the user doesn't care about collating
here.
(inittables): Read locale data into monthtab, rather than modifying a
separate month table and futzing with indirection. Do not worry about
colliding months, since we no longer autodetect month locale.
(fraccompare): Don't set no-longer-used variable nls_fraction_found.
(getmonth): Use strncmp to compare months, since user doesn't care
about collating here. Fix bug where code incorrectly assumed that
strlen (monthtab[lo].name) == strlen (monthtab[ix].name).
(keycompare, main): Don't autodetect month locale.
(compare): Don't use NLS_MEMCP in code that can't be executed if
need_locale is false, as NLS_MEMCP is equivalent to memcmp in that
case.
(sort, insertkey, main): Don't autodetect numeric locale.
1999-05-15 Jim Meyering <meyering@ascend.com>
* tests/join/Test.pm (trailing-sp): New test for this fix.
* src/join.c (xfields): Don't interpret a trailing blank as a
delimiter when e.g. -t: was specified. From Tim Smithers.
1999-05-12 Jim Meyering <meyering@ascend.com>
* tests/Makefile.am (envvar-check): Renamed from check-local.
(check): Depend on envvar-check so the envvar check is performed
before all other tests. Reported by Volker Borchert.
* tests/.env-warn: Use `%%' place-holder that Makefile.am rule expects,
so CDPATH is mentioned in the message. Reported by Volker Borchert.
1999-05-11 Jim Meyering <meyering@ascend.com>
* src/sort.c (usage): Split the --help message into two pieces so that
neither is longer than 2048. For Irix4's cc. Reported by Kaveh Ghazi.
1999-05-09 Jim Meyering <meyering@ascend.com>
* lib/regex.c: Update from libc.
* Version 1.22k.
* Makefile.maint (alpha): Put the announcement in
/tmp/announce-$(distdir)
* tests/sort/Test.pm (neg-nls): New test.
1999-05-08 Jim Meyering <meyering@ascend.com>
* src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
and all the *_MIN and *_MAX symbols): Remove definitions.
* src/sys2.h: Put the definitions here instead (this file is shared
between all three *utils packages, while system.h is not).
1999-05-06 Paul Eggert <eggert@twinsun.com>
* src/sort.c (fraccompare, numcompare): Merge the NLS and
non-NLS versions into a single function.
(decimal_point): Now char, since we no longer convert to unsigned
char.
(th_sep): Now int, since we use a value out of char range to denote
the absence of a thousands separator.
(IS_THOUSANDS_SEP): New macro.
(USE_NEW_FRAC_COMPARE): Remove.
(nls_set_fraction): Arg is now char, not unsigned char.
Set th_sep to CHAR_MAX + 1 if there is no thousands separator.
(numcompare): Don't convert to unsigned char unless necessary.
(main): Turn off decimal points and thousand separators if they
are multibyte characters, as we don't support that yet.
1999-05-06 Paul Eggert <eggert@twinsun.com>
* src/system.h (CHAR_MIN, CHAR_MAX): New macros.
(SCHAR_MIN, SCHAR_MAX): Don't assume that char is signed.
1999-05-06 Paul Eggert <eggert@twinsun.com>
* src/sort.c (numcompare): Handle comparison of two negative
numbers correctly in the ENABLE_NLS case.
1999-05-04 Jim Meyering <meyering@ascend.com>
* src/pr.c (usage): Break the usage message into 3 pieces instead of
only 2. The strings had grown to be longer than 2048, which evokes
errors when compiling with Irix4's cc. Reported by Kaveh Ghazi.
* src/tsort.c (search_item): Use `1' instead of `+1'. The latter
elicits a syntax error from SunOS4's cc. From Kaveh Ghazi.
1999-05-03 Jim Meyering <meyering@ascend.com>
* src/ptx.c <ctype.h>: Don't include.
[!STDC_HEADERS]: Remove definitions of ctype macros.
Convert e.g., isspace to ISSPACE to use definitions from sys2.h.
Reported by Kaveh Ghazi.
* src/sys2.h (TOLOWER): Define.
(TOUPPER): Define.
* src/join.c (TOLOWER): Remove definition.
* src/md5sum.c: (TOLOWER): Remove definition.
1999-04-30 Jim Meyering <meyering@ascend.com>
* src/sort.c (usage): Document the differences between the
obsolescent, +POS1[-POS2] form, and the POSIX -k option.
1999-04-24 Jim Meyering <meyering@ascend.com>
* configure.in: Use AC_CANONICAL_HOST.
* lib/Makefile.am (libtu_a_SOURCES): Add xstrtoumax.c
(noinst_HEADERS): Remove xstrtoul.h.
* src/csplit.c: Include new "xstrtol.h", not "xstrtoul.h".
(struct control) [repeat]: Declare as uintmax_t, not int.
(struct control) [lines_required]: Likewise.
(handle_line_error): Use human_readable to print lines_required.
(parse_repeat_count): Parse a uintmax_t.
(parse_patterns): Parse a uintmax_t.
* src/tail.c: Include new "xstrtol.h", not "xstrtoul.h".
* src/od.c: Likewise.
* src/head.c: Include new "xstrtol.h", not "xstrtoul.h".
Change all U_LONG_LONG to uintmax_t.
(head_lines): Move a couple dcls into an inner scope.
(string_to_integer): Rename from string_to_ull.
1999-04-19 Jim Meyering <meyering@ascend.com>
* Makefile.maint (b_host): Remove /pub suffix.
1999-04-18 Jim Meyering <meyering@ascend.com>
* Version 1.22j.
* Makefile.maint (my-distcheck): Use AMTAR, not TAR.
* src/sort.c (usage): s/DIRECT/DIRECTORY/g
Rename global: s/temp_file_prefix/temp_dir/.
(NAME_MAX_IN_DIR): Rename from PATH_MAX_IN_DIR. Use _POSIX_NAME_MAX,
not _POSIX_PATH_MAX. Guard with #if HAVE_PATHCONF rather than
#if HAVE_UNISTD_H.
(tempname): Wrap after 99999 only for length-impaired file systems.
1999-04-17 Jim Meyering <meyering@ascend.com>
* src/tail.c (file_lines): Fix serious bug introduced with last changes.
From Andreas Schwab.
1999-04-15 Jim Meyering <meyering@ascend.com>
* tests/Makefile.am (EXTRA_DIST): Rename .posix-warn to .env-warn.
(check-local): Warn about CDPATH in the same way
we warn about POSIXLY_CORRECT, since the cp/same-file test fails at
least when using bash with CDPATH set. Reported by Mark Hewitt.
* src/pr.c Add comments.
(init_header): Tweak white space in Date/Time header.
* tests/pr/Test.pm: Updated all tests to reflect the big
1999-02-13 change. From Roland Huebner.
1999-04-12 Jim Meyering <meyering@ascend.com>
* src/cat.c (main): Declare out_dev to be of type dev_t, not `int'.
Declare out_ino to be of type ino_t, not `int'.
From John Bley.
* src/od.c (MIN, MAX): Remove definitions.
* src/sys2.h (MIN, MAX): Define here instead.
Reported by John Bley.
1999-04-11 Jim Meyering <meyering@ascend.com>
* Version 1.22i.
* tests/pr/Test.pm (test_vector): Disable all tests while I wait for
an updated suite.
Fix the problem whereby `yes > k & sleep 1; tail -2c k' would infloop.
* src/tail.c (COPY_TO_EOF): Define.
(dump_remainder): Add parameter, n_bytes, and rewrite to use it.
Update callers.
(file_lines): Rename parameter.
(tail_bytes): Remove obsolete comment.
Fix the problem whereby `yes > k & sleep 1; tail -1 k' would infloop.
* src/tail.c (dump_remainder): Move this function to precede the
new use in file_lines.
(tail_lines): Don't call dump_remainder here.
(file_lines): Call dump_remainder here instead.
Reported by Lehti Rami.
* lib/readtokens.c (readtoken, readtokens): Protoize.
1999-04-10 Jim Meyering <meyering@ascend.com>
* src/tail.c (xwrite): Use STDOUT_FILENO instead of literal `1'.
1999-04-04 Jim Meyering <meyering@ascend.com>
* src/cat.c: Standardize --help and --version processing.

View File

@@ -1,11 +1,35 @@
Changes in release 1.23
[1.22n]
* use lib/memchr.c only if it's not provided by the system -- this means
that on systems with a fast library memchr function you may notice an
improvement. If you use a system with a buggy or signifcantly slower
memchr, please report it.
[1.22m]
* sort now considers newlines to be part of the line, as required by POSIX.2.
E.g. a line starting with a tab now sorts before an empty line,
since tab precedes newline in the ASCII collating sequence.
* sort handles NUL bytes correctly when configured/compiled with --enable-nls
* fix typos in my version of AC_SEARCH_LIBS.
* fix dates on config files so builders don't need autoconf/automake
[1.22l]
* sort no longer autodetects the locale of numbers and months,
as that conflicts with POSIX.2
* `join -tC' now works when input contains trailing spaces
* portability tweaks for Irix's cc
[1.22k]
* `sort -n' works with negative numbers when configured/compiled
with --enable-nls
* head accepts byte and line counts of type uintmax_t (so up to 2^64 - 1)
[1.22j]
* tail: fix bug introduced in 1.22i
[1.22i]
* tail now terminates in `yes > k & sleep 1; tail -2c k'
* `tail -f' now ensures that stdout is unbuffered
* fix a bug in cut to allow use of 8-bit delimiters
* pr accepts POSIX compliant options -s and -w,
the new capital letter options -J, -S and _W turn off the
unexpected interferences of the small letter options -s and -w
if used together with the column options.
the new capital letter options -J, -S and _W turn off the
unexpected interferences of the small letter options -s and -w
if used together with the column options.
* pr output has been adapted to other UNIXes in some cases.
[1.22h]
* portability tweaks

View File

@@ -1,6 +1,6 @@
/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */
/*$Id: ansi2knr.c,v 1.13 1999/02/03 15:23:21 meyering Exp $*/
/*$Id: ansi2knr.c,v 1.14 1999/04/13 14:44:33 meyering Exp $*/
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
/*
@@ -44,7 +44,10 @@ program under the GPL.
* consisting of only
* identifier1(identifier2)
* will not be considered a function definition unless identifier2 is
* the word "void". ansi2knr will recognize a multi-line header provided
* the word "void", and a line consisting of
* identifier1(identifier2, <<arbitrary>>)
* will not be considered a function definition.
* ansi2knr will recognize a multi-line header provided
* that no intervening line ends with a left or right brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
@@ -58,6 +61,12 @@ program under the GPL.
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
lpd 1999-04-12 added minor fixes from Pavel Roskin
<pavel_roskin@geocities.com> for clean compilation with
gcc -W -Wall
lpd 1999-03-22 added hack to recognize lines consisting of
identifier1(identifier2, xxx) as *not* being procedures
lpd 1999-02-03 made indentation of preprocessor commands consistent
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
endless loop; quoted strings within an argument list
confused the parser
@@ -158,6 +167,11 @@ program under the GPL.
#endif
/* Define NULL (for *very* old compilers). */
#ifndef NULL
# define NULL (0)
#endif
/*
* The ctype macros don't always handle 8-bit characters correctly.
* Compensate for this here.
@@ -263,6 +277,11 @@ main(argc, argv)
if ( filename )
fprintf(out, "#line 1 \"%s\"\n", filename);
buf = malloc(bufsize);
if ( buf == NULL )
{
fprintf(stderr, "Unable to allocate read buffer!\n");
exit(1);
}
line = buf;
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
{
@@ -430,7 +449,7 @@ test1(buf)
};
char **key = words;
char *kp;
int len = endfn - buf;
unsigned len = endfn - buf;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
@@ -443,14 +462,16 @@ test1(buf)
int len;
/*
* Check for identifier1(identifier2) and not
* identifier1(void).
* identifier1(void), or identifier1(identifier2, xxxx).
*/
while ( isidchar(*p) )
p++;
len = p - id;
p = skipspace(p, 1);
if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) )
if (*p == ',' ||
(*p == ')' && (len != 4 || strncmp(id, "void", 4)))
)
return 0; /* not a function */
}
/*
@@ -495,7 +516,7 @@ convert1(buf, out, header, convert_varargs)
;
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
if ( breaks == 0 )
if ( breaks == NULL )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(buf, out);
@@ -507,7 +528,7 @@ top: p = endfn;
do
{ int level = 0;
char *lp = NULL;
char *rp;
char *rp = NULL;
char *end = NULL;
if ( bp >= btop )
@@ -545,7 +566,7 @@ top: p = endfn;
}
}
/* Erase any embedded prototype parameters. */
if ( lp )
if ( lp && rp )
writeblanks(lp + 1, rp);
p--; /* back up over terminator */
/* Find the name being declared. */

View File

@@ -100,6 +100,13 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (argc > 1 && STREQ (argv[1], "--"))
{
--argc;
++argv;
}
if (argc == 1 || argc > 3)
{

View File

@@ -486,10 +486,10 @@ main (int argc, char **argv)
int argind;
/* Device number of the output (file or whatever). */
int out_dev;
dev_t out_dev;
/* I-node number of the output. */
int out_ino;
ino_t out_ino;
/* Nonzero if the output file should not be the same as any input file. */
int check_redirection = 1;
@@ -666,6 +666,9 @@ main (int argc, char **argv)
/* Switch stdout to BINARY mode. */
binary_output = 1;
SET_BINARY (output_desc);
/* When stdout is in binary mode, make sure all input files are
also read in binary mode. */
file_open_mode |= O_BINARY;
}
else if (quote)
{

View File

@@ -27,7 +27,7 @@
#include "error.h"
#include "group-member.h"
#include "savedir.h"
#include "xstrtoul.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "chgrp"

View File

@@ -91,7 +91,7 @@ static struct option const long_options[] =
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, short unsigned int mode,
describe_change (const char *file, mode_t mode,
enum Change_status changed)
{
char perms[11]; /* "-rwxrwxrwx" ls-style modes. */
@@ -102,18 +102,18 @@ describe_change (const char *file, short unsigned int mode,
switch (changed)
{
case CH_SUCCEEDED:
fmt = _("mode of %s changed to %04o (%s)\n");
fmt = _("mode of %s changed to %04lo (%s)\n");
break;
case CH_FAILED:
fmt = _("failed to change mode of %s to %04o (%s)\n");
fmt = _("failed to change mode of %s to %04lo (%s)\n");
break;
case CH_NO_CHANGE_REQUESTED:
fmt = _("mode of %s retained as %04o (%s)\n");
fmt = _("mode of %s retained as %04lo (%s)\n");
break;
default:
abort ();
}
printf (fmt, file, mode & 07777, &perms[1]);
printf (fmt, file, (unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
}
/* Change the mode of FILE according to the list of operations CHANGES.
@@ -126,7 +126,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
const int deref_symlink)
{
struct stat file_stats;
unsigned short newmode;
mode_t newmode;
int errors = 0;
if (lstat (file, &file_stats))
@@ -152,9 +152,9 @@ change_file_mode (const char *file, const struct mode_change *changes,
newmode = mode_adjust (file_stats.st_mode, changes);
if (newmode != (file_stats.st_mode & 07777))
if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS))
{
int fail = chmod (file, (int) newmode);
int fail = chmod (file, newmode);
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));

View File

@@ -32,8 +32,9 @@
#include "savedir.h"
#include "copy.h"
#include "cp-hash.h"
#include "path-concat.h"
#include "dirname.h"
#include "path-concat.h"
#include "same.h"
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
(Chown ((File), (x->myeuid == 0 ? (New_uid) : x->myeuid), (New_gid)) \
@@ -195,7 +196,7 @@ copy_reg (const char *src_path, const char *dst_path,
/* Create the new regular file with small permissions initially,
to not create a security hole. */
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (dest_desc < 0)
{
error (0, errno, _("cannot create regular file `%s'"), dst_path);
@@ -428,9 +429,8 @@ copy_internal (const char *src_path, const char *dst_path,
&& ! x->force
/* Allow them to be the same (and don't set `same') if
we're in move mode and they're both symlinks. */
we're in move mode and the target is a symlink. */
&& !(move_mode
&& S_ISLNK (src_sb.st_mode)
&& S_ISLNK (dst_sb.st_mode))
/* If we're making a backup, we'll detect the problem case in
@@ -461,7 +461,8 @@ copy_internal (const char *src_path, const char *dst_path,
if (x->hard_link)
return 0;
if (x->backup_type == none && !x->force)
if (x->backup_type == none
&& (!x->force || same_name (src_path, dst_path)))
{
error (0, 0, _("`%s' and `%s' are the same file"),
src_path, dst_path);
@@ -488,9 +489,9 @@ copy_internal (const char *src_path, const char *dst_path,
if (euidaccess (dst_path, W_OK) != 0)
{
fprintf (stderr,
_("%s: overwrite `%s', overriding mode %04o? "),
_("%s: overwrite `%s', overriding mode %04lo? "),
program_name, dst_path,
(unsigned int) (dst_sb.st_mode & 07777));
(unsigned long) (dst_sb.st_mode & CHMOD_MODE_BITS));
}
else
{
@@ -558,7 +559,7 @@ copy_internal (const char *src_path, const char *dst_path,
/* Temporarily change mode to allow overwriting. */
if (euidaccess (dst_path, W_OK | X_OK) != 0)
{
if (chmod (dst_path, 0700))
if (chmod (dst_path, S_IRWXU))
{
error (0, errno, "%s", dst_path);
return 1;
@@ -682,7 +683,7 @@ copy_internal (const char *src_path, const char *dst_path,
/* Create the new directory writable and searchable, so
we can create new entries in it. */
if (mkdir (dst_path, (src_mode & x->umask_kill) | 0700))
if (mkdir (dst_path, (src_mode & x->umask_kill) | S_IRWXU))
{
error (0, errno, _("cannot create directory `%s'"), dst_path);
goto un_backup;
@@ -697,12 +698,12 @@ copy_internal (const char *src_path, const char *dst_path,
if (x->verbose)
printf ("%s -> %s\n", src_path, dst_path);
/* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
return 0;
}
/* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
return 0;
/* Copy the contents of the directory. */
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x,

View File

@@ -99,7 +99,7 @@ struct cp_options
int symbolic_link;
/* The bits to preserve in created files' modes. */
unsigned int umask_kill;
mode_t umask_kill;
/* If nonzero, do not copy a nondirectory that has an existing destination
with the same or newer modification time. */

View File

@@ -461,7 +461,7 @@ do_copy (int argc, char **argv, const struct cp_options *x)
leading directories. */
parent_exists = !make_path_private (dst_path,
arg_in_concat - dst_path,
0700,
S_IRWXU,
(x->verbose
? "%s -> %s\n" : NULL),
&attr_list, &new_dst,
@@ -617,7 +617,7 @@ cp_option_init (struct cp_options *x)
when using chmod. The creation mask is set to be liberal, so
that created directories can be written, even if it would not
have been allowed with the mask this process was started with. */
x->umask_kill = 0777777 ^ umask (0);
x->umask_kill = ~ umask (0);
x->update = 0;
x->verbose = 0;
@@ -759,7 +759,7 @@ main (int argc, char **argv)
: none);
if (x.preserve_chmod_bits == 1)
x.umask_kill = 0777777;
x.umask_kill = ~ (mode_t) 0;
/* The key difference between -d (--no-dereference) and not is the version
of `stat' to call. */

View File

@@ -31,8 +31,9 @@
#include <regex.h>
#include "error.h"
#include "human.h"
#include "safe-read.h"
#include "xstrtoul.h"
#include "xstrtol.h"
#include "xalloc.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -67,8 +68,8 @@ struct control
char *regexpr; /* Non-compiled regular expression. */
struct re_pattern_buffer re_compiled; /* Compiled regular expression. */
int offset; /* Offset from regexp to split at. */
int lines_required; /* Number of lines required. */
unsigned int repeat; /* Repeat count. */
uintmax_t lines_required; /* Number of lines required. */
uintmax_t repeat; /* Repeat count. */
int repeat_forever; /* Non-zero if `*' used as a repeat count. */
int argnum; /* ARGV index. */
boolean ignore; /* If true, produce no output (for regexp). */
@@ -743,8 +744,10 @@ dump_rest_of_file (void)
static void
handle_line_error (const struct control *p, int repetition)
{
fprintf (stderr, _("%s: `%d': line number out of range"),
program_name, p->lines_required);
char buf[LONGEST_HUMAN_READABLE + 1];
fprintf (stderr, _("%s: `%s': line number out of range"),
program_name, human_readable (p->lines_required, buf, 1, 1));
if (repetition)
fprintf (stderr, _(" on repetition %d\n"), repetition);
else
@@ -762,7 +765,7 @@ static void
process_line_count (const struct control *p, int repetition)
{
unsigned int linenum;
unsigned int last_line_to_save = p->lines_required * (repetition + 1);
uintmax_t last_line_to_save = p->lines_required * (repetition + 1);
struct cstring *line;
create_output_file ();
@@ -1089,7 +1092,7 @@ check_for_offset (struct control *p, const char *str, const char *num)
static void
parse_repeat_count (int argnum, struct control *p, char *str)
{
unsigned long val;
uintmax_t val;
char *end;
end = str + strlen (str) - 1;
@@ -1101,14 +1104,13 @@ parse_repeat_count (int argnum, struct control *p, char *str)
p->repeat_forever = 1;
else
{
if (xstrtoul (str + 1, NULL, 10, &val, "") != LONGINT_OK
|| val > UINT_MAX)
if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK)
{
error (EXIT_FAILURE, 0,
_("%s}: integer required between `{' and `}'"),
global_argv[argnum]);
}
p->repeat = (unsigned int) val;
p->repeat = val;
}
*end = '}';
@@ -1166,8 +1168,8 @@ parse_patterns (int argc, int start, char **argv)
{
int i; /* Index into ARGV. */
struct control *p; /* New control record created. */
unsigned long val;
static unsigned long last_val = 0;
uintmax_t val;
static uintmax_t last_val = 0;
for (i = start; i < argc; i++)
{
@@ -1180,25 +1182,28 @@ parse_patterns (int argc, int start, char **argv)
p = new_control_record ();
p->argnum = i;
if (xstrtoul (argv[i], NULL, 10, &val, "") != LONGINT_OK
|| val > INT_MAX)
if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK)
error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]);
if (val == 0)
error (EXIT_FAILURE, 0,
_("%s: line number must be greater than zero"),
argv[i]);
if (val < last_val)
error (EXIT_FAILURE, 0,
_("line number `%s' is smaller than preceding line number, %lu"),
argv[i], last_val);
{
char buf[LONGEST_HUMAN_READABLE + 1];
error (EXIT_FAILURE, 0,
_("line number `%s' is smaller than preceding line number, %s"),
argv[i], human_readable (last_val, buf, 1, 1));
}
if (val == last_val)
error (0, 0,
_("warning: line number `%s' is the same as preceding line number"),
argv[i]);
last_val = val;
p->lines_required = (int) val;
p->lines_required = val;
}
if (i + 1 < argc && *argv[i + 1] == '{')

View File

@@ -477,12 +477,14 @@ show_date (const char *format, time_t when)
char *out = NULL;
size_t out_length = 0;
/* ISO 8601 formats, in local and UTC. See below regarding %z */
char *iso_format_string[5][2]={
static char *iso_format_string[5][2] =
{
{"", ""},
{"%Y-%m-%d", "%Y-%m-%d"},
{"%Y-%m-%dT%H%z", "%Y-%m-%dT%HZ"},
{"%Y-%m-%dT%H:%M%z", "%Y-%m-%dT%H:%MZ"},
{"%Y-%m-%dT%H:%M:%S%z", "%Y-%m-%dT%H:%M:%SZ"}};
{"%Y-%m-%dT%H:%M:%S%z", "%Y-%m-%dT%H:%M:%SZ"}
};
tm = localtime (&when);

189
src/dd.c
View File

@@ -34,6 +34,7 @@
#include "human.h"
#include "long-options.h"
#include "safe-read.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "dd"
@@ -76,15 +77,9 @@ char *program_name;
/* The name of the input file, or NULL for the standard input. */
static char *input_file = NULL;
/* The input file descriptor. */
static int input_fd = 0;
/* The name of the output file, or NULL for the standard output. */
static char *output_file = NULL;
/* The output file descriptor. */
static int output_fd = 1;
/* The number of bytes in which atomic reads are done. */
static size_t input_blocksize = 0;
@@ -365,9 +360,9 @@ static void
cleanup (void)
{
print_stats ();
if (close (input_fd) < 0)
if (close (STDIN_FILENO) < 0)
error (1, errno, "%s", input_file);
if (close (output_fd) < 0)
if (close (STDOUT_FILENO) < 0)
error (1, errno, "%s", output_file);
}
@@ -422,12 +417,34 @@ install_handler (int sig_num, RETSIGTYPE (*sig_handler) (int sig))
#endif
}
/* Open a file to a particular file descriptor. This is like standard
`open', except it always returns DESIRED_FD if successful. */
static int
open_fd (int desired_fd, char const *filename, int options, mode_t mode)
{
int fd;
close (desired_fd);
fd = open (filename, options, mode);
if (fd < 0)
return -1;
if (fd != desired_fd)
{
if (dup2 (fd, desired_fd) != desired_fd)
desired_fd = -1;
if (close (fd) != 0)
return -1;
}
return desired_fd;
}
/* Write, then empty, the output buffer `obuf'. */
static void
write_output (void)
{
int nwritten = full_write (output_fd, obuf, output_blocksize);
int nwritten = full_write (STDOUT_FILENO, obuf, output_blocksize);
if (nwritten != output_blocksize)
{
error (0, errno, "%s", output_file);
@@ -473,101 +490,15 @@ parse_conversion (char *str)
Assign nonzero to *INVALID if STR does not represent a number in
this format. */
/* FIXME: use xstrtou?[lq] */
static uintmax_t
parse_integer (char *str, int *invalid)
{
register uintmax_t n = 0;
register char *p = str;
uintmax_t n;
enum strtol_error e = xstrtoumax (str, &str, 10, &n, "bcEGkMPTwYZ0");
while (ISDIGIT (*p))
if (e == LONGINT_INVALID_SUFFIX_CHAR && *str == 'x')
{
uintmax_t n10 = n * 10;
int digit = *p - '0';
if (! (n10 / 10 == n && n10 <= n10 + digit))
{
*invalid = 1;
return 0;
}
n = n10 + digit;
p++;
}
for (;;)
{
uintmax_t multiplier;
int power = 0;
#ifdef lint
/* Suppress `used before initialized' warning. */
multiplier = 0;
#endif
switch (*p++)
{
case '\0':
return n;
case 'b':
multiplier = 512;
break;
case 'c':
continue;
case 'E': /* Exa */
power = 6;
break;
case 'G': /* Giga */
power = 3;
break;
case 'k': /* kilo */
power = 1;
break;
case 'M': /* Mega */
power = 2;
break;
case 'P': /* Peta */
power = 5;
break;
case 'T': /* Tera */
power = 4;
break;
case 'w':
multiplier = 2;
break;
case 'x':
multiplier = parse_integer (p, invalid);
p = "";
break;
case 'Y': /* Yotta */
power = 8;
break;
case 'Z': /* Zetta */
power = 7;
break;
default:
{
*invalid = 1;
return 0;
}
}
if (power)
{
int base = 1024;
switch (*p)
{
case 'B': p++; break;
case 'D': p++; base = 1000; break;
}
for (multiplier = base; --power; multiplier *= base)
if (multiplier * base / base != multiplier)
{
*invalid = 1;
return 0;
}
}
uintmax_t multiplier = parse_integer (str + 1, invalid);
if (multiplier != 0 && n * multiplier / multiplier != n)
{
@@ -577,6 +508,13 @@ parse_integer (char *str, int *invalid)
n *= multiplier;
}
else if (e != LONGINT_OK)
{
*invalid = 1;
return 0;
}
return n;
}
static void
@@ -689,14 +627,14 @@ only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sy
{
for (i = 0; i < 256; i++)
if (ISLOWER (trans_table[i]))
trans_table[i] = toupper (trans_table[i]);
trans_table[i] = TOUPPER (trans_table[i]);
translation_needed = 1;
}
else if (conversions_mask & C_LCASE)
{
for (i = 0; i < 256; i++)
if (ISUPPER (trans_table[i]))
trans_table[i] = tolower (trans_table[i]);
trans_table[i] = TOLOWER (trans_table[i]);
translation_needed = 1;
}
@@ -779,19 +717,8 @@ static void
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
unsigned char *buf)
{
struct stat stats;
off_t o;
/* Use fstat instead of checking for errno == ESPIPE because
lseek doesn't work on some special files but doesn't return an
error, either. */
/* FIXME: can this really happen? What system? */
if (fstat (fdesc, &stats))
{
error (0, errno, "%s", file);
quit (1);
}
/* Try lseek and if an error indicates it was an inappropriate
operation, fall back on using read. */
o = records * blocksize;
@@ -934,7 +861,7 @@ dd_copy (void)
obuf = ibuf;
if (skip_records != 0)
skip (input_fd, input_file, skip_records, input_blocksize, ibuf);
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
if (seek_record != 0)
{
@@ -945,7 +872,8 @@ dd_copy (void)
0+0 records out
*/
skip (output_fd, output_file, seek_record, output_blocksize, obuf);
skip (STDOUT_FILENO, output_file, seek_record, output_blocksize,
obuf);
}
if (max_records == 0)
@@ -962,7 +890,7 @@ dd_copy (void)
if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR))
memset ((char *) ibuf, 0, input_blocksize);
nread = safe_read (input_fd, ibuf, input_blocksize);
nread = safe_read (STDIN_FILENO, ibuf, input_blocksize);
if (nread == 0)
break; /* EOF. */
@@ -974,7 +902,7 @@ dd_copy (void)
{
print_stats ();
/* Seek past the bad block if possible. */
lseek (input_fd, (off_t) input_blocksize, SEEK_CUR);
lseek (STDIN_FILENO, (off_t) input_blocksize, SEEK_CUR);
if (conversions_mask & C_SYNC)
/* Replace the missing input with null bytes and
proceed normally. */
@@ -1006,7 +934,7 @@ dd_copy (void)
if (ibuf == obuf) /* If not C_TWOBUFS. */
{
int nwritten = full_write (output_fd, obuf, nread);
int nwritten = full_write (STDOUT_FILENO, obuf, nread);
if (nwritten < 0)
{
error (0, errno, "%s", output_file);
@@ -1065,7 +993,7 @@ dd_copy (void)
/* Write out the last block. */
if (oc != 0)
{
int nwritten = full_write (output_fd, obuf, oc);
int nwritten = full_write (STDOUT_FILENO, obuf, oc);
if (nwritten > 0)
w_partial++;
if (nwritten < 0)
@@ -1107,26 +1035,25 @@ main (int argc, char **argv)
if (input_file != NULL)
{
input_fd = open (input_file, O_RDONLY);
if (input_fd < 0)
if (open_fd (STDIN_FILENO, input_file, O_RDONLY, 0) < 0)
error (1, errno, "%s", input_file);
}
else
input_file = _("standard input");
if (input_fd == output_fd)
error (1, 0, _("%s is closed"), (input_fd == 0
? _("standard input")
: _("standard output")));
if (output_file != NULL)
{
int omode = O_RDWR | O_CREAT;
mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int opts
= (O_CREAT
| (seek_record || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
if (seek_record == 0 && !(conversions_mask & C_NOTRUNC))
omode |= O_TRUNC;
output_fd = open (output_file, omode, 0666);
if (output_fd < 0)
/* Open the output file with *read* access only if we might
need to read to satisfy a `seek=' request. If we can't read
the file, go ahead with write-only access; it might work. */
if ((! seek_record
|| open_fd (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
&& open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)
error (1, errno, "%s", output_file);
#if HAVE_FTRUNCATE
if (seek_record != 0 && !(conversions_mask & C_NOTRUNC))
@@ -1134,7 +1061,7 @@ main (int argc, char **argv)
off_t o = seek_record * output_blocksize;
if (o / output_blocksize != seek_record)
error (1, 0, _("file offset out of range"));
if (ftruncate (output_fd, o) < 0)
if (ftruncate (STDOUT_FILENO, o) < 0)
error (0, errno, "%s", output_file);
}
#endif

View File

@@ -753,7 +753,15 @@ main (int argc, char **argv)
|| show_local_fs));
if (mount_list == NULL)
error (1, errno, _("cannot read table of mounted filesystems"));
{
/* Couldn't read the table of mounted filesystems.
Fail if df was invoked with no file name arguments;
Otherwise, merely give a warning and proceed. */
const char *warning = (optind == argc ? "" : _("Warning: "));
int status = (optind == argc ? 1 : 0);
error (status, errno,
_("%scannot read table of mounted filesystems"), warning);
}
if (require_sync)
sync ();

View File

@@ -73,6 +73,13 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (argc > 1 && STREQ (argv[1], "--"))
{
--argc;
++argv;
}
if (argc != 2)
{

View File

@@ -1,4 +1,4 @@
/* factor -- print factors of n. lose if n > 2^32.
/* factor -- print factors of n.
Copyright (C) 86, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -28,8 +28,9 @@
#include "system.h"
#include "long-options.h"
#include "error.h"
#include "xstrtoul.h"
#include "human.h"
#include "readtokens.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "factor"
@@ -76,9 +77,9 @@ Print factors of each NUMBER; read standard input with no arguments.\n\
/* FIXME: comment */
static int
factor (long unsigned int n0, int max_n_factors, long unsigned int *factors)
factor (uintmax_t n0, int max_n_factors, uintmax_t *factors)
{
register unsigned long n = n0, d, q;
register uintmax_t n = n0, d, q;
int n_factors = 0;
if (n < 1)
@@ -128,20 +129,21 @@ factor (long unsigned int n0, int max_n_factors, long unsigned int *factors)
static int
print_factors (const char *s)
{
unsigned long int factors[MAX_N_FACTORS];
unsigned long n;
uintmax_t factors[MAX_N_FACTORS];
uintmax_t n;
int n_factors;
int i;
char buf[LONGEST_HUMAN_READABLE + 1];
if (xstrtoul (s, NULL, 10, &n, "") != LONGINT_OK)
if (xstrtoumax (s, NULL, 10, &n, "") != LONGINT_OK)
{
error (0, 0, _("`%s' is not a valid positive integer"), s);
return 1;
}
n_factors = factor (n, MAX_N_FACTORS, factors);
printf ("%lu:", n);
printf ("%s:", human_readable (n, buf, 1, 1));
for (i = 0; i < n_factors; i++)
printf (" %lu", factors[i]);
printf (" %s", human_readable (factors[i], buf, 1, 1));
putchar ('\n');
return 0;
}
@@ -181,6 +183,13 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
AUTHORS, usage);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (argc > 1 && STREQ (argv[1], "--"))
{
--argc;
++argv;
}
fail = 0;
if (argc == 1)

View File

@@ -31,7 +31,7 @@
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "xstrtoul.h"
#include "xstrtol.h"
#include "safe-read.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -39,9 +39,6 @@
#define AUTHORS "David MacKenzie"
/* FIXME: someday, make this really *be* `long long'. */
typedef long int U_LONG_LONG;
/* Number of lines/chars/blocks to head. */
#define DEFAULT_NUMBER 10
@@ -118,7 +115,7 @@ write_header (const char *filename)
}
static int
head_bytes (const char *filename, int fd, U_LONG_LONG bytes_to_write)
head_bytes (const char *filename, int fd, uintmax_t bytes_to_write)
{
char buffer[BUFSIZE];
int bytes_read;
@@ -146,18 +143,18 @@ head_bytes (const char *filename, int fd, U_LONG_LONG bytes_to_write)
}
static int
head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
head_lines (const char *filename, int fd, uintmax_t lines_to_write)
{
char buffer[BUFSIZE];
int bytes_read;
int bytes_to_write;
/* Need BINARY I/O for the byte counts to be accurate. */
SET_BINARY2 (fd, fileno (stdout));
while (lines_to_write)
{
bytes_read = safe_read (fd, buffer, BUFSIZE);
int bytes_read = safe_read (fd, buffer, BUFSIZE);
int bytes_to_write = 0;
if (bytes_read < 0)
{
error (0, errno, "%s", filename);
@@ -165,7 +162,6 @@ head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
}
if (bytes_read == 0)
break;
bytes_to_write = 0;
while (bytes_to_write < bytes_read)
if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0)
break;
@@ -176,7 +172,7 @@ head_lines (const char *filename, int fd, U_LONG_LONG lines_to_write)
}
static int
head (const char *filename, int fd, U_LONG_LONG n_units, int count_lines)
head (const char *filename, int fd, uintmax_t n_units, int count_lines)
{
if (count_lines)
return head_lines (filename, fd, n_units);
@@ -185,7 +181,7 @@ head (const char *filename, int fd, U_LONG_LONG n_units, int count_lines)
}
static int
head_file (const char *filename, U_LONG_LONG n_units, int count_lines)
head_file (const char *filename, uintmax_t n_units, int count_lines)
{
int fd;
@@ -221,13 +217,13 @@ head_file (const char *filename, U_LONG_LONG n_units, int count_lines)
COUNT_LINES indicates whether N_STRING is a number of bytes or a number
of lines. It is used solely to give a more specific diagnostic. */
static U_LONG_LONG
string_to_ull (int count_lines, const char *n_string)
static uintmax_t
string_to_integer (int count_lines, const char *n_string)
{
strtol_error s_err;
unsigned long int tmp_ulong;
uintmax_t n;
s_err = xstrtoul (n_string, NULL, 0, &tmp_ulong, "bkm");
s_err = xstrtoumax (n_string, NULL, 0, &n, "bkm");
if (s_err == LONGINT_INVALID)
{
@@ -244,7 +240,7 @@ string_to_ull (int count_lines, const char *n_string)
count_lines ? _("number of lines") : _("number of bytes"));
}
return tmp_ulong;
return n;
}
int
@@ -256,7 +252,7 @@ main (int argc, char **argv)
int c;
/* Number of items to print. */
U_LONG_LONG n_units = DEFAULT_NUMBER;
uintmax_t n_units = DEFAULT_NUMBER;
/* If nonzero, interpret the numeric argument as the number of lines.
Otherwise, interpret it as the number of bytes. */
@@ -330,7 +326,7 @@ main (int argc, char **argv)
if (multiplier_char)
*(++end_n_string) = 0;
n_units = string_to_ull (count_lines, n_string);
n_units = string_to_integer (count_lines, n_string);
/* Make the options we just parsed invisible to getopt. */
argv[1] = argv[0];
@@ -350,12 +346,12 @@ main (int argc, char **argv)
case 'c':
count_lines = 0;
n_units = string_to_ull (count_lines, optarg);
n_units = string_to_integer (count_lines, optarg);
break;
case 'n':
count_lines = 1;
n_units = string_to_ull (count_lines, optarg);
n_units = string_to_integer (count_lines, optarg);
break;
case 'q':

View File

@@ -98,7 +98,7 @@ main (int argc, char **argv)
/* Set hostname to argv[1]. */
err = sethostname (argv[1], strlen (argv[1]));
if (err != 0)
error (1, errno, "%s", argv[1]);
error (1, errno, _("cannot set hostname to `%s'"), argv[1]);
exit (0);
}
#else

View File

@@ -30,7 +30,7 @@
-m, --mode=MODE
Set the permission mode for the installed file or directory
to MODE, which is an octal number (default is 0755).
to MODE, which is an octal number (default is u=rwx,g=rx,o=rx).
-o, --owner=OWNER
If run as root, set the ownership of the installed file to
@@ -117,9 +117,6 @@ gid_t getgid ();
/* Initial number of entries in the inode hash table. */
#define INITIAL_ENTRY_TAB_SIZE 70
/* True if C is an ASCII octal digit. */
#define isodigit(c) ((c) >= '0' && c <= '7')
/* Number of bytes of a file to copy at a time. */
#define READ_SIZE (32 * 1024)
@@ -161,7 +158,7 @@ static gid_t group_id;
/* The permissions to which the files will be set. The umask has
no effect. */
static mode_t mode = 0755;
static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
/* If nonzero, strip executable files after copying them. */
static int strip_files;
@@ -214,7 +211,7 @@ cp_option_init (struct cp_options *x)
Although GNU strip works fine on read-only files, some others
would fail. */
x->set_mode = 1;
x->mode = 0600;
x->mode = S_IRUSR | S_IWUSR;
x->umask_kill = 0;
x->update = 0;
@@ -402,7 +399,7 @@ install_file_to_path (const char *from, const char *to,
owner, group, and permissions for parent directories. Remember
that this option is intended mainly to help installers when the
distribution doesn't provide proper install rules. */
#define DIR_MODE 0755
#define DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
fail = make_path (dest_dir, DIR_MODE, DIR_MODE, owner_id, group_id, 0,
(x->verbose ? _("creating directory `%s'") : NULL));

View File

@@ -24,12 +24,6 @@
#include <sys/types.h>
#include <getopt.h>
#if _LIBC || STDC_HEADERS
# define TOLOWER(c) tolower (c)
#else
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
#endif
#include "system.h"
#include "error.h"
#include "memcasecmp.h"
@@ -236,7 +230,7 @@ xfields (struct line *line)
}
}
if (ptr > line->beg && ((tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
if (ptr > line->beg && ((!tab && ISSPACE (ptr[-1])) || ptr[-1] == tab))
{
/* Add one more (empty) field because the last character of the
line was a delimiter. */

View File

@@ -27,8 +27,8 @@
#include <getopt.h>
#include "system.h"
#include "same.h"
#include "backupfile.h"
#include "dirname.h"
#include "error.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -117,40 +117,6 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
/* Return nonzero if SOURCE and DEST point to the same name in the same
directory. */
static int
same_name (const char *source, const char *dest)
{
struct stat source_dir_stats;
struct stat dest_dir_stats;
char *source_dirname, *dest_dirname;
source_dirname = dir_name (source);
dest_dirname = dir_name (dest);
if (source_dirname == NULL || dest_dirname == NULL)
error (1, 0, _("virtual memory exhausted"));
if (stat (source_dirname, &source_dir_stats))
{
/* Shouldn't happen. */
error (1, errno, "%s", source_dirname);
}
if (stat (dest_dirname, &dest_dir_stats))
{
/* Shouldn't happen. */
error (1, errno, "%s", dest_dirname);
}
free (source_dirname);
free (dest_dirname);
return (SAME_INODE (source_dir_stats, dest_dir_stats)
&& STREQ (base_name (source), base_name (dest)));
}
/* Make a link DEST to the (usually) existing file SOURCE.
Symbolic links to nonexistent files are allowed.
If DEST is a directory, put the link to SOURCE in that directory.

View File

@@ -84,6 +84,13 @@
#include "strverscmp.h"
#include "xstrtol.h"
/* Use access control lists only under all the following conditions.
Some systems (OSF4, Irix5, Irix6) have the acl function, but not
sys/acl.h or don't define the GETACLCNT macro. */
#if HAVE_SYS_ACL_H && HAVE_ACL && defined GETACLCNT
# define USE_ACL 1
#endif
#define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \
: (ls_mode == LS_MULTI_COL \
? "dir" : "vdir"))
@@ -164,14 +171,14 @@ struct fileinfo
enum filetype filetype;
#if HAVE_ACL
#if USE_ACL
/* For long listings, nonzero if the file has an access control list,
otherwise zero. */
int have_acl;
#endif
};
#if HAVE_ACL
#if USE_ACL
# define FILE_HAS_ACL(F) ((F)->have_acl)
#else
# define FILE_HAS_ACL(F) 0
@@ -872,7 +879,7 @@ decode_switches (int argc, char **argv)
case LS_LS:
/* This is for the `ls' program. */
if (isatty (1))
if (isatty (STDOUT_FILENO))
{
format = many_per_line;
/* See description of qmark_funny_chars, above. */
@@ -931,7 +938,7 @@ decode_switches (int argc, char **argv)
{
struct winsize ws;
if (ioctl (1, TIOCGWINSZ, &ws) != -1 && ws.ws_col != 0)
if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 && ws.ws_col != 0)
line_length = ws.ws_col;
}
#endif
@@ -988,7 +995,7 @@ decode_switches (int argc, char **argv)
sort_type = sort_none;
/* disable -l */
if (format == long_format)
format = (isatty (1) ? many_per_line : one_per_line);
format = (isatty (STDOUT_FILENO) ? many_per_line : one_per_line);
print_block_size = 0; /* disable -s */
print_with_color = 0; /* disable --color */
break;
@@ -1745,7 +1752,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
else
{
val = lstat (path, &files[files_index].stat);
#if HAVE_ACL
#if USE_ACL
files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
#endif
}

View File

@@ -59,12 +59,6 @@
# endif
#endif
#if _LIBC || STDC_HEADERS
# define TOLOWER(c) tolower (c)
#else
# define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
#endif
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum --check'. This length does
not include any newline character at the end of a line. */

View File

@@ -75,8 +75,8 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
int
main (int argc, char **argv)
{
unsigned int newmode;
unsigned int parent_mode;
mode_t newmode;
mode_t parent_mode;
const char *symbolic_mode = NULL;
const char *verbose_fmt_string = NULL;
int errors = 0;
@@ -117,8 +117,8 @@ main (int argc, char **argv)
usage (1);
}
newmode = 0777 & ~umask (0);
parent_mode = newmode | 0300; /* u+wx */
newmode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~ umask (0);
parent_mode = S_IWUSR | S_IXUSR | newmode;
if (symbolic_mode)
{
struct mode_change *change = mode_compile (symbolic_mode, 0);
@@ -138,7 +138,7 @@ main (int argc, char **argv)
}
else if (mkdir (argv[optind], newmode))
{
error (0, errno, _("cannot make directory `%s'"), argv[optind]);
error (0, errno, _("cannot create directory `%s'"), argv[optind]);
errors = 1;
}
else if (verbose_fmt_string)

View File

@@ -60,7 +60,7 @@ usage (int status)
printf (_("\
Create named pipes (FIFOs) with the given NAMEs.\n\
\n\
-m, --mode=MODE set permission mode (as in chmod), not 0666 - umask\n\
-m, --mode=MODE set permission mode (as in chmod), not a=rw - umask\n\
--help display this help and exit\n\
--version output version information and exit\n\
"));
@@ -74,7 +74,7 @@ Create named pipes (FIFOs) with the given NAMEs.\n\
int
main (int argc, char **argv)
{
unsigned short newmode;
mode_t newmode;
struct mode_change *change;
const char *symbolic_mode;
int errors = 0;
@@ -112,7 +112,8 @@ main (int argc, char **argv)
usage (1);
}
newmode = 0666 & ~umask (0);
newmode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
& ~ umask (0));
if (symbolic_mode)
{
change = mode_compile (symbolic_mode, 0);

View File

@@ -65,7 +65,7 @@ usage (int status)
printf (_("\
Create the special file NAME of the given TYPE.\n\
\n\
-m, --mode=MODE set permission mode (as in chmod), not 0666 - umask\n\
-m, --mode=MODE set permission mode (as in chmod), not a=rw - umask\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
@@ -84,7 +84,7 @@ MAJOR MINOR are forbidden for TYPE p, mandatory otherwise. TYPE may be:\n\
int
main (int argc, char **argv)
{
unsigned short newmode;
mode_t newmode;
struct mode_change *change;
const char *symbolic_mode;
int optc;
@@ -115,7 +115,8 @@ main (int argc, char **argv)
}
}
newmode = 0666 & ~umask (0);
newmode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
& ~ umask (0));
if (symbolic_mode)
{
change = mode_compile (symbolic_mode, 0);

View File

@@ -136,7 +136,7 @@ cp_option_init (struct cp_options *x)
when using chmod. The creation mask is set to be liberal, so
that created directories can be written, even if it would not
have been allowed with the mask this process was started with. */
x->umask_kill = 0777777 ^ umask (0);
x->umask_kill = ~ umask (0);
x->update = 0;
x->verbose = 0;

View File

@@ -20,7 +20,6 @@
#include <config.h>
#include <stdio.h>
#define NDEBUG
#include <assert.h>
#include <getopt.h>

View File

@@ -25,7 +25,7 @@
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "xstrtoul.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "od"
@@ -46,14 +46,6 @@ typedef double LONG_DOUBLE;
# include <values.h>
#endif
#ifndef MAX
# define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/* The default number of input bytes per output line. */
#define DEFAULT_BYTES_PER_BLOCK 16

View File

@@ -81,6 +81,56 @@ static struct option const longopts[] =
{NULL, 0, NULL, 0}
};
/* Count and return the number of ampersands in STR. */
static int
count_ampersands (const char *str)
{
int count = 0;
do
{
if (*str == '&')
count++;
} while (*str++);
return count;
}
/* Create a string (via xmalloc) which contains a full name by substituting
for each ampersand in GECOS_NAME the USER_NAME string with its first
character capitalized. The caller must ensure that GECOS_NAME contains
no `,'s. The caller also is responsible for free'ing the return value of
this function. */
static char *
create_fullname (const char *gecos_name, const char *user_name)
{
const int result_len = strlen (gecos_name)
+ count_ampersands (gecos_name) * (strlen (user_name) - 1) + 1;
char *const result = xmalloc (result_len);
char *r = result;
while (*gecos_name)
{
if (*gecos_name == '&')
{
const char *uname = user_name;
if (ISLOWER (*uname))
*r++ = TOUPPER (*uname++);
while (*uname)
*r++ = *uname++;
}
else
{
*r++ = *gecos_name;
}
gecos_name++;
}
*r = 0;
return result;
}
/* Return a string representing the time between WHEN and the time
that this function is first run. */
@@ -164,11 +214,14 @@ print_entry (const STRUCT_UTMP *utmp_ent)
else
{
char *const comma = strchr (pw->pw_gecos, ',');
char *result;
if (comma)
*comma = '\0';
/* FIXME: we don't yet convert '&' to username capitalized. */
printf (" %-19.19s", pw->pw_gecos);
result = create_fullname (pw->pw_gecos, pw->pw_name);
printf (" %-19.19s", result);
free (result);
}
}
@@ -245,11 +298,14 @@ print_long_entry (const char name[])
else
{
char *const comma = strchr (pw->pw_gecos, ',');
char *result;
if (comma)
*comma = '\0';
/* FIXME: we don't yet convert '&' to username capitalized. */
printf (" %s", pw->pw_gecos);
result = create_fullname (pw->pw_gecos, pw->pw_name);
printf (" %s", result);
free (result);
}
putchar ('\n');

View File

@@ -72,6 +72,23 @@
An overflow of the line length (without margin) over the input value
PAGE_WIDTH may occur.
The interference of the POSIX-compliant small letter options -w and -s:
(`interference' means `setting a _separator_ with -s switches off the
column sturctur and the default - not generally - page_width,
acts on -w option')
options: text form / separator: equivalent new capital
-w l -s[x] letter options:
--------------------------------------------------------------------
1. -- -- columns / space --
trunc. to page_width = 72
2. -- -s[:] full lines / TAB[:] -J -S["<TAB>"|:]
no truncation
3. -w l -- columns / space -W l
trunc. to page_width = l
4. -w l -s[:] columns / no sep.[:] -W l -S[:]
trunc. to page_width = l
--------------------------------------------------------------------
Options:
@@ -1637,7 +1654,7 @@ init_header (char *filename, int desc)
char *header_text;
struct tm *tmptr;
struct stat st;
char *datim = "- Date/Time --";
char *datim = "-- Date/Time -- ";
if (filename == NULL)
f = "";
@@ -1647,7 +1664,7 @@ init_header (char *filename, int desc)
header = (char *) xmalloc (chars_per_line + 1);
if (!standard_header && *custom_header == '\0')
sprintf (header, "%s", " "); /* blank line header */
*header = '\0'; /* blank line header */
else
{
#define T_BUF_FMT "%Y-%m-%d %H:%M" /* date/time short format */
@@ -2788,6 +2805,8 @@ produce empty pages.\n\
use form feeds instead of newlines to separate pages\n\
(by a 3-line page header with -F or a 5-line header\n\
and trailer without -F)\n\
"));
printf (_("\
-h HEADER, --header=HEADER\n\
use a centered HEADER instead of filename in page header,\n\
with long headers left-hand-side truncation may occur,\n\
@@ -2798,8 +2817,7 @@ produce empty pages.\n\
alignment, -S[STRING] sets separators\n\
-l PAGE_LENGTH, --length=PAGE_LENGTH\n\
set the page length to PAGE_LENGTH (66) lines\n\
(default number of lines of text 56, and with -F 63)\n"));
printf (_("\
(default number of lines of text 56, and with -F 63)\n\
-m, --merge print all files in parallel, one in each column,\n\
truncate lines, but join lines of full length with -J\n\
-n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]]\n\
@@ -2813,6 +2831,8 @@ produce empty pages.\n\
affect -w or -W, MARGIN will be added to PAGE_WIDTH\n\
-r, --no-file-warnings\n\
omit warning when a file cannot be opened\n\
"));
printf (_("\
-s[CHAR],--separator[=CHAR]\n\
separate columns by a single character, default for CHAR\n\
is the <TAB> character without -w and \'no char\' with -w\n\

View File

@@ -38,29 +38,6 @@
/* Number of possible characters in a byte. */
#define CHAR_SET_SIZE 256
/* The ctype definitions should work for all 256 characters. */
#if STDC_HEADERS
# include <ctype.h>
#else
# define isspace(C) ((C) == ' ' || (C) == '\t' || (C) == '\n')
# define isxdigit(C) \
(((unsigned char) (C) >= 'a' && (unsigned char) (C) <= 'f') \
|| ((unsigned char) (C) >= 'A' && (unsigned char) (C) <= 'F') \
|| ((unsigned char) (C) >= '0' && (unsigned char) (C) <= '9'))
# define islower(C) ((unsigned char) (C) >= 'a' && (unsigned char) (C) <= 'z')
# define isupper(C) ((unsigned char) (C) >= 'A' && (unsigned char) (C) <= 'Z')
# define isalpha(C) (islower (C) || isupper (C))
# define toupper(C) (islower (C) ? (C) - 'a' + 'A' : (C))
#endif
#if !defined (isascii) || defined (STDC_HEADERS)
# undef isascii
# define isascii(C) 1
#endif
#ifndef ISXDIGIT
# define ISXDIGIT(C) (isascii (C) && isxdigit (C))
#endif
#define ISODIGIT(C) ((C) >= '0' && (C) <= '7')
#define HEXTOBIN(C) ((C) >= 'a' && (C) <= 'f' ? (C)-'a'+10 \
: (C) >= 'A' && (C) <= 'F' ? (C)-'A'+10 : (C)-'0')
@@ -196,15 +173,15 @@ char *text_buffer_maxend; /* allocated end of text_buffer */
/* SKIP_NON_WHITE used only for getting or skipping the reference. */
#define SKIP_NON_WHITE(cursor, limit) \
while (cursor < limit && !isspace(*cursor)) \
while (cursor < limit && !ISSPACE(*cursor)) \
cursor++
#define SKIP_WHITE(cursor, limit) \
while (cursor < limit && isspace(*cursor)) \
while (cursor < limit && ISSPACE(*cursor)) \
cursor++
#define SKIP_WHITE_BACKWARDS(cursor, start) \
while (cursor > start && isspace(cursor[-1])) \
while (cursor > start && ISSPACE(cursor[-1])) \
cursor--
#define SKIP_SOMETHING(cursor, limit) \
@@ -462,13 +439,13 @@ initialize_regex (void)
/* Initialize the regex syntax table. */
for (character = 0; character < CHAR_SET_SIZE; character++)
syntax_table[character] = isalpha (character) ? Sword : 0;
syntax_table[character] = ISALPHA (character) ? Sword : 0;
/* Initialize the case folding table. */
if (ignore_case)
for (character = 0; character < CHAR_SET_SIZE; character++)
folded_chars[character] = toupper (character);
folded_chars[character] = TOUPPER (character);
/* Unless the user already provided a description of the end of line or
end of sentence sequence, select an end of line sequence to compile.
@@ -508,7 +485,7 @@ initialize_regex (void)
/* Simulate \w+. */
for (character = 0; character < CHAR_SET_SIZE; character++)
word_fastmap[character] = isalpha (character) ? 1 : 0;
word_fastmap[character] = ISALPHA (character) ? 1 : 0;
}
else
{
@@ -1368,7 +1345,7 @@ fix_output_parameters (void)
form feed as a space character, but we do. */
for (character = 0; character < CHAR_SET_SIZE; character++)
edited_flag[character] = isspace (character) != 0;
edited_flag[character] = ISSPACE (character) != 0;
edited_flag['\f'] = 1;
/* Complete the special character flagging according to selected output

View File

@@ -247,7 +247,7 @@ pop_dir (void)
/* Pop the length stack, too. */
assert (obstack_object_size (&len_stack) >= sizeof (size_t));
obstack_blank (&len_stack, -(sizeof (size_t)));
obstack_blank (&len_stack, (int) -(sizeof (size_t)));
}
/* Copy the SRC_LEN bytes of data beginning at SRC into the DST_LEN-byte

View File

@@ -57,6 +57,10 @@ static char *separator;
/* FIXME: make this an option. */
static char *terminator = "\n";
/* The representation of the decimal point in the current locale.
Always "." if the localeconv function is not supported. */
static char *decimal_point = ".";
/* The increment. */
static double step;
@@ -124,20 +128,35 @@ main (int argc, char **argv)
first = 1.0;
step_is_set = 0;
/* Figure out the locale's idea of a decimal point. */
#ifdef HAVE_LOCALECONV
{
struct lconv *locale;
locale = localeconv ();
/* Paranoia. */
if (locale && locale->decimal_point && locale->decimal_point[0] != '\0')
decimal_point = locale->decimal_point;
}
#endif
/* We have to handle negative numbers in the command line but this
conflicts with the command line arguments. So the getopt mode is
REQUIRE_ORDER (the '+' in the format string) and it abort on the
first non-option or negative number. */
while ((optc = getopt_long (argc, argv, "+0123456789f:s:w", long_options,
NULL)) != -1)
conflicts with the command line arguments. So explicitly check first
whether the next argument looks like a negative number. */
while (optind < argc)
{
if ('0' <= optc && optc <= '9')
if (argv[optind][0] == '-'
&& ((optc = argv[optind][1]) == decimal_point[0]
|| ISDIGIT (optc)))
{
/* means negative number */
--optind;
break;
}
optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);
if (optc == -1)
break;
switch (optc)
{
case 0:
@@ -336,26 +355,32 @@ get_width_format ()
}
full_width = width1;
sprintf (buffer, "%g", 1.0 + modf (min_val, &temp));
sprintf (buffer, "%g", 1.0 + modf (fabs (min_val), &temp));
width1 = strlen (buffer);
if (width1 == 1)
width1 = 0;
else
{
if (buffer[0] != '1' || buffer[1] != '.' ||
buffer[2 + strspn (&buffer[2], "0123456789")] != '\0')
if (buffer[0] != '1'
/* FIXME: assumes that decimal_point is a single character
string. */
|| buffer[1] != decimal_point[0]
|| buffer[2 + strspn (&buffer[2], "0123456789")] != '\0')
return "%g";
width1 -= 2;
}
sprintf (buffer, "%g", 1.0 + modf (step, &temp));
sprintf (buffer, "%g", 1.0 + modf (fabs (step), &temp));
width2 = strlen (buffer);
if (width2 == 1)
width2 = 0;
else
{
if (buffer[0] != '1' || buffer[1] != '.' ||
buffer[2 + strspn (&buffer[2], "0123456789")] != '\0')
if (buffer[0] != '1'
/* FIXME: assumes that decimal_point is a single character
string. */
|| buffer[1] != decimal_point[0]
|| buffer[2 + strspn (&buffer[2], "0123456789")] != '\0')
return "%g";
width2 -= 2;
}

File diff suppressed because it is too large Load Diff

1193
src/sort.c

File diff suppressed because it is too large Load Diff

View File

@@ -3,14 +3,6 @@
more time, I'll merge the remaining things in system.h and everything
in this file will go back there. */
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
#ifndef GID_T_MAX
# define GID_T_MAX TYPE_MAXIMUM (gid_t)
#endif
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
@@ -62,7 +54,7 @@ char *alloca ();
character >= 128 which gets sign-extended to a negative value.
The macro ISUPPER protects against this as well." */
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
#if STDC_HEADERS || (!defined (isascii) && !HAVE_ISASCII)
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
@@ -90,6 +82,14 @@ char *alloca ();
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#if STDC_HEADERS
# define TOLOWER(Ch) tolower (Ch)
# define TOUPPER(Ch) toupper (Ch)
#else
# define TOLOWER(Ch) (ISUPPER (Ch) ? tolower (Ch) : (Ch))
# define TOUPPER(Ch) (ISLOWER (Ch) ? toupper (Ch) : (Ch))
#endif
/* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char.
- It's guaranteed to evaluate its argument exactly once.
@@ -129,7 +129,7 @@ char *alloca ();
#endif
#define N_(Text) Text
#define STREQ(a,b) (strcmp((a), (b)) == 0)
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
#ifndef HAVE_DECL_FREE
void free ();
@@ -274,3 +274,75 @@ char *base_name PARAMS ((char const *));
close_stdout (); \
exit (EXIT_SUCCESS); \
break;
#ifndef MAX
# define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
#ifndef CHAR_MIN
# define CHAR_MIN TYPE_MINIMUM (char)
#endif
#ifndef CHAR_MAX
# define CHAR_MAX TYPE_MAXIMUM (char)
#endif
#ifndef SCHAR_MIN
# define SCHAR_MIN (-1 - SCHAR_MAX)
#endif
#ifndef SCHAR_MAX
# define SCHAR_MAX (CHAR_MAX == UCHAR_MAX ? CHAR_MAX / 2 : CHAR_MAX)
#endif
#ifndef UCHAR_MAX
# define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
#endif
#ifndef SHRT_MIN
# define SHRT_MIN TYPE_MINIMUM (short int)
#endif
#ifndef SHRT_MAX
# define SHRT_MAX TYPE_MAXIMUM (short int)
#endif
#ifndef INT_MAX
# define INT_MAX TYPE_MAXIMUM (int)
#endif
#ifndef UINT_MAX
# define UINT_MAX TYPE_MAXIMUM (unsigned int)
#endif
#ifndef LONG_MAX
# define LONG_MAX TYPE_MAXIMUM (long)
#endif
#ifndef ULONG_MAX
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
#endif
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
#ifndef GID_T_MAX
# define GID_T_MAX TYPE_MAXIMUM (gid_t)
#endif

View File

@@ -68,6 +68,18 @@
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
#endif
#if !S_ISUID
# define S_ISUID 04000
#endif
#if !S_ISGID
# define S_ISGID 02000
#endif
/* S_ISVTX is a common extension to POSIX.1. */
#ifndef S_ISVTX
# define S_ISVTX 01000
#endif
#if !S_IWUSR
# if S_IWRITE
# define S_IWUSR S_IWRITE
@@ -97,10 +109,26 @@
#ifndef S_IXOTH
# define S_IXOTH (S_IEXEC >> 6)
#endif
#ifndef S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif
#ifndef S_IRWXG
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif
#ifndef S_IRWXO
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif
/* S_IXUGO is a common extension to POSIX.1. */
#ifndef S_IXUGO
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
/* All the mode bits that can be affected by chmod. */
#define CHMOD_MODE_BITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
#ifdef ST_MTIM_NSEC
# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns)
#else
@@ -145,53 +173,6 @@
# include <limits.h>
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs,
e.g. Cray C 5.0.3.0 when t == time_t. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
#ifndef CHAR_MIN
# define CHAR_MIN TYPE_MINIMUM (char)
#endif
#ifndef CHAR_MAX
# define CHAR_MAX TYPE_MAXIMUM (char)
#endif
#ifndef UCHAR_MAX
# define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
#endif
#ifndef SHRT_MIN
# define SHRT_MIN TYPE_MINIMUM (short int)
#endif
#ifndef SHRT_MAX
# define SHRT_MAX TYPE_MAXIMUM (short int)
#endif
#ifndef INT_MAX
# define INT_MAX TYPE_MAXIMUM (int)
#endif
#ifndef UINT_MAX
# define UINT_MAX TYPE_MAXIMUM (unsigned int)
#endif
#ifndef LONG_MAX
# define LONG_MAX TYPE_MAXIMUM (long)
#endif
#ifndef ULONG_MAX
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
#endif
#include "pathmax.h"
#if TIME_WITH_SYS_TIME

View File

@@ -34,7 +34,7 @@
#include "argmatch.h"
#include "error.h"
#include "safe-read.h"
#include "xstrtoul.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "tail"
@@ -58,6 +58,9 @@
# define BUFSIZ (512 * 8)
#endif
/* A special value for dump_remainder's N_BYTES parameter. */
#define COPY_TO_EOF OFF_T_MAX
/* FIXME: make Follow_name the default? */
#define DEFAULT_FOLLOW_MODE Follow_descriptor
@@ -235,7 +238,7 @@ pretty_name (struct File_spec const *f)
static void
xwrite (int fd, char *const buffer, size_t n_bytes)
{
assert (fd == 1);
assert (fd == STDOUT_FILENO);
assert (n_bytes >= 0);
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) == 0)
error (EXIT_FAILURE, errno, _("write error"));
@@ -261,20 +264,51 @@ write_header (const char *pretty_filename, const char *comment)
first_file = 0;
}
/* Read and output N_BYTES of file PRETTY_FILENAME starting at the current
position in FD. If N_BYTES is COPY_TO_EOF, then copy until end of file.
Return the number of bytes read from the file. */
static long
dump_remainder (const char *pretty_filename, int fd, off_t n_bytes)
{
char buffer[BUFSIZ];
int bytes_read;
long n_written;
off_t n_remaining = n_bytes;
n_written = 0;
while (1)
{
long n = MIN (n_remaining, (off_t) BUFSIZ);
bytes_read = safe_read (fd, buffer, n);
if (bytes_read <= 0)
break;
xwrite (STDOUT_FILENO, buffer, bytes_read);
n_remaining -= bytes_read;
n_written += bytes_read;
}
if (bytes_read == -1)
error (EXIT_FAILURE, errno, "%s", pretty_filename);
return n_written;
}
/* Print the last N_LINES lines from the end of file FD.
Go backward through the file, reading `BUFSIZ' bytes at a time (except
probably the first), until we hit the start of the file or have
read NUMBER newlines.
POS starts out as the length of the file (the offset of the last
byte of the file + 1).
FILE_LENGTH is the length of the file (one more than the offset of the
last byte of the file).
Return 0 if successful, 1 if an error occurred. */
static int
file_lines (const char *pretty_filename, int fd, long int n_lines, off_t pos)
file_lines (const char *pretty_filename, int fd, long int n_lines,
off_t file_length)
{
char buffer[BUFSIZ];
int bytes_read;
int i; /* Index into `buffer' for scanning. */
off_t pos = file_length;
if (n_lines == 0)
return 0;
@@ -312,6 +346,8 @@ file_lines (const char *pretty_filename, int fd, long int n_lines, off_t pos)
print the text after it. */
if (i != bytes_read - 1)
xwrite (STDOUT_FILENO, &buffer[i + 1], bytes_read - (i + 1));
dump_remainder (pretty_filename, fd,
file_length - (pos + bytes_read));
return 0;
}
}
@@ -321,6 +357,7 @@ file_lines (const char *pretty_filename, int fd, long int n_lines, off_t pos)
/* Not enough lines in the file; print the entire file. */
/* FIXME: check lseek return value */
lseek (fd, (off_t) 0, SEEK_SET);
dump_remainder (pretty_filename, fd, file_length);
return 0;
}
pos -= BUFSIZ;
@@ -328,11 +365,13 @@ file_lines (const char *pretty_filename, int fd, long int n_lines, off_t pos)
lseek (fd, pos, SEEK_SET);
}
while ((bytes_read = safe_read (fd, buffer, BUFSIZ)) > 0);
if (bytes_read == -1)
{
error (0, errno, "%s", pretty_filename);
return 1;
}
return 0;
}
@@ -603,28 +642,6 @@ start_lines (const char *pretty_filename, int fd, long int n_lines)
return 0;
}
/* Display file PRETTY_FILENAME from the current position in FD to the end.
Return the number of bytes read from the file. */
static long
dump_remainder (const char *pretty_filename, int fd)
{
char buffer[BUFSIZ];
int bytes_read;
long total;
total = 0;
while ((bytes_read = safe_read (fd, buffer, BUFSIZ)) > 0)
{
xwrite (STDOUT_FILENO, buffer, bytes_read);
total += bytes_read;
}
if (bytes_read == -1)
error (EXIT_FAILURE, errno, "%s", pretty_filename);
return total;
}
/* FIXME: describe */
static void
@@ -828,7 +845,8 @@ tail_forever (struct File_spec *f, int nfiles)
write_header (pretty_name (&f[i]), NULL);
last = i;
}
f[i].size += dump_remainder (pretty_name (&f[i]), f[i].fd);
f[i].size += dump_remainder (pretty_name (&f[i]), f[i].fd,
COPY_TO_EOF);
}
if (n_live_files (f, nfiles) == 0 && ! allow_missing)
@@ -855,10 +873,6 @@ tail_bytes (const char *pretty_filename, int fd, off_t n_bytes)
while binary output will preserve the style (Unix/DOS) of text file. */
SET_BINARY2 (fd, STDOUT_FILENO);
/* FIXME: resolve this like in dd.c. */
/* Use fstat instead of checking for errno == ESPIPE because
lseek doesn't work on some special files but doesn't return an
error, either. */
if (fstat (fd, &stats))
{
error (0, errno, "%s", pretty_filename);
@@ -876,7 +890,7 @@ tail_bytes (const char *pretty_filename, int fd, off_t n_bytes)
{
return 1;
}
dump_remainder (pretty_filename, fd);
dump_remainder (pretty_filename, fd, COPY_TO_EOF);
}
else
{
@@ -915,7 +929,7 @@ tail_bytes (const char *pretty_filename, int fd, off_t n_bytes)
/* FIXME: check lseek return value */
lseek (fd, -n_bytes, SEEK_END);
}
dump_remainder (pretty_filename, fd);
dump_remainder (pretty_filename, fd, n_bytes);
}
else
return pipe_bytes (pretty_filename, fd, n_bytes);
@@ -946,7 +960,7 @@ tail_lines (const char *pretty_filename, int fd, long int n_lines)
{
if (start_lines (pretty_filename, fd, n_lines))
return 1;
dump_remainder (pretty_filename, fd);
dump_remainder (pretty_filename, fd, COPY_TO_EOF);
}
else
{
@@ -962,7 +976,6 @@ tail_lines (const char *pretty_filename, int fd, long int n_lines)
length = lseek (fd, (off_t) 0, SEEK_END);
if (length != 0 && file_lines (pretty_filename, fd, n_lines, length))
return 1;
dump_remainder (pretty_filename, fd);
}
else
return pipe_lines (pretty_filename, fd, n_lines);

View File

@@ -83,7 +83,7 @@ static struct option const longopts[] =
{"time", required_argument, 0, CHAR_MAX + 1},
{"no-create", no_argument, 0, 'c'},
{"date", required_argument, 0, 'd'},
{"file", required_argument, 0, 'r'},
{"file", required_argument, 0, 'r'}, /* FIXME: phase out --file */
{"reference", required_argument, 0, 'r'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
@@ -115,13 +115,15 @@ open_maybe_create (const char *file, int *file_created)
while (1)
{
/* First, see if we can create a new FILE. */
fd = open (file, O_WRONLY | O_CREAT | O_EXCL, 0666);
fd = open (file, O_WRONLY | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd != -1)
*file_created = 1;
/* If the open succeeded or if it failed for any reason other
than the existence of FILE, then we're done. */
if (fd != -1 || errno != EEXIST)
than the existence of FILE, then we're done. Some systems
(solaris) set errno to EINVAL when FILE is a directory. */
if (fd != -1 || (errno != EEXIST && errno != EINVAL))
break;
/* The first open failed because FILE already exists.
@@ -167,30 +169,44 @@ touch (const char *file)
fd = open_maybe_create (file, &file_created);
}
if (fd == -1)
/* Don't fail if the open failed because FILE is a directory. */
if (fd == -1
/* As usual, using E* macros like this is risky...
So heads up. */
&& errno != EISDIR)
{
error (0, errno, "%s", file);
return 1;
}
if (file_created && amtime_now)
if (amtime_now)
{
if (close (fd) < 0)
if (file_created)
{
if (close (fd) < 0)
{
error (0, errno, "%s", file);
return 1;
}
/* We've just created the file with the current times. */
return 0;
}
}
else
{
/* We're setting only one of the time values. stat the target to get
the other one. If we have the file descriptor already, use fstat,
otherwise, FILE is a directory, so we have to use stat. */
if (fd == -1 ? stat (file, &sbuf) : fstat (fd, &sbuf))
{
error (0, errno, "%s", file);
close (fd);
return 1;
}
return 0; /* We've done all we have to. */
}
if (fstat (fd, &sbuf))
{
error (0, errno, "%s", file);
close (fd);
return 1;
}
if (close (fd) < 0)
if (fd != -1 && close (fd) < 0)
{
error (0, errno, "%s", file);
return 1;
@@ -251,7 +267,7 @@ usage (int status)
Update the access and modification times of each FILE to the current time.\n\
\n\
-a change only the access time\n\
-c do not create any files\n\
-c, --no-create do not create any files\n\
-d, --date=STRING parse STRING and use it instead of current time\n\
-f (ignored)\n\
-m change only the modification time\n\

View File

@@ -181,7 +181,7 @@ search_item (struct item *root, const char *str)
else
{
r = p = s->right;
a = +1;
a = 1;
}
while (p != q)
@@ -194,7 +194,7 @@ search_item (struct item *root, const char *str)
}
else
{
p->balance = +1;
p->balance = 1;
p = p->right;
}
}

View File

@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by jla; revised by djm */
/* Created by hacking who.c by Kaveh Ghazi ghazi@caip.rutgers.edu. */
#include <config.h>
#include <getopt.h>
@@ -29,7 +29,7 @@
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "uptime"
#define AUTHORS "Joseph Arceneaux and David MacKenzie"
#define AUTHORS "Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi"
int getloadavg ();

View File

@@ -47,6 +47,7 @@
int gethostname ();
char *ttyname ();
char *canon_host ();
/* The name this program was run with. */
char *program_name;
@@ -173,10 +174,9 @@ print_entry (const STRUCT_UTMP *utmp_ent)
else
printf (" . ");
}
#ifdef HAVE_UT_HOST
#if HAVE_UT_HOST
if (utmp_ent->ut_host[0] && do_lookup)
{
extern char *canon_host ();
char ut_host[sizeof (utmp_ent->ut_host) + 1];
char *host = 0, *display = 0;

8
tests/.env-warn Normal file
View File

@@ -0,0 +1,8 @@
***************************** WARNING ************************************
You seem to have set the %% environment variable,
this might cause some of the tests in this package to fail.
If any test fails, clear %% from the environment,
and rerun all tests.
***************************** WARNING ************************************

View File

@@ -57,12 +57,17 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
@@ -104,17 +109,23 @@ AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) srcdir=$(srcdir) PERL="@PERL@" PATH=../../src:$$PATH PROG=basename
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="@PERL@" \
PATH=../../src:$$PATH \
PROG=basename
subdir = tests/basename
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
@@ -131,8 +142,6 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/basename
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -149,25 +158,52 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; \
@failed=0; all=0; xfail=0; xpass=0; \
srcdir=$(srcdir); export srcdir; \
for tst in $(TESTS); do \
if test -f $$tst; then dir=.; \
else dir="$(srcdir)"; fi; \
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
echo "PASS: $$tst"; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
echo "XPASS: $$tst"; \
;; \
*) \
echo "PASS: $$tst"; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xfail=`expr $$xfail + 1`; \
echo "XFAIL: $$tst"; \
;; \
*) \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
;; \
esac; \
fi; \
done; \
if test "$$failed" -eq 0; then \
banner="All $$all tests passed"; \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
fi; \
else \
banner="$$failed of $$all tests failed"; \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all tests failed"; \
else \
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
fi; \
fi; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
@@ -231,7 +267,7 @@ maintainer-clean: maintainer-clean-am
.PHONY: tags distdir check-TESTS info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
all-redirect all-am all install-strip installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean

View File

@@ -57,6 +57,10 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -64,6 +68,7 @@ CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
@@ -99,13 +104,15 @@ EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH
subdir = tests/chmod
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
@@ -123,8 +130,6 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/chmod
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -141,6 +146,7 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; \
srcdir=$(srcdir); export srcdir; \

View File

@@ -57,6 +57,10 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AMTAR = @AMTAR@
AMTARFLAGS = @AMTARFLAGS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -64,6 +68,7 @@ CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DF_PROG = @DF_PROG@
GENCAT = @GENCAT@
GETCONF = @GETCONF@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
@@ -102,13 +107,15 @@ EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH
subdir = tests/cp
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
@@ -126,8 +133,6 @@ TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/cp
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
@@ -144,6 +149,7 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; \
srcdir=$(srcdir); export srcdir; \

Some files were not shown because too many files have changed in this diff Show More