Compare commits

...

585 Commits

Author SHA1 Message Date
Jim Meyering
be9f2f6ef6 *** empty log message *** 2001-02-18 16:56:57 +00:00
Jim Meyering
320475d619 *** empty log message *** 2001-02-18 16:27:16 +00:00
Jim Meyering
025068df27 *** empty log message *** 2001-02-18 16:25:57 +00:00
Jim Meyering
b7f166b3fd *** empty log message *** 2001-02-18 16:24:26 +00:00
Jim Meyering
57e7dc4cda `chmod 0 file; rm file' would no longer prompt before removal.
(remove_file): Revert last change.
2001-02-18 16:24:21 +00:00
Jim Meyering
325680aae4 *** empty log message *** 2001-02-18 08:50:35 +00:00
Jim Meyering
7446097d1a rename test input files to avoid conflicts on case-insensitive file systems 2001-02-18 08:50:29 +00:00
Jim Meyering
96bbda7216 Update file names to reflect renamings. 2001-02-18 08:49:52 +00:00
Jim Meyering
7f77515e02 *** empty log message *** 2001-02-18 08:49:07 +00:00
Jim Meyering
2714dd0ed2 . 2001-02-18 08:07:42 +00:00
Jim Meyering
7dfaaf5bf1 fix typo 2001-02-17 18:50:17 +00:00
Jim Meyering
4d30007986 *** empty log message *** 2001-02-17 16:56:27 +00:00
Jim Meyering
d07a45be2b Sync from GNU libc. Use double quotes, not <...>
around included file name.
2001-02-17 16:56:20 +00:00
Jim Meyering
438636be9b *** empty log message *** 2001-02-17 16:53:38 +00:00
Jim Meyering
ff7797f6e2 (__strnlen): Merge in a change from GNU libc. 2001-02-17 16:53:33 +00:00
Jim Meyering
d81e0e6f97 *** empty log message *** 2001-02-17 16:51:03 +00:00
Jim Meyering
787a2cf49f update comments from libc 2001-02-17 16:50:27 +00:00
Jim Meyering
9676083a22 *** empty log message *** 2001-02-17 14:23:54 +00:00
Jim Meyering
8d509a79da (main): `quote' the offending argument. 2001-02-17 14:23:43 +00:00
Jim Meyering
1de5de8401 *** empty log message *** 2001-02-17 13:20:31 +00:00
Jim Meyering
e7a4ab5efa (mbrtowc, mbsinit):
Remove workaround macros for hosts that have mbrtowc but not
mbstate_t, as we now insist on proper declarations for both
before using mbrtowc.
2001-02-17 13:18:56 +00:00
Jim Meyering
c2223ba418 . 2001-02-17 13:18:17 +00:00
Jim Meyering
5bc2860579 . 2001-02-17 13:17:49 +00:00
Jim Meyering
0c2cd33ac8 *** empty log message *** 2001-02-17 13:17:40 +00:00
Jim Meyering
198a0609cf *** empty log message *** 2001-02-17 13:11:22 +00:00
Jim Meyering
8270c52b6b *** empty log message *** 2001-02-17 13:11:12 +00:00
Jim Meyering
5d223fd617 *** empty log message *** 2001-02-17 12:53:40 +00:00
Jim Meyering
a256689440 (jm_LIST_MOUNTED_FILESYSTEMS): Don't check for
getmntent via AC_CHECK_FUNCS, since that would get a `no' and disrupt
further attempts by AC_FUNC_GETMNTENT to check with e.g., -lgen on
UnixWare 7.1.1.
2001-02-17 12:53:36 +00:00
Jim Meyering
557c8b8ae8 *** empty log message *** 2001-02-17 12:44:04 +00:00
Jim Meyering
22bdd77f67 (mbswidth): Also define as macro, to avoid prototype clash. 2001-02-17 12:43:57 +00:00
Jim Meyering
fba069f78c . 2001-02-17 11:51:48 +00:00
Jim Meyering
2f4ff2ce9f *** empty log message *** 2001-02-17 10:39:50 +00:00
Jim Meyering
ad177f456c (mbrtowc, mbsinit):
Remove workaround macros for hosts that have mbrtowc but not
mbstate_t, as we now insist on proper declarations for both
before using mbrtowc.
2001-02-17 10:39:43 +00:00
Jim Meyering
1f7a13e62e (mbrtowc, mbsinit):
Remove workaround macros for hosts that have mbrtowc but not
mbstate_t, as we now insist on proper declarations for both
before using mbrtowc.
2001-02-17 10:39:17 +00:00
Jim Meyering
78d17132eb *** empty log message *** 2001-02-17 10:37:10 +00:00
Jim Meyering
2a1afebeb4 *** empty log message *** 2001-02-17 10:36:42 +00:00
Jim Meyering
8ec9cd1836 (jm_FUNC_MBRTOWC): Adapt to use AC_CACHE_CHECK etc., rather than AC_CACHE_VAL. 2001-02-17 10:36:33 +00:00
Jim Meyering
11038c572e bump serial number 2001-02-17 09:35:50 +00:00
Jim Meyering
e3a56266dd bump serial number 2001-02-17 09:35:11 +00:00
Jim Meyering
78e5a1082a (jm_PREREQ_QUOTEARG): Use jm_FUNC_MBRTOWC, not AC_CHECK_FUNCS(mbrtowc). 2001-02-17 09:34:57 +00:00
Jim Meyering
3ede7fb763 (jm_PREREQ_MBSWIDTH):
Use jm_FUNC_MBRTOWC, not AC_CHECK_FUNCS(mbrtowc).
2001-02-17 09:34:14 +00:00
Jim Meyering
0048e2bb67 New file, defining jm_FUNC_MBRTOWC. 2001-02-17 09:33:25 +00:00
Jim Meyering
09221df9c6 *** empty log message *** 2001-02-17 08:59:19 +00:00
Jim Meyering
5044873647 . 2001-02-17 08:55:17 +00:00
Jim Meyering
4bcbd9c6aa Update from libc. 2001-02-17 07:14:31 +00:00
Jim Meyering
98c5eb08be *** empty log message *** 2001-02-17 07:13:03 +00:00
Jim Meyering
9db34852ce *** empty log message *** 2001-02-17 07:12:17 +00:00
Jim Meyering
cd5ba13ce2 *** empty log message *** 2001-02-17 07:05:58 +00:00
Jim Meyering
ecf425de69 Mention that only English is supported.
Show how to use "date" so that the output is acceptable to getdate.
Mention Z as an abbreviation for UTC.
2001-02-17 07:05:33 +00:00
Jim Meyering
e94c44b8f0 *** empty log message *** 2001-02-16 19:31:18 +00:00
Jim Meyering
9cdff96426 (malloc): Undef before defining, since stdlib.h may have defined it. 2001-02-16 19:28:43 +00:00
Jim Meyering
f77dc12f7f *** empty log message *** 2001-02-11 16:24:54 +00:00
Jim Meyering
37c3f113f5 depend on writable-files po-check once again 2001-02-11 16:24:39 +00:00
Jim Meyering
88287082b0 (emit-rsync-commands): Define.
(alpha): Use it here.
2001-02-11 16:24:01 +00:00
Jim Meyering
787421de85 (alpha): Fix previous, incomplete change. 2001-02-10 09:40:19 +00:00
Jim Meyering
47e01313ad *** empty log message *** 2001-02-10 09:40:09 +00:00
Jim Meyering
ba42a3c5b2 . 2001-02-10 09:22:11 +00:00
Jim Meyering
a103ea415c *** empty log message *** 2001-02-10 09:17:03 +00:00
Jim Meyering
4778b57c26 . 2001-02-08 10:43:44 +00:00
Jim Meyering
70c58eb46a update from libc 2001-02-08 06:49:29 +00:00
Jim Meyering
075c8604cb *** empty log message *** 2001-02-07 11:50:30 +00:00
Jim Meyering
55cebafa24 (jm_INCLUDED_REGEX): Add a test for the latest bug. 2001-02-07 11:50:25 +00:00
Jim Meyering
d5c34a9824 *** empty log message *** 2001-02-07 11:50:01 +00:00
Jim Meyering
b2cb2e804e *** empty log message *** 2001-02-07 11:47:40 +00:00
Jim Meyering
0019b6cebf Update from libc. 2001-02-07 11:47:24 +00:00
Jim Meyering
30323f5739 require 1 argument 2001-02-06 09:56:22 +00:00
Jim Meyering
1de223c226 better comment 2001-02-06 09:53:58 +00:00
Jim Meyering
eeae6e79dd emit a comment, print numbers one per line 2001-02-06 09:34:18 +00:00
Jim Meyering
47b335399c remove parens 2001-02-06 09:04:01 +00:00
Jim Meyering
871c0f6caa move decl of q into loop 2001-02-06 09:03:47 +00:00
Jim Meyering
20f3fe5f32 remove n0 2001-02-06 08:42:33 +00:00
Jim Meyering
0aee2ba653 *** empty log message *** 2001-02-05 22:29:57 +00:00
Jim Meyering
4723d1adde Require autoconf-2.14d (not yet released), because
it includes the patch required for `large file' support with at least
HP-UX's 10.20 /bin/cc.
2001-02-05 22:29:52 +00:00
Jim Meyering
987834edba *** empty log message *** 2001-02-05 10:39:40 +00:00
Jim Meyering
2c618b8359 . 2001-02-04 17:19:51 +00:00
Jim Meyering
45ee51d156 remove --help --version, etc 2001-02-04 16:50:07 +00:00
Jim Meyering
934fbc196c *** empty log message *** 2001-02-04 16:28:49 +00:00
Jim Meyering
e7b9e3e7c1 (usage): Tweak --help output: it prints the _prime_
factors, not just any factors.
2001-02-04 16:28:41 +00:00
Jim Meyering
ff10610d6c (is_prime): Remove function. 2001-02-04 15:52:17 +00:00
Jim Meyering
23d47fb4aa *** empty log message *** 2001-02-04 14:04:42 +00:00
Jim Meyering
6bb0a39d24 *** empty log message *** 2001-02-04 12:42:38 +00:00
Jim Meyering
8b8419e185 *** empty log message *** 2001-02-04 12:29:18 +00:00
Jim Meyering
e2625cbbcd fix typo: s/found/yes/ 2001-02-04 08:28:29 +00:00
Jim Meyering
e7ec75cca0 . 2001-02-03 20:23:26 +00:00
Jim Meyering
a1321f00a8 . 2001-02-03 20:23:05 +00:00
Jim Meyering
d622232fb2 (main): Change type of index variable to `unsigned int' to avoid a warning. 2001-02-03 20:22:58 +00:00
Jim Meyering
6aca235a6f *** empty log message *** 2001-02-03 17:29:53 +00:00
Jim Meyering
d22bee04aa *** empty log message *** 2001-02-03 16:51:23 +00:00
Jim Meyering
c036ffc1cc (long_opts): Use `strip-trailing-slashes',
per the documetation, not `strip-trailing-slash'.
2001-02-03 16:50:34 +00:00
Jim Meyering
99d7f7d422 (long_options): Use `strip-trailing-slashes',
per the documetation, not `strip-trailing-slash'.
2001-02-03 16:50:04 +00:00
Jim Meyering
5cb10ea445 (a_host): Use fencepost.
(real_dir): Use the same name for both.
(alpha): Print commands for both hosts.
2001-02-03 16:47:55 +00:00
Jim Meyering
7a493e5c54 *** empty log message *** 2001-02-03 16:45:30 +00:00
Jim Meyering
da56b3ffb6 (jm_FILE_SYSTEM_USAGE): Restore prior use of
AS_IF, now that it works once again (mysteriously).
2001-02-03 16:45:25 +00:00
Jim Meyering
8525d006fc (jm_LIST_MOUNTED_FILESYSTEMS): Restore prior use of
AS_IF, now that it works once again (mysteriously).
2001-02-03 16:44:52 +00:00
Jim Meyering
3f6077b5bb *** empty log message *** 2001-02-03 13:37:55 +00:00
Jim Meyering
52377e246d Improve the performance of `factor' (more than 2x speed-up for large N).
(wheel_tab): New global table.
(WHEEL_START, WHEEL_END): Define.
(factor): Remove the loop that special-cased `2'.
Instead of incrementing by `2', use the offsets from the wheel table.
From Michael Steffens.
2001-02-03 13:37:37 +00:00
Jim Meyering
c83137adb3 *** empty log message *** 2001-02-03 10:31:39 +00:00
Jim Meyering
ed71d8021e *** empty log message *** 2001-02-03 10:29:01 +00:00
Jim Meyering
3ff0f8076b . 2001-01-31 19:15:41 +00:00
Jim Meyering
3dd1381c64 *** empty log message *** 2001-01-30 21:50:36 +00:00
Jim Meyering
1f8a8b45ff Update for FreeBSD 4.2. 2001-01-30 21:50:32 +00:00
Jim Meyering
78e3f940b7 *** empty log message *** 2001-01-30 13:05:48 +00:00
Jim Meyering
d06b301fd0 *** empty log message *** 2001-01-30 13:04:17 +00:00
Jim Meyering
a772996d99 *** empty log message *** 2001-01-30 08:24:21 +00:00
Jim Meyering
2a4617da4c s/conftestdata/conftest.data/ 2001-01-30 08:24:13 +00:00
Jim Meyering
629c01e2c2 s/conftestdir/conftest.d1/ and s/conftestdir2/conftest.d2/. 2001-01-30 08:21:02 +00:00
Jim Meyering
5326a0b265 Rename conftestchown to conftest.chown. 2001-01-30 08:19:25 +00:00
Jim Meyering
f318f5c4d8 *** empty log message *** 2001-01-28 22:25:48 +00:00
Jim Meyering
30bbbfe67a *** empty log message *** 2001-01-28 22:25:04 +00:00
Jim Meyering
f06dd61f03 *** empty log message *** 2001-01-28 22:24:14 +00:00
Jim Meyering
67998a215f (main): Remove decl of unused local, `len'. 2001-01-28 21:58:19 +00:00
Jim Meyering
94767ce8cf add a comment, reformat a little. 2001-01-28 21:45:36 +00:00
Jim Meyering
577a8f346e (gobble_file): Add a FIXME comment. 2001-01-28 21:43:21 +00:00
Jim Meyering
daf6c50b95 *** empty log message *** 2001-01-28 21:43:15 +00:00
Jim Meyering
b221cf780f *** empty log message *** 2001-01-28 21:35:10 +00:00
Jim Meyering
2bc68d2234 [FULL_TIME]: Define.
(long_options): Use it.
(decode_switches): Make --full-time imply -l.
2001-01-28 21:34:35 +00:00
Jim Meyering
d6f931281e . 2001-01-28 08:10:00 +00:00
Jim Meyering
ae9d89cfe2 (jm_FILE_SYSTEM_USAGE): Open-code what was a use of AS_IF. 2001-01-27 14:06:18 +00:00
Jim Meyering
263fb2dc15 (jm_LIST_MOUNTED_FILESYSTEMS): Open-code what was a use of AS_IF. 2001-01-27 14:06:04 +00:00
Jim Meyering
e5e92e670c *** empty log message *** 2001-01-27 13:24:36 +00:00
Jim Meyering
d85aac6782 (jm_FILE_SYSTEM_USAGE): Add `[]' between use of
AS_IF and following `dnl'.
2001-01-27 13:24:32 +00:00
Jim Meyering
d54655c623 (jm_LIST_MOUNTED_FILESYSTEMS): Add `[]' between use of
AS_IF and following `dnl'.
2001-01-27 13:24:13 +00:00
Jim Meyering
18656b733d *** empty log message *** 2001-01-26 11:17:34 +00:00
Jim Meyering
ac4936b7b1 bump serial # 2001-01-26 11:17:29 +00:00
Jim Meyering
742625303d (jm_PREREQ_QUOTEARG): Check for stddef.h, now that quotearg.c includes it. 2001-01-26 11:17:19 +00:00
Jim Meyering
9e2606d77b *** empty log message *** 2001-01-26 11:15:53 +00:00
Jim Meyering
c8d0d0ca6f Include stddef.h. 2001-01-26 11:15:37 +00:00
Jim Meyering
0e3fea79f3 *** empty log message *** 2001-01-26 11:13:34 +00:00
Jim Meyering
dcfda51801 [HAVE_DONE_WORKING_MALLOC_CHECK]: Enclose error-evoking
line in double quotes so that it evokes a better diagnostic.
[HAVE_DONE_WORKING_REALLOC_CHECK]: Likewise.
2001-01-26 11:13:28 +00:00
Jim Meyering
fad08d3f31 *** empty log message *** 2001-01-26 11:13:08 +00:00
Jim Meyering
d362235eed (main): Declare local result as non-const, now that it's freed. 2001-01-26 09:24:46 +00:00
Jim Meyering
6ff755a69a . 2001-01-26 09:22:43 +00:00
Jim Meyering
c4bb1d449e *** empty log message *** 2001-01-22 10:54:32 +00:00
Jim Meyering
e673a685ac (remove_file): Correct an expression to avoid making
an unnecessary call to euidaccess for each file.
2001-01-22 10:51:54 +00:00
Jim Meyering
37e38b4941 *** empty log message *** 2001-01-21 22:54:53 +00:00
Jim Meyering
9eabf6d99a *** empty log message *** 2001-01-21 12:27:39 +00:00
Jim Meyering
8efb6d5f7b *** empty log message *** 2001-01-21 12:26:34 +00:00
Jim Meyering
928b1b8300 *** empty log message *** 2001-01-21 10:15:59 +00:00
Jim Meyering
211a6642e2 (jm_ICONV): Also check whether the iconv declaration has const. 2001-01-21 10:15:53 +00:00
Jim Meyering
fd1d1eaa80 *** empty log message *** 2001-01-21 09:40:48 +00:00
Jim Meyering
ad41cbff8a (print_unicode_char): Cast the second iconv() arg,
to avoid a warning.  Add back 'const' to inptr.
2001-01-21 09:40:43 +00:00
Jim Meyering
71611d94f3 . 2001-01-20 19:41:15 +00:00
Jim Meyering
9beeae646e *** empty log message *** 2001-01-20 19:41:01 +00:00
Jim Meyering
67450be04d *** empty log message *** 2001-01-20 19:24:36 +00:00
Jim Meyering
84264973d6 *** empty log message *** 2001-01-20 19:20:53 +00:00
Jim Meyering
5239228c17 *** empty log message *** 2001-01-20 19:18:43 +00:00
Jim Meyering
29940657ab *** empty log message *** 2001-01-20 18:34:44 +00:00
Jim Meyering
a5ab9f78c3 Be sure that headers are checked before used in code compiled
for the type checks.

(jm_MACROS): Remove all header checks.
In place of that, invoke jm_CHECK_ALL_TYPES.
(jm_CHECK_ALL_HEADERS): New functions with the above checks.
(jm_CHECK_ALL_TYPES): Require jm_CHECK_ALL_HEADERS.
2001-01-20 18:34:32 +00:00
Jim Meyering
01bbd27a4d revert last change 2001-01-20 11:17:33 +00:00
Jim Meyering
df06c5de7b *** empty log message *** 2001-01-20 09:49:24 +00:00
Jim Meyering
706235da55 (jm_PREREQ): Add jm_PREREQ_HASH.
(jm_PREREQ_HASH): New function.
2001-01-20 09:49:10 +00:00
Jim Meyering
403b4c49eb whoops. revert last change 2001-01-20 09:36:19 +00:00
Jim Meyering
c6014bc847 *** empty log message *** 2001-01-20 09:34:34 +00:00
Jim Meyering
c148112941 Fix typo: s/false/0/. 2001-01-20 09:34:20 +00:00
Jim Meyering
19b3a9d102 *** empty log message *** 2001-01-17 10:34:22 +00:00
Jim Meyering
7f9c804f7a (jm_FILE_SYSTEM_USAGE): Use AS_IF, not AS_IFELSE, for autoconf-2.49c. 2001-01-17 10:34:16 +00:00
Jim Meyering
4bdc202a00 (jm_LIST_MOUNTED_FILESYSTEMS): Likewise. 2001-01-17 10:33:43 +00:00
Jim Meyering
a80ec26277 . 2001-01-17 10:30:32 +00:00
Jim Meyering
fcdbd9ff15 (main): Likewise. 2001-01-17 10:30:25 +00:00
Jim Meyering
108694f32a (PACKAGE): Likewise. 2001-01-17 10:29:56 +00:00
Jim Meyering
59b34eded2 (main): Likewise. 2001-01-17 10:28:46 +00:00
Jim Meyering
622dcc58ee (case_GETOPT_VERSION_CHAR): Use PACKAGE, not GNU_PACKAGE. 2001-01-17 10:28:03 +00:00
Jim Meyering
770b6c1bb5 *** empty log message *** 2001-01-17 09:48:02 +00:00
Jim Meyering
56c1cbf2e8 (main): Use PACKAGE, not GNU_PACKAGE. 2001-01-17 09:47:41 +00:00
Jim Meyering
bd485671ff (usage): Convert each TAB in --help output to a sequence of 8 spaces. 2001-01-17 09:47:32 +00:00
Jim Meyering
43be299a76 (main): Use PACKAGE, not GNU_PACKAGE. 2001-01-17 09:42:36 +00:00
Jim Meyering
1493e0d650 *** empty log message *** 2001-01-16 08:34:53 +00:00
Jim Meyering
592e22d509 Include <stdio.h>, needed by assert on SunOS4. 2001-01-16 08:34:45 +00:00
Jim Meyering
c8e070ed62 *** empty log message *** 2001-01-15 11:32:45 +00:00
Jim Meyering
ceb3908c6f . 2001-01-14 20:28:14 +00:00
Jim Meyering
4468f22968 *** empty log message *** 2001-01-14 20:28:03 +00:00
Jim Meyering
eb3dc6a095 Remove conftestdir{,2} before trying to create the directory.
Make the entire configure script fail if the mkdir fails.
2001-01-14 20:27:56 +00:00
Jim Meyering
4a65486da9 (UINT_MAX_32_BITS): Define.
Use UINT_MAX_32_BITS in the cpp conditions that determine
the `word32' typedef.  Using a literal `0xffffffff' failed with
HPUX10.20's /bin/cc.
2001-01-14 20:26:28 +00:00
Jim Meyering
07872e486f *** empty log message *** 2001-01-14 16:42:50 +00:00
Jim Meyering
5aba961278 use id's -ng options, not -nG 2001-01-14 16:27:08 +00:00
Jim Meyering
9be1481d17 *** empty log message *** 2001-01-14 15:37:48 +00:00
Jim Meyering
eda1fa3268 *** empty log message *** 2001-01-14 15:37:22 +00:00
Jim Meyering
633a2ace39 *** empty log message *** 2001-01-14 15:36:53 +00:00
Jim Meyering
c2329c797c . 2001-01-14 15:35:19 +00:00
Jim Meyering
4d8de6887f *** empty log message *** 2001-01-14 15:35:07 +00:00
Jim Meyering
5b2304d7b4 Include stdlib.h, string.h or strings.h, and xalloc.h.
Use strip_trailing_slashes rather than open-coding it.
2001-01-14 15:34:22 +00:00
Jim Meyering
b6863fa3c9 *** empty log message *** 2001-01-14 15:28:54 +00:00
Jim Meyering
c0ba4297c5 Use temporary directories named conftestdir{,2}, not
foo and bar.  Create conftestdir/ in the script, not in the C code.
Remove directories in the script, not in the C code.
2001-01-14 15:28:45 +00:00
Jim Meyering
acc13fdc89 from Volker Borchert 2001-01-14 11:08:35 +00:00
Jim Meyering
ee56fd2719 (jm_MACROS): Require vb_FUNC_RENAME. 2001-01-14 11:07:45 +00:00
Jim Meyering
16863fa14e check for SunOS4.1.1U bug in rename 2001-01-14 11:07:28 +00:00
Jim Meyering
c957bbdeae (TESTS): Add trailing-slash. 2001-01-14 11:06:20 +00:00
Jim Meyering
c6a4fe00db from Volker Borchert 2001-01-14 11:05:50 +00:00
Jim Meyering
30fc8c55a3 [RENAME_TRAILING_SLASH_BUG]: Use the rename wrapper. 2001-01-14 11:04:47 +00:00
Jim Meyering
98c8115e96 *** empty log message *** 2001-01-14 09:42:01 +00:00
Jim Meyering
d6b863b09c (update-po): Merge po-files in temporary files
in the build directory, and update the source directory only when
the merged catalog differs from the original.  This fixes the known
`make distcheck' failure due to `make update-po' being called
on up-to-date but read-only files.
2001-01-14 09:41:53 +00:00
Jim Meyering
c730e2d9e8 *** empty log message *** 2001-01-13 15:59:19 +00:00
Jim Meyering
81268e4b67 . 2001-01-13 15:57:48 +00:00
Jim Meyering
896a20a2a9 *** empty log message *** 2001-01-13 15:56:33 +00:00
Jim Meyering
455ce0178b (TESTS): Add into-self-4. 2001-01-13 15:56:29 +00:00
Jim Meyering
e268536dba *** empty log message *** 2001-01-13 15:55:35 +00:00
Jim Meyering
e2aae9e166 add comment to go along with last change 2001-01-13 15:50:01 +00:00
Jim Meyering
8e4dbf5ab0 *** empty log message *** 2001-01-13 15:49:01 +00:00
Jim Meyering
b7138e1052 (same_file_ok): When moving a symlink onto itself,
don't remove the symlink.  Reported by David Luyer as Debian bug#82089,
via Michael Stone.
2001-01-13 15:48:32 +00:00
Jim Meyering
5775f7e864 *** empty log message *** 2001-01-12 23:27:53 +00:00
Jim Meyering
6deb757ba4 * tests/chmod/setgid: If `chmod g+s d' fails, then try to chgrp
to a group of which we're a member, then try the chmod again.
2001-01-12 23:27:43 +00:00
Jim Meyering
a0d25e62aa *** empty log message *** 2001-01-11 16:58:40 +00:00
Jim Meyering
dc38e3a287 *** empty log message *** 2001-01-11 16:04:46 +00:00
Jim Meyering
7b99d77bc6 *** empty log message *** 2001-01-10 23:30:56 +00:00
Jim Meyering
1a79f34996 . 2001-01-10 23:08:51 +00:00
Jim Meyering
ad3ec0add1 *** empty log message *** 2001-01-10 13:44:13 +00:00
Jim Meyering
a3ffafd3fe . 2001-01-10 12:20:03 +00:00
Jim Meyering
2d33b67399 (TESTS): Add into-self. 2001-01-10 12:19:05 +00:00
Jim Meyering
e7e6c322a0 (copy_internal): Add a comment.
Set *copy_into_self in the new code that detects that.
Make diagnostic more consistent: s/won't/will not/.
[move_mode, copy_into_self]: Give a diagnstic here, now that
we have the top_level_* globals.  Remove the corresponding diagnostic
from mv.c.
Add a FIXME comment.
2001-01-10 12:18:19 +00:00
Jim Meyering
9ea9eed873 (do_move): Remove diagnostic, now that copy.c issues it.
Set `fail' to nonzero in the primary `if (copy_into_self)' block
rather than in its own tiny one below.
2001-01-10 12:16:52 +00:00
Jim Meyering
d882d1d100 *** empty log message *** 2001-01-10 11:56:59 +00:00
Jim Meyering
b6e29912be [struct entry] (node): Describe how it's used,
now that we've overloaded it a little, in order to detect and diagnose
the copying-directory-into-self problem.
(new_file): Remove global.
(htab): Declare global to be static.
(remember_created): Insert file name instead of dummy pointer, so
that copy.c can use the just-created directory name to detect
the copying-directory-into-self problem.
2001-01-10 11:54:53 +00:00
Jim Meyering
687ef9f9fe *** empty log message *** 2001-01-10 10:29:57 +00:00
Jim Meyering
4e1f4a8496 *** empty log message *** 2001-01-10 10:27:09 +00:00
Jim Meyering
c1485dd854 *** empty log message *** 2001-01-10 09:58:43 +00:00
Jim Meyering
35099b35ba *** empty log message *** 2001-01-10 09:56:04 +00:00
Jim Meyering
2a5fb11132 (copy_internal): Don't allow cp (or mv, when working
across a partition boundary) to overwrite a non-directory with a directory.
2001-01-10 09:43:36 +00:00
Jim Meyering
a49513bedd *** empty log message *** 2001-01-10 09:42:16 +00:00
Jim Meyering
fc6a8dcfb2 *** empty log message *** 2001-01-10 09:41:46 +00:00
Jim Meyering
cbb4300cc2 (TESTS): Add dir-vs-file. 2001-01-10 09:41:41 +00:00
Jim Meyering
deb79403bd *** empty log message *** 2001-01-10 09:41:15 +00:00
Jim Meyering
9f43a52210 *** empty log message *** 2001-01-10 09:40:47 +00:00
Jim Meyering
6bf0f043cd *** empty log message *** 2001-01-10 09:40:05 +00:00
Jim Meyering
3f1cd6f52a *** empty log message *** 2001-01-10 09:39:57 +00:00
Jim Meyering
d1da062806 *** empty log message *** 2001-01-09 23:13:08 +00:00
Jim Meyering
bce88bc1ae *** empty log message *** 2001-01-09 16:13:29 +00:00
Jim Meyering
8740ecf8c0 add comment 2001-01-09 16:12:59 +00:00
Jim Meyering
e92e87181b (top_level_src_path, top_level_dst_path): New globals.
(copy_internal): Use them.
(copy): Set them.
2001-01-09 16:07:40 +00:00
Jim Meyering
902dacb46a *** empty log message *** 2001-01-09 15:50:13 +00:00
Jim Meyering
134bbf752c whoops. move printf args, too 2001-01-08 08:34:52 +00:00
Jim Meyering
b27dd775ad (usage): Split long message string. 2001-01-07 16:15:37 +00:00
Jim Meyering
e230d9a62b *** empty log message *** 2001-01-07 16:13:34 +00:00
Jim Meyering
7709a02741 Split a string that was longer than 2048 bytes. 2001-01-07 16:13:27 +00:00
Jim Meyering
aaf9e9a820 (usage): Split a string that was longer than 2048 bytes. 2001-01-07 16:11:14 +00:00
Jim Meyering
674fed73ec (usage): Split a string that was longer than 2048 bytes. 2001-01-07 16:10:50 +00:00
Jim Meyering
98d1d862d5 back out last, prematurely-committed, change 2001-01-07 16:07:33 +00:00
Jim Meyering
aaef348f3d Correct the indentation of an `#endif'. 2001-01-07 16:06:27 +00:00
Jim Meyering
9bc96fd932 clean up after commit hook testing 2001-01-07 10:57:29 +00:00
Jim Meyering
7b0658b00f testing -- commit should fail 2001-01-07 10:54:06 +00:00
Jim Meyering
f4034df457 testing -- commit should fail 2001-01-07 10:52:43 +00:00
Jim Meyering
5856751f41 testing -- commit should fail 2001-01-07 10:51:00 +00:00
Jim Meyering
4df9c47ca7 (usage): Untabify. 2001-01-07 10:12:25 +00:00
Jim Meyering
354a71cdc2 *** empty log message *** 2001-01-07 10:12:16 +00:00
Jim Meyering
481c79dfac *** empty log message *** 2001-01-07 09:23:28 +00:00
Jim Meyering
5e32f7c19a s/can not/cannot/ 2001-01-07 09:23:18 +00:00
Jim Meyering
c5b4a727ab *** empty log message *** 2001-01-07 09:21:41 +00:00
Jim Meyering
8c07ff563b (parse_group): Normalize spelling. 2001-01-07 09:21:34 +00:00
Jim Meyering
fa997616ff normalize spelling in comment 2001-01-07 09:20:47 +00:00
Jim Meyering
0edd80c0f2 *** empty log message *** 2001-01-04 17:59:32 +00:00
Jim Meyering
cc49da4ddf (main): Fail when --rfc-822 (-R) is specified along
with a format string.  Reported by Jochen Hein.
2001-01-04 17:59:22 +00:00
Jim Meyering
b7b4bec8df . 2001-01-04 14:00:07 +00:00
Jim Meyering
7aed2f97a5 . 2001-01-04 10:19:49 +00:00
Jim Meyering
89c7458b53 Sync with glibc time/strftime.c 1.81. 2001-01-04 10:19:43 +00:00
Jim Meyering
0809f17d77 . 2001-01-03 21:04:52 +00:00
Jim Meyering
550edf90b2 Use the more precise algorithm of GNU "make" to decide whether
a file is in the future, by looking at high-resolution time
stamps if available.

(TIMESPEC_NS): New macro.
(current_time): Initialize to the minimum value.
(current_time_ns): New var.
(main): Do not bother to initialize current_time;
it's no longer needed.
(get_current_time): New function.
(print_long_format): Use it when a file appears to be in the future.
Get the nanoseconds of the file's time stamp, if available,
and use that to decide whether the file appears	to be in the future.
2001-01-03 21:02:08 +00:00
Jim Meyering
f3aa989205 check for existing behavior 2001-01-03 16:16:56 +00:00
Jim Meyering
f8a894c567 *** empty log message *** 2001-01-03 11:37:46 +00:00
Jim Meyering
a0439c2405 (main): Remove embedded \n from diagnostic. 2001-01-03 11:36:10 +00:00
Jim Meyering
edfabc70d3 *** empty log message *** 2001-01-03 10:16:14 +00:00
Jim Meyering
9e14c22918 (AM_GNU_GETTEXT): Define MKINSTALLDIRS by
expanding the value of $ac_aux_dir, as in AM_MISSING_HAS_RUN,
so `make install' also works in VPATH builds.
2001-01-03 10:16:02 +00:00
Jim Meyering
f3334434ea *** empty log message *** 2001-01-03 10:09:08 +00:00
Jim Meyering
5686f159ab (print_unicode_char): Remove `const' from declaration of
local `inptr' to avoid warning with some system declarations of iconv.
2001-01-03 10:08:43 +00:00
Jim Meyering
b7f12e5291 *** empty log message *** 2001-01-03 10:06:53 +00:00
Jim Meyering
954daed8c2 . 2001-01-03 09:47:20 +00:00
Jim Meyering
b042ca3c0f (long_time_expected_width, print_long_format): Fix
bug: the initial byte passed to strftime wasn't initialized to
a nonzero value after the buffer was reallocated.
2001-01-03 09:47:09 +00:00
Jim Meyering
5d3b5e175a *** empty log message *** 2001-01-03 09:45:43 +00:00
Jim Meyering
1f13191b6f (install-data-yes): If the package is
fileutils, install LC_TIME as an alias for LC_MESSAGES.
2001-01-03 09:45:32 +00:00
Jim Meyering
5aa665a624 (dcgettext): New macro. 2001-01-03 09:44:56 +00:00
Jim Meyering
85a5e683e8 (decode_switches): Use dcgettext with LC_TIME,
not plain gettext, to get the translations of time formats.
2001-01-03 09:44:15 +00:00
Jim Meyering
e646037f4a . 2001-01-03 09:38:55 +00:00
Jim Meyering
536a6dd3ce (long_time_expected_width): New function.
(print_long_format): Use it, so that we don't assume a
particular width for time stamps in an internationalized
environment.
2001-01-03 09:15:22 +00:00
Jim Meyering
701cc3fe2c *** empty log message *** 2001-01-02 15:50:18 +00:00
Jim Meyering
22fc5f7ac9 (ulonglong_t): Define place-holder type to avoid some #if directives.
(LONGEST_INTEGRAL_TYPE): Remove definition.
(MAX_INTEGRAL_TYPE_SIZE): Use ulonglong_t instead of LONGEST_INTEGRAL_TYPE.
(print_long_long): Compile this function even on systems without
long long support.
(decode_one_format): Remove #if directive.
2001-01-02 15:48:21 +00:00
Jim Meyering
4dcf0e2c7b . 2001-01-02 15:31:41 +00:00
Jim Meyering
67aea68e97 *** empty log message *** 2001-01-02 10:55:34 +00:00
Jim Meyering
2320b98d89 (decode_one_format): Guard use of print_long_long with
`#if HAVE_UNSIGNED_LONG_LONG'.  From Darren Salt.
Change all `#ifdef HAVE_UNSIGNED_LONG_LONG' to use `#if' instead.
2001-01-02 10:54:55 +00:00
Jim Meyering
4f90505509 *** empty log message *** 2001-01-02 10:44:38 +00:00
Jim Meyering
4fcf9133ef *** empty log message *** 2001-01-02 07:21:36 +00:00
Jim Meyering
1f29ee0e02 *** empty log message *** 2001-01-02 07:20:13 +00:00
Jim Meyering
5285933ed8 copyright 2001-01-02 07:19:59 +00:00
Jim Meyering
1efbe325bd (print_long_format):
Report the year for files even slightly in the future.
Avoid overflow problems near Y2038 on 32-bit hosts.
To calculate "six months", take half the average Gregorian
year, not 180 days.
2001-01-02 07:18:56 +00:00
Jim Meyering
1f678f44f9 *** empty log message *** 2001-01-02 07:14:47 +00:00
Jim Meyering
895cf6e91f . 2001-01-01 18:17:10 +00:00
Jim Meyering
682bc57d89 (jm_PREREQ_READUTMP): Include utmp.h (if available), even
on systems with utmpx.h.  It's necessary for the declaration of utmp's
ut_user member.  Reported by Andreas Jaeger.
2001-01-01 18:16:52 +00:00
Jim Meyering
74ac72a78f . 2001-01-01 18:09:31 +00:00
Jim Meyering
f324aa68f9 (jm_CHECK_DECLS): Include grp.h and pwd.h if available.
They are required for the declarations of getgrgid and getpwuid resp.
(_jm_DECL_HEADERS): Check for grp.h and pwd.h.
2001-01-01 18:08:48 +00:00
Jim Meyering
88db6b6944 . 2001-01-01 10:59:50 +00:00
Jim Meyering
387d125c2d *** empty log message *** 2001-01-01 10:52:32 +00:00
Jim Meyering
fd77d94155 *** empty log message *** 2001-01-01 10:51:32 +00:00
Jim Meyering
137c6d5137 (TESTS): Add setgid. 2001-01-01 10:51:22 +00:00
Jim Meyering
671567d496 *** empty log message *** 2001-01-01 10:49:52 +00:00
Jim Meyering
aa3ef39ac8 *** empty log message *** 2000-12-31 13:24:28 +00:00
Jim Meyering
b360fa26e5 (AM_WITH_NLS): When using AC_CONFIG_AUX_DIR,
prepend $(top_srcdir) to the value of MKINSTALLDIRS so that it
can be used in subdirectories.
2000-12-31 12:15:42 +00:00
Jim Meyering
168401bef2 *** empty log message *** 2000-12-31 12:12:41 +00:00
Jim Meyering
9ecf7a54be . 2000-12-31 09:51:50 +00:00
Jim Meyering
b46b6af7e3 . 2000-12-31 09:49:33 +00:00
Jim Meyering
318e97ef64 File renamed from tests/sticky-check.
All uses of "sticky" changed to "setgid".
2000-12-31 09:49:23 +00:00
Jim Meyering
9b525d2fe1 sticky-check -> setgid-check 2000-12-31 09:48:35 +00:00
Jim Meyering
7a5e723600 sticky-check -> setgid-check 2000-12-31 09:48:10 +00:00
Jim Meyering
9a2e78d703 sticky-check -> setgid-check 2000-12-31 09:46:15 +00:00
Jim Meyering
b28d611552 *** empty log message *** 2000-12-31 09:21:28 +00:00
Jim Meyering
f39ef82a14 . 2000-12-31 09:19:25 +00:00
Jim Meyering
c76348c318 (TESTS): Add deref-slink. 2000-12-31 09:17:00 +00:00
Jim Meyering
dd9804a4fe New file. Test for the bug fixed by my 2000-12-28 change to copy.c. 2000-12-31 09:15:44 +00:00
Jim Meyering
f0018a3b9c Improve performance by invoking gettext twice at the start,
instead of once for each file.
(long_time_format): New var.
(decode_switches): Initialize it, if format == long_format.
(print_long_format): Use it.
2000-12-31 09:06:54 +00:00
Jim Meyering
9adb2c7cf1 *** empty log message *** 2000-12-31 08:55:58 +00:00
Jim Meyering
857c948551 (print_long_format): Don't dump core if strftime returns the empty string. 2000-12-31 08:55:41 +00:00
Jim Meyering
33cf956fc8 *** empty log message *** 2000-12-31 08:33:59 +00:00
Jim Meyering
66816a3514 (gobble_file): If not using long format, don't invoke acl; it's not needed. 2000-12-31 08:33:49 +00:00
Jim Meyering
6417617d33 *** empty log message *** 2000-12-31 08:30:28 +00:00
Jim Meyering
769b95b751 Avoid an unnecessary `stat' when using --dereference.
(same_file_ok): Use stat only if lstat reported that
the file was a symbolic link.
2000-12-31 08:29:17 +00:00
Jim Meyering
de0ebc7eb6 *** empty log message *** 2000-12-30 16:51:42 +00:00
Jim Meyering
d8271b06b4 append-only directories -> restricted deletion flag,
which is the term that POSIX d5 uses for this notion.
2000-12-30 16:51:24 +00:00
Jim Meyering
206205c6ee *** empty log message *** 2000-12-29 10:32:33 +00:00
Jim Meyering
3336d7cf69 Do not assume that mode_t uses the
traditional octal encoding.  E.g. "chmod 1 FOO" should set
the other-execute bit of FOO even if S_IXOTH != 1.

(SUID, SGID, SVTX, RUSR, WUSR, XUSR, RGRP, WGRP, XGRP, ROTH,
WOTH, XOTH, ALLM): New macros.
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IWUSR, S_IXUSR,
 S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH):
Use them.
(S_ISGID): Fix typo; it was defaulting to the same value as S_ISUID.
(S_IRWXU, S_IRWXG, S_IRWXO): Specify defaults in terms of the above.
(mode_compile):
No need to use uintmax_t; unsigned long is long enough.
Don't bother to get suffix since we don't use it.
2000-12-29 10:32:09 +00:00
Jim Meyering
c319b5bf3b *** empty log message *** 2000-12-29 08:58:38 +00:00
Jim Meyering
de577f3440 Try /usr/xpg4/bin/id (Solaris 7) if plain 'id' doesn't work. 2000-12-29 08:58:25 +00:00
Jim Meyering
9f0489df43 . 2000-12-28 14:43:13 +00:00
Jim Meyering
46e7805428 Run sticky-check from just-created directory. 2000-12-28 14:40:15 +00:00
Jim Meyering
d4b4519d8d *** empty log message *** 2000-12-28 13:35:28 +00:00
Jim Meyering
b8d4bfe024 . 2000-12-28 13:17:02 +00:00
Jim Meyering
7046dfbc47 tweak comment 2000-12-28 11:52:28 +00:00
Jim Meyering
f119221740 tweak comment 2000-12-28 11:31:44 +00:00
Jim Meyering
fe38ed9d90 *** empty log message *** 2000-12-28 11:23:55 +00:00
Jim Meyering
bc9ff8c14d (same_file_ok): Fix *another* typo from my 2000-09-03 change: s/tmp_dst_sb/tmp_src_sb/. 2000-12-28 11:22:59 +00:00
Jim Meyering
a400a0e081 *** empty log message *** 2000-12-28 09:53:58 +00:00
Jim Meyering
3abbefb5e4 (same_file_ok): Fix typo from my 2000-09-03 change: s/tmp_dst_sb/tmp_src_sb/. 2000-12-28 09:53:34 +00:00
Jim Meyering
51d5f8a438 (same_file_ok): Use a single auto var for
tmp_dst_sb, instead of two static vars.
Likewise for tmp_src_sb.
2000-12-28 09:42:06 +00:00
Jim Meyering
e8c1aced2b *** empty log message *** 2000-12-28 09:41:39 +00:00
Jim Meyering
9926b4ec03 . 2000-12-27 10:05:05 +00:00
Jim Meyering
20b09b0761 . 2000-12-27 07:47:08 +00:00
Jim Meyering
9d72d71f21 . 2000-12-27 07:46:47 +00:00
Jim Meyering
937873451a use AC_DEFINE_UNQUOTED 2000-12-27 07:46:35 +00:00
Jim Meyering
b7eb48d4fc (jm_AC_DOS): Rewrite (though it's still a stub) to work better with autoheader. 2000-12-26 18:57:53 +00:00
Jim Meyering
2f67a24489 *** empty log message *** 2000-12-26 11:34:34 +00:00
Jim Meyering
0fa2ce5716 *** empty log message *** 2000-12-26 09:39:17 +00:00
Jim Meyering
1aef6a3960 tweak comment, white space 2000-12-26 09:36:36 +00:00
Jim Meyering
e41d7c5bee *** empty log message *** 2000-12-26 08:51:59 +00:00
Jim Meyering
37aa98f669 Disable the test if the working directory has the sticky bit set. 2000-12-26 08:51:51 +00:00
Jim Meyering
5c265cddbf *** empty log message *** 2000-12-26 08:43:15 +00:00
Jim Meyering
da21549918 Disable the test if the working directory has the sticky bit set. 2000-12-26 08:43:03 +00:00
Jim Meyering
f46fed1458 add omitted semicolon 2000-12-25 18:51:58 +00:00
Jim Meyering
fa9603b6d4 *** empty log message *** 2000-12-25 18:38:19 +00:00
Jim Meyering
0f4de82749 (same_file_ok): Remove declaration and set of unused
variables: src_sb_no_link, dst_sb_no_link.
2000-12-25 18:35:16 +00:00
Jim Meyering
46fa2b76aa *** empty log message *** 2000-12-25 18:31:25 +00:00
Jim Meyering
1a8989fd9d Add a test for this (for all of cp, mv, ln, install). 2000-12-25 18:31:18 +00:00
Jim Meyering
f4795cc6b3 For both ln and install, when using `--backup=simple --suffix=S',
the suffix `S' wasn't used.

(main): Actually use the local variable, `backup_suffix_string'.
2000-12-25 11:07:20 +00:00
Jim Meyering
5688e294f7 *** empty log message *** 2000-12-25 10:45:20 +00:00
Jim Meyering
3c1f0042f5 (hash_compare_active_dir_ents): Return explicit `true'
or `false', rather than relying on implicit int-to-enum cast.
2000-12-25 10:45:10 +00:00
Jim Meyering
ca08f0ea65 *** empty log message *** 2000-12-25 10:41:52 +00:00
Jim Meyering
61b343a3c8 *** empty log message *** 2000-12-25 10:40:42 +00:00
Jim Meyering
ec76cb5726 (extract_dirs_from_files): Remove unused variable.
(gobble_file): Move decl of local, val, into the scope where it's used.
2000-12-25 10:39:04 +00:00
Jim Meyering
d6c55effc3 *** empty log message *** 2000-12-24 18:02:18 +00:00
Jim Meyering
788bdca00c *** empty log message *** 2000-12-24 17:58:16 +00:00
Jim Meyering
c8b1db11d3 (main): Actually use the local variable, `backup_suffix_string'. 2000-12-24 17:56:51 +00:00
Jim Meyering
24ffc1a3c9 whoops 2000-12-24 17:53:05 +00:00
Jim Meyering
2cea3f1b14 detect ln simple backup bug 2000-12-24 13:49:29 +00:00
Jim Meyering
73a15b2b5f *** empty log message *** 2000-12-24 10:06:00 +00:00
Jim Meyering
3734f30bca *** empty log message *** 2000-12-24 09:39:04 +00:00
Jim Meyering
7862d9f6fc Update to version 1.24. 2000-12-24 09:34:17 +00:00
Jim Meyering
7aa3fb3d47 (is_prime): Return explicit boolean values.
(hash_get_first): Return NULL to appease Irix5.6's 89.
2000-12-24 07:12:21 +00:00
Jim Meyering
6ac10d9b9a . 2000-12-23 10:44:25 +00:00
Jim Meyering
8c8f0df4f0 [HAVE_INTTYPES_H]: Include <inttypes.h>. 2000-12-23 10:43:33 +00:00
Jim Meyering
69e09f0559 *** empty log message *** 2000-12-22 22:45:32 +00:00
Jim Meyering
1a18604b2e (isaac_seed_machdep) [_ARCH_PPC]: Disable the code
that would use the PPC mfspr `asm' code.
2000-12-22 22:44:30 +00:00
Jim Meyering
eae1c2b69c . 2000-12-19 11:06:05 +00:00
Jim Meyering
4c038111f8 *** empty log message *** 2000-12-19 10:51:39 +00:00
Jim Meyering
a82d4c2b3d . 2000-12-19 10:50:31 +00:00
Jim Meyering
0cba2d7f5b *** empty log message *** 2000-12-19 10:37:30 +00:00
Jim Meyering
a87ae161be . 2000-12-19 10:25:15 +00:00
Jim Meyering
275b1879c3 . 2000-12-19 10:25:15 +00:00
Jim Meyering
66cf2ad8ce *** empty log message *** 2000-12-19 09:23:47 +00:00
Jim Meyering
0966c0f860 . 2000-12-19 09:23:09 +00:00
Jim Meyering
83a6c55c74 (UINTMAX_MAX): New macro, taken from C99. 2000-12-19 09:22:24 +00:00
Jim Meyering
3c46adfe19 adjust indentation 2000-12-19 09:21:42 +00:00
Jim Meyering
0787040b75 *** empty log message *** 2000-12-19 09:16:39 +00:00
Jim Meyering
bf86c62a33 Include physmem.h.
(SORTALLOC, mergealloc, LINEALLOC): Remove.
(sortalloc): Default to zero at program startup.
(SORTALLOC_MIN, SORTALLOC_DEFAULT_MIN): New macros.
(usage, main): Add support for new -S SIZE option.
(specify_sort_size, default_sort_size): New functions.
(initlines): Do not let alloc exceed limit.
(findlines): Likewise.
(checkfp, mergefps, sort): Use sortalloc to size everything
else, instead of relying on precomputed sizes.
2000-12-19 09:16:28 +00:00
Jim Meyering
915dacbb85 New "sort" option -S SIZE. 2000-12-19 08:40:54 +00:00
Jim Meyering
b6b86da148 *** empty log message *** 2000-12-19 08:36:53 +00:00
Jim Meyering
de38d76a18 (libfetish_a_SOURCES): Add physmem.c.
(noinst_HEADERS): Add physmem.h.
2000-12-19 08:36:39 +00:00
Jim Meyering
166c00189a (__xstrtol): Add undocumented suffixes 'g' and
't' for compatibility with Solaris 8 sort.
2000-12-19 08:35:20 +00:00
Jim Meyering
bca787f7c4 *** empty log message *** 2000-12-19 08:22:18 +00:00
Jim Meyering
258f00968a *** empty log message *** 2000-12-19 08:16:25 +00:00
Jim Meyering
bc40f9fcef (locale_charset): Add support for Win32. 2000-12-19 08:16:09 +00:00
Jim Meyering
d81418fd5e . 2000-12-18 23:43:27 +00:00
Jim Meyering
85ab4b9988 *** empty log message *** 2000-12-18 23:04:34 +00:00
Jim Meyering
f75f8a4b1d Add support for BeOS. 2000-12-18 23:04:28 +00:00
Jim Meyering
dfada44550 these macros take arguments 2000-12-17 09:26:55 +00:00
Jim Meyering
5d4c822ef7 *** empty log message *** 2000-12-17 09:23:05 +00:00
Jim Meyering
55f51356fb (jm_AC_DOS): New file and macro. 2000-12-17 09:22:56 +00:00
Jim Meyering
3f6afc4a7a (jm_MACROS): Require jm_AC_DOS. 2000-12-17 09:22:17 +00:00
Jim Meyering
dc87bf344c *** empty log message *** 2000-12-17 00:19:05 +00:00
Jim Meyering
7a41a27413 *** empty log message *** 2000-12-17 00:18:50 +00:00
Jim Meyering
8dc25234e0 *** empty log message *** 2000-12-17 00:17:26 +00:00
Jim Meyering
24ad4ecf29 *** empty log message *** 2000-12-17 00:17:03 +00:00
Jim Meyering
c9f0363bea . 2000-12-17 00:15:02 +00:00
Jim Meyering
c44bd5683d Update from master repository. 2000-12-17 00:14:40 +00:00
Jim Meyering
ae8bf0e8f1 . 2000-12-16 23:35:38 +00:00
Jim Meyering
fbba4d8d5e *** empty log message *** 2000-12-16 22:27:18 +00:00
Jim Meyering
2b64713ac6 *** empty log message *** 2000-12-16 22:26:23 +00:00
Jim Meyering
2464a2cd9d [!SHELLS_FILE && __DJGPP__]: Define
SHELLS_FILE to a file name that's useful on djgpp systems.
Include stdlib.h.
(ADDITIONAL_DEFAULT_SHELLS): Define.
(default_shells): Prepend ADDITIONAL_DEFAULT_SHELLS.
Based mostly on a patch from Prashant TR.
2000-12-16 22:25:44 +00:00
Jim Meyering
96e6715ebe . 2000-12-16 18:53:08 +00:00
Jim Meyering
72d973cb61 (uint_to_string): New function.
(uid_to_name): Use it.
(gid_to_name): Use it.
Rename locals, user/group, to uid/gid.
2000-12-16 18:52:58 +00:00
Jim Meyering
39d300f12b (enum Change_status): Start with 1. 2000-12-16 18:47:43 +00:00
Jim Meyering
76f8538bf6 . 2000-12-16 14:49:25 +00:00
Jim Meyering
71411370e7 *** empty log message *** 2000-12-16 13:41:40 +00:00
Jim Meyering
eb24d1f55c *** empty log message *** 2000-12-16 13:40:37 +00:00
Jim Meyering
608b347584 This bug had a serious impact on chown: `chown N:M FILE' (for integer
N and M) would have treated it like `chown N:N FILE'.
(parse_user_spec): Fix typo: s/u/g/.
2000-12-16 13:28:13 +00:00
Jim Meyering
6c4cbe6b5f (main): Rename local, group, to gid. 2000-12-16 13:10:05 +00:00
Jim Meyering
ad31d9b60c tweak a comment 2000-12-16 13:01:24 +00:00
Jim Meyering
8e2ee9a689 (main): Rename locals, user/group, to uid/gid. 2000-12-16 12:57:14 +00:00
Jim Meyering
067af316b6 *** empty log message *** 2000-12-16 09:23:52 +00:00
Jim Meyering
c0ab7dc021 *** empty log message *** 2000-12-16 09:23:32 +00:00
Jim Meyering
8233adab59 Use group-names. 2000-12-16 09:23:10 +00:00
Jim Meyering
be74434bbd Use group-names. 2000-12-16 09:21:20 +00:00
Jim Meyering
bbc027cf8b *** empty log message *** 2000-12-16 09:19:34 +00:00
Jim Meyering
43da73f064 Don't assume that creating a file gives it group $g1. 2000-12-16 09:11:24 +00:00
Jim Meyering
ffc1ef87ea . 2000-12-16 08:20:57 +00:00
Jim Meyering
66e2135f07 (TESTS): Add recurse. 2000-12-16 08:20:11 +00:00
Jim Meyering
e6a5c51ed7 Add ISO-8859-3, BIG5HKSCS, GB18030, JOHAB, VISCII,
CP874, CP949, CP950, CP1250, CP1253, CP1254, CP1255, CP1256, CP1257
to the list of canonical encodings. Rename EUC-CN to GB2312.
2000-12-15 23:43:55 +00:00
Jim Meyering
d952853f74 *** empty log message *** 2000-12-15 14:49:48 +00:00
Jim Meyering
3ebf224b28 *** empty log message *** 2000-12-15 14:45:50 +00:00
Jim Meyering
9be2faa156 *** empty log message *** 2000-12-15 13:32:24 +00:00
Jim Meyering
a8fff5ee1f *** empty log message *** 2000-12-15 13:31:21 +00:00
Jim Meyering
4ab4534292 . 2000-12-15 13:30:32 +00:00
Jim Meyering
0e81b6b48e (main): Reflect renaming: s/dereference/change_symlinks/. 2000-12-15 13:29:56 +00:00
Jim Meyering
694c6b3a86 (enum Dereference_symlink): rename member: s/change_symlinks/dereference/ 2000-12-15 13:27:03 +00:00
Jim Meyering
9724aab7a6 Declare lstat.
Rename change_symlinks member to `dereference' and use the DEREF_*
enum values.
(describe_change): Merge the chgrp and chown switch statements.
Use xmalloc to form the `user:group' string.
(change_file_owner): Record (and later, use) is_symlink and is_directory
from the lstat stats, in order to control whether we operate on symlinks
and whether (with -R) we traverse symlinks to directories.
When dereferencing, use open/fchown (rather than chown) on symlinks.
2000-12-15 13:24:47 +00:00
Jim Meyering
b6ca14a123 changed messages to match those chgrp now produces 2000-12-15 08:42:35 +00:00
Jim Meyering
976f3796be *** empty log message *** 2000-12-14 15:01:55 +00:00
Jim Meyering
1c643649b0 *** empty log message *** 2000-12-14 15:01:24 +00:00
Jim Meyering
3337b5a092 *** empty log message *** 2000-12-14 14:52:15 +00:00
Jim Meyering
b41ab84baa *** empty log message *** 2000-12-13 22:25:42 +00:00
Jim Meyering
af996c06d0 *** empty log message *** 2000-12-13 07:54:44 +00:00
Jim Meyering
2a21b4cf40 *** empty log message *** 2000-12-10 23:25:43 +00:00
Jim Meyering
3614a52150 *** empty log message *** 2000-12-10 12:50:40 +00:00
Jim Meyering
d2be99eb17 add envvar and lang checks 2000-12-10 09:20:52 +00:00
Jim Meyering
fca6110993 *** empty log message *** 2000-12-10 09:20:35 +00:00
Jim Meyering
9bb0e5cdb7 *** empty log message *** 2000-12-10 08:07:38 +00:00
Jim Meyering
cf302e3bc9 give a better diagnostic when only the group is being changed 2000-12-10 08:04:50 +00:00
Jim Meyering
b50fed9980 . 2000-12-09 22:18:02 +00:00
Jim Meyering
baf047f89a *** empty log message *** 2000-12-09 22:17:31 +00:00
Jim Meyering
a65f9eef4a *** empty log message *** 2000-12-09 22:16:57 +00:00
Jim Meyering
9c149c3b6c . 2000-12-09 22:07:28 +00:00
Jim Meyering
d64368c699 *** empty log message *** 2000-12-09 22:06:03 +00:00
Jim Meyering
97e76d3e24 (jm_MACROS): Remove jm_SYS_OFF_T_PRINTF_FORMAT. 2000-12-09 22:05:54 +00:00
Jim Meyering
a157495002 . 2000-12-09 22:05:28 +00:00
Jim Meyering
3c805daf45 . 2000-12-09 20:55:41 +00:00
Jim Meyering
8f55fdc385 (chopt_free): don't free anything 2000-12-09 20:54:23 +00:00
Jim Meyering
26f88f15c8 *** empty log message *** 2000-12-09 20:44:39 +00:00
Jim Meyering
6820c8729e *** empty log message *** 2000-12-09 20:39:17 +00:00
Jim Meyering
78169b6a2f *** empty log message *** 2000-12-09 20:38:12 +00:00
Jim Meyering
5a795ec749 Include "chown-core.h".
[enum Change_status, enum Verbosity]: Remove declarations.
Remove decls of globals that are now part of struct Chown_option.
Remove decl of xstat.
(describe_change): Remove function.
(change_file_group): Likewise.
(change_dir_group): Likewise.
(parse_group): Don't set global, groupname, here...
(main): ... instead, initialize `chopt.group_name' here.
Initialize chopt and update uses of the now-members.
Set group_name also when it's obtained via a --reference=FILE option.
Call change_file_owner (with -1 for uids), not change_file_group.
2000-12-09 20:38:01 +00:00
Jim Meyering
d26ef4e978 add 3 more prototypes 2000-12-09 20:31:56 +00:00
Jim Meyering
40d911bc45 Include <pwd.h>, <grp.h>, and "xalloc.h".
[!_POSIX_VERSION]: Declare getgrnam and getgrgid.
(gid_to_name): New function.
(uid_to_name): Likewise.
(chopt_free): Likewise.
2000-12-09 20:31:34 +00:00
Jim Meyering
748db39d02 Don't include pwd.h or grp.h -- no longer needed.
Include chown-core.h.
[enum Change_status, enum Verbosity]: Remove declarations.
Remove decls of globals that are now part of struct Chown_option.
(describe_change): Remove function.
(change_file_owner): Likewise.
(change_dir_owner): Likewise.
(main): Initialize chopt and update uses of the now-members.
Set user_name and group_name also when they're obtained via a
--reference=FILE option.
Pass `chopt' to change_file_owner.
2000-12-09 20:29:32 +00:00
Jim Meyering
4db97b7a7d *** empty log message *** 2000-12-09 14:47:06 +00:00
Jim Meyering
f8b26d3ade *** empty log message *** 2000-12-09 14:46:34 +00:00
Jim Meyering
5c8eb8ec36 *** empty log message *** 2000-12-09 14:08:07 +00:00
Jim Meyering
64f7bff756 *** empty log message *** 2000-12-09 13:50:13 +00:00
Jim Meyering
040db4c3fe *** empty log message *** 2000-12-09 13:48:03 +00:00
Jim Meyering
34ef74b11c *** empty log message *** 2000-12-09 13:44:37 +00:00
Jim Meyering
de4a3dfb26 *** empty log message *** 2000-12-09 13:44:10 +00:00
Jim Meyering
108881a3b2 *** empty log message *** 2000-12-09 13:38:51 +00:00
Jim Meyering
7d5f893b7f *** empty log message *** 2000-12-09 12:47:51 +00:00
Jim Meyering
8d977c3978 *** empty log message *** 2000-12-09 10:15:26 +00:00
Jim Meyering
73f1bc31d7 (change_file_owner): Restore special file permission
bits, since calling chown resets them on some systems.
Reported by Matt Perry.
2000-12-09 10:15:17 +00:00
Jim Meyering
497d1d9e97 *** empty log message *** 2000-12-09 10:14:52 +00:00
Jim Meyering
764dd3149e Don't make the success of the test depend
on the order in which directory entries are processed.
2000-12-08 20:31:47 +00:00
Jim Meyering
b2b9bed164 *** empty log message *** 2000-12-08 20:31:15 +00:00
Jim Meyering
9580e7cc87 *** empty log message *** 2000-12-08 18:32:11 +00:00
Jim Meyering
a05267197a (mbsnwidth): Don't loop endlessly when called with an
invalid mulitbyte sequence and with the MBSW_ACCEPT_INVALID flag set.
2000-12-08 18:31:38 +00:00
Jim Meyering
a90e5f5a69 *** empty log message *** 2000-12-08 08:06:33 +00:00
Jim Meyering
1f47a082c4 Include xalloc.h.
(main): Use dir_name rather than the underlying dir_name_r.
The former now handles cwd-relative names with drive-letter prefixes.
2000-12-08 07:55:05 +00:00
Jim Meyering
7b55b7aa13 *** empty log message *** 2000-12-07 14:14:18 +00:00
Jim Meyering
bcc94017bc convert a > expression to the equivalent < one 2000-12-07 14:13:51 +00:00
Jim Meyering
b615d79ac3 (ISSLASH): Define.
(strip_trailing_slashes): Use ISSLASH rather than comparing against `/'.
From Prashant TR.
2000-12-07 14:13:13 +00:00
Jim Meyering
04f549820f convert a > expression to the equivalent < one 2000-12-07 14:11:52 +00:00
Jim Meyering
ded8b14afb *** empty log message *** 2000-12-07 14:10:33 +00:00
Jim Meyering
4504b81f3b (FILESYSTEM_PREFIX_LEN): Define.
(dir_name_r): Declare this function as static.
[BACKSLASH_IS_PATH_SEPARATOR]: Fix a bug that'd
manifest itself on a name containing a mix of slashes and
backslashes.
Make this function work with names starting with a DOS-style
drive letter and colon prefix.
(dir_name): Append `.' if necessary.
Based mostly on patches from Prashant TR and Eli Zaretskii.
2000-12-07 14:10:21 +00:00
Jim Meyering
222412dbf1 (dir_name_r): Remove prototype. 2000-12-07 11:50:35 +00:00
Jim Meyering
71751f757d *** empty log message *** 2000-12-07 10:07:28 +00:00
Jim Meyering
8c8424d0c2 (address_base): Declare to be static. 2000-12-07 10:07:08 +00:00
Jim Meyering
e42f27d147 (address_base, address_pad_len): New var.
(output_address_fmt_string, address_fmt_buffer, address_pad): Remove.
(flag_pseudo_start): Now int, not long int.
(pseudo_offset): Now off_t, not long int.
(n_specs, n_specs_allocated): Now size_t, not unsigned int.
(format_address, format_address_none, format_address_std,
format_address_label): Now accepts an extra char argument (an extra
char to print if nonzero), and prints instead of returning a string.
All callers changed.
(bytes_per_block): Now size_t, not int.
(format_address_none): Do not even print the extra char argument.
This simplifies the callers.
(format_address_std, format_address_label): Print off_t ourself
instead of trying to use autoconfigured format.  This is faster and
more portable.
(format_address_paren): New function.
(dump): Remove unnecessary cast.
(expand_address_fmt): Remove.
(main): Use size_t, off_t, etc. instead of builtin types where this is
advisable.  Adjust to above changes.  Remove unnecessary cast.
2000-12-07 10:05:09 +00:00
Jim Meyering
d1cca1ee9c *** empty log message *** 2000-12-06 11:06:43 +00:00
Jim Meyering
0654f3206d Check for strtol. Mainly as a cue to cause automake to include
strtol.c -- that file is included by each of strtoul.c and strtoull.c.
Check for limits.h -- strtol.c needs it.
2000-12-06 11:06:39 +00:00
Jim Meyering
67cf94a857 *** empty log message *** 2000-12-06 10:52:37 +00:00
Jim Meyering
69ed54e544 Check for declarations of strtoul and strtoull. 2000-12-06 10:52:28 +00:00
Jim Meyering
3dabe6b533 separate conditions for strtoul and strtoull 2000-12-06 10:26:51 +00:00
Jim Meyering
2845214164 *** empty log message *** 2000-12-06 09:55:03 +00:00
Jim Meyering
6b8102a180 *** empty log message *** 2000-12-06 09:35:48 +00:00
Jim Meyering
570074d6d1 (jm_AC_PREREQ_XSTRTOUMAX): If we need the replacement
strtoull, we may well need the replacement strtoul, too.
2000-12-06 09:35:40 +00:00
Jim Meyering
72a6d74ab2 . 2000-12-05 13:53:13 +00:00
Jim Meyering
cd6f0af0ea (dir_name_r): Add `const' in a few local declarations. 2000-12-05 13:14:13 +00:00
Jim Meyering
2746cd50c3 *** empty log message *** 2000-12-04 09:41:28 +00:00
Jim Meyering
8a4261c7a5 *** empty log message *** 2000-12-04 09:37:40 +00:00
Jim Meyering
90799b6c68 Also include memory.h, stdlib.h, unistd.h if appropriate. 2000-12-04 09:37:33 +00:00
Jim Meyering
1c6320fe7c *** empty log message *** 2000-12-04 09:15:54 +00:00
Jim Meyering
fecdd2bd2b [!HAVE_DECL_MALLOC]: Declare malloc. 2000-12-04 09:15:49 +00:00
Jim Meyering
15691fb64f *** empty log message *** 2000-12-03 22:40:40 +00:00
Jim Meyering
cb366955f3 (gobble_file) [USE_ACL]: Set have_acl member unconditionally
to avoid uninitialized memory reference via FILE_HAS_ACL.
2000-12-03 22:40:31 +00:00
Jim Meyering
82a6fbda1c *** empty log message *** 2000-12-03 20:46:07 +00:00
Jim Meyering
177b2553e2 (TESTS): Add assert-2. 2000-12-03 20:43:51 +00:00
Jim Meyering
814e63e371 remove instrumentation 2000-12-03 20:37:55 +00:00
Jim Meyering
2eed25f2ed add instrumentation to detect some UMRs 2000-12-03 20:37:18 +00:00
Jim Meyering
1be9e19c7d *** empty log message *** 2000-12-03 20:36:29 +00:00
Jim Meyering
b7895d0d10 (tail_file): Initialize ignore, dev, and ino members,
when tailing forever and the open failed.  Otherwise, we could get
uninitialized memory references of those fields in recheck.
2000-12-03 20:36:19 +00:00
Jim Meyering
8461820956 *** empty log message *** 2000-12-03 13:10:48 +00:00
Jim Meyering
86960ce221 *** empty log message *** 2000-12-03 12:46:55 +00:00
Jim Meyering
6670163eee (alpha): Use rsync rather than scp, so the destination
file is created only after the successful completion of the copy.
2000-12-03 12:46:44 +00:00
Jim Meyering
437f8becaa . 2000-12-03 12:31:59 +00:00
Jim Meyering
5233121102 use CHAR_BIT, not BITSPERBYTE 2000-12-03 11:00:06 +00:00
Jim Meyering
25c2989d30 *** empty log message *** 2000-12-03 10:59:49 +00:00
Jim Meyering
4f96dfa43e (CHAR_BIT): Define. 2000-12-03 10:59:44 +00:00
Jim Meyering
f559a4afa3 *** empty log message *** 2000-12-03 10:39:03 +00:00
Jim Meyering
b5d4b2c555 *** empty log message *** 2000-12-03 10:22:32 +00:00
Jim Meyering
d8a157a00e *** empty log message *** 2000-12-03 10:21:34 +00:00
Jim Meyering
85a75d3a16 *** empty log message *** 2000-12-03 10:18:09 +00:00
Jim Meyering
d183ecddcd Make od print valid addresses for offsets of 2^32 and larger. (cont'd)
(MAX_ADDRESS_LENGTH): Don't hard-code as a literal.
Rather, define in terms of the type, off_t.
(string_min): Declare to be of type size_t.
(flag_dump_strings): Declare to be of type int.
(print_s_char): Declare the n_bytes parameter and the local, `i',
to be of type off_t.
(print_char): Likewise.
(print_s_short): Likewise.
(print_short): Likewise.
(print_int): Likewise.
(print_long): Likewise.
(print_long_long): Likewise.
(print_float): Likewise.
(print_double): Likewise.
(print_long_double): Likewise.
(dump_hexl_mode_trailer): Likewise.
(print_named_ascii): Likewise.
(print_ascii): Likewise.
(write_block): Likewise.
(print_ascii): Declare local, `print_function' with a prototype.
Change a few `>' comparisons to the equivalent `<' form.
(parse_options): Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if the specified offset if larger than OFF_T_MAX.
(dump_strings): Declare local `i' to be of type size_t.
Remove the now-unnecessary cast-to-off_t.
(main) [IF_LINT]: Initialize desired_width to avoid a warning.
Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if minimum string length is larger than SIZE_MAX.
Fail if specified width is larger than ULONG_MAX.
2000-12-03 10:18:04 +00:00
Jim Meyering
e30c09b4cb Add this:
AC_REQUIRE([AC_TYPE_OFF_T])
2000-12-03 10:04:30 +00:00
Jim Meyering
9d5d7f0d50 (OFF_T_MIN): Remove definition.
(OFF_T_MAX): Likewise.
2000-12-03 08:55:51 +00:00
Jim Meyering
caae4ed5a7 (OFF_T_MIN): Define.
(OFF_T_MAX): Define.
2000-12-03 08:54:37 +00:00
Jim Meyering
a1ca60f4e5 Make od print valid addresses for offsets of 2^32 and larger.
(format_address): Use off_t, not long unsigned_int as the
parameter type.
(format_address_none): Likewise.  Mark parameter as unused.
(format_address_std): Likewise.
(format_address_label): Likewise.
(print_ascii): Mark format string parameter as unused.
(write_block): Use off_t, not long unsigned_int as offset type.
(expand_address_fmt): New function.
(main): Use it to expand each address format string template.
Reported by Mark Nudelman, via Andreas Jaeger.
2000-12-03 08:44:12 +00:00
Jim Meyering
ce861b2cb3 (parse_options): Use xstrtoumax to parse the byte and line
offset.  Give a better diagnostic when the requested offset is still
representable but larger than OFF_T_MAX.
2000-12-03 08:35:48 +00:00
Jim Meyering
67ec78d188 *** empty log message *** 2000-12-02 22:18:29 +00:00
Jim Meyering
d661be38ed (valid_format): Move pre-increment to a separate statement to avoid a warning. 2000-12-02 22:18:21 +00:00
Jim Meyering
69e30c7f2a Move dcls of globals used only in main...
(main): ...to here.
(usage): Clarify option descriptions.
2000-12-02 22:16:41 +00:00
Jim Meyering
8973e2b38c whoops. rename the use, too -- not just the decl!! 2000-12-02 21:14:41 +00:00
Jim Meyering
df52f23ebf *** empty log message *** 2000-12-02 21:14:09 +00:00
Jim Meyering
5edc91fc05 (checkfp): Rename local `buf' to avoid shadowing previous declaration. 2000-12-02 21:14:02 +00:00
Jim Meyering
8b4ac20908 (skip): Use lseek instead of worrying about fseeko or fseek.
This should be portable, as we seek before doing any I/O.
(fseeko): Remove; no longer used.
2000-12-02 21:08:01 +00:00
Jim Meyering
1a0d9ea086 add back the parens Paul removed :-) 2000-12-02 20:55:25 +00:00
Jim Meyering
e49511faef (gobble_file): Do not fall back on lstat if stat
fails; POSIX.2 does not allow this.  Invoke acl only on
non-symlinks, and only if lstat or stat succeeds.
2000-12-02 20:55:02 +00:00
Jim Meyering
e05c32a868 *** empty log message *** 2000-12-02 20:52:09 +00:00
Jim Meyering
c2f898236f *** empty log message *** 2000-12-02 20:45:40 +00:00
Jim Meyering
501ebc1cba Make idempotent, to avoid some obscure warnings. 2000-12-02 20:45:30 +00:00
Jim Meyering
77182607c0 . 2000-12-02 18:52:17 +00:00
Jim Meyering
6769657fa3 *** empty log message *** 2000-12-02 18:52:03 +00:00
Jim Meyering
dab453378b (OFF_T_PRINTF_FORMAT_STRING): require it. 2000-12-02 18:51:26 +00:00
Jim Meyering
aa266c29eb *** empty log message *** 2000-12-02 18:04:19 +00:00
Jim Meyering
6b94589fa4 *** empty log message *** 2000-12-02 18:02:05 +00:00
Jim Meyering
0d849addb3 *** empty log message *** 2000-12-02 17:44:04 +00:00
Jim Meyering
1698b85090 *** empty log message *** 2000-12-02 17:40:26 +00:00
Jim Meyering
a538ba0149 *** empty log message *** 2000-12-02 17:39:59 +00:00
Jim Meyering
41f20fd38f *** empty log message *** 2000-12-02 14:53:18 +00:00
Jim Meyering
1c8189de61 (TESTS): Add follow-slink. 2000-12-02 14:53:07 +00:00
Jim Meyering
525e76fce0 *** empty log message *** 2000-12-02 14:52:45 +00:00
Jim Meyering
d91624bd99 *** empty log message *** 2000-12-02 14:43:34 +00:00
Jim Meyering
1c71127370 (NONZERO): Define and use it to make the code a tiny
bit more readable.
2000-12-02 14:43:28 +00:00
Jim Meyering
4f1553c89f *** empty log message *** 2000-12-02 14:28:23 +00:00
Jim Meyering
1b9cb7ea23 (sort invocation): Clarify how -t works when
a sort key specifies a range of fields.  From Karl O. Pinc.
2000-12-02 14:28:11 +00:00
Jim Meyering
479aba180c *** empty log message *** 2000-12-02 14:10:37 +00:00
Jim Meyering
8eeae63a74 . 2000-12-02 14:04:05 +00:00
Jim Meyering
07584e33ec add test that would fail on NetBSD before the last change 2000-12-02 14:02:34 +00:00
Jim Meyering
33ba435db5 *** empty log message *** 2000-12-02 13:22:57 +00:00
Jim Meyering
73fe66c783 *** empty log message *** 2000-12-02 13:22:14 +00:00
Jim Meyering
cc27b86c60 (main): Remove any trailing slash unconditionally.
Reported by Volker Borchert.
2000-12-02 13:20:37 +00:00
Jim Meyering
9db47bb808 *** empty log message *** 2000-12-02 12:15:00 +00:00
Jim Meyering
8bf3961df0 *** empty log message *** 2000-12-02 12:05:15 +00:00
Jim Meyering
df7d583cc2 (TESTS): Add skip-seek2 2000-12-02 12:05:03 +00:00
Jim Meyering
271e41850b *** empty log message *** 2000-12-02 12:04:32 +00:00
Jim Meyering
97b58344c5 *** empty log message *** 2000-12-02 09:58:43 +00:00
Jim Meyering
627dac6c07 Include <config.h> before any system include file. 2000-12-02 09:58:31 +00:00
Jim Meyering
0742bc284e *** empty log message *** 2000-12-02 08:19:31 +00:00
Jim Meyering
acca4638b8 (skip, dd_copy): Use ssize_t to store result of
safe_read, to avoid overflow e.g. on 64-bit Solaris sparc.
(dd_copy): Remove unnecessary cast.
2000-12-02 08:19:21 +00:00
Jim Meyering
05aabec021 *** empty log message *** 2000-12-02 08:14:33 +00:00
Jim Meyering
e996c1bd77 Undo most of the changes since 2000-11-24, since we've
documented a standard way to do it.
(skip_bytes, seek_bytes): Remove.
(usage): Remove B suffix.
(scanargs, skip, dd_copy, main): Remove support for B suffix.
2000-12-02 08:12:56 +00:00
Jim Meyering
b529a77be8 *** empty log message *** 2000-11-30 20:36:08 +00:00
Jim Meyering
4faf0a9a17 *** empty log message *** 2000-11-30 20:35:02 +00:00
Jim Meyering
3e50cea2f5 (jm_MACROS): Add stdint.h to the list of headers. 2000-11-30 20:34:23 +00:00
Jim Meyering
339738f351 s/SIZE_T_MAX/SIZE_MAX/. 2000-11-30 20:30:04 +00:00
Jim Meyering
a48a4d5c63 Include <stdint.h> if HAVE_STDINT_H.
(SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX.
All uses changed.
2000-11-30 20:27:49 +00:00
Jim Meyering
57a0382b5f *** empty log message *** 2000-11-30 11:39:19 +00:00
Jim Meyering
835a8fa634 (SIZE_T_MAX): Define. 2000-11-30 11:39:08 +00:00
Jim Meyering
4ff7ab63ab *** empty log message *** 2000-11-30 11:33:57 +00:00
Jim Meyering
d92f4ac85e Port GNU "sort" to hosts where sizes don't fit in "int",
e.g. 64-bit Solaris (sparc).

("human.h", "xstrtol.h"): Include.
(struct line): length member is now size_t, not int.
(struct lines): Likewise for used, alloc, limit members.
(struct buffer): Likewise for used, alloc, left, newline_free members.
(struct keyfield): Likewise for sword, schar, eword, echar members.
(sortalloc, mergealloc, linelength): Now size_t, not int.

(initbuf, fillbuf, initlines, begfield, limfield, findlines,
numcompare, getmonth, keycompare, compare, checkfp, mergefps,
sortlines, sort): Accept, return, and use size_t for sizes, not int.

(fillbuf, initlines, findlines, checkfp, sort): Check for overflow
when computing buffer sizes.

(begfield, limfield): Do not index past end of array.

(checkfp): Return a boolean, not a line number, as the line
number may not fit in int.  All callers changed.  Use
uintmax_t for line numbers, not int.

(sort): Don't allocate tmp until we need it (and know the right size).

(parse_field_count): New function.

(main): Use it to check for overflow in field counts.
"outfile" is now a pointer to const.
2000-11-30 11:33:49 +00:00
Jim Meyering
21b8c52ae9 *** empty log message *** 2000-11-30 09:36:04 +00:00
Jim Meyering
7303ca25db (dir_name_r): Fix typo: int -> size_t. 2000-11-30 09:35:52 +00:00
Jim Meyering
060fb58f86 *** empty log message *** 2000-11-30 07:45:38 +00:00
Jim Meyering
d185a442b9 s/ifval/m4_ifval/ to accommodate new autoconf. 2000-11-30 07:44:58 +00:00
Jim Meyering
86046cb32f . 2000-11-30 07:40:16 +00:00
Jim Meyering
1500316caf remove useless parens 2000-11-27 09:33:53 +00:00
Jim Meyering
72454050bb *** empty log message *** 2000-11-27 09:04:38 +00:00
Jim Meyering
b0b9c6fee7 *** empty log message *** 2000-11-27 08:47:13 +00:00
Jim Meyering
4a9feba665 add an echo 2000-11-27 08:45:46 +00:00
170 changed files with 6828 additions and 1776 deletions

View File

@@ -85,8 +85,9 @@ alpha_subdir = gnu/fetish
a_url_dir = $(alpha_subdir)
b_url_dir = $(alpha_subdir)
a_real_dir = /fs/share/ftp/$(alpha_subdir)
b_real_dir = fetish-ftp
# This must be the same name on both hosts.
# Make it a symlink that points to the right place.
real_dir = fetish-ftp
url_dir_list = $(foreach x,a b,ftp://$($(x)_host)/$($(x)_url_dir))
@@ -121,6 +122,7 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
for url in $(url_dir_list); do \
echo " $$url/$(xd-delta)"; \
done; \
echo; \
echo "Here are the MD5 and SHA1 signatures for the .tar.gz file"; \
echo; \
echo "$(md5) $(distdir).tar.gz"; \
@@ -158,6 +160,17 @@ wget-update:
$(WGET) $(ftp-gnu)/config/config.sub -O $(srcdir)/config.sub
cvs -d $(automake_repo) co -p automake/depcomp > depcomp
define emit-rsync-commands
echo =====================================
echo =====================================
echo 'for host in $(a_host) $(b_host); do \'
echo ' rsync -e ssh --pro -av $(xd-delta) $(distdir).tar.gz \'
echo ' $$host:$(real_dir); done'
echo '# send the /tmp/announcement e-mail'
echo =====================================
echo =====================================
endef
alpha: writable-files po-check
$(MAKE) cvs-dist
$(MAKE) -s announcement > /tmp/announce-$(distdir)
@@ -169,10 +182,4 @@ alpha: writable-files po-check
chmod a-w $(release-archive-dir)/$(xd-delta)
echo $(VERSION) > $(prev_version_file)
cvs ci -m. $(prev_version_file)
@echo =====================================
@echo =====================================
@echo 'scp $(xd-delta) $(distdir).tar.gz \'
@echo ' $(b_host):$(b_real_dir)'
@echo '# send the /tmp/announcement e-mail'
@echo =====================================
@echo =====================================
@$(emit-rsync-commands)

12
THANKS
View File

@@ -34,6 +34,7 @@ Arne H. Juul arnej@solan.unit.no
Arne Henrik Juul arnej@imf.unit.no
Arthur Pool pool@commerce.uq.edu.au
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
Axel Kittenberger Anshil@gmx.net
Bauke Jan Douma bjdouma@xs4all.nl
Bengt Martensson bengt@mathematik.uni-Bremen.de
Bernd Leibing bernd.leibing@rz.uni-ulm.de
@@ -66,8 +67,10 @@ Collin Rogowski collin@rogowski.de
Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
Darren Salt ds@youmustbejoking.demon.co.uk
David Dyck dcd@tc.fluke.COM
David Godfrey dave@delta.demon.co.uk
David Luyer david_luyer@pacific.net.au
Dennis Henriksen opus@flamingo.osrl.dk
Derek Clegg dclegg@next.com
Dick Streefland dick_streefland@tasking.com
@@ -151,6 +154,7 @@ John Roll john@panic.harvard.edu
John Salmon johns@mullet.anu.edu.au
John Summerfield summer@OS2.ami.com.au
Joost van Baal joostvb@xs4all.nl
Jorge Stolfi stolfi@ic.unicamp.br
Joseph S. Myers jsm28@cam.ac.uk
Jungshik Shin jshin@pantheon.yale.edu
Jürgen Fluk louis@dachau.marco.de
@@ -185,7 +189,9 @@ Mark A. Thomas thommark@access.digex.net
Mark D. Roth roth@uiuc.edu
Mark Harris mark@monitor.designacc.com
Mark Hewitt mhewitt@armature.com
Mark Hounschell markh@compro.net
Mark Kettenis kettenis@phys.uva.nl
Mark Nudelman marknu@flash.net
Mark W. Eichin eichin@cygnus.com
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
Martin martin@dresden.nacamar.de
@@ -197,9 +203,12 @@ Marty Leisner leisner@sdsp.mc.xerox.com
Masami Takikawa takikawm@CS.ORST.EDU
Mate Wierdl mw@moni.msci.memphis.edu
Matej Vela mvela@public.srce.hr
Matt Perry matt@primefactor.com
Matt Schalit mschalit@pacbell.net
Matthew Braun matthew@ans.net
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
Matthew S. Levine mslevine@theory.lcs.mit.edu
Matthew Smith matts@bluesguitar.org
Matthew Swift swift@alum.mit.edu
Mattias Wadenstein maswan@acc.umu.se
Matthias Urlichs smurf@noris.de
@@ -208,6 +217,8 @@ Michael ??? michael@roka.net
Michael Deutschmann michael@talamasca.ocis.net
Michael Hasselberg mikelh@zonta.ping.de
Michael Hohn hohn@math.utah.edu
Michael J. Croghan mcroghan@usatoday.com
Michael Steffens michael.steffens@s.netic.de
Michael Stone mstone@debian.org
Michael Stutz stutz@dsl.org
Michael Veksler mveksler@techunix.technion.ac.il
@@ -221,6 +232,7 @@ Niklas Edmundsson nikke@acc.umu.se
Noah Friedman friedman@splode.com
Noel Cragg noel@red-bean.com
Olav Morkrid olav@funcom.com
Oskar Liljeblad osk@hem.passagen.se
Ørn E. Hansen oehansen@daimi.aau.dk
Paul Eggert eggert@twinsun.com
Paul Nevai nevai@ops.mps.ohio-state.edu

View File

@@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am
# Makefile.in generated automatically by automake 1.4b from Makefile.am
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
@@ -155,7 +155,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(srcdir)/version.texi: stamp-vti
$(srcdir)/version.texi: $(srcdir)/stamp-vti
@:
$(srcdir)/stamp-vti: fileutils.texi $(top_srcdir)/configure.in
@@ -180,8 +180,8 @@ distclean-vti:
maintainer-clean-vti:
-rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
fileutils.info: fileutils.texi version.texi
fileutils.dvi: fileutils.texi version.texi
fileutils.info: fileutils.texi $(srcdir)/version.texi
fileutils.dvi: fileutils.texi $(srcdir)/version.texi
DVIPS = dvips

View File

@@ -100,6 +100,34 @@ When a month is written this way, it is still considered to be written
numerically, instead of being ``spelled in full''; this changes the
allowed strings.
@cindex language, in dates
In the current implementation, only English is supported for words and
abbreviations like @samp{AM}, @samp{DST}, @samp{EST}, @samp{first},
@samp{January}, @samp{Sunday}, @samp{tomorrow}, and @samp{year}.
@cindex language, in dates
@cindex time zone item
The output of @command{date} is not always acceptable as a date string,
not only because of the language problem, but also because there is no
standard meaning for time zone items like @samp{IST}. When using
@command{date} to generate a date string intended to be parsed later,
specify a date format that is independent of language and that does not
use time zone items other than @samp{UTC} and @samp{Z}. Here are some
ways to do this:
@example
$ LC_ALL=C TZ=UTC0 date
Fri Dec 15 19:48:05 UTC 2000
$ TZ=UTC0 date +"%Y-%m-%d %H:%M:%SZ"
2000-12-15 19:48:05Z
$ date --iso-8601=seconds # a GNU extension
2000-12-15T11:48:05-0800
$ date --rfc-822 # a GNU extension
Fri, 15 Dec 2000 11:48:05 -0800
$ date +"%Y-%m-%d %H:%M:%S %z" # %z is a GNU extension.
2000-12-15 11:48:05 -0800
@end example
@cindex case, ignored in dates
@cindex comments, in dates
Alphabetic case is completely ignored in dates. Comments may be introduced
@@ -238,13 +266,15 @@ but not both.
@cindex time zone item
A @dfn{time zone item} specifies an international time zone, indicated
by a small set of letters, e.g., @samp{UTC} for Coordinated Universal
by a small set of letters, e.g., @samp{UTC} or @samp{Z}
for Coordinated Universal
Time. Any included periods are ignored. By following a
non-daylight-saving time zone by the string @samp{DST} in a separate
word (that is, separated by some white space), the corresponding
daylight saving time zone may be specified.
Time zone items are obsolescent and are not recommended, because they
Time zone items other than @samp{UTC} and @samp{Z}
are obsolescent and are not recommended, because they
are ambiguous; for example, @samp{EST} has a different meaning in
Australia than in the United States. Instead, it's better to use
unambiguous numeric time zone corrections like @samp{-0500}, as

View File

@@ -69,11 +69,12 @@ matter what group the user who creates them is in.
@cindex sticky
@cindex swap space, saving text image in
@cindex text image, saving in swap space
@cindex append-only directories
@cindex restricted deletion flag
save the program's text image on the swap device so it will load more
quickly when run (called the @dfn{sticky bit}). For directories on some
systems, prevent users from removing files that they do not own in the
directory; this is called making the directory @dfn{append-only}.
systems, prevent users from removing or renaming a file in a directory
unless they own the file or the directory; this is called the
@dfn{restriction deletion flag} for the directory.
@end enumerate
@node Symbolic Modes
@@ -118,7 +119,7 @@ format:
@noindent
The spaces between the three parts above are shown for readability only;
symbolic modes can not contain spaces.
symbolic modes cannot contain spaces.
The @var{users} part tells which users' access to the file is changed.
It consists of one or more of the following letters (or it can be empty;
@@ -427,7 +428,7 @@ This number is always interpreted in octal; you do not have to add a
leading 0, as you do in C. Mode 0055 is the same as mode 55.
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
mode, but it is limited in that it cannot take into account a file's
previous permissions; it can only set them absolutely.
On most systems, the permissions granted to the user,

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{2000-11-09.08}
\def\texinfoversion{2000-12-11.07}
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
% Free Software Foundation, Inc.
@@ -704,20 +704,35 @@ where each line of input produces a line of output.}
% if you have multiple lines of stuff to put here, you'll need to
% make the vbox yourself of the appropriate size.
\ifx#1l%
\llap{#2\hskip\inmarginspacing}%
\llap{\ignorespaces #2\hskip\inmarginspacing}%
\else
\rlap{\hskip\hsize\hskip\inmarginspacing#2}%
\rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
\fi
\null
}%
}}
\def\inleftmargin{\doinmargin l}
\def\inrightmargin{\doinmargin r}
\def\inmargin{% not perfect, but better than nothing.
\ifodd\pageno
\let\temp=\inleftmargin
%
% @inmargin{TEXT [, RIGHT-TEXT]}
% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
% else use TEXT for both).
%
\def\inmargin#1{\parseinmargin #1,,\finish}
\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
\setbox0 = \hbox{\ignorespaces #2}%
\ifdim\wd0 > 0pt
\def\lefttext{#1}% have both texts
\def\righttext{#2}%
\else
\let\temp=\inrightmargin
\def\lefttext{#1}% have only one text
\def\righttext{#1}%
\fi
%
\ifodd\pageno
\def\temp{\inleftmargin\lefttext}%
\else
\def\temp{\inrightmargin\righttext}%
\fi
\temp
}
@@ -4304,6 +4319,7 @@ width0pt\relax} \fi
\gobble
}
% @quotation does normal linebreaking (hence we can't use \nonfillstart)
% and narrows the margins.
%
@@ -4326,6 +4342,158 @@ width0pt\relax} \fi
}
% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
% If we want to allow any <char> as delimiter,
% we need the curly braces so that makeinfo sees the @verb command, eg:
% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
%
% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
%
% [Knuth] p. 344; only we need to do '@' too
\def\dospecials{%
\do\ \do\\\do\@\do\{\do\}\do\$\do\&%
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
%
% [Knuth] p. 380
\def\uncatcodespecials{%
\def\do##1{\catcode`##1=12}\dospecials}
%
% [Knuth] pp. 380,381,391
% Disable Spanish ligatures ?` and !` of \tt font
\begingroup
\catcode`\`=\active\gdef`{\relax\lq}
\endgroup
%
% Setup for the @verb command.
%
% Eight spaces for a tab
\begingroup
\catcode`\^^I=\active
\gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
\endgroup
%
\def\setupverb{%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\leavevmode\endgraf}%
\catcode`\`=\active
\tabeightspaces
% Respect line breaks,
% print special symbols as themselves, and
% make each space count
% must do in this order:
\obeylines \uncatcodespecials \sepspaces
}
% Setup for the @verbatim environment
%
% Real tab expansion
\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
%
\def\starttabbox{\setbox0=\hbox\bgroup}
\begingroup
\catcode`\^^I=\active
\gdef\tabexpand{%
\catcode`\^^I=\active
\def^^I{\leavevmode\egroup
\dimen0=\wd0 % the width so far, or since the previous tab
\divide\dimen0 by\tabw
\multiply\dimen0 by\tabw % compute previous multiple of \tabw
\advance\dimen0 by\tabw % advance to next multiple of \tabw
\wd0=\dimen0 \box0 \starttabbox
}%
}
\endgroup
\def\setupverbatim{%
% Easiest (and conventionally used) font for verbatim
\tt
\def\par{\leavevmode\egroup\box0\endgraf}%
\catcode`\`=\active
\tabexpand
% Respect line breaks,
% print special symbols as themselves, and
% make each space count
% must do in this order:
\obeylines \uncatcodespecials \sepspaces
\everypar{\starttabbox}%
}
% Do the @verb magic: verbatim text is quoted by unique
% delimiter characters. Before first delimiter expect a
% right brace, after last delimiter expect closing brace:
%
% \def\doverb'{'<char>#1<char>'}'{#1}
%
% [Knuth] p. 382; only eat outer {}
\begingroup
\catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12
\gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
\endgroup
%
\def\verb{\begingroup\setupverb\doverb}
%
%
% Do the @verbatim magic: define the macro \doverbatim so that
% the (first) argument ends when '@end verbatim' is reached, ie:
%
% \def\doverbatim#1@end verbatim{#1}
%
% For Texinfo it's a lot easier than for LaTeX,
% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
% we need not redefine '\', '{' and '}'
%
% Inspired by LaTeX's verbatim command set [latex.ltx]
%% Include LaTeX hack for completeness -- never know
%% \begingroup
%% \catcode`|=0 \catcode`[=1
%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
%% #1|endgroup|def|Everbatim[]|end[verbatim]]
%% |endgroup
\begingroup
\catcode`\ =\active
\gdef\doverbatim#1@end verbatim{#1\end{verbatim}}
\endgroup
%
\def\verbatim{%
\def\Everbatim{\nonfillfinish\endgroup}%
\begingroup
\nonfillstart
\advance\leftskip by -\defbodyindent
\begingroup\setupverbatim\doverbatim
}
% @verbatiminclude FILE - insert text of file in verbatim environment.
%
% Allow normal characters that we make active in the argument (a file name).
\def\verbatiminclude{%
\begingroup
\catcode`\\=12
\catcode`~=12
\catcode`^=12
\catcode`_=12
\catcode`|=12
\catcode`<=12
\catcode`>=12
\catcode`+=12
\parsearg\doverbatiminclude
}
\def\setupverbatiminclude{%
\begingroup
\nonfillstart
\advance\leftskip by -\defbodyindent
\begingroup\setupverbatim
}
%
\def\doverbatiminclude#1{%
% Restore active chars for included file.
\endgroup
\begingroup
\def\thisfile{#1}%
\expandafter\expandafter\setupverbatiminclude\input\thisfile
\endgroup\nonfillfinish\endgroup
}
\message{defuns,}
% @defun etc.

View File

@@ -2260,6 +2260,24 @@ If @var{output-file} is one of the input files, @code{sort} copies
it to a temporary file before sorting and writing the output to
@var{output-file}.
@item -S @var{size}
@opindex -S
@cindex size for main memory sorting
Use a main-memory sort buffer of the given @var{size}. By default,
@var{size} is in units of 1,024 bytes. Appending @samp{%} causes
@var{size} to be interpreted as a percentage of physical memory.
Appending @samp{k} multiplies @var{size} by 1,024 (the default),
@samp{M} by 1,048,576, @samp{G} by 1,073,741,824, and so on for
@samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}. Appending
@samp{b} causes @var{size} to be interpreted as a byte count, with no
multiplication.
This option can improve the performance of @command{sort} by causing it
to start with a larger or smaller sort buffer than the default.
However, this option affects only the initial buffer size. The buffer
grows beyond @var{size} if @command{sort} encounters input lines larger
than @var{size}.
@item -t @var{separator}
@opindex -t
@cindex field separator character
@@ -2269,7 +2287,9 @@ string between a non-whitespace character and a whitespace character.
That is, given the input line @w{@samp{ foo bar}}, @code{sort} breaks it
into fields @w{@samp{ foo}} and @w{@samp{ bar}}. The field separator is
not considered to be part of either the field preceding or the field
following.
following. But note that sort fields that extend to the end of the line,
as @samp{-k 2}, or sort fields consisting of a range, as @samp{-k 2,3},
retain the field separators present between the endpoints of the range.
@item -T @var{tempdir}
@opindex -T

View File

@@ -1,3 +1,181 @@
2001-02-17 Jim Meyering <meyering@lucent.com>
* strtoul.c: Sync from GNU libc. Use double quotes, not <...>
around included file name.
* strnlen.c (__strnlen): Merge in a change from GNU libc.
* strftime.c: Update from GNU libc (the only changes were to comments).
2001-02-13 Bruno Haible <haible@clisp.cons.org>
* mbswidth.h (mbswidth): Also define as macro, to avoid prototype clash.
2001-02-17 Paul Eggert <eggert@twinsun.com>
* mbswidth.c, quotearg.c (mbrtowc, mbsinit):
Remove workaround macros for hosts that have mbrtowc but not
mbstate_t, as we now insist on proper declarations for both
before using mbrtowc.
2001-02-17 Jim Meyering <meyering@lucent.com>
* regex.c: Update from libc.
2001-02-16 Paul Eggert <eggert@twinsun.com>
* lib/alloca.c (malloc): Undef before defining, since stdlib.h
may have defined it. Needed for Encore Umax-3.0.9.16b systems.
Reported by Mark Hounschell via Paul Eggert.
2001-01-30 Bruno Haible <haible@clisp.cons.org>
* config.charset: Update for FreeBSD 4.2.
2001-01-26 Jim Meyering <meyering@lucent.com>
* quotearg.c: Include stddef.h.
* quote.c: Include stddef.h.
Reported by Axel Kittenberger.
* xmalloc.c [HAVE_DONE_WORKING_MALLOC_CHECK]: Enclose error-evoking
line in double quotes so that it evokes a better diagnostic.
[HAVE_DONE_WORKING_REALLOC_CHECK]: Likewise.
Reported by Axel Kittenberger.
2001-01-15 Bruno Haible <haible@clisp.cons.org>
* unicodeio.c (print_unicode_char): Cast the second iconv() arg,
to avoid a warning. Add back 'const' to inptr.
2001-01-16 Jim Meyering <meyering@lucent.com>
* basename.c: Include <stdio.h>, needed by assert on SunOS4.
From Bruno Haible.
2001-01-14 Jim Meyering <meyering@lucent.com>
* rename.c: New file. From Volker Borchert.
Include stdlib.h, string.h or strings.h, and xalloc.h.
Use strip_trailing_slashes rather than open-coding it.
2001-01-03 Paul Eggert <eggert@twinsun.com>
* lib/strftime.c: Sync with glibc time/strftime.c 1.81.
2001-01-03 Jim Meyering <meyering@lucent.com>
* unicodeio.c (print_unicode_char): Remove `const' from declaration of
local `inptr' to avoid warning with some system declarations of iconv.
2000-12-29 Paul Eggert <eggert@twinsun.com>
* lib/modechange.c: Do not assume that mode_t uses the
traditional octal encoding. E.g. "chmod 1 FOO" should set
the other-execute bit of FOO even if S_IXOTH != 1.
(SUID, SGID, SVTX, RUSR, WUSR, XUSR, RGRP, WGRP, XGRP, ROTH,
WOTH, XOTH, ALLM): New macros.
(S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IWUSR, S_IXUSR,
S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH):
Use them.
(S_ISGID): Fix typo; it was defaulting to the same value as S_ISUID.
(S_IRWXU, S_IRWXG, S_IRWXO): Specify defaults in terms of the above.
(mode_compile):
No need to use uintmax_t; unsigned long is long enough.
Don't bother to get suffix since we don't use it.
2000-12-24 Jim Meyering <meyering@lucent.com>
* hash.c (is_prime): Return explicit boolean values.
(hash_get_first): Return NULL to appease Irix5.6's 89.
Reported by Nelson Beebe.
2000-10-31 Bruno Haible <haible@clisp.cons.org>
* localcharset.c (locale_charset): Add support for Win32.
2000-12-18 Paul Eggert <eggert@twinsun.com>
* physmem.h, physmem.c: New files.
* Makefile.am (libfetish_a_SOURCES): Add physmem.c.
(noinst_HEADERS): Add physmem.h.
* xstrtol.c (__xstrtol): Add undocumented suffixes 'g' and
't' for compatibility with Solaris 8 sort.
2000-12-18 Bruno Haible <haible@clisp.cons.org>
* config.charset: Add support for BeOS.
2000-12-16 Jim Meyering <meyering@lucent.com>
* getusershell.c [!SHELLS_FILE && __DJGPP__]: Define
SHELLS_FILE to a file name that's useful on djgpp systems.
Include stdlib.h.
(ADDITIONAL_DEFAULT_SHELLS): Define.
(default_shells): Prepend ADDITIONAL_DEFAULT_SHELLS.
Based mostly on a patch from Prashant TR.
2000-12-16 Jim Meyering <meyering@lucent.com>
This bug had a serious impact on chown: `chown N:M FILE' (for integer
N and M) would have treated it like `chown N:N FILE'.
* userspec.c (parse_user_spec): Fix typo: s/u/g/.
2000-10-31 Bruno Haible <haible@clisp.cons.org>
* config.charset: Add ISO-8859-3, BIG5HKSCS, GB18030, JOHAB, VISCII,
CP874, CP949, CP950, CP1250, CP1253, CP1254, CP1255, CP1256, CP1257
to the list of canonical encodings. Rename EUC-CN to GB2312.
2000-12-08 Andreas Schwab <schwab@suse.de>
* mbswidth.c (mbsnwidth): Don't loop endlessly when called with an
invalid mulitbyte sequence and with the MBSW_ACCEPT_INVALID flag set.
2000-12-07 Jim Meyering <meyering@lucent.com>
* stripslash.c (ISSLASH): Define.
(strip_trailing_slashes): Use ISSLASH rather than comparing against `/'.
From Prashant TR.
* dirname.c (FILESYSTEM_PREFIX_LEN): Define.
(dir_name_r): Declare this function as static.
[BACKSLASH_IS_PATH_SEPARATOR]: Fix a bug that'd
manifest itself on a name containing a mix of slashes and
backslashes.
Make this function work with names starting with a DOS-style
drive letter and colon prefix.
(dir_name): Append `.' if necessary.
Based mostly on patches from Prashant TR and Eli Zaretskii.
* dirname.h (dir_name_r): Remove prototype.
2000-12-05 Jim Meyering <meyering@lucent.com>
* dirname.c (dir_name_r): Add `const' in a few local declarations.
2000-12-04 Jim Meyering <meyering@lucent.com>
* path-concat.c: [!HAVE_DECL_MALLOC]: Declare malloc.
Also include memory.h, stdlib.h, unistd.h if appropriate.
Reported by Andreas Jaeger (conflicting declaration of malloc).
2000-12-02 Jim Meyering <meyering@lucent.com>
* closeout.h: Make idempotent, to avoid some obscure warnings.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* lib/memrchr.c: Include <config.h> before any system include file.
2000-11-29 Paul Eggert <eggert@twinsun.com>
* lib/dirname.c (dir_name_r): Fix typo: int -> size_t.
2000-11-26 Jim Meyering <meyering@lucent.com>
* memcoll.c: Include sys/types.h. From Werner Almesberger.

View File

@@ -13,7 +13,7 @@ libfetish_a_SOURCES = \
full-write.c getopt.c getopt1.c getstr.c getugroups.c hard-locale.c hash.c \
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
makepath.c mbswidth.c md5.c memcasecmp.c memcoll.c modechange.c \
path-concat.c \
path-concat.c physmem.c \
quote.c quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c sha.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
@@ -29,7 +29,8 @@ noinst_HEADERS = \
getstr.h getpagesize.h group-member.h hard-locale.h hash.h human.h lchown.h \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \
path-concat.h pathmax.h posixtm.h quote.h quotearg.h readtokens.h \
path-concat.h pathmax.h physmem.h posixtm.h \
quote.h quotearg.h readtokens.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h sha.h \
strverscmp.h unicodeio.h version-etc.h xalloc.h xstrtod.h xstrtol.h

View File

@@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am
# Makefile.in generated automatically by automake 1.4b from Makefile.am
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
@@ -129,7 +129,7 @@ libfetish_a_SOURCES = \
full-write.c getopt.c getopt1.c getstr.c getugroups.c hard-locale.c hash.c \
human.c idcache.c isdir.c linebuffer.c localcharset.c long-options.c \
makepath.c mbswidth.c md5.c memcasecmp.c memcoll.c modechange.c \
path-concat.c \
path-concat.c physmem.c \
quote.c quotearg.c readtokens.c safe-read.c same.c save-cwd.c \
savedir.c sha.c stripslash.c unicodeio.c userspec.c version-etc.c xgetcwd.c \
xgethostname.c xmalloc.c xstrdup.c xstrtod.c xstrtol.c xstrtoul.c \
@@ -146,7 +146,8 @@ noinst_HEADERS = \
getstr.h getpagesize.h group-member.h hard-locale.h hash.h human.h lchown.h \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \
path-concat.h pathmax.h posixtm.h quote.h quotearg.h readtokens.h \
path-concat.h pathmax.h physmem.h posixtm.h \
quote.h quotearg.h readtokens.h \
readutmp.h regex.h safe-read.h same.h save-cwd.h savedir.h sha.h \
strverscmp.h unicodeio.h version-etc.h xalloc.h xstrtod.h xstrtol.h
@@ -180,11 +181,12 @@ diacrit$U.o dirname$U.o exclude$U.o filemode$U.o full-write$U.o \
getopt$U.o getopt1$U.o getstr$U.o getugroups$U.o hard-locale$U.o \
hash$U.o human$U.o idcache$U.o isdir$U.o linebuffer$U.o \
localcharset$U.o long-options$U.o makepath$U.o mbswidth$U.o md5$U.o \
memcasecmp$U.o memcoll$U.o modechange$U.o path-concat$U.o quote$U.o \
quotearg$U.o readtokens$U.o safe-read$U.o same$U.o save-cwd$U.o \
savedir$U.o sha$U.o stripslash$U.o unicodeio$U.o userspec$U.o \
version-etc$U.o xgetcwd$U.o xgethostname$U.o xmalloc$U.o xstrdup$U.o \
xstrtod$U.o xstrtol$U.o xstrtoul$U.o xstrtoumax$U.o yesno$U.o
memcasecmp$U.o memcoll$U.o modechange$U.o path-concat$U.o physmem$U.o \
quote$U.o quotearg$U.o readtokens$U.o safe-read$U.o same$U.o \
save-cwd$U.o savedir$U.o sha$U.o stripslash$U.o unicodeio$U.o \
userspec$U.o version-etc$U.o xgetcwd$U.o xgethostname$U.o xmalloc$U.o \
xstrdup$U.o xstrtod$U.o xstrtol$U.o xstrtoul$U.o xstrtoumax$U.o \
yesno$U.o
libfetish_a_OBJECTS = $(am_libfetish_a_OBJECTS)
AR = ar
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -217,9 +219,10 @@ $(DEPDIR)/memchr.Po $(DEPDIR)/memcmp.Po $(DEPDIR)/memcoll$U.Po \
$(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po $(DEPDIR)/memrchr.Po \
$(DEPDIR)/memset.Po $(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po \
$(DEPDIR)/mountlist.Po $(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po \
$(DEPDIR)/path-concat$U.Po $(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po \
$(DEPDIR)/quote$U.Po $(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po \
$(DEPDIR)/readutmp.Po $(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po \
$(DEPDIR)/path-concat$U.Po $(DEPDIR)/physmem$U.Po \
$(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po $(DEPDIR)/quote$U.Po \
$(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po $(DEPDIR)/readutmp.Po \
$(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po $(DEPDIR)/rename.Po \
$(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po \
$(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po \
$(DEPDIR)/sha$U.Po $(DEPDIR)/stat.Po $(DEPDIR)/stime.Po \
@@ -240,10 +243,10 @@ error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
getdate.c getgroups.c gethostname.c getline.c getloadavg.c getpass.c \
getusershell.c group-member.c lchown.c malloc.c memchr.c memcmp.c \
memcpy.c memmove.c memrchr.c memset.c mktime.c mountlist.c nanosleep.c \
obstack.c obstack.h putenv.c readutmp.c realloc.c regex.c rmdir.c \
rpmatch.c stime.c stpcpy.c strcasecmp.c strcspn.c strdup.c strftime.c \
strncasecmp.c strndup.c strnlen.c strpbrk.c strstr.c strtod.c strtol.c \
strtoul.c strtoull.c strtoumax.c strverscmp.c utime.c
obstack.c obstack.h putenv.c readutmp.c realloc.c regex.c rename.c \
rmdir.c rpmatch.c stime.c stpcpy.c strcasecmp.c strcspn.c strdup.c \
strftime.c strncasecmp.c strndup.c strnlen.c strpbrk.c strstr.c \
strtod.c strtol.c strtoul.c strtoull.c strtoumax.c strverscmp.c utime.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -254,7 +257,7 @@ OBJECTS = $(am_libfetish_a_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .c .o .sed .sin .y
.SUFFIXES: .sed .sin .c .o .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile
@@ -387,6 +390,8 @@ localcharset_.c: localcharset.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/localcharset.c; then echo $(srcdir)/localcharset.c; else echo localcharset.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > localcharset_.c
long-options_.c: long-options.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/long-options.c; then echo $(srcdir)/long-options.c; else echo long-options.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > long-options_.c
lstat_.c: lstat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/lstat.c; then echo $(srcdir)/lstat.c; else echo lstat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > lstat_.c
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)
@@ -423,6 +428,8 @@ obstack_.c: obstack.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/obstack.c; then echo $(srcdir)/obstack.c; else echo obstack.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > obstack_.c
path-concat_.c: path-concat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/path-concat.c; then echo $(srcdir)/path-concat.c; else echo path-concat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > path-concat_.c
physmem_.c: physmem.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/physmem.c; then echo $(srcdir)/physmem.c; else echo physmem.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > physmem_.c
posixtm_.c: posixtm.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/posixtm.c; then echo $(srcdir)/posixtm.c; else echo posixtm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > posixtm_.c
putenv_.c: putenv.c $(ANSI2KNR)
@@ -439,6 +446,8 @@ realloc_.c: realloc.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/realloc.c; then echo $(srcdir)/realloc.c; else echo realloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > realloc_.c
regex_.c: regex.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/regex.c; then echo $(srcdir)/regex.c; else echo regex.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > regex_.c
rename_.c: rename.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/rename.c; then echo $(srcdir)/rename.c; else echo rename.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > rename_.c
rmdir_.c: rmdir.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/rmdir.c; then echo $(srcdir)/rmdir.c; else echo rmdir.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > rmdir_.c
rpmatch_.c: rpmatch.c $(ANSI2KNR)
@@ -453,6 +462,8 @@ savedir_.c: savedir.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/savedir.c; then echo $(srcdir)/savedir.c; else echo savedir.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > savedir_.c
sha_.c: sha.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sha.c; then echo $(srcdir)/sha.c; else echo sha.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > sha_.c
stat_.c: stat.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stat.c; then echo $(srcdir)/stat.c; else echo stat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stat_.c
stime_.c: stime.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stime.c; then echo $(srcdir)/stime.c; else echo stime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stime_.c
stpcpy_.c: stpcpy.c $(ANSI2KNR)
@@ -522,19 +533,19 @@ fnmatch_.o fsusage_.o ftruncate_.o full-write_.o getdate_.o \
getgroups_.o gethostname_.o getline_.o getloadavg_.o getopt_.o \
getopt1_.o getpass_.o getstr_.o getugroups_.o getusershell_.o \
group-member_.o hard-locale_.o hash_.o human_.o idcache_.o isdir_.o \
lchown_.o linebuffer_.o localcharset_.o long-options_.o makepath_.o \
malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o memcmp_.o \
memcoll_.o memcpy_.o memmove_.o memrchr_.o memset_.o mktime_.o \
modechange_.o mountlist_.o nanosleep_.o obstack_.o path-concat_.o \
posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o readutmp_.o \
realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o same_.o \
save-cwd_.o savedir_.o sha_.o stime_.o stpcpy_.o strcasecmp_.o \
strcspn_.o strdup_.o strftime_.o stripslash_.o strncasecmp_.o \
strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o strtol_.o \
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o \
userspec_.o utime_.o version-etc_.o xgetcwd_.o xgethostname_.o \
xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
yesno_.o : $(ANSI2KNR)
lchown_.o linebuffer_.o localcharset_.o long-options_.o lstat_.o \
makepath_.o malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o \
memcmp_.o memcoll_.o memcpy_.o memmove_.o memrchr_.o memset_.o \
mktime_.o modechange_.o mountlist_.o nanosleep_.o obstack_.o \
path-concat_.o physmem_.o posixtm_.o putenv_.o quote_.o quotearg_.o \
readtokens_.o readutmp_.o realloc_.o regex_.o rename_.o rmdir_.o \
rpmatch_.o safe-read_.o same_.o save-cwd_.o savedir_.o sha_.o stat_.o \
stime_.o stpcpy_.o strcasecmp_.o strcspn_.o strdup_.o strftime_.o \
stripslash_.o strncasecmp_.o strndup_.o strnlen_.o strpbrk_.o strstr_.o \
strtod_.o strtol_.o strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o \
unicodeio_.o userspec_.o utime_.o version-etc_.o xgetcwd_.o \
xgethostname_.o xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o \
xstrtoumax_.o yesno_.o : $(ANSI2KNR)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
@@ -566,6 +577,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
GTAGS:
here=`CDPATH=: && cd $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $$here
mostlyclean-tags:
clean-tags:
@@ -637,6 +653,7 @@ maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/nanosleep.Po
@AMDEP@include $(DEPDIR)/obstack.Po
@AMDEP@include $(DEPDIR)/path-concat$U.Po
@AMDEP@include $(DEPDIR)/physmem$U.Po
@AMDEP@include $(DEPDIR)/posixtm$U.Po
@AMDEP@include $(DEPDIR)/putenv.Po
@AMDEP@include $(DEPDIR)/quote$U.Po
@@ -645,6 +662,7 @@ maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/readutmp.Po
@AMDEP@include $(DEPDIR)/realloc.Po
@AMDEP@include $(DEPDIR)/regex.Po
@AMDEP@include $(DEPDIR)/rename.Po
@AMDEP@include $(DEPDIR)/rmdir.Po
@AMDEP@include $(DEPDIR)/rpmatch.Po
@AMDEP@include $(DEPDIR)/safe-read$U.Po
@@ -725,6 +743,9 @@ check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am: install-exec-local
install-exec: install-exec-am
@@ -789,12 +810,12 @@ maintainer-clean-compile mostlyclean-kr distclean-kr clean-kr \
maintainer-clean-kr tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-local install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-local uninstall-am uninstall all-local all-redirect all-am \
all install-strip installdirs mostlyclean-generic distclean-generic \
clean-generic maintainer-clean-generic clean mostlyclean distclean \
maintainer-clean
installcheck-am installcheck all-recursive-am install-exec-local \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-local uninstall-am uninstall all-local all-redirect \
all-am all install-strip installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
lstat.c: xstat.in
sed \

View File

@@ -88,6 +88,7 @@ typedef char *pointer;
Callers below should use malloc. */
# ifndef emacs
# undef malloc
# define malloc xmalloc
# endif
extern pointer malloc ();

View File

@@ -1,5 +1,5 @@
/* basename.c -- return the last element in a path
Copyright (C) 1990, 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1990, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
# include <config.h>
#endif
#include <stdio.h>
#include <assert.h>
#ifndef FILESYSTEM_PREFIX_LEN

View File

@@ -1,12 +1,17 @@
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
#ifndef CLOSEOUT_H
# define CLOSEOUT_H 1
# ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
# endif
#endif
void close_stdout_set_status PARAMS ((int status));
void close_stdout_set_file_name PARAMS ((const char *file));
void close_stdout PARAMS ((void));
void close_stdout_status PARAMS ((int status));
#endif

View File

@@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000 Free Software Foundation, Inc.
# Copyright (C) 2000-2001 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
@@ -34,6 +34,7 @@
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd
# ISO-8859-1 glibc aix hpux irix osf solaris freebsd yes
# ISO-8859-2 glibc aix hpux irix solaris freebsd yes
# ISO-8859-3 glibc yes
# ISO-8859-4 solaris yes
# ISO-8859-5 glibc aix hpux irix solaris yes
# ISO-8859-6 glibc aix hpux solaris yes
@@ -41,28 +42,41 @@
# ISO-8859-8 glibc aix hpux solaris yes
# ISO-8859-9 glibc aix hpux irix osf solaris yes
# ISO-8859-13 glibc
# ISO-8859-15 aix solaris freebsd
# ISO-8859-15 glibc aix solaris freebsd
# KOI8-R glibc solaris freebsd yes
# KOI8-U glibc yes
# CP850 aix osf
# CP856 aix
# CP866 freebsd
# CP874 win32
# CP922 aix
# CP932 aix
# CP932 aix win32
# CP943 aix
# CP949 win32
# CP950 win32
# CP1046 aix
# CP1124 aix
# CP1129 aix
# CP1251 glibc
# CP1252 aix
# EUC-CN aix hpux irix solaris
# EUC-JP aix hpux irix solaris yes
# EUC-KR aix hpux irix solaris yes
# EUC-TW aix hpux irix solaris
# BIG5 aix hpux solaris yes
# GBK aix
# CP1250 win32
# CP1251 glibc win32
# CP1252 aix win32
# CP1253 win32
# CP1254 win32
# CP1255 win32
# CP1256 win32
# CP1257 win32
# GB2312 glibc aix hpux irix solaris yes
# EUC-JP glibc aix hpux irix solaris yes
# EUC-KR glibc aix hpux irix solaris yes
# EUC-TW glibc aix hpux irix solaris
# BIG5 glibc aix hpux solaris yes
# BIG5HKSCS glibc
# GBK aix win32
# GB18030 glibc
# SJIS hpux solaris
# TIS-620 aix hpux solaris
# JOHAB glibc win32
# TIS-620 glibc aix hpux solaris
# VISCII glibc yes
# HP-ROMAN8 hpux
# HP-ARABIC8 hpux
# HP-GREEK8 hpux
@@ -117,7 +131,7 @@ case "$os" in
echo "IBM-1124 CP1124"
echo "IBM-1129 CP1129"
echo "IBM-1252 CP1252"
echo "IBM-eucCN EUC-CN"
echo "IBM-eucCN GB2312"
echo "IBM-eucJP EUC-JP"
echo "IBM-eucKR EUC-KR"
echo "IBM-eucTW EUC-TW"
@@ -146,7 +160,7 @@ case "$os" in
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "hp15CN EUC-CN"
echo "hp15CN GB2312"
#echo "ccdc ?" # what is this?
echo "SJIS SJIS"
echo "utf8 UTF-8"
@@ -157,7 +171,7 @@ case "$os" in
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-9 ISO-8859-9"
echo "eucCN EUC-CN"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
@@ -181,7 +195,7 @@ case "$os" in
echo "ISO8859-15 ISO-8859-15"
echo "koi8-r KOI8-R"
echo "BIG5 BIG5"
echo "gb2312 EUC-CN"
echo "gb2312 GB2312"
echo "cns11643 EUC-TW"
echo "5601 EUC-KR"
echo "eucJP EUC-JP"
@@ -191,26 +205,42 @@ case "$os" in
echo "UTF-8 UTF-8"
;;
freebsd*)
# FreeBSD 3.3 doesn't have nl_langinfo(CODESET); therefore
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in lt_LN; do
for l in la_LN lt_LN; do
echo "$l.ASCII ASCII"
done
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT lt_LN \
nl_BE nl_NL no_NO pt_PT sv_SE; do
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
echo "$l.ISO_8859-1 ISO-8859-1"
echo "$l.DIS_8859-15 ISO-8859-15"
done
for l in hr_HR hu_HU lt_LN pl_PL sl_SI; do
for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
echo "$l.ISO_8859-2 ISO-8859-2"
done
for l in la_LN lt_LT; do
echo "$l.ISO_8859-4 ISO-8859-4"
done
for l in ru_RU ru_SU; do
echo "$l.KOI8-R KOI8-R"
echo "$l.ISO_8859-5 ISO-8859-5"
echo "$l.CP866 CP866"
done
echo "uk_UA.KOI8-U KOI8-U"
echo "zh_TW.BIG5 BIG5"
echo "zh_TW.Big5 BIG5"
echo "zh_CN.EUC GB2312"
echo "ja_JP.EUC EUC-JP"
echo "ja_JP.SJIS SJIS"
echo "ja_JP.Shift_JIS SJIS"
echo "ko_KR.EUC EUC-KR"
;;
beos*)
# BeOS has a single locale, and it has UTF-8 encoding.
echo "C UTF-8"
;;
esac

View File

@@ -43,26 +43,32 @@ void *memrchr ();
#include "dirname.h"
#ifndef FILESYSTEM_PREFIX_LEN
# define FILESYSTEM_PREFIX_LEN(Filename) 0
#endif
#ifndef ISSLASH
# define ISSLASH(C) ((C) == '/')
#endif
#define BACKSLASH_IS_PATH_SEPARATOR ISSLASH ('\\')
/* Return the length of `dirname (PATH)' and set *RESULT
to point to PATH or to `"."', as appropriate.
Works properly even if there are trailing slashes
(by effectively ignoring them). */
size_t
dir_name_r (const char *path, const char **result)
/* Return the length of `dirname (PATH)' and set *RESULT to point
to PATH or to `"."', as appropriate. Works properly even if
there are trailing slashes (by effectively ignoring them).
WARNING: This function doesn't work for cwd-relative names like
`a:foo' that are specified with a drive-letter prefix. That case
is handled in the caller. */
static size_t
dir_name_r (char const *path, char const **result)
{
char *slash;
int length; /* Length of result, not including NUL. */
char const *slash;
size_t length; /* Length of result, not including NUL. */
slash = strrchr (path, '/');
if (BACKSLASH_IS_PATH_SEPARATOR)
{
char *b = strrchr (path, '\\');
char const *b = strrchr (path, '\\');
if (b && slash < b)
slash = b;
}
@@ -78,10 +84,11 @@ dir_name_r (const char *path, const char **result)
if (path < slash)
{
slash = memrchr (path, '/', slash - path);
size_t len = slash - path;
slash = memrchr (path, '/', len);
if (BACKSLASH_IS_PATH_SEPARATOR)
{
char *b = memrchr (path, '\\', slash - path);
char const *b = memrchr (path, '\\', len);
if (b && slash < b)
slash = b;
}
@@ -91,27 +98,23 @@ dir_name_r (const char *path, const char **result)
if (slash == 0)
{
/* File is in the current directory. */
path = ".";
length = 1;
length = FILESYSTEM_PREFIX_LEN (path);
if (length == 0)
{
path = ".";
length = 1;
}
}
else
{
/* Remove any trailing slashes from the result. */
if (BACKSLASH_IS_PATH_SEPARATOR)
{
const char *lim = ((path[0] >= 'A' && path[0] <= 'z'
&& path[1] == ':')
? path + 2 : path);
/* Remove any trailing slashes from the result. If we have a
canonicalized "d:/path", leave alone the root case "d:/". */
char const *lim = path + FILESYSTEM_PREFIX_LEN (path);
/* If canonicalized "d:/path", leave alone the root case "d:/". */
while (slash > lim && ISSLASH (*slash))
--slash;
}
else
{
while (slash > path && ISSLASH (*slash))
--slash;
}
while (lim < slash && ISSLASH (*slash))
--slash;
length = slash - path + 1;
}
@@ -126,14 +129,18 @@ dir_name_r (const char *path, const char **result)
(by effectively ignoring them). */
char *
dir_name (const char *path)
dir_name (char const *path)
{
const char *result;
char const *result;
size_t length = dir_name_r (path, &result);
char *newpath = (char *) malloc (length + 1);
int append_dot = (length && length == FILESYSTEM_PREFIX_LEN (newpath));
char *newpath = (char *) malloc (length + append_dot + 1);
if (newpath == 0)
return 0;
strncpy (newpath, result, length);
/* If PATH is "d:foo", return "d:.", the CWD on drive d: */
if (append_dot)
newpath[length++] = '.';
newpath[length] = 0;
return newpath;
}
@@ -170,7 +177,7 @@ main ()
{
char path[MAX_BUFF_LEN];
char expected_result[MAX_BUFF_LEN];
char *result;
char const *result;
sscanf (buff, "%s %s", path, expected_result);
result = dir_name (path);
if (strcmp (result, expected_result))

View File

@@ -28,7 +28,4 @@
char *
dir_name PARAMS ((const char *path));
size_t
dir_name_r PARAMS ((const char *path, const char **result));
#endif /* not DIRNAME_H_ */

View File

@@ -22,11 +22,19 @@
#endif
#ifndef SHELLS_FILE
# ifndef __DJGPP__
/* File containing a list of nonrestricted shells, one per line. */
# define SHELLS_FILE "/etc/shells"
# define SHELLS_FILE "/etc/shells"
# else
/* This is a horrible kludge. Isn't there a better way? */
# define SHELLS_FILE "/dev/env/DJDIR/etc/shells"
# endif
#endif
#include <stdio.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <ctype.h>
#include "xalloc.h"
@@ -40,9 +48,17 @@
static int readname ();
#if ! defined ADDITIONAL_DEFAULT_SHELLS && defined __MSDOS__
# define ADDITIONAL_DEFAULT_SHELLS \
"c:/dos/command.com", "c:/windows/command.com", "c:/command.com",
#else
# define ADDITIONAL_DEFAULT_SHELLS /* empty */
#endif
/* List of shells to use if the shells file is missing. */
static char const* const default_shells[] =
{
ADDITIONAL_DEFAULT_SHELLS
"/bin/sh", "/bin/csh", "/usr/bin/sh", "/usr/bin/csh", NULL
};

View File

@@ -1,5 +1,5 @@
/* hash - hashing table processing.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Written by Jim Meyering, 1992.
This program is free software; you can redistribute it and/or modify
@@ -263,6 +263,7 @@ hash_get_first (const Hash_table *table)
return bucket->data;
assert (0);
return NULL;
}
/* Return the user data for the entry following ENTRY, where ENTRY has been
@@ -422,7 +423,7 @@ is_prime (unsigned long candidate)
divisor++;
}
return candidate % divisor != 0;
return (candidate % divisor ? true : false);
}
/* Round a given CANDIDATE number up to the nearest prime, and return that

View File

@@ -37,12 +37,22 @@
# include <stdlib.h>
#endif
#if HAVE_LANGINFO_CODESET
# include <langinfo.h>
#else
# if HAVE_SETLOCALE
# include <locale.h>
#if defined _WIN32 || defined __WIN32__
# undef WIN32 /* avoid warning on mingw32 */
# define WIN32
#endif
#ifndef WIN32
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
# if HAVE_SETLOCALE
# include <locale.h>
# endif
# endif
#else /* WIN32 */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
#ifndef DIRECTORY_SEPARATOR
@@ -73,6 +83,7 @@ get_charset_aliases ()
cp = charset_aliases;
if (cp == NULL)
{
#ifndef WIN32
FILE *fp;
const char *dir = LIBDIR;
const char *base = "charset.alias";
@@ -157,9 +168,20 @@ get_charset_aliases ()
}
}
charset_aliases = cp;
if (file_name != NULL)
free (file_name);
#else /* WIN32 */
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
cp = "CP936" "\0" "GBK" "\0"
"CP1361" "\0" "JOHAB" "\0";
#endif
charset_aliases = cp;
}
return cp;
@@ -180,19 +202,21 @@ locale_charset ()
const char *codeset;
const char *aliases;
#if HAVE_LANGINFO_CODESET
#ifndef WIN32
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
#else
# else
/* On old systems which lack it, use setlocale and getenv. */
const char *locale = NULL;
# if HAVE_SETLOCALE
# if HAVE_SETLOCALE
locale = setlocale (LC_CTYPE, NULL);
# endif
# endif
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_ALL");
@@ -209,6 +233,16 @@ locale_charset ()
through the charset.alias file. */
codeset = locale;
# endif
#else /* WIN32 */
static char buf[2 + 10 + 1];
/* Win32 has a function returning the locale's codepage as a number. */
sprintf (buf, "CP%u", GetACP ());
codeset = buf;
#endif
if (codeset != NULL && codeset[0] != '\0')

View File

@@ -51,12 +51,6 @@
# define iswprint(wc) 1
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HAVE_MBRTOWC && defined mbstate_t
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbsinit(ps) 1
#endif
#ifndef HAVE_DECL_WCWIDTH
"this configure-time declaration test was not run"
#endif
@@ -153,7 +147,11 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
/* An invalid multibyte sequence was encountered. */
{
if (flags & MBSW_ACCEPT_INVALID)
break;
{
p++;
width++;
break;
}
else
return -1;
}
@@ -162,7 +160,11 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
/* An incomplete multibyte character at the end. */
{
if (flags & MBSW_ACCEPT_INVALID)
break;
{
p = plimit;
width++;
break;
}
else
return -1;
}

View File

@@ -1,5 +1,5 @@
/* Determine the number of screen columns needed for a string.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
#define MBSW_ACCEPT_UNPRINTABLE 2
/* Returns the number of screen columns needed for STRING. */
#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
extern int mbswidth PARAMS ((const char *string, int flags));
/* Returns the number of screen columns needed for the NBYTES bytes

View File

@@ -145,7 +145,7 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
/* The following is from gnupg-1.0.2's cipher/bithelp.h. */
/* Rotate a 32 bit integer by n bytes */
#if defined(__GNUC__) && defined(__i386__)
#if defined __GNUC__ && defined __i386__
static inline md5_uint32
rol(md5_uint32 x, int n)
{

View File

@@ -21,12 +21,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#undef __ptr_t
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
# define __ptr_t void *

View File

@@ -1,5 +1,5 @@
/* modechange.c -- file mode manipulation
Copyright (C) 1989, 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1989, 1990, 1997, 1998, 1999, 2001 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
@@ -50,50 +50,65 @@ char *malloc ();
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
/* The traditional octal values corresponding to each mode bit. */
#define SUID 04000
#define SGID 02000
#define SVTX 01000
#define RUSR 00400
#define WUSR 00200
#define XUSR 00100
#define RGRP 00040
#define WGRP 00020
#define XGRP 00010
#define ROTH 00004
#define WOTH 00002
#define XOTH 00001
#define ALLM 07777 /* all octal mode bits */
#ifndef S_ISUID
# define S_ISUID 04000
# define S_ISUID SUID
#endif
#ifndef S_ISGID
# define S_ISGID 04000
# define S_ISGID SGID
#endif
#ifndef S_ISVTX
# define S_ISVTX 01000
# define S_ISVTX SVTX
#endif
#ifndef S_IRUSR
# define S_IRUSR 0400
# define S_IRUSR RUSR
#endif
#ifndef S_IWUSR
# define S_IWUSR 0200
# define S_IWUSR WUSR
#endif
#ifndef S_IXUSR
# define S_IXUSR 0100
# define S_IXUSR XUSR
#endif
#ifndef S_IRGRP
# define S_IRGRP 0040
# define S_IRGRP RGRP
#endif
#ifndef S_IWGRP
# define S_IWGRP 0020
# define S_IWGRP WGRP
#endif
#ifndef S_IXGRP
# define S_IXGRP 0010
# define S_IXGRP XGRP
#endif
#ifndef S_IROTH
# define S_IROTH 0004
# define S_IROTH ROTH
#endif
#ifndef S_IWOTH
# define S_IWOTH 0002
# define S_IWOTH WOTH
#endif
#ifndef S_IXOTH
# define S_IXOTH 0001
# define S_IXOTH XOTH
#endif
#ifndef S_IRWXU
# define S_IRWXU 0700
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif
#ifndef S_IRWXG
# define S_IRWXG 0070
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif
#ifndef S_IRWXO
# define S_IRWXO 0007
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif
/* All the mode bits that can be affected by chmod. */
@@ -157,8 +172,7 @@ 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. */
uintmax_t mode_value; /* The mode value, if octal. */
char *string_end; /* Pointer to end of parsed value. */
unsigned long octal_value; /* The mode value, if octal. */
mode_t umask_value; /* The umask value (surprise). */
head = NULL;
@@ -166,12 +180,34 @@ mode_compile (const char *mode_string, unsigned int masked_ops)
tail = NULL;
#endif
if (xstrtoumax (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK)
if (xstrtoul (mode_string, NULL, 8, &octal_value, "") == LONGINT_OK)
{
struct mode_change *p;
if (mode_value != (mode_value & CHMOD_MODE_BITS))
mode_t mode;
if (octal_value != (octal_value & ALLM))
return MODE_INVALID;
p = make_node_op_equals ((mode_t) mode_value);
/* Help the compiler optimize the usual case where mode_t uses
the traditional octal representation. */
mode = ((S_ISUID == SUID && S_ISGID == SGID && S_ISVTX == SVTX
&& S_IRUSR == RUSR && S_IWUSR == WUSR && S_IXUSR == XUSR
&& S_IRGRP == RGRP && S_IWGRP == WGRP && S_IXGRP == XGRP
&& S_IROTH == ROTH && S_IWOTH == WOTH && S_IXOTH == XOTH)
? octal_value
: ((octal_value & SUID ? S_ISUID : 0)
| (octal_value & SGID ? S_ISGID : 0)
| (octal_value & SVTX ? S_ISVTX : 0)
| (octal_value & RUSR ? S_IRUSR : 0)
| (octal_value & WUSR ? S_IWUSR : 0)
| (octal_value & XUSR ? S_IXUSR : 0)
| (octal_value & RGRP ? S_IRGRP : 0)
| (octal_value & WGRP ? S_IWGRP : 0)
| (octal_value & XGRP ? S_IXGRP : 0)
| (octal_value & ROTH ? S_IROTH : 0)
| (octal_value & WOTH ? S_IWOTH : 0)
| (octal_value & XOTH ? S_IXOTH : 0)));
p = make_node_op_equals (mode);
if (p == NULL)
return MODE_MEMORY_EXHAUSTED;
mode_append_entry (&head, &tail, p);
@@ -393,7 +429,7 @@ mode_adjust (mode_t oldmode, const struct mode_change *changes)
/* In order to change only `u', `g', or `o' permissions,
or some combination thereof, clear unselected bits.
This can not be done in mode_compile because the value
This cannot be done in mode_compile because the value
to which the `changes->affected' mask is applied depends
on the old mode of each file. */
value &= changes->affected;

View File

@@ -26,12 +26,31 @@
#endif
#include <stdio.h>
#if HAVE_STRING_H
# include <string.h>
#endif
#include <sys/types.h>
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#else
# if HAVE_STRINGS_H
# include <strings.h>
# endif
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifndef HAVE_DECL_MALLOC
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_MALLOC
char *malloc ();
#endif
#ifndef strdup
char *strdup ();
#endif

58
lib/physmem.c Normal file
View File

@@ -0,0 +1,58 @@
/* Calculate the size of physical memory.
Copyright 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Paul Eggert. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "physmem.h"
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Return the total amount of physical memory. */
double
physmem_total (void)
{
#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
double pages = sysconf (_SC_PHYS_PAGES);
double pagesize = sysconf (_SC_PAGESIZE);
if (0 <= pages && 0 <= pagesize)
return pages * pagesize;
#endif
/* Guess 64 MB. It's probably an older host, so guess small. */
return 64 * 1024 * 1024;
}
/* Return the amount of physical memory available. */
double
physmem_available (void)
{
#if defined _SC_AVPHYS_PAGES && defined _SC_PAGESIZE
double pages = sysconf (_SC_AVPHYS_PAGES);
double pagesize = sysconf (_SC_PAGESIZE);
if (0 <= pages && 0 <= pagesize)
return pages * pagesize;
#endif
/* Guess 25% of physical memory. */
return physmem_total () / 4;
}

19
lib/physmem.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef PHYSMEM_H_
# define PHYSMEM_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
double physmem_total PARAMS ((void));
double physmem_available PARAMS ((void));
#endif /* PHYSMEM_H_ */

View File

@@ -4,6 +4,9 @@
# include <config.h>
#endif
#if HAVE_STDDEF_H
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
#endif
#include <sys/types.h>
#include <quotearg.h>
#include <quote.h>

View File

@@ -1,5 +1,5 @@
/* quotearg.c - quote arguments for output
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001 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,9 @@
# include <config.h>
#endif
#if HAVE_STDDEF_H
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
#endif
#include <sys/types.h>
#include <quotearg.h>
#include <xalloc.h>
@@ -63,13 +66,7 @@
# include <wchar.h>
#endif
#if HAVE_MBRTOWC
size_t mbrtowc ();
# ifdef mbstate_t
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbsinit(ps) 1
# endif
#else
#if !HAVE_MBRTOWC
/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the
other macros are defined only for documentation and to satisfy C
syntax. */

File diff suppressed because it is too large Load Diff

68
lib/rename.c Normal file
View File

@@ -0,0 +1,68 @@
/* Work around the bug in some systems whereby rename fails when the source
path has a trailing slash. The rename from SunOS 4.1.1_U1 has this bug.
Copyright (C) 2001 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 Volker Borchert */
#include <config.h>
#include <stdio.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#include <xalloc.h>
#ifndef HAVE_DECL_FREE
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_FREE
void free ();
#endif
void strip_trailing_slashes ();
/* Rename the file SRC_PATH to DST_PATH, removing any trailing
slashes from SRC_PATH. Needed for SunOS 4.1.1_U1. */
int
rpl_rename (const char *src_path, const char *dst_path)
{
char *src_temp;
int ret_val;
size_t s_len = strlen (src_path);
if (s_len && src_path[s_len - 1] == '/')
{
src_temp = xstrdup (src_path);
strip_trailing_slashes (src_temp);
}
else
src_temp = (char *) src_path;
ret_val = rename (src_temp, dst_path);
if (src_temp != src_path)
free (src_temp);
return ret_val;
}

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
/* Copyright (C) 1991-1999, 2000, 2001 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.
@@ -289,7 +289,7 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */
else if (to_uppcase) \
memcpy_uppcase (p, (s), _n); \
else \
MEMCPY ((PTR) p, (PTR) (s), _n))
MEMCPY ((PTR) p, (const PTR) (s), _n))
#ifdef COMPILE_WIDE
# define widen(os, ws, l) \
@@ -793,10 +793,11 @@ my_strftime (s, maxsize, format, tp ut_argument)
goto bad_format;
#ifdef _NL_CURRENT
if (! (modifier == 'E'
&& (*(subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME,
NLW(ERA_D_T_FMT)))
&& (*(subfmt =
(const CHAR_T *) _NL_CURRENT (LC_TIME,
NLW(ERA_D_T_FMT)))
!= '\0')))
subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
#else
# if HAVE_STRFTIME
goto underlying_strftime;
@@ -887,10 +888,10 @@ my_strftime (s, maxsize, format, tp ut_argument)
goto bad_format;
#ifdef _NL_CURRENT
if (! (modifier == L_('E')
&& (*(subfmt = (CHAR_T *)_NL_CURRENT (LC_TIME,
NLW(ERA_D_FMT)))
&& (*(subfmt =
(const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT)))
!= L_('\0'))))
subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
goto subformat;
#else
# if HAVE_STRFTIME
@@ -1067,14 +1068,15 @@ my_strftime (s, maxsize, format, tp ut_argument)
goto underlying_strftime;
#endif
case L_('R'): /* GNU extension. */
case L_('R'): /* ISO C99 extension. */
subfmt = L_("%H:%M");
goto subformat;
case L_('r'): /* POSIX.2 extension. */
#ifdef _NL_CURRENT
if (*(subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME,
NLW(T_FMT_AMPM))) == L_('\0'))
if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME,
NLW(T_FMT_AMPM)))
== L_('\0'))
#endif
subfmt = L_("%I:%M:%S %p");
goto subformat;
@@ -1129,10 +1131,10 @@ my_strftime (s, maxsize, format, tp ut_argument)
goto bad_format;
#ifdef _NL_CURRENT
if (! (modifier == L_('E')
&& (*(subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME,
NLW(ERA_T_FMT)))
&& (*(subfmt =
(const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT)))
!= L_('\0'))))
subfmt = (CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT));
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT));
goto subformat;
#else
# if HAVE_STRFTIME
@@ -1159,8 +1161,8 @@ my_strftime (s, maxsize, format, tp ut_argument)
DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7);
case L_('V'):
case L_('g'): /* GNU extension. */
case L_('G'): /* GNU extension. */
case L_('g'): /* ISO C99 extension. */
case L_('G'): /* ISO C99 extension. */
if (modifier == L_('E'))
goto bad_format;
{
@@ -1284,7 +1286,7 @@ my_strftime (s, maxsize, format, tp ut_argument)
#endif
break;
case L_('z'): /* GNU extension. */
case L_('z'): /* ISO C99 extension. */
if (tp->tm_isdst < 0)
break;

View File

@@ -19,12 +19,16 @@
# include <config.h>
#endif
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
#if STDC_HEADERS || HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#ifndef ISSLASH
# define ISSLASH(C) ((C) == '/')
#endif
/* Remove trailing slashes from PATH.
This is useful when using filename completion from a shell that
adds a "/" after directory names (such as tcsh and bash), because
@@ -37,6 +41,6 @@ strip_trailing_slashes (char *path)
int last;
last = strlen (path) - 1;
while (last > 0 && path[last] == '/')
while (0 < last && ISSLASH (path[last]))
path[last--] = '\0';
}

View File

@@ -1,5 +1,5 @@
/* Find the length of STRING, but scan at most MAXLEN characters.
Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -51,7 +51,7 @@ size_t
__strnlen (const char *string, size_t maxlen)
{
const char *end = memchr (string, '\0', maxlen);
return end ? end - string : maxlen;
return end ? (size_t) (end - string) : maxlen;
}
#ifdef weak_alias
weak_alias (__strnlen, strnlen)

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1999 Free Software Foundation, Inc.
/* Copyright (C) 1991, 1999, 2001 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.
@@ -19,4 +19,4 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define UNSIGNED 1
#include <strtol.c>
#include "strtol.c"

View File

@@ -170,7 +170,9 @@ print_unicode_char (FILE *stream, unsigned int code)
outbytesleft = sizeof (outbuf);
/* Convert the character from UTF-8 to the locale's charset. */
res = iconv (utf8_to_local, &inptr, &inbytesleft, &outptr, &outbytesleft);
res = iconv (utf8_to_local,
(ICONV_CONST char **)&inptr, &inbytesleft,
&outptr, &outbytesleft);
if (inbytesleft > 0 || res == (size_t)(-1)
/* Irix iconv() inserts a NUL byte if it cannot convert. */
# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)

View File

@@ -163,8 +163,8 @@ is_number (const char *str)
use the given user's login group.
If SPEC_ARG contains a `:', then use that as the separator, ignoring
any `.'s. If there is no `:', but there is a `.', then first look
up SPEC_ARG as a login name. If that look-up fails, then try again
interpreting the `.' as a separator.
up the entire SPEC_ARG as a login name. If that look-up fails, then
try again interpreting the `.' as a separator.
USERNAME and GROUPNAME will be in newly malloc'd memory.
Either one might be NULL instead, indicating that it was not
@@ -304,7 +304,7 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
else
{
unsigned long int tmp_long;
if (xstrtoul (u, NULL, 0, &tmp_long, NULL) != LONGINT_OK
if (xstrtoul (g, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long > MAXGID)
return _(E_invalid_group);
*gid = tmp_long;

View File

@@ -47,11 +47,11 @@ void free ();
#endif
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
you must run the autoconf test for a properly working malloc -- see malloc.m4
"you must run the autoconf test for a properly working malloc -- see malloc.m4"
#endif
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
you must run the autoconf test for a properly working realloc -- see realloc.m4
"you must run the autoconf test for a properly working realloc --see realloc.m4"
#endif
/* Exit value when the requested amount of memory is not available.

View File

@@ -199,6 +199,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
break;
case 'G': /* Giga */
case 'g': /* 'g' is undocumented; for compatibility only */
overflow = bkm_scale_by_power (&tmp, base, 3);
break;
@@ -207,7 +208,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
break;
case 'M': /* Mega */
case 'm': /* 'm' is undocumented; for backward compatibility only */
case 'm': /* 'm' is undocumented; for compatibility only */
overflow = bkm_scale_by_power (&tmp, base, 2);
break;
@@ -216,6 +217,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
break;
case 'T': /* Tera */
case 't': /* 't' is undocumented; for compatibility only */
overflow = bkm_scale_by_power (&tmp, base, 4);
break;

View File

@@ -1,3 +1,154 @@
2001-02-17 Jim Meyering <meyering@lucent.com>
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Don't check for
getmntent via AC_CHECK_FUNCS, since that would get a `no' and disrupt
further attempts by AC_FUNC_GETMNTENT to check with e.g., -lgen on
UnixWare 7.1.1.
* mbrtowc.m4 (jm_FUNC_MBRTOWC): Adapt to use AC_CACHE_CHECK etc.,
rather than AC_CACHE_VAL.
2001-02-17 Paul Eggert <eggert@twinsun.com>
* mbrtowc.m4: New file, defining jm_FUNC_MBRTOWC.
* mbswidth.m4 (jm_PREREQ_MBSWIDTH):
Use jm_FUNC_MBRTOWC, not AC_CHECK_FUNCS(mbrtowc).
* prereq.m4 (jm_PREREQ_QUOTEARG): Likewise.
2001-02-07 Jim Meyering <meyering@lucent.com>
* regex.m4 (jm_INCLUDED_REGEX): Add a test for the latest bug.
2001-02-05 Jim Meyering <meyering@lucent.com>
* jm-macros.m4: Require autoconf-2.14d (not yet released), because
it includes the patch required for `large file' support with at least
HP-UX's 10.20 /bin/cc.
2001-02-03 Jim Meyering <meyering@lucent.com>
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Restore prior use of
AS_IF, now that it works once again (mysteriously).
* fsusage.m4 (jm_FILE_SYSTEM_USAGE): Likewise.
2001-01-30 Jim Meyering <meyering@lucent.com>
Don't use filenames that are 8.3-equivalent to "conftest" on DOS.
* chown.m4: Rename conftestchown to conftest.chown.
* rename.m4: s/conftestdir/conftest.d1/ and s/conftestdir2/conftest.d2/.
* utimes.m4: s/conftestdata/conftest.data/
Inspired by Pavel Roskin's change in autoconf.
2001-01-27 Jim Meyering <meyering@lucent.com>
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Open-code what was
a use of AS_IF.
* fsusage.m4 (jm_FILE_SYSTEM_USAGE): Likewise.
2001-01-26 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ_QUOTEARG): Check for stddef.h, now that
quotearg.c includes it.
2001-01-15 Bruno Haible <haible@clisp.cons.org>
* iconv.m4 (jm_ICONV): Also check whether the iconv declaration
has const.
2001-01-20 Jim Meyering <meyering@lucent.com>
Be sure that headers are checked before used in code compiled
for the type checks.
* jm-macros.m4 (jm_MACROS): Remove all header checks.
In place of that, invoke jm_CHECK_ALL_TYPES.
(jm_CHECK_ALL_HEADERS): New functions with the above checks.
(jm_CHECK_ALL_TYPES): Require jm_CHECK_ALL_HEADERS.
Alan Iwi reported a build failure on an f300-fujitsu-uxpv4.1_ES;
The check for ssize_t was mistakenly run before the test for unistd.h.
The configure-time check for stdbool.h was missing.
* prereq.m4 (jm_PREREQ): Add jm_PREREQ_HASH.
(jm_PREREQ_HASH): New function.
2001-01-17 Jim Meyering <meyering@lucent.com>
* fsusage.m4 (jm_FILE_SYSTEM_USAGE): Use AS_IF, not AS_IFELSE,
for autoconf-2.49c.
* ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Likewise.
2001-01-14 Jim Meyering <meyering@lucent.com>
* rename.m4: Use temporary directories named conftestdir{,2}, not
foo and bar. Create conftestdir/ in the script, not in the C code.
Remove directories in the script, not in the C code.
Remove conftestdir{,2} before trying to create the directory.
Make the entire configure script fail if the mkdir fails.
2001-01-02 Volker Borchert <bt@teknon.de>
* rename.m4: New file.
* jm-macros.m4 (jm_MACROS): Require vb_FUNC_RENAME.
2001-01-01 Alexandre Duret-Lutz <duret_g@epita.fr>
* libintl.m4 (AM_GNU_GETTEXT): Define MKINSTALLDIRS by
expanding the value of $ac_aux_dir, as in AM_MISSING_HAS_RUN,
so `make install' also works in VPATH builds.
2001-01-01 Jim Meyering <meyering@lucent.com>
* prereq.m4 (jm_PREREQ_READUTMP): Include utmp.h (if available), even
on systems with utmpx.h. It's necessary for the declaration of utmp's
ut_user member. Reported by Andreas Jaeger.
* check-decl.m4 (jm_CHECK_DECLS): Include grp.h and pwd.h if available.
They are required for the declarations of getgrgid and getpwuid resp.
(_jm_DECL_HEADERS): Check for grp.h and pwd.h.
Reported by Andreas Jaeger.
2000-12-25 Alexandre Duret-Lutz <duret_g@epita.fr>
* libintl.m4 (AM_WITH_NLS): When using AC_CONFIG_AUX_DIR,
prepend $(top_srcdir) to the value of MKINSTALLDIRS so that it
can be used in subdirectories.
2000-12-26 Jim Meyering <meyering@lucent.com>
* dos.m4 (jm_AC_DOS): Rewrite (though it's still a stub) to work better
with autoheader.
2000-12-17 Jim Meyering <meyering@lucent.com>
* dos.m4 (jm_AC_DOS): New file and macro.
* jm-macros.m4 (jm_MACROS): Require jm_AC_DOS.
2000-12-06 Paul Eggert <eggert@twinsun.com>
* off_t-format.m4: Remove this file.
* jm-macros.m4 (jm_MACROS): Remove jm_SYS_OFF_T_PRINTF_FORMAT.
2000-12-06 Jim Meyering <meyering@lucent.com>
* xstrtoumax.m4 (jm_AC_PREREQ_XSTRTOUMAX): If we need the replacement
strtoull, we may well need the replacement strtoul, too.
Check for declarations of strtoul and strtoull.
Check for strtol. Mainly as a cue to cause automake to include
strtol.c -- that file is included by each of strtoul.c and strtoull.c.
Check for limits.h -- strtol.c needs it.
2000-12-02 Jim Meyering <meyering@lucent.com>
* off_t-format.m4 (OFF_T_PRINTF_FORMAT_STRING): New file/macro.
* jm-macros.m4 (jm_MACROS): require it.
2000-11-30 Jim Meyering <meyering@lucent.com>
* jm-macros.m4 (jm_MACROS): Check for stdint.h.
2000-11-30 Jim Meyering <meyering@lucent.com>
* getloadavg.m4: s/ifval/m4_ifval/ to accommodate new autoconf.
2000-11-03 Bruno Haible <haible@clisp.cons.org>
* jm-macros.m4 (jm_MACROS): Add test for wcrtomb.
@@ -48,7 +199,7 @@
2000-08-06 Paul Eggert <eggert@twinsun.com>
* m4/mbstate_t.m4 (AC_MBSTATE_T): Define mbstate_t to be int,
* mbstate_t.m4 (AC_MBSTATE_T): Define mbstate_t to be int,
not char, for compatibility with glibc 2.1.3 strftime.c.
2000-07-23 Paul Eggert <eggert@twinsun.com>

View File

@@ -11,6 +11,7 @@ chown.m4 \
codeset.m4 \
d-ino.m4 \
d-type.m4 \
dos.m4 \
error.m4 \
fnmatch.m4 \
fpending.m4 \
@@ -40,6 +41,7 @@ link-follow.m4 \
ls-mntd-fs.m4 \
lstat.m4 \
malloc.m4 \
mbrtowc.m4 \
mbstate_t.m4 \
mbswidth.m4 \
memcmp.m4 \
@@ -51,6 +53,7 @@ putenv.m4 \
readdir.m4 \
realloc.m4 \
regex.m4 \
rename.m4 \
rmdir-errno.m4 \
search-libs.m4 \
st_dm_mode.m4 \

View File

@@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am
# Makefile.in generated automatically by automake 1.4b from Makefile.am
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
@@ -126,6 +126,7 @@ chown.m4 \
codeset.m4 \
d-ino.m4 \
d-type.m4 \
dos.m4 \
error.m4 \
fnmatch.m4 \
fpending.m4 \
@@ -155,6 +156,7 @@ link-follow.m4 \
ls-mntd-fs.m4 \
lstat.m4 \
malloc.m4 \
mbrtowc.m4 \
mbstate_t.m4 \
mbswidth.m4 \
memcmp.m4 \
@@ -166,6 +168,7 @@ putenv.m4 \
readdir.m4 \
realloc.m4 \
regex.m4 \
rename.m4 \
rmdir-errno.m4 \
search-libs.m4 \
st_dm_mode.m4 \

View File

@@ -3,7 +3,7 @@ and textutils packages.
These files are used by a program called aclocal (part of the GNU automake
package). aclocal uses these files to create aclocal.m4 which is in turn
used by autoconf to create the configure script at the the top level in
used by autoconf to create the configure script at the top level in
this distribution.
The Makefile.am file in this directory is automatically generated

View File

@@ -1,4 +1,4 @@
#serial 16
#serial 17
dnl This is just a wrapper function to encapsulate this kludge.
dnl Putting it in a separate file like this helps share it between
@@ -41,6 +41,14 @@ AC_DEFUN(jm_CHECK_DECLS,
#if HAVE_UTMP_H
# include <utmp.h>
#endif
#if HAVE_GRP_H
# include <grp.h>
#endif
#if HAVE_PWD_H
# include <pwd.h>
#endif
'
AC_CHECK_DECLS([
@@ -72,6 +80,6 @@ dnl This is a little helper so we can require these header checks.
AC_DEFUN(_jm_DECL_HEADERS,
[
AC_REQUIRE([AC_HEADER_STDC])
AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h \
utmp.h utmpx.h)
AC_CHECK_HEADERS(grp.h memory.h pwd.h string.h strings.h stdlib.h \
unistd.h sys/time.h utmp.h utmpx.h)
])

View File

@@ -1,4 +1,4 @@
#serial 5
#serial 6
dnl From Jim Meyering.
dnl Determine whether chown accepts arguments of -1 for uid and gid.
@@ -21,7 +21,7 @@ AC_DEFUN(jm_FUNC_CHOWN,
int
main ()
{
char *f = "conftestchown";
char *f = "conftest.chown";
struct stat before, after;
if (creat (f, 0600) < 0)

41
m4/dos.m4 Normal file
View File

@@ -0,0 +1,41 @@
# serial 2
# Define some macros required for proper operation of code in lib/*.c
# on MSDOS/Windows systems.
# From Jim Meyering.
AC_DEFUN(jm_AC_DOS,
[
# FIXME: this is incomplete. Add a compile-test that does something
# like this:
#if defined _WIN32 || defined __WIN32__ || defined __MSDOS__
AH_VERBATIM(FILESYSTEM_PREFIX_LEN,
[#if FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
# define FILESYSTEM_PREFIX_LEN(Filename) \
((Filename)[0] && (Filename)[1] == ':' ? 2 : 0)
else
# define FILESYSTEM_PREFIX_LEN(Filename) 0
#endif])
ac_fs_accepts_drive_letter_prefix=0
AC_DEFINE_UNQUOTED([FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
$ac_fs_accepts_drive_letter_prefix,
[Define on systems for which file names may have a so-called
`drive letter' prefix, define this to compute the length of that
prefix, including the colon.])
AH_VERBATIM(ISSLASH,
[#if FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
# define ISSLASH(C) ((C) == '/' || (C) == '\\\\')
#else
# define ISSLASH(C) ((C) == '/')
#endif])
ac_fs_backslash_is_file_name_separator=0
AC_DEFINE_UNQUOTED([FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
$ac_fs_backslash_is_file_name_separator,
[Define if the backslash character may also serve as a file name
component separator.])
])

View File

@@ -1,4 +1,4 @@
#serial 4
#serial 7
# From fileutils/configure.in
@@ -179,14 +179,15 @@ if test $ac_fsusage_space = no; then
fi
if test $ac_fsusage_space = no; then
# SVR2
AC_TRY_CPP([#include <sys/filsys.h>],
AC_DEFINE(STAT_READ_FILSYS, 1,
[ Define if there is no specific function for reading filesystems usage
information and you have the <sys/filsys.h> header file. (SVR2)])
ac_fsusage_space=yes)
# SVR2
AC_TRY_CPP([#include <sys/filsys.h>
],
AC_DEFINE(STAT_READ_FILSYS, 1,
[Define if there is no specific function for reading filesystems usage
information and you have the <sys/filsys.h> header file. (SVR2)])
ac_fsusage_space=yes)
fi
AS_IFELSE([test $ac_fsusage_space = yes], [$1], [$2])dnl
AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
])

View File

@@ -1,4 +1,4 @@
#serial 7
#serial 8
# A replacement for autoconf's macro by the same name. This version
# accepts an optional argument specifying the name of the $srcdir-relative
@@ -15,7 +15,7 @@ AC_DEFUN([AC_FUNC_GETLOADAVG],
# By default, expect to find getloadavg.c in $srcdir/.
ac_lib_dir_getloadavg=$srcdir
# But if there's an argument, DIR, expect to find getloadavg.c in $srcdir/DIR.
ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
m4_ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
# Make sure getloadavg.c is where it belongs, at ./configure-time.
test -f $ac_lib_dir_getloadavg/getloadavg.c \
|| AC_MSG_ERROR([getloadavg.c is not in $ac_lib_dir_getloadavg])

View File

@@ -1,4 +1,4 @@
#serial 1
#serial 2
dnl From Bruno Haible.
@@ -30,6 +30,27 @@ AC_DEFUN(jm_ICONV,
])
if test "$jm_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(jm_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t* outbytesleft);
#else
size_t iconv();
#endif
], [], jm_cv_proto_iconv_arg1="", jm_cv_proto_iconv_arg1="const")
jm_cv_proto_iconv="extern size_t iconv (iconv_t cd, $jm_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t* outbytesleft);"])
jm_cv_proto_iconv=`echo "[$]jm_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]jm_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $jm_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
LIBICONV=
if test "$jm_cv_lib_iconv" = yes; then

View File

@@ -1,10 +1,10 @@
#serial 27
#serial 32 -*- autoconf -*-
dnl Misc type-related macros for fileutils, sh-utils, textutils.
AC_DEFUN(jm_MACROS,
[
AC_PREREQ(2.14a)
AC_PREREQ(2.14d)
GNU_PACKAGE="GNU $PACKAGE"
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
@@ -19,44 +19,7 @@ AC_DEFUN(jm_MACROS,
dnl This macro actually runs replacement code. See isc-posix.m4.
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_CHECK_HEADERS( \
errno.h \
fcntl.h \
fenv.h \
float.h \
limits.h \
memory.h \
mntent.h \
mnttab.h \
netdb.h \
paths.h \
stdlib.h \
stddef.h \
string.h \
sys/acl.h \
sys/filsys.h \
sys/fs/s5param.h \
sys/fs_types.h \
sys/fstyp.h \
sys/ioctl.h \
sys/mntent.h \
sys/mount.h \
sys/param.h \
sys/socket.h \
sys/statfs.h \
sys/statvfs.h \
sys/systeminfo.h \
sys/time.h \
sys/timeb.h \
sys/vfs.h \
sys/wait.h \
syslog.h \
termios.h \
unistd.h \
utime.h \
values.h \
)
jm_CHECK_ALL_TYPES
jm_INCLUDED_REGEX([lib/regex.c])
AC_REQUIRE([jm_BISON])
@@ -102,6 +65,7 @@ AC_DEFUN(jm_MACROS,
AC_FUNC_GETLOADAVG([lib])
AC_REQUIRE([jm_SYS_PROC_UPTIME])
AC_REQUIRE([jm_FUNC_FTRUNCATE])
AC_REQUIRE([vb_FUNC_RENAME])
AC_REPLACE_FUNCS(strcasecmp strncasecmp)
AC_REPLACE_FUNCS(dup2)
@@ -222,9 +186,55 @@ AC_DEFUN(jm_MACROS,
AC_LIBOBJ(fsusage)
AC_LIBOBJ(mountlist)
fi
AC_REQUIRE([jm_AC_DOS])
])
# These tests must be run before any use of AC_CHECK_TYPE,
# because that macro compiles code that tests e.g., HAVE_UNISTD_H.
# See the definition of ac_includes_default in `configure'.
AC_DEFUN(jm_CHECK_ALL_HEADERS,
[
AC_CHECK_HEADERS( \
errno.h \
fcntl.h \
fenv.h \
float.h \
limits.h \
memory.h \
mntent.h \
mnttab.h \
netdb.h \
paths.h \
stdlib.h \
stddef.h \
stdint.h \
string.h \
sys/acl.h \
sys/filsys.h \
sys/fs/s5param.h \
sys/fs_types.h \
sys/fstyp.h \
sys/ioctl.h \
sys/mntent.h \
sys/mount.h \
sys/param.h \
sys/socket.h \
sys/statfs.h \
sys/statvfs.h \
sys/systeminfo.h \
sys/time.h \
sys/timeb.h \
sys/vfs.h \
sys/wait.h \
syslog.h \
termios.h \
unistd.h \
utime.h \
values.h \
)
])
# This macro must be invoked before any tests that run the compiler.
AC_DEFUN(jm_CHECK_ALL_TYPES,
[
@@ -251,6 +261,7 @@ AC_DEFUN(jm_CHECK_ALL_TYPES,
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_C_LONG_DOUBLE])
AC_REQUIRE([jm_CHECK_ALL_HEADERS])
AC_REQUIRE([AC_HEADER_DIRENT])
AC_REQUIRE([AC_HEADER_STDC])
AC_CHECK_MEMBERS([struct stat.st_blksize],,,[$ac_includes_default

View File

@@ -6,7 +6,7 @@
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 109
# serial 110
AC_PREREQ(2.13) dnl Minimum Autoconf version required.
@@ -289,7 +289,7 @@ strdup __argz_count __argz_stringify __argz_next])
dnl Try to locate it.
MKINSTALLDIRS=
if test -n "$ac_aux_dir"; then
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
MKINSTALLDIRS="`CDPATH=:; cd $ac_aux_dir && pwd`/mkinstalldirs"
fi
if test -z "$MKINSTALLDIRS"; then
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"

View File

@@ -1,4 +1,4 @@
#serial 6
#serial 10
dnl From Jim Meyering.
dnl
@@ -6,12 +6,10 @@ dnl This is not pretty. I've just taken the autoconf code and wrapped
dnl it in an AC_DEFUN.
dnl
AC_PREREQ(2.14a)
# jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
[
AC_CHECK_FUNCS(listmntent getmntent getmntinfo)
AC_CHECK_FUNCS(listmntent getmntinfo)
AC_CHECK_HEADERS(mntent.h)
# Determine how to get the list of mounted filesystems.
@@ -239,6 +237,6 @@ if test -z "$ac_list_mounted_fs"; then
# Can't build mountlist.c or anything that needs its functions
fi
AS_IFELSE([test $ac_list_mounted_fs = found], [$1], [$2])dnl
AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
])

18
m4/mbrtowc.m4 Normal file
View File

@@ -0,0 +1,18 @@
#serial 2
dnl From Paul Eggert
AC_DEFUN(jm_FUNC_MBRTOWC,
[
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
jm_cv_func_mbrtowc,
[AC_TRY_LINK(
[@%:@include <wchar.h>],
[mbstate_t state; return ! (sizeof state && mbrtowc);],
jm_cv_func_mbrtowc=yes,
jm_cv_func_mbrtowc=no)])
if test $jm_cv_func_mbrtowc = yes; then
AC_DEFINE(HAVE_MBRTOWC, 1,
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
fi
])

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 4
dnl autoconf tests required for use of mbswidth.c
dnl From Bruno Haible.
@@ -8,7 +8,8 @@ AC_DEFUN(jm_PREREQ_MBSWIDTH,
AC_REQUIRE([AC_HEADER_STDC])
AC_REQUIRE([AM_C_PROTOTYPES])
AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
AC_CHECK_FUNCS(isascii iswprint mbrtowc wcwidth)
AC_CHECK_FUNCS(isascii iswprint wcwidth)
jm_FUNC_MBRTOWC
headers='
# if HAVE_WCHAR_H
# include <wchar.h>

View File

@@ -1,4 +1,4 @@
#serial 13
#serial 17
dnl These are the prerequisite macros for files in the lib/
dnl directories of the fileutils, sh-utils, and textutils packages.
@@ -10,6 +10,7 @@ AC_DEFUN(jm_PREREQ,
jm_PREREQ_DIRNAME
jm_PREREQ_ERROR
jm_PREREQ_GETPAGESIZE
jm_PREREQ_HASH
jm_PREREQ_HUMAN
jm_PREREQ_MBSWIDTH
jm_PREREQ_MEMCHR
@@ -53,6 +54,12 @@ AC_DEFUN(jm_PREREQ_GETPAGESIZE,
AC_CHECK_HEADERS(OS.h unistd.h)
])
AC_DEFUN(jm_PREREQ_HASH,
[
AC_CHECK_HEADERS(stdlib.h stdbool.h)
AC_REQUIRE([jm_CHECK_DECLS])
])
# If you use human.c, you need the following files:
# uintmax_t.m4 inttypes_h.m4 ulonglong.m4
AC_DEFUN(jm_PREREQ_HUMAN,
@@ -70,8 +77,9 @@ AC_DEFUN(jm_PREREQ_MEMCHR,
AC_DEFUN(jm_PREREQ_QUOTEARG,
[
AC_CHECK_FUNCS(isascii iswprint mbrtowc)
AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
AC_CHECK_FUNCS(isascii iswprint)
jm_FUNC_MBRTOWC
AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
AC_HEADER_STDC
AC_C_BACKSLASH_A
AC_MBSTATE_T
@@ -91,7 +99,8 @@ AC_DEFUN(jm_PREREQ_READUTMP,
$ac_includes_default
#ifdef HAVE_UTMPX_H
# include <utmpx.h>
#else
#endif
#ifdef HAVE_UTMP_H
# include <utmp.h>
#endif
"

View File

@@ -1,4 +1,4 @@
#serial 8
#serial 9
dnl Initially derived from code in GNU grep.
dnl Mostly written by Jim Meyering.
@@ -28,6 +28,7 @@ AC_DEFUN(jm_INCLUDED_REGEX,
{
static struct re_pattern_buffer regex;
const char *s;
struct re_registers regs;
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
/* Add this third left square bracket, [, to balance the
three right ones below. Otherwise autoconf-2.14 chokes. */
@@ -39,7 +40,20 @@ AC_DEFUN(jm_INCLUDED_REGEX,
/* This should succeed, but doesn't for e.g. glibc-2.1.3. */
s = re_compile_pattern ("{1", 2, &regex);
exit (s ? 1 : 0);
if (s)
exit (1);
/* The following example is derived from a problem report
against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
s = re_compile_pattern ("[anù]*n", 7, &regex);
if (s)
exit (1);
/* This should match, but doesn't for e.g. glibc-2.2.1. */
if (re_match (&regex, "an", 2, 0, &regs) != 2)
exit (1);
exit (0);
}
],
jm_cv_func_working_re_compile_pattern=yes,

40
m4/rename.m4 Normal file
View File

@@ -0,0 +1,40 @@
#serial 2
dnl From Volker Borchert.
dnl Determine whether rename works for source paths with a trailing slash.
dnl The rename from SunOS 4.1.1_U1 doesn't.
dnl
dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
dnl to compile the wrapper function.
dnl
AC_DEFUN(vb_FUNC_RENAME,
[
AC_CACHE_CHECK([whether rename is broken],
vb_cv_func_rename_trailing_slash_bug,
[
rm -rf conftest.d1 conftest.d2
mkdir conftest.d1 ||
AC_MSG_ERROR([cannot create temporary directory])
AC_TRY_RUN([
# include <stdio.h>
int
main ()
{
exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
}
],
vb_cv_func_rename_trailing_slash_bug=no,
vb_cv_func_rename_trailing_slash_bug=yes,
dnl When crosscompiling, assume rename is broken.
vb_cv_func_rename_trailing_slash_bug=yes)
rm -rf conftest.d1 conftest.d2
])
if test $vb_cv_func_rename_trailing_slash_bug = yes; then
AC_LIBOBJ(rename)
AC_DEFINE_UNQUOTED(RENAME_TRAILING_SLASH_BUG, 1,
[Define if rename does not work for source paths with a trailing slash,
like the one from SunOS 4.1.1_U1.])
fi
])

View File

@@ -5,7 +5,7 @@ dnl then do case-insensitive s/utime/utimes/.
AC_DEFUN(jm_FUNC_UTIMES_NULL,
[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
[rm -f conftestdata; > conftestdata
[rm -f conftest.data; > conftest.data
AC_TRY_RUN([
/* In case stat has been defined to rpl_stat, undef it here. */
#undef stat
@@ -13,9 +13,11 @@ AC_TRY_RUN([
#include <sys/stat.h>
main() {
struct stat s, t;
exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
&& stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
&& t.st_mtime - s.st_mtime < 120));
exit(!(stat ("conftest.data", &s) == 0
&& utimes("conftest.data", (long *)0) == 0
&& stat("conftest.data", &t) == 0
&& t.st_mtime >= s.st_mtime
&& t.st_mtime - s.st_mtime < 120));
}],
ac_cv_func_utimes_null=yes,
ac_cv_func_utimes_null=no,

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
# autoconf tests required for use of xstrtoumax.c
@@ -7,7 +7,8 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_DECLS([strtoul, strtoull])
AC_CHECK_HEADERS(limits.h stdlib.h)
AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
jm_cv_func_strtoumax_macro,
@@ -28,7 +29,13 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
dnl so we need the replacement strtoull only if strtoumax does not exist.
case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
yes,no,no)
AC_REPLACE_FUNCS(strtoull)
AC_REPLACE_FUNCS(strtoull strtol)
;;
esac
case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
no,no)
AC_REPLACE_FUNCS(strtoul strtol)
;;
esac

View File

@@ -27,7 +27,7 @@ use Text::Tabs qw(expand);
use POSIX qw(strftime setlocale LC_TIME);
my $this_program = 'help2man';
my $this_version = '1.23';
my $this_version = '1.24';
my $version_info = <<EOT;
GNU $this_program $this_version
@@ -59,18 +59,20 @@ EOT
my $section = 1;
my ($opt_name, @opt_include, $opt_output, $opt_no_info);
# Parse options.
Getopt::Long::config('bundling');
GetOptions (
my %opt_def = (
'n|name=s' => \$opt_name,
's|section=s' => \$section,
'i|include=s' => sub { push @opt_include, [ pop, 1 ] },
'I|opt-include=s' => sub { push @opt_include, [ pop, 0 ] },
'o|output=s' => \$opt_output,
'N|no-info' => \$opt_no_info,
help => sub { print $help_info; exit },
version => sub { print $version_info; exit },
);
# Parse options.
Getopt::Long::config('bundling');
GetOptions (%opt_def,
help => sub { print $help_info; exit },
version => sub { print $version_info; exit },
) or die $help_info;
die $help_info unless @ARGV == 1;
@@ -93,9 +95,9 @@ BEGIN { eval q(sub qr { '' =~ $_[0]; $_[0] }) if $] < 5.005 }
# verbatim text
#
for (@opt_include)
while (@opt_include)
{
my ($inc, $required) = @$_;
my ($inc, $required) = @{shift @opt_include};
next unless -f $inc or $required;
die "$this_program: can't open `$inc' ($!)\n"
@@ -134,9 +136,20 @@ for (@opt_include)
next;
}
# Silently ignore anything before the first
# section--allows for comments and revision info.
next unless $key;
# Check for options before the first section--anything else is
# silently ignored, allowing the first for comments and
# revision info.
unless ($key)
{
# handle options
if (/^-/)
{
local @ARGV = split;
GetOptions %opt_def;
}
next;
}
$hash->{$key} ||= '';
$hash->{$key} .= $_;

View File

@@ -1,8 +1,572 @@
2001-02-18 Jim Meyering <meyering@lucent.com>
* Version 4.0.41.
* depcomp: New version, from automake.
`chmod 0 file; rm file' would no longer prompt before removal.
* src/remove.c (remove_file): Revert last change.
Reported by Vin Shelton.
2001-02-17 Jim Meyering <meyering@lucent.com>
* Version 4.0.40.
* src/chown.c (main): `quote' the offending argument.
2001-02-17 Paul Eggert <eggert@twinsun.com>
Stop trying to support hosts that have nonstandard declarations for
mbrtowc and/or mbstate_t. It's not worth the portability hassle.
* m4/mbrtowc.m4: New file, defining jm_FUNC_MBRTOWC.
* m4/mbswidth.m4 (jm_PREREQ_MBSWIDTH):
Use jm_FUNC_MBRTOWC, not AC_CHECK_FUNCS(mbrtowc).
* m4/prereq.m4 (jm_PREREQ_QUOTEARG): Likewise.
* lib/mbswidth.c, lib/quotearg.c, src/ls.c (mbrtowc, mbsinit):
Remove workaround macros for hosts that have mbrtowc but not
mbstate_t, as we now insist on proper declarations for both
before using mbrtowc.
Reported by Matt Schalit.
2001-02-17 Jim Meyering <meyering@lucent.com>
* config.sub: Update from master repository.
* config.guess: Likewise.
2001-02-16 Paul Eggert <eggert@twinsun.com>
* doc/getdate.texi: Mention that only English is supported.
Show how to use "date" so that the output is acceptable to getdate.
Mention Z as an abbreviation for UTC.
2001-02-11 Jim Meyering <meyering@lucent.com>
* Makefile.maint (emit-rsync-commands): Define.
(alpha): Use it here.
2001-02-10 Jim Meyering <meyering@lucent.com>
* Makefile.maint (alpha): Fix previous, incomplete change.
* Version 4.0.39.
* depcomp: New version, from automake.
2001-02-04 Jim Meyering <meyering@lucent.com>
* README: Remove note about now-ancient Sequents.
2001-02-03 Jim Meyering <meyering@lucent.com>
* src/ln.c (main): Change type of index variable to `unsigned int'
to avoid a warning.
* config.guess: Update from master repository.
* Makefile.maint (a_host): Use fencepost.
(real_dir): Use the same name for both.
(alpha): Print commands for both hosts.
* src/mv.c (long_options): Use `strip-trailing-slashes',
per the documetation, not `strip-trailing-slash'.
* src/cp.c (long_opts): Likewise.
Reported by Oskar Liljeblad.
* doc/fileutils.texi (mv invocation): Add a warning about how a trailing
slash makes a difference. Prompted by a report from Oskar Liljeblad
via Michael Stone (Debian bug#83991).
2001-01-31 Jim Meyering <meyering@lucent.com>
* config.sub: Update from master repository.
* config.guess: Likewise.
2001-01-28 Jim Meyering <meyering@lucent.com>
* Version 4.0.38.
* configure, aclocal.m4, etc.: Regenerate using autoconf-2.49c.
* src/ls.c (gobble_file): Add a FIXME comment.
* TODO: Add a few items.
* src/ls.c (enum) [FULL_TIME]: Define.
(long_options): Use it.
(decode_switches): Make --full-time imply -l.
Prompted by a report from Karl Eichwalder.
2001-01-22 Jim Meyering <meyering@lucent.com>
* src/remove.c (remove_file): Correct an expression to avoid making
an unnecessary call to euidaccess for each file.
2001-01-21 Jim Meyering <meyering@lucent.com>
* Version 4.0.37.
2001-01-20 Jim Meyering <meyering@lucent.com>
* configure.in: Remove jm_CHECK_ALL_TYPES.
Now it's invoked by jm_MACROS.
2001-01-17 Jim Meyering <meyering@lucent.com>
* src/sys2.h (case_GETOPT_VERSION_CHAR): Use PACKAGE, not GNU_PACKAGE.
* src/sync.c (main): Likewise.
* src/shred.c (PACKAGE): Likewise.
* src/dd.c (main): Likewise.
2001-01-14 Jim Meyering <meyering@lucent.com>
* Version 4.0.36.
* src/shred.c (UINT_MAX_32_BITS): Define.
Use UINT_MAX_32_BITS in the cpp conditions that determine
the `word32' typedef. Using a literal `0xffffffff' failed with
HPUX10.20's /bin/cc.
* config.sub: Update from master repository.
* config.guess: Likewise.
2001-01-02 Volker Borchert <bt@teknon.de>
Work around a broken rename system call, e.g. on SunOS 4.1.1_U1,
that fails when the source path has a trailing slash.
* src/copy.h [RENAME_TRAILING_SLASH_BUG]: Use the rename wrapper.
* tests/mv/trailing-slash: Test whether the workaround works.
* tests/m4/Makefile.am (TESTS): Add trailing-slash.
2001-01-03 Alexandre Duret-Lutz <duret_g@epita.fr>
* po/Makefile.in.in (update-po): Merge po-files in temporary files
in the build directory, and update the source directory only when
the merged catalog differs from the original. This fixes the known
`make distcheck' failure due to `make update-po' being called
on up-to-date but read-only files.
2001-01-13 Jim Meyering <meyering@lucent.com>
* src/copy.c (same_file_ok): When moving a symlink onto itself,
don't remove the symlink. Reported by David Luyer as Debian bug#82089,
via Michael Stone.
* tests/mv/into-self-4: New test for the above.
* tests/mv/Makefile.am (TESTS): Add into-self-4.
* tests/chmod/setgid: If `chmod g+s d' fails, then try to chgrp
to a group of which we're a member, then try the chmod again.
2001-01-11 Jim Meyering <meyering@lucent.com>
* depcomp: New version, from automake.
2001-01-10 Jim Meyering <meyering@lucent.com>
* src/copy.c (copy_internal): Add a comment.
Set *copy_into_self in the new code that detects that.
Make diagnostic more consistent: s/won't/will not/.
[move_mode, copy_into_self]: Give a diagnstic here, now that
we have the top_level_* globals. Remove the corresponding diagnostic
from mv.c.
Add a FIXME comment.
* src/mv.c (do_move): Remove diagnostic, now that copy.c issues it.
Set `fail' to nonzero in the primary `if (copy_into_self)' block
rather than in its own tiny one below.
* src/copy.c (copy_internal): Don't allow cp (or mv, when working
across a partition boundary) to overwrite a non-directory with a
directory. Reported by Michael J. Croghan.
* tests/cp/dir-vs-file: New test for the above.
* tests/cp/Makefile.am (TESTS): Add dir-vs-file.
2001-01-09 Jim Meyering <meyering@lucent.com>
Give a better diagnostic for `cp -R a a'.
* src/copy.c (top_level_src_path, top_level_dst_path): New globals.
(copy_internal): Use them.
(copy): Set them.
* src/cp-hash.c [struct entry] (node): Describe how it's used,
now that we've overloaded it, in order to detect and diagnose
the copying-directory-into-self problem.
(new_file): Remove global.
(htab): Declare global to be static.
(remember_created): Insert file name instead of dummy pointer, so
that copy.c can use the just-created directory name to detect
the copying-directory-into-self problem.
* tests/cp/into-self: New test for the above.
* tests/cp/Makefile.am (TESTS): Add into-self.
2001-01-07 Jim Meyering <meyering@lucent.com>
* src/cp.c (usage): Split a string that was longer than 2048 bytes.
* doc/perm.texi: s/can not/cannot/
2001-01-07 Karl Eichwalder <ke@suse.de>
* src/chown.c (usage): Split long message string.
2001-01-07 Karl Eichwalder <ke@suse.de>
* src/ls.c (usage): Untabify.
* src/chgrp.c (parse_group): Normalize spelling.
2001-01-03 Paul Eggert <eggert@twinsun.com>
* NEWS: Document the planned --full-time change.
* doc/fileutils.texi: Likewise.
* NEWS: Document that time stamps depend on LC_TIME, not LC_MESSAGES.
2001-01-03 Paul Eggert <eggert@twinsun.com>
Use the more precise algorithm of GNU "make" to decide whether
a file is in the future, by looking at high-resolution time
stamps if available.
* src/ls.c:
(TIMESPEC_NS): New macro.
(current_time): Initialize to the minimum value.
(current_time_ns): New var.
(main): Do not bother to initialize current_time;
it's no longer needed.
(get_current_time): New function.
(print_long_format): Use it when a file appears to be in the future.
Get the nanoseconds of the file's time stamp, if available,
and use that to decide whether the file appears to be in the future.
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): New macros.
2001-01-02 Paul Eggert <eggert@twinsun.com>
* src/ls.c (long_time_expected_width, print_long_format): Fix
bug: the initial byte passed to strftime wasn't initialized to
a nonzero value after the buffer was reallocated.
2001-01-02 Paul Eggert <eggert@twinsun.com>
Make ls -l compatible with POSIX, which requires that the
behavior of time formats must depend only on LC_TIME, not on
LC_MESSAGES.
* po/Makefile.in.in (install-data-yes): If the package is
fileutils, install LC_TIME as an alias for LC_MESSAGES.
* src/sys2.h (dcgettext): New macro.
* src/ls.c (decode_switches): Use dcgettext with LC_TIME,
not plain gettext, to get the translations of time formats.
2001-01-02 Paul Eggert <eggert@twinsun.com>
* src/ls.c (long_time_expected_width): New function.
(print_long_format): Use it, so that we don't assume a
particular width for time stamps in an internationalized
environment.
2001-01-01 Paul Eggert <eggert@twinsun.com>
* doc/fileutils.texi, NEWS:
ls -l now reports the year for files even slightly in the future, as
POSIX requires. This helps warn users about clock skew problems.
* src/ls.c (print_long_format):
Report the year for files even slightly in the future.
Avoid overflow problems near Y2038 on 32-bit hosts.
To calculate "six months", take half the average Gregorian
year, not 180 days.
2001-01-01 Jim Meyering <meyering@lucent.com>
* tests/chmod/Makefile.am (TESTS): Add setgid.
* tests/chmod/setgid: Test for chmod's existing behavior.
Based on a report from Paul Eggert.
2000-12-29 Paul Eggert <eggert@twinsun.com>
Clean up the terminology a tad: some directories were called "sticky"
when they were really setgid.
* tests/Makefile.am (EXTRA_DIST): sticky-check -> setgid-check
* tests/chmod/c-option, tests/cp/cp-parents, tests/mkdir/parents,
tests/mkdir/perm: Likewise.
* tests/setgid-check: File renamed from tests/sticky-check.
All uses of "sticky" changed to "setgid".
2000-12-31 Jim Meyering <meyering@lucent.com>
* tests/cp/Makefile.am (TESTS): Add deref-slink.
* tests/cp/deref-slink: New file. Test for the bug fixed by my
2000-12-28 change to copy.c.
2000-12-30 Paul Eggert <eggert@twinsun.com>
* src/ls.c: Improve performance by invoking gettext twice at the start,
instead of once for each file.
(long_time_format): New var.
(decode_switches): Initialize it, if format == long_format.
(print_long_format): Use it.
2000-12-30 Paul Eggert <eggert@twinsun.com>
* src/ls.c (print_long_format): Don't dump core if strftime
returns the empty string.
2000-12-30 Paul Eggert <eggert@twinsun.com>
* src/ls.c (gobble_file): If not using long format, don't
invoke acl; it's not needed.
2000-12-30 Jim Meyering <meyering@lucent.com>
Avoid an unnecessary `stat' when using --dereference.
* src/copy.c (same_file_ok): Use stat only if lstat reported that
the file was a symbolic link.
2000-12-29 Paul Eggert <eggert@twinsun.com>
* doc/perm.texi: append-only directories -> restricted deletion flag,
which is the term that POSIX d5 uses for this notion.
2000-12-28 Paul Eggert <eggert@twinsun.com>
* tests/group-names: Try /usr/xpg4/bin/id (Solaris 7) if plain
'id' doesn't work.
2000-12-28 Jim Meyering <meyering@lucent.com>
* tests/cp/cp-parents: Run sticky-check from just-created directory.
2000-12-28 Jim Meyering <meyering@lucent.com>
* src/copy.c (same_file_ok): Fix two typos from my 2000-09-03 change:
s/tmp_dst_sb/tmp_src_sb/.
2000-12-27 Paul Eggert <eggert@twinsun.com>
* tests/sticky-check: Turn off the working directory's sticky
bit, so that we don't have to worry about it later.
* src/copy.c (same_file_ok): Use a single auto var for
tmp_dst_sb, instead of two static vars. Likewise for
tmp_src_sb.
2000-12-26 Jim Meyering <meyering@lucent.com>
* Version 4.0.35.
* Regenerate build/config framework to use automake-1.4b and
the latest CVS version autoconf.
* tests/mkdir/perm: Disable the test if the working directory has
the sticky bit set.
* tests/cp/cp-parents: Likewise.
Reported by Nelson Beebe.
2000-12-25 Jim Meyering <meyering@lucent.com>
Clean-up to avoid warnings from Irix's c89.
* src/remove.c (hash_compare_active_dir_ents): Return explicit `true'
or `false', rather than relying on implicit int-to-enum cast.
* src/copy.c (same_file_ok): Remove declaration and set of unused
variables: src_sb_no_link, dst_sb_no_link.
* src/ls.c (extract_dirs_from_files): Remove unused variable.
Reported by Nelson Beebe.
* src/ls.c (gobble_file): Move decl of local, val, into the scope
where it's used.
2000-12-24 Jim Meyering <meyering@lucent.com>
For both ln and install, when using `--backup=simple --suffix=S',
the suffix `S' wasn't used.
* src/ln.c (main): Actually use the local variable,
`backup_suffix_string'.
* src/install.c (main): Likewise.
Nelson Beebe reported the unused variables.
* tests/ln/misc: Add a test for this (for all of cp, mv, ln, install).
* man/help2man: Update to version 1.24.
2000-12-22 Jim Meyering <meyering@lucent.com>
* Version 4.0.34.
* src/shred.c (isaac_seed_machdep) [_ARCH_PPC]: Disable the code
that would use the PPC mfspr `asm' code. Suggestion from Michael Stone.
2000-12-19 Jim Meyering <meyering@lucent.com>
* doc/fileutils.texi: Use `ref_file' in place of `file' to make
descriptions of the various --reference=... options clearer.
2000-12-17 Jim Meyering <meyering@lucent.com>
* doc/texinfo.tex: Update from master repository.
* config.sub: Likewise.
* config.guess: Likewise.
2000-12-16 Jim Meyering <meyering@lucent.com>
* src/chown-core.c (uint_to_string): New function.
(uid_to_name): Use it.
(gid_to_name): Use it.
Rename locals, user/group, to uid/gid.
* src/chown-core.h (enum Change_status): Start with 1.
* src/chown.c (main): Rename locals, user/group, to uid/gid.
* src/chgrp.c (main): Rename local, group, to gid.
* tests/group-names: New file.
* tests/Makefile.am (EXTRA_DIST): Add group-names.
* tests/chgrp/basic: Use group-names.
* tests/chgrp/deref: Likewise.
* tests/chgrp/recurse: Likewise.
* tests/chgrp/basic: Don't assume that creating a file gives it
group $g1.
* tests/chgrp/Makefile.am (TESTS): Add recurse.
2000-12-15 Jim Meyering <meyering@lucent.com>
* src/chown-core.h [enum Dereference_symlink] (dereference): Rename
from change_symlinks.
* src/chown-core.c: Declare lstat.
Rename change_symlinks member to `dereference' and use the DEREF_*
enum values.
(describe_change): Merge the chgrp and chown switch statements.
Use xmalloc to form the `user:group' string.
(change_file_owner): Record (and later, use) is_symlink and is_directory
from the lstat stats, in order to control whether we operate on symlinks
and whether (with -R) we traverse symlinks to directories.
When dereferencing, use open/fchown (rather than chown) on symlinks.
* src/chown.c (main): Reflect renaming: s/dereference/change_symlinks/.
* src/chgrp.c (main): Likewise.
* src/chown-core.c (describe_change): Use `:' (not `.') to separate the
username and group in messages evoked by the --verbose and --changes
options.
2000-12-09 Jim Meyering <meyering@lucent.com>
* src/Makefile.am (noinst_HEADERS): Add chown-core.h.
(chown_SOURCES): Define.
(chgrp_SOURCES): Define.
* src/chgrp.c: Include "chown-core.h".
[enum Change_status, enum Verbosity]: Remove declarations.
Remove decls of globals that are now part of struct Chown_option.
Remove decl of xstat.
(describe_change): Remove function.
(change_file_group): Likewise.
(change_dir_group): Likewise.
(parse_group): Don't set global, groupname, here...
(main): ... instead, initialize `chopt.group_name' here.
Initialize chopt and update uses of the now-members.
Set group_name also when it's obtained via a --reference=FILE option.
Call change_file_owner (with -1 for uids), not change_file_group.
* src/chown.c: Don't include pwd.h or grp.h -- no longer needed.
Include "chown-core.h".
[enum Change_status, enum Verbosity]: Remove declarations.
Remove decls of globals that are now part of struct Chown_option.
(describe_change): Remove function.
(change_file_owner): Likewise.
(change_dir_owner): Likewise.
(main): Initialize chopt and update uses of the now-members.
Set user_name and group_name also when they're obtained via a
--reference=FILE option.
Pass `chopt' to change_file_owner.
* src/chown-core.c: Include <pwd.h>, <grp.h>, and "xalloc.h".
[!_POSIX_VERSION]: Declare getgrnam and getgrgid.
(gid_to_name): New function.
(uid_to_name): Likewise.
(chopt_free): Likewise.
Factor out code that's common to chgrp.c and chown.c.
* src/chown-core.h: New file.
* src/chown-core.c (chopt_init): New function.
(describe_change): Extracted/combined from chgrp.c and chown.c.
(change_dir_owner): Likewise.
(change_file_owner): Likewise.
* po/POTFILES.in: Add src/chown-core.c.
* configure.in (AC_OUTPUT): Add tests/chgrp/Makefile.
* tests/Makefile.am (SUBDIRS): Add chgrp.
* tests/chgrp: New directory.
* tests/chgrp/basic: New test.
* tests/chgrp/deref: Likewise.
* tests/chgrp/Makefile.am: New file.
* src/chown.c (change_file_owner): Restore special file permission
bits, since calling chown resets them on some systems.
Reported by Matt Perry.
2000-12-08 Andreas Schwab <schwab@suse.de>
* tests/mv/mv-special-1: Don't make the success of the test depend
on the order in which directory entries are processed.
2000-12-03 Jim Meyering <meyering@lucent.com>
* src/ls.c (gobble_file) [USE_ACL]: Set have_acl member unconditionally
to avoid uninitialized memory reference via FILE_HAS_ACL.
* Makefile.maint (alpha): Use rsync rather than scp, so the destination
file is created only after the successful completion of the copy.
2000-12-02 Jim Meyering <meyering@lucent.com>
* tests/ls/Makefile.am (TESTS): Add follow-slink.
* tests/ls/follow-slink: New file.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* src/ls.c (gobble_file): Do not fall back on lstat if stat
fails; POSIX.2 does not allow this. Invoke acl only on
non-symlinks, and only if lstat or stat succeeds.
2000-12-02 Jim Meyering <meyering@lucent.com>
* configure: Regenerate using the very latest version (in CVS) of
autoconf.
* tests/dd/skip-seek: Remove test #2, now that support for the
`B' suffix is gone.
* tests/dd/Makefile.am (TESTS): Add skip-seek2
* tests/dd/skip-seek2: New file.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* src/dd.c (skip, dd_copy): Use ssize_t to store result of
safe_read, to avoid overflow e.g. on 64-bit Solaris sparc.
(dd_copy): Remove unnecessary cast.
2000-12-01 Paul Eggert <eggert@twinsun.com>
* doc/fileutils.texi: Remove B suffix. Document how to have
the desired effect without it.
* src/dd.c: Undo most of the changes since 2000-11-24, since we've
documented a standard way to do it.
(skip_bytes, seek_bytes): Remove.
(usage): Remove B suffix.
(scanargs, skip, dd_copy, main): Remove support for B suffix.
2000-11-28 Jim Meyering <meyering@lucent.com>
* src/mkdir.c (main): Remove any trailing slash unconditionally.
Reported by Volker Borchert.
* tests/mkdir/t-slash: Add a test for this.
2000-11-27 Jim Meyering <meyering@lucent.com>
* Version 4.0.33.
* tests/touch/no-rights: Use touch with `-d tomorrow' to avoid
* tests/touch/no-rights: Use touch with `-d tomorrow' to avoid a
race condition.
* tests/Fetish.pm (_compare_files): New function.

View File

@@ -1,8 +1,49 @@
Changes in release 4.01:
[4.0.41]
* fix bug in rm introduced in 4.0.38: `chmod 0 f; rm f' would no longer prompt
before removal.
[4.0.40]
* portability fixes, mainly for UnixWare 7.1.1
[4.0.39]
* cp and mv accept --strip-trailing-slashes, not just --strip-trailing-slash
[4.0.38]
* ls --full-time now implies -l; before, without -l it was a no-op
[4.0.37]
* portability fixes for SunOS4.1.1, Fujitsu (f300-fujitsu-uxpv4.1_ES),
and Unicos (alphaev5-cray-unicosmk2.0.5.X)
[4.0.36]
* `mv dir/ new-name' no longer fails on SunOS4.1.1U
* attempting to use mv to move a symlink onto itself no longer removes
the symlink
* `cp -R directory file' no longer removes `file'. now it fails and gives
a diagnostic
* The manual now warns that ls's --full-time format string is planned
to change in a future release.
* ls -l's time stamp format now depends on LC_TIME, not LC_MESSAGES,
as POSIX requires.
* ls -l now reports the year for files even slightly in the future, as
POSIX requires. This helps warn users about clock skew problems.
* `cp -d file symlink-to-some-other-file' no longer fails
* performance improvements for ls
[4.0.35]
* ln --backup=simple --suffix=SUFFIX once again uses SUFFIX
* install: Likewise.
[4.0.34]
* fix a bug (introduced in 4.0z) that made `chown 123:456 file' act like
`chown 123:123 file'. Other uses with a numeric group ID would cause
chown to fail when it shouldn't have.
* the chown and chgrp programs preserve set-uid and set-gid bits, even on
systems for which the chown function call resets those bits.
* `ls -L dangling-symlink' now fails (per POSIX) rather than printing the
link name
* dd no longer honors the just-added `B' suffix on skip= and seek= arguments.
* `mkdir no-such-dir/' no longer fails on NetBSD systems
[4.0.33]
* dd now accepts skip=nB and seek=nB, to advance past some number of bytes, n,
that is smaller than the block size.
* dd (without conv=notrunc) now uses ftruncate only on regular files
that need not be a multiple of the block size.
* dd (without conv=notrunc) now complains only when ftruncate fails on a
regular file, a directory, or a shared memory object -- not when it fails
to truncate other types of files, like /dev/fd0.
* chmod --changes (-c) once again issues diagnostics only for the files
with changed permissions
* mkdir now gives one diagnostic (rather than two) for certain failures
@@ -56,7 +97,7 @@ Changes in release 4.01:
* cp -p and mv now try to preserve uid even if you're not root, as per POSIX.2.
This affects behavior only on hosts that let you give files away via chmod.
* du would fail when given `.' or `..' followed by other command line arguments
* Using cp's short-named `-P' option evokes the warning that that the
* Using cp's short-named `-P' option evokes the warning that the
meaning of `-P' will soon change. Use `--parents' instead.
* chgrp, chmod, and chown: when used with the --verbose option, might give an
invalid diagnostic (due to clobbered errno) when failing.

View File

@@ -1,6 +1,66 @@
2001-02-04 Jim Meyering <meyering@lucent.com>
* src/factor.c (usage): Tweak --help output: it prints the _prime_
factors, not just any factors.
2001-02-03 Jim Meyering <meyering@lucent.com>
Improve the performance of `factor' (more than 2x speed-up for large N).
* src/factor.c (wheel_tab): New global table.
(WHEEL_START, WHEEL_END): Define.
(factor): Remove the loop that special-cased `2'.
Instead of incrementing by `2', use the offsets from the wheel table.
From Michael Steffens.
2000-11-27 Prashant TR <rprash@wilco-int.com>
* src/test.c (eaccess) [__MSDOS__]: Just use access.
2001-01-26 Jim Meyering <meyering@lucent.com>
* src/dirname.c (main): Declare local result as non-const, now
that it's freed.
2001-01-20 Jim Meyering <meyering@lucent.com>
* configure.in: Remove jm_CHECK_ALL_TYPES.
Now it's invoked by jm_MACROS.
2001-01-04 Jim Meyering <meyering@lucent.com>
* src/date.c (main): Fail when --rfc-822 (-R) is specified along
with a format string. Reported by Jochen Hein.
2000-12-17 Jim Meyering <meyering@lucent.com>
* doc/texinfo.tex: Update from master repository.
* config.sub: Likewise.
* config.guess: Likewise.
* djgpp: New directory.
* djgpp/*: New files.
* Makefile.am (SUBDIRS): Add djgpp.
* configure.in (AC_OUTPUT): Add djgpp/Makefile.
From Prashant TR.
2000-12-08 Jim Meyering <meyering@lucent.com>
* src/dirname.c: Include xalloc.h.
(main): Use dir_name rather than the underlying dir_name_r.
The former now handles cwd-relative names with drive-letter prefixes.
2000-12-02 Jim Meyering <meyering@lucent.com>
* src/seq.c (valid_format): Move pre-increment to a separate statement
to avoid a warning.
* src/id.c: Move dcls of globals used only in main...
(main): ...to here.
(usage): Clarify option descriptions.
2000-11-18 Jim Meyering <meyering@lucent.com>
* Version 2.0.12.
* po/Makefile.in.in: Sync with the one from fileutils.
* configure, config.h.in, Makefile.in, etc.: Regenerate using the
very latest version (in CVS) of autoconf.

View File

@@ -1,7 +1,242 @@
2000-11-27 Jim Meyering <meyering@lucent.com>
2001-02-18 Jim Meyering <meyering@lucent.com>
Rename test input files to avoid conflicts on case-insensitive
file systems.
* tests/pr/2-Sf-t_notab: Rename from 2Sf-t_notab.
* tests/pr/2-S_f-t_notab: Rename from 2S_f-t_notab.
* tests/pr/W-72l17f-ll: Rename from W72l17f-ll.
* tests/pr/Test.pm: Update file names to reflect renamings.
Reported by Matthew Smith.
2001-01-20 Jim Meyering <meyering@lucent.com>
* configure.in: Remove jm_CHECK_ALL_TYPES.
Now it's invoked by jm_MACROS.
2001-01-17 Jim Meyering <meyering@lucent.com>
* src/cksum.c (main): Use PACKAGE, not GNU_PACKAGE.
* src/tsort.c (main): Likewise.
* src/sort.c (main): Likewise.
(usage): Convert each TAB in --help output to a sequence of 8 spaces.
2001-01-07 Jim Meyering <meyering@lucent.com>
* src/tail.c (usage): Split a string that was longer than 2048 bytes.
2001-01-03 Jim Meyering <meyering@lucent.com>
* src/sort.c (main): Remove embedded \n from diagnostic.
2001-01-02 Jim Meyering <meyering@lucent.com>
* src/od.c (ulonglong_t): Define place-holder type to avoid some #if
directives.
(LONGEST_INTEGRAL_TYPE): Remove definition.
(MAX_INTEGRAL_TYPE_SIZE): Use ulonglong_t instead of
LONGEST_INTEGRAL_TYPE.
(print_long_long): Compile this function even on systems without
long long support.
(decode_one_format): Remove #if directive.
* src/od.c (decode_one_format): Guard use of print_long_long with
`#if HAVE_UNSIGNED_LONG_LONG'. From Darren Salt.
Change all `#ifdef HAVE_UNSIGNED_LONG_LONG' to use `#if' instead.
2000-12-23 Jim Meyering <meyering@lucent.com>
* src/sys2.h [HAVE_INTTYPES_H]: Include <inttypes.h>.
2000-12-19 Jim Meyering <meyering@lucent.com>
* Version 2.0.11.
2000-12-18 Paul Eggert <eggert@twinsun.com>
* NEWS, doc/textutils.texi: New "sort" option -S SIZE.
* src/sys2.h (UINTMAX_MAX): New macro, taken from C99.
* src/sort.c: Include physmem.h.
(SORTALLOC, mergealloc, LINEALLOC): Remove.
(sortalloc): Default to zero at program startup.
(SORTALLOC_MIN, SORTALLOC_DEFAULT_MIN): New macros.
(usage, main): Add support for new -S SIZE option.
(specify_sort_size, default_sort_size): New functions.
(initlines): Do not let alloc exceed limit.
(findlines): Likewise.
(checkfp, mergefps, sort): Use sortalloc to size everything
else, instead of relying on precomputed sizes.
2000-12-17 Jim Meyering <meyering@lucent.com>
* doc/texinfo.tex: Update from master repository.
* config.sub: Likewise.
* config.guess: Likewise.
2000-12-11 Jim Meyering <meyering@lucent.com>
* Version 2.0.10.
2000-12-07 Jim Meyering <meyering@lucent.com>
* src/od.c (address_base): Declare to be static.
2000-12-06 Paul Eggert <eggert@twinsun.com>
* src/od.c (address_base, address_pad_len): New var.
(output_address_fmt_string, address_fmt_buffer, address_pad): Remove.
(flag_pseudo_start): Now int, not long int.
(pseudo_offset): Now off_t, not long int.
(n_specs, n_specs_allocated): Now size_t, not unsigned int.
(format_address, format_address_none, format_address_std,
format_address_label): Now accepts an extra char argument (an extra
char to print if nonzero), and prints instead of returning a string.
All callers changed.
(bytes_per_block): Now size_t, not int.
(format_address_none): Do not even print the extra char argument.
This simplifies the callers.
(format_address_std, format_address_label): Print off_t ourself
instead of trying to use autoconfigured format. This is faster and
more portable.
(format_address_paren): New function.
(dump): Remove unnecessary cast.
(expand_address_fmt): Remove.
(main): Use size_t, off_t, etc. instead of builtin types where this is
advisable. Adjust to above changes. Remove unnecessary cast.
2000-12-03 Jim Meyering <meyering@lucent.com>
* src/tail.c (tail_file): Initialize ignore, dev, and ino members,
when tailing forever and the open failed. Otherwise, we could get
uninitialized memory references of those fields in recheck.
* tests/tail-2/Makefile.am (TESTS): Add assert-2.
* tests/tail-2/assert-2: New file.
* Version 2.0.9.
Make od print valid addresses for offsets of 2^32 and larger, and
allow byte offset (-j) and byte count (-N) to be 2^32 and larger.
* src/od.c (MAX_ADDRESS_LENGTH): Don't hard-code as a literal.
Rather, define in terms of the type, off_t.
(string_min): Declare to be of type size_t.
(flag_dump_strings): Declare to be of type int.
(print_s_char): Declare the n_bytes parameter and the local, `i',
to be of type off_t.
(print_char): Likewise.
(print_s_short): Likewise.
(print_short): Likewise.
(print_int): Likewise.
(print_long): Likewise.
(print_long_long): Likewise.
(print_float): Likewise.
(print_double): Likewise.
(print_long_double): Likewise.
(dump_hexl_mode_trailer): Likewise.
(print_named_ascii): Likewise.
(print_ascii): Likewise.
(write_block): Likewise.
(print_ascii): Declare local, `print_function' with a prototype.
Change a few `>' comparisons to the equivalent `<' form.
(parse_options): Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if the specified offset if larger than OFF_T_MAX.
(dump_strings): Declare local `i' to be of type size_t.
Remove the now-unnecessary cast-to-off_t.
(main) [IF_LINT]: Initialize desired_width to avoid a warning.
Declare `tmp' to be of type uintmax_t.
Use xstrtoumax, not xstrtoul.
Fail if minimum string length is larger than SIZE_MAX.
Fail if specified width is larger than ULONG_MAX.
* src/od.c (format_address): Use off_t, not long unsigned_int as the
parameter type.
(format_address_none): Likewise. Mark parameter as unused.
(format_address_std): Likewise.
(format_address_label): Likewise.
(print_ascii): Mark format string parameter as unused.
(write_block): Use off_t, not long unsigned_int as offset type.
(expand_address_fmt): New function.
(main): Use it to expand each address format string template.
Reported by Mark Nudelman, via Andreas Jaeger.
* src/sys2.h (OFF_T_MIN): Define here instead.
(OFF_T_MAX): Likewise.
(CHAR_BIT): Define.
* src/tail.c (parse_options): Use xstrtoumax to parse the byte and line
offset. Give a better diagnostic when the requested offset is still
representable but larger than OFF_T_MAX.
(OFF_T_MIN): Remove definition.
(OFF_T_MAX): Likewise.
2000-12-02 Jim Meyering <meyering@lucent.com>
* src/sort.c (checkfp): Rename local `buf' to avoid shadowing previous
declaration.
* src/sort.c (NONZERO): Define and use it to make the code a tiny
bit more readable.
* doc/textutils.texi (sort invocation): Clarify how -t works
when a sort key specifies a range of fields. From Karl O. Pinc.
2000-11-26 Paul Eggert <eggert@twinsun.com>
* src/od.c (skip): Use lseek instead of worrying about fseeko or fseek.
This should be portable, as we seek before doing any I/O.
(fseeko): Remove; no longer used.
2000-11-30 Jim Meyering <meyering@lucent.com>
* src/sort.c: s/SIZE_T_MAX/SIZE_MAX/.
2000-11-30 Paul Eggert <eggert@twinsun.com>
* src/sys2.h: Include <stdint.h> if HAVE_STDINT_H.
(SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX.
All uses changed.
2000-11-30 Jim Meyering <meyering@lucent.com>
* src/sort.c: SIZE_MAX is not defined, so s/SIZE_MAX/SIZE_T_MAX/, and...
* src/sys2.h (SIZE_T_MAX): ... define.
2000-11-29 Paul Eggert <eggert@twinsun.com>
Port GNU "sort" to hosts where sizes don't fit in "int",
e.g. 64-bit Solaris (sparc).
* src/sort.c ("human.h", "xstrtol.h"): Include.
(struct line): length member is now size_t, not int.
(struct lines): Likewise for used, alloc, limit members.
(struct buffer): Likewise for used, alloc, left, newline_free members.
(struct keyfield): Likewise for sword, schar, eword, echar members.
(sortalloc, mergealloc, linelength): Now size_t, not int.
(initbuf, fillbuf, initlines, begfield, limfield, findlines,
numcompare, getmonth, keycompare, compare, checkfp, mergefps,
sortlines, sort): Accept, return, and use size_t for sizes, not int.
(fillbuf, initlines, findlines, checkfp, sort): Check for overflow
when computing buffer sizes.
(begfield, limfield): Do not index past end of array.
(checkfp): Return a boolean, not a line number, as the line
number may not fit in int. All callers changed. Use
uintmax_t for line numbers, not int.
(sort): Don't allocate tmp until we need it (and know the right size).
(parse_field_count): New function.
(main): Use it to check for overflow in field counts.
"outfile" is now a pointer to const.
2000-11-27 Jim Meyering <meyering@lucent.com>
* src/checksum.h: Don't include system.h here.
* src/md5.c: Include config.h, stdio.h, sys/types.h. and system.h here
instead.

View File

@@ -1,5 +1,14 @@
Changes in release 2.1
[2.0.11]
* sort accepts new -S SIZE option, to specify main-memory usage.
[2.0.10]
* od is faster and more portable than it was in 2.0.9
* tail avoids an uninitialized memory reference
[2.0.9]
* od now prints valid addresses for offsets of 2^32 and larger, and allows
the byte offset (-j) and byte count (-N) arguments to be 2^32 and larger.
* tail now works with line and byte counts of 2^32 and larger, on systems
with large file support
* join now works with an 8-bit delimiter
* fix a compilation failure on some Solaris systems with wc.c
[2.0.8]

View File

@@ -150,6 +150,13 @@ install-data-yes: all
true; \
fi; \
fi; \
if test "$(PACKAGE)" = "fileutils"; then \
timedir=$$destdir/$$lang/LC_TIME; \
rm -fr $$timedir; \
ln -s LC_MESSAGES $$timedir \
|| (mkdir $$timedir && ln $$dir/* $$timedir); \
echo "installing $$timedir as an alias for $$dir"; \
fi; \
done
if test "$(PACKAGE)" = "gettext"; then \
if test -x "$(MKINSTALLDIRS)"; then \
@@ -206,20 +213,25 @@ dist distdir: update-po $(DISTFILES)
update-po: Makefile
$(MAKE) $(PACKAGE).pot
PATH=`pwd`/../src:$$PATH; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
mv $$lang.po $$lang.old.po; \
echo "$$lang:"; \
if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \
rm -f $$lang.old.po; \
if $(MSGMERGE) $(srcdir)/$$lang.po \
$(srcdir)/$(PACKAGE).pot -o $$lang.new.po; then \
if cmp $$lang.new.po $(srcdir)/$$lang.po >/dev/null; then \
echo "$$lang.po is unchanged"; \
rm -f $$lang.new.po; \
else \
echo "updating $$lang.po"; \
rm -f $(srcdir)/$$lang.po; \
mv $$lang.new.po $(srcdir)/$$lang.po; \
fi; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$lang.po; \
mv $$lang.old.po $$lang.po; \
rm -f $$lang.new.po; \
exit 1; \
fi; \
done

View File

@@ -1,5 +1,5 @@
/* chgrp -- change group ownership of files
Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 89, 90, 91, 1995-2001 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
@@ -30,6 +30,7 @@
#include "quote.h"
#include "savedir.h"
#include "xstrtol.h"
#include "chown-core.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "chgrp"
@@ -52,54 +53,9 @@ struct group *getgrnam ();
# define endgrent() ((void) 0)
#endif
enum Change_status
{
CH_NOT_APPLIED,
CH_SUCCEEDED,
CH_FAILED,
CH_NO_CHANGE_REQUESTED
};
enum Verbosity
{
/* Print a message for each file that is processed. */
V_high,
/* Print a message for each file whose attributes we change. */
V_changes_only,
/* Do not be verbose. This is the default. */
V_off
};
int lstat ();
static int change_dir_group PARAMS ((const char *dir, gid_t group,
const struct stat *statp));
/* The name the program was run with. */
char *program_name;
/* If nonzero, and the systems has support for it, change the ownership
of symbolic links rather than any files they point to. */
static int change_symlinks = 1;
/* When change_symlinks is set, this should be set to `lstat', otherwise,
it should be `stat'. */
static int (*xstat) ();
/* If nonzero, change the ownership of directories recursively. */
static int recurse;
/* If nonzero, force silence (no error messages). */
static int force_silent;
/* Level of verbosity. */
static enum Verbosity verbosity = V_off;
/* The name of the group to which ownership of the files is being given. */
static const char *groupname;
/* The argument to the --reference option. Use the group ID of this file.
This file must exist. */
static char *reference_file;
@@ -127,38 +83,6 @@ static struct option const long_options[] =
{0, 0, 0, 0}
};
/* Tell the user how/if the group of FILE has been changed.
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, enum Change_status changed)
{
const char *fmt;
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
quote (file));
return;
}
switch (changed)
{
case CH_SUCCEEDED:
fmt = _("group of %s changed to %s\n");
break;
case CH_FAILED:
fmt = _("failed to change group of %s to %s\n");
break;
case CH_NO_CHANGE_REQUESTED:
fmt = _("group of %s retained as %s\n");
break;
default:
abort ();
}
printf (fmt, quote (file), groupname);
}
/* Set *G according to NAME. */
static void
@@ -166,9 +90,8 @@ parse_group (const char *name, gid_t *g)
{
struct group *grp;
groupname = name;
if (*name == '\0')
error (1, 0, _("can not change to null group"));
error (1, 0, _("cannot change to null group"));
grp = getgrnam (name);
if (grp == NULL)
@@ -193,139 +116,6 @@ parse_group (const char *name, gid_t *g)
endgrent (); /* Save a file descriptor. */
}
/* Change the ownership of FILE to GID GROUP.
If it is a directory and -R is given, recurse.
Return 0 if successful, 1 if errors occurred. */
static int
change_file_group (int cmdline_arg, const char *file, gid_t group)
{
struct stat file_stats;
int errors = 0;
if ((*xstat) (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
if (group != file_stats.st_gid)
{
int fail;
int symlink_changed = 1;
int saved_errno;
if (S_ISLNK (file_stats.st_mode) && change_symlinks)
{
fail = lchown (file, (uid_t) -1, group);
/* Ignore the failure if it's due to lack of support (ENOSYS)
and this is not a command line argument. */
if (!cmdline_arg && fail && errno == ENOSYS)
{
fail = 0;
symlink_changed = 0;
}
}
else
{
fail = chown (file, (uid_t) -1, group);
}
/* Save errno, since in verbose mode, describe_change might change it. */
saved_errno = errno;
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
{
enum Change_status ch_status = (! symlink_changed ? CH_NOT_APPLIED
: (fail ? CH_FAILED : CH_SUCCEEDED));
describe_change (file, ch_status);
}
if (fail)
{
errors = 1;
if (force_silent == 0)
{
/* Give a more specific message. Some systems set errno
to EPERM for both `inaccessible file' and `user not a member
of the specified group' errors. */
if (saved_errno == EPERM && !group_member (group))
{
error (0, saved_errno, _("you are not a member of group %s"),
quote (groupname));
}
else if (saved_errno == EINVAL && group > MAXUID)
{
error (0, 0, _("%s: invalid group number"),
quote (groupname));
}
else
{
error (0, saved_errno, _("changing group of %s"),
quote (file));
}
}
}
}
else if (verbosity == V_high)
{
describe_change (file, CH_NO_CHANGE_REQUESTED);
}
if (recurse && S_ISDIR (file_stats.st_mode))
errors |= change_dir_group (file, group, &file_stats);
return errors;
}
/* Recursively change the ownership of the files in directory DIR
to GID GROUP.
STATP points to the results of lstat on DIR.
Return 0 if successful, 1 if errors occurred. */
static int
change_dir_group (const char *dir, gid_t group, const struct stat *statp)
{
char *name_space, *namep;
char *path; /* Full path of each entry to process. */
unsigned dirlength; /* Length of `dir' and '\0'. */
unsigned filelength; /* Length of each pathname to process. */
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (force_silent == 0)
error (0, errno, "%s", quote (dir));
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
pathlength = dirlength + 1;
/* Give `path' a dummy value; it will be reallocated before first use. */
path = xmalloc (pathlength);
strcpy (path, dir);
path[dirlength - 1] = '/';
for (namep = name_space; *namep; namep += filelength - dirlength)
{
filelength = dirlength + strlen (namep) + 1;
if (filelength > pathlength)
{
pathlength = filelength * 2;
path = xrealloc (path, pathlength);
}
strcpy (path + dirlength, namep);
errors |= change_file_group (0, path, group);
}
free (path);
free (name_space);
return errors;
}
void
usage (int status)
{
@@ -364,9 +154,10 @@ Change the group membership of each FILE to GROUP.\n\
int
main (int argc, char **argv)
{
gid_t group;
gid_t gid;
int errors = 0;
int optc;
struct Chown_option chopt;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -375,7 +166,7 @@ main (int argc, char **argv)
atexit (close_stdout);
recurse = force_silent = 0;
chopt_init (&chopt);
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
{
@@ -387,22 +178,22 @@ main (int argc, char **argv)
reference_file = optarg;
break;
case DEREFERENCE_OPTION:
change_symlinks = 0;
chopt.dereference = DEREF_ALWAYS;
break;
case 'R':
recurse = 1;
chopt.recurse = 1;
break;
case 'c':
verbosity = V_changes_only;
chopt.verbosity = V_changes_only;
break;
case 'f':
force_silent = 1;
chopt.force_silent = 1;
break;
case 'h':
change_symlinks = 1;
chopt.dereference = DEREF_NEVER;
break;
case 'v':
verbosity = V_high;
chopt.verbosity = V_high;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -417,24 +208,26 @@ main (int argc, char **argv)
usage (1);
}
if (change_symlinks)
xstat = lstat;
else
xstat = stat;
if (reference_file)
{
struct stat ref_stats;
if (stat (reference_file, &ref_stats))
error (1, errno, _("getting attributes of %s"), quote (reference_file));
group = ref_stats.st_gid;
chopt.group_name = gid_to_name (ref_stats.st_gid);
gid = ref_stats.st_gid;
}
else
parse_group (argv[optind++], &group);
{
chopt.group_name = argv[optind++];
parse_group (chopt.group_name, &gid);
}
for (; optind < argc; ++optind)
errors |= change_file_group (1, argv[optind], group);
errors |= change_file_owner (1, argv[optind], (uid_t) -1, gid,
(uid_t) -1, (gid_t) -1, &chopt);
chopt_free (&chopt);
exit (errors);
}

366
src/chown-core.c Normal file
View File

@@ -0,0 +1,366 @@
/* chown-core.c -- core functions for changing ownership.
Copyright (C) 2000 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
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. */
/* Extracted from chown.c/chgrp.c and librarified by Jim Meyering. */
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
#include "system.h"
#include "error.h"
#include "lchown.h"
#include "quote.h"
#include "savedir.h"
#include "chown-core.h"
#include "xalloc.h"
/* The number of decimal digits required to represent the largest value of
type `unsigned int'. This is enough for an 8-byte unsigned int type. */
#define UINT_MAX_DECIMAL_DIGITS 20
#ifndef _POSIX_VERSION
struct group *getgrnam ();
struct group *getgrgid ();
#endif
int lstat ();
void
chopt_init (struct Chown_option *chopt)
{
chopt->verbosity = V_off;
chopt->dereference = DEREF_NEVER;
chopt->recurse = 0;
chopt->force_silent = 0;
chopt->user_name = 0;
chopt->group_name = 0;
}
void
chopt_free (struct Chown_option *chopt)
{
/* Deliberately do not free chopt->user_name or ->group_name.
They're not always allocated. */
}
/* Convert N to a string, and return a pointer to that string in memory
allocated from the heap. */
static char *
uint_to_string (unsigned int n)
{
char buf[UINT_MAX_DECIMAL_DIGITS + 1];
char *p = buf + sizeof buf;
*--p = '\0';
do
*--p = '0' + (n % 10);
while ((n /= 10) != 0);
return xstrdup (p);
}
/* Convert the numeric group-id, GID, to a string stored in xmalloc'd memory,
and return it. If there's no corresponding group name, use the decimal
representation of the ID. */
char *
gid_to_name (gid_t gid)
{
struct group *grp = getgrgid (gid);
return grp ? xstrdup (grp->gr_name) : uint_to_string (gid);
}
/* Convert the numeric user-id, UID, to a string stored in xmalloc'd memory,
and return it. If there's no corresponding user name, use the decimal
representation of the ID. */
char *
uid_to_name (uid_t uid)
{
struct passwd *pwd = getpwuid (uid);
return pwd ? xstrdup (pwd->pw_name) : uint_to_string (uid);
}
/* Tell the user how/if the user and group of FILE have been changed.
If USER is NULL, give the group-oriented messages.
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, enum Change_status changed,
char const *user, char const *group)
{
const char *fmt;
char *spec;
int spec_allocated = 0;
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
quote (file));
return;
}
if (user)
{
if (group)
{
spec = xmalloc (strlen (user) + 1 + strlen (group) + 1);
stpcpy (stpcpy (stpcpy (spec, user), ":"), group);
spec_allocated = 1;
}
else
{
spec = (char *) user;
}
}
else
{
spec = (char *) group;
}
switch (changed)
{
case CH_SUCCEEDED:
fmt = (user
? _("changed ownership of %s to %s\n")
: _("changed group of %s to %s\n"));
break;
case CH_FAILED:
fmt = (user
? _("failed to change ownership of %s to %s\n")
: _("failed to change group of %s to %s\n"));
break;
case CH_NO_CHANGE_REQUESTED:
fmt = (user
? _("ownership of %s retained as %s\n")
: _("group of %s retained as %s\n"));
break;
default:
abort ();
}
printf (fmt, quote (file), spec);
if (spec_allocated)
free (spec);
}
/* Recursively change the ownership of the files in directory DIR to user-id,
UID, and group-id, GID, according to the options specified by CHOPT.
STATP points to the results of lstat on DIR.
Return 0 if successful, 1 if errors occurred. */
static int
change_dir_owner (const char *dir, uid_t uid, gid_t gid,
uid_t old_uid, gid_t old_gid,
const struct stat *statp,
struct Chown_option const *chopt)
{
char *name_space, *namep;
char *path; /* Full path of each entry to process. */
unsigned dirlength; /* Length of `dir' and '\0'. */
unsigned filelength; /* Length of each pathname to process. */
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (chopt->force_silent == 0)
error (0, errno, "%s", quote (dir));
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
pathlength = dirlength + 1;
/* Give `path' a dummy value; it will be reallocated before first use. */
path = xmalloc (pathlength);
strcpy (path, dir);
path[dirlength - 1] = '/';
for (namep = name_space; *namep; namep += filelength - dirlength)
{
filelength = dirlength + strlen (namep) + 1;
if (filelength > pathlength)
{
pathlength = filelength * 2;
path = xrealloc (path, pathlength);
}
strcpy (path + dirlength, namep);
errors |= change_file_owner (0, path, uid, gid, old_uid, old_gid,
chopt);
}
free (path);
free (name_space);
return errors;
}
/* Change the ownership of FILE to user-id, UID, and group-id, GID,
provided it presently has owner OLD_UID and group OLD_GID.
Honor the options specified by CHOPT.
If FILE is a directory and -R is given, recurse.
Return 0 if successful, 1 if errors occurred. */
int
change_file_owner (int cmdline_arg, const char *file, uid_t uid, gid_t gid,
uid_t old_uid, gid_t old_gid,
struct Chown_option const *chopt)
{
struct stat file_stats;
uid_t new_uid;
gid_t new_gid;
int errors = 0;
int is_symlink;
int is_directory;
if (lstat (file, &file_stats))
{
if (chopt->force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
/* If it's a symlink and we're dereferencing, then use stat
to get the attributes of the referent. */
if (S_ISLNK (file_stats.st_mode))
{
if (chopt->dereference == DEREF_ALWAYS
&& stat (file, &file_stats))
{
if (chopt->force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
is_symlink = 1;
/* With -R, don't traverse through symlinks-to-directories.
But of course, this will all change with POSIX's new
-H, -L, -P options. */
is_directory = 0;
}
else
{
is_symlink = 0;
is_directory = S_ISDIR (file_stats.st_mode);
}
if ((old_uid == (uid_t) -1 || file_stats.st_uid == old_uid)
&& (old_gid == (gid_t) -1 || file_stats.st_gid == old_gid))
{
new_uid = (uid == (uid_t) -1 ? file_stats.st_uid : uid);
new_gid = (gid == (gid_t) -1 ? file_stats.st_gid : gid);
if (new_uid != file_stats.st_uid || new_gid != file_stats.st_gid)
{
int fail;
int symlink_changed = 1;
int saved_errno;
int called_lchown = 0;
if (is_symlink)
{
if (chopt->dereference == DEREF_NEVER)
{
called_lchown = 1;
fail = lchown (file, new_uid, new_gid);
/* Ignore the failure if it's due to lack of support (ENOSYS)
and this is not a command line argument. */
if (!cmdline_arg && fail && errno == ENOSYS)
{
fail = 0;
symlink_changed = 0;
}
}
else if (chopt->dereference == DEREF_ALWAYS)
{
/* Applying chown to a symlink and expecting it to affect
the referent is not portable. So instead, open the
file and use fchown on the resulting descriptor. */
int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
fail = (fd == -1 ? 1 : fchown (fd, new_uid, new_gid));
}
else
{
/* FIXME */
abort ();
}
}
else
{
fail = chown (file, new_uid, new_gid);
}
saved_errno = errno;
if (chopt->verbosity == V_high
|| (chopt->verbosity == V_changes_only && !fail))
{
enum Change_status ch_status = (! symlink_changed
? CH_NOT_APPLIED
: (fail
? CH_FAILED : CH_SUCCEEDED));
describe_change (file, ch_status,
chopt->user_name, chopt->group_name);
}
if (fail)
{
if (chopt->force_silent == 0)
error (0, saved_errno, (uid != (uid_t) -1
? _("changing ownership of %s")
: _("changing group of %s")),
quote (file));
errors = 1;
}
else
{
/* The change succeeded. On some systems, the chown function
resets the `special' permission bits. When run by a
`privileged' user, this program must ensure that at least
the set-uid and set-group ones are still set. */
if (file_stats.st_mode & ~(S_IFMT | S_IRWXUGO)
/* If we called lchown above (which means this is a symlink),
then skip it. */
&& ! called_lchown)
{
if (chmod (file, file_stats.st_mode))
{
error (0, saved_errno,
_("unable to restore permissions of %s"),
quote (file));
fail = 1;
}
}
}
}
else if (chopt->verbosity == V_high)
{
describe_change (file, CH_NO_CHANGE_REQUESTED,
chopt->user_name, chopt->group_name);
}
}
if (chopt->recurse && is_directory)
errors |= change_dir_owner (file, uid, gid,
old_uid, old_gid, &file_stats, chopt);
return errors;
}

89
src/chown-core.h Normal file
View File

@@ -0,0 +1,89 @@
/* chown-core.h -- types and prototypes shared by chown and chgrp.
Copyright (C) 2000 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef CHOWN_CORE_H
# define CHOWN_CORE_H
enum Change_status
{
CH_NOT_APPLIED = 1,
CH_SUCCEEDED,
CH_FAILED,
CH_NO_CHANGE_REQUESTED
};
enum Verbosity
{
/* Print a message for each file that is processed. */
V_high,
/* Print a message for each file whose attributes we change. */
V_changes_only,
/* Do not be verbose. This is the default. */
V_off
};
enum Dereference_symlink
{
DEREF_UNDEFINED = 1,
DEREF_NEVER, /* -P */
DEREF_COMMAND_LINE_ARGUMENTS, /* -H */
DEREF_ALWAYS /* -L */
};
struct Chown_option
{
/* Level of verbosity. */
enum Verbosity verbosity;
/* If nonzero, change the ownership of directories recursively. */
int recurse;
/* This is useful only on systems with support for changing the
ownership of symbolic links. */
enum Dereference_symlink dereference;
/* If nonzero, force silence (no error messages). */
int force_silent;
/* The name of the user to which ownership of the files is being given. */
char *user_name;
/* The name of the group to which ownership of the files is being given. */
char *group_name;
};
void
chopt_init (struct Chown_option *);
void
chopt_free (struct Chown_option *);
char *
gid_to_name (gid_t);
char *
uid_to_name (uid_t);
int
change_file_owner PARAMS ((int, const char *,
uid_t, gid_t,
uid_t, gid_t,
struct Chown_option const *));
#endif /* CHOWN_CORE_H */

View File

@@ -1,5 +1,5 @@
/* chown -- change user and group ownership of files
Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,8 +31,6 @@
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
#include <getopt.h>
#include "system.h"
@@ -40,6 +38,7 @@
#include "lchown.h"
#include "quote.h"
#include "savedir.h"
#include "chown-core.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "chown"
@@ -59,52 +58,9 @@ struct group *getgrgid ();
char *parse_user_spec ();
void strip_trailing_slashes ();
enum Change_status
{
CH_NOT_APPLIED,
CH_SUCCEEDED,
CH_FAILED,
CH_NO_CHANGE_REQUESTED
};
enum Verbosity
{
/* Print a message for each file that is processed. */
V_high,
/* Print a message for each file whose attributes we change. */
V_changes_only,
/* Do not be verbose. This is the default. */
V_off
};
static int change_dir_owner PARAMS ((const char *dir, uid_t user, gid_t group,
uid_t old_user, gid_t old_group,
const struct stat *statp));
/* The name the program was run with. */
char *program_name;
/* If nonzero, and the systems has support for it, change the ownership
of symbolic links rather than any files they point to. */
static int change_symlinks = 1;
/* If nonzero, change the ownership of directories recursively. */
static int recurse;
/* If nonzero, force silence (no error messages). */
static int force_silent;
/* Level of verbosity. */
static enum Verbosity verbosity = V_off;
/* The name of the user to which ownership of the files is being given. */
static char *username;
/* The name of the group to which ownership of the files is being given. */
static const char *groupname;
/* The argument to the --reference option. Use the owner and group IDs
of this file. This file must exist. */
static char *reference_file;
@@ -134,169 +90,6 @@ static struct option const long_options[] =
{0, 0, 0, 0}
};
/* Tell the user how/if the user and group of FILE have been changed.
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, enum Change_status changed)
{
const char *fmt;
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
quote (file));
return;
}
switch (changed)
{
case CH_SUCCEEDED:
fmt = _("owner of %s changed to ");
break;
case CH_FAILED:
fmt = _("failed to change owner of %s to ");
break;
case CH_NO_CHANGE_REQUESTED:
fmt = _("owner of %s retained as ");
break;
default:
abort ();
}
printf (fmt, file);
if (groupname)
printf ("%s.%s\n", username, groupname);
else
printf ("%s\n", username);
}
/* Change the ownership of FILE to UID USER and GID GROUP
provided it presently has UID OLDUSER and GID OLDGROUP.
If it is a directory and -R is given, recurse.
Return 0 if successful, 1 if errors occurred. */
static int
change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
uid_t old_user, gid_t old_group)
{
struct stat file_stats;
uid_t newuser;
gid_t newgroup;
int errors = 0;
if (lstat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
if ((old_user == (uid_t) -1 || file_stats.st_uid == old_user) &&
(old_group == (gid_t) -1 || file_stats.st_gid == old_group))
{
newuser = user == (uid_t) -1 ? file_stats.st_uid : user;
newgroup = group == (gid_t) -1 ? file_stats.st_gid : group;
if (newuser != file_stats.st_uid || newgroup != file_stats.st_gid)
{
int fail;
int symlink_changed = 1;
int saved_errno;
if (S_ISLNK (file_stats.st_mode) && change_symlinks)
{
fail = lchown (file, newuser, newgroup);
/* Ignore the failure if it's due to lack of support (ENOSYS)
and this is not a command line argument. */
if (!cmdline_arg && fail && errno == ENOSYS)
{
fail = 0;
symlink_changed = 0;
}
}
else
{
fail = chown (file, newuser, newgroup);
}
saved_errno = errno;
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
{
enum Change_status ch_status = (! symlink_changed
? CH_NOT_APPLIED
: (fail
? CH_FAILED : CH_SUCCEEDED));
describe_change (file, ch_status);
}
if (fail)
{
if (force_silent == 0)
error (0, saved_errno, _("changing ownership of %s"),
quote (file));
errors = 1;
}
}
else if (verbosity == V_high)
{
describe_change (file, CH_NO_CHANGE_REQUESTED);
}
}
if (recurse && S_ISDIR (file_stats.st_mode))
errors |= change_dir_owner (file, user, group,
old_user, old_group, &file_stats);
return errors;
}
/* Recursively change the ownership of the files in directory DIR
to UID USER and GID GROUP.
STATP points to the results of lstat on DIR.
Return 0 if successful, 1 if errors occurred. */
static int
change_dir_owner (const char *dir, uid_t user, gid_t group,
uid_t old_user, gid_t old_group,
const struct stat *statp)
{
char *name_space, *namep;
char *path; /* Full path of each entry to process. */
unsigned dirlength; /* Length of `dir' and '\0'. */
unsigned filelength; /* Length of each pathname to process. */
unsigned pathlength; /* Bytes allocated for `path'. */
int errors = 0;
name_space = savedir (dir, statp->st_size);
if (name_space == NULL)
{
if (force_silent == 0)
error (0, errno, "%s", quote (dir));
return 1;
}
dirlength = strlen (dir) + 1; /* + 1 is for the trailing '/'. */
pathlength = dirlength + 1;
/* Give `path' a dummy value; it will be reallocated before first use. */
path = xmalloc (pathlength);
strcpy (path, dir);
path[dirlength - 1] = '/';
for (namep = name_space; *namep; namep += filelength - dirlength)
{
filelength = dirlength + strlen (namep) + 1;
if (filelength > pathlength)
{
pathlength = filelength * 2;
path = xrealloc (path, pathlength);
}
strcpy (path + dirlength, namep);
errors |= change_file_owner (0, path, user, group, old_user, old_group);
}
free (path);
free (name_space);
return errors;
}
void
usage (int status)
{
@@ -333,6 +126,8 @@ Change the owner and/or group of each FILE to OWNER and/or GROUP.\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
"));
printf (_("\
Owner is unchanged if missing. Group is unchanged if missing, but changed\n\
to login group if implied by a `:'. OWNER and GROUP may be numeric as well\n\
as symbolic.\n\
@@ -345,10 +140,11 @@ as symbolic.\n\
int
main (int argc, char **argv)
{
uid_t user = (uid_t) -1; /* New uid; -1 if not to be changed. */
gid_t group = (uid_t) -1; /* New gid; -1 if not to be changed. */
uid_t old_user = (uid_t) -1; /* Old uid; -1 if unrestricted. */
gid_t old_group = (uid_t) -1; /* Old gid; -1 if unrestricted. */
uid_t uid = (uid_t) -1; /* New uid; -1 if not to be changed. */
gid_t gid = (uid_t) -1; /* New gid; -1 if not to be changed. */
uid_t old_uid = (uid_t) -1; /* Old uid; -1 if unrestricted. */
gid_t old_gid = (uid_t) -1; /* Old gid; -1 if unrestricted. */
struct Chown_option chopt;
int errors = 0;
int optc;
@@ -360,7 +156,7 @@ main (int argc, char **argv)
atexit (close_stdout);
recurse = force_silent = 0;
chopt_init (&chopt);
while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
{
@@ -372,32 +168,32 @@ main (int argc, char **argv)
reference_file = optarg;
break;
case DEREFERENCE_OPTION:
change_symlinks = 0;
chopt.dereference = DEREF_ALWAYS;
break;
case FROM_OPTION:
{
char *u_dummy, *g_dummy;
const char *e = parse_user_spec (argv[optind],
&old_user, &old_group,
&old_uid, &old_gid,
&u_dummy, &g_dummy);
if (e)
error (1, 0, "%s: %s", quote (argv[optind]), e);
break;
}
case 'R':
recurse = 1;
chopt.recurse = 1;
break;
case 'c':
verbosity = V_changes_only;
chopt.verbosity = V_changes_only;
break;
case 'f':
force_silent = 1;
chopt.force_silent = 1;
break;
case 'h':
change_symlinks = 1;
chopt.dereference = DEREF_NEVER;
break;
case 'v':
verbosity = V_high;
chopt.verbosity = V_high;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -419,17 +215,21 @@ main (int argc, char **argv)
if (stat (reference_file, &ref_stats))
error (1, errno, _("getting attributes of %s"), quote (reference_file));
user = ref_stats.st_uid;
group = ref_stats.st_gid;
uid = ref_stats.st_uid;
gid = ref_stats.st_gid;
chopt.user_name = uid_to_name (ref_stats.st_uid);
chopt.group_name = gid_to_name (ref_stats.st_gid);
}
else
{
const char *e = parse_user_spec (argv[optind], &user, &group,
&username, &groupname);
const char *e = parse_user_spec (argv[optind], &uid, &gid,
&chopt.user_name, &chopt.group_name);
if (e)
error (1, 0, "%s: %s", argv[optind], e);
if (username == NULL)
username = "";
error (1, 0, "%s: %s", quote (argv[optind]), e);
/* FIXME: set it to the empty string? */
if (chopt.user_name == NULL)
chopt.user_name = "";
optind++;
}
@@ -437,9 +237,11 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
{
strip_trailing_slashes (argv[optind]);
errors |= change_file_owner (1, argv[optind], user, group,
old_user, old_group);
errors |= change_file_owner (1, argv[optind], uid, gid,
old_uid, old_gid, &chopt);
}
chopt_free (&chopt);
exit (errors);
}

View File

@@ -1,5 +1,5 @@
/* cksum -- calculate and print POSIX.2 checksums and sizes of files
Copyright (C) 92, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 92, 1995-2001 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
@@ -296,7 +296,7 @@ main (int argc, char **argv)
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
have_read_stdin = 0;

View File

@@ -1,5 +1,5 @@
/* copy.c -- core functions for copying files and directories
Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation.
Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -67,6 +67,11 @@ static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
int *copy_into_self,
int *rename_succeeded));
/* Pointers to the file names: they're used in the diagnostic that is issued
when we detect the user is trying to copy a directory into itself. */
static char const *top_level_src_path;
static char const *top_level_dst_path;
/* The invocation name of this program. */
extern char *program_name;
@@ -392,8 +397,8 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
{
const struct stat *src_sb_link;
const struct stat *dst_sb_link;
const struct stat *src_sb_no_link;
const struct stat *dst_sb_no_link;
struct stat tmp_dst_sb;
struct stat tmp_src_sb;
int same_link;
int same = (SAME_INODE (*src_sb, *dst_sb));
@@ -417,17 +422,15 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
/* If both the source and destination files are symlinks (and we'll
know this here IFF preserving symlinks (aka xstat == lstat),
then it's ok. */
then it's ok -- as long as they are distinct. */
if (S_ISLNK (src_sb->st_mode) && S_ISLNK (dst_sb->st_mode))
return 1;
return ! same_name (src_path, dst_path);
src_sb_link = src_sb;
dst_sb_link = dst_sb;
}
else
{
static struct stat tmp_dst_sb;
static struct stat tmp_src_sb;
if (!same)
return 1;
@@ -491,7 +494,7 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
return 1;
/* If neither is a symlink, then it's ok as long as they aren't
links to the same file. */
hard links to the same file. */
if (!S_ISLNK (src_sb_link->st_mode) && !S_ISLNK (dst_sb_link->st_mode))
{
if (!SAME_INODE (*src_sb_link, *dst_sb_link))
@@ -506,19 +509,25 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
}
/* It's ok to remove a destination symlink. But that works only when we
unlink before opening the destination and when they're on the same
partition. */
unlink before opening the destination and when the source and destination
files are on the same partition. */
if (x->unlink_dest_before_opening
&& S_ISLNK (dst_sb_link->st_mode))
return src_sb_link->st_dev == src_sb_link->st_dev;
return dst_sb_link->st_dev == src_sb_link->st_dev;
if (x->xstat == lstat)
{
static struct stat tmp_dst_sb;
static struct stat tmp_src_sb;
if (stat (dst_path, &tmp_dst_sb)
|| stat (src_path, &tmp_src_sb)
|| ! SAME_INODE (tmp_dst_sb, tmp_dst_sb))
if ( ! S_ISLNK (src_sb_link->st_mode))
tmp_src_sb = *src_sb_link;
else if (stat (src_path, &tmp_src_sb))
return 1;
if ( ! S_ISLNK (dst_sb_link->st_mode))
tmp_dst_sb = *dst_sb_link;
else if (stat (dst_path, &tmp_dst_sb))
return 1;
if ( ! SAME_INODE (tmp_src_sb, tmp_dst_sb))
return 1;
/* FIXME: shouldn't this be testing whether we're making symlinks? */
@@ -527,13 +536,6 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
*return_now = 1;
return 1;
}
src_sb_no_link = &tmp_src_sb;
dst_sb_no_link = &tmp_dst_sb;
}
else
{
src_sb_no_link = src_sb;
dst_sb_no_link = dst_sb;
}
return 0;
@@ -586,6 +588,10 @@ copy_internal (const char *src_path, const char *dst_path,
find created files so as to not copy infinitely if a directory is
copied into itself. */
/* Associate the destination path with the source device and inode
so that if we encounter a matching dev/ino pair in the source tree
we can arrange to create a hard link between the corresponding names
in the destination tree. */
earlier_file = remember_copied (dst_path, src_sb.st_ino, src_sb.st_dev);
src_mode = src_sb.st_mode;
@@ -626,6 +632,14 @@ copy_internal (const char *src_path, const char *dst_path,
return 1;
}
if (S_ISDIR (src_type) && !S_ISDIR (dst_sb.st_mode))
{
error (0, 0,
_("cannot overwrite non-directory %s with directory %s"),
quote_n (0, dst_path), quote_n (1, src_path));
return 1;
}
if (!S_ISDIR (src_type))
{
if (S_ISDIR (dst_sb.st_mode))
@@ -759,8 +773,21 @@ copy_internal (const char *src_path, const char *dst_path,
directories). */
if (S_ISDIR (src_type))
{
error (0, 0, _("won't create hard link %s to directory %s"),
quote_n (0, dst_path), quote_n (1, earlier_file));
/* If src_path and earlier_file refer to the same directory entry,
then warn about copying a directory into itself. */
if (same_name (src_path, earlier_file))
{
error (0, 0, _("cannot copy a directory, %s, into itself, %s"),
quote_n (0, top_level_src_path),
quote_n (1, top_level_dst_path));
*copy_into_self = 1;
}
else
{
error (0, 0, _("will not create hard link %s to directory %s"),
quote_n (0, dst_path), quote_n (1, earlier_file));
}
goto un_backup;
}
@@ -806,7 +833,13 @@ copy_internal (const char *src_path, const char *dst_path,
/* FIXME: this is a little fragile in that it relies on rename(2)
failing with a specific errno value. Expect problems on
non-POSIX systems. */
error (0, 0, _("cannot move %s to a subdirectory of itself, %s"),
quote_n (0, top_level_src_path),
quote_n (1, top_level_dst_path));
*copy_into_self = 1;
/* FIXME-cleanup: Don't return zero here; adjust mv.c accordingly.
The only caller that uses this code (mv.c) ends up setting its
exit status to nonzero when copy_into_self is nonzero. */
return 0;
}
@@ -1170,6 +1203,17 @@ copy (const char *src_path, const char *dst_path,
int move_mode = options->move_mode;
assert (valid_options (options));
/* Record the file names: they're used in case of error, when copying
a directory into itself. I don't like to make these tools do *any*
extra work in the common case when that work is solely to handle
exceptional cases, but in this case, I don't see a way to derive the
top level source and destination directory names where they're used.
An alternative is to use COPY_INTO_SELF and print the diagnostic
from every caller -- but I don't wan't to do that. */
top_level_src_path = src_path;
top_level_dst_path = dst_path;
return copy_internal (src_path, dst_path, nonexistent_dst, 0, NULL,
options, move_mode, copy_into_self, rename_succeeded);
}

View File

@@ -142,6 +142,17 @@ int rpl_lstat PARAMS((const char *, struct stat *));
# define lstat rpl_lstat
# endif
int rename ();
/* Arrange to make rename calls go through the wrapper function
on systems with a rename function that fails for a source path
specified with a trailing slash. */
# if RENAME_TRAILING_SLASH_BUG
int rpl_rename PARAMS((const char *, const char *));
# undef rename
# define rename rpl_rename
# endif
int
copy PARAMS ((const char *src_path, const char *dst_path,
int nonexistent_dst, const struct cp_options *options,

View File

@@ -1,5 +1,5 @@
/* cp-hash.c -- file copying (hash search routines)
Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation.
Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,7 +33,11 @@ struct entry
{
ino_t ino;
dev_t dev;
char *node; /* Path name, or &new_file for new inodes. */
/* Destination path name (of non-directory or pre-existing directory)
corresponding to the dev/ino of a copied file, or the destination path
name corresponding to a dev/ino pair for a newly-created directory. */
char *node;
struct entry *coll_link; /* 0 = entry not occupied. */
};
@@ -46,8 +50,7 @@ struct htab
struct entry *hash[1]; /* Vector of pointers in `entry_tab'. */
};
struct htab *htab;
char new_file;
static struct htab *htab;
static char *cph_hash_insert PARAMS ((ino_t ino, dev_t dev, const char *node));
@@ -65,7 +68,7 @@ remember_created (const char *path)
return 1;
}
cph_hash_insert (sb.st_ino, sb.st_dev, &new_file);
cph_hash_insert (sb.st_ino, sb.st_dev, path);
return 0;
}

View File

@@ -1,5 +1,5 @@
/* cp.c -- file copying (main routines)
Copyright (C) 89, 90, 91, 1995-2000 Free Software Foundation.
Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -124,7 +124,7 @@ static struct option const long_opts[] =
{"preserve", no_argument, NULL, 'p'},
{"recursive", no_argument, NULL, 'R'},
{"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
{"strip-trailing-slash", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
{"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
@@ -172,6 +172,8 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
special files like FIFOs or /dev/zero\n\
--remove-destination remove each existing destination file before\n\
attempting to open it (contrast with --force)\n\
"));
printf (_("\
--sparse=WHEN control creation of sparse files\n\
-R, --recursive copy directories recursively\n\
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\

View File

@@ -1,5 +1,5 @@
/* date - print or set the system date and time
Copyright (C) 1989-2000 Free Software Foundation, Inc.
Copyright (C) 1989-2001 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
@@ -355,6 +355,15 @@ argument must be a format string beginning with `+'."),
usage (1);
}
/* Simply ignore --rfc-822 if specified when setting the date. */
if (rfc_format && !set_date && n_args > 0)
{
error (0, 0,
_("a format string may not be specified when using\
the --rfc-822 (-R) option"));
usage (1);
}
if (set_date)
datestr = set_datestr;

View File

@@ -1,5 +1,5 @@
/* dd -- convert a file while copying it.
Copyright (C) 85, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 85, 90, 91, 1995-2001 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
@@ -103,15 +103,9 @@ static size_t conversion_blocksize = 0;
/* Skip this many records of `input_blocksize' bytes before input. */
static uintmax_t skip_records = 0;
/* Nonzero if SKIP_RECORDS is actually a byte count, not a record count. */
static int skip_bytes = 0;
/* Skip this many records of `output_blocksize' bytes before output. */
static uintmax_t seek_records = 0;
/* Nonzero if SEEK_RECORDS is actually a byte count, not a record count. */
static int seek_bytes = 0;
/* Copy only this many records. The default is effectively infinity. */
static uintmax_t max_records = (uintmax_t) -1;
@@ -311,7 +305,6 @@ Copy a file, converting and formatting according to the options.\n\
BLOCKS and BYTES may be followed by the following multiplicative suffixes:\n\
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,\n\
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.\n\
For seek= and skip=, a B suffix for BLOCKS means it counts bytes not blocks.\n\
Each KEYWORD may be:\n\
\n\
ascii from EBCDIC to ASCII\n\
@@ -566,18 +559,7 @@ scanargs (int argc, char **argv)
else
{
int invalid = 0;
uintmax_t n;
int count_bytes = 0;
if (STREQ (name, "seek") || STREQ (name, "skip"))
{
size_t vallen = strlen (val);
count_bytes = vallen && val[vallen - 1] == 'B';
if (count_bytes)
val[vallen - 1] = '\0';
}
n = parse_integer (val, &invalid);
uintmax_t n = parse_integer (val, &invalid);
if (STREQ (name, "ibs"))
{
@@ -603,15 +585,9 @@ scanargs (int argc, char **argv)
|| conversion_blocksize == 0);
}
else if (STREQ (name, "skip"))
{
skip_records = n;
skip_bytes = count_bytes;
}
skip_records = n;
else if (STREQ (name, "seek"))
{
seek_records = n;
seek_bytes = count_bytes;
}
seek_records = n;
else if (STREQ (name, "count"))
max_records = n;
else
@@ -783,32 +759,23 @@ buggy_lseek_support (int fdesc)
nonzero. */
static void
skip (int fdesc, char *file, int count_bytes, uintmax_t records,
size_t blocksize, unsigned char *buf)
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
unsigned char *buf)
{
size_t seek_blocksize = count_bytes ? 1 : blocksize;
off_t offset = records * seek_blocksize;
off_t offset = records * blocksize;
/* Try lseek and if an error indicates it was an inappropriate
operation, fall back on using read. Some broken versions of
lseek may return zero, so count that as an error too as a valid
zero return is not possible here. */
if (offset / seek_blocksize != records
if (offset / blocksize != records
|| buggy_lseek_support (fdesc)
|| lseek (fdesc, offset, SEEK_CUR) <= 0)
{
if (count_bytes)
records = offset;
while (records)
while (records--)
{
int nread;
if (count_bytes && records < blocksize)
blocksize = records;
nread = safe_read (fdesc, buf, blocksize);
ssize_t nread = safe_read (fdesc, buf, blocksize);
if (nread < 0)
{
error (0, errno, _("reading %s"), quote (file));
@@ -819,8 +786,6 @@ skip (int fdesc, char *file, int count_bytes, uintmax_t records,
FIXME: maybe give a warning. */
if (nread == 0)
break;
records -= (count_bytes ? nread : 1);
}
}
}
@@ -927,7 +892,7 @@ dd_copy (void)
unsigned char *ibuf, *bufstart; /* Input buffer. */
unsigned char *real_buf; /* real buffer address before alignment */
unsigned char *real_obuf;
int nread; /* Bytes read in the current block. */
ssize_t nread; /* Bytes read in the current block. */
int exit_status = 0;
size_t page_size = getpagesize ();
size_t n_bytes_read;
@@ -970,8 +935,7 @@ dd_copy (void)
}
if (skip_records != 0)
skip (STDIN_FILENO, input_file, skip_bytes, skip_records,
input_blocksize, ibuf);
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
if (seek_records != 0)
{
@@ -982,8 +946,7 @@ dd_copy (void)
0+0 records out
*/
skip (STDOUT_FILENO, output_file, seek_bytes, seek_records,
output_blocksize, obuf);
skip (STDOUT_FILENO, output_file, seek_records, output_blocksize, obuf);
}
if (max_records == 0)
@@ -1028,7 +991,7 @@ dd_copy (void)
}
}
n_bytes_read = (size_t) nread;
n_bytes_read = nread;
if (n_bytes_read < input_blocksize)
{
@@ -1148,7 +1111,7 @@ main (int argc, char **argv)
/* Arrange to close stdout if parse_long_options exits. */
atexit (close_stdout_wrapper);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
/* Don't close stdout on exit from here on. */
@@ -1190,9 +1153,8 @@ main (int argc, char **argv)
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
{
struct stat stdout_stat;
size_t blocksize = seek_bytes ? 1 : output_blocksize;
off_t o = seek_records * blocksize;
if (o / blocksize != seek_records)
off_t o = seek_records * output_blocksize;
if (o / output_blocksize != seek_records)
error (1, 0, _("file offset out of range"));
if (fstat (STDOUT_FILENO, &stdout_stat) != 0)

View File

@@ -1,5 +1,5 @@
/* dirname -- strip filename suffix from pathname
Copyright (C) 1990-1997, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1990-1997, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
#include "error.h"
#include "dirname.h"
#include "closeout.h"
#include "xalloc.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "dirname"
@@ -65,8 +66,7 @@ output `.' (meaning the current directory).\n\
int
main (int argc, char **argv)
{
const char *result;
size_t len;
char *result;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -92,9 +92,11 @@ main (int argc, char **argv)
usage (1);
}
len = dir_name_r (argv[1], &result);
fwrite (result, 1, len, stdout);
putchar ('\n');
result = dir_name (argv[1]);
if (result == NULL)
xalloc_die ();
puts (result);
free (result);
exit (0);
}

View File

@@ -1,5 +1,5 @@
/* factor -- print factors of n.
Copyright (C) 86, 1995-2000 Free Software Foundation, Inc.
/* factor -- print prime factors of n.
Copyright (C) 86, 1995-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,6 +45,41 @@
than 2^128, this constant (and the algorithm :-) will have to change. */
#define MAX_N_FACTORS 128
/* The trial divisor increment wheel. Use it to skip over divisors that
are composites of 2, 3, 5, 7, or 11. The part from WHEEL_START up to
WHEEL_END is reused periodically, while the "lead in" is used to test
for those primes and to jump onto the wheel. For more information, see
http://www.utm.edu/research/primes/glossary/WheelFactorization.html */
static const unsigned int wheel_tab[] = {
/* lead in: */ 1, 2, 2, 4, 2, /* and the periodic tail: */
4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4,
2, 4, 2, 4,14, 4, 6, 2,10, 2, 6, 6, 4, 2, 4, 6, 2,10, 2, 4,
2,12,10, 2, 4, 2, 4, 6, 2, 6, 4, 6, 6, 6, 2, 6, 4, 2, 6, 4,
6, 8, 4, 2, 4, 6, 8, 6,10, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2,
6, 4, 2, 6,10, 2,10, 2, 4, 2, 4, 6, 8, 4, 2, 4,12, 2, 6, 4,
2, 6, 4, 6,12, 2, 4, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6,10, 2,
4, 6, 2, 6, 4, 2, 4, 2,10, 2,10, 2, 4, 6, 6, 2, 6, 6, 4, 6,
6, 2, 6, 4, 2, 6, 4, 6, 8, 4, 2, 6, 4, 8, 6, 4, 6, 2, 4, 6,
8, 6, 4, 2,10, 2, 6, 4, 2, 4, 2,10, 2,10, 2, 4, 2, 4, 8, 6,
4, 2, 4, 6, 6, 2, 6, 4, 8, 4, 6, 8, 4, 2, 4, 2, 4, 8, 6, 4,
6, 6, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4, 2,10, 2,10, 2,
6, 4, 6, 2, 6, 4, 2, 4, 6, 6, 8, 4, 2, 6,10, 8, 4, 2, 4, 2,
4, 8,10, 6, 2, 4, 8, 6, 6, 4, 2, 4, 6, 2, 6, 4, 6, 2,10, 2,
10, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 6, 6, 4, 6, 8,
4, 2, 4, 2, 4, 8, 6, 4, 8, 4, 6, 2, 6, 6, 4, 2, 4, 6, 8, 4,
2, 4, 2,10, 2,10, 2, 4, 2, 4, 6, 2,10, 2, 4, 6, 8, 6, 4, 2,
6, 4, 6, 8, 4, 6, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6, 6, 4, 6,
6, 2, 6, 6, 4, 2,10, 2,10, 2, 4, 2, 4, 6, 2, 6, 4, 2,10, 6,
2, 6, 4, 2, 6, 4, 6, 8, 4, 2, 4, 2,12, 6, 4, 6, 2, 4, 6, 2,
12, 4, 2, 4, 8, 6, 4, 2, 4, 2,10, 2,10, 6, 2, 4, 6, 2, 6, 4,
2, 4, 6, 6, 2, 6, 4, 2,10, 6, 8, 6, 4, 2, 4, 8, 6, 4, 6, 2,
4, 6, 2, 6, 6, 6, 4, 6, 2, 6, 4, 2, 4, 2,10,12, 2, 4, 2,10,
2, 6, 4, 2, 4, 6, 6, 2,10, 2, 6, 4,14, 4, 2, 4, 2, 4, 8, 6,
4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4,12, 2,12};
#define WHEEL_START (wheel_tab + 5)
#define WHEEL_END (wheel_tab + (sizeof wheel_tab / sizeof wheel_tab[0]))
/* The name this program was run with. */
char *program_name;
@@ -62,7 +97,7 @@ Usage: %s [NUMBER]...\n\
"),
program_name, program_name);
printf (_("\
Print factors of each NUMBER; read standard input with no arguments.\n\
Print the prime factors of each NUMBER.\n\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
@@ -82,17 +117,11 @@ factor (uintmax_t n0, int max_n_factors, uintmax_t *factors)
{
register uintmax_t n = n0, d, q;
int n_factors = 0;
unsigned int const *w = wheel_tab;
if (n < 1)
return n_factors;
while (n % 2 == 0)
{
assert (n_factors < max_n_factors);
factors[n_factors++] = 2;
n /= 2;
}
/* The exit condition in the following loop is correct because
any time it is tested one of these 3 conditions holds:
(1) d divides n
@@ -101,7 +130,7 @@ factor (uintmax_t n0, int max_n_factors, uintmax_t *factors)
If (1) or (2) obviously the right thing happens.
If (3), then since n is composite it is >= d^2. */
d = 3;
d = 2;
do
{
q = n / d;
@@ -112,7 +141,9 @@ factor (uintmax_t n0, int max_n_factors, uintmax_t *factors)
n = q;
q = n / d;
}
d += 2;
d += *(w++);
if (w == WHEEL_END)
w = WHEEL_START;
}
while (d <= q);

View File

@@ -54,21 +54,9 @@ static void print_full_info PARAMS ((const char *username));
/* The name this program was run with. */
char *program_name;
/* If nonzero, output only the group ID(s). -g */
static int just_group = 0;
/* If nonzero, output user/group name instead of ID number. -n */
static int use_name = 0;
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
static int use_real = 0;
/* If nonzero, output only the user ID(s). -u */
static int just_user = 0;
/* If nonzero, output only the supplementary groups. -G */
static int just_group_list = 0;
/* The real and effective IDs of the user to print. */
static uid_t ruid, euid;
static gid_t rgid, egid;
@@ -101,11 +89,11 @@ usage (int status)
Print information for USERNAME, or the current user.\n\
\n\
-a ignore, for compatibility with other versions\n\
-g, --group print only the group ID\n\
-G, --groups print only the supplementary groups\n\
-g, --group print only the effective group ID\n\
-G, --groups print all group IDs\n\
-n, --name print a name instead of a number, for -ugG\n\
-r, --real print the real ID instead of effective ID, for -ugG\n\
-u, --user print only the user ID\n\
-r, --real print the real ID instead of the effective ID, with -ugG\n\
-u, --user print only the effective user ID\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
@@ -121,6 +109,15 @@ main (int argc, char **argv)
{
int optc;
/* If nonzero, output the list of all group IDs. -G */
int just_group_list = 0;
/* If nonzero, output only the group ID(s). -g */
int just_group = 0;
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
int use_real = 0;
/* If nonzero, output only the user ID(s). -u */
int just_user = 0;
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);

View File

@@ -273,8 +273,13 @@ main (int argc, char **argv)
error (1, 0,
_("the strip option may not be used when installing a directory"));
if (make_backups)
x.backup_type = xget_version ("backup type", version_control_string);
if (backup_suffix_string)
simple_backup_suffix = xstrdup (backup_suffix_string);
x.backup_type = (make_backups
? xget_version (_("backup type"),
version_control_string)
: none);
n_files = argc - optind;
file = argv + optind;

View File

@@ -1,5 +1,5 @@
/* `ln' program to create links between files.
Copyright (C) 86, 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 86, 89, 90, 91, 1995-2001 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
@@ -511,13 +511,16 @@ main (int argc, char **argv)
usage (1);
}
if (backup_suffix_string)
simple_backup_suffix = xstrdup (backup_suffix_string);
backup_type = (make_backups
? xget_version (_("backup type"), version_control_string)
: none);
if (target_directory_specified || n_files > 2)
{
int i;
unsigned int i;
unsigned int last_file_idx = (target_directory_specified
? n_files - 1
: n_files - 2);

218
src/ls.c
View File

@@ -1,5 +1,5 @@
/* `dir', `vdir' and `ls' directory listing programs for GNU.
Copyright (C) 85, 88, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 85, 88, 90, 91, 1995-2001 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
@@ -93,12 +93,6 @@
# define iswprint(wc) 1
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HAVE_MBRTOWC && defined mbstate_t
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbsinit(ps) 1
#endif
#ifndef HAVE_DECL_WCWIDTH
"this configure-time declaration test was not run"
#endif
@@ -205,6 +199,12 @@ int rpl_lstat PARAMS((const char *, struct stat *));
# define DT_INIT(Val) /* empty */
#endif
#ifdef ST_MTIM_NSEC
# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC)
#else
# define TIMESPEC_NS(timespec) 0
#endif
enum filetype
{
unknown DT_INIT (DT_UNKNOWN),
@@ -383,10 +383,11 @@ struct pending
static struct pending *pending_dirs;
/* Current time (seconds since 1970). When we are printing a file's time,
include the year if it is more than 6 months before this time. */
/* Current time in seconds and nanoseconds since 1970, updated as
needed when deciding whether a file is recent. */
static time_t current_time;
static time_t current_time = TYPE_MINIMUM (time_t);
static int current_time_ns = -1;
/* The number of digits to use for block sizes.
4, or more if needed for bigger numbers. */
@@ -648,6 +649,11 @@ static int format_needs_stat;
static int format_needs_type;
/* strftime formats for non-recent and recent files, respectively, in
-l output. */
static char const *long_time_format[2];
/* The exit status to use if we don't get any fatal errors. */
static int exit_status;
@@ -659,6 +665,7 @@ enum
BLOCK_SIZE_OPTION = CHAR_MAX + 1,
COLOR_OPTION,
FORMAT_OPTION,
FULL_TIME,
INDICATOR_STYLE_OPTION,
QUOTING_STYLE_OPTION,
SHOW_CONTROL_CHARS_OPTION,
@@ -672,7 +679,7 @@ static struct option const long_options[] =
{"escape", no_argument, 0, 'b'},
{"directory", no_argument, 0, 'd'},
{"dired", no_argument, 0, 'D'},
{"full-time", no_argument, &full_time, 1},
{"full-time", no_argument, 0, FULL_TIME},
{"human-readable", no_argument, 0, 'h'},
{"inode", no_argument, 0, 'i'},
{"kilobytes", no_argument, 0, 'k'},
@@ -861,7 +868,6 @@ main (int argc, char **argv)
dir_defaulted = 1;
print_dir_name = 1;
pending_dirs = 0;
current_time = time ((time_t *) 0);
i = decode_switches (argc, argv);
@@ -1277,6 +1283,11 @@ decode_switches (int argc, char **argv)
format = XARGMATCH ("--format", optarg, format_args, format_types);
break;
case FULL_TIME:
format = long_format;
full_time = 1;
break;
case COLOR_OPTION:
if (optarg)
i = XARGMATCH ("--color", optarg, color_args, color_types);
@@ -1352,6 +1363,18 @@ decode_switches (int argc, char **argv)
sort_type = sort_time;
}
if (format == long_format)
{
if (full_time)
long_time_format[0] = long_time_format[1] =
dcgettext (NULL, "%a %b %d %H:%M:%S %Y", LC_TIME);
else
{
long_time_format[0] = dcgettext (NULL, "%b %e %Y", LC_TIME);
long_time_format[1] = dcgettext (NULL, "%b %e %H:%M", LC_TIME);
}
}
return optind;
}
@@ -1860,7 +1883,6 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
const char *dirname)
{
register uintmax_t blocks;
register int val;
register char *path;
if (files_index == nfiles)
@@ -1874,10 +1896,15 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
files[files_index].linkmode = 0;
files[files_index].linkok = 0;
/* FIXME: this use of ls: `mkdir a; touch a/{b,c,d}; ls -R a'
shouldn't require that ls stat b, c, and d -- at least
not on systems with usable d_type. The problem is that
format_needs_stat is set, because of the -R. */
if (explicit_arg || format_needs_stat
|| (format_needs_type && type == unknown))
{
/* `path' is the absolute pathname of this file. */
int val;
if (name[0] == '/' || dirname[0] == 0)
path = (char *) name;
@@ -1887,23 +1914,9 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
attach (path, dirname, name);
}
if (trace_links)
{
val = stat (path, &files[files_index].stat);
if (val < 0)
{
/* Perhaps a symbolically-linked to file doesn't exist; stat
the link instead. */
val = lstat (path, &files[files_index].stat);
}
}
else
{
val = lstat (path, &files[files_index].stat);
#if USE_ACL
files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
#endif
}
val = (trace_links
? stat (path, &files[files_index].stat)
: lstat (path, &files[files_index].stat));
if (val < 0)
{
@@ -1912,6 +1925,13 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
return 0;
}
#if USE_ACL
if (format == long_format)
files[files_index].have_acl =
(! S_ISLNK (files[files_index].stat.st_mode)
&& 4 < acl (path, GETACLCNT, 0, NULL));
#endif
if (S_ISLNK (files[files_index].stat.st_mode)
&& (explicit_arg || format == long_format || check_symlink_color))
{
@@ -2076,9 +2096,7 @@ static void
extract_dirs_from_files (const char *dirname, int recursive)
{
register int i, j;
int dirlen;
dirlen = strlen (dirname) + 2;
/* Queue the directories last one first, because queueing reverses the
order. */
for (i = files_index - 1; i >= 0; i--)
@@ -2336,6 +2354,80 @@ print_current_files (void)
}
}
/* Return the expected number of columns in a long-format time stamp,
or zero if it cannot be calculated. */
static int
long_time_expected_width (void)
{
static int width = -1;
if (width < 0)
{
time_t epoch = 0;
struct tm const *tm = localtime (&epoch);
char const *fmt = long_time_format[0];
char initbuf[100];
char *buf = initbuf;
size_t bufsize = sizeof initbuf;
size_t len;
for (;;)
{
*buf = '\1';
len = strftime (buf, bufsize, fmt, tm);
if (len || ! *buf)
break;
buf = alloca (bufsize *= 2);
}
width = mbsnwidth (buf, len, 0);
if (width < 0)
width = 0;
}
return width;
}
/* Get the current time. */
static void
get_current_time (void)
{
#if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
{
struct timespec timespec;
if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
{
current_time = timespec.tv_sec;
current_time_ns = timespec.tv_nsec;
return;
}
}
#endif
/* The clock does not have nanosecond resolution, so get the maximum
possible value for the current time that is consistent with the
reported clock. That way, files are not considered to be in the
future merely because their time stamps have higher resolution
than the clock resolution. */
#if HAVE_GETTIMEOFDAY
{
struct timeval timeval;
if (gettimeofday (&timeval, NULL) == 0)
{
current_time = timeval.tv_sec;
current_time_ns = timeval.tv_usec * 1000 + 999;
return;
}
}
#endif
current_time = time (NULL);
current_time_ns = 999999999;
}
static void
print_long_format (const struct fileinfo *f)
{
@@ -2355,8 +2447,8 @@ print_long_format (const struct fileinfo *f)
size_t s;
char *p;
time_t when;
int when_ns IF_LINT (= 0);
struct tm *when_local;
const char *fmt;
char *user_name;
#if HAVE_ST_DM_MODE
@@ -2373,38 +2465,18 @@ print_long_format (const struct fileinfo *f)
{
case time_ctime:
when = f->stat.st_ctime;
when_ns = TIMESPEC_NS (f->stat.st_ctim);
break;
case time_mtime:
when = f->stat.st_mtime;
when_ns = TIMESPEC_NS (f->stat.st_mtim);
break;
case time_atime:
when = f->stat.st_atime;
when_ns = TIMESPEC_NS (f->stat.st_atim);
break;
}
if (full_time)
{
fmt = _("%a %b %d %H:%M:%S %Y");
}
else
{
if (current_time > when + 6L * 30L * 24L * 60L * 60L /* Old. */
|| current_time < when - 60L * 60L) /* In the future. */
{
/* The file is fairly old or in the future.
POSIX says the cutoff is 6 months old;
approximate this by 6*30 days.
Allow a 1 hour slop factor for what is considered "the future",
to allow for NFS server/client clock disagreement.
Show the year instead of the time of day. */
fmt = _("%b %e %Y");
}
else
{
fmt = _("%b %e %H:%M");
}
}
p = buf;
if (print_inode)
@@ -2462,9 +2534,35 @@ print_long_format (const struct fileinfo *f)
if ((when_local = localtime (&when)))
{
while (! (s = strftime (p, buf + bufsize - p - 1, fmt, when_local)))
time_t six_months_ago;
int recent;
char const *fmt;
/* If the file appears to be in the future, update the current
time, in case the file happens to have been modified since
the last time we checked the clock. */
if (current_time < when
|| (current_time == when && current_time_ns < when_ns))
get_current_time ();
/* Consider a time to be recent if it is within the past six
months. A Gregorian year has 365.2425 * 24 * 60 * 60 ==
31556952 seconds on the average. Write this value as an
integer constant to avoid floating point hassles. */
six_months_ago = current_time - 31556952 / 2;
recent = (six_months_ago <= when
&& (when < current_time
|| (when == current_time && when_ns <= current_time_ns)));
fmt = long_time_format[recent];
for (;;)
{
char *newbuf = (char *) alloca (bufsize *= 2);
char *newbuf;
*p = '\1';
s = strftime (p, buf + bufsize - p - 1, fmt, when_local);
if (s || ! *p)
break;
newbuf = alloca (bufsize *= 2);
memcpy (newbuf, buf, p - buf);
p = newbuf + (p - buf);
buf = newbuf;
@@ -2481,7 +2579,7 @@ print_long_format (const struct fileinfo *f)
/* The time cannot be represented as a local time;
print it as a huge integer number of seconds. */
char hbuf[LONGEST_HUMAN_READABLE + 1];
int width = full_time ? 24 : 12;
int width = long_time_expected_width ();
if (when < 0)
{
@@ -3158,7 +3256,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
--block-size=SIZE use SIZE-byte blocks\n\
-B, --ignore-backups do not list implied entries ending with ~\n\
-c with -lt: sort by, and show, ctime (time of last\n\
modification of file status information)\n\
modification of file status information)\n\
with -l: show ctime and sort by name\n\
otherwise: sort by ctime\n\
-C list entries by columns\n\

View File

@@ -143,23 +143,19 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
{
int fail = 0;
/* Remove any trailing slashes. Not removing them would lead to calling
`mkdir ("dir/", mode)' for e.g., the commands `mkdir dir/' and
`mkdir -p dir/', and such a call fails on NetBSD systems when `dir'
doesn't already exist. */
strip_trailing_slashes (argv[optind]);
if (create_parents)
{
char *parents = dir_name (argv[optind]);
fail = make_path (parents, parent_mode, parent_mode,
-1, -1, 1, verbose_fmt_string);
free (parents);
/* If we're creating parent directories, then it's ok to remove
trailing slashes. In fact, *not* removing them would lead
to calling `mkdir ("dir/", mode)' for the command `mkdir -p dir/',
and such a call fails on NetBSD systems if `dir' doesn't already
exist. */
/* An alternate approach would be to change make_path to interpret
an argument with a trailing slash as if it also had a trailing
`.'. In fact, that would be more consistent with POSIX, so
FIXME: some day. */
strip_trailing_slashes (argv[optind]);
}
if (fail == 0)

View File

@@ -1,5 +1,5 @@
/* mv -- move or rename files
Copyright (C) 86, 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 86, 89, 90, 91, 1995-2001 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
@@ -72,7 +72,7 @@ static struct option const long_options[] =
{"backup", optional_argument, NULL, 'b'},
{"force", no_argument, NULL, 'f'},
{"interactive", no_argument, NULL, 'i'},
{"strip-trailing-slash", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
{"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
{"update", no_argument, NULL, 'u'},
@@ -195,9 +195,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
and failing. */
dir_to_remove = NULL;
error (0, 0,
_("cannot move %s to a subdirectory of itself, %s"),
quote_n (0, source), quote_n (1, dest));
fail = 1;
}
else if (rename_succeeded)
{
@@ -259,9 +257,6 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
if (fail)
error (0, errno, _("cannot remove %s"), quote (dir_to_remove));
}
if (copy_into_self)
fail = 1;
}
return fail;

334
src/od.c
View File

@@ -1,5 +1,5 @@
/* od -- dump files in octal and other formats
Copyright (C) 92, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 92, 1995-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -65,11 +65,6 @@ typedef double LONG_DOUBLE;
# define LDBL_DIG DBL_DIG
#endif
#if !HAVE_FSEEKO
# undef fseeko
# define fseeko(Stream, Offset, Whence) (-1)
#endif
enum size_spec
{
NO_SIZE,
@@ -155,19 +150,18 @@ static const char *const charname[33] =
"sp"
};
/* A printf control string for printing a file offset. */
static const char *output_address_fmt_string;
/* Address base (8, 10 or 16). */
static int address_base;
/* FIXME: make this the number of octal digits in an unsigned long. */
#define MAX_ADDRESS_LENGTH 13
/* The number of octal digits required to represent the largest off_t value. */
#define MAX_ADDRESS_LENGTH \
((sizeof (off_t) * CHAR_BIT + CHAR_BIT - 1) / 3)
/* Space for a normal address, a space, a pseudo address, parentheses
around the pseudo address, and a trailing zero byte. */
static char address_fmt_buffer[2 * MAX_ADDRESS_LENGTH + 4];
static char address_pad[MAX_ADDRESS_LENGTH + 1];
/* Width of a normal address. */
static int address_pad_len;
static unsigned long int string_min;
static unsigned long int flag_dump_strings;
static size_t string_min;
static int flag_dump_strings;
/* Non-zero if we should recognize the pre-POSIX non-option arguments
that specified at most one file and optional arguments specifying
@@ -175,15 +169,15 @@ static unsigned long int flag_dump_strings;
static int traditional;
/* Non-zero if an old-style `pseudo-address' was specified. */
static long int flag_pseudo_start;
static int flag_pseudo_start;
/* The difference between the old-style pseudo starting address and
the number of bytes to skip. */
static long int pseudo_offset;
static off_t pseudo_offset;
/* Function to format an address and optionally an additional parenthesized
pseudo-address; it returns the formatted string. */
static const char *(*format_address) PARAMS ((long unsigned int));
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
static void (*format_address) PARAMS ((off_t, char));
/* The number of input bytes to skip before formatting and writing. */
static off_t n_bytes_to_skip = 0;
@@ -205,16 +199,16 @@ static int abbreviate_duplicate_blocks = 1;
static struct tspec *spec;
/* The number of format specs. */
static unsigned int n_specs;
static size_t n_specs;
/* The allocated length of SPEC. */
static unsigned int n_specs_allocated;
static size_t n_specs_allocated;
/* The number of input bytes formatted per output line. It must be
a multiple of the least common multiple of the sizes associated with
the specified output types. It should be as large as possible, but
no larger than 16 -- unless specified with the -w option. */
static unsigned int bytes_per_block;
static size_t bytes_per_block;
/* Human-readable representation of *file_list (for error messages).
It differs from *file_list only when *file_list is "-". */
@@ -231,13 +225,15 @@ static FILE *in_stream;
/* If nonzero, at least one of the files we read was standard input. */
static int have_read_stdin;
#ifdef HAVE_UNSIGNED_LONG_LONG
# define LONGEST_INTEGRAL_TYPE unsigned long long
#if HAVE_UNSIGNED_LONG_LONG
typedef unsigned long long ulonglong_t;
#else
# define LONGEST_INTEGRAL_TYPE long int
/* This is just a place-holder to avoid a few `#if' directives.
In this case, the type isn't actually used. */
typedef unsigned long int ulonglong_t;
#endif
#define MAX_INTEGRAL_TYPE_SIZE sizeof(LONGEST_INTEGRAL_TYPE)
#define MAX_INTEGRAL_TYPE_SIZE sizeof (ulonglong_t)
static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
@@ -364,10 +360,9 @@ lcm (unsigned int u, unsigned int v)
}
static void
print_s_char (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_s_char (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
int tmp = (unsigned) *(const unsigned char *) block;
@@ -380,10 +375,9 @@ print_s_char (long unsigned int n_bytes, const char *block,
}
static void
print_char (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_char (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int tmp = *(const unsigned char *) block;
@@ -393,10 +387,9 @@ print_char (long unsigned int n_bytes, const char *block,
}
static void
print_s_short (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_s_short (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
{
int tmp = (unsigned) *(const unsigned short *) block;
@@ -409,10 +402,9 @@ print_s_short (long unsigned int n_bytes, const char *block,
}
static void
print_short (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_short (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
{
unsigned int tmp = *(const unsigned short *) block;
@@ -422,10 +414,9 @@ print_short (long unsigned int n_bytes, const char *block,
}
static void
print_int (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_int (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned int); i > 0; i--)
{
unsigned int tmp = *(const unsigned int *) block;
@@ -435,10 +426,9 @@ print_int (long unsigned int n_bytes, const char *block,
}
static void
print_long (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (unsigned long); i > 0; i--)
{
unsigned long tmp = *(const unsigned long *) block;
@@ -447,26 +437,22 @@ print_long (long unsigned int n_bytes, const char *block,
}
}
#ifdef HAVE_UNSIGNED_LONG_LONG
static void
print_long_long (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long_long (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
for (i = n_bytes / sizeof (unsigned long long); i > 0; i--)
off_t i;
for (i = n_bytes / sizeof (ulonglong_t); i > 0; i--)
{
unsigned long long tmp = *(const unsigned long long *) block;
ulonglong_t tmp = *(const ulonglong_t *) block;
printf (fmt_string, tmp);
block += sizeof (unsigned long long);
block += sizeof (ulonglong_t);
}
}
#endif
static void
print_float (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_float (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (float); i > 0; i--)
{
float tmp = *(const float *) block;
@@ -476,10 +462,9 @@ print_float (long unsigned int n_bytes, const char *block,
}
static void
print_double (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_double (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (double); i > 0; i--)
{
double tmp = *(const double *) block;
@@ -490,10 +475,9 @@ print_double (long unsigned int n_bytes, const char *block,
#ifdef HAVE_LONG_DOUBLE
static void
print_long_double (long unsigned int n_bytes, const char *block,
const char *fmt_string)
print_long_double (off_t n_bytes, const char *block, const char *fmt_string)
{
int i;
off_t i;
for (i = n_bytes / sizeof (LONG_DOUBLE); i > 0; i--)
{
LONG_DOUBLE tmp = *(const LONG_DOUBLE *) block;
@@ -505,9 +489,9 @@ print_long_double (long unsigned int n_bytes, const char *block,
#endif
static void
dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
dump_hexl_mode_trailer (off_t n_bytes, const char *block)
{
int i;
off_t i;
fputs (" >", stdout);
for (i = n_bytes; i > 0; i--)
{
@@ -520,10 +504,10 @@ dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
}
static void
print_named_ascii (long unsigned int n_bytes, const char *block,
const char *unused_fmt_string)
print_named_ascii (off_t n_bytes, const char *block,
const char *unused_fmt_string ATTRIBUTE_UNUSED)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int c = *(const unsigned char *) block;
@@ -547,10 +531,10 @@ print_named_ascii (long unsigned int n_bytes, const char *block,
}
static void
print_ascii (long unsigned int n_bytes, const char *block,
const char *unused_fmt_string)
print_ascii (off_t n_bytes, const char *block,
const char *unused_fmt_string ATTRIBUTE_UNUSED)
{
int i;
off_t i;
for (i = n_bytes; i > 0; i--)
{
unsigned int c = *(const unsigned char *) block;
@@ -652,7 +636,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
enum output_format fmt;
const char *pre_fmt_string;
char *fmt_string;
void (*print_function) ();
void (*print_function) PARAMS ((off_t, const char *, const char *));
const char *p;
unsigned int c;
unsigned int field_width = 0;
@@ -702,7 +686,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
size = sizeof (int);
else
{
if (size > MAX_INTEGRAL_TYPE_SIZE
if (MAX_INTEGRAL_TYPE_SIZE < size
|| integral_type_size[size] == NO_SIZE)
{
error (0, 0, _("invalid type string `%s';\n\
@@ -986,15 +970,15 @@ skip (off_t n_skip)
if (n_skip == 0)
break;
/* First try using fseek. For large offsets, this extra work is
/* First try seeking. For large offsets, this extra work is
worthwhile. If the offset is below some threshold it may be
more efficient to move the pointer by reading. There are two
issues when trying to use fseek:
issues when trying to seek:
- the file must be seekable.
- before seeking to the specified position, make sure
that the new position is in the current file.
Try to do that by getting file's size using fstat().
But that will work only for regular files and dirs. */
Try to do that by getting file's size using fstat.
But that will work only for regular files. */
if (fstat (fileno (in_stream), &file_stats))
{
@@ -1010,7 +994,7 @@ skip (off_t n_skip)
n_skip and go on to the next file. */
if (S_ISREG (file_stats.st_mode))
{
if (n_skip >= file_stats.st_size)
if (file_stats.st_size <= n_skip)
{
n_skip -= file_stats.st_size;
if (in_stream != stdin && fclose (in_stream) == EOF)
@@ -1022,10 +1006,7 @@ skip (off_t n_skip)
}
else
{
/* Try fseeko if available, fseek otherwise. */
if (fseeko (in_stream, n_skip, SEEK_SET) == 0
|| (n_skip <= LONG_MAX
&& fseek (in_stream, (long) n_skip, SEEK_SET) == 0))
if (0 <= lseek (fileno (in_stream), n_skip, SEEK_CUR))
{
n_skip = 0;
break;
@@ -1036,10 +1017,10 @@ skip (off_t n_skip)
/* Seek didn't work or wasn't attempted; position the file pointer
by reading. */
for (j = n_skip / BUFSIZ; j >= 0; j--)
for (j = n_skip / BUFSIZ; 0 <= j; j--)
{
char buf[BUFSIZ];
size_t n_bytes_to_read = (j > 0
size_t n_bytes_to_read = (0 < j
? BUFSIZ
: n_skip % BUFSIZ);
size_t n_bytes_read;
@@ -1059,32 +1040,64 @@ skip (off_t n_skip)
return err;
}
static const char *
format_address_none (long unsigned int address)
static void
format_address_none (off_t address ATTRIBUTE_UNUSED, char c ATTRIBUTE_UNUSED)
{
return "";
}
static const char *
format_address_std (long unsigned int address)
static void
format_address_std (off_t address, char c)
{
const char *address_string;
char buf[MAX_ADDRESS_LENGTH + 2];
char *p = buf + sizeof buf;
char const *pbound;
sprintf (address_fmt_buffer, output_address_fmt_string, address);
address_string = address_fmt_buffer;
return address_string;
*--p = '\0';
*--p = c;
pbound = p - address_pad_len;
/* Use a special case of the code for each base. This is measurably
faster than generic code. */
switch (address_base)
{
case 8:
do
*--p = '0' + (address & 7);
while ((address >>= 3) != 0);
break;
case 10:
do
*--p = '0' + (address % 10);
while ((address /= 10) != 0);
break;
case 16:
do
*--p = "0123456789abcdef"[address & 15];
while ((address >>= 4) != 0);
break;
}
while (pbound < p)
*--p = '0';
fputs (p, stdout);
}
static const char *
format_address_label (long unsigned int address)
static void
format_address_paren (off_t address, char c)
{
const char *address_string;
assert (output_address_fmt_string != NULL);
putchar ('(');
format_address_std (address, ')');
putchar (c);
}
sprintf (address_fmt_buffer, output_address_fmt_string,
address, address + pseudo_offset);
address_string = address_fmt_buffer;
return address_string;
static void
format_address_label (off_t address, char c)
{
format_address_std (address, ' ');
format_address_paren (address + pseudo_offset, c);
}
/* Write N_BYTES bytes from CURR_BLOCK to standard output once for each
@@ -1099,7 +1112,7 @@ format_address_label (long unsigned int address)
only when it has not been padded to length BYTES_PER_BLOCK. */
static void
write_block (long unsigned int current_offset, long unsigned int n_bytes,
write_block (off_t current_offset, off_t n_bytes,
const char *prev_block, const char *curr_block)
{
static int first = 1;
@@ -1124,16 +1137,15 @@ write_block (long unsigned int current_offset, long unsigned int n_bytes,
}
else
{
unsigned int i;
size_t i;
prev_pair_equal = 0;
for (i = 0; i < n_specs; i++)
{
const char *addr_or_pad = (i == 0
? format_address (current_offset)
: address_pad);
fputs (addr_or_pad, stdout);
if (i == 0)
format_address (current_offset, '\0');
else
printf ("%*s", address_pad_len, "");
(*spec[i].print_function) (n_bytes, curr_block, spec[i].fmt_string);
if (spec[i].hexl_mode_trailer)
{
@@ -1264,7 +1276,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
{
int err;
assert (n > 0 && n <= bytes_per_block);
assert (0 < n && n <= bytes_per_block);
*n_bytes_in_buffer = 0;
@@ -1324,7 +1336,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
static int
get_lcm (void)
{
unsigned int i;
size_t i;
int l_c_m = 1;
for (i = 0; i < n_specs; i++)
@@ -1341,7 +1353,7 @@ parse_old_offset (const char *s)
int radix;
off_t offset;
enum strtol_error s_err;
long unsigned int tmp;
uintmax_t tmp;
if (*s == '\0')
return -1;
@@ -1363,12 +1375,15 @@ parse_old_offset (const char *s)
radix = 8;
}
s_err = xstrtoul (s, NULL, radix, &tmp, "Bb");
s_err = xstrtoumax (s, NULL, radix, &tmp, "Bb");
if (s_err != LONGINT_OK)
{
STRTOL_FAIL_WARN (s, _("old-style offset"), s_err);
return -1;
}
if (OFF_T_MAX < tmp)
error (EXIT_FAILURE, 0,
_("%s is larger than the maximum file size on this system"), s);
offset = tmp;
return offset;
}
@@ -1450,7 +1465,7 @@ dump (void)
/* Make bytes_to_write the smallest multiple of l_c_m that
is at least as large as n_bytes_read. */
bytes_to_write = l_c_m * (int) ((n_bytes_read + l_c_m - 1) / l_c_m);
bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m);
memset (block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read);
write_block (current_offset, bytes_to_write,
@@ -1458,8 +1473,7 @@ dump (void)
current_offset += n_bytes_read;
}
if (output_address_fmt_string != NULL)
printf ("%s\n", format_address (current_offset));
format_address (current_offset, '\n');
if (limit_bytes_to_format && current_offset > end_offset)
err |= check_and_close ();
@@ -1485,15 +1499,14 @@ dump_strings (void)
err = 0;
while (1)
{
unsigned int i;
size_t i;
int c;
/* See if the next `string_min' chars are all printing chars. */
tryline:
if (limit_bytes_to_format
&& address >= (n_bytes_to_skip + max_bytes_to_format -
(off_t) string_min))
&& address >= (n_bytes_to_skip + max_bytes_to_format - string_min))
break;
for (i = 0; i < string_min; i++)
@@ -1538,10 +1551,8 @@ dump_strings (void)
/* If we get here, the string is all printable and null-terminated,
so print it. It is all in `buf' and `i' is its length. */
buf[i] = 0;
if (output_address_fmt_string != NULL)
{
printf ("%s ", format_address (address - i - 1));
}
format_address (address - i - 1, ' ');
for (i = 0; (c = buf[i]); i++)
{
switch (c)
@@ -1595,17 +1606,16 @@ main (int argc, char **argv)
{
int c;
int n_files;
unsigned int i;
unsigned int l_c_m;
unsigned int address_pad_len;
unsigned long int desired_width;
size_t i;
int l_c_m;
size_t desired_width IF_LINT (= 0);
int width_specified = 0;
int n_failed_decodes = 0;
int err;
/* The old-style `pseudo starting address' to be printed in parentheses
after any true address. */
long int pseudo_start IF_LINT (= 0);
off_t pseudo_start IF_LINT (= 0);
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -1623,8 +1633,8 @@ main (int argc, char **argv)
integral_type_size[sizeof (short int)] = SHORT;
integral_type_size[sizeof (int)] = INT;
integral_type_size[sizeof (long int)] = LONG;
#ifdef HAVE_UNSIGNED_LONG_LONG
integral_type_size[sizeof (long long)] = LONG_LONG;
#if HAVE_UNSIGNED_LONG_LONG
integral_type_size[sizeof (ulonglong_t)] = LONG_LONG;
#endif
for (i = 0; i <= MAX_FP_TYPE_SIZE; i++)
@@ -1641,15 +1651,15 @@ main (int argc, char **argv)
n_specs_allocated = 5;
spec = (struct tspec *) xmalloc (n_specs_allocated * sizeof (struct tspec));
output_address_fmt_string = "%07o";
format_address = format_address_std;
address_base = 8;
address_pad_len = 7;
flag_dump_strings = 0;
while ((c = getopt_long (argc, argv, "abcdfhilos::xw::A:j:N:t:v",
long_options, NULL)) != -1)
{
unsigned long int tmp;
uintmax_t tmp;
enum strtol_error s_err;
switch (c)
@@ -1661,22 +1671,21 @@ main (int argc, char **argv)
switch (optarg[0])
{
case 'd':
output_address_fmt_string = "%07d";
format_address = format_address_std;
address_base = 10;
address_pad_len = 7;
break;
case 'o':
output_address_fmt_string = "%07o";
format_address = format_address_std;
address_base = 8;
address_pad_len = 7;
break;
case 'x':
output_address_fmt_string = "%06x";
format_address = format_address_std;
address_base = 16;
address_pad_len = 6;
break;
case 'n':
output_address_fmt_string = NULL;
format_address = format_address_none;
address_pad_len = 0;
break;
@@ -1690,7 +1699,7 @@ it must be one character from [doxn]"),
break;
case 'j':
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
n_bytes_to_skip = tmp;
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("skip argument"), s_err);
@@ -1699,17 +1708,15 @@ it must be one character from [doxn]"),
case 'N':
limit_bytes_to_format = 1;
/* FIXME: if off_t is long long and that's an 8-byte type,
use xstrtouq here. */
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
max_bytes_to_format = tmp;
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("limit argument"), s_err);
if (tmp > LONG_MAX)
if (OFF_T_MAX < tmp)
error (EXIT_FAILURE, 0,
_("specified number of bytes `%s' is larger than \
the maximum\nrepresentable value of type `long'"), optarg);
_("%s is larger than the maximum file size on this system"),
optarg);
break;
case 's':
@@ -1717,11 +1724,18 @@ the maximum\nrepresentable value of type `long'"), optarg);
string_min = 3;
else
{
s_err = xstrtoul (optarg, NULL, 0, &string_min, "bkm");
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("minimum string length"), s_err);
/* The minimum string length may be no larger than SIZE_MAX,
since we may allocate a buffer of this size. */
if (SIZE_MAX < tmp)
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
string_min = tmp;
}
++flag_dump_strings;
flag_dump_strings = 1;
break;
case 't':
@@ -1771,9 +1785,13 @@ the maximum\nrepresentable value of type `long'"), optarg);
}
else
{
s_err = xstrtoul (optarg, NULL, 10, &desired_width, "");
uintmax_t w_tmp;
s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, "");
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("width specification"), s_err);
if (SIZE_MAX < w_tmp)
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
desired_width = w_tmp;
}
break;
@@ -1871,29 +1889,17 @@ the maximum\nrepresentable value of type `long'"), optarg);
if (flag_pseudo_start)
{
static char buf[10];
if (output_address_fmt_string == NULL)
if (format_address == format_address_none)
{
output_address_fmt_string = "(%07o)";
format_address = format_address_std;
address_base = 8;
address_pad_len = 7;
format_address = format_address_paren;
}
else
{
sprintf (buf, "%s (%s)",
output_address_fmt_string,
output_address_fmt_string);
output_address_fmt_string = buf;
format_address = format_address_label;
}
format_address = format_address_label;
}
}
assert (address_pad_len <= MAX_ADDRESS_LENGTH);
for (i = 0; i < address_pad_len; i++)
address_pad[i] = ' ';
address_pad[address_pad_len] = '\0';
if (n_specs == 0)
{
if (decode_one_format ("o2", "o2", NULL, &(spec[0])))
@@ -1934,14 +1940,14 @@ the maximum\nrepresentable value of type `long'"), optarg);
else
{
error (0, 0, _("warning: invalid width %lu; using %d instead"),
desired_width, l_c_m);
(unsigned long) desired_width, l_c_m);
bytes_per_block = l_c_m;
}
}
else
{
if (l_c_m < DEFAULT_BYTES_PER_BLOCK)
bytes_per_block = l_c_m * (int) (DEFAULT_BYTES_PER_BLOCK / l_c_m);
bytes_per_block = l_c_m * (DEFAULT_BYTES_PER_BLOCK / l_c_m);
else
bytes_per_block = l_c_m;
}

View File

@@ -1,5 +1,5 @@
/* remove.c -- core functions for removing files and directories
Copyright (C) 88, 90, 91, 1994-2000 Free Software Foundation, Inc.
Copyright (C) 88, 90, 91, 1994-2001 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
@@ -171,7 +171,7 @@ hash_compare_active_dir_ents (void const *x, void const *y)
{
struct active_dir_ent const *a = x;
struct active_dir_ent const *b = y;
return SAME_INODE (*a, *b);
return SAME_INODE (*a, *b) ? true : false;
}
/* A hash function for null-terminated char* strings using

View File

@@ -147,7 +147,10 @@ valid_format (const char *fmt)
fmt += strspn (fmt, "0123456789");
if (*fmt == '.')
fmt += strspn (++fmt, "0123456789");
{
++fmt;
fmt += strspn (fmt, "0123456789");
}
}
if (!(*fmt == 'e' || *fmt == 'f' || *fmt == 'g'))

View File

@@ -117,7 +117,7 @@ char *xstrdup PARAMS ((char const *));
# include <sys/time.h> /* For struct timeval */
# include <sys/stat.h> /* For struct stat */
# define GNU_PACKAGE "standalone"
# define PACKAGE "standalone"
# define VERSION "2.0" /* Kind of arbitrary... */
# if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5 || __STRICT_ANSI__
@@ -508,16 +508,22 @@ files, most people use the --remove option.\n\
* --------------------------------------------------------------------
*/
#if ULONG_MAX == 0xffffffff
#if defined __STDC__ && __STDC__
# define UINT_MAX_32_BITS 4294967295U
#else
# define UINT_MAX_32_BITS 0xFFFFFFFF
#endif
#if ULONG_MAX == UINT_MAX_32_BITS
typedef unsigned long word32;
#else
# if UINT_MAX == 0xffffffff
# if UINT_MAX == UINT_MAX_32_BITS
typedef unsigned word32;
# else
# if USHRT_MAX == 0xffffffff
# if USHRT_MAX == UINT_MAX_32_BITS
typedef unsigned short word32;
# else
# if UCHAR_MAX == 0xffffffff
# if UCHAR_MAX == UINT_MAX_32_BITS
typedef unsigned char word32;
# else
"No 32-bit type available!"
@@ -779,7 +785,7 @@ isaac_seed_finish (struct isaac_state *s)
#define ISAAC_SEED(s,x) isaac_seed_data (s, &(x), sizeof (x))
#if __GNUC__ >= 2 && (__i386__ || __alpha__ || _ARCH_PPC)
#if __GNUC__ >= 2 && (__i386__ || __alpha__)
/*
* Many processors have very-high-resolution timer registers,
* The timer registers can be made inaccessible, so we have to deal with the
@@ -815,6 +821,8 @@ isaac_seed_machdep (struct isaac_state *s)
__asm__ __volatile__ ("rpcc %0" : "=r" (t));
# endif
# if _ARCH_PPC
/* Code not used because this instruction is available only on first-
generation PPCs and evokes a SIGBUS on some Linux 2.4 kernels. */
word32 t;
__asm__ __volatile__ ("mfspr %0,22" : "=r" (t));
# endif
@@ -833,12 +841,12 @@ isaac_seed_machdep (struct isaac_state *s)
}
}
#else /* !(__i386__ || __alpha__ || _ARCH_PPC) */
#else /* !(__i386__ || __alpha__) */
/* Do-nothing stub */
# define isaac_seed_machdep(s) (void) 0
#endif /* !(__i386__ || __alpha__ || _ARCH_PPC) */
#endif /* !(__i386__ || __alpha__) */
/*

View File

@@ -1,5 +1,5 @@
/* sort - sort lines of text (with all kinds of options).
Copyright (C) 88, 1991-2000 Free Software Foundation, Inc.
Copyright (C) 88, 1991-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,8 +32,11 @@
#include "long-options.h"
#include "error.h"
#include "hard-locale.h"
#include "human.h"
#include "memcoll.h"
#include "physmem.h"
#include "xalloc.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "sort"
@@ -55,6 +58,7 @@ double strtod ();
#endif
/* Undefine, to avoid warning about redefinition on some systems. */
/* FIXME: Remove these: use MIN/MAX from sys2.h. */
#undef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#undef max
@@ -99,6 +103,8 @@ static int hard_LC_TIME;
#endif
#define NONZERO(x) (x != 0)
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
@@ -109,7 +115,7 @@ int eolchar = '\n';
struct line
{
char *text; /* Text of the line. */
int length; /* Length including final newline. */
size_t length; /* Length including final newline. */
char *keybeg; /* Start of first key. */
char *keylim; /* Limit of first key. */
};
@@ -118,29 +124,29 @@ struct line
struct lines
{
struct line *lines; /* Dynamically allocated array of lines. */
int used; /* Number of slots used. */
int alloc; /* Number of slots allocated. */
int limit; /* Max number of slots to allocate. */
size_t used; /* Number of slots used. */
size_t alloc; /* Number of slots allocated. */
size_t limit; /* Max number of slots to allocate. */
};
/* Input buffers. */
struct buffer
{
char *buf; /* Dynamically allocated buffer. */
int used; /* Number of bytes used. */
int alloc; /* Number of bytes allocated. */
int left; /* Number of bytes left from previous reads. */
int newline_free; /* Number of left bytes that are known
size_t used; /* Number of bytes used. */
size_t alloc; /* Number of bytes allocated. */
size_t left; /* Number of bytes left from previous reads. */
size_t newline_free; /* Number of left bytes that are known
to be newline-free. */
};
struct keyfield
{
int sword; /* Zero-origin 'word' to start at. */
int schar; /* Additional characters to skip. */
size_t sword; /* Zero-origin 'word' to start at. */
size_t schar; /* Additional characters to skip. */
int skipsblanks; /* Skip leading white space at start. */
int eword; /* Zero-origin first word after field. */
int echar; /* Additional characters in field. */
size_t eword; /* Zero-origin first word after field. */
size_t echar; /* Additional characters in field. */
int skipeblanks; /* Skip trailing white space at finish. */
int *ignore; /* Boolean array of characters to ignore. */
char *translate; /* Translation applied to characters. */
@@ -211,20 +217,18 @@ static MONTHTAB_CONST struct month monthtab[] =
/* During the merge phase, the number of files to merge at once. */
#define NMERGE 16
/* Initial buffer size for in-core sorting. The buffer will grow only
if a line longer than this is seen. */
#define SORTALLOC (8 * 1024 * 1024)
static int const sortalloc = SORTALLOC;
/* Minimum text buffer size. */
#define SORTALLOC_MIN (4 * NMERGE * sizeof (struct line))
/* Initial buffer size for in core merge buffers. Bear in mind that
up to NMERGE * mergealloc bytes may be allocated for merge buffers. */
static int const mergealloc = SORTALLOC / NMERGE / 2;
/* Minimum text buffer size if the user does not specify a size. */
#define SORTALLOC_DEFAULT_MIN max (SORTALLOC_MIN, 1024 * 1024)
/* Initial text buffer size for main-memory sorting. The buffer will
grow only if a line longer than this is seen. */
static size_t sortalloc;
/* Guess of average line length. */
static int const linelength = 30;
/* Maximum number of elements for the array(s) of struct line's, in bytes. */
#define LINEALLOC (SORTALLOC / 2)
static size_t const linelength = 30;
/* Array of directory names in which any temporary files are to be created. */
static char const **temp_dirs;
@@ -277,7 +281,7 @@ Usage: %s [OPTION]... [FILE]...\n\
Write sorted concatenation of all FILE(s) to standard output.\n\
\n\
+POS1 [-POS2] start a key at POS1, end it *before* POS2 (obsolescent)\n\
field numbers and character offsets are numbered\n\
field numbers and character offsets are numbered\n\
starting with zero (contrast with the -k option)\n\
-b ignore leading blanks in sort fields or keys\n\
-c check if given files already sorted, do not sort\n\
@@ -286,7 +290,7 @@ Write sorted concatenation of all FILE(s) to standard output.\n\
-g compare according to general numerical value, imply -b\n\
-i consider only printable characters in keys\n\
-k POS1[,POS2] start a key at POS1, end it *at* POS2\n\
field numbers and character offsets are numbered\n\
field numbers and character offsets are numbered\n\
starting with one (contrast with zero-based +POS form)\n\
-m merge already sorted files, do not sort\n\
-M compare (unknown) < `JAN' < ... < `DEC', imply -b\n\
@@ -294,9 +298,10 @@ Write sorted concatenation of all FILE(s) to standard output.\n\
-o FILE write result on FILE instead of standard output\n\
-r reverse the result of comparisons\n\
-s stabilize sort by disabling last resort comparison\n\
-S SIZE use SIZE for main memory sorting\n\
-t SEP use SEParator instead of non- to whitespace transition\n\
-T DIRECTORY use DIRECTORY for temporary files, not $TMPDIR or %s\n\
multiple -T options specify multiple directories\n\
multiple -T options specify multiple directories\n\
-u with -c, check for strict ordering;\n\
with -m, only output the first of an equal sequence\n\
-z end lines with 0 byte, not newline, for find -print0\n\
@@ -310,7 +315,12 @@ POS is F[.C][OPTS], where F is the field number and C the character position\n\
in the field, both counted from one with -k, from zero with the obsolescent\n\
form. OPTS is made up of one or more of Mbdfinr; this effectively disables\n\
global -Mbdfinr settings for that key. If no key is given, use the entire\n\
line as the key. With no FILE, or when FILE is -, read standard input.\n\
line as the key.\n\
\n\
SIZE may be followed by the following multiplicative suffixes:\n\
%% 1%% of memory, b 1, k 1024 (default), and so on for M, G, T, P, E, Z, Y.\n\
\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
*** WARNING ***\n\
The locale specified by the environment affects sort order.\n\
@@ -554,10 +564,83 @@ inittables (void)
#endif /* NLS */
}
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (char const *s)
{
uintmax_t n;
char *suffix;
enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkmMPtTYZ");
/* The default unit is kB. */
if (e == LONGINT_OK && ISDIGIT (suffix[-1]))
{
if (n <= UINTMAX_MAX / 1024)
n *= 1024;
else
e = LONGINT_OVERFLOW;
}
/* A 'b' suffix means bytes; a '%' suffix means percent of memory. */
if (e == LONGINT_INVALID_SUFFIX_CHAR && ISDIGIT (suffix[-1]) && ! suffix[1])
switch (suffix[0])
{
case 'b':
e = LONGINT_OK;
break;
case '%':
{
double mem = physmem_total () * n / 100;
/* Use "<", not "<=", to avoid problems with rounding. */
if (mem < UINTMAX_MAX)
{
n = mem;
e = LONGINT_OK;
}
else
e = LONGINT_OVERFLOW;
}
break;
}
if (e == LONGINT_OK)
{
/* Normally a buffer is allocated with sortalloc bytes, and a
line table with at most sortalloc / 2 bytes. So adjust the
size so that size * 1.5 is about n. */
sortalloc = (n / 3) * 2;
if (sortalloc == (n / 3) * 2)
{
if (sortalloc < SORTALLOC_MIN)
sortalloc = SORTALLOC_MIN;
return;
}
e = LONGINT_OVERFLOW;
}
STRTOL_FATAL_ERROR (s, _("sort size"), e);
}
/* Set the sort size to the default. */
static void
default_sort_size (void)
{
/* Set sortalloc to 50% of available memory, unless it overflows. */
double mem = physmem_available ();
sortalloc = min (mem, SIZE_MAX);
sortalloc >>= 1;
if (sortalloc < SORTALLOC_DEFAULT_MIN)
sortalloc = SORTALLOC_DEFAULT_MIN;
}
/* Initialize BUF, allocating ALLOC bytes initially. */
static void
initbuf (struct buffer *buf, int alloc)
initbuf (struct buffer *buf, size_t alloc)
{
buf->alloc = alloc;
buf->buf = xmalloc (buf->alloc);
@@ -569,7 +652,7 @@ initbuf (struct buffer *buf, int alloc)
file wasn't terminated by a newline, supply one. Return a count
of bytes buffered. */
static int
static size_t
fillbuf (struct buffer *buf, FILE *fp)
{
if (buf->used != buf->left)
@@ -580,10 +663,12 @@ fillbuf (struct buffer *buf, FILE *fp)
while (!feof (fp))
{
int cc;
size_t cc;
if (buf->used == buf->alloc)
{
buf->alloc *= 2;
if (buf->alloc < buf->used)
xalloc_die ();
buf->buf = xrealloc (buf->buf, buf->alloc);
}
cc = fread (buf->buf + buf->used, 1, buf->alloc - buf->used, fp);
@@ -608,6 +693,8 @@ fillbuf (struct buffer *buf, FILE *fp)
if (buf->newline_free != buf->used)
return buf->used;
buf->alloc *= 2;
if (buf->alloc < buf->used)
xalloc_die ();
buf->buf = xrealloc (buf->buf, buf->alloc);
}
buf->buf[buf->used++] = eolchar;
@@ -621,9 +708,13 @@ fillbuf (struct buffer *buf, FILE *fp)
for, ever. */
static void
initlines (struct lines *lines, int alloc, int limit)
initlines (struct lines *lines, size_t alloc, size_t limit)
{
if (limit < alloc)
alloc = limit;
lines->alloc = alloc;
if (SIZE_MAX / sizeof (struct line) < alloc)
xalloc_die ();
lines->lines = (struct line *) xmalloc (lines->alloc * sizeof (struct line));
lines->used = 0;
lines->limit = limit;
@@ -636,7 +727,8 @@ static char *
begfield (const struct line *line, const struct keyfield *key)
{
register char *ptr = line->text, *lim = ptr + line->length - 1;
register int sword = key->sword, schar = key->schar;
register size_t sword = key->sword;
register size_t schar = key->schar;
if (tab)
while (ptr < lim && sword--)
@@ -659,7 +751,7 @@ begfield (const struct line *line, const struct keyfield *key)
while (ptr < lim && blanks[UCHAR (*ptr)])
++ptr;
if (ptr + schar <= lim)
if (schar < lim - ptr)
ptr += schar;
else
ptr = lim;
@@ -674,7 +766,7 @@ static char *
limfield (const struct line *line, const struct keyfield *key)
{
register char *ptr = line->text, *lim = ptr + line->length - 1;
register int eword = key->eword, echar = key->echar;
register size_t eword = key->eword, echar = key->echar;
/* Note: from the POSIX spec:
The leading field separator itself is included in
@@ -692,7 +784,7 @@ limfield (const struct line *line, const struct keyfield *key)
{
while (ptr < lim && *ptr != tab)
++ptr;
if (ptr < lim && (eword || echar > 0))
if (ptr < lim && (eword | echar))
++ptr;
}
else
@@ -761,7 +853,7 @@ limfield (const struct line *line, const struct keyfield *key)
++ptr;
/* Advance PTR by ECHAR (if possible), but no further than LIM. */
if (ptr + echar <= lim)
if (echar < lim - ptr)
ptr += echar;
else
ptr = lim;
@@ -795,7 +887,9 @@ findlines (struct buffer *buf, struct lines *lines)
if (lines->used == lines->alloc)
{
lines->alloc *= 2;
lines->alloc = min (2 * lines->alloc, lines->limit);
if (SIZE_MAX / sizeof (struct line) < lines->alloc)
xalloc_die ();
lines->lines = (struct line *)
xrealloc ((char *) lines->lines,
lines->alloc * sizeof (struct line));
@@ -808,9 +902,9 @@ findlines (struct buffer *buf, struct lines *lines)
if (key)
{
/* Precompute the position of the first key for efficiency. */
line->keylim = 0 <= key->eword ? limfield (line, key) : ptr;
line->keylim = (key->eword == -1 ? ptr : limfield (line, key));
if (key->sword >= 0)
if (key->sword != -1)
line->keybeg = begfield (line, key);
else
{
@@ -902,7 +996,8 @@ fraccompare (register const char *a, register const char *b)
static int
numcompare (register const char *a, register const char *b)
{
register int tmpa, tmpb, loga, logb, tmp;
register int tmpa, tmpb, tmp;
register size_t loga, logb;
tmpa = *a;
tmpb = *b;
@@ -965,8 +1060,8 @@ numcompare (register const char *a, register const char *b)
tmpb = *++b;
while (IS_THOUSANDS_SEP (tmpb));
if (logb - loga != 0)
return logb - loga;
if (loga != logb)
return loga < logb ? 1 : -1;
if (!loga)
return 0;
@@ -1027,8 +1122,8 @@ numcompare (register const char *a, register const char *b)
tmpb = *++b;
while (IS_THOUSANDS_SEP (tmpb));
if (loga - logb != 0)
return loga - logb;
if (loga != logb)
return loga < logb ? -1 : 1;
if (!loga)
return 0;
@@ -1070,10 +1165,11 @@ general_numcompare (const char *sa, const char *sb)
Return 0 if the name in S is not recognized. */
static int
getmonth (const char *s, int len)
getmonth (const char *s, size_t len)
{
char *month;
register int i, lo = 0, hi = MONTHS_PER_YEAR, result;
register size_t i;
register int lo = 0, hi = MONTHS_PER_YEAR, result;
while (len > 0 && blanks[UCHAR (*s)])
{
@@ -1123,7 +1219,8 @@ keycompare (const struct line *a, const struct line *b)
register char *lima = a->keylim;
register char *limb = b->keylim;
int diff, lena, lenb;
int diff;
size_t lena, lenb;
for (;;)
{
@@ -1131,11 +1228,8 @@ keycompare (const struct line *a, const struct line *b)
register int *ignore = key->ignore;
/* Find the lengths. */
lena = lima - texta, lenb = limb - textb;
if (lena < 0)
lena = 0;
if (lenb < 0)
lenb = 0;
lena = lima <= texta ? 0 : lima - texta;
lenb = limb <= textb ? 0 : limb - textb;
if (key->skipeblanks)
{
@@ -1168,7 +1262,7 @@ keycompare (const struct line *a, const struct line *b)
{
char *copy_a = (char *) alloca (lena + 1 + lenb + 1);
char *copy_b = copy_a + lena + 1;
int new_len_a, new_len_b, i;
size_t new_len_a, new_len_b, i;
/* Ignore and/or translate chars before comparing. */
for (new_len_a = new_len_b = i = 0; i < max (lena, lenb); i++)
@@ -1194,7 +1288,7 @@ keycompare (const struct line *a, const struct line *b)
diff = memcoll (copy_a, new_len_a, copy_b, new_len_b);
}
else if (lena == 0)
diff = -lenb;
diff = - NONZERO (lenb);
else if (lenb == 0)
goto greater;
else
@@ -1232,7 +1326,7 @@ keycompare (const struct line *a, const struct line *b)
CMP_WITH_IGNORE (UCHAR (*texta), UCHAR (*textb));
}
else if (lena == 0)
diff = -lenb;
diff = - NONZERO (lenb);
else if (lenb == 0)
goto greater;
else
@@ -1253,7 +1347,7 @@ keycompare (const struct line *a, const struct line *b)
if (diff)
goto not_equal;
}
diff = lena - lenb;
diff = lena < lenb ? -1 : lena != lenb;
}
if (diff)
@@ -1264,12 +1358,12 @@ keycompare (const struct line *a, const struct line *b)
break;
/* Find the beginning and limit of the next field. */
if (key->eword >= 0)
if (key->eword != -1)
lima = limfield (a, key), limb = limfield (b, key);
else
lima = a->text + a->length - 1, limb = b->text + b->length - 1;
if (key->sword >= 0)
if (key->sword != -1)
texta = begfield (a, key), textb = begfield (b, key);
else
{
@@ -1298,7 +1392,8 @@ keycompare (const struct line *a, const struct line *b)
static int
compare (register const struct line *a, register const struct line *b)
{
int diff, alen, blen;
int diff;
size_t alen, blen;
/* First try to compare on the specified keys (if any).
The only two cases with no key at all are unadorned sort,
@@ -1316,23 +1411,23 @@ compare (register const struct line *a, register const struct line *b)
alen = a->length - 1, blen = b->length - 1;
if (alen == 0)
diff = - blen;
diff = - NONZERO (blen);
else if (blen == 0)
diff = alen;
diff = NONZERO (alen);
#ifdef ENABLE_NLS
else if (hard_LC_COLLATE)
diff = memcoll (a->text, alen, b->text, blen);
#endif
else if (! (diff = memcmp (a->text, b->text, min (alen, blen))))
diff = alen - blen;
diff = alen < blen ? -1 : alen != blen;
return reverse ? -diff : diff;
}
/* Check that the lines read from the given FP come in order. Print a
diagnostic (FILE_NAME, line number, contents of line) to stderr and return
the line number of the first out-of-order line (counting from 1) if they
are not in order. Otherwise, print no diagnostic and return zero. */
one if they are not in order. Otherwise, print no diagnostic
and return zero. */
static int
checkfp (FILE *fp, const char *file_name)
@@ -1340,16 +1435,17 @@ checkfp (FILE *fp, const char *file_name)
struct buffer buf; /* Input buffer. */
struct lines lines; /* Lines scanned from the buffer. */
struct line temp; /* Copy of previous line. */
int cc; /* Character count. */
int alloc;
int line_number = 1;
size_t cc; /* Character count. */
size_t alloc;
uintmax_t line_number = 1;
struct line *disorder_line IF_LINT (= NULL);
int disorder_line_number = 0;
uintmax_t disorder_line_number = 0;
struct keyfield *key = keylist;
size_t mergealloc = sortalloc / (2 * NMERGE);
initbuf (&buf, mergealloc);
initlines (&lines, mergealloc / linelength + 1,
LINEALLOC / ((NMERGE + NMERGE) * sizeof (struct line)));
sortalloc / (4 * NMERGE * sizeof (struct line)));
alloc = linelength;
temp.text = xmalloc (alloc);
@@ -1363,16 +1459,16 @@ checkfp (FILE *fp, const char *file_name)
{
struct line *prev_line; /* Pointer to previous line. */
int cmp; /* Result of calling compare. */
int i;
size_t i;
/* Compare each line in the buffer with its successor. */
for (i = 0; i < lines.used - 1; ++i)
for (i = 1; i < lines.used; ++i)
{
cmp = compare (&lines.lines[i], &lines.lines[i + 1]);
cmp = compare (&lines.lines[i - 1], &lines.lines[i]);
if ((unique && cmp >= 0) || (cmp > 0))
{
disorder_line = &lines.lines[i + 1];
disorder_line_number = line_number + i + 1;
disorder_line = &lines.lines[i];
disorder_line_number = line_number + i;
goto finish;
}
}
@@ -1383,8 +1479,14 @@ checkfp (FILE *fp, const char *file_name)
prev_line = lines.lines + (lines.used - 1);
if (alloc < prev_line->length)
{
while ((alloc *= 2) < prev_line->length)
continue;
do
{
if (alloc * 2 < alloc)
xalloc_die ();
alloc *= 2;
}
while (alloc < prev_line->length);
temp.text = xrealloc (temp.text, alloc);
}
memcpy (temp.text, prev_line->text, prev_line->length);
@@ -1416,8 +1518,9 @@ finish:
if (disorder_line_number)
{
fprintf (stderr, _("%s: %s:%d: disorder: "), program_name, file_name,
disorder_line_number);
char hr_buf[LONGEST_HUMAN_READABLE + 1];
fprintf (stderr, _("%s: %s:%s: disorder: "), program_name, file_name,
human_readable (disorder_line_number, hr_buf, 1, 1));
write_bytes (disorder_line->text, disorder_line->length, stderr,
_("standard error"));
}
@@ -1425,7 +1528,7 @@ finish:
free (buf.buf);
free ((char *) lines.lines);
free (temp.text);
return disorder_line_number;
return NONZERO (disorder_line_number);
}
/* Merge lines from FPS onto OFP. NFPS cannot be greater than NMERGE.
@@ -1439,8 +1542,9 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
struct line saved; /* Saved line storage for unique check. */
struct line const *savedline IF_LINT (= NULL);
/* &saved if there is a saved line. */
int savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
int cur[NMERGE]; /* Current line in each line table. */
size_t mergealloc = sortalloc / (2 * NMERGE);
size_t savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
size_t cur[NMERGE]; /* Current line in each line table. */
int ord[NMERGE]; /* Table representing a permutation of fps,
such that lines[ord[0]].lines[cur[ord[0]]]
is the smallest line and will be next
@@ -1473,7 +1577,7 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
else
{
initlines (&lines[i], mergealloc / linelength + 1,
LINEALLOC / ((NMERGE + NMERGE) * sizeof (struct line)));
sortalloc / (4 * NMERGE * sizeof (struct line)));
findlines (&buffer[i], &lines[i]);
cur[i] = 0;
}
@@ -1585,10 +1689,10 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
/* Sort the array LINES with NLINES members, using TEMP for temporary space. */
static void
sortlines (struct line *lines, int nlines, struct line *temp)
sortlines (struct line *lines, size_t nlines, struct line *temp)
{
register struct line *lo, *hi, *t;
register int nlo, nhi;
register size_t nlo, nhi;
if (nlines == 2)
{
@@ -1638,10 +1742,7 @@ check (char **files, int nfiles)
for (i = 0; i < nfiles; ++i)
{
fp = xfopen (files[i], "r");
if (checkfp (fp, files[i]))
{
++disorders;
}
disorders += checkfp (fp, files[i]);
}
return disorders;
}
@@ -1694,8 +1795,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
{
struct buffer buf;
struct lines lines;
struct line *tmp;
int i, ntmp;
struct line *tmp = NULL;
size_t ntmp = 0;
FILE *fp, *tfp;
struct tempnode *node;
int n_temp_files = 0;
@@ -1703,9 +1804,7 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
initbuf (&buf, sortalloc);
initlines (&lines, sortalloc / linelength + 1,
LINEALLOC / sizeof (struct line));
ntmp = lines.alloc;
tmp = (struct line *) xmalloc (ntmp * sizeof (struct line));
sortalloc / (2 * sizeof (struct line)));
while (nfiles--)
{
@@ -1714,6 +1813,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
fp = xfopen (*files++, "r");
while (fillbuf (&buf, fp))
{
size_t i;
if (nfiles && buf.used != buf.alloc && feof (fp))
{
/* End of file, but there is more input and buffer room.
@@ -1726,8 +1827,13 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
findlines (&buf, &lines);
if (ntmp < lines.used)
{
while ((ntmp *= 2) < lines.used)
continue;
if (ntmp == 0)
ntmp = lines.used;
else
while ((ntmp *= 2) < lines.used)
continue;
if (SIZE_MAX / sizeof (struct line) < ntmp)
xalloc_die ();
tmp = (struct line *)
xrealloc ((char *) tmp, ntmp * sizeof (struct line));
}
@@ -1759,8 +1865,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
if (n_temp_files)
{
int i = n_temp_files;
tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *));
i = n_temp_files;
for (node = temphead.next; i > 0; node = node->next)
tempfiles[--i] = node->name;
merge (tempfiles, n_temp_files, ofp, output_file);
@@ -1787,6 +1893,39 @@ badfieldspec (const char *s)
error (SORT_FAILURE, 0, _("invalid field specification `%s'"), s);
}
/* Parse the leading integer in STRING and store the resulting value
(which must fit into size_t) into *VAL. Return the address of the
suffix after the integer. */
static char const *
parse_field_count (char const *string, size_t *val)
{
/* '@' can't possibly be a valid suffix; return &bad_suffix so that
the caller will eventually invoke badfieldspec. */
static char const invalid_suffix = '@';
char *suffix;
uintmax_t n;
switch (xstrtoumax (string, &suffix, 10, &n, ""))
{
case LONGINT_OK:
case LONGINT_INVALID_SUFFIX_CHAR:
*val = n;
if (*val == n)
break;
/* Fall through. */
case LONGINT_OVERFLOW:
error (0, 0, _("count `%.*s' too large"),
(int) (suffix - string), string);
return &invalid_suffix;
case LONGINT_INVALID:
error (0, 0, _("invalid count at start of `%s'"), string);
return &invalid_suffix;
}
return suffix;
}
/* Handle interrupts and hangups. */
static void
@@ -1865,10 +2004,11 @@ int
main (int argc, char **argv)
{
struct keyfield *key = NULL, gkey;
char *s;
int i, t, t2;
char const *s;
int i;
int checkonly = 0, mergeonly = 0, nfiles = 0;
char *minus = "-", *outfile = minus, **files, *tmp;
char *minus = "-", **files, *tmp;
char const *outfile = minus;
FILE *ofp;
#ifdef SA_NOCLDSTOP
struct sigaction oldact, newact;
@@ -1909,7 +2049,7 @@ main (int argc, char **argv)
#endif /* NLS */
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
have_read_stdin = 0;
@@ -1966,18 +2106,10 @@ main (int argc, char **argv)
s = argv[i] + 1;
if (! (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1]))))
badfieldspec (argv[i]);
for (t = 0; ISDIGIT (*s); ++s)
t = 10 * t + *s - '0';
t2 = 0;
s = parse_field_count (s, &key->sword);
if (*s == '.')
for (++s; ISDIGIT (*s); ++s)
t2 = 10 * t2 + *s - '0';
if (t2 || t)
{
key->sword = t;
key->schar = t2;
}
else
s = parse_field_count (s + 1, &key->schar);
if (! (key->sword | key->schar))
key->sword = -1;
s = set_ordering (s, key, bl_start);
if (*s)
@@ -1995,14 +2127,9 @@ main (int argc, char **argv)
key specifiers,\nthe +POS specifier must come first"));
usage (SORT_FAILURE);
}
for (t = 0; ISDIGIT (*s); ++s)
t = t * 10 + *s - '0';
t2 = 0;
s = parse_field_count (s, &key->eword);
if (*s == '.')
for (++s; ISDIGIT (*s); ++s)
t2 = t2 * 10 + *s - '0';
key->eword = t;
key->echar = t2;
s = parse_field_count (s + 1, &key->echar);
s = set_ordering (s, key, bl_end);
if (*s)
badfieldspec (argv[i]);
@@ -2039,17 +2166,14 @@ key specifiers,\nthe +POS specifier must come first"));
/* Get POS1. */
if (!ISDIGIT (*s))
badfieldspec (argv[i]);
for (t = 0; ISDIGIT (*s); ++s)
t = 10 * t + *s - '0';
if (t == 0)
s = parse_field_count (s, &key->sword);
if (! key->sword--)
{
/* Provoke with `sort -k0' */
error (0, 0, _("the starting field number argument \
to the `-k' option must be positive"));
badfieldspec (argv[i]);
}
--t;
t2 = 0;
if (*s == '.')
{
if (!ISDIGIT (s[1]))
@@ -2059,23 +2183,16 @@ to the `-k' option must be positive"));
lacks following character offset"));
badfieldspec (argv[i]);
}
for (++s; ISDIGIT (*s); ++s)
t2 = 10 * t2 + *s - '0';
if (t2 == 0)
s = parse_field_count (s + 1, &key->schar);
if (! key->schar--)
{
/* Provoke with `sort -k1.0' */
error (0, 0, _("starting field character offset \
argument to the `-k' option\nmust be positive"));
argument to the `-k' option must be positive"));
badfieldspec (argv[i]);
}
--t2;
}
if (t2 || t)
{
key->sword = t;
key->schar = t2;
}
else
if (! (key->sword | key->schar))
key->sword = -1;
s = set_ordering (s, key, bl_start);
if (*s == 0)
@@ -2097,17 +2214,14 @@ lacks following field spec"));
badfieldspec (argv[i]);
}
/* Get POS2. */
for (t = 0; ISDIGIT (*s); ++s)
t = t * 10 + *s - '0';
if (t == 0)
s = parse_field_count (s, &key->eword);
if (! key->eword--)
{
/* Provoke with `sort -k1,0' */
error (0, 0, _("ending field number argument \
to the `-k' option must be positive"));
badfieldspec (argv[i]);
}
--t;
t2 = 0;
if (*s == '.')
{
if (!ISDIGIT (s[1]))
@@ -2117,16 +2231,13 @@ to the `-k' option must be positive"));
but lacks following character offset"));
badfieldspec (argv[i]);
}
for (++s; ISDIGIT (*s); ++s)
t2 = t2 * 10 + *s - '0';
s = parse_field_count (s + 1, &key->echar);
}
else
{
/* `-k 2,3' is equivalent to `+1 -3'. */
++t;
key->eword++;
}
key->eword = t;
key->echar = t2;
s = set_ordering (s, key, bl_end);
if (*s)
badfieldspec (argv[i]);
@@ -2153,6 +2264,15 @@ but lacks following character offset"));
case 's':
stable = 1;
break;
case 'S':
if (s[1])
specify_sort_size (++s);
else if (i < argc - 1)
specify_sort_size (argv[++i]);
else
error (SORT_FAILURE, 0,
_("option `-S' requires an argument"));
goto outer;
case 't':
if (s[1])
tab = *++s;
@@ -2211,7 +2331,7 @@ but lacks following character offset"));
for (key = keylist; key; key = key->next)
if (!key->ignore && !key->translate && !key->skipsblanks && !key->reverse
&& !key->skipeblanks && !key->month && !key->numeric
&& !key->general_numeric)
&& !key->general_numeric)
{
key->ignore = gkey.ignore;
key->translate = gkey.translate;
@@ -2241,6 +2361,9 @@ but lacks following character offset"));
files = &minus;
}
if (sortalloc == 0)
default_sort_size ();
if (checkonly)
{
if (nfiles > 1)

View File

@@ -1,5 +1,5 @@
/* sync - update the super block
Copyright (C) 1994-2000 Free Software Foundation, Inc.
Copyright (C) 1994-2001 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
@@ -63,7 +63,7 @@ main (int argc, char **argv)
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
if (argc != 1)

View File

@@ -167,6 +167,14 @@ char *alloca ();
# include <sys/exceptn.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h> /* for the definition of UINTMAX_MAX */
#endif
#include <ctype.h>
/* Jim Meyering writes:
@@ -256,12 +264,17 @@ char *alloca ();
#if ENABLE_NLS
# include <libintl.h>
# if HAVE_GETTEXT && !HAVE_DCGETTEXT && !defined dcgettext
# define dcgettext(Domain, Text, Category) Text
# endif
# define _(Text) gettext (Text)
#else
# undef bindtextdomain
# define bindtextdomain(Domain, Directory) /* empty */
# undef textdomain
# define textdomain(Domain) /* empty */
# undef dcgettext
# define dcgettext(Domainname, Text, Category) Text
# define _(Text) Text
#endif
#define N_(Text) Text
@@ -451,7 +464,7 @@ enum
#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \
case GETOPT_VERSION_CHAR: \
version_etc (stdout, Program_name, GNU_PACKAGE, VERSION, Authors); \
version_etc (stdout, Program_name, PACKAGE, VERSION, Authors); \
exit (EXIT_SUCCESS); \
break;
@@ -519,6 +532,22 @@ enum
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
#endif
#ifndef SIZE_MAX
# define SIZE_MAX TYPE_MAXIMUM (size_t)
#endif
#ifndef UINTMAX_MAX
# define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t)
#endif
#ifndef OFF_T_MIN
# define OFF_T_MIN TYPE_MINIMUM (off_t)
#endif
#ifndef OFF_T_MAX
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
#endif
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
@@ -531,6 +560,10 @@ enum
# define PID_T_MAX TYPE_MAXIMUM (pid_t)
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
#ifdef lint
# define IF_LINT(Code) Code

View File

@@ -1,5 +1,5 @@
/* tail -- output the last part of file(s)
Copyright (C) 1989, 90, 91, 1995-2000 Free Software Foundation, Inc.
Copyright (C) 1989, 90, 91, 1995-2001 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
@@ -44,14 +44,6 @@
#define AUTHORS \
"Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering"
#ifndef OFF_T_MIN
# define OFF_T_MIN TYPE_MINIMUM (off_t)
#endif
#ifndef OFF_T_MAX
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
#endif
#ifndef ENOSYS
/* Some systems don't have ENOSYS -- this should be a big enough
value that no valid errno value will match it. */
@@ -271,6 +263,11 @@ With no FILE, or when FILE is -, read standard input.\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
"),
DEFAULT_N_LINES, DEFAULT_N_LINES,
DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS
);
printf (_("\
If the first character of N (the number of bytes or lines) is a `+',\n\
print beginning with the Nth item from the start of each file, otherwise,\n\
print the last N items in the file. N may have a multiplier suffix:\n\
@@ -287,10 +284,7 @@ rotation). Use --follow=name in that case. That causes tail to track the\n\
named file by reopening it periodically to see if it has been removed and\n\
recreated by some other program.\n\
\n\
"),
DEFAULT_N_LINES, DEFAULT_N_LINES,
DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS
);
"));
puts (_("\nReport bugs to <bug-textutils@gnu.org>."));
}
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
@@ -1145,6 +1139,9 @@ tail_file (struct File_spec *f, off_t n_units)
{
f->fd = -1;
f->errnum = errno;
f->ignore = 0;
f->ino = 0;
f->dev = 0;
}
error (0, errno, "%s", pretty_name (f));
errors = 1;
@@ -1382,8 +1379,8 @@ parse_options (int argc, char **argv,
{
strtol_error s_err;
unsigned long int tmp_ulong;
s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "bkm");
uintmax_t n;
s_err = xstrtoumax (optarg, NULL, 10, &n, "bkm");
if (s_err == LONGINT_INVALID)
{
error (EXIT_FAILURE, 0, "%s: %s", optarg,
@@ -1391,14 +1388,16 @@ parse_options (int argc, char **argv,
? _("invalid number of lines")
: _("invalid number of bytes")));
}
if (s_err != LONGINT_OK || tmp_ulong > OFF_T_MAX)
{
error (EXIT_FAILURE, 0,
_("%s: %s is so large that it is not representable"),
optarg,
c == 'n' ? _("number of lines") : _("number of bytes"));
}
*n_units = (off_t) tmp_ulong;
if (s_err != LONGINT_OK)
error (EXIT_FAILURE, 0,
_("%s: is so large that it is not representable"), optarg);
if (OFF_T_MAX < n)
error (EXIT_FAILURE, 0,
_("%s is larger than the maximum file size on this system"),
optarg);
*n_units = (off_t) n;
}
break;

View File

@@ -1,5 +1,5 @@
/* tsort - topological sort.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001 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
@@ -556,7 +556,7 @@ main (int argc, char **argv)
exit_status = 0;
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
while ((opt = getopt_long (argc, argv, "", long_options, NULL)) != -1)

97
src/wheel-gen.pl Executable file
View File

@@ -0,0 +1,97 @@
#!/usr/bin/perl -w
# -*- perl -*-
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0;
use strict;
(my $program_name = $0) =~ s|.*/||;
sub END
{
use POSIX qw (_exit);
# This is required if the code might send any output to stdout
# E.g., even --version or --help. So it's best to do it unconditionally.
close STDOUT
or (warn "$program_name: closing standard output: $!\n"), _exit (1);
}
sub is_prime ($)
{
my ($n) = @_;
use integer;
$n == 2
and return 1;
my $d = 2;
my $w = 1;
while (1)
{
my $q = $n / $d;
$n == $q * $d
and return 0;
$d += $w;
$q < $d
and last;
$w = 2;
}
return 1;
}
{
@ARGV == 1
or die "$program_name: missing argument\n";
my $wheel_size = $ARGV[0];
my @primes = (2);
my $product = $primes[0];
my $n_primes = 1;
for (my $i = 3; ; $i += 2)
{
if (is_prime $i)
{
push @primes, $i;
$product *= $i;
++$n_primes == $wheel_size
and last;
}
}
my $ws_m1 = $wheel_size - 1;
print <<EOF;
/* The first $ws_m1 elements correspond to the incremental offsets of the
first $wheel_size primes (@primes). The $wheel_size(th) element is the
difference between that last prime and the next largest integer
that is not a multiple of those primes. The remaining numbers
define the wheel. For more information, see
http://www.utm.edu/research/primes/glossary/WheelFactorization.html. */
EOF
my @increments;
my $prev = 2;
for (my $i = 3; ; $i += 2)
{
my $rel_prime = 1;
foreach my $divisor (@primes)
{
$i != $divisor && $i % $divisor == 0
and $rel_prime = 0;
}
if ($rel_prime)
{
#warn $i, ' ', $i - $prev, "\n";
push @increments, $i - $prev;
$prev = $i;
$product + 1 < $i
and last;
}
}
print join (",\n", @increments), "\n";
exit 0;
}

View File

@@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4a from Makefile.am
# Makefile.in generated automatically by automake 1.4c from Makefile.am
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
@@ -67,8 +67,6 @@ CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DF_PROG = @DF_PROG@
@@ -150,6 +148,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
tags: TAGS
TAGS:
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; \
srcdir=$(srcdir); export srcdir; \
@@ -274,12 +273,12 @@ maintainer-clean-am: maintainer-clean-generic distclean-am
maintainer-clean: maintainer-clean-am
.PHONY: tags check-TESTS distdir 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 install-strip installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
.PHONY: all all-am all-redirect check check-TESTS check-am clean \
clean-generic distclean distclean-generic distdir dvi dvi-am info \
info-am install install-am install-data install-data-am install-exec \
install-exec-am install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.

1
tests/chgrp/.cvsignore Normal file
View File

@@ -0,0 +1 @@
Makefile

7
tests/chgrp/Makefile.am Normal file
View File

@@ -0,0 +1,7 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = basic deref recurse
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH

283
tests/chgrp/Makefile.in Normal file
View File

@@ -0,0 +1,283 @@
# Makefile.in generated automatically by automake 1.4b from Makefile.am
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
@SET_MAKE@
host_alias = @host_alias@
host_triplet = @host@
AMDEP = @AMDEP@
AMTAR = @AMTAR@
AWK = @AWK@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DF_PROG = @DF_PROG@
FESETROUND_LIBM = @FESETROUND_LIBM@
GENCAT = @GENCAT@
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
GLIBC21 = @GLIBC21@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
GNU_PACKAGE = @GNU_PACKAGE@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
KMEM_GROUP = @KMEM_GROUP@
LIBICONV = @LIBICONV@
LIBOBJS = @LIBOBJS@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIB_CRYPT = @LIB_CRYPT@
LIB_NANOSLEEP = @LIB_NANOSLEEP@
MAKEINFO = @MAKEINFO@
MAN = @MAN@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
NEED_SETGID = @NEED_SETGID@
OPTIONAL_BIN_PROGS = @OPTIONAL_BIN_PROGS@
OPTIONAL_BIN_ZCRIPTS = @OPTIONAL_BIN_ZCRIPTS@
PACKAGE = @PACKAGE@
PERL = @PERL@
POFILES = @POFILES@
POSUB = @POSUB@
POW_LIBM = @POW_LIBM@
RANLIB = @RANLIB@
SEQ_LIBM = @SEQ_LIBM@
SQRT_LIBM = @SQRT_LIBM@
U = @U@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
install_sh = @install_sh@
l = @l@
AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = basic deref recurse
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PATH=`pwd`/../../src:$$PATH
subdir = tests/chgrp
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnits tests/chgrp/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; \
srcdir=$(srcdir); export srcdir; \
list='$(TESTS)'; \
if test -n "$$list"; then \
for tst in $$list; do \
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`; \
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`; \
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 \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
fi; \
else \
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"; \
echo "$$banner"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
fi
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir) \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-rm -f Makefile.in
mostlyclean-am: mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: tags check-TESTS distdir 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 install-strip installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

89
tests/chgrp/basic Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/sh
# make sure chgrp is reasonable
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/../envvar-check
. $srcdir/../lang-default
. $srcdir/../group-names
pwd=`pwd`
tmp=basic.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework' 1>&2
(exit 1); exit
fi
fail=0
set _ $groups; shift
g1=$1
g2=$2
mkdir d
touch f f2 d/f3
chgrp $g1 f || fail=1
chgrp $g2 f || fail=1
chgrp $g2 f2 || fail=1
(
chgrp -c $g1 f
chgrp -c $g2 f
chgrp -c $g2 f
chgrp --verbose $g1 f
chgrp --verbose $g1 f
chgrp --verbose --reference=f2 f
chgrp -R --verbose $g2 d
chgrp -R --verbose $g1 d
chgrp -R -c $g2 d
chgrp -R -c $g1 d
chgrp -c $g2 d
rm -f f
touch f
ln -s f symlink
chgrp $g1 f
chgrp $g2 symlink 2> /dev/null
# This should not change the group of f.
chgrp -c $g2 symlink 2> /dev/null
chgrp -c $g2 f
# This *should* change the group of f.
# Though note that the diagnostic is misleading in that
# it says the `group of `symlink'' has been changed.
chgrp --dereference -c $g1 symlink
) 2>&1 | sed "s/ $g1$/ G1/;s/ $g2$/ G2/" > actual
cat <<\EOF > expected
changed group of `f' to G1
changed group of `f' to G2
changed group of `f' to G1
group of `f' retained as G1
changed group of `f' to G2
changed group of `d' to G2
changed group of `d/f3' to G2
changed group of `d' to G1
changed group of `d/f3' to G1
changed group of `d' to G2
changed group of `d/f3' to G2
changed group of `d' to G1
changed group of `d/f3' to G1
changed group of `d' to G2
changed group of `f' to G2
changed group of `symlink' to G1
EOF
cmp expected actual \
|| { diff -u expected actual 1>&2; fail=1; }
(exit $fail); exit

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