Compare commits

...

219 Commits

Author SHA1 Message Date
Jim Meyering
3ae3622d9e *** empty log message *** 1998-07-25 17:52:54 +00:00
Jim Meyering
27682ba5ce Skip three more unportable tests. These failed on SunOS4.1.4. 1998-07-25 17:52:37 +00:00
Jim Meyering
8dd3e53122 *** empty log message *** 1998-07-25 16:49:13 +00:00
Jim Meyering
d1187d36da *** empty log message *** 1998-07-25 16:45:45 +00:00
Jim Meyering
0f85045bb3 . 1998-07-25 15:32:12 +00:00
Jim Meyering
69835e9fb6 (SAME_INODE): Define it here instead. 1998-07-25 15:31:23 +00:00
Jim Meyering
3ba948db7e (SAME_INODE): Remove definition. 1998-07-25 15:30:08 +00:00
Jim Meyering
d1f9e2315b . 1998-07-25 15:28:24 +00:00
Jim Meyering
d04604664a (same_file): New function
(remove_dir): Use it to give a better diagnostic when rmdir fails
because it can't remove the current directory.
1998-07-25 15:27:55 +00:00
Jim Meyering
4e9a99dd9a (long_options): Changes table entries not to use this form:
{"all", no_argument, &show_all_fs, 1},
but rather this form:
{"all", no_argument, NULL, 'a'},
Using the latter, all the option handling in one place: the getopt loop.
1998-07-25 15:14:16 +00:00
Jim Meyering
3f3df4e600 Use PARAMS macro. 1998-07-25 15:01:32 +00:00
Jim Meyering
27e780fe97 (xatoi): Ansideclify.
(fstype_to_string): Ansideclify.
1998-07-25 15:00:37 +00:00
Jim Meyering
122d3f15ae (REMOTE_FS_TYPE): New macro. 1998-07-25 14:55:10 +00:00
Jim Meyering
bb3fca40db (read_filesystem_list) [MOUNTED_GETMNTINFO]: Use fsp_to_string.
(fsp_to_string): Don't xmalloc return value (yet).
1998-07-25 14:54:42 +00:00
Jim Meyering
91c40bd499 (read_filesystem_list): If all_fs is negative, omit non-local filesytems.
From Paul Eggert.
1998-07-25 14:41:04 +00:00
Jim Meyering
0f4fcb1fbd (show_dev): Omit local devices if show_all_fs is negative.
(show_all_fs): If negative, omit non-local filesystems.
All uses of (all_fs != 0) changed to (all_fs > 0).
(long_options, usage, main): Add -l or --local option.
(main): When asking for df of an explicit file name, get all
the mount points, so that we're more likely to find it when
we look it up.
1998-07-25 14:36:07 +00:00
Jim Meyering
3fbc98bb54 . 1998-07-25 13:49:47 +00:00
Jim Meyering
240b9c0f89 . 1998-07-25 13:48:45 +00:00
Jim Meyering
fc13bb65df (utime_now): Moved into m4/utimes.m4.
(touch) [!HAVE_UTIME_NULL]: Remove #ifdef and use of utime_now in if-block.
1998-07-25 13:20:49 +00:00
Jim Meyering
27f3ca3d5a . 1998-07-25 13:16:38 +00:00
Jim Meyering
f1a7e03bbe *** empty log message *** 1998-07-25 13:10:11 +00:00
Jim Meyering
8d58cbb99e . 1998-07-22 18:32:36 +00:00
Jim Meyering
3b87431a69 (human_readable): amt -> damt, to fix typo when
computing which power to use after overflow occurs during
multiplication.

From Paul Eggert.
1998-07-22 18:30:16 +00:00
Jim Meyering
d09816b054 *** empty log message *** 1998-07-22 16:57:26 +00:00
Jim Meyering
19c23eefb7 Include <stdio.h> if NDEBUG is not defined; needed on SunOS 4.
From Paul Eggert.
1998-07-22 16:57:15 +00:00
Jim Meyering
ef8d2acace . 1998-07-20 03:59:51 +00:00
Jim Meyering
f7d6ece6e4 . 1998-07-20 03:58:24 +00:00
Jim Meyering
90a63a16ec . 1998-07-20 03:58:04 +00:00
Jim Meyering
ec7ec3773f *** empty log message *** 1998-07-20 03:57:59 +00:00
Jim Meyering
a97f821233 (copy_internal): Add another exclusion from the
sameness test: when --force has been specified, the destination
is unlinked before any copy.
(copy_internal): Add yet another: when both src and dest are symlinks.
1998-07-19 04:14:52 +00:00
Jim Meyering
b15e832f4d *** empty log message *** 1998-07-18 14:06:38 +00:00
Jim Meyering
e77a16efec *** empty log message *** 1998-07-18 13:54:40 +00:00
Jim Meyering
7fd7c6465e *** empty log message *** 1998-07-18 13:53:32 +00:00
Jim Meyering
7fc23ef625 . 1998-07-18 13:51:11 +00:00
Jim Meyering
1bd7deb235 (TESTS): Add into-self-2. 1998-07-18 13:16:43 +00:00
Jim Meyering
f2dd2f10c1 . 1998-07-18 13:15:33 +00:00
Jim Meyering
1af4f2f11d (read_filesystem_list): Fix more memory leaks on failure.
From Andreas Schwab.
1998-07-18 12:28:31 +00:00
Jim Meyering
1703d0d59c *** empty log message *** 1998-07-16 23:41:43 +00:00
Jim Meyering
7ac1d190bc Include lchown.h. 1998-07-16 23:41:03 +00:00
Jim Meyering
0c3c6b1b0b *** empty log message *** 1998-07-16 23:40:18 +00:00
Jim Meyering
01c3ff5a1e (noinst_HEADERS): Add lchown.h. 1998-07-16 23:26:50 +00:00
Jim Meyering
1b03d98f62 include lchown.h 1998-07-16 23:25:29 +00:00
Jim Meyering
b294d530d4 . 1998-07-16 23:23:05 +00:00
Jim Meyering
75b6b90fe1 [!ENOSYS] (ENOSYS): Define to ENOTSUP or ENOMSG. 1998-07-16 23:20:03 +00:00
Jim Meyering
7613946ac6 *** empty log message *** 1998-07-16 23:14:30 +00:00
Jim Meyering
5b16f997e8 [!ENOSYS] (ENOSYS): Define to ENOTSUP or ENOMSG. 1998-07-16 23:12:25 +00:00
Jim Meyering
ee041d6d4f Update prototype. 1998-07-16 23:02:19 +00:00
Jim Meyering
f89f495c0d (safe_read): Change type of pointer parameter to
`void' to avoid Irix4 cc errors.  Reported by Kaveh Ghazi.
1998-07-16 23:02:03 +00:00
Jim Meyering
5e3e9e7a15 . 1998-07-16 22:58:12 +00:00
Jim Meyering
8d4d2c4cf4 (check_format): Add `5' to the list of digits.
Reported by Donni Erpel.
1998-07-15 12:39:58 +00:00
Jim Meyering
36de2ed1e2 . 1998-07-13 00:33:36 +00:00
Jim Meyering
f42b337a0b check: depend on maint_gen 1998-07-13 00:31:49 +00:00
Jim Meyering
6cdd12a9f2 (print_header): Print "1k-blocks", not "1.0k-blocks". 1998-07-13 00:17:57 +00:00
Jim Meyering
a0ec87fbf9 *** empty log message *** 1998-07-09 14:29:22 +00:00
Jim Meyering
5c71306463 (jm_FUNC_CHOWN): Add a check to verify that the
uid and gid actually remain unchanged.
1998-07-09 14:29:11 +00:00
Jim Meyering
da69105424 *** empty log message *** 1998-07-08 01:10:45 +00:00
Jim Meyering
1ea1c0864c *** empty log message *** 1998-07-08 01:08:37 +00:00
Jim Meyering
a4e98775a4 Remove FCLOSE_UNLOCKED block. 1998-07-08 01:07:39 +00:00
Jim Meyering
5017930f13 Remove fclose_unlocked. 1998-07-08 01:03:34 +00:00
Jim Meyering
73b7370917 (parse_line): Add casts to avoid errors from Irix4's `cc' C compiler.
From Kaveh Ghazi.
1998-07-05 00:25:10 +00:00
Jim Meyering
bca292d9e6 Include stdio.h. Required on some systems when using assert.
From Kaveh Ghazi.
1998-07-04 17:15:08 +00:00
Jim Meyering
6e3b675ea8 Use cmp, not diff.
Reported by Kaveh Ghazi.
1998-07-04 17:08:26 +00:00
Jim Meyering
95efa0587b *** empty log message *** 1998-07-04 16:46:04 +00:00
Jim Meyering
e49ef588db bump serial number 1998-07-04 16:45:52 +00:00
Jim Meyering
5823a999fe Use syscmd, ifelse, and sysval. Mainly as an exercise
to prove that this macro can be used in packages without regex.c.
1998-07-04 16:45:18 +00:00
Jim Meyering
218c464b91 tweak comment 1998-07-04 15:46:38 +00:00
Jim Meyering
3cc80de466 . 1998-07-04 15:14:46 +00:00
Jim Meyering
52fa9ac235 Remove #ifdef around <regex.h> inclusion. 1998-07-04 14:45:29 +00:00
Jim Meyering
9b809393be Remove #ifdef around <regex.h> inclusion.
(extract_regexp): Remove #if !WITH_REGEX...#endif block.
1998-07-04 14:45:12 +00:00
Jim Meyering
610567e17f *** empty log message *** 1998-07-04 04:10:28 +00:00
Jim Meyering
ad4e506e0f add warning 1998-07-04 04:07:55 +00:00
Jim Meyering
4475ffda48 (remove_dir): Use fprintf, not error to avoid newline in prompt. 1998-07-04 03:59:34 +00:00
Jim Meyering
1b23f5094d *** empty log message *** 1998-07-04 03:43:50 +00:00
Jim Meyering
02f917c543 . 1998-07-04 03:42:40 +00:00
Jim Meyering
60a6e7be26 *** empty log message *** 1998-07-04 03:17:08 +00:00
Jim Meyering
8133377948 . 1998-07-04 01:46:33 +00:00
Jim Meyering
1df5503ccf *** empty log message *** 1998-07-04 01:46:23 +00:00
Jim Meyering
e9a5c7551c use $jm_with_regex, now $WITH_REGEX 1998-07-04 01:46:01 +00:00
Jim Meyering
adfde62439 remove ifdef around inclusion of regex.h altogether!! 1998-07-04 01:44:01 +00:00
Jim Meyering
4b05962106 add 100 to serial number 1998-07-04 01:38:14 +00:00
Jim Meyering
df142feab8 . 1998-07-04 01:33:27 +00:00
Jim Meyering
b2aff777b1 (noinst_HEADERS): Add regex.h. 1998-07-04 01:33:19 +00:00
Jim Meyering
b793f241f4 . 1998-07-04 00:53:46 +00:00
Jim Meyering
ad22b83e45 *** empty log message *** 1998-07-04 00:53:38 +00:00
Jim Meyering
c71fc5f18e . 1998-07-04 00:48:49 +00:00
Jim Meyering
3e13b5e49d . 1998-07-04 00:48:15 +00:00
Jim Meyering
8f55e63084 (read_filesystem_list):
Don't leak memory on failure.
Don't create a dummy struct mount_entry entry;
use the address-of-the-tail-address method instead.
Preserve errno if possible on failure, setting it to 0 if inapplicable.
Close file descriptor leak if the F_SETLKW failed.
Report an error if SVR4 lock file cannot be opened for some reason
other than a nonexistent lock file.
1998-07-04 00:48:11 +00:00
Jim Meyering
2eb479a682 . 1998-07-04 00:41:16 +00:00
Jim Meyering
ec65e39e6f *** empty log message *** 1998-07-04 00:40:52 +00:00
Jim Meyering
bedf44ba83 (AM_WITH_NLS): Remove intl/libintl.h if <libintl.h> is to be used. 1998-07-04 00:39:41 +00:00
Jim Meyering
0cb0cc4e2f . 1998-07-04 00:35:27 +00:00
Jim Meyering
aee16a6664 . 1998-07-04 00:23:40 +00:00
Jim Meyering
93d47b3db9 . 1998-07-04 00:22:39 +00:00
Jim Meyering
18c222c5b5 . 1998-07-04 00:20:47 +00:00
Jim Meyering
bb01a24be5 Require jm_WITH_REGEX. 1998-07-04 00:20:36 +00:00
Jim Meyering
1ccc979847 . 1998-07-04 00:19:23 +00:00
Jim Meyering
ad1d74e973 *** empty log message *** 1998-07-04 00:19:08 +00:00
Jim Meyering
0142ca7d96 *** empty log message *** 1998-07-04 00:17:52 +00:00
Jim Meyering
bcfa9cbbd7 Change guard on <regex.h> inclusion to use new
symbol `! HAVE_LIBC_REGEX' defined in m4/regex.m4.
1998-07-04 00:15:37 +00:00
Jim Meyering
6c93489171 . 1998-07-04 00:05:23 +00:00
Jim Meyering
345c323ffd (copy_internal): Rename variable and reverse sense of tests
to make the code a little clearer.
1998-07-03 23:56:44 +00:00
Jim Meyering
1f682431ae (df_readable): Rename local so as not to shadow global. 1998-07-03 21:05:06 +00:00
Jim Meyering
698a43f363 (SAME_INODE): New macro.
Use it to replace open-coded equivalents.
1998-07-03 20:57:31 +00:00
Jim Meyering
def9c2bf0b (copy_internal): Try harder identifying a relative
symbolic link in the current directory.
From Andreas Schwab.
1998-07-03 20:32:37 +00:00
Jim Meyering
6191d1839a Skip tests that depend on link(2) not following symlinks.
From Andreas Schwab.
1998-07-03 20:09:03 +00:00
Jim Meyering
184870f9bb (copy_internal): Don't skip test for same file if creating a hardlink
from symlink over a non-symlink while making backups.
1998-07-03 20:06:50 +00:00
Jim Meyering
6ccae5e2d8 (copy_internal): Don't call chown on a symlink. 1998-07-03 19:57:42 +00:00
Jim Meyering
31f6e2b228 *** empty log message *** 1998-07-01 12:46:39 +00:00
Jim Meyering
d05618c5c2 Don't define NDEBUG, now that it's done via configure's --disable-assert option. 1998-07-01 12:44:22 +00:00
Jim Meyering
7a314199db (read_filesystem_list):
Plug file descriptor leak on failure.
Report failure if lock file can't be opened for some reason
other than nonexistence.
1998-06-30 14:32:53 +00:00
Jim Meyering
837a447ba4 *** empty log message *** 1998-06-30 14:32:33 +00:00
Jim Meyering
5d2bbddf97 . 1998-06-30 03:57:55 +00:00
Jim Meyering
6dda2aaa52 (read_filesystem_list) [MOUNTED_GETMNTENT2]:
Always close stream and file descriptor before returning.
1998-06-30 03:56:57 +00:00
Jim Meyering
3fa1d4bb24 (main): Move the test of the result of the read_filesystem_list call
up out of if-block -- code in the else-block depends on it too.
1998-06-30 02:27:51 +00:00
Jim Meyering
1c84606b56 (read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
to avoid race conditions (e.g. with the automounter on Solaris 2.6).

Include <errno.h>, <fcntl.h>, <unistd.h>.
1998-06-30 02:15:43 +00:00
Jim Meyering
b1b273f24f *** empty log message *** 1998-06-29 20:34:02 +00:00
Jim Meyering
e211d3960f . 1998-06-29 20:33:24 +00:00
Jim Meyering
9282f5f8a6 . 1998-06-29 20:32:36 +00:00
Jim Meyering
1d2074e02a protoize 1998-06-29 20:29:28 +00:00
Jim Meyering
8dce8df49a . 1998-06-29 17:35:28 +00:00
Jim Meyering
4d4b2c8e5e *** empty log message *** 1998-06-29 17:31:11 +00:00
Jim Meyering
a72bab1a32 *** empty log message *** 1998-06-29 17:19:30 +00:00
Jim Meyering
affbb977af . 1998-06-29 17:03:13 +00:00
Jim Meyering
aa1c5467ec (fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS. 1998-06-29 17:01:48 +00:00
Jim Meyering
435fa5a7dd Include sys/param.h. NetBSD 1.3.1 requires this
for the definition of NGROUPS (used in a system header included
by sys/mount.h).
1998-06-29 16:57:09 +00:00
Jim Meyering
b7441176e3 *** empty log message *** 1998-06-29 16:24:37 +00:00
Jim Meyering
f3c14cb59f revert back to using lower case _unlocked wrapper names 1998-06-29 16:24:01 +00:00
Jim Meyering
8ba97d963e Include system.h only after error.h and readutmp.h
so we don't get redefinition warnings about getc, etc.
Revert back to using lower case _unlocked wrapper names.
1998-06-29 16:23:15 +00:00
Jim Meyering
223e88f957 *** empty log message *** 1998-06-29 16:16:58 +00:00
Jim Meyering
83d4b736d2 revert back to using lower case _unlocked wrapper names 1998-06-29 15:59:39 +00:00
Jim Meyering
257c5c4737 revert back to using lower case _unlocked wrapper names 1998-06-29 15:57:45 +00:00
Jim Meyering
391c960cba Update call to human_readable -- now there's one fewer arg. 1998-06-29 15:56:23 +00:00
Jim Meyering
62f208d493 . 1998-06-29 15:38:09 +00:00
Jim Meyering
60ae0b81a5 (__xstrtol), src/dd.c (parse_integer):
Add support for SI-like suffixes like "GB" and "TD".
(usage): Describe it.
1998-06-29 15:36:28 +00:00
Jim Meyering
09d344df5b (human_readable_base, output_units): Remove;
replace with new variable output_block_size.  All uses changed.
(long_options, usage, main): Add --block-size.
(main, decode_switches): Use new human_block_size function to
initialize output block size consistently with other programs.

From Paul Eggert.
1998-06-29 15:34:54 +00:00
Jim Meyering
43f4099c95 (human_readable_base, output_units): Remove;
replace with new variable output_block_size.  All uses changed.
(long_options, usage, main): Add --block-size.
(main, decode_switches): Use new human_block_size function to
initialize output block size consistently with other programs.

(print_header, show_dev): Shrink some columns and expand
others, to squeeze in support for today's larger filesystems.
(print_header): Print output block size using power-of-1024 SI format.
(df_readable): Coalesce last two args into one, for convenience.
All callers changed.
(main): Remove check for portable output format and larger
or human-readable block sizes.

From Paul Eggert.
1998-06-29 15:33:38 +00:00
Jim Meyering
476cb02516 * lib/xstrtol.c (bkm_scale): Don't assume that you can convert
unsigned long to double without losing information.
	(bkm_scale_by_power): New function.

	* lib/xstrtol.c (__xstrtol), src/dd.c (parse_integer):
	Add support for SI-like suffixes like "GB" and "TD".
	* src/dd.c (usage): Describe it.
1998-06-29 15:24:43 +00:00
Jim Meyering
159788fcca (__ZLONG_MAX): Remove. 1998-06-29 15:24:15 +00:00
Jim Meyering
f32dc5a2b0 (human_readable): Coalesce last two args into one, for convenience. 1998-06-29 15:23:45 +00:00
Jim Meyering
ea7102f120 * lib/human.c, lib/human.h (human_readable): Coalesce last two args
into one, for convenience.  All callers changed.
	(human_block_size): New function.
	* lib/human.c: Include <config.h> only if HAVE_CONFIG_H.
	Include <stdlib.h> if HAVE_STDLIB_H;
	declare getenv unless HAVE_DECL_GETENV.
	(_): New macro.
	Include <argmatch.h>, <error.h>, <xstrtoul.h>.
	(DEFAULT_BLOCK_SIZE): New macro.
	(block_size_args, block_size_types): New constants.
	(humblock): New function.
1998-06-29 15:23:04 +00:00
Jim Meyering
41ef62c472 *** empty log message *** 1998-06-29 14:27:03 +00:00
Jim Meyering
26d5ce2f26 . 1998-06-29 03:42:55 +00:00
Jim Meyering
868ed3b0af (usage): Make --kilobytes description consistent with
that in du and df.  From Gran Uddeborg.
1998-06-29 03:42:50 +00:00
Jim Meyering
6552bb980b *** empty log message *** 1998-06-29 03:42:18 +00:00
Jim Meyering
79a6760fe4 . 1998-06-29 02:27:55 +00:00
Jim Meyering
531453d901 . 1998-06-29 02:16:17 +00:00
Jim Meyering
1d94869663 . 1998-06-29 02:15:29 +00:00
Jim Meyering
ce195c7a07 . 1998-06-29 02:14:27 +00:00
Jim Meyering
09a2261919 . 1998-06-29 02:13:56 +00:00
Jim Meyering
c5eb9edf26 Change all uses of unlocked-wrapped functions to their upper case wrapper names. 1998-06-29 02:13:21 +00:00
Jim Meyering
dd9470cb58 Change all uses of unlocked-wrapped functions to their upper case wrapper names. 1998-06-29 02:11:07 +00:00
Jim Meyering
02fc5fa0d0 Change all uses of unlocked-wrapped functions to their upper case wrapper names. 1998-06-29 02:10:24 +00:00
Jim Meyering
b62793b100 . 1998-06-29 01:11:00 +00:00
Jim Meyering
c7af539321 (fsp_to_string): Clean out some crufty #ifdefs
now that we're using the jm_FSTYPENAME autoconf macro.
1998-06-29 01:10:24 +00:00
Jim Meyering
e989012b57 add #undefs, alphabetize 1998-06-29 01:00:51 +00:00
Jim Meyering
7aeda9a4d3 . 1998-06-28 23:51:58 +00:00
Jim Meyering
d51682ef43 *** empty log message *** 1998-06-28 23:51:47 +00:00
Jim Meyering
ab869ed00e . 1998-06-28 23:12:10 +00:00
Jim Meyering
73ab48d4e7 experimental support for -t [optional fd] -- probably soon to be backed out 1998-06-28 21:53:05 +00:00
Jim Meyering
73e6d60538 . 1998-06-28 21:42:37 +00:00
Jim Meyering
032aecf5e7 Require the new macro: jm_FUNC_GLIBC_UNLOCKED_IO. 1998-06-28 21:41:08 +00:00
Jim Meyering
8f3524de4a . 1998-06-28 21:40:12 +00:00
Jim Meyering
439fdff851 Add macro definitions for GNU libc unlocked wrappers. 1998-06-28 21:38:14 +00:00
Jim Meyering
933b990ab9 add a FIXME for output delimiter 1998-06-28 21:32:51 +00:00
Jim Meyering
ae965a958a remove `non-directory' 1998-06-28 21:13:04 +00:00
Jim Meyering
214ee5aecd *** empty log message *** 1998-06-28 21:11:31 +00:00
Jim Meyering
4dc12acc27 *** empty log message *** 1998-06-28 21:11:20 +00:00
Jim Meyering
a92dd43b7c Add DIRED_ prefix to the macros: FPUTS and FPUTS_LITERAL. 1998-06-28 20:34:29 +00:00
Jim Meyering
d2698caef3 s/PUTCHAR/DIRED_PUTCHAR/g. 1998-06-28 20:31:16 +00:00
Jim Meyering
db8fe3cf1f *** empty log message *** 1998-06-28 02:35:08 +00:00
Jim Meyering
664ba0841c *** empty log message *** 1998-06-27 23:54:10 +00:00
Jim Meyering
26d84b6c70 *** empty log message *** 1998-06-27 23:45:46 +00:00
Jim Meyering
70c8aaf873 Add two tests for double spacing. 1998-06-27 23:45:03 +00:00
Jim Meyering
182a1780ac (print_page): Break out of loop before double space test
if cols_ready_to_print is zero.
1998-06-27 23:43:40 +00:00
Jim Meyering
cf430d3590 *** empty log message *** 1998-06-27 22:10:02 +00:00
Jim Meyering
6ae99a4290 (copy_internal): Fix it so hard-link test is no longer hidden inside
big if-(backup_type == none) block.
1998-06-27 22:09:45 +00:00
Jim Meyering
c76172fbb0 *** empty log message *** 1998-06-27 21:36:28 +00:00
Jim Meyering
dd040b917a *** empty log message *** 1998-06-27 21:14:40 +00:00
Jim Meyering
4ec1fad4e7 *** empty log message *** 1998-06-27 21:03:16 +00:00
Jim Meyering
9d9fef5595 (copy_reg): Detect identical source and dest here.
(copy_internal): Make the test symmetric.
1998-06-27 20:44:23 +00:00
Jim Meyering
6fd3c331ba . 1998-06-27 20:37:17 +00:00
Jim Meyering
9b989298f4 *** empty log message *** 1998-06-27 20:35:26 +00:00
Jim Meyering
07507c07da (TESTS): Add same-file. 1998-06-27 20:35:16 +00:00
Jim Meyering
c96968a2a3 *** empty log message *** 1998-06-27 20:33:58 +00:00
Jim Meyering
a3e1200b4a *** empty log message *** 1998-06-27 20:33:22 +00:00
Jim Meyering
2b2424aab8 *** empty log message *** 1998-06-27 20:22:36 +00:00
Jim Meyering
994c3c82ef . 1998-06-27 20:20:25 +00:00
Jim Meyering
dfc86db1cc *** empty log message *** 1998-06-27 20:14:15 +00:00
Jim Meyering
162f6824cf *** empty log message *** 1998-06-27 20:10:29 +00:00
Jim Meyering
feccdc6c58 *** empty log message *** 1998-06-27 13:45:23 +00:00
Jim Meyering
2f617e52d6 changed --verbose message 1998-06-27 04:40:13 +00:00
Jim Meyering
d200f4974b (remove_file): Remove `non-directory' part of
`removing non-directory FILE' verbose message.
1998-06-27 04:39:25 +00:00
Jim Meyering
de45950430 (show_dev): Increase field width for blocks, used,
and available columns from 7 to 8.
1998-06-24 03:02:06 +00:00
Jim Meyering
4d95aa356f *** empty log message *** 1998-06-21 18:53:07 +00:00
Jim Meyering
d82af243b1 *** empty log message *** 1998-06-21 18:51:18 +00:00
Jim Meyering
2781ec69b7 . 1998-06-18 15:22:51 +00:00
Jim Meyering
4a9222e0c2 (check): Depend on $(maint_gen) so
`make maintainer-clean; ./configure; make check' works.
1998-06-18 15:20:03 +00:00
Jim Meyering
84c104b6da . 1998-06-07 14:45:55 +00:00
Jim Meyering
500594433a *** empty log message *** 1998-06-07 14:40:04 +00:00
Jim Meyering
ed1fdb8841 *** empty log message *** 1998-06-07 14:27:15 +00:00
Jim Meyering
5d59e18618 *** empty log message *** 1998-06-07 14:08:40 +00:00
Jim Meyering
94ff35fc2d . 1998-06-07 13:56:20 +00:00
Jim Meyering
dc6658157d . 1998-06-06 04:42:12 +00:00
Jim Meyering
36fc028151 *** empty log message *** 1998-06-05 13:00:17 +00:00
Jim Meyering
6db9dc96d3 *** empty log message *** 1998-06-01 03:31:42 +00:00
Jim Meyering
7af859841f . 1998-06-01 03:29:54 +00:00
Jim Meyering
dcfb3e037a (main): Fix argv-handling bug in my 1998-05-09 change.
Reported by Don Parsons.
1998-06-01 03:28:16 +00:00
Jim Meyering
bc63f10b59 *** empty log message *** 1998-06-01 03:27:57 +00:00
Jim Meyering
ce42a622b2 *** empty log message *** 1998-05-30 21:34:32 +00:00
Jim Meyering
5cd15e8abb Clean up ctime test. Note that it fails also
on Solaris5.5.1 tmpfs file systems.
1998-05-30 21:34:21 +00:00
Jim Meyering
c685d1c4cb . 1998-05-30 20:49:07 +00:00
Jim Meyering
cc13b3d81f *** empty log message *** 1998-05-30 20:48:26 +00:00
Jim Meyering
f23d890626 *** empty log message *** 1998-05-27 12:54:34 +00:00
Jim Meyering
e7976515e2 . 1998-05-27 12:41:08 +00:00
Jim Meyering
25485fa497 . 1998-05-27 12:39:37 +00:00
Jim Meyering
ab4ea710f1 (TESTS): s/cr-1/rt-1/ 1998-05-27 12:38:10 +00:00
Jim Meyering
39f78131e2 . 1998-05-27 12:36:38 +00:00
Jim Meyering
75637a7ef4 Don't use the ctime for testing, it is impossible to set it reliably. 1998-05-27 12:35:56 +00:00
Jim Meyering
9e1c89c38e (two_arguments): Don't test argv[pos][2] if it's past end of string. 1998-05-26 13:36:49 +00:00
113 changed files with 5171 additions and 603 deletions

3
THANKS
View File

@@ -9,15 +9,18 @@ Bengt Martensson: bengt@mathematik.uni-Bremen.de
Bjorn Helgaas: helgaas@rsn.hp.com
Charles Karney: karney@pppl.gov
Dirk Lattermann: dlatt@t-online.de
Don Parsons: dparsons@synapse.kent.edu
Eirik Fuller: eirik@netcom.com
Eli Zaretskii: eliz@is.elta.co.il
Emile LeBlanc: leblanc@math.toronto.edu
François Pinard: pinard@iro.umontreal.ca
Galen Hazelwood: galenh@micron.net
Göran Uddeborg: goeran@uddeborg.pp.se
Greg McGary: gkm@eng.ascend.com
Hugh Daniel: hugh@xanadu.com
James: james@albion.glarp.com
James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Tanis: jtt@soscorp.com
Jesse Thilo: jgt2@eecs.lehigh.edu
Joakim Rosqvist: dvljrt@cs.umu.se
John Gatewood Ham: zappaman@alphabox.compsci.buu.ac.th

View File

@@ -4,7 +4,6 @@
# 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

View File

@@ -19,9 +19,9 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h long-options.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
quotearg.h safe-read.h save-cwd.h savedir.h strverscmp.h \
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
xalloc.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c

View File

@@ -4,7 +4,6 @@
# 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
@@ -109,9 +108,9 @@ libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h closeout.h \
error.h exclude.h fnmatch.h fsusage.h \
getdate.h getline.h getopt.h group-member.h human.h long-options.h \
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
quotearg.h safe-read.h save-cwd.h savedir.h strverscmp.h \
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
xalloc.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c
@@ -144,9 +143,9 @@ DIST_COMMON = Makefile.am Makefile.in TODO alloca.c chown.c error.c \
error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
getdate.c getgroups.c getline.c group-member.c lchown.c lstat.c \
malloc.c memcmp.c memcpy.c memset.c mkdir.c mktime.c mountlist.c \
obstack.c obstack.h posixtm.c realloc.c regex.c regex.h rename.c \
rmdir.c rpmatch.c rx.c rx.h stat.c stpcpy.c strcasecmp.c strdup.c \
strftime.c strndup.c strstr.c strtol.c strtoul.c strverscmp.c ylwrap
obstack.c obstack.h posixtm.c realloc.c regex.c rename.c rmdir.c \
rpmatch.c stat.c stpcpy.c strcasecmp.c strdup.c strftime.c strndup.c \
strstr.c strtol.c strtoul.c strverscmp.c utime.c ylwrap
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@@ -165,11 +164,11 @@ DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
.deps/memset.P .deps/mkdir.P .deps/mktime.P .deps/modechange.P \
.deps/mountlist.P .deps/obstack.P .deps/path-concat.P .deps/posixtm \
.deps/posixtm.P .deps/quotearg.P .deps/realloc.P .deps/regex.P \
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.P \
.deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stat.P \
.deps/stpcpy.P .deps/strcasecmp.P .deps/strdup.P .deps/strftime.P \
.deps/stripslash.P .deps/strndup.P .deps/strstr.P .deps/strtol.P \
.deps/strtoul.P .deps/strverscmp.P .deps/userspec.P .deps/xgetcwd.P \
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/safe-read.P \
.deps/save-cwd.P .deps/savedir.P .deps/stat.P .deps/stpcpy.P \
.deps/strcasecmp.P .deps/strdup.P .deps/strftime.P .deps/stripslash.P \
.deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \
.deps/strverscmp.P .deps/userspec.P .deps/utime.P .deps/xgetcwd.P \
.deps/xmalloc.P .deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P \
.deps/yesno.P
SOURCES = $(libfu_a_SOURCES)
@@ -332,8 +331,6 @@ rmdir_.c: rmdir.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rmdir.c; then echo $(srcdir)/rmdir.c; else echo rmdir.c; fi` | $(ANSI2KNR) > rmdir_.c
rpmatch_.c: rpmatch.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rpmatch.c; then echo $(srcdir)/rpmatch.c; else echo rpmatch.c; fi` | $(ANSI2KNR) > rpmatch_.c
rx_.c: rx.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/rx.c; then echo $(srcdir)/rx.c; else echo rx.c; fi` | $(ANSI2KNR) > rx_.c
safe-read_.c: safe-read.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/safe-read.c; then echo $(srcdir)/safe-read.c; else echo safe-read.c; fi` | $(ANSI2KNR) > safe-read_.c
save-cwd_.c: save-cwd.c $(ANSI2KNR)
@@ -364,6 +361,8 @@ strverscmp_.c: strverscmp.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/strverscmp.c; then echo $(srcdir)/strverscmp.c; else echo strverscmp.c; fi` | $(ANSI2KNR) > strverscmp_.c
userspec_.c: userspec.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/userspec.c; then echo $(srcdir)/userspec.c; else echo userspec.c; fi` | $(ANSI2KNR) > userspec_.c
utime_.c: utime.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/utime.c; then echo $(srcdir)/utime.c; else echo utime.c; fi` | $(ANSI2KNR) > utime_.c
xgetcwd_.c: xgetcwd.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(CPPFLAGS) `if test -f $(srcdir)/xgetcwd.c; then echo $(srcdir)/xgetcwd.c; else echo xgetcwd.c; fi` | $(ANSI2KNR) > xgetcwd_.c
xmalloc_.c: xmalloc.c $(ANSI2KNR)
@@ -383,11 +382,11 @@ getgroups_.o getline_.o getopt_.o getopt1_.o group-member_.o hash_.o \
human_.o idcache_.o isdir_.o lchown_.o long-options_.o lstat_.o \
makepath_.o malloc_.o memcmp_.o memcpy_.o memset_.o mkdir_.o mktime_.o \
modechange_.o mountlist_.o obstack_.o path-concat_.o posixtm_.o \
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o rx_.o \
quotearg_.o realloc_.o regex_.o rename_.o rmdir_.o rpmatch_.o \
safe-read_.o save-cwd_.o savedir_.o stat_.o stpcpy_.o strcasecmp_.o \
strdup_.o strftime_.o stripslash_.o strndup_.o strstr_.o strtol_.o \
strtoul_.o strverscmp_.o userspec_.o xgetcwd_.o xmalloc_.o xstrdup_.o \
xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
strtoul_.o strverscmp_.o userspec_.o utime_.o xgetcwd_.o xmalloc_.o \
xstrdup_.o xstrtol_.o xstrtoul_.o yesno_.o : $(ANSI2KNR)
tags: TAGS

View File

@@ -1,5 +1,5 @@
/* human.c -- print human readable file size
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,9 +16,12 @@
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Originally contributed by lm@sgi.com;
--si and large file support added by eggert@twinsun.com. */
--si, output block size selection, and large file support
added by eggert@twinsun.com. */
#include <config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
@@ -34,6 +37,24 @@
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifndef HAVE_DECL_GETENV
char *getenv ();
#endif
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#include <argmatch.h>
#include <error.h>
#include <xstrtoul.h>
#include "human.h"
@@ -52,25 +73,32 @@ static const char suffixes[] =
/* Convert N to a human readable format in BUF.
N is expressed in units of FROM_UNITS; use units of TO_UNITS in the
output number. FROM_UNITS and TO_UNITS must be positive, and one must
be a multiple of the other.
N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must
be positive.
If BASE is nonzero, use a format like "127k" if possible,
using powers of BASE; otherwise, use ordinary decimal format.
Normally BASE is either 1000 or 1024; it must be at least 2.
Most people visually process strings of 3-4 digits effectively,
but longer strings of digits are more prone to misinterpretation.
Hence, converting to an abbreviated form usually improves readability.
Use a suffix indicating which power is being used.
For example, assuming BASE is 1024, 8500 would be converted to 8.3k,
If OUTPUT_BLOCK_SIZE is positive, use units of OUTPUT_BLOCK_SIZE in
the output number. OUTPUT_BLOCK_SIZE must be a multiple of
FROM_BLOCK_SIZE or vice versa.
If OUTPUT_BLOCK_SIZE is negative, use a format like "127k" if
possible, using powers of -OUTPUT_BLOCK_SIZE; otherwise, use
ordinary decimal format. Normally -OUTPUT_BLOCK_SIZE is either
1000 or 1024; it must be at least 2. Most people visually process
strings of 3-4 digits effectively, but longer strings of digits are
more prone to misinterpretation. Hence, converting to an
abbreviated form usually improves readability. Use a suffix
indicating which power is being used. For example, assuming
-OUTPUT_BLOCK_SIZE is 1024, 8500 would be converted to 8.3k,
133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller
than BASE aren't modified. */
than -OUTPUT_BLOCK_SIZE aren't modified. */
char *
human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
human_readable (uintmax_t n, char *buf,
int from_block_size, int output_block_size)
{
uintmax_t amt;
int base;
int to_block_size;
int tenths;
int power;
char *p;
@@ -81,6 +109,17 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */
int rounding;
if (output_block_size < 0)
{
base = -output_block_size;
to_block_size = 1;
}
else
{
base = 0;
to_block_size = output_block_size;
}
p = buf + LONGEST_HUMAN_READABLE;
*p = '\0';
@@ -89,11 +128,11 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
power = 0;
#endif
/* Adjust AMT out of FROM_UNITS units and into TO_UNITS units. */
/* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */
if (to_units <= from_units)
if (to_block_size <= from_block_size)
{
int multiplier = from_units / to_units;
int multiplier = from_block_size / to_block_size;
amt = n * multiplier;
tenths = rounding = 0;
@@ -119,7 +158,7 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
e *= base;
power++;
}
while (e * base <= amt && power < sizeof suffixes - 1);
while (e * base <= damt && power < sizeof suffixes - 1);
damt /= e;
@@ -133,7 +172,7 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
}
else
{
int divisor = to_units / from_units;
int divisor = to_block_size / from_block_size;
int r10 = (n % divisor) * 10;
int r2 = (r10 % divisor) * 2;
amt = n / divisor;
@@ -201,3 +240,47 @@ human_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
return p;
}
/* The default block size used for output. This number may change in
the future as disks get larger. */
#ifndef DEFAULT_BLOCK_SIZE
# define DEFAULT_BLOCK_SIZE 1024
#endif
static char const *const block_size_args[] = { "human-readable", "si", 0 };
static int const block_size_types[] = { -1024, -1000 };
static strtol_error
humblock (char const *spec, int *block_size)
{
int i;
if (! spec && ! (spec = getenv ("BLOCK_SIZE")))
*block_size = getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE;
else if (0 <= (i = argmatch (spec, block_size_args)))
*block_size = block_size_types[i];
else
{
char *ptr;
unsigned long val;
strtol_error e = xstrtoul (spec, &ptr, 0, &val, "eEgGkKmMpPtTyYzZ0");
if (e != LONGINT_OK)
return e;
if (*ptr)
return LONGINT_INVALID_SUFFIX_CHAR;
if ((int) val < 0 || val != (int) val)
return LONGINT_OVERFLOW;
*block_size = (int) val;
}
return LONGINT_OK;
}
void
human_block_size (char const *spec, int report_errors, int *block_size)
{
strtol_error e = humblock (spec, block_size);
if (e != LONGINT_OK && report_errors)
STRTOL_FATAL_ERROR (spec, _("block size"), e);
}

View File

@@ -15,6 +15,8 @@
# endif
# endif
char *human_readable PARAMS ((uintmax_t, char *, int, int, int));
char *human_readable PARAMS ((uintmax_t, char *, int, int));
void human_block_size PARAMS ((char const *, int, int *));
#endif /* HUMAN_H_ */

View File

@@ -25,6 +25,7 @@
#ifndef errno
extern int errno;
#endif
#include "lchown.h"
/* Work just like chown, except when FILE is a symbolic link.
In that case, set errno to ENOSYS and return -1. */

9
lib/lchown.h Normal file
View File

@@ -0,0 +1,9 @@
/* Some systems don't have ENOSYS. */
#ifndef ENOSYS
# ifdef ENOTSUP
# define ENOSYS ENOTSUP
# else
/* Some systems don't have ENOTSUP either. */
# define ENOSYS ENOMSG
# endif
#endif

View File

@@ -42,6 +42,19 @@ char *xrealloc ();
char *xstrdup ();
void error ();
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
@@ -116,10 +129,10 @@ void error ();
/* Return the value of the hexadecimal number represented by CP.
No prefix (like '0x') or suffix (like 'h') is expected to be
part of CP. */
/* FIXME: this can overflow */
static int
xatoi (cp)
char *cp;
xatoi (char *cp)
{
int val;
@@ -140,107 +153,120 @@ xatoi (cp)
}
#endif /* MOUNTED_GETMNTENT1. */
#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__) && !defined (__OpenBSD__)
#if MOUNTED_GETMNTINFO
# if ! HAVE_F_FSTYPENAME_IN_STATFS
static char *
fstype_to_string (t)
short t;
fstype_to_string (short t)
{
switch (t)
{
# ifdef MOUNT_PC
# ifdef MOUNT_PC
case MOUNT_PC:
return "pc";
# endif
# ifdef MOUNT_MFS
# endif
# ifdef MOUNT_MFS
case MOUNT_MFS:
return "mfs";
# endif
# ifdef MOUNT_LO
# endif
# ifdef MOUNT_LO
case MOUNT_LO:
return "lo";
# endif
# ifdef MOUNT_TFS
# endif
# ifdef MOUNT_TFS
case MOUNT_TFS:
return "tfs";
# endif
# ifdef MOUNT_TMP
# endif
# ifdef MOUNT_TMP
case MOUNT_TMP:
return "tmp";
# endif
# ifdef MOUNT_UFS
# endif
# ifdef MOUNT_UFS
case MOUNT_UFS:
return "ufs" ;
# endif
# ifdef MOUNT_NFS
# endif
# ifdef MOUNT_NFS
case MOUNT_NFS:
return "nfs" ;
# endif
# ifdef MOUNT_MSDOS
# endif
# ifdef MOUNT_MSDOS
case MOUNT_MSDOS:
return "msdos" ;
# endif
# ifdef MOUNT_LFS
# endif
# ifdef MOUNT_LFS
case MOUNT_LFS:
return "lfs" ;
# endif
# ifdef MOUNT_LOFS
# endif
# ifdef MOUNT_LOFS
case MOUNT_LOFS:
return "lofs" ;
# endif
# ifdef MOUNT_FDESC
# endif
# ifdef MOUNT_FDESC
case MOUNT_FDESC:
return "fdesc" ;
# endif
# ifdef MOUNT_PORTAL
# endif
# ifdef MOUNT_PORTAL
case MOUNT_PORTAL:
return "portal" ;
# endif
# ifdef MOUNT_NULL
# endif
# ifdef MOUNT_NULL
case MOUNT_NULL:
return "null" ;
# endif
# ifdef MOUNT_UMAP
# endif
# ifdef MOUNT_UMAP
case MOUNT_UMAP:
return "umap" ;
# endif
# ifdef MOUNT_KERNFS
# endif
# ifdef MOUNT_KERNFS
case MOUNT_KERNFS:
return "kernfs" ;
# endif
# ifdef MOUNT_PROCFS
# endif
# ifdef MOUNT_PROCFS
case MOUNT_PROCFS:
return "procfs" ;
# endif
# ifdef MOUNT_AFS
# endif
# ifdef MOUNT_AFS
case MOUNT_AFS:
return "afs" ;
# endif
# ifdef MOUNT_CD9660
# endif
# ifdef MOUNT_CD9660
case MOUNT_CD9660:
return "cd9660" ;
# endif
# ifdef MOUNT_UNION
# endif
# ifdef MOUNT_UNION
case MOUNT_UNION:
return "union" ;
# endif
# ifdef MOUNT_DEVFS
# endif
# ifdef MOUNT_DEVFS
case MOUNT_DEVFS:
return "devfs" ;
# endif
# ifdef MOUNT_EXT2FS
# endif
# ifdef MOUNT_EXT2FS
case MOUNT_EXT2FS:
return "ext2fs" ;
# endif
# endif
default:
return "?";
}
}
# endif /* ! HAVE_F_FSTYPENAME_IN_STATFS */
/* __NetBSD__ || BSD_NET2 || __OpenBSD__ */
static char *
fsp_to_string (const struct statfs *fsp)
{
# if defined HAVE_F_FSTYPENAME_IN_STATFS
return fsp->f_fstypename;
# else
return fstype_to_string (fsp->f_type);
# endif
}
#endif /* MOUNTED_GETMNTINFO */
#ifdef MOUNTED_VMOUNT /* AIX. */
static char *
fstype_to_string (t)
int t;
fstype_to_string (int t)
{
struct vfs_ent *e;
@@ -256,21 +282,16 @@ fstype_to_string (t)
Add each entry to the tail of the list so that they stay in order.
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
the returned list are valid. Otherwise, they might not be.
If ALL_FS is zero, do not return entries for filesystems that
are automounter (dummy) entries. */
If ALL_FS is positive, return all entries; if zero, omit entries
for filesystems that are automounter (dummy) entries; if negative,
also omit non-local filesystems. */
struct mount_entry *
read_filesystem_list (need_fs_type, all_fs)
int need_fs_type, all_fs;
read_filesystem_list (int need_fs_type, int all_fs)
{
struct mount_entry *mount_list;
struct mount_entry *me;
struct mount_entry *mtail;
/* Start the list off with a dummy entry. */
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_next = NULL;
mount_list = mtail = me;
struct mount_entry **mtail = &mount_list;
#ifdef MOUNTED_LISTMNTENT
{
@@ -285,18 +306,17 @@ read_filesystem_list (need_fs_type, all_fs)
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
return NULL;
p = mntlist;
while(p){
for (p = mntlist; p; p = p->next) {
mnt = p->ment;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt->mnt_type))
continue;
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
me->me_devname = xstrdup(mnt->mnt_fsname);
me->me_mountdir = xstrdup(mnt->mnt_dir);
me->me_type = xstrdup(mnt->mnt_type);
me->me_dev = -1;
me->me_next = NULL;
mtail->me_next = me;
mtail = me;
p = p->next;
*mtail = me;
mtail = &me->me_next;
}
freemntlist(mntlist);
}
@@ -315,8 +335,10 @@ read_filesystem_list (need_fs_type, all_fs)
while ((mnt = getmntent (fp)))
{
if (!all_fs && (!strcmp (mnt->mnt_type, "ignore")
|| !strcmp (mnt->mnt_type, "auto")))
if (all_fs <= 0 && (!strcmp (mnt->mnt_type, "ignore")
|| !strcmp (mnt->mnt_type, "auto")))
continue;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt->mnt_type))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
@@ -333,15 +355,14 @@ read_filesystem_list (need_fs_type, all_fs)
}
else
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
if (endmntent (fp) == 0)
return NULL;
goto free_then_fail;
}
#endif /* MOUNTED_GETMNTENT1. */
@@ -353,23 +374,21 @@ read_filesystem_list (need_fs_type, all_fs)
entries = getmntinfo (&fsp, MNT_NOWAIT);
if (entries < 0)
return NULL;
while (entries-- > 0)
for (; entries-- > 0; fsp++)
{
char *fs_type = fsp_to_string (fsp);
if (all_fs < 0 && REMOTE_FS_TYPE (fs_type))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsp->f_mntfromname);
me->me_mountdir = xstrdup (fsp->f_mntonname);
# if defined (__NetBSD__) || defined (__OpenBSD__)
me->me_type = xstrdup (fsp->f_fstypename);
# else
me->me_type = fstype_to_string (fsp->f_type);
# endif
me->me_type = fs_type;
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
fsp++;
*mtail = me;
mtail = &me->me_next;
}
}
#endif /* MOUNTED_GETMNTINFO */
@@ -380,22 +399,25 @@ read_filesystem_list (need_fs_type, all_fs)
int val;
struct fs_data fsd;
while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
(char *) 0)) > 0)
while (errno = 0,
0 <= (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
(char *) 0)))
{
if (all_fs < 0 && REMOTE_FS_TYPE (gt_names[fsd.fd_req.fstype]))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsd.fd_req.devname);
me->me_mountdir = xstrdup (fsd.fd_req.path);
me->me_type = gt_names[fsd.fd_req.fstype];
me->me_dev = fsd.fd_req.dev;
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
if (val < 0)
return NULL;
goto free_then_fail;
}
#endif /* MOUNTED_GETMNT. */
@@ -420,16 +442,18 @@ read_filesystem_list (need_fs_type, all_fs)
for (counter = 0; counter < numsys; counter++)
{
if (all_fs < 0 && REMOTE_FS_TYPE (mnt_names[stats[counter].f_type]))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (stats[counter].f_mntfromname);
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
me->me_type = mnt_names[stats[counter].f_type];
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
free (stats);
@@ -448,6 +472,24 @@ read_filesystem_list (need_fs_type, all_fs)
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
{
char *fs_type = "";
# ifdef GETFSTYP /* SVR3. */
if (need_fs_type || all_fs < 0)
{
struct statfs fsd;
char typebuf[FSTYPSZ];
if (statfs (mnt.mt_filsys, &fsd, sizeof fsd, 0) != -1
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
{
if (all_fs < 0 && REMOTE_FS_TYPE (typebuf))
continue;
fs_type = xstrdup (typebuf);
}
}
# endif
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
# ifdef GETFSTYP /* SVR3. */
me->me_devname = xstrdup (mnt.mt_dev);
@@ -458,27 +500,23 @@ read_filesystem_list (need_fs_type, all_fs)
# endif
me->me_mountdir = xstrdup (mnt.mt_filsys);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_type = "";
# ifdef GETFSTYP /* SVR3. */
if (need_fs_type)
{
struct statfs fsd;
char typebuf[FSTYPSZ];
if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
me->me_type = xstrdup (typebuf);
}
# endif
me->me_next = NULL;
me->me_type = fs_type;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
if (ferror (fp))
{
int saved_errno = errno;
fclose (fp);
errno = saved_errno;
goto free_then_fail;
}
if (fclose (fp) == EOF)
return NULL;
goto free_then_fail;
}
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
@@ -487,16 +525,18 @@ read_filesystem_list (need_fs_type, all_fs)
struct mntent **mnttbl=getmnttbl(),**ent;
for (ent=mnttbl;*ent;ent++)
{
if (all_fs < 0 && REMOTE_FS_TYPE ((*ent)->mt_fstype))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup ( (*ent)->mt_resource);
me->me_mountdir = xstrdup( (*ent)->mt_directory);
me->me_type = xstrdup ((*ent)->mt_fstype);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
endmnttbl();
}
@@ -508,33 +548,74 @@ read_filesystem_list (need_fs_type, all_fs)
char *table = MNTTAB;
FILE *fp;
int ret;
int lockfd = -1;
# if defined F_RDLCK && defined F_SETLKW
/* MNTTAB_LOCK is a macro name of our own invention; it's not present in
e.g. Solaris 2.6. If the SVR4 folks ever define a macro
for this file name, we should use their macro name instead.
(Why not just lock MNTTAB directly? We don't know.) */
# ifndef MNTTAB_LOCK
# define MNTTAB_LOCK "/etc/.mnttab.lock"
# endif
lockfd = open (MNTTAB_LOCK, O_RDONLY);
if (0 <= lockfd)
{
struct flock flock;
flock.l_type = F_RDLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 0;
while (fcntl (lockfd, F_SETLKW, &flock) == -1)
if (errno != EINTR)
{
int saved_errno = errno;
close (lockfd);
errno = saved_errno;
return NULL;
}
}
else if (errno != ENOENT)
return NULL;
# endif
errno = 0;
fp = fopen (table, "r");
if (fp == NULL)
return NULL;
while ((ret = getmntent (fp, &mnt)) == 0)
ret = errno;
else
{
/* Don't show automounted filesystems twice on e.g., Solaris. */
if (!all_fs && MNT_IGNORE (&mnt))
continue;
while ((ret = getmntent (fp, &mnt)) == 0)
{
/* Don't show automounted filesystems twice on e.g., Solaris. */
if (all_fs <= 0 && MNT_IGNORE (&mnt))
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);
me->me_type = xstrdup (mnt.mnt_fstype);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
if (all_fs < 0 && REMOTE_FS_TYPE (mnt.mnt_fstype))
continue;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);
me->me_type = xstrdup (mnt.mnt_fstype);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
mtail = &me->me_next;
}
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
}
if (ret > 0)
return NULL;
if (fclose (fp) == EOF)
return NULL;
if (0 <= lockfd && close (lockfd) != 0)
ret = errno;
if (0 <= ret)
{
errno = ret;
goto free_then_fail;
}
}
#endif /* MOUNTED_GETMNTENT2. */
@@ -555,6 +636,8 @@ read_filesystem_list (need_fs_type, all_fs)
thisent += vmp->vmt_length)
{
vmp = (struct vmount *) thisent;
if (all_fs < 0 && vmp->vmt_flags & MNT_REMOTE)
continue;
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
if (vmp->vmt_flags & MNT_REMOTE)
{
@@ -576,19 +659,35 @@ read_filesystem_list (need_fs_type, all_fs)
me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
*mtail = me;
mtail = &me->me_next;
}
free (entries);
}
#endif /* MOUNTED_VMOUNT. */
/* Free the dummy head. */
me = mount_list;
mount_list = mount_list->me_next;
free (me);
*mtail = NULL;
return mount_list;
free_then_fail:
{
int saved_errno = errno;
*mtail = NULL;
while (mount_list)
{
me = mount_list->me_next;
free (mount_list->me_devname);
free (mount_list->me_mountdir);
/* FIXME: me_type is not always malloced. */
free (mount_list);
mount_list = me;
}
errno = saved_errno;
return NULL;
}
}

View File

@@ -1,5 +1,5 @@
/* mountlist.h -- declarations for list of mounted filesystems
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
Copyright (C) 1991, 1992, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,8 +25,19 @@ struct mount_entry
struct mount_entry *me_next;
};
#if __STDC__
struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs);
#else
struct mount_entry *read_filesystem_list ();
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
struct mount_entry *read_filesystem_list PARAMS ((int need_fs_type,
int all_fs));
/* In most environments, by default, a filesystem type is remote if it
begins with "nfs". This allows variants like "nfs3". */
#ifndef REMOTE_FS_TYPE
# define REMOTE_FS_TYPE(t) (!strncmp (t, "nfs", 3))
#endif

View File

@@ -1,6 +1,6 @@
/* Determine whether string value is affirmation or negative response
according to current locale's data.
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,11 +30,7 @@
#endif
#include <sys/types.h>
#if WITH_REGEX
# include <regex.h>
#else
# include <rx.h>
#endif
#include <regex.h>
#if ENABLE_NLS
# include <libintl.h>

View File

@@ -38,7 +38,7 @@ extern int errno;
for an error. */
ssize_t
safe_read (int desc, char *ptr, size_t len)
safe_read (int desc, void *ptr, size_t len)
{
ssize_t n_chars;

View File

@@ -7,4 +7,4 @@
#endif
ssize_t
safe_read PARAMS ((int desc, char *ptr, size_t len));
safe_read PARAMS ((int desc, void *ptr, size_t len));

81
lib/utime.c Normal file
View File

@@ -0,0 +1,81 @@
/* Copyright (C) 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* derived from a function in touch.c */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef utime
#include <sys/types.h>
#ifdef HAVE_UTIME_H
# include <utime.h>
#endif
#include "safe-read.h"
/* Some systems (even some that do have <utime.h>) don't declare this
structure anywhere. */
#ifndef HAVE_STRUCT_UTIMBUF
struct utimbuf
{
long actime;
long modtime;
};
#endif
/* Emulate utime (file, NULL) for systems (like 4.3BSD) that do not
interpret it to set the access and modification times of FILE to
the current time. Return 0 if successful, -1 if not. */
static int
utime_null (const char *file)
{
#if HAVE_UTIMES_NULL
return utimes (file, 0);
#else
int fd;
char c;
int status = 0;
struct stat sb;
fd = open (file, O_RDWR, 0666);
if (fd < 0
|| fstat (fd, &sb) < 0
|| safe_read (fd, &c, sizeof (char)) < 0
|| lseek (fd, (off_t) 0, SEEK_SET) < 0
|| full_write (fd, &c, sizeof (char)) < 0
/* Maybe do this -- it's necessary on SunOS4.1.3 with some combination
of patches, but that system doesn't use this code: it has utimes.
|| fsync (fd) < 0
*/
|| ftruncate (fd, st.st_size) < 0
|| close (fd) < 0)
status = -1;
return status;
#endif
}
int
rpl_utime (const char *file, const struct utimbuf *times)
{
if (times)
return utime (file, times);
return utime_null (file);
}

View File

@@ -21,6 +21,8 @@
# include <config.h>
#endif
#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
#endif
@@ -34,7 +36,12 @@
# endif
#endif
#define NDEBUG
/* Some pre-ANSI implementations (e.g. SunOS 4)
need stderr defined if assertion checking is enabled. */
#ifndef NDEBUG
# include <stdio.h>
#endif
#include <assert.h>
#include <errno.h>
@@ -71,40 +78,41 @@ extern int errno;
__unsigned long int __strtol ();
static int
bkm_scale (x, scale_factor)
__unsigned long int *x;
int scale_factor;
bkm_scale (__unsigned long int *x, int scale_factor)
{
/* The cast to `__unsigned long int' before the cast to double is
required to work around a bug in SunOS's /bin/cc. */
if (*x > (double) ((__unsigned long int) __ZLONG_MAX) / scale_factor)
{
__unsigned long int product = *x * scale_factor;
if (*x != product / scale_factor)
return 1;
*x = product;
return 0;
}
static int
bkm_scale_by_power (__unsigned long int *x, int base, int power)
{
while (power--)
if (bkm_scale (x, base))
return 1;
}
*x *= scale_factor;
return 0;
}
/* FIXME: comment. */
strtol_error
__xstrtol (s, ptr, base, val, valid_suffixes)
const char *s;
char **ptr;
int base;
__unsigned long int *val;
const char *valid_suffixes;
__xstrtol (const char *s, char **ptr, int strtol_base,
__unsigned long int *val, const char *valid_suffixes)
{
char *t_ptr;
char **p;
__unsigned long int tmp;
assert (0 <= base && base <= 36);
assert (0 <= strtol_base && strtol_base <= 36);
p = (ptr ? ptr : &t_ptr);
errno = 0;
tmp = __strtol (s, p, base);
tmp = __strtol (s, p, strtol_base);
if (errno != 0)
return LONGINT_OVERFLOW;
if (*p == s)
@@ -121,44 +129,92 @@ __xstrtol (s, ptr, base, val, valid_suffixes)
if (**p != '\0')
{
int base = 1024;
int suffixes = 1;
int overflow;
if (!strchr (valid_suffixes, **p))
return LONGINT_INVALID_SUFFIX_CHAR;
if (strchr (valid_suffixes, '0'))
{
/* The ``valid suffix'' '0' is a special flag meaning that
an optional second suffix is allowed, which can change
the base, e.g. "100MD" for 100 megabytes decimal. */
switch (p[0][1])
{
case 'B':
suffixes++;
break;
case 'D':
base = 1000;
suffixes++;
break;
}
}
switch (**p)
{
case 'b':
if (bkm_scale (&tmp, 512))
return LONGINT_OVERFLOW;
++(*p);
break;
case 'c':
++(*p);
overflow = bkm_scale (&tmp, 512);
break;
case 'B':
case 'k':
if (bkm_scale (&tmp, 1024))
return LONGINT_OVERFLOW;
++(*p);
overflow = bkm_scale (&tmp, 1024);
break;
case 'm':
if (bkm_scale (&tmp, 1024 * 1024))
return LONGINT_OVERFLOW;
++(*p);
case 'c':
overflow = 0;
break;
case 'E': /* Exa */
overflow = bkm_scale_by_power (&tmp, base, 6);
break;
case 'G': /* Giga */
overflow = bkm_scale_by_power (&tmp, base, 3);
break;
case 'k': /* kilo */
overflow = bkm_scale_by_power (&tmp, base, 1);
break;
case 'M': /* Mega */
case 'm': /* 'm' is undocumented; for backward compatibility only */
overflow = bkm_scale_by_power (&tmp, base, 2);
break;
case 'P': /* Peta */
overflow = bkm_scale_by_power (&tmp, base, 5);
break;
case 'T': /* Tera */
overflow = bkm_scale_by_power (&tmp, base, 4);
break;
case 'w':
if (bkm_scale (&tmp, 2))
return LONGINT_OVERFLOW;
++(*p);
overflow = bkm_scale (&tmp, 2);
break;
case 'Y': /* Yotta */
overflow = bkm_scale_by_power (&tmp, base, 8);
break;
case 'Z': /* Zetta */
overflow = bkm_scale_by_power (&tmp, base, 7);
break;
default:
return LONGINT_INVALID_SUFFIX_CHAR;
break;
}
if (overflow)
return LONGINT_OVERFLOW;
(*p) += suffixes;
}
*val = tmp;

View File

@@ -5,12 +5,10 @@
# define __xstrtol xstrtoul
# define __strtol strtoul
# define __unsigned unsigned
# define __ZLONG_MAX ULONG_MAX
# else
# define __xstrtol xstrtol
# define __strtol strtol
# define __unsigned /* empty */
# define __ZLONG_MAX LONG_MAX
# endif
# ifndef PARAMS

View File

@@ -1,3 +1,52 @@
1998-07-25 Jim Meyering <meyering@ascend.com>
* utime.m4 (jm_FUNC_UTIME): New file and macro.
* utimes.m4 (jm_FUNC_UTIMES_NULL): New file and macro.
1998-07-09 Manfred Hollstein <manfred@s-direktnet.de>
* chown.m4 (jm_FUNC_CHOWN): Add a check to verify that the
uid and gid actually remain unchanged.
1998-07-07 Jim Meyering <meyering@ascend.com>
* jm-glibc-io.m4: Remove fclose_unlocked.
1998-07-04 Jim Meyering <meyering@ascend.com>
* regex.m4: Use syscmd, ifelse, and sysval. Mainly as an exercise
to prove that this macro can be used in packages without regex.c.
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* gettext.m4 (AM_WITH_NLS): Remove intl/libintl.h if <libintl.h>
is to be used.
1998-07-03 Jim Meyering <meyering@ascend.com>
* gettext.m4: Add -lintl if it's found to be necessary.
* gettext.m4: New file -- from gettext-0.10.35.
* lcmessage.m4: Likewise.
* progtest.m4: Likewise.
* regex.m4 (jm_WITH_REGEX): New file and macro.
* jm-macros.m4: Require the new macro.
1998-06-29 Jim Meyering <meyering@ascend.com>
* fstypename.m4: Include sys/param.h. NetBSD 1.3.1 requires this
for the definition of NGROUPS (used in a system header included
by sys/mount.h).
1998-06-28 Jim Meyering <meyering@ascend.com>
* ls-mntd-fs.m4: New file.
* fstypename.m4: New file.
* jm-macros.m4: Require the new macro.
* jm-glibc-io.m4: New file.
1998-05-19 Jim Meyering <meyering@ascend.com>
* jm-macros.m4: Add jm_FUNC_LCHOWN.

View File

@@ -2,11 +2,13 @@
##m4-files-begin
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 chown.m4 \
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 getgroups.m4 getline.m4 \
getloadavg.m4 inttypes_h.m4 isc-posix.m4 jm-macros.m4 jm-mktime.m4 \
jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 \
perl.m4 prereq.m4 putenv.m4 readdir.m4 realloc.m4 ssize_t.m4 stat.m4 \
strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 getgroups.m4 \
getline.m4 getloadavg.m4 gettext.m4 inttypes_h.m4 isc-posix.m4 \
jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 \
lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 \
perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 \
ssize_t.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 \
utimes.m4
##m4-files-end

View File

@@ -4,7 +4,6 @@
# 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
@@ -91,11 +90,13 @@ YACC = @YACC@
l = @l@
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 chown.m4 \
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 getgroups.m4 getline.m4 \
getloadavg.m4 inttypes_h.m4 isc-posix.m4 jm-macros.m4 jm-mktime.m4 \
jm-winsz1.m4 jm-winsz2.m4 lchown.m4 lfs.m4 lstat.m4 malloc.m4 memcmp.m4 \
perl.m4 prereq.m4 putenv.m4 readdir.m4 realloc.m4 ssize_t.m4 stat.m4 \
strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4
const.m4 d-ino.m4 d-type.m4 decl.m4 error.m4 fstypename.m4 getgroups.m4 \
getline.m4 getloadavg.m4 gettext.m4 inttypes_h.m4 isc-posix.m4 \
jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 jm-winsz1.m4 jm-winsz2.m4 \
lchown.m4 lcmessage.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 \
perl.m4 prereq.m4 progtest.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 \
ssize_t.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 \
utimes.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =

View File

@@ -17,6 +17,7 @@ AC_DEFUN(jm_FUNC_CHOWN,
AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
[AC_TRY_RUN([
# include <sys/types.h>
# include <stat.h>
# include <fcntl.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -28,7 +29,14 @@ AC_DEFUN(jm_FUNC_CHOWN,
char *f = "conftestchown";
if (creat (f, 0600) < 0)
exit (1);
exit (chown (f, (uid_t) -1, (gid_t) -1) == -1 ? 1 : 0);
if (stat (f, &before) < 0)
exit (1);
if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
exit (1);
if (stat (f, &after) < 0)
exit (1);
exit ((before.st_uid == after.st_uid
&& before.st_gid == after.st_gid) ? 0 : 1);
}
],
jm_cv_func_working_chown=yes,

42
m4/fstypename.m4 Normal file
View File

@@ -0,0 +1,42 @@
#serial 1
dnl From Jim Meyering.
dnl
dnl See if struct statfs has the f_fstypename member.
dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS.
dnl
AC_DEFUN(jm_FSTYPENAME,
[
AC_CACHE_CHECK([for f_fstypename in struct statfs],
fu_cv_sys_f_fstypename_in_statfs,
[
AC_TRY_COMPILE(
[
#include <sys/param.h>
#include <sys/types.h>
#include <sys/mount.h>
],
[struct statfs s; int i = sizeof s.f_fstypename;],
fu_cv_sys_f_fstypename_in_statfs=yes,
fu_cv_sys_f_fstypename_in_statfs=no
)
]
)
if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
if test x = y; then
# This code is deliberately never run via ./configure.
# FIXME: this is a hack to make autoheader put the corresponding
# HAVE_* undef for this symbol in config.h.in. This saves me the
# trouble of having to maintain the #undef in acconfig.h manually.
AC_CHECK_FUNCS(F_FSTYPENAME_IN_STATFS)
fi
# Defining it this way (rather than via AC_DEFINE) short-circuits the
# autoheader check -- autoheader doesn't know it's already been taken
# care of by the hack above.
ac_kludge=HAVE_F_FSTYPENAME_IN_STATFS
AC_DEFINE_UNQUOTED($ac_kludge)
fi
]
)

324
m4/gettext.m4 Normal file
View File

@@ -0,0 +1,324 @@
# Macro to add for using GNU gettext.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
# This file can be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 105
AC_DEFUN(AM_WITH_NLS,
[AC_MSG_CHECKING([whether NLS is requested])
dnl Default is enabled NLS
AC_ARG_ENABLE(nls,
[ --disable-nls do not use Native Language Support],
USE_NLS=$enableval, USE_NLS=yes)
AC_MSG_RESULT($USE_NLS)
AC_SUBST(USE_NLS)
USE_INCLUDED_LIBINTL=no
dnl If we use NLS figure out what method
if test "$USE_NLS" = "yes"; then
AC_DEFINE(ENABLE_NLS)
AC_MSG_CHECKING([whether included gettext is requested])
AC_ARG_WITH(included-gettext,
[ --with-included-gettext use the GNU gettext library included here],
nls_cv_force_use_gnu_gettext=$withval,
nls_cv_force_use_gnu_gettext=no)
AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
dnl User does not insist on using GNU NLS library. Figure out what
dnl to use. If gettext or catgets are available (in this order) we
dnl use this. Else we have to fall back to GNU NLS library.
dnl catgets is only used if permitted by option --with-catgets.
nls_cv_header_intl=
nls_cv_header_libgt=
CATOBJEXT=NONE
AC_CHECK_HEADER(libintl.h,
[AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
[AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
if test "$gt_cv_func_gettext_libc" != "yes"; then
AC_CHECK_LIB(intl, bindtextdomain,
[AC_CACHE_CHECK([for gettext in libintl],
gt_cv_func_gettext_libintl,
[AC_CHECK_LIB(intl, gettext,
gt_cv_func_gettext_libintl=yes,
gt_cv_func_gettext_libintl=no)],
gt_cv_func_gettext_libintl=no)])
if test "$gt_cv_func_gettext_libintl" = yes; then
LIBS="$LIBS -lintl"
fi
fi
if test "$gt_cv_func_gettext_libc" = "yes" \
|| test "$gt_cv_func_gettext_libintl" = "yes"; then
AC_DEFINE(HAVE_GETTEXT)
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
if test "$MSGFMT" != "no"; then
AC_CHECK_FUNCS(dcgettext)
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
return _nl_msg_cat_cntr],
[CATOBJEXT=.gmo
DATADIRNAME=share],
[CATOBJEXT=.mo
DATADIRNAME=lib])
INSTOBJEXT=.mo
fi
fi
])
if test "$CATOBJEXT" = "NONE"; then
AC_MSG_CHECKING([whether catgets can be used])
AC_ARG_WITH(catgets,
[ --with-catgets use catgets functions if available],
nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
AC_MSG_RESULT($nls_cv_use_catgets)
if test "$nls_cv_use_catgets" = "yes"; then
dnl No gettext in C library. Try catgets next.
AC_CHECK_LIB(i, main)
AC_CHECK_FUNC(catgets,
[AC_DEFINE(HAVE_CATGETS)
INTLOBJS="\$(CATOBJS)"
AC_PATH_PROG(GENCAT, gencat, no)dnl
if test "$GENCAT" != "no"; then
AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
if test "$GMSGFMT" = "no"; then
AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
fi
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
USE_INCLUDED_LIBINTL=yes
CATOBJEXT=.cat
INSTOBJEXT=.cat
DATADIRNAME=lib
INTLDEPS='$(top_builddir)/intl/libintl.a'
INTLLIBS=$INTLDEPS
LIBS=`echo $LIBS | sed -e 's/-lintl//'`
nls_cv_header_intl=intl/libintl.h
nls_cv_header_libgt=intl/libgettext.h
fi])
fi
fi
if test "$CATOBJEXT" = "NONE"; then
dnl Neither gettext nor catgets in included in the C library.
dnl Fall back on GNU gettext library.
nls_cv_use_gnu_gettext=yes
fi
fi
if test "$nls_cv_use_gnu_gettext" = "yes"; then
dnl Mark actions used to generate GNU NLS library.
INTLOBJS="\$(GETTOBJS)"
AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
AC_SUBST(MSGFMT)
USE_INCLUDED_LIBINTL=yes
CATOBJEXT=.gmo
INSTOBJEXT=.mo
DATADIRNAME=share
INTLDEPS='$(top_builddir)/intl/libintl.a'
INTLLIBS=$INTLDEPS
LIBS=`echo $LIBS | sed -e 's/-lintl//'`
nls_cv_header_intl=intl/libintl.h
nls_cv_header_libgt=intl/libgettext.h
fi
dnl Test whether we really found GNU xgettext.
if test "$XGETTEXT" != ":"; then
dnl If it is no GNU xgettext we define it as : so that the
dnl Makefiles still can work.
if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
: ;
else
AC_MSG_RESULT(
[found xgettext program is not GNU xgettext; ignore it])
XGETTEXT=":"
fi
fi
# We need to process the po/ directory.
POSUB=po
else
DATADIRNAME=share
nls_cv_header_intl=intl/libintl.h
nls_cv_header_libgt=intl/libgettext.h
fi
if test -z "$nsl_cv_header_intl"; then
# Clean out junk possibly left behind by a previous configuration.
rm -f intl/libintl.h
fi
AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
AC_OUTPUT_COMMANDS(
[case "$CONFIG_FILES" in *po/Makefile.in*)
sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
esac])
# If this is used in GNU gettext we have to set USE_NLS to `yes'
# because some of the sources are only built for this goal.
if test "$PACKAGE" = gettext; then
USE_NLS=yes
USE_INCLUDED_LIBINTL=yes
fi
dnl These rules are solely for the distribution goal. While doing this
dnl we only have to keep exactly one list of the available catalogs
dnl in configure.in.
for lang in $ALL_LINGUAS; do
GMOFILES="$GMOFILES $lang.gmo"
POFILES="$POFILES $lang.po"
done
dnl Make all variables we use known to autoconf.
AC_SUBST(USE_INCLUDED_LIBINTL)
AC_SUBST(CATALOGS)
AC_SUBST(CATOBJEXT)
AC_SUBST(DATADIRNAME)
AC_SUBST(GMOFILES)
AC_SUBST(INSTOBJEXT)
AC_SUBST(INTLDEPS)
AC_SUBST(INTLLIBS)
AC_SUBST(INTLOBJS)
AC_SUBST(POFILES)
AC_SUBST(POSUB)
])
AC_DEFUN(AM_GNU_GETTEXT,
[AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_C_INLINE])dnl
AC_REQUIRE([AC_TYPE_OFF_T])dnl
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_FUNC_MMAP])dnl
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
unistd.h sys/param.h])
AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
strdup __argz_count __argz_stringify __argz_next])
if test "${ac_cv_func_stpcpy+set}" != "set"; then
AC_CHECK_FUNCS(stpcpy)
fi
if test "${ac_cv_func_stpcpy}" = "yes"; then
AC_DEFINE(HAVE_STPCPY)
fi
AM_LC_MESSAGES
AM_WITH_NLS
if test "x$CATOBJEXT" != "x"; then
if test "x$ALL_LINGUAS" = "x"; then
LINGUAS=
else
AC_MSG_CHECKING(for catalogs to be installed)
NEW_LINGUAS=
for lang in ${LINGUAS=$ALL_LINGUAS}; do
case "$ALL_LINGUAS" in
*$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
esac
done
LINGUAS=$NEW_LINGUAS
AC_MSG_RESULT($LINGUAS)
fi
dnl Construct list of names of catalog files to be constructed.
if test -n "$LINGUAS"; then
for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
fi
fi
dnl The reference to <locale.h> in the installed <libintl.h> file
dnl must be resolved because we cannot expect the users of this
dnl to define HAVE_LOCALE_H.
if test $ac_cv_header_locale_h = yes; then
INCLUDE_LOCALE_H="#include <locale.h>"
else
INCLUDE_LOCALE_H="\
/* The system does not provide the header <locale.h>. Take care yourself. */"
fi
AC_SUBST(INCLUDE_LOCALE_H)
dnl Determine which catalog format we have (if any is needed)
dnl For now we know about two different formats:
dnl Linux libc-5 and the normal X/Open format
test -d intl || mkdir intl
if test "$CATOBJEXT" = ".cat"; then
AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
dnl Transform the SED scripts while copying because some dumb SEDs
dnl cannot handle comments.
sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
fi
dnl po2tbl.sed is always needed.
sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
$srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
dnl In the intl/Makefile.in we have a special dependency which makes
dnl only sense for gettext. We comment this out for non-gettext
dnl packages.
if test "$PACKAGE" = "gettext"; then
GT_NO="#NO#"
GT_YES=
else
GT_NO=
GT_YES="#YES#"
fi
AC_SUBST(GT_NO)
AC_SUBST(GT_YES)
dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
dnl Try to locate is.
MKINSTALLDIRS=
if test -n "$ac_aux_dir"; then
MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
fi
if test -z "$MKINSTALLDIRS"; then
MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
fi
AC_SUBST(MKINSTALLDIRS)
dnl *** For now the libtool support in intl/Makefile is not for real.
l=
AC_SUBST(l)
dnl Generate list of files to be processed by xgettext which will
dnl be included in po/Makefile.
test -d po || mkdir po
if test "x$srcdir" != "x."; then
if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
posrcprefix="$srcdir/"
else
posrcprefix="../$srcdir/"
fi
else
posrcprefix="../"
fi
rm -f po/POTFILES
sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
< $srcdir/po/POTFILES.in > po/POTFILES
])

23
m4/jm-glibc-io.m4 Normal file
View File

@@ -0,0 +1,23 @@
#serial 1
dnl From Jim Meyering.
dnl
dnl See if the glibc *_unlocked I/O macros are available.
dnl
AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
[AC_CHECK_FUNCS( \
clearerr_unlocked \
feof_unlocked \
ferror_unlocked \
fflush_unlocked \
fputc_unlocked \
fread_unlocked \
fwrite_unlocked \
getc_unlocked \
getchar_unlocked \
putc_unlocked \
putchar_unlocked \
)
]
)

View File

@@ -7,6 +7,7 @@ AC_DEFUN(jm_MACROS,
dnl This macro actually runs replacement code. See isc-posix.m4.
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_REQUIRE([jm_WITH_REGEX])
AC_REQUIRE([jm_ASSERT])
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
@@ -27,4 +28,5 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([jm_FUNC_MALLOC])
AC_REQUIRE([jm_FUNC_READDIR])
AC_REQUIRE([jm_FUNC_MEMCMP])
AC_REQUIRE([jm_FUNC_GLIBC_UNLOCKED_IO])
])

19
m4/lcmessage.m4 Normal file
View File

@@ -0,0 +1,19 @@
# Check whether LC_MESSAGES is available in <locale.h>.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
# This file can be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
AC_DEFUN(AM_LC_MESSAGES,
[if test $ac_cv_header_locale_h = yes; then
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
if test $am_cv_val_LC_MESSAGES = yes; then
AC_DEFINE(HAVE_LC_MESSAGES)
fi
fi])

201
m4/ls-mntd-fs.m4 Normal file
View File

@@ -0,0 +1,201 @@
#serial 1
dnl From Jim Meyering.
dnl
dnl This is not pretty. I've just taken the autoconf code and wrapped
dnl it in an AC_DEFUN.
dnl
dnl CAUTION: This is very fragile. It relies on several checks that
dnl are still in fileutils' configure.in:
dnl FIXME: add AC_REQUIRE uses to pull in all definitions required
dnl for all uses of $ac_cv_func_* and $ac_cv_header_* variables below.
dnl
AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
[
# Determine how to get the list of mounted filesystems.
list_mounted_fs=
# If the getmntent function is available but not in the standard library,
# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
AC_FUNC_GETMNTENT
# This test must precede the ones for getmntent because Unicos-9 is
# reported to have the getmntent function, but its support is incompatible
# with other getmntent implementations.
# NOTE: Normally, I wouldn't use a check for system type as I've done for
# `CRAY' below since that goes against the whole autoconf philosophy. But
# I think there is too great a chance that some non-Cray system has a
# function named listmntent to risk the false positive.
if test -z "$list_mounted_fs"; then
# Cray UNICOS 9
AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
[fu_cv_sys_mounted_cray_listmntent=no
AC_EGREP_CPP(yes,
[#ifdef _CRAY
yes
#endif
], [test $ac_cv_func_listmntent = yes \
&& fu_cv_sys_mounted_cray_listmntent=yes]
)
]
)
AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
if test $fu_cv_sys_mounted_cray_listmntent = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_LISTMNTENT)
fi
fi
if test $ac_cv_func_getmntent = yes; then
# This system has the getmntent function.
# Determine whether it's the one-argument variant or the two-argument one.
if test -z "$list_mounted_fs"; then
# 4.3BSD, SunOS, HP-UX, Dynix, Irix
AC_MSG_CHECKING([for one-argument getmntent function])
AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
[test $ac_cv_header_mntent_h = yes \
&& fu_cv_sys_mounted_getmntent1=yes \
|| fu_cv_sys_mounted_getmntent1=no])
AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
if test $fu_cv_sys_mounted_getmntent1 = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_GETMNTENT1)
fi
fi
if test -z "$list_mounted_fs"; then
# SVR4
AC_MSG_CHECKING([for two-argument getmntent function])
AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
[AC_EGREP_HEADER(getmntent, sys/mnttab.h,
fu_cv_sys_mounted_getmntent2=yes,
fu_cv_sys_mounted_getmntent2=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
if test $fu_cv_sys_mounted_getmntent2 = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_GETMNTENT2)
fi
fi
if test -z "$list_mounted_fs"; then
AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
fi
fi
if test -z "$list_mounted_fs"; then
# DEC Alpha running OSF/1.
AC_MSG_CHECKING([for getfsstat function])
AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
[AC_TRY_LINK([
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/fs_types.h>],
[struct statfs *stats;
int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
fu_cv_sys_mounted_getsstat=yes,
fu_cv_sys_mounted_getsstat=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
if test $fu_cv_sys_mounted_getsstat = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_GETFSSTAT)
fi
fi
if test -z "$list_mounted_fs"; then
# AIX.
AC_MSG_CHECKING([for mntctl function and struct vmount])
AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
[AC_TRY_CPP([#include <fshelp.h>],
fu_cv_sys_mounted_vmount=yes,
fu_cv_sys_mounted_vmount=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
if test $fu_cv_sys_mounted_vmount = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_VMOUNT)
fi
fi
if test -z "$list_mounted_fs"; then
# SVR3
AC_MSG_CHECKING([for FIXME existence of three headers])
AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
[AC_TRY_CPP([
#include <sys/statfs.h>
#include <sys/fstyp.h>
#include <mnttab.h>],
fu_cv_sys_mounted_fread_fstyp=yes,
fu_cv_sys_mounted_fread_fstyp=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
if test $fu_cv_sys_mounted_fread_fstyp = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_FREAD_FSTYP)
fi
fi
if test -z "$list_mounted_fs"; then
# 4.4BSD and DEC OSF/1.
AC_MSG_CHECKING([for getmntinfo function])
AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
[
ok=
if test $ac_cv_func_getmntinfo = yes; then
AC_EGREP_HEADER(f_type;, sys/mount.h,
ok=yes)
fi
test -n "$ok" \
&& fu_cv_sys_mounted_getmntinfo=yes \
|| fu_cv_sys_mounted_getmntinfo=no
])
AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
if test $fu_cv_sys_mounted_getmntinfo = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_GETMNTINFO)
fi
fi
# FIXME: add a test for netbsd-1.1 here
if test -z "$list_mounted_fs"; then
# Ultrix
AC_MSG_CHECKING([for getmnt function])
AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
[AC_TRY_CPP([
#include <sys/fs_types.h>
#include <sys/mount.h>],
fu_cv_sys_mounted_getmnt=yes,
fu_cv_sys_mounted_getmnt=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
if test $fu_cv_sys_mounted_getmnt = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_GETMNT)
fi
fi
if test -z "$list_mounted_fs"; then
# SVR2
AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
AC_CACHE_VAL(fu_cv_sys_mounted_fread,
[AC_TRY_CPP([#include <mnttab.h>],
fu_cv_sys_mounted_fread=yes,
fu_cv_sys_mounted_fread=no)])
AC_MSG_RESULT($fu_cv_sys_mounted_fread)
if test $fu_cv_sys_mounted_fread = yes; then
list_mounted_fs=found
AC_DEFINE(MOUNTED_FREAD)
fi
fi
if test -z "$list_mounted_fs"; then
AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
# FIXME -- no need to abort building the whole package
# Can't build mountlist.c or anything that needs its functions
fi
])

47
m4/progtest.m4 Normal file
View File

@@ -0,0 +1,47 @@
# Search path for a program which passes the given test.
# Ulrich Drepper <drepper@cygnus.com>, 1996.
#
# This file can be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN(AM_PATH_PROG_WITH_TEST,
[# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
/*)
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in ifelse([$5], , $PATH, [$5]); do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word"
break
fi
fi
done
IFS="$ac_save_ifs"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test -n "[$]$1"; then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
AC_SUBST($1)dnl
])

23
m4/regex.m4 Normal file
View File

@@ -0,0 +1,23 @@
#serial 2
dnl Derived from code in GNU grep.
AC_DEFUN(jm_WITH_REGEX,
[
dnl Even packages that don't use regex.c can use this macro.
dnl Of course, for them it doesn't do anything.
syscmd([test -f lib/regex.c])
ifelse(sysval, 0,
[
AC_ARG_WITH(included-regex,
[ --without-included-regex don't compile regex (use with caution)],
jm_with_regex=$withval,
jm_with_regex=yes)
if test "$jm_with_regex" = yes; then
LIBOBJS="$LIBOBJS regex.o"
fi
],
)
]
)

18
m4/utime.m4 Normal file
View File

@@ -0,0 +1,18 @@
#serial 1
dnl From Jim Meyering
dnl Replace the utime function on systems that need it.
dnl FIXME
AC_DEFUN(jm_FUNC_UTIME,
[
AC_CHECK_HEADERS(utime.h)
AC_REQUIRE([jm_STRUCT_UTIMBUF])
AC_REQUIRE([AC_FUNC_UTIME_NULL])
if test $ac_cv_func_utime_null = no; then
jm_FUNC_UTIMES_NULL
AC_REPLACE_FUNCS(utime)
fi
])

34
m4/utimes.m4 Normal file
View File

@@ -0,0 +1,34 @@
#serial 1
dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL.
AC_DEFUN(jm_FUNC_UTIMES_NULL,
[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
[rm -f conftestdata; > conftestdata
AC_TRY_RUN([#include <sys/types.h>
#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));
}], ac_cv_func_utimes_null=yes, ac_cv_func_utimes_null=no,
ac_cv_func_utimes_null=no)
rm -f core core.* *.core])
if test $ac_cv_func_utimes_null = yes; then
if test x = y; then
# This code is deliberately never run via ./configure.
# FIXME: this is a hack to make autoheader put the corresponding
# HAVE_* undef for this symbol in config.h.in. This saves me the
# trouble of having to maintain the #undef in acconfig.h manually.
AC_CHECK_FUNCS(UTIMES_NULL)
fi
# Defining it this way (rather than via AC_DEFINE) short-circuits the
# autoheader check -- autoheader doesn't know it's already been taken
# care of by the hack above.
ac_kludge=HAVE_UTIMES_NULL
AC_DEFINE_UNQUOTED($ac_kludge)
fi
]
)

View File

@@ -1,3 +1,326 @@
1998-07-25 Jim Meyering <meyering@ascend.com>
* Version 3.16s.
* tests/cp/same-file: Skip three more unportable tests.
These failed on SunOS4.1.4.
* src/copy.c (SAME_INODE): Remove definition.
* src/sys2.h (SAME_INODE): Define it here instead.
* src/remove.c (same_file): New function.
(remove_dir): Use it to give a better diagnostic when rmdir fails
because it can't remove the current directory.
* src/df.c (long_options): Changes table entries not to use this form:
{"all", no_argument, &show_all_fs, 1},
but rather this form:
{"all", no_argument, NULL, 'a'},
Using the latter, all the option handling in one place: the getopt loop.
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNTINFO]:
Use fsp_to_string.
(fsp_to_string): Don't xmalloc return value (yet).
(xatoi): Ansideclify.
(fstype_to_string): Ansideclify.
* lib/mountlist.h: Define and use PARAMS macro.
* lib/utime.c: New file.
* src/touch.c (utime_now): Moved into m4/utimes.m4.
(touch) [!HAVE_UTIME_NULL]: Remove #ifdef and the use of utime_now
in the if-block.
* configure.in (jm_FUNC_UTIME): Use this, not AC_FUNC_UTIME.
1998-07-22 Paul Eggert <eggert@twinsun.com>
* lib/human.c (human_readable): amt -> damt, to fix typo when
computing which power to use after overflow occurs during
multiplication.
* lib/xstrtol.c: Include <stdio.h> if NDEBUG is not defined;
needed on SunOS 4.
1998-07-21 Paul Eggert <eggert@twinsun.com>
Add df -l or --local option.
* doc/fileutils.texi: Document it.
* lib/mountlist.h (REMOTE_FS_TYPE): New macro.
* lib/mountlist.c (read_filesystem_list):
If all_fs is negative, omit non-local filesytems.
* src/df.c (show_dev): Omit local devices if show_all_fs is negative.
(show_all_fs): If negative, omit non-local filesystems.
All uses of (all_fs != 0) changed to (all_fs > 0).
(long_options, usage, main): Add -l or --local option.
(main): When asking for df of an explicit file name, get all
the mount points, so that we're more likely to find it when
we look it up.
1998-07-18 Jim Meyering <meyering@ascend.com>
* src/copy.c (copy_internal): Add another exclusion from the
sameness test: when --force has been specified, the destination
is unlinked before any copy.
(copy_internal): Add yet another: when both src and dest are symlinks.
* tests/touch: New subdir.
* tests/Makefile.am (SUBDIRS): Add touch.
* configure.in (AC_OUTPUT): Add tests/touch/Makefile.
* tests/mv/into-self-2: New test.
* tests/mv/Makefile.am (TESTS): Add into-self-2.
1998-07-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* lib/mountlist.c (read_filesystem_list): Fix more memory leaks on
failure.
1998-07-16 Jim Meyering <meyering@ascend.com>
Work around failure of chown calls on m68k-motorola-sysv systems.
* src/chown.c: Include lchown.h.
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
* lib/lchown.c: Include lchown.h.
Reported by and with suggestions from Manfred Hollstein.
1998-07-12 Paul Eggert <eggert@twinsun.com>
* src/df.c (print_header): Print "1k-blocks", not "1.0k-blocks".
1998-07-07 Jim Meyering <meyering@ascend.com>
* src/sys2.h [HAVE_FCLOSE_UNLOCKED]: Remove unnecessary block.
Suggestion from Ulrich Drepper.
1998-07-04 Jim Meyering <meyering@ascend.com>
* lib/safe-read.c (safe_read): Change type of pointer parameter to
`void' to avoid Irix4 cc errors. Reported by Kaveh Ghazi.
* lib/safe-read.h: Update prototype.
* src/dircolors.c (parse_line): Add casts to avoid errors from
Irix4's `cc' C compiler. From Kaveh Ghazi.
* lib/xstrtol.c: Include stdio.h. Required on some systems when
using assert. From Kaveh Ghazi.
* tests/mv/backup-is-src: Use cmp, not diff.
Reported by Kaveh Ghazi.
1998-07-03 Jim Meyering <meyering@ascend.com>
* Version 3.16r.
* src/remove.c (remove_dir): Use fprintf (not error) to avoid
newline in prompt.
1998-06-30 Paul Eggert <eggert@shade.twinsun.com>
* lib/mountlist.c: (read_filesystem_list):
Don't leak memory on failure.
Don't create a dummy struct mount_entry entry;
use the address-of-the-tail-address method instead.
Preserve errno if possible on failure, setting it to 0 if inapplicable.
Close file descriptor leak if the F_SETLKW failed.
Report an error if SVR4 lock file cannot be opened for some reason
other than a nonexistent lock file.
1998-07-03 Jim Meyering <meyering@ascend.com>
* configure.in (AM_WITH_REGEX): Remove. Now the replacement
macro, jm_WITH_REGEX, is bundled with the rest in jm_MACROS.
* acconfig.h (WITH_REGEX): Remove undef.
* lib/Makefile.am (noinst_HEADERS): Add regex.h.
* lib/rpmatch.c: Remove #ifdef around <regex.h> inclusion.
* lib/rx.c: Remove file.
* lib/rx.h: Remove file.
* src/df.c (df_readable): Rename local so as not to shadow global.
* src/copy.c (SAME_INODE): New macro.
Use it to replace open-coded equivalents.
(copy_internal): Rename variable and reverse sense of tests
to make the code a little clearer.
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* src/copy.c (copy_internal): Try harder identifying a relative
symbolic link in the current directory.
* src/copy.c (copy_internal): Don't skip test for same file if
creating a hardlink from symlink over a non-symlink while making
backups.
* tests/cp/same-file: Skip tests that depend on link(2) not
following symlinks.
1998-07-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* src/copy.c (copy_internal): Don't call chown on a symlink.
1998-07-01 Jim Meyering <meyering@ascend.com>
* lib/xstrtol.c: Don't define NDEBUG here, now that it's done via
configure's --disable-assert option.
1998-06-29 Paul Eggert <eggert@twinsun.com>
* lib/mountlist.c (read_filesystem_list):
Plug file descriptor leak on failure.
Report failure if lock file can't be opened for some reason
other than nonexistence.
1998-06-29 Jim Meyering <meyering@ascend.com>
* Version 3.16q.
* lib/mountlist.c (read_filesystem_list) [MOUNTED_GETMNTENT2]:
Always close stream and file descriptor before returning.
* src/df.c (main): Move the test of the result of the
read_filesystem_list call up out of if-block -- code in the
else-block depends on it too.
1998-06-29 Paul Eggert <eggert@twinsun.com>
* lib/mountlist.c: (read_filesystem_list): If SVR4, lock
/etc/.mnttab.lock if available, to avoid race conditions
(e.g. with the automounter on Solaris 2.6).
Include <errno.h>, <fcntl.h>, <unistd.h>.
1998-06-29 Jim Meyering <meyering@ascend.com>
* lib/mountlist.c (fstype_to_string): Guard with
#if ! HAVE_F_FSTYPENAME_IN_STATFS.
1998-06-28 Paul Eggert <eggert@twinsun.com>
Add support for new --block-size option and
BLOCK_SIZE. DF_BLOCK_SIZE, etc. variables to `df', `du', and `ls'.
Adjust df output slightly to accommodate larger filesystems.
* lib/human.c, lib/human.h (human_readable): Coalesce last two args
into one, for convenience. All callers changed.
(human_block_size): New function.
* lib/human.c: Include <config.h> only if HAVE_CONFIG_H.
Include <stdlib.h> if HAVE_STDLIB_H;
declare getenv unless HAVE_DECL_GETENV.
(_): New macro.
Include <argmatch.h>, <error.h>, <xstrtoul.h>.
(DEFAULT_BLOCK_SIZE): New macro.
(block_size_args, block_size_types): New constants.
(humblock): New function.
* lib/xstrtol.h (__ZLONG_MAX): Remove.
* lib/xstrtol.c (bkm_scale): Don't assume that you can convert
unsigned long to double without losing information.
(bkm_scale_by_power): New function.
* lib/xstrtol.c (__xstrtol), src/dd.c (parse_integer):
Add support for SI-like suffixes like "GB" and "TD".
* src/dd.c (usage): Describe it.
* src/df.c, src/du.c, src/ls.c (human_readable_base, output_units):
Remove; replace with new variable output_block_size. All uses changed.
(long_options, usage, main): Add --block-size.
(main, decode_switches): Use new human_block_size function to
initialize output block size consistently with other programs.
* src/df.c (print_header, show_dev): Shrink some columns and expand
others, to squeeze in support for today's larger filesystems.
(print_header): Print output block size using power-of-1024 SI format.
(df_readable): Coalesce last two args into one, for convenience.
All callers changed.
(main): Remove check for portable output format and larger
or human-readable block sizes.
* NEWS, doc/fileutils.texi: Describe above changes.
1998-06-28 Jim Meyering <meyering@ascend.com>
* src/ls.c (usage): Make --kilobytes description consistent with
that in du and df. From Göran Uddeborg.
* lib/mountlist.c (fsp_to_string): Clean out some crufty #ifdefs
now that we're using the jm_FSTYPENAME autoconf macro.
James Tanis reported the old version didn't compile on BSDI3.
* configure.in: Move big block of list_mounted_fs checks into
new jm_LIST_MOUNTED_FILESYSTEMS macro.
Use new jm_FSTYPENAME macro.
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
* src/ls.c: Add DIRED_ prefix to the macros: PUTCHAR, FPUTS, and
FPUTS_LITERAL
1998-06-27 Jim Meyering <meyering@ascend.com>
* src/copy.c (copy_reg): Detect identical source and dest here.
(copy_internal): Make the test symmetric.
* tests/cp/same-file: New file.
* tests/cp/Makefile.am (TESTS): Add it.
1998-06-26 Jim Meyering <meyering@ascend.com>
* src/remove.c (remove_file): Remove `non-directory' part of
`removing non-directory FILE' verbose message.
1998-06-23 Jim Meyering <meyering@ascend.com>
* src/df.c (show_dev): Increase field width for blocks, used,
and available columns from 7 to 8.
1998-06-21 Jim Meyering <meyering@ascend.com>
* aclocal.m4: Regenerate with fixed gettext.m4 installed.
See README-alpha for details.
1998-06-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* src/automake-wrap: Quote `&' in sed replacement text.
1998-05-31 Jim Meyering <meyering@ascend.com>
* Version 3.16p.
* src/install.c (main): Fix argv-handling bug in my 1998-05-09 change.
Reported by Don Parsons.
1998-05-30 Jim Meyering <meyering@ascend.com>
* tests/ls/time-1: Clean up ctime test. Note that it fails also
on Solaris5.5.1 tmpfs file systems.
Solve the `rm -f rm' problem more cleanly.
* src/.rm-warning: Remove file.
* src/automake-wrap: New file.
* src/Makefile.am (AUTOMAKE): Define to use automake-wrap.
(Makefile.in): Depend on automake-wrap.
(EXTRA_DIST): Add automake-wrap.
(DISTCLEANFILES): Remove definition.
(rm_DEPENDENCIES): Likewise.
(.rm-warn-stamp): Remove rule.
1998-05-27 Jim Meyering <meyering@ascend.com>
* tests/ls/Makefile.am (TESTS): s/cr-1/rt-1/
* tests/ls/rt-1: New file, renamed from cr-1.
1998-05-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* src/Makefile.am (.rm-warn-stamp): Cope with $(srcdir) != ".".
* tests/ls/cr-1: Don't use the ctime for testing, it is impossible
to set it reliably.
1998-05-25 Jim Meyering <meyering@ascend.com>
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
[!_GNU_SOURCE]: Add #undef instead.
1998-05-24 Jim Meyering <meyering@ascend.com>
* Version 3.16o.

View File

@@ -1,4 +1,34 @@
Changes in release 3.17:
[3.16s]
* df accept a new option --local (-l)
* touch works around a system-specific bug so it now affects existing,
zero-length files on certain systems
* chown now works even on certain SVR3 systems where it used to fail
[3.16r]
* include gettext's m4 macros
* minor cp bug fixed
* non-portable cp tests removed
* --without-included-regex now means don't compile regex.c
* rx support removed
[3.16q]
* `df', `du', and `ls' now accept a new option --block-size=SIZE,
where SIZE can be a positive integer block size, followed by an
optional SI prefix (e.g. `k' for kilo, `M' for Mega), followed by an
optional `B' (for ``byte'', indicating powers of 1024, which is the
default) or `D' (for ``decimal byte'', indicating powers of 1000).
SIZE can also be `human-readable' (for -h or --human-readable
behavior) or `si' (for -H or --si behavior).
* These suffixes can also be used by `dd'; e.g. `dd bs=1MB' is equivalent
to `dd bs=1048576'.
* The default block size for the `df' command is now obtained from the
DF_BLOCK_SIZE environment variable or, if that is not set, from BLOCK_SIZE.
Similarly for `du' and `ls'.
* The output columns of `df' have been adjusted slightly to accommodate
larger filesystems.
* fix gettext-related link failures seen when configuring certain ways
[3.16p]
* fix install bug introduced in 3.16o
* build/test changes only
[3.16o]
* chown accepts new option, --dereference. --no-dereference is now the default.
* install now shares core copying code with mv and cp

View File

@@ -1,7 +1,62 @@
1998-05-16 Jim Meyering <meyering@ascend.com>
1998-07-16 Jim Meyering <meyering@ascend.com>
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
* lib/lchown.c: Include lchown.h.
1998-07-15 Jim Meyering <meyering@ascend.com>
* src/seq.c (check_format): Add `5' to the list of digits.
Reported by Donni Erpel.
1998-07-12 Jim Meyering <meyering@ascend.com>
* Version 1.16f.
* tests/test: New directory and tests.
* tests/Makefile.am (SUBDIRS): Add test.
* configure.in (AC_OUTPUT): Add tests/test/Makefile.
1998-07-04 Jim Meyering <meyering@ascend.com>
* lib/Makefile.am (libsu_a_SOURCES): Remove regex.c, now that it's
automatically discovered by automake.
(noinst_HEADERS): Remove unused safe-read.h.
* src/Makefile.am (CLEANFILES): Put $(SCRIPTS) here rather than in
DISTCLEANFILES.
(CLEANFILES): Add su, since we build it unconditionally, yet it's
never put in @OPTIONAL_BIN_PROGS@.
1998-06-29 Jim Meyering <meyering@ascend.com>
* src/uptime.c: Include system.h only after error.h and readutmp.h
so we don't get redefinition warnings about getc, etc.
* src/who.c: Likewise.
* src/users.c: Likewise.
1998-06-28 Jim Meyering <meyering@ascend.com>
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
1998-06-06 Jim Meyering <meyering@ascend.com>
* src/test.c (unary_operator): Fail if the operand to -t is not valid.
(posixtest): Treat `test -t' the same as `test -t 1'.
1998-05-26 Jim Meyering <meyering@ascend.com>
* src/test.c (two_arguments): Don't test argv[pos][2] if it's
past end of string.
1998-05-25 Jim Meyering <meyering@ascend.com>
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
[!_GNU_SOURCE]: Add #undef instead.
1998-05-16 Jim Meyering <meyering@ascend.com>
* lib/readutmp.c (read_utmp): Add variant for systems that have
the utmpname function.
Ansideclify.

View File

@@ -1,8 +1,8 @@
Changes in release 1.17
[1.16f]
* new autoconf tests detect bugs in vendor mktime from Irix-6.4 and SunOS4.1.4
Your executables will be a little larger on such systems because you'll use
GNU's mktime function, but date will work more reliably.
[1.16f]
* hostid: new program
* `yes --help' and `yes --version' print those strings when the POSIXLY_CORRECT
environment variable is set

View File

@@ -1,7 +1,56 @@
1998-05-16 Jim Meyering <meyering@ascend.com>
1998-07-16 Jim Meyering <meyering@ascend.com>
* Version 1.22f.
* src/chown.c: Include lchown.h.
* lib/Makefile.am (noinst_HEADERS): Add lchown.h.
* lib/lchown.h: New file, just to define ENOSYS on systems that lack it.
* lib/lchown.c: Include lchown.h.
1998-07-04 Jim Meyering <meyering@ascend.com>
* configure.in (AM_WITH_REGEX): Remove. Now the replacement
macro, jm_WITH_REGEX, is bundled with the rest in jm_MACROS.
* acconfig.h (WITH_REGEX): Remove undef.
* src/csplit.c: Remove #ifdef around <regex.h> inclusion.
* src/nl.c: Likewise.
* src/tac.c: Likewise.
* src/csplit.c (extract_regexp): Remove #if !WITH_REGEX...#endif block.
* lib/Makefile.am (noinst_HEADERS): Remove rx.h.
* lib/rx.c: Remove file.
* lib/rx.h: Remove file.
1998-06-29 Jim Meyering <meyering@ascend.com>
* src/wc.c: Update calls to human_readable -- now there's one fewer arg.
* lib/Makefile.am (libtu_a_SOURCES): Add argmatch.c.
(noinst_HEADERS): Add argmatch.h.
1998-06-28 Jim Meyering <meyering@ascend.com>
* src/sys2.h: Add macro definitions for GNU libc *_unlocked wrappers.
1998-06-27 Jim Meyering <meyering@ascend.com>
* tests/pr/Test.pm: Add two tests for double spacing.
* src/pr.c (print_page): If cols_ready_to_print is zero,
break out of loop just before the double-space test.
Reported by Michael Stutz.
1998-06-18 Jim Meyering <meyering@ascend.com>
* tests/Makefile.am.in (check): Depend on $(maint_gen) so
`make maintainer-clean; ./configure; make check' works.
1998-05-25 Jim Meyering <meyering@ascend.com>
* configure.in (_GNU_SOURCE): AC_DEFINE it here.
* acconfig.h (_GNU_SOURCE): Remove definition from @TOP@ section.
[!_GNU_SOURCE]: Add #undef instead.
1998-05-16 Jim Meyering <meyering@ascend.com>
* configure.in (jm_MACROS): New wrapper macro.
Remove uses of most jm_* macros.

View File

@@ -1,5 +1,6 @@
Changes in release 1.23
[1.22f]
* fix pr bug: pr -td didn't double space
* fix tac bug when using -b, -r, and -s SEPARATOR
* fix sort bug whereby using key-local `d' option would cause following
key specs to be ignored when any two keys (in the `d'-modified test)

View File

@@ -39,6 +39,7 @@
#include "closeout.h"
#include "error.h"
#include "savedir.h"
#include "lchown.h"
#ifndef _POSIX_VERSION
struct passwd *getpwnam ();

View File

@@ -34,13 +34,6 @@
#include "cp-hash.h"
#include "path-concat.h"
/* On Linux (from slackware-1.2.13 to 2.0.2?) there is no lchown function.
To change ownership of symlinks, you must run chown with an effective
UID of 0. */
#ifdef __linux__
# define ROOT_CHOWN_AFFECTS_SYMLINKS
#endif
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
(Chown ((File), (x->myeuid == 0 ? (New_uid) : x->myeuid), (New_gid)) \
/* If non-root uses -p, it's ok if we can't preserve ownership. \
@@ -58,6 +51,7 @@ struct dir_list
int full_write ();
int euidaccess ();
int yesno ();
char *dirname ();
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
int new_dst, dev_t device,
@@ -185,7 +179,16 @@ copy_reg (const char *src_path, const char *dst_path,
source_desc = open (src_path, O_RDONLY);
if (source_desc < 0)
{
error (0, errno, "%s", src_path);
/* If SRC_PATH doesn't exist, then chances are good that the
user did something like this `cp --backup foo foo': and foo
existed to start with, but copy_internal renamed DST_PATH
with the backup suffix, thus also renaming SRC_PATH. */
if (errno == ENOENT)
error (0, 0, _("`%s' and `%s' are the same file"),
src_path, dst_path);
else
error (0, errno, "%s", src_path);
return -1;
}
@@ -415,7 +418,9 @@ copy_internal (const char *src_path, const char *dst_path,
return 1;
}
else
new_dst = 1;
{
new_dst = 1;
}
}
else
{
@@ -423,20 +428,43 @@ copy_internal (const char *src_path, const char *dst_path,
/* The destination file exists already. */
same = (src_sb.st_ino == dst_sb.st_ino
&& src_sb.st_dev == dst_sb.st_dev);
same = (SAME_INODE (src_sb, dst_sb));
#ifdef S_ISLNK
/* If we're preserving symlinks (--no-dereference) and the
destination file is a symlink, use stat (not xstat) to
see if it points back to the source. */
if (!same && !x->dereference && S_ISLNK (dst_sb.st_mode))
/* If we're preserving symlinks (--no-dereference) and either
file is a symlink, use stat (not xstat) to see if they refer
to the same file. */
if (!same
/* If we'll remove DST_PATH first, then this doesn't matter. */
&& ! x->force
/* Allow them to be the same (and don't set `same') if
we're in move mode and they're both symlinks. */
&& !(move_mode
&& S_ISLNK (src_sb.st_mode)
&& S_ISLNK (dst_sb.st_mode))
/* If we're making a backup, we'll detect the problem case in
copy_reg because SRC_PATH will no longer exist. Allowing
the test to be deferred lets cp do some useful things.
But when creating hardlinks and SRC_PATH is a symlink
but DST_PATH is not we must test anyway. */
&& (x->backup_type == none
|| (x->hard_link
&& S_ISLNK (src_sb.st_mode)
&& !S_ISLNK (dst_sb.st_mode)))
&& !x->dereference
&& (S_ISLNK (dst_sb.st_mode) || S_ISLNK (src_sb.st_mode)))
{
struct stat dst2_sb;
struct stat src2_sb;
if (stat (dst_path, &dst2_sb) == 0
&& (src_sb.st_ino == dst2_sb.st_ino &&
src_sb.st_dev == dst2_sb.st_dev))
same = 1;
&& stat (src_path, &src2_sb) == 0
&& SAME_INODE (src2_sb, dst2_sb))
{
same = 1;
}
}
#endif
@@ -445,9 +473,12 @@ copy_internal (const char *src_path, const char *dst_path,
if (x->hard_link)
return 0;
error (0, 0, _("`%s' and `%s' are the same file"),
src_path, dst_path);
return 1;
if (x->backup_type == none && !x->force)
{
error (0, 0, _("`%s' and `%s' are the same file"),
src_path, dst_path);
return 1;
}
}
if (!S_ISDIR (src_type))
@@ -641,25 +672,42 @@ copy_internal (const char *src_path, const char *dst_path,
#ifdef S_ISLNK
else if (x->symbolic_link)
{
if (*src_path == '/'
|| (!strncmp (dst_path, "./", 2) && strchr (dst_path + 2, '/') == 0)
|| strchr (dst_path, '/') == 0)
if (*src_path != '/')
{
if (symlink (src_path, dst_path))
/* Check that DST_PATH denotes a file in the current directory. */
struct stat dot_sb;
struct stat dst_parent_sb;
char *dst_parent;
int in_current_dir;
dst_parent = dirname (dst_path);
if (dst_parent == NULL)
error (1, 0, _("virtual memory exhausted"));
in_current_dir = (STREQ (".", dst_parent)
/* If either stat call fails, it's ok not to report
the failure and say dst_path is in the current
directory. Other things will fail later. */
|| stat (".", &dot_sb)
|| stat (dst_parent, &dst_parent_sb)
|| SAME_INODE (dot_sb, dst_parent_sb));
free (dst_parent);
if (! in_current_dir)
{
error (0, errno, "%s", dst_path);
error (0, 0,
_("%s: can make relative symbolic links only in current directory"),
dst_path);
goto un_backup;
}
return 0;
}
else
if (symlink (src_path, dst_path))
{
error (0, 0,
_("%s: can make relative symbolic links only in current directory"),
dst_path);
error (0, errno, "%s", dst_path);
goto un_backup;
}
return 0;
}
#endif
else if (x->hard_link)
@@ -738,26 +786,10 @@ copy_internal (const char *src_path, const char *dst_path,
goto un_backup;
}
# else
# ifdef ROOT_CHOWN_AFFECTS_SYMLINKS
if (x->myeuid == 0)
{
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), dst_path);
goto un_backup;
}
}
else
{
/* FIXME: maybe give a diagnostic: you must be root
to preserve ownership and group of symlinks. */
}
# else
/* Can't preserve ownership of symlinks.
FIXME: maybe give a warning or even error for symlinks
in directories with the sticky bit set -- there, not
preserving owner/group is a potential security problem. */
# endif
# endif
}

View File

@@ -28,11 +28,7 @@
#include "system.h"
#if WITH_REGEX
# include <regex.h>
#else
# include <rx.h>
#endif
#include <regex.h>
#include "error.h"
#include "xstrtoul.h"
@@ -1150,9 +1146,6 @@ extract_regexp (int argnum, boolean ignore, char *str)
p->re_compiled.buffer = (unsigned char *) xmalloc (p->re_compiled.allocated);
p->re_compiled.fastmap = xmalloc (256);
p->re_compiled.translate = 0;
#if !WITH_REGEX
p->re_compiled.syntax_parens = 0;
#endif
err = re_compile_pattern (p->regexpr, len, &p->re_compiled);
if (err)
{

View File

@@ -579,7 +579,10 @@ cut_fields (FILE *stream)
if (print_kth (field_idx))
{
if (found_any_selected_field)
putchar (delim);
{
/* FIXME: use output delimiter here */
putchar (delim);
}
found_any_selected_field = 1;
while ((c = getc (stream)) != delim && c != '\n' && c != EOF)

View File

@@ -304,8 +304,10 @@ Copy a file, converting and formatting according to the options.\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
BYTES may be suffixed: by xM for multiplication by M, by c for x1,\n\
by w for x2, by b for x512, by k for x1024. Each KEYWORD may be:\n\
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\
Each KEYWORD may be:\n\
\n\
ascii from EBCDIC to ASCII\n\
ebcdic from ASCII to EBCDIC\n\
@@ -352,15 +354,15 @@ print_stats (void)
{
char buf[2][LONGEST_HUMAN_READABLE + 1];
fprintf (stderr, _("%s+%s records in\n"),
human_readable (r_full, buf[0], 1, 1, 0),
human_readable (r_partial, buf[1], 1, 1, 0));
human_readable (r_full, buf[0], 1, 1),
human_readable (r_partial, buf[1], 1, 1));
fprintf (stderr, _("%s+%s records out\n"),
human_readable (w_full, buf[0], 1, 1, 0),
human_readable (w_partial, buf[1], 1, 1, 0));
human_readable (w_full, buf[0], 1, 1),
human_readable (w_partial, buf[1], 1, 1));
if (r_truncate > 0)
{
fprintf (stderr, "%s %s\n",
human_readable (r_truncate, buf[0], 1, 1, 0),
human_readable (r_truncate, buf[0], 1, 1),
(r_truncate == 1
? _("truncated record")
: _("truncated records")));
@@ -503,6 +505,12 @@ parse_integer (char *str, int *invalid)
for (;;)
{
uintmax_t multiplier;
int power = 0;
#ifdef lint
/* Suppress `used before initialized' warning. */
multiplier = 0;
#endif
switch (*p++)
{
@@ -513,8 +521,23 @@ parse_integer (char *str, int *invalid)
break;
case 'c':
continue;
case 'k':
multiplier = 1024;
case 'E': /* Exa */
power = 6;
break;
case 'G': /* Giga */
power = 3;
break;
case 'k': /* kilo */
power = 1;
break;
case 'M': /* Mega */
power = 2;
break;
case 'P': /* Peta */
power = 5;
break;
case 'T': /* Tera */
power = 4;
break;
case 'w':
multiplier = 2;
@@ -523,6 +546,12 @@ parse_integer (char *str, int *invalid)
multiplier = parse_integer (p, invalid);
p = "";
break;
case 'Y': /* Yotta */
power = 8;
break;
case 'Z': /* Zetta */
power = 7;
break;
default:
{
*invalid = 1;
@@ -530,6 +559,24 @@ parse_integer (char *str, int *invalid)
}
}
if (power)
{
int base = 1024;
switch (*p)
{
case 'B': p++; break;
case 'D': p++; base = 1000; break;
}
for (multiplier = base; --power; multiplier *= base)
if (multiplier * base / base != multiplier)
{
*invalid = 1;
return 0;
}
}
if (multiplier != 0 && n * multiplier / multiplier != n)
{
*invalid = 1;

168
src/df.c
View File

@@ -47,19 +47,17 @@ char *program_name;
/* If nonzero, show inode information. */
static int inode_format;
/* If nonzero, show even filesystems with zero size or
uninteresting types. */
/* If positive, show all entries; if zero, omit size-zero entries and
automounter dummies; if negative, also omit non-local filesystems. */
static int show_all_fs;
/* If nonzero, output data for each filesystem corresponding to a
command line argument -- even if it's a dummy (automounter) entry. */
static int show_listed_fs;
/* base used for human style output */
static int human_readable_base;
/* The units to count in. */
static int output_units;
/* If positive, the units to use when printing sizes;
if negative, the human-readable base. */
static int output_block_size;
/* If nonzero, use the POSIX output format. */
static int posix_format;
@@ -113,18 +111,20 @@ static int print_type;
static struct option const long_options[] =
{
{"all", no_argument, &show_all_fs, 1},
{"inodes", no_argument, &inode_format, 1},
{"human-readable", no_argument, 0, 'h'},
{"si", no_argument, 0, 'H'},
{"kilobytes", no_argument, 0, 'k'},
{"megabytes", no_argument, 0, 'm'},
{"portability", no_argument, &posix_format, 1},
{"print-type", no_argument, &print_type, 1},
{"sync", no_argument, 0, 129},
{"no-sync", no_argument, 0, 130},
{"type", required_argument, 0, 't'},
{"exclude-type", required_argument, 0, 'x'},
{"all", no_argument, NULL, 'a'},
{"block-size", required_argument, NULL, 131},
{"inodes", no_argument, NULL, 'i'},
{"human-readable", no_argument, NULL, 'h'},
{"si", no_argument, NULL, 'H'},
{"kilobytes", no_argument, NULL, 'k'},
{"local", no_argument, NULL, 'l'},
{"megabytes", no_argument, NULL, 'm'},
{"portability", no_argument, NULL, 'P'},
{"print-type", no_argument, NULL, 'T'},
{"sync", no_argument, NULL, 129},
{"no-sync", no_argument, NULL, 130},
{"type", required_argument, NULL, 't'},
{"exclude-type", required_argument, NULL, 'x'},
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
@@ -141,15 +141,22 @@ print_header (void)
printf (" ");
if (inode_format)
printf (" Inodes IUsed IFree %%IUsed ");
printf (" Inodes IUsed IFree IUse%%");
else if (output_block_size < 0)
printf (" Size Used Avail Use%%");
else
if (output_units == 1024 * 1024)
printf (" MB-blocks Used Available Capacity");
else if (human_readable_base)
printf (" Size Used Avail Capacity");
else
printf (" %s Used Available Capacity",
output_units == 1024 ? "1024-blocks" : " 512-blocks");
{
char buf[LONGEST_HUMAN_READABLE + 1];
char *p = human_readable (output_block_size, buf, 1, -1024);
/* Replace e.g. "1.0k" by "1k". */
size_t plen = strlen (p);
if (3 <= plen && strncmp (p + plen - 3, ".0", 2) == 0)
strcpy (p + plen - 3, p + plen - 1);
printf (" %4s-blocks Used Available Use%%", p);
}
printf (" Mounted on\n");
}
@@ -187,9 +194,11 @@ excluded_fstype (const char *fstype)
/* Like human_readable, except return "-" if the argument is -1. */
static char *
df_readable (uintmax_t n, char *buf, int from_units, int to_units, int base)
df_readable (uintmax_t n, char *buf,
int from_block_size, int t_output_block_size)
{
return n == -1 ? "-" : human_readable (n, buf, from_units, to_units, base);
return (n == -1 ? "-"
: human_readable (n, buf, from_block_size, t_output_block_size));
}
/* Display a space listing for the disk device with absolute path DISK.
@@ -205,15 +214,18 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
struct fs_usage fsu;
const char *stat_file;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
/* If MOUNT_POINT is NULL, then the filesystem is not mounted, and this
program reports on the filesystem that the special file is on.
It would be better to report on the unmounted filesystem,
but statfs doesn't do that on most systems. */
stat_file = mount_point ? mount_point : disk;
if (show_all_fs < 0 && fstype && REMOTE_FS_TYPE (fstype))
return;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
if (get_fs_usage (stat_file, disk, &fsu))
{
error (0, errno, "%s", stat_file);
@@ -221,7 +233,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
return;
}
if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs)
if (fsu.fsu_blocks == 0 && show_all_fs <= 0 && !show_listed_fs)
return;
if (! disk)
@@ -241,6 +253,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
char buf[3][LONGEST_HUMAN_READABLE + 1];
double inodes_percent_used;
uintmax_t inodes_used;
int inode_units = output_block_size < 0 ? output_block_size : 1;
if (fsu.fsu_files == -1 || fsu.fsu_files < fsu.fsu_ffree)
{
@@ -256,18 +269,18 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
}
printf (" %7s %7s %7s ",
df_readable (fsu.fsu_files, buf[0], 1, 1, human_readable_base),
df_readable (inodes_used, buf[1], 1, 1, human_readable_base),
df_readable (fsu.fsu_ffree, buf[2], 1, 1, human_readable_base));
df_readable (fsu.fsu_files, buf[0], 1, inode_units),
df_readable (inodes_used, buf[1], 1, inode_units),
df_readable (fsu.fsu_ffree, buf[2], 1, inode_units));
if (inodes_percent_used < 0)
printf (" - ");
printf (" - ");
else
printf (" %5.0f%%", inodes_percent_used);
printf ("%4.0f%%", inodes_percent_used);
}
else
{
int w = human_readable_base ? 5 : 7;
int w = output_block_size < 0 ? 5 : 9;
char buf[2][LONGEST_HUMAN_READABLE + 1];
char availbuf[LONGEST_HUMAN_READABLE + 2];
char *avail;
@@ -296,22 +309,22 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
? - fsu.fsu_bavail
: fsu.fsu_bavail),
availbuf + 1, fsu.fsu_blocksize,
output_units, human_readable_base);
output_block_size);
if (fsu.fsu_bavail_top_bit_set)
*--avail = '-';
printf (" %*s %*s %*s ",
printf (" %*s %*s %*s ",
w, df_readable (fsu.fsu_blocks, buf[0], fsu.fsu_blocksize,
output_units, human_readable_base),
output_block_size),
w, df_readable (blocks_used, buf[1], fsu.fsu_blocksize,
output_units, human_readable_base),
output_block_size),
w, avail);
if (blocks_percent_used < 0)
printf (" - ");
printf (" - ");
else
printf (" %5.0f%% ", blocks_percent_used);
printf ("%3.0f%%", blocks_percent_used);
}
if (mount_point)
@@ -325,7 +338,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0)
mount_point += 8;
#endif
printf (" %s", mount_point);
printf (" %s", mount_point);
}
putchar ('\n');
}
@@ -534,11 +547,13 @@ Show information about the filesystem on which each FILE resides,\n\
or all filesystems by default.\n\
\n\
-a, --all include filesystems having 0 blocks\n\
--block-size=SIZE use SIZE-byte blocks\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
-i, --inodes list inode information instead of block usage\n\
-k, --kilobytes use 1024-byte blocks\n\
-m, --megabytes use 1048576-byte blocks\n\
-k, --kilobytes like --block-size=1024\n\
-l, --local limit listing to local filesystems\n\
-m, --megabytes like --block-size=1048576\n\
--no-sync do not invoke sync before getting usage info (default)\n\
-P, --portability use the POSIX output format\n\
--sync invoke sync before getting usage info\n\
@@ -572,31 +587,13 @@ main (int argc, char **argv)
show_all_fs = 0;
show_listed_fs = 0;
if (getenv ("POSIXLY_CORRECT"))
output_units = 512;
else
{
char *bs;
if ((bs = getenv ("BLOCKSIZE"))
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
{
human_readable_base = 1024;
output_units = 1;
}
else if (bs && STREQ (bs, "SI"))
{
human_readable_base = 1000;
output_units = 1;
}
else
output_units = 1024;
}
human_block_size (getenv ("DF_BLOCK_SIZE"), 0, &output_block_size);
print_type = 0;
posix_format = 0;
exit_status = 0;
while ((c = getopt_long (argc, argv, "aiF:hHkmPTt:vx:", long_options, NULL))
while ((c = getopt_long (argc, argv, "aiF:hHklmPTt:vx:", long_options, NULL))
!= -1)
{
switch (c)
@@ -610,20 +607,19 @@ main (int argc, char **argv)
inode_format = 1;
break;
case 'h':
human_readable_base = 1024;
output_units = 1;
output_block_size = -1024;
break;
case 'H':
human_readable_base = 1000;
output_units = 1;
output_block_size = -1000;
break;
case 'k':
human_readable_base = 0;
output_units = 1024;
output_block_size = 1024;
break;
case 'l':
show_all_fs = -1;
break;
case 'm':
human_readable_base = 0;
output_units = 1024 * 1024;
output_block_size = 1024 * 1024;
break;
case 'T':
print_type = 1;
@@ -638,6 +634,10 @@ main (int argc, char **argv)
require_sync = 0;
break;
case 131:
human_block_size (optarg, 1, &output_block_size);
break;
case 'F':
/* Accept -F as a synonym for -t for compatibility with Solaris. */
case 't':
@@ -665,15 +665,6 @@ main (int argc, char **argv)
if (show_help)
usage (0);
if (posix_format && output_units == 1024 * 1024)
error (1, 0, _("the option for counting 1MB blocks may not be used\n\
with the portable output format"));
if (posix_format && human_readable_base)
error (1, 0,
_("the option for printing with adaptive units may not be used\n\
with the portable output format"));
/* Fail if the same file system type was both selected and excluded. */
{
int match = 0;
@@ -725,15 +716,16 @@ with the portable output format"));
read_filesystem_list ((fs_select_list != NULL
|| fs_exclude_list != NULL
|| print_type),
show_all_fs);
optind == argc ? show_all_fs : 1);
if (mount_list == NULL)
error (1, errno, _("cannot read table of mounted filesystems"));
if (require_sync)
sync ();
if (optind == argc)
{
if (mount_list == NULL)
error (1, errno, _("cannot read table of mounted filesystems"));
print_header ();
show_all_entries ();
}

View File

@@ -174,7 +174,7 @@ parse_line (unsigned char const *line, char **keyword, char **arg)
++p;
}
*keyword = xstrndup (keyword_start, p - keyword_start);
*keyword = xstrndup ((const char *) keyword_start, p - keyword_start);
if (*p == '\0')
return;
@@ -198,7 +198,7 @@ parse_line (unsigned char const *line, char **keyword, char **arg)
}
++p;
*arg = xstrndup (arg_start, p - arg_start);
*arg = xstrndup ((const char *) arg_start, p - arg_start);
}
/* FIXME: Write a string to standard out, while watching for "dangerous"
@@ -287,7 +287,7 @@ dc_parse_stream (FILE *fp, const char *filename)
break;
}
parse_line (line, &keywd, &arg);
parse_line ((unsigned char *) line, &keywd, &arg);
if (keywd == NULL)
continue;

View File

@@ -26,9 +26,9 @@
arguments have been processed. This can be used to find
out the disk usage of a directory, with some files excluded.
-h Print sizes in human readable format (1k 234M 2G, etc).
-k Print sizes in kilobytes instead of 512 byte blocks
(the default required by POSIX).
-m Print sizes in megabytes instead of 512 byte blocks
-H Similar, but use powers of 1000 not 1024.
-k Print sizes in kilobytes.
-m Print sizes in megabytes.
-b Print sizes in bytes.
-S Count the size of each directory separately, not including
the sizes of subdirectories.
@@ -143,11 +143,9 @@ static int opt_dereference_arguments = 0;
is at level 0, so `du --max-depth=0' is equivalent to `du -s'. */
static int max_depth = INT_MAX;
/* base used for human style output */
static int human_readable_base;
/* The units to count in. */
static int output_units;
/* If positive, the units to use when printing sizes;
if negative, the human-readable base. */
static int output_block_size;
/* Accumulated path for file or directory being processed. */
static String *path;
@@ -180,6 +178,7 @@ static uintmax_t tot_size = 0;
static struct option const long_options[] =
{
{"all", no_argument, &opt_all, 1},
{"block-size", required_argument, 0, 129},
{"bytes", no_argument, NULL, 'b'},
{"count-links", no_argument, &opt_count_all, 1},
{"dereference", no_argument, NULL, 'L'},
@@ -217,15 +216,16 @@ usage (int status, char *reason)
Summarize disk usage of each FILE, recursively for directories.\n\
\n\
-a, --all write counts for all files, not just directories\n\
--block-size=SIZE use SIZE-byte blocks\n\
-b, --bytes print size in bytes\n\
-c, --total produce a grand total\n\
-D, --dereference-args dereference PATHs when symbolic link\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
-k, --kilobytes use 1024-byte blocks\n\
-k, --kilobytes like --block-size=1024\n\
-l, --count-links count sizes many times if hard linked\n\
-L, --dereference dereference all symbolic links\n\
-m, --megabytes use 1048576-byte blocks\n\
-m, --megabytes like --block-size=1048576\n\
-S, --separate-dirs do not include size of subdirectories\n\
-s, --summarize display only a total for each argument\n\
-x, --one-file-system skip directories on different filesystems\n\
@@ -249,7 +249,6 @@ main (int argc, char **argv)
{
int c;
char *cwd_only[2];
char *bs;
int max_depth_specified = 0;
/* If nonzero, display only a total for each argument. */
@@ -266,21 +265,7 @@ main (int argc, char **argv)
exclude = new_exclude ();
xstat = lstat;
if (getenv ("POSIXLY_CORRECT"))
output_units = 512;
else if ((bs = getenv ("BLOCKSIZE"))
&& strncmp (bs, "HUMAN", sizeof ("HUMAN") - 1) == 0)
{
human_readable_base = 1024;
output_units = 1;
}
else if (bs && STREQ (bs, "SI"))
{
human_readable_base = 1000;
output_units = 1;
}
else
output_units = 1024;
human_block_size (getenv ("DU_BLOCK_SIZE"), 0, &output_block_size);
while ((c = getopt_long (argc, argv, "abchHklmsxDLSX:", long_options, NULL))
!= -1)
@@ -296,8 +281,7 @@ main (int argc, char **argv)
break;
case 'b':
human_readable_base = 0;
output_units = 1;
output_block_size = 1;
break;
case 'c':
@@ -305,18 +289,15 @@ main (int argc, char **argv)
break;
case 'h':
human_readable_base = 1024;
output_units = 1;
output_block_size = -1024;
break;
case 'H':
human_readable_base = 1000;
output_units = 1;
output_block_size = -1000;
break;
case 'k':
human_readable_base = 0;
output_units = 1024;
output_block_size = 1024;
break;
case 13: /* --max-depth=N */
@@ -329,8 +310,7 @@ main (int argc, char **argv)
break;
case 'm':
human_readable_base = 0;
output_units = 1024 * 1024;
output_block_size = 1024 * 1024;
break;
case 'l':
@@ -366,6 +346,10 @@ main (int argc, char **argv)
add_exclude (exclude, optarg);
break;
case 129:
human_block_size (optarg, 1, &output_block_size);
break;
default:
usage (1, (char *) 0);
}
@@ -413,8 +397,8 @@ main (int argc, char **argv)
}
/* Print N_BLOCKS followed by STRING on a line. NBLOCKS is the number of
ST_NBLOCKSIZE-byte blocks; convert it to OUTPUT_UNITS units before
printing. If HUMAN_READABLE_BASE is nonzero, use a human readable
ST_NBLOCKSIZE-byte blocks; convert it to OUTPUT_BLOCK_SIZE units before
printing. If OUTPUT_BLOCK_SIZE is negative, use a human readable
notation instead. */
static void
@@ -422,8 +406,7 @@ print_size (uintmax_t n_blocks, const char *string)
{
char buf[LONGEST_HUMAN_READABLE + 1];
printf ("%s\t%s\n",
human_readable (n_blocks, buf, ST_NBLOCKSIZE, output_units,
human_readable_base),
human_readable (n_blocks, buf, ST_NBLOCKSIZE, output_block_size),
string);
fflush (stdout);
}
@@ -490,7 +473,7 @@ du_files (char **files)
free_cwd (&cwd);
}
/* Print (if appropriate) the size (in units determined by `output_units')
/* Print (if appropriate) the size (in units determined by `output_block_size')
of file or directory ENT. Return the size of ENT in units of 512-byte
blocks. TOP is one for external calls, zero for recursive calls.
LAST_DEV is the device that the parent directory of ENT is on.

View File

@@ -370,11 +370,18 @@ main (int argc, char **argv)
else
{
int i;
if (!isdir (file[1]))
usage (1);
const char *dest = file[n_files - 1];
if (!isdir (dest))
{
error (0, 0,
_("installing multiple files, but last argument (%s) \
is not a directory"),
dest);
usage (1);
}
for (i = 0; i < n_files - 1; i++)
{
errors |= install_file_in_dir (file[i], file[n_files - 1], &x);
errors |= install_file_in_dir (file[i], dest, &x);
}
}
}

100
src/ls.c
View File

@@ -317,13 +317,13 @@ int inhibit_group;
static int numeric_ids;
/* Nonzero means mention the size in 512 byte blocks of each file. -s */
/* Nonzero means mention the size in blocks of each file. -s */
static int print_block_size;
/* The units to count blocks in. */
static int output_units;
/* If positive, the units to use when printing sizes;
if negative, the human-readable base. */
static int output_block_size;
/* Precede each line of long output (per file) with a string like `m,n:'
where M is the number of characters after the `:' and before the
@@ -409,10 +409,6 @@ struct col_ext_type *col_ext_list = NULL;
/* Buffer for color sequences */
static char *color_buf;
/* base used for human style output */
static int human_readable_base;
/* Nonzero means mention the inode number of each file. -i */
static int print_inode;
@@ -532,6 +528,7 @@ static struct option const long_options[] =
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
{"color", optional_argument, 0, 13},
{"block-size", required_argument, 0, 17},
{NULL, 0, NULL, 0}
};
@@ -569,14 +566,14 @@ static char const *const time_args[] =
and later output themselves. */
static size_t dired_pos;
#define PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0)
#define DIRED_PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0)
/* Write S to STREAM and increment DIRED_POS by S_LEN. */
#define FPUTS(s, stream, s_len) \
#define DIRED_FPUTS(s, stream, s_len) \
do {fputs ((s), (stream)); dired_pos += s_len;} while (0)
/* Like FPUTS, but for use when S is a literal string. */
#define FPUTS_LITERAL(s, stream) \
/* Like DIRED_FPUTS, but for use when S is a literal string. */
#define DIRED_FPUTS_LITERAL(s, stream) \
do {fputs ((s), (stream)); dired_pos += sizeof((s)) - 1;} while (0)
#define DIRED_INDENT() \
@@ -584,7 +581,7 @@ static size_t dired_pos;
{ \
/* FIXME: remove the `&& format == long_format' clause. */ \
if (dired && format == long_format) \
FPUTS_LITERAL (" ", stdout); \
DIRED_FPUTS_LITERAL (" ", stdout); \
} \
while (0)
@@ -753,7 +750,7 @@ main (int argc, char **argv)
{
print_current_files ();
if (pending_dirs)
PUTCHAR ('\n');
DIRED_PUTCHAR ('\n');
}
else if (pending_dirs && pending_dirs->next == 0)
print_dir_name = 0;
@@ -843,7 +840,6 @@ decode_switches (int argc, char **argv)
sort_reverse = 0;
numeric_ids = 0;
print_block_size = 0;
output_units = getenv ("POSIXLY_CORRECT") ? 512 : 1024;
indicator_style = none;
print_inode = 0;
trace_links = 0;
@@ -857,11 +853,7 @@ decode_switches (int argc, char **argv)
&& 0 <= (i = argmatch (p, quoting_style_args)))
set_quoting_style (NULL, (enum quoting_style) i);
if ((p = getenv ("BLOCKSIZE"))
&& strncmp (p, "HUMAN", sizeof ("HUMAN") - 1) == 0)
human_readable_base = 1024;
else if (p && STREQ (p, "SI"))
human_readable_base = 1000;
human_block_size (getenv ("LS_BLOCK_SIZE"), 0, &output_block_size);
line_length = 80;
if ((p = getenv ("COLUMNS")) && *p)
@@ -950,11 +942,11 @@ decode_switches (int argc, char **argv)
break;
case 'h':
human_readable_base = 1024;
output_block_size = -1024;
break;
case 'H':
human_readable_base = 1000;
output_block_size = -1000;
break;
case 'i':
@@ -962,7 +954,7 @@ decode_switches (int argc, char **argv)
break;
case 'k':
output_units = 1024;
output_block_size = 1024;
break;
case 'l':
@@ -1178,14 +1170,15 @@ decode_switches (int argc, char **argv)
qmark_funny_chars = 0;
break;
case 17:
human_block_size (optarg, 1, &output_block_size);
break;
default:
usage (EXIT_FAILURE);
}
}
if (human_readable_base)
output_units = 1;
filename_quoting_options = clone_quoting_options (NULL);
if (indicator_style != none)
for (p = "*=@|" + (int) indicator_style - 1; *p; p++)
@@ -1598,7 +1591,7 @@ print_dir (const char *name, const char *realname)
dired_pos += quote_name (stdout, realname ? realname : name,
dirname_quoting_options);
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
FPUTS_LITERAL (":\n", stdout);
DIRED_FPUTS_LITERAL (":\n", stdout);
}
if (format == long_format || print_block_size)
@@ -1608,19 +1601,18 @@ print_dir (const char *name, const char *realname)
DIRED_INDENT ();
p = _("total");
FPUTS (p, stdout, strlen (p));
PUTCHAR (' ');
p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_units,
human_readable_base);
FPUTS (p, stdout, strlen (p));
PUTCHAR ('\n');
DIRED_FPUTS (p, stdout, strlen (p));
DIRED_PUTCHAR (' ');
p = human_readable (total_blocks, buf, ST_NBLOCKSIZE, output_block_size);
DIRED_FPUTS (p, stdout, strlen (p));
DIRED_PUTCHAR ('\n');
}
if (files_index)
print_current_files ();
if (pending_dirs)
PUTCHAR ('\n');
DIRED_PUTCHAR ('\n');
}
/* Add `pattern' to the list of patterns for which files that match are
@@ -1802,7 +1794,7 @@ gobble_file (const char *name, int explicit_arg, const char *dirname)
{
char buf[LONGEST_HUMAN_READABLE + 1];
int len = strlen (human_readable (blocks, buf, ST_NBLOCKSIZE,
output_units, human_readable_base));
output_block_size));
if (block_size_size < len)
block_size_size = len < 7 ? len : 7;
}
@@ -2161,7 +2153,7 @@ print_current_files (void)
for (i = 0; i < files_index; i++)
{
print_long_format (files + i);
PUTCHAR ('\n');
DIRED_PUTCHAR ('\n');
}
break;
}
@@ -2240,7 +2232,7 @@ print_long_format (const struct fileinfo *f)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
sprintf (p, "%*s ", INODE_DIGITS,
human_readable ((uintmax_t) f->stat.st_ino, hbuf, 1, 1, 0));
human_readable ((uintmax_t) f->stat.st_ino, hbuf, 1, 1));
p += strlen (p);
}
@@ -2249,8 +2241,7 @@ print_long_format (const struct fileinfo *f)
char hbuf[LONGEST_HUMAN_READABLE + 1];
sprintf (p, "%*s ", block_size_size,
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), hbuf,
ST_NBLOCKSIZE, output_units,
human_readable_base));
ST_NBLOCKSIZE, output_block_size));
p += strlen (p);
}
@@ -2283,8 +2274,8 @@ print_long_format (const struct fileinfo *f)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
sprintf (p, "%8s ",
human_readable ((uintmax_t) f->stat.st_size,
hbuf, 1, 1, human_readable_base));
human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
output_block_size < 0 ? output_block_size : 1));
}
p += strlen (p);
@@ -2305,7 +2296,7 @@ print_long_format (const struct fileinfo *f)
p += s;
*p++ = ' ';
/* NUL-terminate the string -- fputs (via FPUTS) requires it. */
/* NUL-terminate the string -- fputs (via DIRED_FPUTS) requires it. */
*p = '\0';
}
else
@@ -2317,19 +2308,19 @@ print_long_format (const struct fileinfo *f)
if (when < 0)
{
const char *num = human_readable (- (uintmax_t) when, hbuf, 1, 1, 0);
const char *num = human_readable (- (uintmax_t) when, hbuf, 1, 1);
int sign_width = width - strlen (num);
sprintf (p, "%*s%s ", sign_width < 0 ? 0 : sign_width, "-", num);
}
else
sprintf (p, "%*s ", width,
human_readable ((uintmax_t) when, hbuf, 1, 1, 0));
human_readable ((uintmax_t) when, hbuf, 1, 1));
p += strlen (p);
}
DIRED_INDENT ();
FPUTS (buf, stdout, p - buf);
DIRED_FPUTS (buf, stdout, p - buf);
print_name_with_quoting (f->name, f->stat.st_mode, f->linkok,
&dired_obstack);
@@ -2337,7 +2328,7 @@ print_long_format (const struct fileinfo *f)
{
if (f->linkname)
{
FPUTS_LITERAL (" -> ", stdout);
DIRED_FPUTS_LITERAL (" -> ", stdout);
print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
NULL);
if (indicator_style != none)
@@ -2422,12 +2413,12 @@ print_file_name_and_frills (const struct fileinfo *f)
if (print_inode)
printf ("%*s ", INODE_DIGITS,
human_readable ((uintmax_t) f->stat.st_ino, buf, 1, 1, 0));
human_readable ((uintmax_t) f->stat.st_ino, buf, 1, 1));
if (print_block_size)
printf ("%*s ", block_size_size,
human_readable ((uintmax_t) ST_NBLOCKS (f->stat), buf,
ST_NBLOCKSIZE, output_units, human_readable_base));
ST_NBLOCKSIZE, output_block_size));
print_name_with_quoting (f->name, f->stat.st_mode, f->linkok, NULL);
@@ -2439,26 +2430,26 @@ static void
print_type_indicator (unsigned int mode)
{
if (S_ISDIR (mode))
PUTCHAR ('/');
DIRED_PUTCHAR ('/');
#ifdef S_ISLNK
if (S_ISLNK (mode))
PUTCHAR ('@');
DIRED_PUTCHAR ('@');
#endif
#ifdef S_ISFIFO
if (S_ISFIFO (mode))
PUTCHAR ('|');
DIRED_PUTCHAR ('|');
#endif
#ifdef S_ISSOCK
if (S_ISSOCK (mode))
PUTCHAR ('=');
DIRED_PUTCHAR ('=');
#endif
if (S_ISREG (mode) && indicator_style == classify
&& (mode & S_IXUGO))
PUTCHAR ('*');
DIRED_PUTCHAR ('*');
}
static void
@@ -2868,6 +2859,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
-a, --all do not hide entries starting with .\n\
-A, --almost-all do not list implied . and ..\n\
-b, --escape print octal escapes for nongraphic characters\n\
--block-size=SIZE use SIZE-byte blocks\n\
-B, --ignore-backups do not list implied entries ending with ~\n\
-c sort by change time; with -l: show ctime\n\
-C list entries by columns\n\
@@ -2890,7 +2882,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.\n\
none (default), classify (-F), file-type (-p)\n\
-i, --inode print index number of each file\n\
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN\n\
-k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
-k, --kilobytes like --block-size=1024\n\
-l use a long listing format\n\
-L, --dereference list entries pointed to by symbolic links\n\
-m fill width with a comma separated list of entries\n\

View File

@@ -27,11 +27,7 @@
#include "linebuffer.h"
#include "system.h"
#if WITH_REGEX
# include <regex.h>
#else
# include <rx.h>
#endif
#include <regex.h>
#include "error.h"
#include "xstrtol.h"

View File

@@ -1584,7 +1584,10 @@ print_page (void)
--lines_left_on_page;
}
if (double_space && pv && extremities)
if (cols_ready_to_print () <= 0 && !extremities)
break;
if (double_space && pv)
{
putchar ('\n');
--lines_left_on_page;

View File

@@ -412,6 +412,16 @@ fspec_filetype_mode (const struct File_spec *fs)
return fs->mode;
}
static int
same_file (const char *file_1, const char *file_2)
{
struct stat sb1, sb2;
return (lstat (file_1, &sb1) == 0
&& lstat (file_2, &sb2) == 0
&& SAME_INODE (sb1, sb2));
}
/* Recursively remove all of the entries in the current directory.
Return an indication of the success of the operation. */
@@ -625,7 +635,7 @@ remove_file (struct File_spec *fs, const struct rm_options *x)
}
if (x->verbose)
printf (_("removing non-directory %s\n"), full_filename (pathname));
printf (_("removing %s\n"), full_filename (pathname));
if (unlink (pathname) && (errno != ENOENT || !x->ignore_missing_files))
{
@@ -720,8 +730,10 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
if (x->interactive)
{
error (0, 0, _("remove directory `%s'%s? "), full_filename (dir_name),
(status != RM_OK ? _(" (might be nonempty)") : ""));
fprintf (stderr, _("%s: remove directory `%s'%s? "),
program_name,
full_filename (dir_name),
(status != RM_OK ? _(" (might be nonempty)") : ""));
if (!yesno ())
{
return RM_USER_DECLINED;
@@ -733,8 +745,24 @@ remove_dir (struct File_spec *fs, int need_save_cwd, const struct rm_options *x)
if (rmdir (dir_name) && (errno != ENOENT || !x->ignore_missing_files))
{
error (0, errno, _("cannot remove directory `%s'"),
full_filename (dir_name));
int saved_errno = errno;
#ifndef EINVAL
# define EINVAL 0
#endif
/* See if rmdir just failed because DIR_NAME is the current directory.
If so, give a better diagnostic than `rm: cannot remove directory
`...': Invalid argument' */
if (errno == EINVAL && same_file (".", dir_name))
{
error (0, 0, _("cannot remove current directory `%s'"),
full_filename (dir_name));
}
else
{
error (0, saved_errno, _("cannot remove directory `%s'"),
full_filename (dir_name));
}
return RM_ERROR;
}

View File

@@ -276,7 +276,7 @@ check_format (const char *fmt)
fmt += strspn (fmt, "-+#0");
if (ISDIGIT (*fmt))
{
fmt += strspn (fmt, "012345789");
fmt += strspn (fmt, "0123456789");
if (*fmt == '.')
fmt += strspn (++fmt, "0123456789");

View File

@@ -659,7 +659,7 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\
exit (status);
}
/* Return 1 if the string only contains valid options. */
/* Return 1 if the string contains only valid options. */
int
valid_options (char *opt, const char *valid_opts,
const char *valid_arg_opts)

View File

@@ -156,3 +156,67 @@ off_t lseek ();
/* Be CAREFUL that there are no side effects in N. */
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
/* These are wrappers for functions/macros from GNU libc.
The standard I/O functions are thread-safe. These *_unlocked ones
are more efficient but not thread-safe. That they're not thread-safe
is fine since all these applications are single threaded. */
#ifdef HAVE_CLEARERR_UNLOCKED
# undef clearerr
# define clearerr(S) clearerr_unlocked (S)
#endif
#ifdef HAVE_FEOF_UNLOCKED
# undef feof
# define feof(S) feof_unlocked (S)
#endif
#ifdef HAVE_FERROR_UNLOCKED
# undef ferror
# define ferror(S) ferror_unlocked (S)
#endif
#ifdef HAVE_FFLUSH_UNLOCKED
# undef fflush
# define fflush(S) fflush_unlocked (S)
#endif
#ifdef HAVE_FPUTC_UNLOCKED
# undef fputc
# define fputc(C, S) fputc_unlocked (C, S)
#endif
#ifdef HAVE_FREAD_UNLOCKED
# undef fread
# define fread(P, Z, N, S) fread_unlocked (P, Z, N, S)
#endif
#ifdef HAVE_FWRITE_UNLOCKED
# undef fwrite
# define fwrite(P, Z, N, S) fwrite_unlocked (P, Z, N, S)
#endif
#ifdef HAVE_GETC_UNLOCKED
# undef getc
# define getc(S) getc_unlocked (S)
#endif
#ifdef HAVE_GETCHAR_UNLOCKED
# undef getchar
# define getchar(S) getchar_unlocked (S)
#endif
#ifdef HAVE_PUTC_UNLOCKED
# undef putc
# define putc(C, S) putc_unlocked (C, S)
#endif
#ifdef HAVE_PUTCHAR_UNLOCKED
# undef putchar
# define putchar(C) putchar_unlocked (C)
#endif
#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)

View File

@@ -42,11 +42,7 @@ tac -r -s '.\|
#include <sys/types.h>
#include "system.h"
#if WITH_REGEX
# include <regex.h>
#else
# include <rx.h>
#endif
#include <regex.h>
#include "error.h"
#include "safe-read.h"

View File

@@ -2,7 +2,7 @@
/* Modified to run with the GNU shell by bfox. */
/* Copyright (C) 1987-1996, 1997 Free Software Foundation, Inc.
/* Copyright (C) 1987-1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -370,7 +370,7 @@ term (void)
value = binary_operator ();
/* Might be a switch type argument */
else if ('-' == argv[pos][0] && 0 == argv[pos][2])
else if ('-' == argv[pos][0] && argv[pos][1] && 0 == argv[pos][2])
{
if (unop (argv[pos][1]))
value = unary_operator ();
@@ -627,7 +627,7 @@ binary_operator (void)
static int
unary_operator (void)
{
long r, value;
long fd, value;
struct stat stat_buf;
switch (argv[pos][1])
@@ -784,14 +784,19 @@ unary_operator (void)
return (TRUE == (0 != (stat_buf.st_mode & S_ISVTX)));
#endif
case 't': /* File (fd) is a terminal? (fd) defaults to stdout. */
case 't': /* File (fd) is a terminal? */
advance (0);
if (pos < argc && isint (argv[pos], &r))
if (pos < argc)
{
if (!isint (argv[pos], &fd))
integer_expected_error (_("after -t"));
advance (0);
return (TRUE == (isatty ((int) r)));
}
return (TRUE == (isatty (1)));
else
{
fd = 1;
}
return (TRUE == (isatty ((int) fd)));
case 'n': /* True if arg has some length. */
unary_advance ();
@@ -873,14 +878,25 @@ unop (int op)
return (member (op, "abcdefgkLhprsStuwxOGnz"));
}
static int
one_argument (const char *s)
{
if (STREQ (s, "-t"))
return (TRUE == (isatty (1)));
return strlen (s) != 0;
}
static int
two_arguments (void)
{
int value;
if (STREQ (argv[pos], "!"))
value = strlen (argv[pos+1]) == 0;
else if ((argv[pos][0] == '-') && (argv[pos][2] == '\0'))
value = ! one_argument (argv[pos+1]);
else if (argv[pos][0] == '-'
&& argv[pos][1] != '\0'
&& argv[pos][2] == '\0')
{
if (unop (argv[pos][1]))
value = unary_operator ();
@@ -929,7 +945,7 @@ posixtest (void)
break;
case 1:
value = strlen (argv[1]) != 0;
value = one_argument (argv[1]);
pos = argc;
break;

View File

@@ -52,10 +52,6 @@ time_t posixtime ();
int full_write ();
void invalid_arg ();
#if ! HAVE_UTIME_NULL
static int utime_now ();
#endif
/* Bitmasks for `change_times'. */
#define CH_ATIME 1
#define CH_MTIME 2
@@ -171,13 +167,9 @@ touch (char *file)
if (amtime_now)
{
#if ! HAVE_UTIME_NULL
status = utime_now (file, sbuf.st_size);
#else
/* Pass NULL to utime so it will not fail if we just have
write access to the file, but don't own it. */
status = utime (file, NULL);
#endif
}
else
{
@@ -209,32 +201,6 @@ touch (char *file)
return 0;
}
#if ! HAVE_UTIME_NULL
/* Emulate utime (file, NULL) for systems (like 4.3BSD) that do not
interpret it to set the access and modification times of FILE to
the current time. FILESIZE is the correct size of FILE, used to
make sure empty files are not lengthened to 1 byte.
Return 0 if successful, -1 if not. */
static int
utime_now (const char *file, off_t filesize)
{
int fd;
char c;
int status = 0;
fd = open (file, O_RDWR, 0666);
if (fd < 0
|| safe_read (fd, &c, sizeof (char)) < 0
|| lseek (fd, (off_t) 0, SEEK_SET) < 0
|| full_write (fd, &c, sizeof (char)) < 0
|| ftruncate (fd, filesize) < 0
|| close (fd) < 0)
status = -1;
return status;
}
#endif
static void
usage (int status)
{

View File

@@ -1,5 +1,5 @@
/* GNU's uptime.
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,9 +20,9 @@
#include <config.h>
#include <getopt.h>
#include "system.h"
#include "error.h"
#include "readutmp.h"
#include "system.h"
/* The name this program was run with. */
char *program_name;

View File

@@ -1,5 +1,5 @@
/* GNU's users.
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,9 +20,9 @@
#include <config.h>
#include <getopt.h>
#include "system.h"
#include "error.h"
#include "readutmp.h"
#include "system.h"
/* The name this program was run with. */
char *program_name;

View File

@@ -111,22 +111,22 @@ write_counts (uintmax_t lines,
if (print_lines)
{
printf ("%7s", human_readable (lines, buf, 1, 1, 0));
printf ("%7s", human_readable (lines, buf, 1, 1));
space = " ";
}
if (print_words)
{
printf ("%s%7s", space, human_readable (words, buf, 1, 1, 0));
printf ("%s%7s", space, human_readable (words, buf, 1, 1));
space = " ";
}
if (print_chars)
{
printf ("%s%7s", space, human_readable (chars, buf, 1, 1, 0));
printf ("%s%7s", space, human_readable (chars, buf, 1, 1));
space = " ";
}
if (print_linelength)
{
printf ("%s%7s", space, human_readable (linelength, buf, 1, 1, 0));
printf ("%s%7s", space, human_readable (linelength, buf, 1, 1));
}
if (*file)
printf (" %s", file);

View File

@@ -1,5 +1,5 @@
/* GNU's who.
Copyright (C) 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,9 +27,9 @@
#include <config.h>
#include <getopt.h>
#include "system.h"
#include "error.h"
#include "readutmp.h"
#include "system.h"
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 64

View File

@@ -20,6 +20,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -1,6 +1,8 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = CP=../../src/cp RM=../../src/rm

View File

@@ -4,7 +4,6 @@
# 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
@@ -92,7 +91,9 @@ l = @l@
AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = CP=../../src/cp RM=../../src/rm
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs

169
tests/cp/same-file Executable file
View File

@@ -0,0 +1,169 @@
#!/bin/sh
# Test some of cp's options and how cp handles situations in
# which a naive implementation might overwrite the source file.
# FIXME: punt for now
CP=cp
if test "$VERBOSE" = yes; then
set -x
$CP --version
fi
LANGUAGE=C; export LANGUAGE
LANG=C; export LANG
VERSION_CONTROL=numbered; export VERSION_CONTROL
pwd=`pwd`
PATH=$pwd/../../src:$PATH
actual=actual-$$
expected=expected-$$
trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
exec 1> $actual
# FIXME: This should be bigger: like more than 8k
contents=XYZ
for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
for options in '' -d -f -df -b -bd -bf -bdf \
-l -dl -fl -dfl -bl -bdl -bfl -bdfl; do
case $args$options in
# These tests are not portable.
'sl1 sl2'-bd*l)
continue;;
'symlink foo'-dfl)
continue;;
'symlink foo'-bdfl)
continue;;
'sl1 sl2'-dfl)
continue;;
esac
rm -rf dir
mkdir dir
cd dir
echo $contents > foo
case "$args" in *symlink*) ln -s foo symlink ;; esac
case "$args" in *hardlink*) ln foo hardlink ;; esac
case "$args" in *sl1*) ln -s foo sl1;; esac
case "$args" in *sl2*) ln -s foo sl2;; esac
(
(
$CP $options $args 2>.err
echo $? $options
# Normalize the program name in the error output,
# and put brackets around the output.
test -s .err && echo "[`sed 's/^[^:][^:]*:/cp:/' .err`]"
# Strip off all but the file names.
ls="`ls -lG --ignore=.err . \
| sed \
-e '/^total /d' \
-e 's/^..............................................//'`"
echo "($ls)"
# Make sure the original is unchanged and that
# the destination is a copy.
for f in $args; do
if test -f $f; then
case "`cat $f`" in
"$contents") ;;
*) echo cp FAILED;;
esac
else
echo symlink-loop
fi
done
) | tr '\012' ' '
echo
) | sed 's/ *$//'
cd ..
done
echo
done
cat <<\EOF > $expected
1 [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
1 -d [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
0 -f (foo symlink)
0 -df (foo symlink)
0 -b (foo symlink symlink.~1~ -> foo)
0 -bd (foo symlink symlink.~1~ -> foo)
0 -bf (foo symlink symlink.~1~ -> foo)
0 -bdf (foo symlink symlink.~1~ -> foo)
0 -l (foo symlink -> foo)
0 -dl (foo symlink -> foo)
0 -fl (foo symlink -> foo)
0 -dfl (foo symlink)
0 -bl (foo symlink -> foo)
0 -bdl (foo symlink symlink.~1~ -> foo)
0 -bfl (foo symlink -> foo)
0 -bdfl (foo symlink symlink.~1~ -> foo)
1 [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -d [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -f [cp: `symlink' and `foo' are the same file] (symlink -> foo) symlink-loop symlink-loop
0 -df (foo -> foo symlink -> foo) symlink-loop symlink-loop
1 -b [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
0 -bd (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop
1 -bf [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
0 -bdf (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop
0 -l (foo symlink -> foo)
0 -dl (foo symlink -> foo)
0 -fl (foo symlink -> foo)
0 -bl (foo symlink -> foo)
0 -bdl (foo symlink -> foo)
0 -bfl (foo symlink -> foo)
1 [cp: `foo' and `foo' are the same file] (foo)
1 -d [cp: `foo' and `foo' are the same file] (foo)
1 -f [cp: `foo' and `foo' are the same file] () symlink-loop symlink-loop
1 -df [cp: `foo' and `foo' are the same file] () symlink-loop symlink-loop
1 -b [cp: `foo' and `foo' are the same file] (foo)
1 -bd [cp: `foo' and `foo' are the same file] (foo)
0 -bf (foo foo.~1~)
0 -bdf (foo foo.~1~)
0 -l (foo)
0 -dl (foo)
0 -fl (foo)
0 -dfl (foo)
0 -bl (foo)
0 -bdl (foo)
0 -bfl (foo foo.~1~)
0 -bdfl (foo foo.~1~)
1 [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
1 -d [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
0 -f (foo sl1 -> foo sl2)
0 -df (foo sl1 -> foo sl2 -> foo)
0 -b (foo sl1 -> foo sl2 sl2.~1~ -> foo)
0 -bd (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo)
0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
0 -l (foo sl1 -> foo sl2 -> foo)
0 -dl (foo sl1 -> foo sl2 -> foo)
0 -fl (foo sl1 -> foo sl2 -> foo)
0 -bl (foo sl1 -> foo sl2 -> foo)
0 -bfl (foo sl1 -> foo sl2 -> foo)
1 [cp: `foo' and `hardlink' are the same file] (foo hardlink)
1 -d [cp: `foo' and `hardlink' are the same file] (foo hardlink)
0 -f (foo hardlink)
0 -df (foo hardlink)
0 -b (foo hardlink hardlink.~1~)
0 -bd (foo hardlink hardlink.~1~)
0 -bf (foo hardlink hardlink.~1~)
0 -bdf (foo hardlink hardlink.~1~)
0 -l (foo hardlink)
0 -dl (foo hardlink)
0 -fl (foo hardlink)
0 -dfl (foo hardlink)
0 -bl (foo hardlink)
0 -bdl (foo hardlink)
0 -bfl (foo hardlink)
0 -bdfl (foo hardlink)
EOF
cmp $expected $actual || diff -u $expected $actual 1>&2

View File

@@ -34,6 +34,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -237,6 +237,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -40,6 +40,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -255,6 +255,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -28,6 +28,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -243,6 +243,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -33,6 +33,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -236,6 +236,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -4,7 +4,6 @@
# 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

View File

@@ -36,6 +36,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -239,6 +239,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -4,7 +4,6 @@
# 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

View File

@@ -2,6 +2,6 @@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = cr-1 time-1
TESTS = rt-1 time-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = LS=../../src/ls TOUCH=../../src/touch

View File

@@ -4,7 +4,6 @@
# 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
@@ -92,7 +91,7 @@ l = @l@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = cr-1 time-1
TESTS = rt-1 time-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = LS=../../src/ls TOUCH=../../src/touch
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs

View File

@@ -40,10 +40,10 @@ fi
fail=0
set `$LS -c a b c`
set `$LS -t a b c`
test "$*" = 'a b c' && : || fail=1
set `$LS -rc a b c`
set `$LS -rt a b c`
test "$*" = 'c b a' && : || fail=1
cd ..

View File

@@ -40,13 +40,21 @@ $TOUCH -m -d "$t3" a || test_failure=1
$TOUCH -m -d "$t2" b || test_failure=1
$TOUCH -m -d "$t1" c || test_failure=1
$TOUCH -a -d "$u1" a || test_failure=1
$TOUCH -a -d "$u2" b || test_failure=1
$TOUCH -a -d "$u3" c || test_failure=1
$TOUCH -a -d "$u2" b || test_failure=1
# Make sure A has ctime at least 1 second more recent than C's.
sleep 2
$TOUCH -a -d "$u1" a || test_failure=1
fail=0
# A has ctime more recent than C.
set `$LS -c a c`
test "$*" = 'a c' || fail=1
# Sleep so long in an attempt to avoid spurious failures
# due to NFS caching and/or clock skew.
sleep 5
sleep 2
# Create a link, updating c's ctime.
ln c d || test_failure=1
@@ -56,22 +64,23 @@ if test $test_failure = 1; then
exit 1
fi
fail=0
set `$LS -u a b c`
test "$*" = 'c b a' && : || fail=1
set `$LS -t a b c`
test "$*" = 'a b c' && : || fail=1
# C has newer ctime.
# Now, C should have ctime more recent than A.
set `$LS -c a c`
if test "$*" = 'c a'; then
: ok
else
# In spite of documentation, (e.g., stat(2)), neither link nor chmod
# update a file's st_ctime on SunOS4.1.4.
echo "failed ls ctime test -- this is expected at least for SunOS4.1.4" >&2
cat >&2 << \EOF
failed ls ctime test -- this is expected at least for SunOS4.1.4
and for tmpfs file systems on Solaris 5.5.1.
EOF
fail=1
fi

View File

@@ -24,6 +24,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -227,6 +227,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -4,7 +4,6 @@
# 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

View File

@@ -1,10 +1,11 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = mv-special-1 into-self backup-is-src
TESTS = mv-special-1 into-self into-self-2 backup-is-src
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \
DF=../../src/df \
LN=../../src/ln \
LS=../../src/ls \
MKDIR=../../src/mkdir \
MKNOD=../../src/mknod \

View File

@@ -4,7 +4,6 @@
# 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
@@ -92,10 +91,11 @@ l = @l@
AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = mv-special-1 into-self backup-is-src
TESTS = mv-special-1 into-self into-self-2 backup-is-src
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \
DF=../../src/df \
LN=../../src/ln \
LS=../../src/ls \
MKDIR=../../src/mkdir \
MKNOD=../../src/mknod \

View File

@@ -49,7 +49,7 @@ cat > exp <<\EOF
XXX: backing up `YYY' would destroy source; `ZZZ' not moved
EOF
diff -u out2 exp || fail=1
cmp out2 exp || fail=1
$RM -fr out out2 exp $a $a2 $other_partition_tmpdir

59
tests/mv/into-self-2 Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/sh
# Force mv to use the copying code.
# Consider the case where SRC and DEST are on a different
# partitions and DEST is a symlink to SRC.
: ${MV=mv}
: ${RM=rm}
: ${LN=ln}
if test "$VERBOSE" = yes; then
set -x
$MV --version
fi
. $srcdir/setup
if test -z "$other_partition_tmpdir"; then
exit 77
fi
file="$other_partition_tmpdir/file"
symlink=symlink
framework_failure=0
$RM -f $file $symlink || framework_failure=1
echo whatever > $file || framework_failure=1
$LN -s $file $symlink || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
# This mv command should exit nonzero.
$MV $file $symlink > out 2>&1 && fail=1
sed \
-e "s,$MV:,XXX:," \
-e "s,$file,YYY," \
-e "s,$symlink,ZZZ," \
out > out2
cat > exp <<\EOF
XXX: `YYY' and `ZZZ' are the same file
EOF
cmp out2 exp || fail=1
$RM -fr out out2 exp $file $symlink $other_partition_tmpdir
exit $fail

View File

@@ -50,7 +50,7 @@ sed "s,$other_partition_tmpdir,XXX," out > out2
cat > exp <<\EOF
.mv-null -> XXX/.mv-null
removing non-directory .mv-null
removing .mv-null
.mv-dir -> XXX/.mv-dir
.mv-dir/a -> XXX/.mv-dir/a
.mv-dir/a/b -> XXX/.mv-dir/a/b
@@ -64,14 +64,14 @@ removing all entries of directory .mv-dir
removing all entries of directory .mv-dir/a
removing all entries of directory .mv-dir/a/b
removing all entries of directory .mv-dir/a/b/c
removing non-directory .mv-dir/a/b/c/file1
removing .mv-dir/a/b/c/file1
removing the directory itself: .mv-dir/a/b/c
removing the directory itself: .mv-dir/a/b
removing the directory itself: .mv-dir/a
removing all entries of directory .mv-dir/d
removing all entries of directory .mv-dir/d/e
removing all entries of directory .mv-dir/d/e/f
removing non-directory .mv-dir/d/e/f/file2
removing .mv-dir/d/e/f/file2
removing the directory itself: .mv-dir/d/e/f
removing the directory itself: .mv-dir/d/e
removing the directory itself: .mv-dir/d

View File

@@ -21,7 +21,7 @@ tFFt-bl tFFt-lm tFnFt ta3-0FF ta3-FF tb3-0FF tb3-FF tn tt-0FF tt-FF tt-bl \
tt-t tta3-0FF tta3-FF ttb3-0FF ttb3-FF w20l17f-lm w25l17f-lm w26l17f-lm \
w35a3l17f-lm w35b3l17f-lm w35ja3l17f-lm w35jb3l17f-lm w35jml17f-lmlo \
w35ml17f-lm-lo w48l17f-lm w72j-0FF
maint_gen = margin-0.I margin-0.X
maint_gen = margin-0.I margin-0.X dbl-sp-a.I dbl-sp-a.X dbl-sp-b.I dbl-sp-b.X
run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 1g.O \
1g.E 1h.O 1h.E 1i.O 1i.E 1j.O 1j.E 1k.O 1k.E 1l.O 1l.E 2a.O 2a.E 2b.O 2b.E \
2c.O 2c.E 2d.O 2d.E 2e.O 2e.E 2f.O 2f.E 2g.O 2g.E 2h.O 2h.E 2i.O 2i.E 2j.O \
@@ -56,7 +56,7 @@ run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 1g.O \
10bd.E 11a.O 11a.E 11b.O 11b.E 11e.O 11e.E 11f.O 11f.E 11g.O 11g.E 11h.O \
11h.E 12aa.O 12aa.E 12ab.O 12ab.E 12ac.O 12ac.E 12ba.O 12ba.E 12bb.O 12bb.E \
12bc.O 12bc.E 12ma.O 12ma.E 12mb.O 12mb.E 12mc.O 12mc.E 12md.O 12md.E \
margin-0.O margin-0.E
margin-0.O margin-0.E dbl-sp-a.O dbl-sp-a.E dbl-sp-b.O dbl-sp-b.E
##test-files-end
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
@@ -76,6 +76,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -107,7 +107,7 @@ tFFt-bl tFFt-lm tFnFt ta3-0FF ta3-FF tb3-0FF tb3-FF tn tt-0FF tt-FF tt-bl \
tt-t tta3-0FF tta3-FF ttb3-0FF ttb3-FF w20l17f-lm w25l17f-lm w26l17f-lm \
w35a3l17f-lm w35b3l17f-lm w35ja3l17f-lm w35jb3l17f-lm w35jml17f-lmlo \
w35ml17f-lm-lo w48l17f-lm w72j-0FF
maint_gen = margin-0.I margin-0.X
maint_gen = margin-0.I margin-0.X dbl-sp-a.I dbl-sp-a.X dbl-sp-b.I dbl-sp-b.X
run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 1g.O \
1g.E 1h.O 1h.E 1i.O 1i.E 1j.O 1j.E 1k.O 1k.E 1l.O 1l.E 2a.O 2a.E 2b.O 2b.E \
2c.O 2c.E 2d.O 2d.E 2e.O 2e.E 2f.O 2f.E 2g.O 2g.E 2h.O 2h.E 2i.O 2i.E 2j.O \
@@ -142,7 +142,7 @@ run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 1g.O \
10bd.E 11a.O 11a.E 11b.O 11b.E 11e.O 11e.E 11f.O 11f.E 11g.O 11g.E 11h.O \
11h.E 12aa.O 12aa.E 12ab.O 12ab.E 12ac.O 12ac.E 12ba.O 12ba.E 12bb.O 12bb.E \
12bc.O 12bc.E 12ma.O 12ma.E 12mb.O 12mb.E 12mc.O 12mc.E 12md.O 12md.E \
margin-0.O margin-0.E
margin-0.O margin-0.E dbl-sp-a.O dbl-sp-a.E dbl-sp-b.O dbl-sp-b.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
@@ -279,6 +279,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -263,6 +263,12 @@ my @tv = (
['12md', '-o3 -j -m -l17 -f', [\'tFFt-lm', \'loli'], [\'o3jml17f-lm-lo'], 0],
['margin-0', '-o 0', '', '', 0],
# FIXME: that leading space on 3rd line of output should not be there
['dbl-sp-a', '-d -l 14 -h ""', "1\n2\n", "\n\n \n\n\n1\n\n2\n\n\n\n\n\n\n", 0],
# This test failed with 1.22e and earlier.
['dbl-sp-b', '-d -t', "1\n2\n", "1\n\n2\n\n", 0],
);
#']]);

View File

@@ -3707,8 +3707,42 @@ else
esac
fi
test -s margin-0.E || rm -f margin-0.E
$xx --test -h x -d -l 14 -h "" $srcdir/dbl-sp-a.I > dbl-sp-a.O 2> dbl-sp-a.E
code=$?
if test $code != 0 ; then
$echo "Test dbl-sp-a failed: ../../src/pr return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp dbl-sp-a.O $srcdir/dbl-sp-a.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed dbl-sp-a"; fi ;;
1) $echo "Test dbl-sp-a failed: files dbl-sp-a.O and $srcdir/dbl-sp-a.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test dbl-sp-a may have failed." 1>&2;
$echo The command "cmp dbl-sp-a.O $srcdir/dbl-sp-a.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s dbl-sp-a.E || rm -f dbl-sp-a.E
$xx --test -h x -d -t $srcdir/dbl-sp-b.I > dbl-sp-b.O 2> dbl-sp-b.E
code=$?
if test $code != 0 ; then
$echo "Test dbl-sp-b failed: ../../src/pr return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp dbl-sp-b.O $srcdir/dbl-sp-b.X > /dev/null 2>&1
case $? in
0) if test "$VERBOSE" ; then $echo "passed dbl-sp-b"; fi ;;
1) $echo "Test dbl-sp-b failed: files dbl-sp-b.O and $srcdir/dbl-sp-b.X differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test dbl-sp-b may have failed." 1>&2;
$echo The command "cmp dbl-sp-b.O $srcdir/dbl-sp-b.X" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s dbl-sp-b.E || rm -f dbl-sp-b.E
if test $errors = 0 ; then
$echo Passed all 217 tests. 1>&2
$echo Passed all 219 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi

View File

@@ -4,7 +4,6 @@
# 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

View File

@@ -25,7 +25,7 @@ removing all entries of directory $tmp/a
removing all entries of directory $tmp/a/a
removing the directory itself: $tmp/a/a
removing the directory itself: $tmp/a
removing non-directory $tmp/b
removing $tmp/b
EOF
if test $test_failure = 1; then

View File

@@ -20,9 +20,9 @@ mkdir $tmp $tmp/a $tmp/a/b
cat <<EOF > $tmp/$test.E
removing all entries of directory $tmp/a
removing all entries of directory $tmp/a/b
removing non-directory $tmp/a/b/g
removing $tmp/a/b/g
removing the directory itself: $tmp/a/b
removing non-directory $tmp/a/f
removing $tmp/a/f
removing the directory itself: $tmp/a
EOF

View File

@@ -56,6 +56,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -259,6 +259,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -36,6 +36,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -239,6 +239,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -38,6 +38,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

View File

@@ -241,6 +241,8 @@ $(srcdir)/$x-tests: $(mk_script) Test.pm
mv $@.n $@
chmod 755 $@
check: $(maint_gen)
Makefile.am: ../Makefile.am.in Test.pm $(mk_script)
rm -f $@ $@t
sed -n '1,/^##test-files-begin/p' $< > $@t

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